WordPress.org

Make WordPress Core

Changeset 10457


Ignore:
Timestamp:
01/29/2009 07:00:00 AM (12 years ago)
Author:
azaozz
Message:

Make simple form validation and ajax-add new categories compatible with jQuery 1.3.1

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-link-form.php

    r10259 r10457  
    114114 */
    115115function link_categories_meta_box($link) { ?>
     116<ul id="category-tabs">
     117    <li class="ui-tabs-selected"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>
     118    <li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
     119</ul>
     120
     121<div id="categories-all" class="ui-tabs-panel">
     122    <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
     123        <?php
     124        if ( isset($link->link_id) )
     125            wp_link_category_checklist($link->link_id);
     126        else
     127            wp_link_category_checklist();
     128        ?>
     129    </ul>
     130</div>
     131
     132<div id="categories-pop" class="ui-tabs-panel" style="display: none;">
     133    <ul id="categorychecklist-pop" class="categorychecklist form-no-clear">
     134        <?php wp_popular_terms_checklist('link_category'); ?>
     135    </ul>
     136</div>
     137
    116138<div id="category-adder" class="wp-hidden-children">
    117139    <h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4>
     
    123145        <span id="category-ajax-response"></span>
    124146    </p>
    125 </div>
    126 
    127 <ul id="category-tabs">
    128     <li class="ui-tabs-selected"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>
    129     <li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
    130 </ul>
    131 
    132 <div id="categories-all" class="ui-tabs-panel">
    133     <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
    134         <?php
    135         if ( isset($link->link_id) )
    136             wp_link_category_checklist($link->link_id);
    137         else
    138             wp_link_category_checklist();
    139         ?>
    140     </ul>
    141 </div>
    142 
    143 <div id="categories-pop" class="ui-tabs-panel" style="display: none;">
    144     <ul id="categorychecklist-pop" class="categorychecklist form-no-clear">
    145         <?php wp_popular_terms_checklist('link_category'); ?>
    146     </ul>
    147147</div>
    148148<?php
  • trunk/wp-admin/js/link.dev.js

    r10291 r10457  
    4747    $('#category-add-toggle').click( function() {
    4848        $(this).parents('div:first').toggleClass( 'wp-hidden-children' );
    49         categoryTabs.tabsClick( 1 );
     49        categoryTabs.find('a[href="#categories-all"]').click();
    5050        return false;
    5151    } );
  • trunk/wp-admin/js/link.js

    r10291 r10457  
    1 jQuery(document).ready(function(c){var e,b,a=false,d,f;c("#link_name").focus();postboxes.add_postbox_toggles("link");e=c("#category-tabs").tabs();b=c("#newcat").one("focus",function(){c(this).val("").removeClass("form-input-tip")});c("#category-add-submit").click(function(){b.focus()});d=function(){if(a){return}a=true;var g=c(this),i=g.is(":checked"),h=g.val().toString();c("#in-category-"+h+", #in-popular-category-"+h).attr("checked",i);a=false};f=function(h,g){c(g.what+" response_data",h).each(function(){var i=c(c(this).text());i.find("label").each(function(){var k=c(this),m=k.find("input").val(),n=k.find("input")[0].id,j=c.trim(k.text()),l;c("#"+n).change(d);l=c('<option value="'+parseInt(m,10)+'"></option>').text(j)})})};c("#categorychecklist").wpList({alt:"",what:"link-category",response:"category-ajax-response",addAfter:f});c('a[href="#categories-all"]').click(function(){deleteUserSetting("cats")});c('a[href="#categories-pop"]').click(function(){setUserSetting("cats","pop")});if("pop"==getUserSetting("cats")){c('a[href="#categories-pop"]').click()}c("#category-add-toggle").click(function(){c(this).parents("div:first").toggleClass("wp-hidden-children");e.tabsClick(1);return false});c(".categorychecklist :checkbox").change(d).filter(":checked").change()});
     1jQuery(document).ready(function(c){var e,b,a=false,d,f;c("#link_name").focus();postboxes.add_postbox_toggles("link");e=c("#category-tabs").tabs();b=c("#newcat").one("focus",function(){c(this).val("").removeClass("form-input-tip")});c("#category-add-submit").click(function(){b.focus()});d=function(){if(a){return}a=true;var g=c(this),i=g.is(":checked"),h=g.val().toString();c("#in-category-"+h+", #in-popular-category-"+h).attr("checked",i);a=false};f=function(h,g){c(g.what+" response_data",h).each(function(){var i=c(c(this).text());i.find("label").each(function(){var k=c(this),m=k.find("input").val(),n=k.find("input")[0].id,j=c.trim(k.text()),l;c("#"+n).change(d);l=c('<option value="'+parseInt(m,10)+'"></option>').text(j)})})};c("#categorychecklist").wpList({alt:"",what:"link-category",response:"category-ajax-response",addAfter:f});c('a[href="#categories-all"]').click(function(){deleteUserSetting("cats")});c('a[href="#categories-pop"]').click(function(){setUserSetting("cats","pop")});if("pop"==getUserSetting("cats")){c('a[href="#categories-pop"]').click()}c("#category-add-toggle").click(function(){c(this).parents("div:first").toggleClass("wp-hidden-children");e.find('a[href="#categories-all"]').click();return false});c(".categorychecklist :checkbox").change(d).filter(":checked").change()});
  • trunk/wp-includes/js/wp-ajax-response.dev.js

    r10348 r10457  
    5555    validateForm: function( selector ) {
    5656        selector = jQuery( selector );
    57         return !wpAjax.invalidateForm( selector.find('.form-required').andSelf().filter('.form-required:has(:input[value=""]), .form-required:input[value=""]') ).size();
     57        return !wpAjax.invalidateForm( selector.find('.form-required').filter( function() { return jQuery('input:visible', this).val() == ''; } ) ).size();
    5858    }
    5959}, wpAjax || { noPerm: 'You do not have permission to do that.', broken: 'An unidentified error has occurred.' } );
  • trunk/wp-includes/js/wp-ajax-response.js

    r10348 r10457  
    1 var wpAjax=jQuery.extend({unserialize:function(c){var d={},e,a,b,f;if(!c){return d}e=c.split("?");if(e[1]){c=e[1]}a=c.split("&");for(b in a){if(jQuery.isFunction(a.hasOwnProperty)&&!a.hasOwnProperty(b)){continue}f=a[b].split("=");d[f[0]]=f[1]}return d},parseAjaxResponse:function(a,f,g){var b={},c=jQuery("#"+f).html(""),d="";if(a&&typeof a=="object"&&a.getElementsByTagName("wp_ajax")){b.responses=[];b.errors=false;jQuery("response",a).each(function(){var h=jQuery(this),i=jQuery(this.firstChild),e;e={action:h.attr("action"),what:i.get(0).nodeName,id:i.attr("id"),oldId:i.attr("old_id"),position:i.attr("position")};e.data=jQuery("response_data",i).text();e.supplemental={};if(!jQuery("supplemental",i).children().each(function(){e.supplemental[this.nodeName]=jQuery(this).text()}).size()){e.supplemental=false}e.errors=[];if(!jQuery("wp_error",i).each(function(){var j=jQuery(this).attr("code"),m,l,k;m={code:j,message:this.firstChild.nodeValue,data:false};l=jQuery('wp_error_data[code="'+j+'"]',a);if(l){m.data=l.get()}k=jQuery("form-field",l).text();if(k){j=k}if(g){wpAjax.invalidateForm(jQuery("#"+g+' :input[name="'+j+'"]').parents(".form-field:first"))}d+="<p>"+m.message+"</p>";e.errors.push(m);b.errors=true}).size()){e.errors=false}b.responses.push(e)});if(d.length){c.html('<div class="error">'+d+"</div>")}return b}if(isNaN(a)){return !c.html('<div class="error"><p>'+a+"</p></div>")}a=parseInt(a,10);if(-1==a){return !c.html('<div class="error"><p>'+wpAjax.noPerm+"</p></div>")}else{if(0===a){return !c.html('<div class="error"><p>'+wpAjax.broken+"</p></div>")}}return true},invalidateForm:function(a){return jQuery(a).addClass("form-invalid").change(function(){jQuery(this).removeClass("form-invalid")})},validateForm:function(a){a=jQuery(a);return !wpAjax.invalidateForm(a.find(".form-required").andSelf().filter('.form-required:has(:input[value=""]), .form-required:input[value=""]')).size()}},wpAjax||{noPerm:"You do not have permission to do that.",broken:"An unidentified error has occurred."});jQuery(document).ready(function(a){a("form.validate").submit(function(){return wpAjax.validateForm(a(this))})});
     1var wpAjax=jQuery.extend({unserialize:function(c){var d={},e,a,b,f;if(!c){return d}e=c.split("?");if(e[1]){c=e[1]}a=c.split("&");for(b in a){if(jQuery.isFunction(a.hasOwnProperty)&&!a.hasOwnProperty(b)){continue}f=a[b].split("=");d[f[0]]=f[1]}return d},parseAjaxResponse:function(a,f,g){var b={},c=jQuery("#"+f).html(""),d="";if(a&&typeof a=="object"&&a.getElementsByTagName("wp_ajax")){b.responses=[];b.errors=false;jQuery("response",a).each(function(){var h=jQuery(this),i=jQuery(this.firstChild),e;e={action:h.attr("action"),what:i.get(0).nodeName,id:i.attr("id"),oldId:i.attr("old_id"),position:i.attr("position")};e.data=jQuery("response_data",i).text();e.supplemental={};if(!jQuery("supplemental",i).children().each(function(){e.supplemental[this.nodeName]=jQuery(this).text()}).size()){e.supplemental=false}e.errors=[];if(!jQuery("wp_error",i).each(function(){var j=jQuery(this).attr("code"),m,l,k;m={code:j,message:this.firstChild.nodeValue,data:false};l=jQuery('wp_error_data[code="'+j+'"]',a);if(l){m.data=l.get()}k=jQuery("form-field",l).text();if(k){j=k}if(g){wpAjax.invalidateForm(jQuery("#"+g+' :input[name="'+j+'"]').parents(".form-field:first"))}d+="<p>"+m.message+"</p>";e.errors.push(m);b.errors=true}).size()){e.errors=false}b.responses.push(e)});if(d.length){c.html('<div class="error">'+d+"</div>")}return b}if(isNaN(a)){return !c.html('<div class="error"><p>'+a+"</p></div>")}a=parseInt(a,10);if(-1==a){return !c.html('<div class="error"><p>'+wpAjax.noPerm+"</p></div>")}else{if(0===a){return !c.html('<div class="error"><p>'+wpAjax.broken+"</p></div>")}}return true},invalidateForm:function(a){return jQuery(a).addClass("form-invalid").change(function(){jQuery(this).removeClass("form-invalid")})},validateForm:function(a){a=jQuery(a);return !wpAjax.invalidateForm(a.find(".form-required").filter(function(){return jQuery("input:visible",this).val()==""})).size()}},wpAjax||{noPerm:"You do not have permission to do that.",broken:"An unidentified error has occurred."});jQuery(document).ready(function(a){a("form.validate").submit(function(){return wpAjax.validateForm(a(this))})});
  • trunk/wp-includes/js/wp-lists.dev.js

    r10291 r10457  
    314314            .filter('form').submit( function() { return list.wpList.add(this); } ).end()
    315315            .not('form').click( function() { return list.wpList.add(this); } ).each( function() {
    316                 var addEl = this, c = wpList.parseClass(this,'add')[2] || addEl.id, forms, ins;
     316                var addEl = this, c = wpList.parseClass(this,'add')[2] || addEl.id, forms = [], ins = [];
    317317                if ( !c ) { return; }
    318                 forms = [];
    319                 ins = []; // this is all really inefficient
     318                // this is all really inefficient
    320319                $('#' + c + ' :input').focus( function() { currentFormEl = this; } ).blur( function() { currentFormEl = false; } ).each( function() {
    321320                    ins.push(this);
  • trunk/wp-includes/js/wp-lists.js

    r10291 r10457  
    1 (function(c){var b=false,a={add:"ajaxAdd",del:"ajaxDel",dim:"ajaxDim",process:"process",recolor:"recolor"},d;d={settings:{url:wpListL10n.url,type:"POST",response:"ajax-response",what:"",alt:"alternate",altOffset:0,addColor:null,delColor:null,dimAddColor:null,dimDelColor:null,confirm:null,addBefore:null,addAfter:null,delBefore:null,delAfter:null,dimBefore:null,dimAfter:null},nonce:function(h,g){var f=wpAjax.unserialize(h.attr("href"));return g.nonce||f._ajax_nonce||c("#"+g.element+" input[name=_ajax_nonce]").val()||f._wpnonce||c("#"+g.element+" input[name=_wpnonce]").val()||0},parseClass:function(i,g){var j=[],f;try{f=c(i).attr("class")||"";f=f.match(new RegExp(g+":[\\S]+"));if(f){j=f[0].split(":")}}catch(h){}return j},pre:function(j,h,f){var g,i;h=c.extend({},this.wpList.settings,{element:null,nonce:0,target:j.get(0)},h||{});if(c.isFunction(h.confirm)){if("add"!=f){g=c("#"+h.element).css("backgroundColor");c("#"+h.element).css("backgroundColor","#FF9966")}i=h.confirm.call(this,j,h,f,g);if("add"!=f){c("#"+h.element).css("backgroundColor",g)}if(!i){return false}}return h},ajaxAdd:function(k,g){k=c(k);g=g||{};var i=this,f=d.parseClass(k,"add"),l,h,j;g=d.pre.call(i,k,g,"add");g.element=f[2]||k.attr("id")||g.element||null;if(f[3]){g.addColor="#"+f[3]}else{g.addColor=g.addColor||"#FFFF33"}if(!g){return false}if(!k.is("[class^=add:"+i.id+":]")){return !d.add.call(i,k,g)}if(!g.element){return true}g.action="add-"+g.what;g.nonce=d.nonce(k,g);l=c("#"+g.element+" :input").not("[name=_ajax_nonce], [name=_wpnonce], [name=action]");h=wpAjax.validateForm("#"+g.element);if(!h){return false}g.data=c.param(c.extend({_ajax_nonce:g.nonce,action:g.action},wpAjax.unserialize(f[4]||"")));j=c.isFunction(l.fieldSerialize)?l.fieldSerialize():l.serialize();if(j){g.data+="&"+j}if(c.isFunction(g.addBefore)){g=g.addBefore(g);if(!g){return true}}if(!g.data.match(/_ajax_nonce=[a-f0-9]+/)){return true}g.success=function(m){var e=wpAjax.parseAjaxResponse(m,g.response,g.element),n;if(!e||e.errors){return false}if(true===e){return true}jQuery.each(e.responses,function(){d.add.call(i,this.data,c.extend({},g,{pos:this.position||0,id:this.id||0,oldId:this.oldId||null}))});if(c.isFunction(g.addAfter)){n=this.complete;this.complete=function(o,p){var q=c.extend({xml:o,status:p,parsed:e},g);g.addAfter(m,q);if(c.isFunction(n)){n(o,p)}}}i.wpList.recolor();d.clear.call(i,"#"+g.element)};c.ajax(g);return false},ajaxDel:function(k,h){k=c(k);h=h||{};var j=this,f=d.parseClass(k,"delete"),g,i;h=d.pre.call(j,k,h,"delete");h.element=f[2]||h.element||null;if(f[3]){h.delColor="#"+f[3]}else{h.delColor=h.delColor||"#FF3333"}if(!h||!h.element){return false}h.action="delete-"+h.what;h.nonce=d.nonce(k,h);h.data=c.extend({action:h.action,id:h.element.split("-").pop(),_ajax_nonce:h.nonce},wpAjax.unserialize(f[4]||""));if(c.isFunction(h.delBefore)){h=h.delBefore(h);if(!h){return true}}if(!h.data._ajax_nonce){return true}g=c("#"+h.element);if("none"!=h.delColor){i="slideUp";if(g.css("display").match(/table/)){i="fadeOut"}g.animate({backgroundColor:h.delColor},"fast")[i]("fast").queue(function(){j.wpList.recolor();c(this).dequeue()})}else{j.wpList.recolor()}h.success=function(l){var e=wpAjax.parseAjaxResponse(l,h.response,h.element),m;if(!e||e.errors){g.stop().stop().css("backgroundColor","#FF3333").show().queue(function(){j.wpList.recolor();c(this).dequeue()});return false}if(c.isFunction(h.delAfter)){m=this.complete;this.complete=function(n,o){g.queue(function(){var p=c.extend({xml:n,status:o,parsed:e},h);h.delAfter(l,p);if(c.isFunction(m)){m(n,o)}}).dequeue()}}};c.ajax(h);return false},ajaxDim:function(l,i){if(c(l).parent().css("display")=="none"){return false}l=c(l);i=i||{};var k=this,f=d.parseClass(l,"dim"),h,m,g,j;i=d.pre.call(k,l,i,"dim");i.element=f[2]||i.element||null;i.dimClass=f[3]||i.dimClass||null;if(f[4]){i.dimAddColor="#"+f[4]}else{i.dimAddColor=i.dimAddColor||"#FFFF33"}if(f[5]){i.dimDelColor="#"+f[5]}else{i.dimDelColor=i.dimDelColor||"#FF3333"}if(!i||!i.element||!i.dimClass){return true}i.action="dim-"+i.what;i.nonce=d.nonce(l,i);i.data=c.extend({action:i.action,id:i.element.split("-").pop(),dimClass:i.dimClass,_ajax_nonce:i.nonce},wpAjax.unserialize(f[6]||""));if(c.isFunction(i.dimBefore)){i=i.dimBefore(i);if(!i){return true}}h=c("#"+i.element);m=h.toggleClass(i.dimClass).is("."+i.dimClass);g=d.getColor(h);h.toggleClass(i.dimClass);j=m?i.dimAddColor:i.dimDelColor;if("none"!=j){h.animate({backgroundColor:j},"fast").queue(function(){h.toggleClass(i.dimClass);c(this).dequeue()}).animate({backgroundColor:g},{complete:function(){c(this).css("backgroundColor","")}})}if(!i.data._ajax_nonce){return true}i.success=function(n){var e=wpAjax.parseAjaxResponse(n,i.response,i.element),p;if(!e||e.errors){h.stop().stop().css("backgroundColor","#FF3333")[m?"removeClass":"addClass"](i.dimClass).show().queue(function(){k.wpList.recolor();c(this).dequeue()});return false}if(c.isFunction(i.dimAfter)){p=this.complete;this.complete=function(o,q){h.queue(function(){var r=c.extend({xml:o,status:q,parsed:e},i);i.dimAfter(n,r);if(c.isFunction(p)){p(o,q)}}).dequeue()}}};c.ajax(i);return false},getColor:function(f){if(f.constructor==Object){f=f.get(0)}var g=f,e,h=new RegExp("rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\)","i");do{e=jQuery.curCSS(g,"backgroundColor");if(e!=""&&e!="transparent"&&!e.match(h)||jQuery.nodeName(g,"body")){break}}while(g=g.parentNode);return e||"#ffffff"},add:function(l,h){l=c(l);var j=c(this),f=false,k={pos:0,id:0,oldId:null},m,i,g;if("string"==typeof h){h={what:h}}h=c.extend(k,this.wpList.settings,h);if(!l.size()||!h.what){return false}if(h.oldId){f=c("#"+h.what+"-"+h.oldId)}if(h.id&&(h.id!=h.oldId||!f||!f.size())){c("#"+h.what+"-"+h.id).remove()}if(f&&f.size()){f.replaceWith(l)}else{if(isNaN(h.pos)){m="after";if("-"==h.pos.substr(0,1)){h.pos=h.pos.substr(1);m="before"}i=j.find("#"+h.pos);if(1===i.size()){i[m](l)}else{j.append(l)}}else{if(h.pos<0){j.prepend(l)}else{j.append(l)}}}if(h.alt){if((j.children(":visible").index(l[0])+h.altOffset)%2){l.removeClass(h.alt)}else{l.addClass(h.alt)}}if("none"!=h.addColor){g=d.getColor(l);l.css("backgroundColor",h.addColor).animate({backgroundColor:g},{complete:function(){c(this).css("backgroundColor","")}})}j.each(function(){this.wpList.process(l)});return l},clear:function(i){var h=this,g,f;i=c(i);if(h.wpList&&i.parents("#"+h.id).size()){return}i.find(":input").each(function(){if(c(this).parents(".form-no-clear").size()){return}g=this.type.toLowerCase();f=this.tagName.toLowerCase();if("text"==g||"password"==g||"textarea"==f){this.value=""}else{if("checkbox"==g||"radio"==g){this.checked=false}else{if("select"==f){this.selectedIndex=null}}}})},process:function(e){var f=this;c("[class^=add:"+f.id+":]",e||null).filter("form").submit(function(){return f.wpList.add(this)}).end().not("form").click(function(){return f.wpList.add(this)}).each(function(){var j=this,i=d.parseClass(this,"add")[2]||j.id,g,h;if(!i){return}g=[];h=[];c("#"+i+" :input").focus(function(){b=this}).blur(function(){b=false}).each(function(){h.push(this);var k=c(this).parents("form:first").get(0);if(c.inArray(k,g)<0){g.push(k)}});c(g).submit(function(){if(0<=c.inArray(b,h)){c(j).trigger("click");c(b).focus();return false}})});c("[class^=delete:"+f.id+":]",e||null).click(function(){return f.wpList.del(this)});c("[class^=dim:"+f.id+":]",e||null).click(function(){return f.wpList.dim(this)})},recolor:function(){var g=this,f,e;if(!g.wpList.settings.alt){return}f=c(".list-item:visible",g);if(!f.size()){f=c(g).children(":visible")}e=[":even",":odd"];if(g.wpList.settings.altOffset%2){e.reverse()}f.filter(e[0]).addClass(g.wpList.settings.alt).end().filter(e[1]).removeClass(g.wpList.settings.alt)},init:function(){var e=this;e.wpList.process=function(f){e.each(function(){this.wpList.process(f)})};e.wpList.recolor=function(){e.each(function(){this.wpList.recolor()})}}};c.fn.wpList=function(e){this.each(function(){var f=this;this.wpList={settings:c.extend({},d.settings,{what:d.parseClass(this,"list")[1]||""},e)};c.each(a,function(g,h){f.wpList[g]=function(j,i){return d[h].call(f,j,i)}})});d.init.call(this);this.wpList.process();return this}})(jQuery);
     1(function(c){var b=false,a={add:"ajaxAdd",del:"ajaxDel",dim:"ajaxDim",process:"process",recolor:"recolor"},d;d={settings:{url:wpListL10n.url,type:"POST",response:"ajax-response",what:"",alt:"alternate",altOffset:0,addColor:null,delColor:null,dimAddColor:null,dimDelColor:null,confirm:null,addBefore:null,addAfter:null,delBefore:null,delAfter:null,dimBefore:null,dimAfter:null},nonce:function(h,g){var f=wpAjax.unserialize(h.attr("href"));return g.nonce||f._ajax_nonce||c("#"+g.element+" input[name=_ajax_nonce]").val()||f._wpnonce||c("#"+g.element+" input[name=_wpnonce]").val()||0},parseClass:function(i,g){var j=[],f;try{f=c(i).attr("class")||"";f=f.match(new RegExp(g+":[\\S]+"));if(f){j=f[0].split(":")}}catch(h){}return j},pre:function(j,h,f){var g,i;h=c.extend({},this.wpList.settings,{element:null,nonce:0,target:j.get(0)},h||{});if(c.isFunction(h.confirm)){if("add"!=f){g=c("#"+h.element).css("backgroundColor");c("#"+h.element).css("backgroundColor","#FF9966")}i=h.confirm.call(this,j,h,f,g);if("add"!=f){c("#"+h.element).css("backgroundColor",g)}if(!i){return false}}return h},ajaxAdd:function(k,g){k=c(k);g=g||{};var i=this,f=d.parseClass(k,"add"),l,h,j;g=d.pre.call(i,k,g,"add");g.element=f[2]||k.attr("id")||g.element||null;if(f[3]){g.addColor="#"+f[3]}else{g.addColor=g.addColor||"#FFFF33"}if(!g){return false}if(!k.is("[class^=add:"+i.id+":]")){return !d.add.call(i,k,g)}if(!g.element){return true}g.action="add-"+g.what;g.nonce=d.nonce(k,g);l=c("#"+g.element+" :input").not("[name=_ajax_nonce], [name=_wpnonce], [name=action]");h=wpAjax.validateForm("#"+g.element);if(!h){return false}g.data=c.param(c.extend({_ajax_nonce:g.nonce,action:g.action},wpAjax.unserialize(f[4]||"")));j=c.isFunction(l.fieldSerialize)?l.fieldSerialize():l.serialize();if(j){g.data+="&"+j}if(c.isFunction(g.addBefore)){g=g.addBefore(g);if(!g){return true}}if(!g.data.match(/_ajax_nonce=[a-f0-9]+/)){return true}g.success=function(m){var e=wpAjax.parseAjaxResponse(m,g.response,g.element),n;if(!e||e.errors){return false}if(true===e){return true}jQuery.each(e.responses,function(){d.add.call(i,this.data,c.extend({},g,{pos:this.position||0,id:this.id||0,oldId:this.oldId||null}))});if(c.isFunction(g.addAfter)){n=this.complete;this.complete=function(o,p){var q=c.extend({xml:o,status:p,parsed:e},g);g.addAfter(m,q);if(c.isFunction(n)){n(o,p)}}}i.wpList.recolor();d.clear.call(i,"#"+g.element)};c.ajax(g);return false},ajaxDel:function(k,h){k=c(k);h=h||{};var j=this,f=d.parseClass(k,"delete"),g,i;h=d.pre.call(j,k,h,"delete");h.element=f[2]||h.element||null;if(f[3]){h.delColor="#"+f[3]}else{h.delColor=h.delColor||"#FF3333"}if(!h||!h.element){return false}h.action="delete-"+h.what;h.nonce=d.nonce(k,h);h.data=c.extend({action:h.action,id:h.element.split("-").pop(),_ajax_nonce:h.nonce},wpAjax.unserialize(f[4]||""));if(c.isFunction(h.delBefore)){h=h.delBefore(h);if(!h){return true}}if(!h.data._ajax_nonce){return true}g=c("#"+h.element);if("none"!=h.delColor){i="slideUp";if(g.css("display").match(/table/)){i="fadeOut"}g.animate({backgroundColor:h.delColor},"fast")[i]("fast").queue(function(){j.wpList.recolor();c(this).dequeue()})}else{j.wpList.recolor()}h.success=function(l){var e=wpAjax.parseAjaxResponse(l,h.response,h.element),m;if(!e||e.errors){g.stop().stop().css("backgroundColor","#FF3333").show().queue(function(){j.wpList.recolor();c(this).dequeue()});return false}if(c.isFunction(h.delAfter)){m=this.complete;this.complete=function(n,o){g.queue(function(){var p=c.extend({xml:n,status:o,parsed:e},h);h.delAfter(l,p);if(c.isFunction(m)){m(n,o)}}).dequeue()}}};c.ajax(h);return false},ajaxDim:function(l,i){if(c(l).parent().css("display")=="none"){return false}l=c(l);i=i||{};var k=this,f=d.parseClass(l,"dim"),h,m,g,j;i=d.pre.call(k,l,i,"dim");i.element=f[2]||i.element||null;i.dimClass=f[3]||i.dimClass||null;if(f[4]){i.dimAddColor="#"+f[4]}else{i.dimAddColor=i.dimAddColor||"#FFFF33"}if(f[5]){i.dimDelColor="#"+f[5]}else{i.dimDelColor=i.dimDelColor||"#FF3333"}if(!i||!i.element||!i.dimClass){return true}i.action="dim-"+i.what;i.nonce=d.nonce(l,i);i.data=c.extend({action:i.action,id:i.element.split("-").pop(),dimClass:i.dimClass,_ajax_nonce:i.nonce},wpAjax.unserialize(f[6]||""));if(c.isFunction(i.dimBefore)){i=i.dimBefore(i);if(!i){return true}}h=c("#"+i.element);m=h.toggleClass(i.dimClass).is("."+i.dimClass);g=d.getColor(h);h.toggleClass(i.dimClass);j=m?i.dimAddColor:i.dimDelColor;if("none"!=j){h.animate({backgroundColor:j},"fast").queue(function(){h.toggleClass(i.dimClass);c(this).dequeue()}).animate({backgroundColor:g},{complete:function(){c(this).css("backgroundColor","")}})}if(!i.data._ajax_nonce){return true}i.success=function(n){var e=wpAjax.parseAjaxResponse(n,i.response,i.element),p;if(!e||e.errors){h.stop().stop().css("backgroundColor","#FF3333")[m?"removeClass":"addClass"](i.dimClass).show().queue(function(){k.wpList.recolor();c(this).dequeue()});return false}if(c.isFunction(i.dimAfter)){p=this.complete;this.complete=function(o,q){h.queue(function(){var r=c.extend({xml:o,status:q,parsed:e},i);i.dimAfter(n,r);if(c.isFunction(p)){p(o,q)}}).dequeue()}}};c.ajax(i);return false},getColor:function(f){if(f.constructor==Object){f=f.get(0)}var g=f,e,h=new RegExp("rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\)","i");do{e=jQuery.curCSS(g,"backgroundColor");if(e!=""&&e!="transparent"&&!e.match(h)||jQuery.nodeName(g,"body")){break}}while(g=g.parentNode);return e||"#ffffff"},add:function(l,h){l=c(l);var j=c(this),f=false,k={pos:0,id:0,oldId:null},m,i,g;if("string"==typeof h){h={what:h}}h=c.extend(k,this.wpList.settings,h);if(!l.size()||!h.what){return false}if(h.oldId){f=c("#"+h.what+"-"+h.oldId)}if(h.id&&(h.id!=h.oldId||!f||!f.size())){c("#"+h.what+"-"+h.id).remove()}if(f&&f.size()){f.replaceWith(l)}else{if(isNaN(h.pos)){m="after";if("-"==h.pos.substr(0,1)){h.pos=h.pos.substr(1);m="before"}i=j.find("#"+h.pos);if(1===i.size()){i[m](l)}else{j.append(l)}}else{if(h.pos<0){j.prepend(l)}else{j.append(l)}}}if(h.alt){if((j.children(":visible").index(l[0])+h.altOffset)%2){l.removeClass(h.alt)}else{l.addClass(h.alt)}}if("none"!=h.addColor){g=d.getColor(l);l.css("backgroundColor",h.addColor).animate({backgroundColor:g},{complete:function(){c(this).css("backgroundColor","")}})}j.each(function(){this.wpList.process(l)});return l},clear:function(i){var h=this,g,f;i=c(i);if(h.wpList&&i.parents("#"+h.id).size()){return}i.find(":input").each(function(){if(c(this).parents(".form-no-clear").size()){return}g=this.type.toLowerCase();f=this.tagName.toLowerCase();if("text"==g||"password"==g||"textarea"==f){this.value=""}else{if("checkbox"==g||"radio"==g){this.checked=false}else{if("select"==f){this.selectedIndex=null}}}})},process:function(e){var f=this;c("[class^=add:"+f.id+":]",e||null).filter("form").submit(function(){return f.wpList.add(this)}).end().not("form").click(function(){return f.wpList.add(this)}).each(function(){var j=this,i=d.parseClass(this,"add")[2]||j.id,g=[],h=[];if(!i){return}c("#"+i+" :input").focus(function(){b=this}).blur(function(){b=false}).each(function(){h.push(this);var k=c(this).parents("form:first").get(0);if(c.inArray(k,g)<0){g.push(k)}});c(g).submit(function(){if(0<=c.inArray(b,h)){c(j).trigger("click");c(b).focus();return false}})});c("[class^=delete:"+f.id+":]",e||null).click(function(){return f.wpList.del(this)});c("[class^=dim:"+f.id+":]",e||null).click(function(){return f.wpList.dim(this)})},recolor:function(){var g=this,f,e;if(!g.wpList.settings.alt){return}f=c(".list-item:visible",g);if(!f.size()){f=c(g).children(":visible")}e=[":even",":odd"];if(g.wpList.settings.altOffset%2){e.reverse()}f.filter(e[0]).addClass(g.wpList.settings.alt).end().filter(e[1]).removeClass(g.wpList.settings.alt)},init:function(){var e=this;e.wpList.process=function(f){e.each(function(){this.wpList.process(f)})};e.wpList.recolor=function(){e.each(function(){this.wpList.recolor()})}}};c.fn.wpList=function(e){this.each(function(){var f=this;this.wpList={settings:c.extend({},d.settings,{what:d.parseClass(this,"list")[1]||""},e)};c.each(a,function(g,h){f.wpList[g]=function(j,i){return d[h].call(f,j,i)}})});d.init.call(this);this.wpList.process();return this}})(jQuery);
  • trunk/wp-includes/script-loader.php

    r10444 r10457  
    8686    $scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
    8787
    88     $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), '20090102' );
     88    $scripts->add( 'wp-ajax-response', "/wp-includes/js/wp-ajax-response$suffix.js", array('jquery'), '20090128' );
    8989    $scripts->add_data( 'wp-ajax-response', 'group', 1 );
    9090    $scripts->localize( 'wp-ajax-response', 'wpAjax', array(
     
    9797    $scripts->add_data( 'autosave', 'group', 1 );
    9898
    99     $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20090102' );
     99    $scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20090128' );
    100100    $scripts->add_data( 'wp-lists', 'group', 1 );
    101101    $scripts->localize( 'wp-lists', 'wpListL10n', array(
     
    301301        ) );
    302302
    303         $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20090102' );
     303        $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20090128' );
    304304        $scripts->add_data( 'link', 'group', 1 );
    305305
     
    312312            'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};'
    313313        ) );
     314
    314315        $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20090102' );
    315316
Note: See TracChangeset for help on using the changeset viewer.