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