~andreserl/maas/packaging_precise_rebase

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/queue-promote/queue-promote.js

  • Committer: Andres Rodriguez
  • Date: 2013-03-20 18:12:30 UTC
  • mfrom: (145.2.22 precise.sru)
  • Revision ID: andreserl@ubuntu.com-20130320181230-6l5guc0nhlv2z4p7
Re-base againts latest quantal released branch towards SRU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.5.1 (build 22)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('queue-promote', function(Y) {
 
8
 
 
9
/**
 
10
 * Adds methods promote, remove, and indexOf to Queue instances.
 
11
 *
 
12
 * @module queue-promote
 
13
 * @for Queue
 
14
 */
 
15
 
 
16
Y.mix(Y.Queue.prototype, {
 
17
    /**
 
18
     * Returns the current index in the queue of the specified item
 
19
     * 
 
20
     * @method indexOf
 
21
     * @param needle {MIXED} the item to search for
 
22
     * @return {Number} the index of the item or -1 if not found
 
23
     */
 
24
    indexOf : function (callback) {
 
25
        return Y.Array.indexOf(this._q, callback);
 
26
    },
 
27
 
 
28
    /**
 
29
     * Moves the referenced item to the head of the queue
 
30
     *
 
31
     * @method promote
 
32
     * @param item {MIXED} an item in the queue
 
33
     */
 
34
    promote : function (callback) {
 
35
        var index = this.indexOf(callback);
 
36
 
 
37
        if (index > -1) {
 
38
            this._q.unshift(this._q.splice(index,1)[0]);
 
39
        }
 
40
    },
 
41
 
 
42
    /**
 
43
     * Removes the referenced item from the queue
 
44
     *
 
45
     * @method remove
 
46
     * @param item {MIXED} an item in the queue
 
47
     */
 
48
    remove : function (callback) {
 
49
        var index = this.indexOf(callback);
 
50
 
 
51
        if (index > -1) {
 
52
            this._q.splice(index,1);
 
53
        }
 
54
    }
 
55
 
 
56
});
 
57
 
 
58
 
 
59
}, '3.5.1' ,{requires:['yui-base']});