From 5a392100ac0460c91f1d231530621fb02878b552 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 5 Sep 2017 10:30:21 +0200 Subject: [PATCH] =?utf8?q?CKEditor:=20Fixes=20f=C3=BCr=20texteditor=20in?= =?utf8?q?=20popup=5Fdialog?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - 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 --- js/kivi.js | 64 ++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) 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() { -- 2.20.1