Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
YUI.add('queue-promote', function (Y, NAME) {
2
 
3
/**
4
 * Adds methods promote, remove, and indexOf to Queue instances.
5
 *
6
 * @module queue-promote
7
 * @for Queue
8
 */
9
 
10
Y.mix(Y.Queue.prototype, {
11
    /**
12
     * Returns the current index in the queue of the specified item
13
     *
14
     * @method indexOf
15
     * @param needle {MIXED} the item to search for
16
     * @return {Number} the index of the item or -1 if not found
17
     */
18
    indexOf : function (callback) {
19
        return Y.Array.indexOf(this._q, callback);
20
    },
21
 
22
    /**
23
     * Moves the referenced item to the head of the queue
24
     *
25
     * @method promote
26
     * @param item {MIXED} an item in the queue
27
     */
28
    promote : function (callback) {
29
        var index = this.indexOf(callback);
30
 
31
        if (index > -1) {
32
            this._q.unshift(this._q.splice(index,1)[0]);
33
        }
34
    },
35
 
36
    /**
37
     * Removes the referenced item from the queue
38
     *
39
     * @method remove
40
     * @param item {MIXED} an item in the queue
41
     */
42
    remove : function (callback) {
43
        var index = this.indexOf(callback);
44
 
45
        if (index > -1) {
46
            this._q.splice(index,1);
47
        }
48
    }
49
 
50
});
51
 
52
 
53
}, '3.18.1', {"requires": ["yui-base"]});