12345 |
- /*
- Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
- For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
- */
- CKEDITOR.plugins.add("panelbutton",{requires:"button",onLoad:function(){function t(t){var e=this._;e.state!=CKEDITOR.TRISTATE_DISABLED&&(this.createPanel(t),e.on?e.panel.hide():e.panel.showBlock(this._.id,this.document.getById(this._.id),4))}CKEDITOR.ui.panelButton=CKEDITOR.tools.createClass({base:CKEDITOR.ui.button,$:function(e){var n=e.panel||{};delete e.panel,this.base(e),this.document=n.parent&&n.parent.getDocument()||CKEDITOR.document,n.block={attributes:n.attributes},n.toolbarRelated=!0,this.hasArrow="listbox",this.click=t,this._={panelDefinition:n}},statics:{handler:{create:function(t){return new CKEDITOR.ui.panelButton(t)}}},proto:{createPanel:function(t){var e=this._;if(!e.panel){var n=this._.panelDefinition,o=this._.panelDefinition.block,a=n.parent||CKEDITOR.document.getBody(),s=this._.panel=new CKEDITOR.ui.floatPanel(t,a,n),n=s.addBlock(e.id,o),i=this,l=t.getCommand(this.command);s.onShow=function(){i.className&&this.element.addClass(i.className+"_panel"),i.setState(CKEDITOR.TRISTATE_ON),e.on=1,i.editorFocus&&t.focus(),i.onOpen&&i.onOpen()},s.onHide=function(n){i.className&&this.element.getFirst().removeClass(i.className+"_panel"),!i.modes&&l?i.setStateFromCommand(l):i.setState(i.modes&&i.modes[t.mode]?CKEDITOR.TRISTATE_OFF:CKEDITOR.TRISTATE_DISABLED),e.on=0,!n&&i.onClose&&i.onClose()},s.onEscape=function(){s.hide(1),i.document.getById(e.id).focus()},this.onBlock&&this.onBlock(s,n),n.onHide=function(){e.on=0,!i.modes&&i.command?i.setStateFromCommand(l):i.setState(CKEDITOR.TRISTATE_OFF)}}},setStateFromCommand:function(t){this.setState(t.state)}}})},beforeInit:function(t){t.ui.addHandler(CKEDITOR.UI_PANELBUTTON,CKEDITOR.ui.panelButton.handler)}}),CKEDITOR.UI_PANELBUTTON="panelbutton";
|