Changeset 9626
- Timestamp:
- 11/12/2008 12:27:01 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 deleted
- 2 edited
-
wp-admin/js/common.js (modified) (1 diff)
-
wp-admin/js/menu.js (deleted)
-
wp-admin/js/settings-box.js (deleted)
-
wp-admin/js/upload.js (deleted)
-
wp-admin/js/user-settings.js (deleted)
-
wp-includes/script-loader.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/js/common.js
r9569 r9626 1 jQuery(document).ready( function() { 1 2 wpCookies = { 3 // The following functions are from Cookie.js class in TinyMCE, Moxiecode, used under LGPL. 4 5 each : function(o, cb, s) { 6 var n, l; 7 8 if (!o) 9 return 0; 10 11 s = s || o; 12 13 if (typeof(o.length) != 'undefined') { 14 for (n=0, l = o.length; n<l; n++) { 15 if (cb.call(s, o[n], n, o) === false) 16 return 0; 17 } 18 } else { 19 for (n in o) { 20 if (o.hasOwnProperty(n)) { 21 if (cb.call(s, o[n], n, o) === false) 22 return 0; 23 } 24 } 25 } 26 return 1; 27 }, 28 29 getHash : function(n) { 30 var v = this.get(n), h; 31 32 if (v) { 33 this.each(v.split('&'), function(v) { 34 v = v.split('='); 35 h = h || {}; 36 h[v[0]] = v[1]; 37 }); 38 } 39 return h; 40 }, 41 42 setHash : function(n, v, e, p, d, s) { 43 var o = ''; 44 45 this.each(v, function(v, k) { 46 o += (!o ? '' : '&') + k + '=' + v; 47 }); 48 49 this.set(n, o, e, p, d, s); 50 }, 51 52 get : function(n) { 53 var c = document.cookie, e, p = n + "=", b; 54 55 if (!c) 56 return; 57 58 b = c.indexOf("; " + p); 59 60 if (b == -1) { 61 b = c.indexOf(p); 62 63 if (b != 0) 64 return null; 65 } else 66 b += 2; 67 68 e = c.indexOf(";", b); 69 70 if (e == -1) 71 e = c.length; 72 73 return decodeURIComponent(c.substring(b + p.length, e)); 74 }, 75 76 set : function(n, v, e, p, d, s) { 77 document.cookie = n + "=" + encodeURIComponent(v) + 78 ((e) ? "; expires=" + e.toGMTString() : "") + 79 ((p) ? "; path=" + p : "") + 80 ((d) ? "; domain=" + d : "") + 81 ((s) ? "; secure" : ""); 82 }, 83 84 remove : function(n, p) { 85 var d = new Date(); 86 87 d.setTime(d.getTime() - 1000); 88 89 this.set(n, '', d, p, d); 90 } 91 }; 92 93 // Returns the value as string. Second arg or empty string is returned when value is not set. 94 function getUserSetting( name, def ) { 95 var o = getAllUserSettings(); 96 97 if ( o.hasOwnProperty(name) ) 98 return o[name]; 99 100 if ( typeof def != 'undefined' ) 101 return def; 102 103 return ''; 104 } 105 106 // Both name and value must be only ASCII letters, numbers or underscore 107 // and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text. 108 function setUserSetting( name, value, del ) { 109 var c = 'wp-settings-'+userSettings.uid, o = wpCookies.getHash(c) || {}, d = new Date(); 110 var n = name.toString().replace(/[^A-Za-z0-9_]/, ''), v = value.toString().replace(/[^A-Za-z0-9_]/, ''); 111 112 if ( del ) delete o[n]; 113 else o[n] = v; 114 115 d.setTime( d.getTime() + 31536000000 ); 116 p = userSettings.url; 117 118 wpCookies.setHash(c, o, d, p ); 119 wpCookies.set('wp-settings-time-'+userSettings.uid, userSettings.time, d, p ); 120 } 121 122 function deleteUserSetting( name ) { 123 setUserSetting( name, '', 1 ); 124 } 125 126 // Returns all settings as js object. 127 function getAllUserSettings() { 128 return wpCookies.getHash('wp-settings-'+userSettings.uid) || {}; 129 } 130 131 132 jQuery(document).ready( function($) { 2 133 // pulse 3 jQuery('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);134 $('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300); 4 135 5 136 // show things that should be visible, hide what should be hidden 6 jQuery('.hide-if-no-js').removeClass('hide-if-no-js');7 jQuery('.hide-if-js').hide();137 $('.hide-if-no-js').removeClass('hide-if-no-js'); 138 $('.hide-if-js').hide(); 8 139 9 140 // Basic form validation 10 if ( ( 'undefined' != typeof wpAjax ) && jQuery.isFunction( wpAjax.validateForm ) ) {11 jQuery('form.validate').submit( function() { return wpAjax.validateForm( jQuery(this) ); } );141 if ( ( 'undefined' != typeof wpAjax ) && $.isFunction( wpAjax.validateForm ) ) { 142 $('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } ); 12 143 } 13 144 14 145 // Move .updated and .error alert boxes 15 jQuery('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2'); 16 jQuery('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first'); 17 146 $('div.wrap h2 ~ div.updated, div.wrap h2 ~ div.error').addClass('below-h2'); 147 $('div.updated, div.error').not('.below-h2').insertAfter('div.wrap h2:first'); 148 149 // screen settings tab 150 $('#show-settings-link').click(function () { 151 if ( ! $('#screen-options-wrap').hasClass('screen-options-open') ) { 152 $('#contextual-help-link-wrap').addClass('invisible'); 153 } 154 $('#screen-options-wrap').slideToggle('fast', function(){ 155 if ( $(this).hasClass('screen-options-open') ) { 156 $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right.gif")'}); 157 $('#contextual-help-link-wrap').removeClass('invisible'); 158 $(this).removeClass('screen-options-open'); 159 160 } else { 161 $('#show-settings-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'}); 162 $(this).addClass('screen-options-open'); 163 } 164 }); 165 return false; 166 }); 167 168 // help tab 169 $('#contextual-help-link').click(function () { 170 if ( ! $('#contextual-help-wrap').hasClass('contextual-help-open') ) { 171 $('#screen-options-link-wrap').addClass('invisible'); 172 } 173 $('#contextual-help-wrap').slideToggle('fast', function(){ 174 if ( $(this).hasClass('contextual-help-open') ) { 175 $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right.gif")'}); 176 $('#screen-options-link-wrap').removeClass('invisible'); 177 $(this).removeClass('contextual-help-open'); 178 } else { 179 $('#contextual-help-link').css({'backgroundImage':'url("images/screen-options-right-up.gif")'}); 180 $(this).addClass('contextual-help-open'); 181 } 182 }); 183 return false; 184 }); 18 185 }); 19 186 187 (function($){ 188 20 189 // stub for doing better warnings 21 (function($){ 22 showNotice = { 23 warn : function(text) { 24 if ( confirm(text) ) 25 return true; 26 27 return false; 28 }, 190 showNotice = { 191 warn : function(text) { 192 if ( confirm(text) ) 193 return true; 194 195 return false; 196 }, 197 198 note : function(text) { 199 alert(text); 200 } 201 }; 202 203 // sidebar admin menu 204 adminMenu = { 29 205 30 note : function(text) { 31 alert(text); 32 } 33 } 206 init : function() { 207 $('#adminmenu a').attr('tabindex', '10'); 208 $('#adminmenu div.wp-menu-toggle').each( function() { 209 if ( $(this).siblings('.wp-submenu').length ) 210 $(this).click(function(){ adminMenu.toggle( $(this).siblings('.wp-submenu') ); }); 211 else 212 $(this).hide(); 213 }); 214 $('#adminmenu li.menu-top .wp-menu-image').click( function() { window.location = $(this).siblings('a.menu-top')[0].href; } ); 215 this.favorites(); 216 217 $('.wp-menu-separator').click(function(){ 218 if ( $('#adminmenu').hasClass('folded') ) { 219 adminMenu.fold(1); 220 setUserSetting( 'mfold', 'o' ); 221 } else { 222 adminMenu.fold(); 223 setUserSetting( 'mfold', 'f' ); 224 } 225 }); 226 227 if ( 'f' != getUserSetting( 'mfold' ) ) { 228 this.restoreMenuState(); 229 } else { 230 this.fold(); 231 } 232 }, 233 234 restoreMenuState : function() { 235 $('#adminmenu li.wp-has-submenu').each(function(i, e) { 236 var v = getUserSetting( 'm'+i ); 237 if ( $(e).hasClass('wp-has-current-submenu') ) return true; // leave the current parent open 238 239 if ( 'o' == v ) $(e).addClass('wp-menu-open'); 240 else if ( 'c' == v ) $(e).removeClass('wp-menu-open'); 241 }); 242 }, 243 244 toggle : function(el) { 245 246 el['slideToggle'](150, function(){el.css('display','');}).parent().toggleClass( 'wp-menu-open' ); 247 248 $('#adminmenu li.wp-has-submenu').each(function(i, e) { 249 var v = $(e).hasClass('wp-menu-open') ? 'o' : 'c'; 250 setUserSetting( 'm'+i, v ); 251 }); 252 253 return false; 254 }, 255 256 fold : function(off) { 257 if (off) { 258 $('#adminmenu').removeClass('folded'); 259 $('#adminmenu li.wp-has-submenu').unbind(); 260 } else { 261 $('#adminmenu').addClass('folded'); 262 $('#adminmenu li.wp-has-submenu').hoverIntent({ 263 over: function(e){ 264 var m = $(this).find('.wp-submenu'), t = e.clientY, H = $(window).height(), h = m.height(), o; 265 266 if ( (t+h+10) > H ) { 267 o = (t+h+10) - H; 268 m.css({'marginTop':'-'+o+'px'}); 269 } else if ( m.css('marginTop') ) { 270 m.css({'marginTop':''}) 271 } 272 m.addClass('sub-open'); 273 }, 274 out: function(){ $(this).find('.wp-submenu').removeClass('sub-open'); }, 275 timeout: 220, 276 sensitivity: 8, 277 interval: 100 278 }); 279 280 } 281 }, 282 283 favorites : function() { 284 $('#favorite-inside').width($('#favorite-actions').width()-4); 285 $('#favorite-toggle, #favorite-inside').bind( 'mouseenter', function(){$('#favorite-inside').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideDown') ) { $('#favorite-inside').slideDown(100); $('#favorite-first').addClass('slide-down'); }}, 200) } ); 286 287 $('#favorite-toggle, #favorite-inside').bind( 'mouseleave', function(){$('#favorite-inside').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('#favorite-inside').hasClass('slideUp') ) { $('#favorite-inside').slideUp(100, function(){ $('#favorite-first').removeClass('slide-down'); } ); }}, 300) } ); 288 } 289 }; 290 291 $(document).ready(function(){adminMenu.init();}); 292 34 293 })(jQuery); 294 35 295 36 296 /* -
trunk/wp-includes/script-loader.php
r9604 r9626 42 42 $scripts->default_version = get_bloginfo( 'version' ); 43 43 44 $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery', ' user-settings', 'menu'), '20081107' );44 $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery', 'hoverIntent'), '20081111' ); 45 45 $scripts->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' ); 46 46 … … 146 146 'how' => __('Separate multiple categories with commas.') 147 147 ) ); 148 $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists', 'columns' , 'settings-box'), '20080925' );149 $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists', 'columns' , 'settings-box'), '20080925' );148 $scripts->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists', 'columns'), '20080925' ); 149 $scripts->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists', 'columns'), '20080925' ); 150 150 $scripts->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' ); 151 151 $scripts->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20081021' ); … … 157 157 'strong' => __('Strong') 158 158 ) ); 159 $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'columns' , 'settings-box'), '20081031' );159 $scripts->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'columns'), '20081031' ); 160 160 $scripts->localize( 'admin-comments', 'adminCommentsL10n', array( 161 161 'pending' => __('%i% pending'), // must look like: "# blah blah" … … 163 163 'hotkeys_highlight_last' => isset($_GET['hotkeys_highlight_last']), 164 164 ) ); 165 $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists', 'columns' , 'settings-box'), '20080925' );165 $scripts->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists', 'columns'), '20080925' ); 166 166 $scripts->add( 'admin-forms', '/wp-admin/js/forms.js', array('jquery'), '20080729'); 167 167 $scripts->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' ); 168 $scripts->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' );169 168 $scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery-ui-sortable'), '20081109' ); 170 169 $scripts->localize( 'postbox', 'postboxL10n', array( … … 177 176 'cancel' => __('Cancel'), 178 177 ) ); 179 $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug' , 'settings-box'), '20081107' );178 $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20081107' ); 180 179 $scripts->localize( 'post', 'postL10n', array( 181 180 'tagsUsed' => __('Tags used on this post:'), … … 196 195 'saveDraft' => __('Save Draft') 197 196 ) ); 198 $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox' , 'settings-box'), '20081107' );197 $scripts->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'wp-lists', 'postbox'), '20081107' ); 199 198 $scripts->localize( 'page', 'postL10n', array( 200 199 'cancel' => __('Cancel'), … … 211 210 'saveDraft' => __('Save Draft') 212 211 ) ); 213 $scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox' , 'settings-box'), '20080925' );212 $scripts->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20080925' ); 214 213 $scripts->add( 'comment', '/wp-admin/js/comment.js', array('jquery'), '20081103' ); 215 214 $scripts->localize( 'comment', 'commentL10n', array( … … 220 219 $scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20080709' ); 221 220 $scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20081031' ); 222 $scripts->localize( 'upload', 'uploadL10n', array( 223 'browseTitle' => attribute_escape(__('Browse your files')), 224 'back' => __('« Back'), 225 'directTitle' => attribute_escape(__('Direct link to file')), 226 'edit' => __('Edit'), 227 'thumb' => __('Thumbnail'), 228 'full' => __('Full size'), 229 'icon' => __('Icon'), 230 'title' => __('Title'), 231 'show' => __('Show:'), 232 'link' => __('Link to:'), 233 'file' => __('File'), 234 'page' => __('Page'), 235 'none' => __('None'), 236 'editorText' => attribute_escape(__('Send to editor »')), 237 'insert' => __('Insert'), 238 'urlText' => __('URL'), 239 'desc' => __('Description'), 240 'deleteText' => attribute_escape(__('Delete File')), 241 'saveText' => attribute_escape(__('Save »')), 242 'confirmText' => __("Are you sure you want to delete the file '%title%'?\nClick ok to delete or cancel to go back.") 243 ) ); 221 244 222 $scripts->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20081010' ); 245 223 $scripts->localize( 'admin-widgets', 'widgetsL10n', array( … … 281 259 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); 282 260 283 $scripts->add( 'user-settings', '/wp-admin/js/user-settings.js', array(), '20080829' ); 284 285 $scripts->add( 'posts', '/wp-admin/js/posts.js', array('columns', 'settings-box'), '20080925' ); 286 $scripts->add( 'pages', '/wp-admin/js/pages.js', array('columns', 'settings-box'), '20080925' ); 287 $scripts->add( 'links', '/wp-admin/js/links.js', array('columns', 'settings-box'), '20080925' ); 288 $scripts->add( 'media', '/wp-admin/js/media.js', array('columns', 'settings-box'), '20080925' ); 261 $scripts->add( 'posts', '/wp-admin/js/posts.js', array('columns'), '20080925' ); 262 $scripts->add( 'pages', '/wp-admin/js/pages.js', array('columns'), '20080925' ); 263 $scripts->add( 'links', '/wp-admin/js/links.js', array('columns'), '20080925' ); 264 $scripts->add( 'media', '/wp-admin/js/media.js', array('columns'), '20080925' ); 289 265 290 266 $scripts->add( 'columns', '/wp-admin/js/columns.js', false, '20080910' ); … … 293 269 ) ); 294 270 295 $scripts->add( 'settings-box', '/wp-admin/js/settings-box.js', array( 'jquery' ), '20081107' ); 296 297 $scripts->add( 'dashboard', '/wp-admin/js/dashboard.js', array( 'jquery', 'admin-comments', 'postbox', 'settings-box' ), '20081016' ); 271 $scripts->add( 'dashboard', '/wp-admin/js/dashboard.js', array( 'jquery', 'admin-comments', 'postbox' ), '20081016' ); 298 272 299 273 $scripts->add( 'hoverIntent', '/wp-includes/js/hoverIntent.js', array('jquery'), '20081109' ); 300 $scripts->add( 'menu', '/wp-admin/js/menu.js', array( 'jquery', 'hoverIntent' ), '20081109' );301 274 302 275 } … … 401 374 402 375 $userid = isset($current_user) ? $current_user->ID : 0; 403 wp_localize_script( ' user-settings', 'userSettings', array(376 wp_localize_script( 'common', 'userSettings', array( 404 377 'url' => SITECOOKIEPATH, 405 378 'uid' => $userid,
Note: See TracChangeset
for help on using the changeset viewer.