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