/* * ADOBE SYSTEMS INCORPORATED * Copyright 2007 Adobe Systems Incorporated * All Rights Reserved * * NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the * terms of the Adobe license agreement accompanying it. If you have received this file from a * source other than Adobe, then your use, modification, or distribution of it requires the prior * written permission of Adobe. */ // Copyright 2001-2005 Interakt Online. All rights reserved. /* * * base classes extensions * */ /* * fix ecma compliance * */ if (!Function.prototype.apply) { Function.prototype.apply = function (o,a) { var r; if(!o){ o = {}; } // in case func.apply(null, arguments). o.___apply=this; switch((a && a.length) || 0) { case 0: r = o.___apply(); break; case 1: r = o.___apply(a[0]); break; case 2: r = o.___apply(a[0],a[1]); break; case 3: r = o.___apply(a[0],a[1],a[2]); break; case 4: r = o.___apply(a[0],a[1],a[2],a[3]); break; case 5: r = o.___apply(a[0],a[1],a[2],a[3],a[4]); break; case 6: r = o.___apply(a[0],a[1],a[2],a[3],a[4],a[5]); break; default: for(var i=0, s=""; i=start_slide;--i){ _this[i] = _this[i - nslide]; } // copy inserted elements for(i=start;i=0; i--) { if (_this[i] == x) { return i; } } return -1; }; Array_last = function(_this) { if (_this.length > 0) { return _this[_this.length - 1]; } }; /* String extensions */ // .trim : trim whitespace at beginning and end of a string String_trim = function(_this, str) { if (!str) str = _this; return str.replace(/^\s*/, "").replace(/\s*$/, ""); }; // .normalize_space : return string with extra whitespace removed String_normalize_space = function(_this, str) { if (!str) str = _this; return String_trim(str).replace(/\s+/g, " "); }; String_htmlencode = function(_this, str) { if (!str) str = _this; return str.replace(/\&/g, "&").replace(/\/g, ">").replace(/\"/g, """); }; String_htmldecode = function(_this, str) { if (!str) str = _this; return str.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"").replace(/&/g, "&"); }; /* from ruby.js */ Array_each = function(_this, block) { for (var index = 0; index < _this.length; ++index) { var item = _this[index]; block(item, index) } return _this; }; Number_times = function(_this, block) { for (var i = 0; i < _this; i++) block(i) }; /* helpers */ // min for array, string and as function // [3, 2, 4].min() => 2 Array_min = function(_this) { if (_this.length == 0) return false; if (_this.length == 1) return _this[0]; var min, me, val; min = 0; me = _this; Array_each(me, function(val, i) { if (val < me[min]) { min = i; } }); return _this[min]; }; // "3,2,4".min() => 2 String_min = function(_this) { return Array_min(_this.split(',')); }; // min(3, 2, 4) => 2 function min() { //arguments.each = Array.prototype.each; var a = []; Array_each(arguments, function(val, i) { Array_push(a, val); }); return Array_min(a); }; // max for array, string and as function // [3, 2, 4].max() => 4 Array_max = function(_this) { if (_this.length == 0) return false; if (_this.length == 1) return _this[0]; var max, me, val; max = 0; me = _this; Array_each(me, function(val, i) { if (val > me[max]) { max = i; } }); return _this[max]; }; // "3,2,4".max() => 4 String_max = function(_this) { return Array_max(_this.split(',')); }; // max(3, 2, 4) => 4 function max() { //arguments.each = Array.prototype.each; var a = []; Array_each(arguments, function(val, i) { Array_push(a, val); }); return Array_max(a); };