From: Sven Schöling Date: Tue, 5 Sep 2017 08:30:21 +0000 (+0200) Subject: CKEditor: Fixes für texteditor in popup_dialog X-Git-Tag: release-3.5.4~832 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5a392100ac0460c91f1d231530621fb02878b552;p=kivitendo-erp.git CKEditor: Fixes für texteditor in popup_dialog - data field kanonisch auf data('ckeditorInstance') geändert - jQuery style $.ckeditor hooks auf editor.on('loaded') geändert, der Adapter unterstützt kein inline - mehrfachinitialisierung unterbunden - selectall und focus Funktionalität in zwei Funktionen getrennt - focus auf die API Methode .focus() umgestellt --- diff --git a/js/kivi.js b/js/kivi.js index b4608c9f0..4e415d97f 100644 --- a/js/kivi.js +++ b/js/kivi.js @@ -157,41 +157,39 @@ namespace("kivi", function(ns) { }; ns.focus_ckeditor_when_ready = function(element) { - $(element).ckeditor(function() { ns.focus_ckeditor(element); }); + $(element).data('ckeditorInstance').on('instanceReady', function() { ns.focus_ckeditor(element); }); }; ns.focus_ckeditor = function(element) { - var editor = $(element).ckeditorGet(); - var editable = editor.editable(); - - if (editable.is('textarea')) { - var textarea = editable.$; - - if (CKEDITOR.env.ie) - textarea.createTextRange().execCommand('SelectAll'); - else { - textarea.selectionStart = 0; - textarea.selectionEnd = textarea.value.length; - } - - textarea.focus(); - - } else { - if (editable.is('body')) - editor.document.$.execCommand('SelectAll', false, null); + $(element).data('ckeditorInstance').focus(); + }; - else { - var range = editor.createRange(); - range.selectNodeContents(editable); - range.select(); - } + ns.selectall_ckeditor = function(element) { + var editor = $(element).ckeditorGet(); + var editable = editor.editable(); + if (editable.is('textarea')) { + var textarea = editable.$; + + if (CKEDITOR.env.ie) + textarea.createTextRange().execCommand('SelectAll'); + else { + textarea.selectionStart = 0; + textarea.selectionEnd = textarea.value.length; + } + } else { + if (editable.is('body')) + editor.document.$.execCommand('SelectAll', false, null); - editor.forceNextSelectionCheck(); - editor.selectionChange(); + else { + var range = editor.createRange(); + range.selectNodeContents(editable); + range.select(); + } - editor.focus(); - } - }; + editor.forceNextSelectionCheck(); + editor.selectionChange(); + } + } ns.init_tabwidget = function(element) { var $element = $(element); @@ -228,14 +226,14 @@ namespace("kivi", function(ns) { title: false }; - config.height = $e.height(); - config.width = $e.width(); + config.height = $e.height(); + config.width = $e.width(); var editor = CKEDITOR.inline($e.get(0), config); - $e.data('editor', editor); + $e.data('ckeditorInstance', editor); if ($e.hasClass('texteditor-autofocus')) - $e.ckeditor(function() { ns.focus_ckeditor($e); }); + editor.on('instanceReady', function() { ns.focus_ckeditor($e); }); }; ns.reinit_widgets = function() {