~bjornt/lazr-js/prefetch-yui-3.5

« back to all changes in this revision

Viewing changes to src-js/lazrjs/yui/collection/arraylist-add-debug.js

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-01-14 23:32:29 UTC
  • mfrom: (197.1.7 yui-3.3.0)
  • Revision ID: launchpad@pqm.canonical.com-20110114233229-r6i4cazdiiw18o7p
Upgrade to YUI 3.3.0 [r=mars]

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3
3
Code licensed under the BSD License:
4
4
http://developer.yahoo.com/yui/license.html
5
 
version: 3.2.0
6
 
build: 2676
 
5
version: 3.3.0
 
6
build: 3167
7
7
*/
8
8
YUI.add('arraylist-add', function(Y) {
9
9
 
17
17
 * Adds methods add and remove to Y.ArrayList
18
18
 * @class ArrayList~add
19
19
 */
20
 
Y.mix( Y.ArrayList.prototype, {
 
20
Y.mix(Y.ArrayList.prototype, {
21
21
 
22
22
    /**
23
23
     * Add a single item to the ArrayList.  Does not prevent duplicates.
24
24
     *
25
25
     * @method add
26
 
     * @param item { mixed } Item presumably of the same type as others in the
27
 
     *                       ArrayList
28
 
     * @param index {Number} (Optional.)  Number representing the position at 
 
26
     * @param { mixed } item Item presumably of the same type as others in the
 
27
     *                       ArrayList.
 
28
     * @param {Number} index (Optional.)  Number representing the position at
29
29
     * which the item should be inserted.
30
 
     * @return {ArrayList} the instance
 
30
     * @return {ArrayList} the instance.
31
31
     * @chainable
32
32
     */
33
 
    add: function ( item, index ) {
 
33
    add: function(item, index) {
34
34
        var items = this._items;
35
35
 
36
36
        if (Y.Lang.isNumber(index)) {
49
49
     * matches.
50
50
     *
51
51
     * @method remove
52
 
     * @param needle { mixed } Item to find and remove from the list
53
 
     * @param all { Boolean } If true, remove all occurrences
54
 
     * @param comparator { Function } optional a/b function to test equivalence
55
 
     * @return {ArrayList} the instance
 
52
     * @param { mixed } needle Item to find and remove from the list.
 
53
     * @param { Boolean } all If true, remove all occurrences.
 
54
     * @param { Function } comparator optional a/b function to test equivalence.
 
55
     * @return {ArrayList} the instance.
56
56
     * @chainable
57
57
     */
58
 
    remove: function ( needle, all, comparator ) {
 
58
    remove: function(needle, all, comparator) {
59
59
        comparator = comparator || this.itemsAreEqual;
60
60
 
61
61
        for (var i = this._items.length - 1; i >= 0; --i) {
62
 
            if ( comparator.call( this, needle, this.item( i ) ) ) {
63
 
                this._items.splice( i, 1 );
64
 
                if ( !all ) {
 
62
            if (comparator.call(this, needle, this.item(i))) {
 
63
                this._items.splice(i, 1);
 
64
                if (!all) {
65
65
                    break;
66
66
                }
67
67
            }
74
74
     * Default comparator for items stored in this list.  Used by remove().
75
75
     *
76
76
     * @method itemsAreEqual
77
 
     * @param a { mixed } item to test equivalence with
78
 
     * @param b { mixed } other item to test equivalance
79
 
     * @return { Boolean } true if items are deemed equivalent
 
77
     * @param { mixed } a item to test equivalence with.
 
78
     * @param { mixed } b other item to test equivalance.
 
79
     * @return { Boolean } true if items are deemed equivalent.
80
80
     */
81
 
    itemsAreEqual: function ( a, b ) {
 
81
    itemsAreEqual: function(a, b) {
82
82
        return a === b;
83
83
    }
84
84
 
85
 
} );
86
 
 
87
 
 
88
 
}, '3.2.0' ,{requires:['arraylist']});
 
85
});
 
86
 
 
87
 
 
88
}, '3.3.0' ,{requires:['arraylist']});