From 27d94d7e4030324ebce07b4ef186c6ff22cbbacd Mon Sep 17 00:00:00 2001 From: michal Date: Thu, 30 Jun 2011 15:27:55 +0200 Subject: [PATCH 247/247] [#1198068] Confusing behavior with IMCE button implimentation --- plugins/imce/plugin.js | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-) diff --git a/plugins/imce/plugin.js b/plugins/imce/plugin.js index a0b04e4..b8e7d5c 100644 --- a/plugins/imce/plugin.js +++ b/plugins/imce/plugin.js @@ -11,29 +11,29 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { init: function( editor ) { - //adding button + //adding button editor.ui.addButton( 'IMCE', { label: 'IMCE', command: 'IMCEWindow', icon: this.path + 'images/icon.png' }); - + //opening imce window editor.addCommand( 'IMCEWindow', { exec : function () { var width = editor.config.filebrowserWindowWidth || '80%', height = editor.config.filebrowserWindowHeight || '70%'; - + editor.popup(Drupal.settings.basePath + 'index.php?q=imce\x26app=ckeditor|sendto@ckeditor_setFile|&CKEditorFuncNum=' + editor._.filebrowserFnIMCE, width, height); } }); - + //add editor function editor._.filebrowserFnIMCE = CKEDITOR.tools.addFunction( setFile, editor ) - + //function which receive imce response - window.ckeditor_setFile = function (file, win) { + window.ckeditor_setFile = function (file, win) { var cfunc = win.location.href.split('&'); for (var x in cfunc) { if (cfunc[x].match(/^CKEditorFuncNum=\d+$/)) { @@ -44,24 +44,36 @@ For licensing, see LICENSE.html or http://ckeditor.com/license CKEDITOR.tools.callFunction(cfunc[1], file); win.close(); }; - + } } ); function setFile(file) { - var sel = this.getSelection(), - text = sel.getSelectedText(); + + if (Drupal.ckeditorCompareVersion('3.6.1')) + { + //fix for IE6 - editor looses focus after clicking on IMCE button + if(CKEDITOR.env.ie6Compat ) + { + this.focus(); + } + var text = this.getSelection().getSelectedText(); + }else{ + var text = ''; + } if (file.width != 0 && file.height != 0) { if (text) { this.insertHtml('' + text + ''); } else { this.insertHtml('' + file.name + ''); } - } else { + } else { if (text) { this.insertHtml('' + text + ''); } else { this.insertHtml('' + file.name + ''); } } + } + } )(); -- 1.7.4.msysgit.0