Edit File by line
/home/barbar84/public_h.../wp-admin/js
File: gallery.js
/**
[0] Fix | Delete
* @output wp-admin/js/gallery.js
[1] Fix | Delete
*/
[2] Fix | Delete
[3] Fix | Delete
/* global unescape, getUserSetting, setUserSetting, wpgallery, tinymce */
[4] Fix | Delete
[5] Fix | Delete
jQuery(document).ready(function($) {
[6] Fix | Delete
var gallerySortable, gallerySortableInit, sortIt, clearAll, w, desc = false;
[7] Fix | Delete
[8] Fix | Delete
gallerySortableInit = function() {
[9] Fix | Delete
gallerySortable = $('#media-items').sortable( {
[10] Fix | Delete
items: 'div.media-item',
[11] Fix | Delete
placeholder: 'sorthelper',
[12] Fix | Delete
axis: 'y',
[13] Fix | Delete
distance: 2,
[14] Fix | Delete
handle: 'div.filename',
[15] Fix | Delete
stop: function() {
[16] Fix | Delete
// When an update has occurred, adjust the order for each item.
[17] Fix | Delete
var all = $('#media-items').sortable('toArray'), len = all.length;
[18] Fix | Delete
$.each(all, function(i, id) {
[19] Fix | Delete
var order = desc ? (len - i) : (1 + i);
[20] Fix | Delete
$('#' + id + ' .menu_order input').val(order);
[21] Fix | Delete
});
[22] Fix | Delete
}
[23] Fix | Delete
} );
[24] Fix | Delete
};
[25] Fix | Delete
[26] Fix | Delete
sortIt = function() {
[27] Fix | Delete
var all = $('.menu_order_input'), len = all.length;
[28] Fix | Delete
all.each(function(i){
[29] Fix | Delete
var order = desc ? (len - i) : (1 + i);
[30] Fix | Delete
$(this).val(order);
[31] Fix | Delete
});
[32] Fix | Delete
};
[33] Fix | Delete
[34] Fix | Delete
clearAll = function(c) {
[35] Fix | Delete
c = c || 0;
[36] Fix | Delete
$('.menu_order_input').each( function() {
[37] Fix | Delete
if ( this.value === '0' || c ) {
[38] Fix | Delete
this.value = '';
[39] Fix | Delete
}
[40] Fix | Delete
});
[41] Fix | Delete
};
[42] Fix | Delete
[43] Fix | Delete
$('#asc').on( 'click', function( e ) {
[44] Fix | Delete
e.preventDefault();
[45] Fix | Delete
desc = false;
[46] Fix | Delete
sortIt();
[47] Fix | Delete
});
[48] Fix | Delete
$('#desc').on( 'click', function( e ) {
[49] Fix | Delete
e.preventDefault();
[50] Fix | Delete
desc = true;
[51] Fix | Delete
sortIt();
[52] Fix | Delete
});
[53] Fix | Delete
$('#clear').on( 'click', function( e ) {
[54] Fix | Delete
e.preventDefault();
[55] Fix | Delete
clearAll(1);
[56] Fix | Delete
});
[57] Fix | Delete
$('#showall').on( 'click', function( e ) {
[58] Fix | Delete
e.preventDefault();
[59] Fix | Delete
$('#sort-buttons span a').toggle();
[60] Fix | Delete
$('a.describe-toggle-on').hide();
[61] Fix | Delete
$('a.describe-toggle-off, table.slidetoggle').show();
[62] Fix | Delete
$('img.pinkynail').toggle(false);
[63] Fix | Delete
});
[64] Fix | Delete
$('#hideall').on( 'click', function( e ) {
[65] Fix | Delete
e.preventDefault();
[66] Fix | Delete
$('#sort-buttons span a').toggle();
[67] Fix | Delete
$('a.describe-toggle-on').show();
[68] Fix | Delete
$('a.describe-toggle-off, table.slidetoggle').hide();
[69] Fix | Delete
$('img.pinkynail').toggle(true);
[70] Fix | Delete
});
[71] Fix | Delete
[72] Fix | Delete
// Initialize sortable.
[73] Fix | Delete
gallerySortableInit();
[74] Fix | Delete
clearAll();
[75] Fix | Delete
[76] Fix | Delete
if ( $('#media-items>*').length > 1 ) {
[77] Fix | Delete
w = wpgallery.getWin();
[78] Fix | Delete
[79] Fix | Delete
$('#save-all, #gallery-settings').show();
[80] Fix | Delete
if ( typeof w.tinyMCE !== 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) {
[81] Fix | Delete
wpgallery.mcemode = true;
[82] Fix | Delete
wpgallery.init();
[83] Fix | Delete
} else {
[84] Fix | Delete
$('#insert-gallery').show();
[85] Fix | Delete
}
[86] Fix | Delete
}
[87] Fix | Delete
});
[88] Fix | Delete
[89] Fix | Delete
jQuery(window).on( 'unload', function () { window.tinymce = window.tinyMCE = window.wpgallery = null; } ); // Cleanup.
[90] Fix | Delete
[91] Fix | Delete
/* gallery settings */
[92] Fix | Delete
window.tinymce = null;
[93] Fix | Delete
[94] Fix | Delete
window.wpgallery = {
[95] Fix | Delete
mcemode : false,
[96] Fix | Delete
editor : {},
[97] Fix | Delete
dom : {},
[98] Fix | Delete
is_update : false,
[99] Fix | Delete
el : {},
[100] Fix | Delete
[101] Fix | Delete
I : function(e) {
[102] Fix | Delete
return document.getElementById(e);
[103] Fix | Delete
},
[104] Fix | Delete
[105] Fix | Delete
init: function() {
[106] Fix | Delete
var t = this, li, q, i, it, w = t.getWin();
[107] Fix | Delete
[108] Fix | Delete
if ( ! t.mcemode ) {
[109] Fix | Delete
return;
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
li = ('' + document.location.search).replace(/^\?/, '').split('&');
[113] Fix | Delete
q = {};
[114] Fix | Delete
for (i=0; i<li.length; i++) {
[115] Fix | Delete
it = li[i].split('=');
[116] Fix | Delete
q[unescape(it[0])] = unescape(it[1]);
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
if ( q.mce_rdomain ) {
[120] Fix | Delete
document.domain = q.mce_rdomain;
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
// Find window & API.
[124] Fix | Delete
window.tinymce = w.tinymce;
[125] Fix | Delete
window.tinyMCE = w.tinyMCE;
[126] Fix | Delete
t.editor = tinymce.EditorManager.activeEditor;
[127] Fix | Delete
[128] Fix | Delete
t.setup();
[129] Fix | Delete
},
[130] Fix | Delete
[131] Fix | Delete
getWin : function() {
[132] Fix | Delete
return window.dialogArguments || opener || parent || top;
[133] Fix | Delete
},
[134] Fix | Delete
[135] Fix | Delete
setup : function() {
[136] Fix | Delete
var t = this, a, ed = t.editor, g, columns, link, order, orderby;
[137] Fix | Delete
if ( ! t.mcemode ) {
[138] Fix | Delete
return;
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
t.el = ed.selection.getNode();
[142] Fix | Delete
[143] Fix | Delete
if ( t.el.nodeName !== 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {
[144] Fix | Delete
if ( ( g = ed.dom.select('img.wpGallery') ) && g[0] ) {
[145] Fix | Delete
t.el = g[0];
[146] Fix | Delete
} else {
[147] Fix | Delete
if ( getUserSetting('galfile') === '1' ) {
[148] Fix | Delete
t.I('linkto-file').checked = 'checked';
[149] Fix | Delete
}
[150] Fix | Delete
if ( getUserSetting('galdesc') === '1' ) {
[151] Fix | Delete
t.I('order-desc').checked = 'checked';
[152] Fix | Delete
}
[153] Fix | Delete
if ( getUserSetting('galcols') ) {
[154] Fix | Delete
t.I('columns').value = getUserSetting('galcols');
[155] Fix | Delete
}
[156] Fix | Delete
if ( getUserSetting('galord') ) {
[157] Fix | Delete
t.I('orderby').value = getUserSetting('galord');
[158] Fix | Delete
}
[159] Fix | Delete
jQuery('#insert-gallery').show();
[160] Fix | Delete
return;
[161] Fix | Delete
}
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
a = ed.dom.getAttrib(t.el, 'title');
[165] Fix | Delete
a = ed.dom.decode(a);
[166] Fix | Delete
[167] Fix | Delete
if ( a ) {
[168] Fix | Delete
jQuery('#update-gallery').show();
[169] Fix | Delete
t.is_update = true;
[170] Fix | Delete
[171] Fix | Delete
columns = a.match(/columns=['"]([0-9]+)['"]/);
[172] Fix | Delete
link = a.match(/link=['"]([^'"]+)['"]/i);
[173] Fix | Delete
order = a.match(/order=['"]([^'"]+)['"]/i);
[174] Fix | Delete
orderby = a.match(/orderby=['"]([^'"]+)['"]/i);
[175] Fix | Delete
[176] Fix | Delete
if ( link && link[1] ) {
[177] Fix | Delete
t.I('linkto-file').checked = 'checked';
[178] Fix | Delete
}
[179] Fix | Delete
if ( order && order[1] ) {
[180] Fix | Delete
t.I('order-desc').checked = 'checked';
[181] Fix | Delete
}
[182] Fix | Delete
if ( columns && columns[1] ) {
[183] Fix | Delete
t.I('columns').value = '' + columns[1];
[184] Fix | Delete
}
[185] Fix | Delete
if ( orderby && orderby[1] ) {
[186] Fix | Delete
t.I('orderby').value = orderby[1];
[187] Fix | Delete
}
[188] Fix | Delete
} else {
[189] Fix | Delete
jQuery('#insert-gallery').show();
[190] Fix | Delete
}
[191] Fix | Delete
},
[192] Fix | Delete
[193] Fix | Delete
update : function() {
[194] Fix | Delete
var t = this, ed = t.editor, all = '', s;
[195] Fix | Delete
[196] Fix | Delete
if ( ! t.mcemode || ! t.is_update ) {
[197] Fix | Delete
s = '[gallery' + t.getSettings() + ']';
[198] Fix | Delete
t.getWin().send_to_editor(s);
[199] Fix | Delete
return;
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
if ( t.el.nodeName !== 'IMG' ) {
[203] Fix | Delete
return;
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
all = ed.dom.decode( ed.dom.getAttrib( t.el, 'title' ) );
[207] Fix | Delete
all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, '');
[208] Fix | Delete
all += t.getSettings();
[209] Fix | Delete
[210] Fix | Delete
ed.dom.setAttrib(t.el, 'title', all);
[211] Fix | Delete
t.getWin().tb_remove();
[212] Fix | Delete
},
[213] Fix | Delete
[214] Fix | Delete
getSettings : function() {
[215] Fix | Delete
var I = this.I, s = '';
[216] Fix | Delete
[217] Fix | Delete
if ( I('linkto-file').checked ) {
[218] Fix | Delete
s += ' link="file"';
[219] Fix | Delete
setUserSetting('galfile', '1');
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
if ( I('order-desc').checked ) {
[223] Fix | Delete
s += ' order="DESC"';
[224] Fix | Delete
setUserSetting('galdesc', '1');
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
if ( I('columns').value !== 3 ) {
[228] Fix | Delete
s += ' columns="' + I('columns').value + '"';
[229] Fix | Delete
setUserSetting('galcols', I('columns').value);
[230] Fix | Delete
}
[231] Fix | Delete
[232] Fix | Delete
if ( I('orderby').value !== 'menu_order' ) {
[233] Fix | Delete
s += ' orderby="' + I('orderby').value + '"';
[234] Fix | Delete
setUserSetting('galord', I('orderby').value);
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
return s;
[238] Fix | Delete
}
[239] Fix | Delete
};
[240] Fix | Delete
[241] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function