3
Copyright 2012 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
7
YUI.add('queue-promote', function(Y) {
10
* Adds methods promote, remove, and indexOf to Queue instances.
12
* @module queue-promote
16
Y.mix(Y.Queue.prototype, {
18
* Returns the current index in the queue of the specified item
21
* @param needle {MIXED} the item to search for
22
* @return {Number} the index of the item or -1 if not found
24
indexOf : function (callback) {
25
return Y.Array.indexOf(this._q, callback);
29
* Moves the referenced item to the head of the queue
32
* @param item {MIXED} an item in the queue
34
promote : function (callback) {
35
var index = this.indexOf(callback);
38
this._q.unshift(this._q.splice(index,1)[0]);
43
* Removes the referenced item from the queue
46
* @param item {MIXED} an item in the queue
48
remove : function (callback) {
49
var index = this.indexOf(callback);
52
this._q.splice(index,1);
59
}, '3.5.1' ,{requires:['yui-base']});