X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fpanelbutton%2Fplugin.js;h=eba97cd3ff4cf29ab8bb1a8d59939dda7a051bd2;hp=44d5699c76ba669e73e49e5ce5227aaa2f112012;hb=f0610347140239143439a511ee2bd48cb784f470;hpb=4e70ea24db840898be8cc21c950363a52a2a6aba diff --git a/_source/plugins/panelbutton/plugin.js b/_source/plugins/panelbutton/plugin.js index 44d5699..eba97cd 100644 --- a/_source/plugins/panelbutton/plugin.js +++ b/_source/plugins/panelbutton/plugin.js @@ -6,141 +6,139 @@ For licensing, see LICENSE.html or http://ckeditor.com/license CKEDITOR.plugins.add( 'panelbutton', { requires : [ 'button' ], - beforeInit : function( editor ) + onLoad : function() { - editor.ui.addHandler( CKEDITOR.UI_PANELBUTTON, CKEDITOR.ui.panelButton.handler ); - } -}); + function clickFn( editor ) + { + var _ = this._; -/** - * Button UI element. - * @constant - * @example - */ -CKEDITOR.UI_PANELBUTTON = 'panelbutton'; + if ( _.state == CKEDITOR.TRISTATE_DISABLED ) + return; -(function() -{ - var clickFn = function( editor ) - { - var _ = this._; + this.createPanel( editor ); - if ( _.state == CKEDITOR.TRISTATE_DISABLED ) - return; - - this.createPanel( editor ); + if ( _.on ) + { + _.panel.hide(); + return; + } - if ( _.on ) - { - _.panel.hide(); - return; + _.panel.showBlock( this._.id, this.document.getById( this._.id ), 4 ); } - _.panel.showBlock( this._.id, this.document.getById( this._.id ), 4 ); - }; - - - CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass( - { - base : CKEDITOR.ui.button, - - $ : function( definition ) + CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass( { - // We don't want the panel definition in this object. - var panelDefinition = definition.panel; - delete definition.panel; + base : CKEDITOR.ui.button, - this.base( definition ); + $ : function( definition ) + { + // We don't want the panel definition in this object. + var panelDefinition = definition.panel; + delete definition.panel; - this.document = ( panelDefinition - && panelDefinition.parent - && panelDefinition.parent.getDocument() ) - || CKEDITOR.document; + this.base( definition ); - panelDefinition.block = - { - attributes : panelDefinition.attributes - }; + this.document = ( panelDefinition + && panelDefinition.parent + && panelDefinition.parent.getDocument() ) + || CKEDITOR.document; - this.hasArrow = true; + panelDefinition.block = + { + attributes : panelDefinition.attributes + }; - this.click = clickFn; + this.hasArrow = true; - this._ = - { - panelDefinition : panelDefinition - }; - }, + this.click = clickFn; - statics : - { - handler : + this._ = + { + panelDefinition : panelDefinition + }; + }, + + statics : { - create : function( definition ) + handler : { - return new CKEDITOR.ui.panelButton( definition ); + create : function( definition ) + { + return new CKEDITOR.ui.panelButton( definition ); + } } - } - }, + }, - proto : - { - createPanel : function( editor ) + proto : { - var _ = this._; + createPanel : function( editor ) + { + var _ = this._; - if ( _.panel ) - return; + if ( _.panel ) + return; - var panelDefinition = this._.panelDefinition || {}, - panelBlockDefinition = this._.panelDefinition.block, - panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(), - panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ), - block = panel.addBlock( _.id, panelBlockDefinition ), - me = this; + var panelDefinition = this._.panelDefinition || {}, + panelBlockDefinition = this._.panelDefinition.block, + panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(), + panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ), + block = panel.addBlock( _.id, panelBlockDefinition ), + me = this; - panel.onShow = function() - { - if ( me.className ) - this.element.getFirst().addClass( me.className + '_panel' ); + panel.onShow = function() + { + if ( me.className ) + this.element.getFirst().addClass( me.className + '_panel' ); - me.setState( CKEDITOR.TRISTATE_ON ); + me.setState( CKEDITOR.TRISTATE_ON ); - _.on = 1; + _.on = 1; - if ( me.onOpen ) - me.onOpen(); - }; + if ( me.onOpen ) + me.onOpen(); + }; - panel.onHide = function( preventOnClose ) - { - if ( me.className ) - this.element.getFirst().removeClass( me.className + '_panel' ); + panel.onHide = function( preventOnClose ) + { + if ( me.className ) + this.element.getFirst().removeClass( me.className + '_panel' ); - me.setState( me.modes && me.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED ); + me.setState( me.modes && me.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED ); - _.on = 0; + _.on = 0; - if ( !preventOnClose && me.onClose ) - me.onClose(); - }; + if ( !preventOnClose && me.onClose ) + me.onClose(); + }; - panel.onEscape = function() - { - panel.hide(); - me.document.getById( _.id ).focus(); - }; + panel.onEscape = function() + { + panel.hide(); + me.document.getById( _.id ).focus(); + }; - if ( this.onBlock ) - this.onBlock( panel, block ); + if ( this.onBlock ) + this.onBlock( panel, block ); - block.onHide = function() - { - _.on = 0; - me.setState( CKEDITOR.TRISTATE_OFF ); - }; + block.onHide = function() + { + _.on = 0; + me.setState( CKEDITOR.TRISTATE_OFF ); + }; + } } - } - }); + }); -})(); + }, + beforeInit : function( editor ) + { + editor.ui.addHandler( CKEDITOR.UI_PANELBUTTON, CKEDITOR.ui.panelButton.handler ); + } +}); + +/** + * Button UI element. + * @constant + * @example + */ +CKEDITOR.UI_PANELBUTTON = 'panelbutton';