]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js
WordPress 3.8
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / wpgallery / editor_plugin.js
index 6d18b2a0bba06ad5c4bbd90d28f8f3b72b803d13..cd426627b295905a57af652d4d11c289bc94483d 100644 (file)
@@ -1 +1 @@
-(function(){tinymce.create("tinymce.plugins.wpGallery",{init:function(a,b){var c=this;c.url=b;c.editor=a;c._createButtons();a.addCommand("WP_Gallery",function(){if(tinymce.isIE){a.selection.moveToBookmark(a.wpGalleryBookmark)}var e=a.selection.getNode(),d=wp.media.gallery,f;if(typeof wp==="undefined"||!wp.media||!wp.media.gallery){return}if(e.nodeName!="IMG"||a.dom.getAttrib(e,"class").indexOf("wpGallery")==-1){return}f=d.edit("["+a.dom.getAttrib(e,"title")+"]");f.state("gallery-edit").on("update",function(g){var h=d.shortcode(g).string().slice(1,-1);a.dom.setAttrib(e,"title",h)})});a.onInit.add(function(d){if("ontouchstart" in window){d.dom.events.add(d.getBody(),"touchstart",function(g){var f=g.target;if(f.nodeName=="IMG"&&d.dom.hasClass(f,"wpGallery")){d.selection.select(f);d.dom.events.cancel(g);d.plugins.wordpress._hideButtons();d.plugins.wordpress._showButtons(f,"wp_gallerybtns")}})}});a.onMouseDown.add(function(d,f){if(f.target.nodeName=="IMG"&&d.dom.hasClass(f.target,"wpGallery")){d.plugins.wordpress._hideButtons();d.plugins.wordpress._showButtons(f.target,"wp_gallerybtns")}});a.onBeforeSetContent.add(function(d,e){e.content=c._do_gallery(e.content)});a.onPostProcess.add(function(d,e){if(e.get){e.content=c._get_gallery(e.content)}})},_do_gallery:function(a){return a.replace(/\[gallery([^\]]*)\]/g,function(d,c){return'<img src="'+tinymce.baseURL+'/plugins/wpgallery/img/t.gif" class="wpGallery mceItem" title="gallery'+tinymce.DOM.encode(c)+'" />'})},_get_gallery:function(b){function a(c,d){d=new RegExp(d+'="([^"]+)"',"g").exec(c);return d?tinymce.DOM.decode(d[1]):""}return b.replace(/(?:<p[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g,function(e,d){var c=a(d,"class");if(c.indexOf("wpGallery")!=-1){return"<p>["+tinymce.trim(a(d,"title"))+"]</p>"}return e})},_createButtons:function(){var b=this,a=tinymce.activeEditor,d=tinymce.DOM,e,c,f;if(d.get("wp_gallerybtns")){return}f=(window.devicePixelRatio&&window.devicePixelRatio>1)||(window.matchMedia&&window.matchMedia("(min-resolution:130dpi)").matches);d.add(document.body,"div",{id:"wp_gallerybtns",style:"display:none;"});e=d.add("wp_gallerybtns","img",{src:f?b.url+"/img/edit-2x.png":b.url+"/img/edit.png",id:"wp_editgallery",width:"24",height:"24",title:a.getLang("wordpress.editgallery")});tinymce.dom.Event.add(e,"mousedown",function(h){var g=tinymce.activeEditor;g.wpGalleryBookmark=g.selection.getBookmark("simple");g.execCommand("WP_Gallery");g.plugins.wordpress._hideButtons()});c=d.add("wp_gallerybtns","img",{src:f?b.url+"/img/delete-2x.png":b.url+"/img/delete.png",id:"wp_delgallery",width:"24",height:"24",title:a.getLang("wordpress.delgallery")});tinymce.dom.Event.add(c,"mousedown",function(i){var g=tinymce.activeEditor,h=g.selection.getNode();if(h.nodeName=="IMG"&&g.dom.hasClass(h,"wpGallery")){g.dom.remove(h);g.execCommand("mceRepaint");g.dom.events.cancel(i)}g.plugins.wordpress._hideButtons()})},getInfo:function(){return{longname:"Gallery Settings",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wpgallery",tinymce.plugins.wpGallery)})();
\ No newline at end of file
+!function(){tinymce.create("tinymce.plugins.wpGallery",{init:function(a,b){var c=this;c.url=b,c.editor=a,c._createButtons(),a.addCommand("WP_Gallery",function(){tinymce.isIE&&a.selection.moveToBookmark(a.wpGalleryBookmark);var b,c=a.selection.getNode(),d=wp.media.gallery;"undefined"!=typeof wp&&wp.media&&wp.media.gallery&&"IMG"==c.nodeName&&-1!=a.dom.getAttrib(c,"class").indexOf("wp-gallery")&&(b=d.edit("["+a.dom.getAttrib(c,"title")+"]"),b.state("gallery-edit").on("update",function(b){var e=d.shortcode(b).string().slice(1,-1);a.dom.setAttrib(c,"title",e)}))}),a.onInit.add(function(a){"ontouchstart"in window&&a.dom.events.add(a.getBody(),"touchstart",function(b){var c=b.target;"IMG"==c.nodeName&&a.dom.hasClass(c,"wp-gallery")&&(a.selection.select(c),a.dom.events.cancel(b),a.plugins.wordpress._hideButtons(),a.plugins.wordpress._showButtons(c,"wp_gallerybtns"))})}),a.onMouseDown.add(function(a,b){"IMG"==b.target.nodeName&&a.dom.hasClass(b.target,"wp-gallery")&&(a.plugins.wordpress._hideButtons(),a.plugins.wordpress._showButtons(b.target,"wp_gallerybtns"))}),a.onBeforeSetContent.add(function(a,b){b.content=c._do_gallery(b.content)}),a.onPostProcess.add(function(a,b){b.get&&(b.content=c._get_gallery(b.content))})},_do_gallery:function(a){return a.replace(/\[gallery([^\]]*)\]/g,function(a,b){return'<img src="'+tinymce.baseURL+'/plugins/wpgallery/img/t.gif" class="wp-gallery mceItem" title="gallery'+tinymce.DOM.encode(b)+'" />'})},_get_gallery:function(a){function b(a,b){return b=new RegExp(b+'="([^"]+)"',"g").exec(a),b?tinymce.DOM.decode(b[1]):""}return a.replace(/(?:<p[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g,function(a,c){var d=b(c,"class");return-1!=d.indexOf("wp-gallery")?"<p>["+tinymce.trim(b(c,"title"))+"]</p>":a})},_createButtons:function(){var a,b,c,d=this,e=tinymce.activeEditor,f=tinymce.DOM;f.get("wp_gallerybtns")||(c=window.devicePixelRatio&&window.devicePixelRatio>1||window.matchMedia&&window.matchMedia("(min-resolution:130dpi)").matches,f.add(document.body,"div",{id:"wp_gallerybtns",style:"display:none;"}),a=f.add("wp_gallerybtns","img",{src:c?d.url+"/img/edit-2x.png":d.url+"/img/edit.png",id:"wp_editgallery",width:"24",height:"24",title:e.getLang("wordpress.editgallery")}),tinymce.dom.Event.add(a,"mousedown",function(){var a=tinymce.activeEditor;a.wpGalleryBookmark=a.selection.getBookmark("simple"),a.execCommand("WP_Gallery"),a.plugins.wordpress._hideButtons()}),b=f.add("wp_gallerybtns","img",{src:c?d.url+"/img/delete-2x.png":d.url+"/img/delete.png",id:"wp_delgallery",width:"24",height:"24",title:e.getLang("wordpress.delgallery")}),tinymce.dom.Event.add(b,"mousedown",function(a){var b=tinymce.activeEditor,c=b.selection.getNode();"IMG"==c.nodeName&&b.dom.hasClass(c,"wp-gallery")&&(b.dom.remove(c),b.execCommand("mceRepaint"),b.dom.events.cancel(a)),b.plugins.wordpress._hideButtons()}))},getInfo:function(){return{longname:"Gallery Settings",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}}),tinymce.PluginManager.add("wpgallery",tinymce.plugins.wpGallery)}();
\ No newline at end of file