~smagoun/whoopsie/whoopsie-lp1017637

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/build/arraylist-add/arraylist-add.js

  • Committer: Evan Dandrea
  • Date: 2012-05-09 05:53:45 UTC
  • Revision ID: evan.dandrea@canonical.com-20120509055345-z2j41tmcbf4as5uf
The backend now lives in lp:daisy and the website (errors.ubuntu.com) now lives in lp:errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.5.0 (build 5089)
3
 
Copyright 2012 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('arraylist-add', function(Y) {
8
 
 
9
 
/**
10
 
 * Collection utilities beyond what is provided in the YUI core
11
 
 * @module collection
12
 
 * @submodule arraylist-add
13
 
 * @deprecated Use ModelList or a custom ArrayList subclass
14
 
 */
15
 
 
16
 
/*
17
 
 * Adds methods add and remove to Y.ArrayList
18
 
 */
19
 
Y.mix(Y.ArrayList.prototype, {
20
 
 
21
 
    /**
22
 
     * Add a single item to the ArrayList.  Does not prevent duplicates.
23
 
     *
24
 
     * @method add
25
 
     * @param { mixed } item Item presumably of the same type as others in the
26
 
     *                       ArrayList.
27
 
     * @param {Number} index (Optional.)  Number representing the position at
28
 
     * which the item should be inserted.
29
 
     * @return {ArrayList} the instance.
30
 
     * @for ArrayList
31
 
     * @deprecated Use ModelList or a custom ArrayList subclass
32
 
     * @chainable
33
 
     */
34
 
    add: function(item, index) {
35
 
        var items = this._items;
36
 
 
37
 
        if (Y.Lang.isNumber(index)) {
38
 
            items.splice(index, 0, item);
39
 
        }
40
 
        else {
41
 
            items.push(item);
42
 
        }
43
 
 
44
 
        return this;
45
 
    },
46
 
 
47
 
    /**
48
 
     * Removes first or all occurrences of an item to the ArrayList.  If a
49
 
     * comparator is not provided, uses itemsAreEqual method to determine
50
 
     * matches.
51
 
     *
52
 
     * @method remove
53
 
     * @param { mixed } needle Item to find and remove from the list.
54
 
     * @param { Boolean } all If true, remove all occurrences.
55
 
     * @param { Function } comparator optional a/b function to test equivalence.
56
 
     * @return {ArrayList} the instance.
57
 
     * @for ArrayList
58
 
     * @deprecated Use ModelList or a custom ArrayList subclass
59
 
     * @chainable
60
 
     */
61
 
    remove: function(needle, all, comparator) {
62
 
        comparator = comparator || this.itemsAreEqual;
63
 
 
64
 
        for (var i = this._items.length - 1; i >= 0; --i) {
65
 
            if (comparator.call(this, needle, this.item(i))) {
66
 
                this._items.splice(i, 1);
67
 
                if (!all) {
68
 
                    break;
69
 
                }
70
 
            }
71
 
        }
72
 
 
73
 
        return this;
74
 
    },
75
 
 
76
 
    /**
77
 
     * Default comparator for items stored in this list.  Used by remove().
78
 
     *
79
 
     * @method itemsAreEqual
80
 
     * @param { mixed } a item to test equivalence with.
81
 
     * @param { mixed } b other item to test equivalance.
82
 
     * @return { Boolean } true if items are deemed equivalent.
83
 
     * @for ArrayList
84
 
     * @deprecated Use ModelList or a custom ArrayList subclass
85
 
     */
86
 
    itemsAreEqual: function(a, b) {
87
 
        return a === b;
88
 
    }
89
 
 
90
 
});
91
 
 
92
 
 
93
 
}, '3.5.0' ,{requires:['arraylist']});