Make WordPress Core

Ticket #34917: 34917.patch

File 34917.patch, 21.8 KB (added by rommelxcastro, 10 years ago)

rename variables, add dockblocks

  • wp-includes/js/wp-lists.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    1717                dimBefore: null, dimAfter: null
    1818        },
    1919
    20         nonce: function(e,s) {
    21                 var url = wpAjax.unserialize(e.attr('href'));
    22                 return s.nonce || url._ajax_nonce || $('#' + s.element + ' input[name="_ajax_nonce"]').val() || url._wpnonce || $('#' + s.element + ' input[name="_wpnonce"]').val() || 0;
     20        /**
     21         *
     22         * @param {jQuery} el
     23         * @param {Object} settings
     24         * @returns {number|*}
     25         */
     26        nonce: function(el,settings) {
     27                var url = wpAjax.unserialize(el.attr('href'));
     28                return settings.nonce || url._ajax_nonce || $('#' + settings.element + ' input[name="_ajax_nonce"]').val() || url._wpnonce || $('#' + settings.element + ' input[name="_wpnonce"]').val() || 0;
    2329        },
    2430
    2531        /**
    2632         * Extract list item data from a DOM element.
    2733         *
    28          * @param  {HTMLElement} e The DOM element.
    29          * @param  {string}      t
    30          * @return {array}
     34         * @param  {HTMLElement} el The DOM element.
     35         * @param  {string}      filter
     36         * @return {Array}
    3137         */
    32         parseData: function(e,t) {
     38        parseData: function(el,filter) {
    3339                var d = [], wpListsData;
    3440
    3541                try {
    36                         wpListsData = $(e).attr('data-wp-lists') || '';
    37                         wpListsData = wpListsData.match(new RegExp(t+':[\\S]+'));
     42                        wpListsData = $(el).attr('data-wp-lists') || '';
     43                        wpListsData = wpListsData.match(new RegExp(filter+':[\\S]+'));
    3844
    3945                        if ( wpListsData )
    4046                                d = wpListsData[0].split(':');
     
    4349                return d;
    4450        },
    4551
    46         pre: function(e,s,a) {
     52        /**
     53         *
     54         * @param {HTMLElement} el
     55         * @param {Object} settings
     56         * @param a
     57         * @returns {*}
     58         */
     59        pre: function(el,settings,a) {
    4760                var bg, r;
    4861
    49                 s = $.extend( {}, this.wpList.settings, {
     62                settings = $.extend( {}, this.wpList.settings, {
    5063                        element: null,
    5164                        nonce: 0,
    52                         target: e.get(0)
    53                 }, s || {} );
     65                        target: el.get(0)
     66                }, settings || {} );
    5467
    55                 if ( $.isFunction( s.confirm ) ) {
     68                if ( $.isFunction( settings.confirm ) ) {
    5669                        if ( 'add' != a ) {
    57                                 bg = $('#' + s.element).css('backgroundColor');
    58                                 $('#' + s.element).css('backgroundColor', '#FF9966');
     70                                bg = $('#' + settings.element).css('backgroundColor');
     71                                $('#' + settings.element).css('backgroundColor', '#FF9966');
    5972                        }
    60                         r = s.confirm.call(this, e, s, a, bg);
     73                        r = settings.confirm.call(this, el, settings, a, bg);
    6174
    6275                        if ( 'add' != a )
    63                                 $('#' + s.element).css('backgroundColor', bg );
     76                                $('#' + settings.element).css('backgroundColor', bg );
    6477
    6578                        if ( !r )
    6679                                return false;
    6780                }
    6881
    69                 return s;
     82                return settings;
    7083        },
    7184
    72         ajaxAdd: function( e, s ) {
    73                 e = $(e);
    74                 s = s || {};
    75                 var list = this, data = wpList.parseData(e,'add'), es, valid, formData, res, rres;
     85        /**
     86         *
     87         * @param {HTMLElement} el
     88         * @param {Object} settings
     89         * @returns {boolean}
     90         */
     91        ajaxAdd: function( el, settings ) {
     92                el = $(el);
     93                settings = settings || {};
     94                var list = this, data = wpList.parseData(el,'add'), elSettings, valid, formData, parseResponse, rres;
    7695
    77                 s = wpList.pre.call( list, e, s, 'add' );
     96                settings = wpList.pre.call( list, el, settings, 'add' );
    7897
    79                 s.element = data[2] || e.attr( 'id' ) || s.element || null;
     98                settings.element = data[2] || el.attr( 'id' ) || settings.element || null;
    8099
    81100                if ( data[3] )
    82                         s.addColor = '#' + data[3];
     101                        settings.addColor = '#' + data[3];
    83102                else
    84                         s.addColor = s.addColor || '#FFFF33';
     103                        settings.addColor = settings.addColor || '#FFFF33';
    85104
    86                 if ( !s )
     105                if ( !settings )
    87106                        return false;
    88107
    89                 if ( !e.is('[id="' + s.element + '-submit"]') )
    90                         return !wpList.add.call( list, e, s );
     108                if ( !el.is('[id="' + settings.element + '-submit"]') )
     109                        return !wpList.add.call( list, el, settings );
    91110
    92                 if ( !s.element )
     111                if ( !settings.element )
    93112                        return true;
    94113
    95                 s.action = 'add-' + s.what;
     114                settings.action = 'add-' + settings.what;
    96115
    97                 s.nonce = wpList.nonce(e,s);
     116                settings.nonce = wpList.nonce(el,settings);
    98117
    99                 es = $('#' + s.element + ' :input').not('[name="_ajax_nonce"], [name="_wpnonce"], [name="action"]');
    100                 valid = wpAjax.validateForm( '#' + s.element );
     118                elSettings = $('#' + settings.element + ' :input').not('[name="_ajax_nonce"], [name="_wpnonce"], [name="action"]');
     119                valid = wpAjax.validateForm( '#' + settings.element );
    101120
    102121                if ( !valid )
    103122                        return false;
    104123
    105                 s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( data[4] || '' ) ) );
    106                 formData = $.isFunction(es.fieldSerialize) ? es.fieldSerialize() : es.serialize();
     124                settings.data = $.param( $.extend( { _ajax_nonce: settings.nonce, action: settings.action }, wpAjax.unserialize( data[4] || '' ) ) );
     125                formData = $.isFunction(elSettings.fieldSerialize) ? elSettings.fieldSerialize() : elSettings.serialize();
    107126
    108127                if ( formData )
    109                         s.data += '&' + formData;
     128                        settings.data += '&' + formData;
    110129
    111                 if ( $.isFunction(s.addBefore) ) {
    112                         s = s.addBefore( s );
    113                         if ( !s )
     130                if ( $.isFunction(settings.addBefore) ) {
     131                        settings = settings.addBefore( settings );
     132                        if ( !settings )
    114133                                return true;
    115134                }
    116135
    117                 if ( !s.data.match(/_ajax_nonce=[a-f0-9]+/) )
     136                if ( !settings.data.match(/_ajax_nonce=[a-f0-9]+/) )
    118137                        return true;
    119138
    120                 s.success = function(r) {
    121                         res = wpAjax.parseAjaxResponse(r, s.response, s.element);
     139                settings.success = function(response) {
     140                        parseResponse = wpAjax.parseAjaxResponse(response, settings.response, settings.element);
    122141
    123                         rres = r;
     142                        rres = response;
    124143
    125                         if ( !res || res.errors )
     144                        if ( !parseResponse || parseResponse.errors )
    126145                                return false;
    127146
    128                         if ( true === res )
     147                        if ( true === parseResponse )
    129148                                return true;
    130149
    131                         jQuery.each( res.responses, function() {
    132                                 wpList.add.call( list, this.data, $.extend( {}, s, { // this.firstChild.nodevalue
     150                        jQuery.each( parseResponse.responses, function() {
     151                                wpList.add.call( list, this.data, $.extend( {}, settings, { // this.firstChild.nodevalue
    133152                                        pos: this.position || 0,
    134153                                        id: this.id || 0,
    135154                                        oldId: this.oldId || null
     
    137156                        } );
    138157
    139158                        list.wpList.recolor();
    140                         $(list).trigger( 'wpListAddEnd', [ s, list.wpList ] );
    141                         wpList.clear.call(list,'#' + s.element);
     159                        $(list).trigger( 'wpListAddEnd', [ settings, list.wpList ] );
     160                        wpList.clear.call(list,'#' + settings.element);
    142161                };
    143162
    144                 s.complete = function(x, st) {
    145                         if ( $.isFunction(s.addAfter) ) {
    146                                 var _s = $.extend( { xml: x, status: st, parsed: res }, s );
    147                                 s.addAfter( rres, _s );
     163                settings.complete = function(x, st) {
     164                        if ( $.isFunction(settings.addAfter) ) {
     165                                var _s = $.extend( { xml: x, status: st, parsed: parseResponse }, settings );
     166                                settings.addAfter( rres, _s );
    148167                        }
    149168                };
    150169
    151                 $.ajax( s );
     170                $.ajax( settings );
    152171                return false;
    153172        },
    154173
    155174        /**
    156175         * Delete an item in the list via AJAX.
    157176         *
    158          * @param  {HTMLElement} e A DOM element containing item data.
    159          * @param  {Object}      s
     177         * @param  {HTMLElement} el A DOM element containing item data.
     178         * @param  {Object}      settings
    160179         * @return {boolean}
    161180         */
    162         ajaxDel: function( e, s ) {
    163                 e = $(e);
    164                 s = s || {};
    165                 var list = this, data = wpList.parseData(e,'delete'), element, res, rres;
     181        ajaxDel: function( el, settings ) {
     182                el = $(el);
     183                settings = settings || {};
     184                var list = this, data = wpList.parseData(el,'delete'), element, parsedResponse, rres;
    166185
    167                 s = wpList.pre.call( list, e, s, 'delete' );
     186                settings = wpList.pre.call( list, el, settings, 'delete' );
    168187
    169                 s.element = data[2] || s.element || null;
     188                settings.element = data[2] || settings.element || null;
    170189
    171190                if ( data[3] )
    172                         s.delColor = '#' + data[3];
     191                        settings.delColor = '#' + data[3];
    173192                else
    174                         s.delColor = s.delColor || '#faa';
     193                        settings.delColor = settings.delColor || '#faa';
    175194
    176                 if ( !s || !s.element )
     195                if ( !settings || !settings.element )
    177196                        return false;
    178197
    179                 s.action = 'delete-' + s.what;
     198                settings.action = 'delete-' + settings.what;
    180199
    181                 s.nonce = wpList.nonce(e,s);
     200                settings.nonce = wpList.nonce(el,settings);
    182201
    183                 s.data = $.extend(
    184                         { action: s.action, id: s.element.split('-').pop(), _ajax_nonce: s.nonce },
     202                settings.data = $.extend(
     203                        { action: settings.action, id: settings.element.split('-').pop(), _ajax_nonce: settings.nonce },
    185204                        wpAjax.unserialize( data[4] || '' )
    186205                );
    187206
    188                 if ( $.isFunction(s.delBefore) ) {
    189                         s = s.delBefore( s, list );
    190                         if ( !s )
     207                if ( $.isFunction(settings.delBefore) ) {
     208                        settings = settings.delBefore( settings, list );
     209                        if ( !settings )
    191210                                return true;
    192211                }
    193212
    194                 if ( !s.data._ajax_nonce )
     213                if ( !settings.data._ajax_nonce )
    195214                        return true;
    196215
    197                 element = $('#' + s.element);
     216                element = $('#' + settings.element);
    198217
    199                 if ( 'none' != s.delColor ) {
    200                         element.css( 'backgroundColor', s.delColor ).fadeOut( 350, function(){
     218                if ( 'none' != settings.delColor ) {
     219                        element.css( 'backgroundColor', settings.delColor ).fadeOut( 350, function(){
    201220                                list.wpList.recolor();
    202                                 $(list).trigger( 'wpListDelEnd', [ s, list.wpList ] );
     221                                $(list).trigger( 'wpListDelEnd', [ settings, list.wpList ] );
    203222                        });
    204223                } else {
    205224                        list.wpList.recolor();
    206                         $(list).trigger( 'wpListDelEnd', [ s, list.wpList ] );
     225                        $(list).trigger( 'wpListDelEnd', [ settings, list.wpList ] );
    207226                }
    208227
    209                 s.success = function(r) {
    210                         res = wpAjax.parseAjaxResponse(r, s.response, s.element);
    211                         rres = r;
     228                settings.success = function(response) {
     229                        parsedResponse = wpAjax.parseAjaxResponse(response, settings.response, settings.element);
     230                        rres = response;
    212231
    213                         if ( !res || res.errors ) {
     232                        if ( !parsedResponse || parsedResponse.errors ) {
    214233                                element.stop().stop().css( 'backgroundColor', '#faa' ).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
    215234                                return false;
    216235                        }
    217236                };
    218237
    219                 s.complete = function(x, st) {
    220                         if ( $.isFunction(s.delAfter) ) {
     238                settings.complete = function(xml, status) {
     239                        if ( $.isFunction(settings.delAfter) ) {
    221240                                element.queue( function() {
    222                                         var _s = $.extend( { xml: x, status: st, parsed: res }, s );
    223                                         s.delAfter( rres, _s );
     241                                        var _s = $.extend( { xml: xml, status: status, parsed: parsedResponse }, settings );
     242                                        settings.delAfter( rres, _s );
    224243                                }).dequeue();
    225244                        }
    226245                };
    227246
    228                 $.ajax( s );
     247                $.ajax( settings );
    229248                return false;
    230249        },
    231250
    232         ajaxDim: function( e, s ) {
    233                 if ( $(e).parent().css('display') == 'none' ) // Prevent hidden links from being clicked by hotkeys
     251        /**
     252         *
     253         * @param {HTMLElement} el
     254         * @param {Object} settings
     255         * @returns {boolean}
     256         */
     257        ajaxDim: function( el, settings ) {
     258                if ( $(el).parent().css('display') == 'none' ) // Prevent hidden links from being clicked by hotkeys
    234259                        return false;
    235260
    236                 e = $(e);
    237                 s = s || {};
     261                el = $(el);
     262                settings = settings || {};
    238263
    239                 var list = this, data = wpList.parseData(e,'dim'), element, isClass, color, dimColor, res, rres;
     264                var list = this, data = wpList.parseData(el,'dim'), element, isClass, color, dimColor, parsedResponse, rres;
    240265
    241                 s = wpList.pre.call( list, e, s, 'dim' );
     266                settings = wpList.pre.call( list, el, settings, 'dim' );
    242267
    243                 s.element = data[2] || s.element || null;
    244                 s.dimClass =  data[3] || s.dimClass || null;
     268                settings.element = data[2] || settings.element || null;
     269                settings.dimClass =  data[3] || settings.dimClass || null;
    245270
    246271                if ( data[4] )
    247                         s.dimAddColor = '#' + data[4];
     272                        settings.dimAddColor = '#' + data[4];
    248273                else
    249                         s.dimAddColor = s.dimAddColor || '#FFFF33';
     274                        settings.dimAddColor = settings.dimAddColor || '#FFFF33';
    250275
    251276                if ( data[5] )
    252                         s.dimDelColor = '#' + data[5];
     277                        settings.dimDelColor = '#' + data[5];
    253278                else
    254                         s.dimDelColor = s.dimDelColor || '#FF3333';
     279                        settings.dimDelColor = settings.dimDelColor || '#FF3333';
    255280
    256                 if ( !s || !s.element || !s.dimClass )
     281                if ( !settings || !settings.element || !settings.dimClass )
    257282                        return true;
    258283
    259                 s.action = 'dim-' + s.what;
     284                settings.action = 'dim-' + settings.what;
    260285
    261                 s.nonce = wpList.nonce(e,s);
     286                settings.nonce = wpList.nonce(el,settings);
    262287
    263                 s.data = $.extend(
    264                         { action: s.action, id: s.element.split('-').pop(), dimClass: s.dimClass, _ajax_nonce : s.nonce },
     288                settings.data = $.extend(
     289                        { action: settings.action, id: settings.element.split('-').pop(), dimClass: settings.dimClass, _ajax_nonce : settings.nonce },
    265290                        wpAjax.unserialize( data[6] || '' )
    266291                );
    267292
    268                 if ( $.isFunction(s.dimBefore) ) {
    269                         s = s.dimBefore( s );
    270                         if ( !s )
     293                if ( $.isFunction(settings.dimBefore) ) {
     294                        settings = settings.dimBefore( settings );
     295                        if ( !settings )
    271296                                return true;
    272297                }
    273298
    274                 element = $('#' + s.element);
    275                 isClass = element.toggleClass(s.dimClass).is('.' + s.dimClass);
     299                element = $('#' + settings.element);
     300                isClass = element.toggleClass(settings.dimClass).is('.' + settings.dimClass);
    276301                color = wpList.getColor( element );
    277                 element.toggleClass( s.dimClass );
    278                 dimColor = isClass ? s.dimAddColor : s.dimDelColor;
     302                element.toggleClass( settings.dimClass );
     303                dimColor = isClass ? settings.dimAddColor : settings.dimDelColor;
    279304
    280305                if ( 'none' != dimColor ) {
    281306                        element
    282307                                .animate( { backgroundColor: dimColor }, 'fast' )
    283                                 .queue( function() { element.toggleClass(s.dimClass); $(this).dequeue(); } )
     308                                .queue( function() { element.toggleClass(settings.dimClass); $(this).dequeue(); } )
    284309                                .animate( { backgroundColor: color }, { complete: function() {
    285310                                                $(this).css( 'backgroundColor', '' );
    286                                                 $(list).trigger( 'wpListDimEnd', [ s, list.wpList ] );
     311                                                $(list).trigger( 'wpListDimEnd', [ settings, list.wpList ] );
    287312                                        }
    288313                                });
    289314                } else {
    290                         $(list).trigger( 'wpListDimEnd', [ s, list.wpList ] );
     315                        $(list).trigger( 'wpListDimEnd', [ settings, list.wpList ] );
    291316                }
    292317
    293                 if ( !s.data._ajax_nonce )
     318                if ( !settings.data._ajax_nonce )
    294319                        return true;
    295320
    296                 s.success = function(r) {
    297                         res = wpAjax.parseAjaxResponse(r, s.response, s.element);
    298                         rres = r;
     321                settings.success = function(response) {
     322                        parsedResponse = wpAjax.parseAjaxResponse(response, settings.response, settings.element);
     323                        rres = response;
    299324
    300                         if ( true === res ) {
     325                        if ( true === parsedResponse ) {
    301326                                return true;
    302327                        }
    303328
    304                         if ( ! res || res.errors ) {
    305                                 element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
     329                        if ( ! parsedResponse || parsedResponse.errors ) {
     330                                element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](settings.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
    306331                                return false;
    307332                        }
    308333
    309                         if ( 'undefined' !== typeof res.responses[0].supplemental.comment_link ) {
     334                        if ( 'undefined' !== typeof parsedResponse.responses[0].supplemental.comment_link ) {
    310335                                var submittedOn = element.find( '.submitted-on' ),
    311336                                        commentLink = submittedOn.find( 'a' );
    312337
    313338                                // Comment is approved; link the date field.
    314                                 if ( '' !== res.responses[0].supplemental.comment_link ) {
    315                                         submittedOn.html( $('<a></a>').text( submittedOn.text() ).prop( 'href', res.responses[0].supplemental.comment_link ) );
     339                                if ( '' !== parsedResponse.responses[0].supplemental.comment_link ) {
     340                                        submittedOn.html( $('<a></a>').text( submittedOn.text() ).prop( 'href', parsedResponse.responses[0].supplemental.comment_link ) );
    316341
    317342                                // Comment is not approved; unlink the date field.
    318343                                } else if ( commentLink.length ) {
     
    321346                        }
    322347                };
    323348
    324                 s.complete = function(x, st) {
    325                         if ( $.isFunction(s.dimAfter) ) {
     349                settings.complete = function(xml, status) {
     350                        if ( $.isFunction(settings.dimAfter) ) {
    326351                                element.queue( function() {
    327                                         var _s = $.extend( { xml: x, status: st, parsed: res }, s );
    328                                         s.dimAfter( rres, _s );
     352                                        var _settings = $.extend( { xml: xml, status: status, parsed: parsedResponse }, settings );
     353                                        settings.dimAfter( rres, _settings );
    329354                                }).dequeue();
    330355                        }
    331356                };
    332357
    333                 $.ajax( s );
     358                $.ajax( settings );
    334359                return false;
    335360        },
    336361
     362        /**
     363         *
     364         * @param {HTMLElement} el The DOM element.
     365         * @returns string
     366         */
    337367        getColor: function( el ) {
    338368                var color = jQuery(el).css('backgroundColor');
    339369
    340370                return color || '#ffffff';
    341371        },
    342372
    343         add: function( e, s ) {
    344                 if ( 'string' == typeof e ) {
    345                         e = $( $.trim( e ) ); // Trim leading whitespaces
     373        /**
     374         *
     375         * @param {HTMLElement} el
     376         * @param {Object} settings
     377         * @returns {*}
     378         */
     379        add: function( el, settings ) {
     380                if ( 'string' == typeof el ) {
     381                        el = $( $.trim( el ) ); // Trim leading whitespaces
    346382                } else {
    347                         e = $( e );
     383                        el = $( el );
    348384                }
    349385
    350                 var list = $(this), old = false, _s = { pos: 0, id: 0, oldId: null }, ba, ref, color;
     386                var list = $(this), old = false, _settings = { pos: 0, id: 0, oldId: null }, beforeAfter, ref, color;
    351387
    352                 if ( 'string' == typeof s )
    353                         s = { what: s };
     388                if ( 'string' == typeof settings )
     389                        settings = { what: settings };
    354390
    355                 s = $.extend(_s, this.wpList.settings, s);
     391                settings = $.extend(_settings, this.wpList.settings, settings);
    356392
    357                 if ( !e.length || !s.what )
     393                if ( !el.length || !settings.what )
    358394                        return false;
    359395
    360                 if ( s.oldId )
    361                         old = $('#' + s.what + '-' + s.oldId);
     396                if ( settings.oldId )
     397                        old = $('#' + settings.what + '-' + settings.oldId);
    362398
    363                 if ( s.id && ( s.id != s.oldId || !old || !old.length ) )
    364                         $('#' + s.what + '-' + s.id).remove();
     399                if ( settings.id && ( settings.id != settings.oldId || !old || !old.length ) )
     400                        $('#' + settings.what + '-' + settings.id).remove();
    365401
    366402                if ( old && old.length ) {
    367                         old.before(e);
     403                        old.before(el);
    368404                        old.remove();
    369                 } else if ( isNaN(s.pos) ) {
    370                         ba = 'after';
     405                } else if ( isNaN(settings.pos) ) {
     406                        beforeAfter = 'after';
    371407
    372                         if ( '-' == s.pos.substr(0,1) ) {
    373                                 s.pos = s.pos.substr(1);
    374                                 ba = 'before';
     408                        if ( '-' == settings.pos.substr(0,1) ) {
     409                                settings.pos = settings.pos.substr(1);
     410                                beforeAfter = 'before';
    375411                        }
    376412
    377                         ref = list.find( '#' + s.pos );
     413                        ref = list.find( '#' + settings.pos );
    378414
    379415                        if ( 1 === ref.length )
    380                                 ref[ba](e);
     416                                ref[beforeAfter](el);
    381417                        else
    382                                 list.append(e);
     418                                list.append(el);
    383419
    384                 } else if ( 'comment' != s.what || 0 === $('#' + s.element).length ) {
    385                         if ( s.pos < 0 ) {
    386                                 list.prepend(e);
     420                } else if ( 'comment' != settings.what || 0 === $('#' + settings.element).length ) {
     421                        if ( settings.pos < 0 ) {
     422                                list.prepend(el);
    387423                        } else {
    388                                 list.append(e);
     424                                list.append(el);
    389425                        }
    390426                }
    391427
    392                 if ( s.alt ) {
    393                         if ( ( list.children(':visible').index( e[0] ) + s.altOffset ) % 2 ) { e.removeClass( s.alt ); }
    394                         else { e.addClass( s.alt ); }
     428                if ( settings.alt ) {
     429                        if ( ( list.children(':visible').index( el[0] ) + settings.altOffset ) % 2 ) { el.removeClass( settings.alt ); }
     430                        else { el.addClass( settings.alt ); }
    395431                }
    396432
    397                 if ( 'none' != s.addColor ) {
    398                         color = wpList.getColor( e );
    399                         e.css( 'backgroundColor', s.addColor ).animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } );
     433                if ( 'none' != settings.addColor ) {
     434                        color = wpList.getColor( el );
     435                        el.css( 'backgroundColor', settings.addColor ).animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } );
    400436                }
    401                 list.each( function() { this.wpList.process( e ); } );
    402                 return e;
     437                list.each( function eachList() { this.wpList.process( el ); } );
     438                return el;
    403439        },
    404440
    405         clear: function(e) {
    406                 var list = this, t, tag;
     441        /**
     442         *
     443         * {HTMLElement} el The DOM element.
     444         */
     445        clear: function(el) {
     446                var list = this, inputType, tag;
    407447
    408                 e = $(e);
     448                el = $(el);
    409449
    410                 if ( list.wpList && e.parents( '#' + list.id ).length )
     450                if ( list.wpList && el.parents( '#' + list.id ).length )
    411451                        return;
    412452
    413                 e.find(':input').each( function() {
     453                el.find(':input').each( function eachInput() {
    414454                        if ( $(this).parents('.form-no-clear').length )
    415455                                return;
    416456
    417                         t = this.type.toLowerCase();
     457                        inputType = this.type.toLowerCase();
    418458                        tag = this.tagName.toLowerCase();
    419459
    420                         if ( 'text' == t || 'password' == t || 'textarea' == tag )
     460                        if ( 'text' == inputType || 'password' == inputType || 'textarea' == tag )
    421461                                this.value = '';
    422                         else if ( 'checkbox' == t || 'radio' == t )
     462                        else if ( 'checkbox' == inputType || 'radio' == inputType )
    423463                                this.checked = false;
    424464                        else if ( 'select' == tag )
    425465                                this.selectedIndex = null;
    426466                });
    427467        },
    428468
     469        /**
     470         *
     471         * {HTMLElement} el The DOM element.
     472         */
    429473        process: function(el) {
    430474                var list = this,
    431475                        $el = $(el || document);
     
    448492        },
    449493
    450494        recolor: function() {
    451                 var list = this, items, eo;
     495                var list = this, items, evenOdd;
    452496
    453497                if ( !list.wpList.settings.alt )
    454498                        return;
     
    458502                if ( !items.length )
    459503                        items = $(list).children(':visible');
    460504
    461                 eo = [':even',':odd'];
     505                evenOdd = [':even',':odd'];
    462506
    463507                if ( list.wpList.settings.altOffset % 2 )
    464                         eo.reverse();
     508                        evenOdd.reverse();
    465509
    466                 items.filter(eo[0]).addClass(list.wpList.settings.alt).end().filter(eo[1]).removeClass(list.wpList.settings.alt);
     510                items.filter(evenOdd[0]).addClass(list.wpList.settings.alt).end().filter(evenOdd[1]).removeClass(list.wpList.settings.alt);
    467511        },
    468512
    469513        init: function() {
    470514                var lists = this;
    471515
    472516                lists.wpList.process = function(a) {
    473                         lists.each( function() {
     517                        lists.each( function eachList() {
    474518                                this.wpList.process(a);
    475519                        } );
    476520                };
    477521
    478522                lists.wpList.recolor = function() {
    479                         lists.each( function() {
     523                        lists.each( function eachList() {
    480524                                this.wpList.recolor();
    481525                        } );
    482526                };
    483527        }
    484528};
    485529
     530/**
     531 *
     532 * @param {Object} settings
     533 * @returns {jQuery}
     534 */
    486535$.fn.wpList = function( settings ) {
    487536        this.each( function() {
    488537                var _this = this;
    489538
    490539                this.wpList = { settings: $.extend( {}, wpList.settings, { what: wpList.parseData(this,'list')[1] || '' }, settings ) };
    491                 $.each( fs, function(i,f) { _this.wpList[i] = function( e, s ) { return wpList[f].call( _this, e, s ); }; } );
     540                $.each( fs, function(index,func) { _this.wpList[index] = function( el, settings ) { return wpList[func].call( _this, el, settings ); }; } );
    492541        } );
    493542
    494543        wpList.init.call(this);