From 187b034b0af24a510881b242c280be776e789a2f Mon Sep 17 00:00:00 2001 From: Katochimoto Date: Wed, 19 Aug 2015 14:41:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D1=80=D0=B0=D0=B3=20=D0=BA=D0=B0=D1=80?= =?UTF-8?q?=D1=82=D0=B8=D0=BD=D0=BA=D0=B8=20=D1=81=20=D0=B2=D1=80=D0=B0?= =?UTF-8?q?=D0=BF=D0=BF=D0=B5=D1=80=D0=BE=D0=BC=20=D0=B2=20=D1=81=D0=B0?= =?UTF-8?q?=D1=84=D0=B0=D1=80=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- plugin.js | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index fcfeabb..72eba93 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ckeditor-imgresize", - "version": "1.0.11", + "version": "1.0.12", "description": "CKEditor dragable image resizing with support divarea", "keywords": [ "ckeditor", diff --git a/plugin.js b/plugin.js index eceb0c8..6ae3d13 100644 --- a/plugin.js +++ b/plugin.js @@ -122,7 +122,7 @@ return; } - this._imgresize.show(new CKEDITOR.dom.element(nativeEvent.target)); + this._imgresize.toggle(new CKEDITOR.dom.element(nativeEvent.target)); } }); @@ -138,12 +138,21 @@ 'beforeCommandExec': { 'restoreFocus': true }, 'beforeSetMode': null, 'destroy': null, - 'dragstart': null, + 'dragstart': { 'restoreFocus': true }, 'paste': null, 'readOnly': null }; - Resizer.prototype.show = function(element) { + Resizer.prototype.toggle = function(element) { + if (this._wrapper) { + this._hideWrapper({ 'listenerData': { 'restoreFocus': true } }); + + } else { + this._showWrapper(element); + } + }; + + Resizer.prototype._showWrapper = function(element) { this._element = element; this._wrapper = this._getWrapper(this._element); @@ -162,8 +171,8 @@ this._controls = this._wrapper.findOne('.cke_imgresize_controls'); this._preview = this._wrapper.findOne('.cke_imgresize_preview'); - this._wrapper.on('drag:start', this._onDragStart, this); this._wrapper.on('drag:drag', this._onDragDrag, this); + this._wrapper.on('drag:start', this._onDragStart, this); this._wrapper.on('drag:stop', this._onDragStop, this); this._wrapper.on('mousedown', this._initDrag, this, null, 0); this._wrapper.once('blur', this._hideWrapper, this, { 'restoreFocus': true }, 0);