first commit
This commit is contained in:
@ -0,0 +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)})();
|
156
wp-includes/js/tinymce/plugins/wpgallery/editor_plugin_src.js
Normal file
156
wp-includes/js/tinymce/plugins/wpgallery/editor_plugin_src.js
Normal file
@ -0,0 +1,156 @@
|
||||
|
||||
(function() {
|
||||
tinymce.create('tinymce.plugins.wpGallery', {
|
||||
|
||||
init : function(ed, url) {
|
||||
var t = this;
|
||||
|
||||
t.url = url;
|
||||
t.editor = ed;
|
||||
t._createButtons();
|
||||
|
||||
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
|
||||
ed.addCommand('WP_Gallery', function() {
|
||||
if ( tinymce.isIE )
|
||||
ed.selection.moveToBookmark( ed.wpGalleryBookmark );
|
||||
|
||||
var el = ed.selection.getNode(),
|
||||
gallery = wp.media.gallery,
|
||||
frame;
|
||||
|
||||
// Check if the `wp.media.gallery` API exists.
|
||||
if ( typeof wp === 'undefined' || ! wp.media || ! wp.media.gallery )
|
||||
return;
|
||||
|
||||
// Make sure we've selected a gallery node.
|
||||
if ( el.nodeName != 'IMG' || ed.dom.getAttrib(el, 'class').indexOf('wpGallery') == -1 )
|
||||
return;
|
||||
|
||||
frame = gallery.edit( '[' + ed.dom.getAttrib( el, 'title' ) + ']' );
|
||||
|
||||
frame.state('gallery-edit').on( 'update', function( selection ) {
|
||||
var shortcode = gallery.shortcode( selection ).string().slice( 1, -1 );
|
||||
ed.dom.setAttrib( el, 'title', shortcode );
|
||||
});
|
||||
});
|
||||
|
||||
ed.onInit.add(function(ed) {
|
||||
// iOS6 doesn't show the buttons properly on click, show them on 'touchstart'
|
||||
if ( 'ontouchstart' in window ) {
|
||||
ed.dom.events.add(ed.getBody(), 'touchstart', function(e){
|
||||
var target = e.target;
|
||||
|
||||
if ( target.nodeName == 'IMG' && ed.dom.hasClass(target, 'wpGallery') ) {
|
||||
ed.selection.select(target);
|
||||
ed.dom.events.cancel(e);
|
||||
ed.plugins.wordpress._hideButtons();
|
||||
ed.plugins.wordpress._showButtons(target, 'wp_gallerybtns');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ed.onMouseDown.add(function(ed, e) {
|
||||
if ( e.target.nodeName == 'IMG' && ed.dom.hasClass(e.target, 'wpGallery') ) {
|
||||
ed.plugins.wordpress._hideButtons();
|
||||
ed.plugins.wordpress._showButtons(e.target, 'wp_gallerybtns');
|
||||
}
|
||||
});
|
||||
|
||||
ed.onBeforeSetContent.add(function(ed, o) {
|
||||
o.content = t._do_gallery(o.content);
|
||||
});
|
||||
|
||||
ed.onPostProcess.add(function(ed, o) {
|
||||
if (o.get)
|
||||
o.content = t._get_gallery(o.content);
|
||||
});
|
||||
},
|
||||
|
||||
_do_gallery : function(co) {
|
||||
return co.replace(/\[gallery([^\]]*)\]/g, function(a,b){
|
||||
return '<img src="'+tinymce.baseURL+'/plugins/wpgallery/img/t.gif" class="wpGallery mceItem" title="gallery'+tinymce.DOM.encode(b)+'" />';
|
||||
});
|
||||
},
|
||||
|
||||
_get_gallery : function(co) {
|
||||
|
||||
function getAttr(s, n) {
|
||||
n = new RegExp(n + '=\"([^\"]+)\"', 'g').exec(s);
|
||||
return n ? tinymce.DOM.decode(n[1]) : '';
|
||||
};
|
||||
|
||||
return co.replace(/(?:<p[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g, function(a,im) {
|
||||
var cls = getAttr(im, 'class');
|
||||
|
||||
if ( cls.indexOf('wpGallery') != -1 )
|
||||
return '<p>['+tinymce.trim(getAttr(im, 'title'))+']</p>';
|
||||
|
||||
return a;
|
||||
});
|
||||
},
|
||||
|
||||
_createButtons : function() {
|
||||
var t = this, ed = tinymce.activeEditor, DOM = tinymce.DOM, editButton, dellButton, isRetina;
|
||||
|
||||
if ( DOM.get('wp_gallerybtns') )
|
||||
return;
|
||||
|
||||
isRetina = ( window.devicePixelRatio && window.devicePixelRatio > 1 ) || // WebKit, Opera
|
||||
( window.matchMedia && window.matchMedia('(min-resolution:130dpi)').matches ); // Firefox, IE10, Opera
|
||||
|
||||
DOM.add(document.body, 'div', {
|
||||
id : 'wp_gallerybtns',
|
||||
style : 'display:none;'
|
||||
});
|
||||
|
||||
editButton = DOM.add('wp_gallerybtns', 'img', {
|
||||
src : isRetina ? t.url+'/img/edit-2x.png' : t.url+'/img/edit.png',
|
||||
id : 'wp_editgallery',
|
||||
width : '24',
|
||||
height : '24',
|
||||
title : ed.getLang('wordpress.editgallery')
|
||||
});
|
||||
|
||||
tinymce.dom.Event.add(editButton, 'mousedown', function(e) {
|
||||
var ed = tinymce.activeEditor;
|
||||
ed.wpGalleryBookmark = ed.selection.getBookmark('simple');
|
||||
ed.execCommand("WP_Gallery");
|
||||
ed.plugins.wordpress._hideButtons();
|
||||
});
|
||||
|
||||
dellButton = DOM.add('wp_gallerybtns', 'img', {
|
||||
src : isRetina ? t.url+'/img/delete-2x.png' : t.url+'/img/delete.png',
|
||||
id : 'wp_delgallery',
|
||||
width : '24',
|
||||
height : '24',
|
||||
title : ed.getLang('wordpress.delgallery')
|
||||
});
|
||||
|
||||
tinymce.dom.Event.add(dellButton, 'mousedown', function(e) {
|
||||
var ed = tinymce.activeEditor, el = ed.selection.getNode();
|
||||
|
||||
if ( el.nodeName == 'IMG' && ed.dom.hasClass(el, 'wpGallery') ) {
|
||||
ed.dom.remove(el);
|
||||
|
||||
ed.execCommand('mceRepaint');
|
||||
ed.dom.events.cancel(e);
|
||||
}
|
||||
|
||||
ed.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);
|
||||
})();
|
BIN
wp-includes/js/tinymce/plugins/wpgallery/img/delete-2x.png
Normal file
BIN
wp-includes/js/tinymce/plugins/wpgallery/img/delete-2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
BIN
wp-includes/js/tinymce/plugins/wpgallery/img/delete.png
Normal file
BIN
wp-includes/js/tinymce/plugins/wpgallery/img/delete.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
wp-includes/js/tinymce/plugins/wpgallery/img/edit-2x.png
Normal file
BIN
wp-includes/js/tinymce/plugins/wpgallery/img/edit-2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
BIN
wp-includes/js/tinymce/plugins/wpgallery/img/edit.png
Normal file
BIN
wp-includes/js/tinymce/plugins/wpgallery/img/edit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
wp-includes/js/tinymce/plugins/wpgallery/img/t.gif
Normal file
BIN
wp-includes/js/tinymce/plugins/wpgallery/img/t.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 43 B |
Reference in New Issue
Block a user