CKEDITOR.plugins.add('gallery',{init:function(a){a.addCommand('gallery',new CKEDITOR.dialogCommand('gallery'));a.ui.addButton('Gallery',{label:'图集',command:'gallery'});CKEDITOR.dialog.add('gallery',this.path+'dialogs/gallery.js');a.addCss('img.cke_gallery{background-image: url('+CKEDITOR.getUrl(this.path+'images/anchor.gif')+');'+'background-position: center center;'+'background-repeat: no-repeat;'+'clear: both;'+'display: block;'+'float: none;'+'border: 1px solid #a9a9a9;'+'width: 100px;'+'height: 100px;'+'page-break-after: always;'+'}');a.on('selectionChange',function(b){var c=a.getCommand('unlink'),d=b.data.path.lastElement.getAscendant('a',true);if(d&&d.getName()=='a'&&d.getAttribute('href'))c.setState(CKEDITOR.TRISTATE_OFF);else c.setState(CKEDITOR.TRISTATE_DISABLED);});a.on('doubleclick',function(b){var c=CKEDITOR.plugins.link.getSelectedLink(a)||b.data.element;if(c.is('div'))b.data.dialog='gallery';else if(c.is('img')&&c.getAttribute('_cke_real_element_type')=='div')b.data.dialog='gallery';});},afterInit:function(a){var b=a.dataProcessor,c=b&&b.dataFilter;if(c)c.addRules({elements:{div:function(d){var e=d.attributes,f=e&&e.style,g=e['class']||'';if(g.toLowerCase()=='php168_gallery'&&/display\s*:\s*none/i.test(f))return a.createFakeParserElement(d,'cke_gallery','div');}}});},requires:['fakeobjects']});CKEDITOR.plugins.gallery={getSelectedLink:function(a){var b;try{b=a.getSelection().getRanges()[0];}catch(d){return null;}b.shrink(CKEDITOR.SHRINK_TEXT);var c=b.getCommonAncestor();return c.getAscendant('a',true);}};
