X-Git-Url: https://scm.cri.mines-paristech.fr/git/ckeditor.git/blobdiff_plain/cefda675a7663b0fb54a048687d36898555f0fe1..e7f8fb547940c134de50db80ffaf54be1135ca7b:/skins/ckeditor/plugins/plinn_styles/plugin.js diff --git a/skins/ckeditor/plugins/plinn_styles/plugin.js b/skins/ckeditor/plugins/plinn_styles/plugin.js index 7301c07..835b08b 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; @@ -23,18 +38,18 @@ PlinnStylesCombo.prototype.init = function() { for (i=0 ; i < this.styles.length ; i++) { style = this.styles[i]; this.add(style.name, - '
' + - style.name + - '
', - style.name - ); + '
' + + style.name + + '
', + style.name + ); } }; PlinnStylesCombo.prototype.onClick = function(value) { this.editor.focus(); this.editor.fire('saveSnapshot'); - var style = this.styles[value] + var style = this.styles[value]; var className = style.className; var ranges = this.editor.getSelection().getRanges(); var element = this.editor.elementPath().lastElement; @@ -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) {