diff options
Diffstat (limited to 'wp-admin/js')
-rw-r--r-- | wp-admin/js/blog-switch.js | 15 | ||||
-rw-r--r-- | wp-admin/js/cat.js | 16 | ||||
-rw-r--r-- | wp-admin/js/categories.js | 29 | ||||
-rw-r--r-- | wp-admin/js/comment.js | 18 | ||||
-rw-r--r-- | wp-admin/js/common.js | 37 | ||||
-rw-r--r-- | wp-admin/js/custom-fields.js | 55 | ||||
-rw-r--r-- | wp-admin/js/edit-comments.js | 117 | ||||
-rw-r--r-- | wp-admin/js/editor.js | 35 | ||||
-rw-r--r-- | wp-admin/js/forms.js | 12 | ||||
-rw-r--r-- | wp-admin/js/link.js | 2 | ||||
-rw-r--r-- | wp-admin/js/page.js | 20 | ||||
-rw-r--r-- | wp-admin/js/password-strength-meter.js | 92 | ||||
-rw-r--r-- | wp-admin/js/post.js | 35 | ||||
-rw-r--r-- | wp-admin/js/upload.js | 75 | ||||
-rw-r--r-- | wp-admin/js/users.js | 22 | ||||
-rw-r--r-- | wp-admin/js/widgets.js | 4 |
16 files changed, 321 insertions, 263 deletions
diff --git a/wp-admin/js/blog-switch.js b/wp-admin/js/blog-switch.js new file mode 100644 index 0000000..19cf9ef --- /dev/null +++ b/wp-admin/js/blog-switch.js @@ -0,0 +1,15 @@ +jQuery( function($) { + var form = $( '#all-my-blogs' ).submit( function() { document.location = form.find( 'select' ).val(); return false;} ); + var tab = $('#all-my-blogs-tab a'); + var head = $('#wphead'); + $('.blog-picker-toggle').click( function() { + form.toggle(); + tab.toggleClass( 'current' ); + if ( form.is( ':visible' ) ) { + head.css( 'padding-top', form.height() + 16 ); + } else { + head.css( 'padding-top', 0 ); + } + return false; + } ); +} ); diff --git a/wp-admin/js/cat.js b/wp-admin/js/cat.js index e697e9b..4a64994 100644 --- a/wp-admin/js/cat.js +++ b/wp-admin/js/cat.js @@ -1,11 +1,5 @@ -addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=1;catList.alt=0;catList.showLink=0;}); -addLoadEvent(newCatAddIn); -function newCatAddIn() { - var jaxcat = $('jaxcat'); - if ( !jaxcat ) - return false; - // These multiple blank hidden inputs are needed: https://bugzilla.mozilla.org/show_bug.cgi?id=377815 , #3895 , #4664 - Element.update(jaxcat,'<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="' + catL10n.add + '"/><input type="hidden"/><input type="hidden"/><span id="howto">' + catL10n.how + '</span></span>'); - $('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); }; - $('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); }; -} +jQuery( function($) { + var myConfirm = function() { return '' !== $('#newcat').val(); }; + $('#jaxcat').prepend('<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" class="add:categorychecklist:jaxcat" id="catadd" value="' + catL10n.add + '"/><input type="hidden"/><input type="hidden"/><span id="howto">' + catL10n.how + '</span></span><span id="cat-ajax-response"></span>') + $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response', confirm: myConfirm } ); +} ); diff --git a/wp-admin/js/categories.js b/wp-admin/js/categories.js index 3cee6c6..a327338 100644 --- a/wp-admin/js/categories.js +++ b/wp-admin/js/categories.js @@ -1,16 +1,23 @@ -addLoadEvent(function() { - if (!theList.theList) return false; - document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); }; - theList.addComplete = function(what, where, update, transport) { - var name = getNodeValue(transport.responseXML, 'name').unescapeHTML(); - var id = transport.responseXML.getElementsByTagName(what)[0].getAttribute('id'); - var options = document.forms['addcat'].category_parent.options; +jQuery(function($) { + var options = false + if ( document.forms['addcat'].category_parent ) + options = document.forms['addcat'].category_parent.options; + + var addAfter = function( r, settings ) { + var name = $("<span>" + $('name', r).text() + "</span>").html(); + var id = $('cat', r).attr('id'); options[options.length] = new Option(name, id); - }; - theList.delComplete = function(what, id) { - var options = document.forms['addcat'].category_parent.options; + } + + var delAfter = function( r, settings ) { + var id = $('cat', r).attr('id'); for ( var o = 0; o < options.length; o++ ) if ( id == options[o].value ) options[o] = null; - }; + } + + if ( options ) + $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } ); + else + $('#the-list').wpList(); }); diff --git a/wp-admin/js/comment.js b/wp-admin/js/comment.js index bde9b97..3efdf11 100644 --- a/wp-admin/js/comment.js +++ b/wp-admin/js/comment.js @@ -1,12 +1,26 @@ -addLoadEvent( function() { +jQuery(document).ready( function() { add_postbox_toggles('comment'); + // close postboxes that should be closed + jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); + + // show things that should be visible, hide what should be hidden + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + jQuery('.edit-timestamp').click(function () { if (jQuery('#timestampdiv').is(":hidden")) { jQuery('#timestampdiv').slideDown("normal"); + jQuery('.edit-timestamp').text(commentL10n.cancel); } else { jQuery('#timestampdiv').hide(); + jQuery('#mm').val(jQuery('#hidden_mm').val()); + jQuery('#jj').val(jQuery('#hidden_jj').val()); + jQuery('#aa').val(jQuery('#hidden_aa').val()); + jQuery('#hh').val(jQuery('#hidden_hh').val()); + jQuery('#mn').val(jQuery('#hidden_mn').val()); + jQuery('.edit-timestamp').text(commentL10n.edit); } return false; }); -});
\ No newline at end of file +}); diff --git a/wp-admin/js/common.js b/wp-admin/js/common.js index 9f05e55..6559d7d 100644 --- a/wp-admin/js/common.js +++ b/wp-admin/js/common.js @@ -1,4 +1,4 @@ -addLoadEvent( function() { +jQuery(document).ready( function() { // pulse jQuery('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300); @@ -7,6 +7,39 @@ addLoadEvent( function() { // Basic form validation if ( ( 'undefined' != typeof wpAjax ) && jQuery.isFunction( wpAjax.validateForm ) ) { - jQuery('form').submit( function() { return wpAjax.validateForm( jQuery(this) ); } ); + jQuery('form.validate').submit( function() { return wpAjax.validateForm( jQuery(this) ); } ); } }); + +(function(JQ) { + JQ.fn.tTips = function() { + + JQ('body').append('<div id="tTips"><p id="tTips_inside"></p></div>'); + var TT = JQ('#tTips'); + + this.each(function() { + var el = JQ(this), txt; + + if ( txt = el.attr('title') ) el.attr('tip', txt).removeAttr('title'); + else return; + el.find('img').removeAttr('alt'); + + el.mouseover(function(e) { + txt = el.attr('tip'), o = el.offset();; + + clearTimeout(TT.sD); + TT.find('p').html(txt); + + TT.css({'top': o.top - 43, 'left': o.left - 5}); + TT.sD = setTimeout(function(){TT.fadeIn(150);}, 100); + }); + + el.mouseout(function() { + clearTimeout(TT.sD); + TT.css({display : 'none'}); + }) + }); + } +}(jQuery)); + +jQuery(function(){jQuery('#media-buttons a').tTips();}); diff --git a/wp-admin/js/custom-fields.js b/wp-admin/js/custom-fields.js index ad7a2db..8f2b1a5 100644 --- a/wp-admin/js/custom-fields.js +++ b/wp-admin/js/custom-fields.js @@ -1,26 +1,33 @@ -function customFieldsOnComplete( what, where, update, transport ) { - var pidEl = $('post_ID'); - pidEl.name = 'post_ID'; - pidEl.value = getNodeValue(transport.responseXML, 'postid'); - var aEl = $('hiddenaction') - if ( aEl.value == 'post' ) aEl.value = 'postajaxpost'; -} -addLoadEvent(customFieldsAddIn); -function customFieldsAddIn() { - theList.showLink=0; - theList.addComplete = customFieldsOnComplete; - if (!theList.theList) return false; - inputs = theList.theList.getElementsByTagName('input'); - for ( var i=0; i < inputs.length; i++ ) { - if ('text' == inputs[i].type) { - inputs[i].setAttribute('autocomplete', 'off'); - inputs[i].onkeypress = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.name.slice(5),10) + '");', e); }; - } - if ('updatemeta' == inputs[i].className) { - inputs[i].onclick = function(e) {return killSubmit('theList.ajaxUpdater("meta", "meta-' + parseInt(this.parentNode.parentNode.id.slice(5),10) + '");', e); }; - } +jQuery( function($) { + var before = function() { + var nonce = $('#newmeta [@name=_ajax_nonce]').val(); + var postId = $('#post_ID').val(); + if ( !nonce || !postId ) { return false; } + return [nonce,postId]; } - $('metakeyinput').onkeypress = function(e) {return killSubmit('theList.inputData+="&id="+$("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); }; - $('updatemetasub').onclick = function(e) {return killSubmit('theList.inputData+="&id="+$("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); }; -} + var addBefore = function( s ) { + var b = before(); + if ( !b ) { return false; } + s.data = s.data.replace(/_ajax_nonce=[a-f0-9]+/, '_ajax_nonce=' + b[0]) + '&post_id=' + b[1]; + return s; + }; + + var addAfter = function( r, s ) { + var postId = $('postid', r).text(); + if ( !postId ) { return; } + $('#post_ID').attr( 'name', 'post_ID' ).val( postId ); + var h = $('#hiddenaction'); + if ( 'post' == h.val() ) { h.val( 'postajaxpost' ); } + }; + + var delBefore = function( s ) { + var b = before(); if ( !b ) return false; + s.data._ajax_nonce = b[0]; s.data.post_id = b[1]; + return s; + } + + $('#the-list') + .wpList( { addBefore: addBefore, addAfter: addAfter, delBefore: delBefore } ) + .find('.updatemeta, .deletemeta').attr( 'type', 'button' ); +} ); diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index e1fc68f..f2bf8f8 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -1,59 +1,70 @@ -addLoadEvent(function() { - theCommentList = new listMan('the-comment-list'); - if ( !theCommentList ) - return false; +var theList; var theExtraList; +jQuery(function($) { - theExtraCommentList = new listMan('the-extra-comment-list'); - if ( theExtraCommentList ) { - theExtraCommentList.showLink = 0; - theExtraCommentList.altOffset = 1; - if ( theExtraCommentList.theList && theExtraCommentList.theList.childNodes ) - var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length; - else - var commentNum = 0; - var urlQ = document.location.href.split('?'); - var params = urlQ[1] ? urlQ[1].toQueryParams() : []; - var search = params['s'] ? params['s'] : ''; - var page = params['apage'] ? params['apage'] : 1; - } - - theCommentList.dimComplete = function(what,id,dimClass) { - var m = document.getElementById('awaitmod'); - if ( document.getElementById(what + '-' + id).className.match(dimClass) ) - m.innerHTML = parseInt(m.innerHTML,10) + 1; - else - m.innerHTML = parseInt(m.innerHTML,10) - 1; - } +var dimAfter = function( r, settings ) { + $('li span.comment-count').each( function() { + var a = $(this); + var n = parseInt(a.html(),10); + n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 ); + if ( n < 0 ) { n = 0; } + a.html( n.toString() ); + $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); + }); + $('.post-com-count span.comment-count').each( function() { + var a = $(this); + var n = parseInt(a.html(),10); + var t = parseInt(a.parent().attr('title'), 10); + if ( $('#' + settings.element).is('.unapproved') ) { // we unapproved a formerly approved comment + n = n - 1; + t = t + 1; + } else { // we approved a formerly unapproved comment + n = n + 1; + t = t - 1; + } + if ( n < 0 ) { n = 0; } + if ( t < 0 ) { t = 0; } + if ( t >= 0 ) { a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); } + if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); } + a.html( n.toString() ); + }); +} - theCommentList.delComplete = function(what,id) { - var m = document.getElementById('awaitmod'); - what = what.split('-')[0]; - if ( document.getElementById(what + '-' + id).className.match('unapproved') ) - m.innerHTML = parseInt(m.innerHTML,10) - 1; - if ( theExtraCommentList && commentNum ) { - var theMover = theExtraCommentList.theList.childNodes[0]; - Element.removeClassName(theMover,'alternate'); - theCommentList.theList.appendChild(theMover); - theExtraCommentList.inputData += '&page=' + page; - if ( search ) - theExtraCommentList.inputData += '&s=' + search; // trust the URL not the search box - theExtraCommentList.addComplete = function() { - if ( theExtraCommentList.theList.childNodes ) - var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length; - else - var commentNum = 0; - } - theExtraCommentList.ajaxAdder( 'comment', 'ajax-response' ); // Dummy Request +var delAfter = function( r, settings ) { + $('li span.comment-count').each( function() { + var a = $(this); + var n = parseInt(a.html(),10); + if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment + n = n - 1; + } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove" + n = n + 1; } + if ( n < 0 ) { n = 0; } + a.html( n.toString() ); + $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); + }); + $('.post-com-count span.comment-count').each( function() { + var a = $(this); + if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment + var t = parseInt(a.parent().attr('title'), 10); + if ( t < 1 ) { return; } + t = t - 1; + a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); + if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); } + return; + } + var n = parseInt(a.html(),10) - 1; + a.html( n.toString() ); + }); + + if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) { + return; } - if ( theList ) // the post list: edit.php - theList.delComplete = function() { - var comments = document.getElementById('comments'); - var commdel = encloseFunc(function(a){a.parentNode.removeChild(a);},comments); - var listdel = encloseFunc(function(a){a.parentNode.removeChild(a);},theCommentList.theList); - setTimeout(commdel,705); - setTimeout(listdel,705); - } -}); + theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() ); + $('#get-extra-comments').submit(); +} + +theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } ); +theList = $('#the-comment-list').wpList( { alt: '', dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ); +} ); diff --git a/wp-admin/js/editor.js b/wp-admin/js/editor.js index a5500ec..757fd30 100644 --- a/wp-admin/js/editor.js +++ b/wp-admin/js/editor.js @@ -24,36 +24,45 @@ switchEditors = { }, pre_wpautop : function(content) { - // We have a TON of cleanup to do. + // We have a TON of cleanup to do. Line breaks are already stripped. - // Remove anonymous, empty paragraphs. - content = content.replace(new RegExp('<p>(\\s| |<br />)*</p>', 'mg'), ''); + // Pretty it up for the source editor + var blocklist1 = 'blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|pre|p'; + content = content.replace(new RegExp('\\s*</('+blocklist1+')>\\s*', 'mg'), '</$1>\n'); + content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>'); // Mark </p> if it has any attributes. - content = content.replace(new RegExp('(<p[^>]+>.*?)</p>', 'mg'), '$1</p#>'); + content = content.replace(new RegExp('(<p [^>]+>.*?)</p>', 'mg'), '$1</p#>'); - // Get it ready for wpautop. + // Sepatate <div> containing <p> + content = content.replace(new RegExp('<div([^>]*)>\\s*<p>', 'mgi'), '<div$1>\n\n'); + + // Remove <p> and <br /> content = content.replace(new RegExp('\\s*<p>', 'mgi'), ''); content = content.replace(new RegExp('\\s*</p>\\s*', 'mgi'), '\n\n'); content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n'); content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n'); // Fix some block element newline issues - var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre'; - content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); - content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n'); - content = content.replace(new RegExp('<li>', 'g'), '\t<li>'); + content = content.replace(new RegExp('\\s*<div', 'mg'), '\n<div'); + content = content.replace(new RegExp('</div>\\s*', 'mg'), '</div>\n'); + + var blocklist2 = 'blockquote|ul|ol|li|table|thead|tr|th|td|h[1-6]|pre'; + content = content.replace(new RegExp('\\s*<(('+blocklist2+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); + content = content.replace(new RegExp('\\s*</('+blocklist2+')>\\s*', 'mg'), '</$1>\n'); + content = content.replace(new RegExp('<li([^>]*)>', 'g'), '\t<li$1>'); if ( content.indexOf('<object') != -1 ) { - content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'g'), "<param$1>"); // no pee inside object/embed - content = content.replace(new RegExp('\\s*</embed>\\s*', 'g'), '</embed>'); + content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'mg'), "<param$1>"); + content = content.replace(new RegExp('\\s*</embed>\\s*', 'mg'), '</embed>'); } // Unmark special paragraph closing tags content = content.replace(new RegExp('</p#>', 'g'), '</p>\n'); - content = content.replace(new RegExp('\\s*(<p[^>]+>.*</p>)', 'mg'), '\n$1'); + content = content.replace(new RegExp('\\s*(<p [^>]+>.*</p>)', 'mg'), '\n$1'); - // Trim trailing whitespace + // Trim whitespace + content = content.replace(new RegExp('^\\s*', ''), ''); content = content.replace(new RegExp('\\s*$', ''), ''); // Hope. diff --git a/wp-admin/js/forms.js b/wp-admin/js/forms.js index 21a62f4..6cb2cb7 100644 --- a/wp-admin/js/forms.js +++ b/wp-admin/js/forms.js @@ -1,10 +1,10 @@ function checkAll(form) { for (i = 0, n = form.elements.length; i < n; i++) { - if(form.elements[i].type == "checkbox" && !(form.elements[i].hasAttribute('onclick'))) { - if(form.elements[i].checked == true) - form.elements[i].checked = false; - else - form.elements[i].checked = true; + if(form.elements[i].type == "checkbox" && !(form.elements[i].getAttribute('onclick',2))) { + if(form.elements[i].checked == true) + form.elements[i].checked = false; + else + form.elements[i].checked = true; } } } @@ -28,4 +28,4 @@ function checkAllUsers(role) { inp.checked = true; else inp.checked = false; -}
\ No newline at end of file +} diff --git a/wp-admin/js/link.js b/wp-admin/js/link.js index 9f5a28d..cfc0f94 100644 --- a/wp-admin/js/link.js +++ b/wp-admin/js/link.js @@ -1,4 +1,4 @@ -addLoadEvent( function() { +jQuery(document).ready( function() { jQuery('#link_name').focus(); // postboxes add_postbox_toggles('link'); diff --git a/wp-admin/js/page.js b/wp-admin/js/page.js index 02fd708..0060e8e 100644 --- a/wp-admin/js/page.js +++ b/wp-admin/js/page.js @@ -1,16 +1,32 @@ -addLoadEvent( function() { +jQuery(document).ready( function() { add_postbox_toggles('page'); make_slugedit_clickable(); + // close postboxes that should be closed + jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); + + // show things that should be visible, hide what should be hidden + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + + jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); + // hide advanced slug field jQuery('#pageslugdiv').hide(); jQuery('.edit-timestamp').click(function () { if (jQuery('#timestampdiv').is(":hidden")) { jQuery('#timestampdiv').slideDown("normal"); + jQuery('.edit-timestamp').text(postL10n.cancel); } else { jQuery('#timestampdiv').hide(); + jQuery('#mm').val(jQuery('#hidden_mm').val()); + jQuery('#jj').val(jQuery('#hidden_jj').val()); + jQuery('#aa').val(jQuery('#hidden_aa').val()); + jQuery('#hh').val(jQuery('#hidden_hh').val()); + jQuery('#mn').val(jQuery('#hidden_mn').val()); + jQuery('.edit-timestamp').text(postL10n.edit); } return false; }); -});
\ No newline at end of file +}); diff --git a/wp-admin/js/password-strength-meter.js b/wp-admin/js/password-strength-meter.js index eba43fc..e90c3e0 100644 --- a/wp-admin/js/password-strength-meter.js +++ b/wp-admin/js/password-strength-meter.js @@ -3,15 +3,13 @@ // Firas Kassem phiras.wordpress.com || phiras at gmail {dot} com // for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/ -var shortPass = 'Too short' -var badPass = 'Bad' -var goodPass = 'Good' -var strongPass = 'Strong' +var shortPass = pwsL10n.short +var badPass = pwsL10n.bad +var goodPass = pwsL10n.good +var strongPass = pwsL10n.strong - -function passwordStrength(password,username) -{ +function passwordStrength(password,username) { score = 0 //password < 4 @@ -79,84 +77,4 @@ function checkRepetition(pLen,str) { } return res } -// Password strength meter -// This jQuery plugin is written by firas kassem [2007.04.05] -// Firas Kassem phiras.wordpress.com || phiras at gmail {dot} com -// for more information : http://phiras.wordpress.com/2007/04/08/password-strength-meter-a-jquery-plugin/ - -var shortPass = 'Too short' -var badPass = 'Bad' -var goodPass = 'Good' -var strongPass = 'Strong' - - - -function passwordStrength(password,username) -{ - score = 0 - - //password < 4 - if (password.length < 4 ) { return shortPass } - - //password == username - if (password.toLowerCase()==username.toLowerCase()) return badPass - - //password length - score += password.length * 4 - score += ( checkRepetition(1,password).length - password.length ) * 1 - score += ( checkRepetition(2,password).length - password.length ) * 1 - score += ( checkRepetition(3,password).length - password.length ) * 1 - score += ( checkRepetition(4,password).length - password.length ) * 1 - - //password has 3 numbers - if (password.match(/(.*[0-9].*[0-9].*[0-9])/)) score += 5 - - //password has 2 sybols - if (password.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)) score += 5 - - //password has Upper and Lower chars - if (password.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)) score += 10 - - //password has number and chars - if (password.match(/([a-zA-Z])/) && password.match(/([0-9])/)) score += 15 - // - //password has number and symbol - if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([0-9])/)) score += 15 - //password has char and symbol - if (password.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && password.match(/([a-zA-Z])/)) score += 15 - - //password is just a nubers or chars - if (password.match(/^\w+$/) || password.match(/^\d+$/) ) score -= 10 - - //verifing 0 < score < 100 - if ( score < 0 ) score = 0 - if ( score > 100 ) score = 100 - - if (score < 34 ) return badPass - if (score < 68 ) return goodPass - return strongPass -} - - -// checkRepetition(1,'aaaaaaabcbc') = 'abcbc' -// checkRepetition(2,'aaaaaaabcbc') = 'aabc' -// checkRepetition(2,'aaaaaaabcdbcd') = 'aabcd' - -function checkRepetition(pLen,str) { - res = "" - for ( i=0; i<str.length ; i++ ) { - repeated=true - for (j=0;j < pLen && (j+i+pLen) < str.length;j++) - repeated=repeated && (str.charAt(j+i)==str.charAt(j+i+pLen)) - if (j<pLen) repeated=false - if (repeated) { - i+=pLen-1 - repeated=false - } - else { - res+=str.charAt(i) - } - } - return res -} diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index 9aeafcc..78b22ed 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -58,15 +58,17 @@ function tag_press_key( e ) { } } -addLoadEvent( function() { +jQuery(document).ready( function() { + // close postboxes that should be closed + jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); + + // show things that should be visible, hide what should be hidden + jQuery('.hide-if-no-js').show(); + jQuery('.hide-if-js').hide(); + // postboxes add_postbox_toggles('post'); - // If no tags on the page, skip the tag and category stuff. - if ( !jQuery('#tags-input').size() ) { - return; - } - // Editable slugs make_slugedit_clickable(); @@ -76,7 +78,7 @@ addLoadEvent( function() { jQuery('#tags-input').hide(); tag_update_quickclicks(); // add the quickadd form - jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="button" class="button" id="tagadd" value="' + postL10n.add + '"/><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>'); + jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="button" class="button" id="tagadd" value="' + postL10n.add + '" tabindex="3" /><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>'); jQuery('#tagadd').click( tag_flush_to_text ); jQuery('#newtag').focus(function() { if ( this.value == postL10n.addTag ) @@ -91,6 +93,8 @@ addLoadEvent( function() { jQuery('#publish').click( tag_save_on_publish ); jQuery('#save-post').click( tag_save_on_publish ); + jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); + // auto-suggest stuff jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2 } ); jQuery('#newtag').keypress( tag_press_key ); @@ -149,9 +153,24 @@ addLoadEvent( function() { jQuery('.edit-timestamp').click(function () { if (jQuery('#timestampdiv').is(":hidden")) { jQuery('#timestampdiv').slideDown("normal"); + jQuery('.edit-timestamp').text(postL10n.cancel); } else { jQuery('#timestampdiv').hide(); + jQuery('#mm').val(jQuery('#hidden_mm').val()); + jQuery('#jj').val(jQuery('#hidden_jj').val()); + jQuery('#aa').val(jQuery('#hidden_aa').val()); + jQuery('#hh').val(jQuery('#hidden_hh').val()); + jQuery('#mn').val(jQuery('#hidden_mn').val()); + jQuery('.edit-timestamp').text(postL10n.edit); } return false; - }); + + }); + + // Custom Fields + jQuery('#the-list').wpList( { addAfter: function( xml, s ) { + if ( jQuery.isFunction( autosave_update_post_ID ) ) { + autosave_update_post_ID(s.parsed.responses[0].supplemental.postid); + } + } }); }); diff --git a/wp-admin/js/upload.js b/wp-admin/js/upload.js index d38cdcb..f60f113 100644 --- a/wp-admin/js/upload.js +++ b/wp-admin/js/upload.js @@ -1,21 +1,51 @@ -addLoadEvent( function() { +jQuery(document).ready( function() { theFileList = { currentImage: {ID: 0}, nonce: '', tab: '', postID: 0, - toQueryParams: function(qryStrOrig) { - var params = new Object(); - var qryStr = qryStrOrig; - var i = 0; - do { - params[qryStr.split("=")[0].replace(/&/, "")] = ( qryStr.split("=")[1] ) ? qryStr.split("=")[1].split(/&|$/)[0] : ''; - qryStr = ( qryStr.split("=")[1] ) ? qryStr.split(qryStr.split("=")[1].split(/&|$/)[0])[1] : ''; - i++; - } - while(i < (qryStrOrig.split("=").length - 1)); - return params; + // cookie create and read functions adapted from http://www.quirksmode.org/js/cookies.html + createCookie: function(name,value,days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name+"="+value+expires+"; path=/"; + }, + + readCookie: function(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); + } + return null; + }, + + assignCookieOnChange: function() { + jQuery(this).bind("change", function(){ + theFileList.createCookie(jQuery(this).attr('name'),jQuery(this).attr('id'),365); + }); + }, + + checkCookieSetting: function(name, defaultSetting) { + return this.readCookie(name) ? this.readCookie(name) : defaultSetting; + }, + + toQueryParams: function( s ) { + var r = {}; if ( !s ) { return r; } + var q = s.split('?'); if ( q[1] ) { s = q[1]; } + var pp = s.split('&'); + for ( var i in pp ) { + var p = pp[i].split('='); + r[p[0]] = p[1]; + } + return r; }, toQueryString: function(params) { @@ -116,12 +146,12 @@ addLoadEvent( function() { h += "<form name='uploadoptions' id='uploadoptions' class='alignleft'>"; h += "<table>"; var display = []; - var checked = 'display-title'; + var checkedDisplay = 'display-title'; if ( 1 == this.currentImage.isImage ) { - checked = 'display-full'; + checkedDisplay = 'display-full'; if ( this.currentImage.thumb ) { display.push("<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' /> " + this.thumb + "</label><br />"); - checked = 'display-thumb'; + checkedDisplay = 'display-thumb'; } display.push("<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> " + this.full + "</label>"); } else if ( this.currentImage.thumb ) { @@ -134,9 +164,9 @@ addLoadEvent( function() { h += "</td></tr>"; } - h += "<tr><th>" + this.link + "</th><td>"; - h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' checked='checked'/> " + this.file + "</label><br />"; - h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> " + this.page + "</label><br />"; + var checkedLink = 'link-file'; + h += "<tr><th>" + this.link + "</th><td>"; + h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' /> " + this.file + "</label><br />"; h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> " + this.page + "</label><br />"; h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> " + this.none + "</label>"; h += "</td></tr>"; @@ -148,7 +178,12 @@ addLoadEvent( function() { h += "</div>"; jQuery(h).prependTo('#upload-content'); - jQuery('#' + checked).attr('checked','checked'); + jQuery("input[@name='display']").each(theFileList.assignCookieOnChange); + jQuery("input[@name='link']").each(theFileList.assignCookieOnChange); + checkedDisplay = this.checkCookieSetting('display', checkedDisplay); + checkedLink = this.checkCookieSetting('link', checkedLink); + jQuery('#' + checkedDisplay).attr('checked','checked'); + jQuery('#' + checkedLink).attr('checked','checked'); if (e) return e.stopPropagation(); return false; }, @@ -288,7 +323,7 @@ addLoadEvent( function() { }; - for ( var property in uploadL10n ) + for ( var property in uploadL10n ) theFileList[property] = uploadL10n[property]; theFileList.initializeVars(); theFileList.initializeLinks(); diff --git a/wp-admin/js/users.js b/wp-admin/js/users.js index f249f65..522cbad 100644 --- a/wp-admin/js/users.js +++ b/wp-admin/js/users.js @@ -1,21 +1 @@ -addLoadEvent(function() { - theListEls = document.getElementsByTagName('tbody'); - theUserLists = new Array(); - for ( var l = 0; l < theListEls.length; l++ ) { - if ( theListEls[l].id ) - theUserLists[theListEls[l].id] = new listMan(theListEls[l].id); - } - addUserInputs = document.getElementById('adduser').getElementsByTagName('input'); - for ( var i = 0; i < addUserInputs.length; i++ ) { - addUserInputs[i].onkeypress = function(e) { return killSubmit('addUserSubmit();', e); } - } - document.getElementById('addusersub').onclick = function(e) { return killSubmit('addUserSubmit();', e); } -} -); - -function addUserSubmit() { - var roleEl = document.getElementById('role'); - var role = roleEl.options[roleEl.selectedIndex].value; - if ( !theUserLists['role-' + role] ) return true; - return theUserLists['role-' + role].ajaxAdder('user', 'adduser'); -} +jQuery( function($) { $('#users').wpList(); } ); diff --git a/wp-admin/js/widgets.js b/wp-admin/js/widgets.js index 6bf7f2c..2802f9b 100644 --- a/wp-admin/js/widgets.js +++ b/wp-admin/js/widgets.js @@ -11,7 +11,7 @@ jQuery(function($) { var widgetAnim = $.browser.msie ? function() { var t = $(this); if ( t.is(':visible') ) { - if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"]' ).attr( 'disabled', 'disabled' ); } + if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } li.css( 'marginLeft', 0 ); t.siblings('h4').children('a').text( widgetsL10n.edit ); } else { @@ -25,7 +25,7 @@ jQuery(function($) { var t = $(this); if ( t.is(':visible') ) { - if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"]' ).attr( 'disabled', 'disabled' ); } + if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"], [name*="[submit]"]' ).attr( 'disabled', 'disabled' ); } if ( width > 250 ) li.animate( { marginLeft: 0 } ); t.siblings('h4').children('a').text( widgetsL10n.edit ); |