summaryrefslogtreecommitdiffstats
path: root/wp-admin/js
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-10-23 18:28:40 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-10-23 18:28:40 +0000
commit87bb8cd69cc593fe6bed330fb1791eac9df87167 (patch)
tree6b2ad252df89d2a1863198fd44b321b59e42ef54 /wp-admin/js
parent0cbda3349a2571904ea063fdd73e018299919589 (diff)
downloadwordpress-mu-87bb8cd69cc593fe6bed330fb1791eac9df87167.tar.gz
wordpress-mu-87bb8cd69cc593fe6bed330fb1791eac9df87167.tar.xz
wordpress-mu-87bb8cd69cc593fe6bed330fb1791eac9df87167.zip
Merge with WordPress, rev 6285 and untested
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1125 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/js')
-rw-r--r--wp-admin/js/cat.js15
-rw-r--r--wp-admin/js/categories.js24
-rw-r--r--wp-admin/js/custom-fields.js55
-rw-r--r--wp-admin/js/edit-comments.js71
-rw-r--r--wp-admin/js/edit-posts.js22
-rw-r--r--wp-admin/js/link-cat.js10
-rw-r--r--wp-admin/js/users.js41
7 files changed, 110 insertions, 128 deletions
diff --git a/wp-admin/js/cat.js b/wp-admin/js/cat.js
index e697e9b..9cb81cf 100644
--- a/wp-admin/js/cat.js
+++ b/wp-admin/js/cat.js
@@ -1,11 +1,4 @@
-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($) {
+ $('#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>')
+ var a = $('#categorychecklist').wpList( { alt: '', response: 'cat-ajax-response' } );
+} );
diff --git a/wp-admin/js/categories.js b/wp-admin/js/categories.js
index 3cee6c6..23a67c5 100644
--- a/wp-admin/js/categories.js
+++ b/wp-admin/js/categories.js
@@ -1,16 +1,18 @@
-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 = 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;
- };
+ }
+
+ var a = $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } );
});
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..a185774 100644
--- a/wp-admin/js/edit-comments.js
+++ b/wp-admin/js/edit-comments.js
@@ -1,59 +1,26 @@
-addLoadEvent(function() {
- theCommentList = new listMan('the-comment-list');
- if ( !theCommentList )
- return false;
+var list; var extra;
+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;
- }
+var dimAfter = function( r, settings ) {
+ var a = $('#awaitmod');
+ a.html( parseInt(a.html(),10) + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -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 delAfter = function( r, settings ) {
+ var a = $('#awaitmod');
+ if ( $('#' + settings.element).is('.unapproved') && parseInt(a.html(),10) > 0 ) {
+ a.html( parseInt(a.html(),10) - 1 );
}
- 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
- }
+ if ( extra.size() == 0 || extra.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);
- }
-});
+ list[0].wpList.add( extra.children(':eq(0)').remove().clone() );
+ $('#get-extra-comments').submit();
+}
+
+extra = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
+list = $('#the-comment-list').wpList( { dimAfter : dimAfter, delAfter : delAfter, addColor: 'none' } );
+} );
diff --git a/wp-admin/js/edit-posts.js b/wp-admin/js/edit-posts.js
new file mode 100644
index 0000000..c85fba9
--- /dev/null
+++ b/wp-admin/js/edit-posts.js
@@ -0,0 +1,22 @@
+jQuery(function($) {
+var delAfter; var extra; var list;
+
+if ( document.location.href.match(/(\?|&)c=/) )
+ delAfter = function() { $('#comments, #the-comment-list').remove(); }
+else
+ delAfter = function() {
+ list[0].wpList.add( extra.children(':eq(0)').remove().clone() );
+ $('#get-extra-button').click();
+ }
+
+var addBefore = function ( settings ) {
+ var q = document.location.href.split('?');
+ if ( q[1] )
+ settings.data += '&' + q[1];
+ return settings;
+}
+
+extra = $('#the-extra-list').wpList( { alt: '', addBefore: addBefore, addColor: 'none', delColor: 'none' } );
+list = $('#the-list').wpList( { delAfter: delAfter, addColor: 'none' } );
+
+} );
diff --git a/wp-admin/js/link-cat.js b/wp-admin/js/link-cat.js
index a0775ce..e69de29 100644
--- a/wp-admin/js/link-cat.js
+++ b/wp-admin/js/link-cat.js
@@ -1,10 +0,0 @@
-addLoadEvent(function(){linkcatList=new listMan('linkcategorychecklist');linkcatList.ajaxRespEl='jaxcat';linkcatList.topAdder=1;linkcatList.alt=0;linkcatList.showLink=0;});
-addLoadEvent(newLinkCatAddIn);
-function newLinkCatAddIn() {
- var jaxcat = $('jaxcat');
- if ( !jaxcat )
- return false;
- 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="' + linkcatL10n.add + '"/><input type="hidden"/><span id="howto">' + linkcatL10n.how + '</span></span>');
- $('newcat').onkeypress = function(e) { return killSubmit("linkcatList.ajaxAdder('link-category','jaxcat');", e); };
- $('catadd').onclick = function() { linkcatList.ajaxAdder('link-category', 'jaxcat'); };
-}
diff --git a/wp-admin/js/users.js b/wp-admin/js/users.js
index f249f65..5b89d0f 100644
--- a/wp-admin/js/users.js
+++ b/wp-admin/js/users.js
@@ -1,21 +1,22 @@
-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); }
-}
-);
+jQuery( function($) {
+ var userLists; var list; var addBefore; var addAfter;
-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');
-}
+ addBefore = function( s ) {
+ if ( $( '#role-' + $('#role').val() ).size() )
+ return s;
+ return false;
+ };
+
+ addAfter = function( r, s ) {
+ var roleTable = $( '#role-' + $('role', r).text() );
+
+ var e = $('#user-' + $('user', r).attr('id') );
+ if ( !roleTable.size() ) { return; }
+ if ( !e.size() ) { return; }
+
+ roleTable[0].wpList.add(e.remove().clone());
+ };
+
+ userLists = $('.user-list').wpList();
+ list = $('#user-list').wpList( { addBefore: addBefore, addAfter: addAfter } );
+} );