%PDF- %PDF-
Direktori : /home/riacommer/public_html/admin/vendor/wysihtml5/src/lang/ |
Current File : /home/riacommer/public_html/admin/vendor/wysihtml5/src/lang/array.js |
wysihtml5.lang.array = function(arr) { return { /** * Check whether a given object exists in an array * * @example * wysihtml5.lang.array([1, 2]).contains(1); * // => true */ contains: function(needle) { if (arr.indexOf) { return arr.indexOf(needle) !== -1; } else { for (var i=0, length=arr.length; i<length; i++) { if (arr[i] === needle) { return true; } } return false; } }, /** * Substract one array from another * * @example * wysihtml5.lang.array([1, 2, 3, 4]).without([3, 4]); * // => [1, 2] */ without: function(arrayToSubstract) { arrayToSubstract = wysihtml5.lang.array(arrayToSubstract); var newArr = [], i = 0, length = arr.length; for (; i<length; i++) { if (!arrayToSubstract.contains(arr[i])) { newArr.push(arr[i]); } } return newArr; }, /** * Return a clean native array * * Following will convert a Live NodeList to a proper Array * @example * var childNodes = wysihtml5.lang.array(document.body.childNodes).get(); */ get: function() { var i = 0, length = arr.length, newArray = []; for (; i<length; i++) { newArray.push(arr[i]); } return newArray; } }; };