From a1afd8bc466a171d842f4a49a278773a9820e9c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Fri, 1 Aug 2014 10:44:53 +0200 Subject: [PATCH 1/1] =?utf8?q?D=C3=A9sactivation=20de=20la=20combo=20des?= =?utf8?q?=20style=20lorsque=20la=20s=C3=A9lection=20est=20discontinue.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/ckeditor/plugins/plinn_styles/plugin.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/skins/ckeditor/plugins/plinn_styles/plugin.js b/skins/ckeditor/plugins/plinn_styles/plugin.js index 7301c07..742a40a 100644 --- a/skins/ckeditor/plugins/plinn_styles/plugin.js +++ b/skins/ckeditor/plugins/plinn_styles/plugin.js @@ -1,3 +1,4 @@ +/* © 2014 Benoît Pin, MINES ParisTech */ ( function() { var PlinnStylesCombo = function(editor) { @@ -13,6 +14,20 @@ var PlinnStylesCombo = function(editor) { this.styles = []; }; +PlinnStylesCombo.prototype.onRender = function() { + var self = this; + this.editor.on('selectionChange', function(evt){self.checkSelection(evt);}); +}; + +PlinnStylesCombo.prototype.checkSelection = function(evt) { + if (evt.data.selection.getRanges().length > 1) { + this.disable(); + } + else { + this.enable(); + } +}; + PlinnStylesCombo.prototype.loadStyle = function(definition) { this.styles.push(definition); this.styles[definition.name] = definition; @@ -66,7 +81,7 @@ PlinnStylePlugin.prototype.init = function(editor) { this.combo = new PlinnStylesCombo(editor); editor.ui.addRichCombo('PlinnStyles', this.combo); var self = this; - editor.on('stylesSet', function(evt){self.onStylesSet(evt)}); + editor.on('stylesSet', function(evt){self.onStylesSet(evt);}); }; PlinnStylePlugin.prototype.onStylesSet = function(evt) { -- 2.20.1