Changeset 26269
- Timestamp:
- 11/19/2013 11:09:01 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/gallery.js
r21592 r26269 1 /* global unescape, getUserSetting, setUserSetting */ 2 1 3 jQuery(document).ready(function($) { 2 var gallerySortable, gallerySortableInit, w, desc = false;4 var gallerySortable, gallerySortableInit, sortIt, clearAll, w, desc = false; 3 5 4 6 gallerySortableInit = function() { … … 9 11 distance: 2, 10 12 handle: 'div.filename', 11 stop: function( e, ui) {13 stop: function() { 12 14 // When an update has occurred, adjust the order for each item 13 15 var all = $('#media-items').sortable('toArray'), len = all.length; … … 18 20 } 19 21 } ); 20 } 22 }; 21 23 22 24 sortIt = function() { … … 26 28 $(this).val(order); 27 29 }); 28 } 30 }; 29 31 30 32 clearAll = function(c) { 31 33 c = c || 0; 32 $('.menu_order_input').each(function(){ 33 if ( this.value == '0' || c ) this.value = ''; 34 $('.menu_order_input').each( function() { 35 if ( this.value === '0' || c ) { 36 this.value = ''; 37 } 34 38 }); 35 } 36 37 $('#asc').click(function(){desc = false; sortIt(); return false;}); 38 $('#desc').click(function(){desc = true; sortIt(); return false;}); 39 $('#clear').click(function(){clearAll(1); return false;}); 40 $('#showall').click(function(){ 39 }; 40 41 $('#asc').click( function() { 42 desc = false; 43 sortIt(); 44 return false; 45 }); 46 $('#desc').click( function() { 47 desc = true; 48 sortIt(); 49 return false; 50 }); 51 $('#clear').click( function() { 52 clearAll(1); 53 return false; 54 }); 55 $('#showall').click( function() { 41 56 $('#sort-buttons span a').toggle(); 42 57 $('a.describe-toggle-on').hide(); … … 45 60 return false; 46 61 }); 47 $('#hideall').click( function(){62 $('#hideall').click( function() { 48 63 $('#sort-buttons span a').toggle(); 49 64 $('a.describe-toggle-on').show(); … … 61 76 62 77 $('#save-all, #gallery-settings').show(); 63 if ( typeof w.tinyMCE != 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) {78 if ( typeof w.tinyMCE !== 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) { 64 79 wpgallery.mcemode = true; 65 80 wpgallery.init(); … … 89 104 var t = this, li, q, i, it, w = t.getWin(); 90 105 91 if ( ! t.mcemode ) return; 106 if ( ! t.mcemode ) { 107 return; 108 } 92 109 93 110 li = ('' + document.location.search).replace(/^\?/, '').split('&'); … … 98 115 } 99 116 100 if ( q.mce_rdomain)117 if ( q.mce_rdomain ) { 101 118 document.domain = q.mce_rdomain; 119 } 102 120 103 121 // Find window & API … … 115 133 setup : function() { 116 134 var t = this, a, ed = t.editor, g, columns, link, order, orderby; 117 if ( ! t.mcemode ) return; 135 if ( ! t.mcemode ) { 136 return; 137 } 118 138 119 139 t.el = ed.selection.getNode(); 120 140 121 if ( t.el.nodeName != 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {122 if ( ( g = ed.dom.select('img.wpGallery')) && g[0] ) {141 if ( t.el.nodeName !== 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) { 142 if ( ( g = ed.dom.select('img.wpGallery') ) && g[0] ) { 123 143 t.el = g[0]; 124 144 } else { 125 if ( getUserSetting('galfile') == '1' ) t.I('linkto-file').checked = "checked"; 126 if ( getUserSetting('galdesc') == '1' ) t.I('order-desc').checked = "checked"; 127 if ( getUserSetting('galcols') ) t.I('columns').value = getUserSetting('galcols'); 128 if ( getUserSetting('galord') ) t.I('orderby').value = getUserSetting('galord'); 145 if ( getUserSetting('galfile') === '1' ) { 146 t.I('linkto-file').checked = 'checked'; 147 } 148 if ( getUserSetting('galdesc') === '1' ) { 149 t.I('order-desc').checked = 'checked'; 150 } 151 if ( getUserSetting('galcols') ) { 152 t.I('columns').value = getUserSetting('galcols'); 153 } 154 if ( getUserSetting('galord') ) { 155 t.I('orderby').value = getUserSetting('galord'); 156 } 129 157 jQuery('#insert-gallery').show(); 130 158 return; … … 144 172 orderby = a.match(/orderby=['"]([^'"]+)['"]/i); 145 173 146 if ( link && link[1] ) t.I('linkto-file').checked = "checked"; 147 if ( order && order[1] ) t.I('order-desc').checked = "checked"; 148 if ( columns && columns[1] ) t.I('columns').value = ''+columns[1]; 149 if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1]; 174 if ( link && link[1] ) { 175 t.I('linkto-file').checked = 'checked'; 176 } 177 if ( order && order[1] ) { 178 t.I('order-desc').checked = 'checked'; 179 } 180 if ( columns && columns[1] ) { 181 t.I('columns').value = '' + columns[1]; 182 } 183 if ( orderby && orderby[1] ) { 184 t.I('orderby').value = orderby[1]; 185 } 150 186 } else { 151 187 jQuery('#insert-gallery').show(); … … 157 193 158 194 if ( ! t.mcemode || ! t.is_update ) { 159 s = '[gallery' +t.getSettings()+']';195 s = '[gallery' + t.getSettings() + ']'; 160 196 t.getWin().send_to_editor(s); 161 197 return; 162 198 } 163 199 164 if (t.el.nodeName != 'IMG') return; 165 166 all = ed.dom.decode(ed.dom.getAttrib(t.el, 'title')); 200 if ( t.el.nodeName !== 'IMG' ) { 201 return; 202 } 203 204 all = ed.dom.decode( ed.dom.getAttrib( t.el, 'title' ) ); 167 205 all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, ''); 168 206 all += t.getSettings(); … … 185 223 } 186 224 187 if ( I('columns').value != 3 ) {188 s += ' columns="' +I('columns').value+'"';225 if ( I('columns').value !== 3 ) { 226 s += ' columns="' + I('columns').value + '"'; 189 227 setUserSetting('galcols', I('columns').value); 190 228 } 191 229 192 if ( I('orderby').value != 'menu_order' ) {193 s += ' orderby="' +I('orderby').value+'"';230 if ( I('orderby').value !== 'menu_order' ) { 231 s += ' orderby="' + I('orderby').value + '"'; 194 232 setUserSetting('galord', I('orderby').value); 195 233 }
Note: See TracChangeset
for help on using the changeset viewer.