Fix JSHint errors in gallery.js.
props dougwollison. fixes #25999. Built from https://develop.svn.wordpress.org/trunk@26269 git-svn-id: http://core.svn.wordpress.org/trunk@26174 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
812e66d61d
commit
3a0a3bb775
|
@ -1,5 +1,7 @@
|
||||||
|
/* global unescape, getUserSetting, setUserSetting */
|
||||||
|
|
||||||
jQuery(document).ready(function($) {
|
jQuery(document).ready(function($) {
|
||||||
var gallerySortable, gallerySortableInit, w, desc = false;
|
var gallerySortable, gallerySortableInit, sortIt, clearAll, w, desc = false;
|
||||||
|
|
||||||
gallerySortableInit = function() {
|
gallerySortableInit = function() {
|
||||||
gallerySortable = $('#media-items').sortable( {
|
gallerySortable = $('#media-items').sortable( {
|
||||||
|
@ -8,7 +10,7 @@ jQuery(document).ready(function($) {
|
||||||
axis: 'y',
|
axis: 'y',
|
||||||
distance: 2,
|
distance: 2,
|
||||||
handle: 'div.filename',
|
handle: 'div.filename',
|
||||||
stop: function(e, ui) {
|
stop: function() {
|
||||||
// When an update has occurred, adjust the order for each item
|
// When an update has occurred, adjust the order for each item
|
||||||
var all = $('#media-items').sortable('toArray'), len = all.length;
|
var all = $('#media-items').sortable('toArray'), len = all.length;
|
||||||
$.each(all, function(i, id) {
|
$.each(all, function(i, id) {
|
||||||
|
@ -17,7 +19,7 @@ jQuery(document).ready(function($) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
};
|
||||||
|
|
||||||
sortIt = function() {
|
sortIt = function() {
|
||||||
var all = $('.menu_order_input'), len = all.length;
|
var all = $('.menu_order_input'), len = all.length;
|
||||||
|
@ -25,26 +27,39 @@ jQuery(document).ready(function($) {
|
||||||
var order = desc ? (len - i) : (1 + i);
|
var order = desc ? (len - i) : (1 + i);
|
||||||
$(this).val(order);
|
$(this).val(order);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
clearAll = function(c) {
|
clearAll = function(c) {
|
||||||
c = c || 0;
|
c = c || 0;
|
||||||
$('.menu_order_input').each(function(){
|
$('.menu_order_input').each( function() {
|
||||||
if ( this.value == '0' || c ) this.value = '';
|
if ( this.value === '0' || c ) {
|
||||||
|
this.value = '';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
$('#asc').click(function(){desc = false; sortIt(); return false;});
|
$('#asc').click( function() {
|
||||||
$('#desc').click(function(){desc = true; sortIt(); return false;});
|
desc = false;
|
||||||
$('#clear').click(function(){clearAll(1); return false;});
|
sortIt();
|
||||||
$('#showall').click(function(){
|
return false;
|
||||||
|
});
|
||||||
|
$('#desc').click( function() {
|
||||||
|
desc = true;
|
||||||
|
sortIt();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$('#clear').click( function() {
|
||||||
|
clearAll(1);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$('#showall').click( function() {
|
||||||
$('#sort-buttons span a').toggle();
|
$('#sort-buttons span a').toggle();
|
||||||
$('a.describe-toggle-on').hide();
|
$('a.describe-toggle-on').hide();
|
||||||
$('a.describe-toggle-off, table.slidetoggle').show();
|
$('a.describe-toggle-off, table.slidetoggle').show();
|
||||||
$('img.pinkynail').toggle(false);
|
$('img.pinkynail').toggle(false);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$('#hideall').click(function(){
|
$('#hideall').click( function() {
|
||||||
$('#sort-buttons span a').toggle();
|
$('#sort-buttons span a').toggle();
|
||||||
$('a.describe-toggle-on').show();
|
$('a.describe-toggle-on').show();
|
||||||
$('a.describe-toggle-off, table.slidetoggle').hide();
|
$('a.describe-toggle-off, table.slidetoggle').hide();
|
||||||
|
@ -60,7 +75,7 @@ jQuery(document).ready(function($) {
|
||||||
w = wpgallery.getWin();
|
w = wpgallery.getWin();
|
||||||
|
|
||||||
$('#save-all, #gallery-settings').show();
|
$('#save-all, #gallery-settings').show();
|
||||||
if ( typeof w.tinyMCE != 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) {
|
if ( typeof w.tinyMCE !== 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) {
|
||||||
wpgallery.mcemode = true;
|
wpgallery.mcemode = true;
|
||||||
wpgallery.init();
|
wpgallery.init();
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,7 +103,9 @@ wpgallery = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var t = this, li, q, i, it, w = t.getWin();
|
var t = this, li, q, i, it, w = t.getWin();
|
||||||
|
|
||||||
if ( ! t.mcemode ) return;
|
if ( ! t.mcemode ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
li = ('' + document.location.search).replace(/^\?/, '').split('&');
|
li = ('' + document.location.search).replace(/^\?/, '').split('&');
|
||||||
q = {};
|
q = {};
|
||||||
|
@ -97,8 +114,9 @@ wpgallery = {
|
||||||
q[unescape(it[0])] = unescape(it[1]);
|
q[unescape(it[0])] = unescape(it[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (q.mce_rdomain)
|
if ( q.mce_rdomain ) {
|
||||||
document.domain = q.mce_rdomain;
|
document.domain = q.mce_rdomain;
|
||||||
|
}
|
||||||
|
|
||||||
// Find window & API
|
// Find window & API
|
||||||
tinymce = w.tinymce;
|
tinymce = w.tinymce;
|
||||||
|
@ -114,18 +132,28 @@ wpgallery = {
|
||||||
|
|
||||||
setup : function() {
|
setup : function() {
|
||||||
var t = this, a, ed = t.editor, g, columns, link, order, orderby;
|
var t = this, a, ed = t.editor, g, columns, link, order, orderby;
|
||||||
if ( ! t.mcemode ) return;
|
if ( ! t.mcemode ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
t.el = ed.selection.getNode();
|
t.el = ed.selection.getNode();
|
||||||
|
|
||||||
if ( t.el.nodeName != 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {
|
if ( t.el.nodeName !== 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {
|
||||||
if ( (g = ed.dom.select('img.wpGallery')) && g[0] ) {
|
if ( ( g = ed.dom.select('img.wpGallery') ) && g[0] ) {
|
||||||
t.el = g[0];
|
t.el = g[0];
|
||||||
} else {
|
} else {
|
||||||
if ( getUserSetting('galfile') == '1' ) t.I('linkto-file').checked = "checked";
|
if ( getUserSetting('galfile') === '1' ) {
|
||||||
if ( getUserSetting('galdesc') == '1' ) t.I('order-desc').checked = "checked";
|
t.I('linkto-file').checked = 'checked';
|
||||||
if ( getUserSetting('galcols') ) t.I('columns').value = getUserSetting('galcols');
|
}
|
||||||
if ( getUserSetting('galord') ) t.I('orderby').value = getUserSetting('galord');
|
if ( getUserSetting('galdesc') === '1' ) {
|
||||||
|
t.I('order-desc').checked = 'checked';
|
||||||
|
}
|
||||||
|
if ( getUserSetting('galcols') ) {
|
||||||
|
t.I('columns').value = getUserSetting('galcols');
|
||||||
|
}
|
||||||
|
if ( getUserSetting('galord') ) {
|
||||||
|
t.I('orderby').value = getUserSetting('galord');
|
||||||
|
}
|
||||||
jQuery('#insert-gallery').show();
|
jQuery('#insert-gallery').show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -143,10 +171,18 @@ wpgallery = {
|
||||||
order = a.match(/order=['"]([^'"]+)['"]/i);
|
order = a.match(/order=['"]([^'"]+)['"]/i);
|
||||||
orderby = a.match(/orderby=['"]([^'"]+)['"]/i);
|
orderby = a.match(/orderby=['"]([^'"]+)['"]/i);
|
||||||
|
|
||||||
if ( link && link[1] ) t.I('linkto-file').checked = "checked";
|
if ( link && link[1] ) {
|
||||||
if ( order && order[1] ) t.I('order-desc').checked = "checked";
|
t.I('linkto-file').checked = 'checked';
|
||||||
if ( columns && columns[1] ) t.I('columns').value = ''+columns[1];
|
}
|
||||||
if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1];
|
if ( order && order[1] ) {
|
||||||
|
t.I('order-desc').checked = 'checked';
|
||||||
|
}
|
||||||
|
if ( columns && columns[1] ) {
|
||||||
|
t.I('columns').value = '' + columns[1];
|
||||||
|
}
|
||||||
|
if ( orderby && orderby[1] ) {
|
||||||
|
t.I('orderby').value = orderby[1];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
jQuery('#insert-gallery').show();
|
jQuery('#insert-gallery').show();
|
||||||
}
|
}
|
||||||
|
@ -156,14 +192,16 @@ wpgallery = {
|
||||||
var t = this, ed = t.editor, all = '', s;
|
var t = this, ed = t.editor, all = '', s;
|
||||||
|
|
||||||
if ( ! t.mcemode || ! t.is_update ) {
|
if ( ! t.mcemode || ! t.is_update ) {
|
||||||
s = '[gallery'+t.getSettings()+']';
|
s = '[gallery' + t.getSettings() + ']';
|
||||||
t.getWin().send_to_editor(s);
|
t.getWin().send_to_editor(s);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.el.nodeName != 'IMG') return;
|
if ( t.el.nodeName !== 'IMG' ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
all = ed.dom.decode(ed.dom.getAttrib(t.el, 'title'));
|
all = ed.dom.decode( ed.dom.getAttrib( t.el, 'title' ) );
|
||||||
all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, '');
|
all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, '');
|
||||||
all += t.getSettings();
|
all += t.getSettings();
|
||||||
|
|
||||||
|
@ -184,13 +222,13 @@ wpgallery = {
|
||||||
setUserSetting('galdesc', '1');
|
setUserSetting('galdesc', '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( I('columns').value != 3 ) {
|
if ( I('columns').value !== 3 ) {
|
||||||
s += ' columns="'+I('columns').value+'"';
|
s += ' columns="' + I('columns').value + '"';
|
||||||
setUserSetting('galcols', I('columns').value);
|
setUserSetting('galcols', I('columns').value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( I('orderby').value != 'menu_order' ) {
|
if ( I('orderby').value !== 'menu_order' ) {
|
||||||
s += ' orderby="'+I('orderby').value+'"';
|
s += ' orderby="' + I('orderby').value + '"';
|
||||||
setUserSetting('galord', I('orderby').value);
|
setUserSetting('galord', I('orderby').value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
jQuery(document).ready(function(a){var b,c,d,e=!1;c=function(){b=a("#media-items").sortable({items:"div.media-item",placeholder:"sorthelper",axis:"y",distance:2,handle:"div.filename",stop:function(){var b=a("#media-items").sortable("toArray"),c=b.length;a.each(b,function(b,d){var f=e?c-b:1+b;a("#"+d+" .menu_order input").val(f)})}})},sortIt=function(){var b=a(".menu_order_input"),c=b.length;b.each(function(b){var d=e?c-b:1+b;a(this).val(d)})},clearAll=function(b){b=b||0,a(".menu_order_input").each(function(){("0"==this.value||b)&&(this.value="")})},a("#asc").click(function(){return e=!1,sortIt(),!1}),a("#desc").click(function(){return e=!0,sortIt(),!1}),a("#clear").click(function(){return clearAll(1),!1}),a("#showall").click(function(){return a("#sort-buttons span a").toggle(),a("a.describe-toggle-on").hide(),a("a.describe-toggle-off, table.slidetoggle").show(),a("img.pinkynail").toggle(!1),!1}),a("#hideall").click(function(){return a("#sort-buttons span a").toggle(),a("a.describe-toggle-on").show(),a("a.describe-toggle-off, table.slidetoggle").hide(),a("img.pinkynail").toggle(!0),!1}),c(),clearAll(),a("#media-items>*").length>1&&(d=wpgallery.getWin(),a("#save-all, #gallery-settings").show(),"undefined"!=typeof d.tinyMCE&&d.tinyMCE.activeEditor&&!d.tinyMCE.activeEditor.isHidden()?(wpgallery.mcemode=!0,wpgallery.init()):a("#insert-gallery").show())}),jQuery(window).unload(function(){tinymce=tinyMCE=wpgallery=null});var tinymce=null,tinyMCE,wpgallery;wpgallery={mcemode:!1,editor:{},dom:{},is_update:!1,el:{},I:function(a){return document.getElementById(a)},init:function(){var a,b,c,d,e=this,f=e.getWin();if(e.mcemode){for(a=(""+document.location.search).replace(/^\?/,"").split("&"),b={},c=0;c<a.length;c++)d=a[c].split("="),b[unescape(d[0])]=unescape(d[1]);b.mce_rdomain&&(document.domain=b.mce_rdomain),tinymce=f.tinymce,tinyMCE=f.tinyMCE,e.editor=tinymce.EditorManager.activeEditor,e.setup()}},getWin:function(){return window.dialogArguments||opener||parent||top},setup:function(){var a,b,c,d,e,f,g=this,h=g.editor;if(g.mcemode){if(g.el=h.selection.getNode(),"IMG"!=g.el.nodeName||!h.dom.hasClass(g.el,"wpGallery")){if(!(b=h.dom.select("img.wpGallery"))||!b[0])return"1"==getUserSetting("galfile")&&(g.I("linkto-file").checked="checked"),"1"==getUserSetting("galdesc")&&(g.I("order-desc").checked="checked"),getUserSetting("galcols")&&(g.I("columns").value=getUserSetting("galcols")),getUserSetting("galord")&&(g.I("orderby").value=getUserSetting("galord")),jQuery("#insert-gallery").show(),void 0;g.el=b[0]}a=h.dom.getAttrib(g.el,"title"),a=h.dom.decode(a),a?(jQuery("#update-gallery").show(),g.is_update=!0,c=a.match(/columns=['"]([0-9]+)['"]/),d=a.match(/link=['"]([^'"]+)['"]/i),e=a.match(/order=['"]([^'"]+)['"]/i),f=a.match(/orderby=['"]([^'"]+)['"]/i),d&&d[1]&&(g.I("linkto-file").checked="checked"),e&&e[1]&&(g.I("order-desc").checked="checked"),c&&c[1]&&(g.I("columns").value=""+c[1]),f&&f[1]&&(g.I("orderby").value=f[1])):jQuery("#insert-gallery").show()}},update:function(){var a,b=this,c=b.editor,d="";return b.mcemode&&b.is_update?("IMG"==b.el.nodeName&&(d=c.dom.decode(c.dom.getAttrib(b.el,"title")),d=d.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi,""),d+=b.getSettings(),c.dom.setAttrib(b.el,"title",d),b.getWin().tb_remove()),void 0):(a="[gallery"+b.getSettings()+"]",b.getWin().send_to_editor(a),void 0)},getSettings:function(){var a=this.I,b="";return a("linkto-file").checked&&(b+=' link="file"',setUserSetting("galfile","1")),a("order-desc").checked&&(b+=' order="DESC"',setUserSetting("galdesc","1")),3!=a("columns").value&&(b+=' columns="'+a("columns").value+'"',setUserSetting("galcols",a("columns").value)),"menu_order"!=a("orderby").value&&(b+=' orderby="'+a("orderby").value+'"',setUserSetting("galord",a("orderby").value)),b}};
|
jQuery(document).ready(function(a){var b,c,d,e,f,g=!1;c=function(){b=a("#media-items").sortable({items:"div.media-item",placeholder:"sorthelper",axis:"y",distance:2,handle:"div.filename",stop:function(){var b=a("#media-items").sortable("toArray"),c=b.length;a.each(b,function(b,d){var e=g?c-b:1+b;a("#"+d+" .menu_order input").val(e)})}})},d=function(){var b=a(".menu_order_input"),c=b.length;b.each(function(b){var d=g?c-b:1+b;a(this).val(d)})},e=function(b){b=b||0,a(".menu_order_input").each(function(){("0"===this.value||b)&&(this.value="")})},a("#asc").click(function(){return g=!1,d(),!1}),a("#desc").click(function(){return g=!0,d(),!1}),a("#clear").click(function(){return e(1),!1}),a("#showall").click(function(){return a("#sort-buttons span a").toggle(),a("a.describe-toggle-on").hide(),a("a.describe-toggle-off, table.slidetoggle").show(),a("img.pinkynail").toggle(!1),!1}),a("#hideall").click(function(){return a("#sort-buttons span a").toggle(),a("a.describe-toggle-on").show(),a("a.describe-toggle-off, table.slidetoggle").hide(),a("img.pinkynail").toggle(!0),!1}),c(),e(),a("#media-items>*").length>1&&(f=wpgallery.getWin(),a("#save-all, #gallery-settings").show(),"undefined"!=typeof f.tinyMCE&&f.tinyMCE.activeEditor&&!f.tinyMCE.activeEditor.isHidden()?(wpgallery.mcemode=!0,wpgallery.init()):a("#insert-gallery").show())}),jQuery(window).unload(function(){tinymce=tinyMCE=wpgallery=null});var tinymce=null,tinyMCE,wpgallery;wpgallery={mcemode:!1,editor:{},dom:{},is_update:!1,el:{},I:function(a){return document.getElementById(a)},init:function(){var a,b,c,d,e=this,f=e.getWin();if(e.mcemode){for(a=(""+document.location.search).replace(/^\?/,"").split("&"),b={},c=0;c<a.length;c++)d=a[c].split("="),b[unescape(d[0])]=unescape(d[1]);b.mce_rdomain&&(document.domain=b.mce_rdomain),tinymce=f.tinymce,tinyMCE=f.tinyMCE,e.editor=tinymce.EditorManager.activeEditor,e.setup()}},getWin:function(){return window.dialogArguments||opener||parent||top},setup:function(){var a,b,c,d,e,f,g=this,h=g.editor;if(g.mcemode){if(g.el=h.selection.getNode(),"IMG"!==g.el.nodeName||!h.dom.hasClass(g.el,"wpGallery")){if(!(b=h.dom.select("img.wpGallery"))||!b[0])return"1"===getUserSetting("galfile")&&(g.I("linkto-file").checked="checked"),"1"===getUserSetting("galdesc")&&(g.I("order-desc").checked="checked"),getUserSetting("galcols")&&(g.I("columns").value=getUserSetting("galcols")),getUserSetting("galord")&&(g.I("orderby").value=getUserSetting("galord")),jQuery("#insert-gallery").show(),void 0;g.el=b[0]}a=h.dom.getAttrib(g.el,"title"),a=h.dom.decode(a),a?(jQuery("#update-gallery").show(),g.is_update=!0,c=a.match(/columns=['"]([0-9]+)['"]/),d=a.match(/link=['"]([^'"]+)['"]/i),e=a.match(/order=['"]([^'"]+)['"]/i),f=a.match(/orderby=['"]([^'"]+)['"]/i),d&&d[1]&&(g.I("linkto-file").checked="checked"),e&&e[1]&&(g.I("order-desc").checked="checked"),c&&c[1]&&(g.I("columns").value=""+c[1]),f&&f[1]&&(g.I("orderby").value=f[1])):jQuery("#insert-gallery").show()}},update:function(){var a,b=this,c=b.editor,d="";return b.mcemode&&b.is_update?("IMG"===b.el.nodeName&&(d=c.dom.decode(c.dom.getAttrib(b.el,"title")),d=d.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi,""),d+=b.getSettings(),c.dom.setAttrib(b.el,"title",d),b.getWin().tb_remove()),void 0):(a="[gallery"+b.getSettings()+"]",b.getWin().send_to_editor(a),void 0)},getSettings:function(){var a=this.I,b="";return a("linkto-file").checked&&(b+=' link="file"',setUserSetting("galfile","1")),a("order-desc").checked&&(b+=' order="DESC"',setUserSetting("galdesc","1")),3!==a("columns").value&&(b+=' columns="'+a("columns").value+'"',setUserSetting("galcols",a("columns").value)),"menu_order"!==a("orderby").value&&(b+=' orderby="'+a("orderby").value+'"',setUserSetting("galord",a("orderby").value)),b}};
|
Loading…
Reference in New Issue