Last active
December 24, 2015 18:19
-
-
Save whiskers75/6842487 to your computer and use it in GitHub Desktop.
Safebyte.com source code - modified to ACTUALLY WORK WITH CHROME
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function $A(iterable) { | |
| if (!iterable) return []; | |
| if ("toArray" in Object(iterable)) return iterable.toArray(); | |
| for (var length = iterable.length || 0, results = new Array(length); length--;) results[length] = iterable[length]; | |
| return results | |
| } | |
| function $w(string) { | |
| return Object.isString(string) ? (string = string.strip(), string ? string.split(/\s+/) : []) : [] | |
| } | |
| function $H(object) { | |
| return new Hash(object) | |
| } | |
| function $R(start, end, exclusive) { | |
| return new ObjectRange(start, end, exclusive) | |
| } | |
| function hash_SHA1(msg) { | |
| var K = [1518500249, 1859775393, 2400959708, 3395469782]; | |
| msg += String.fromCharCode(128); | |
| for (var l = msg.length / 4 + 2, N = Math.ceil(l / 16), M = new Array(N), i = 0; N > i; i++) { | |
| M[i] = new Array(16); | |
| for (var j = 0; 16 > j; j++) M[i][j] = msg.charCodeAt(64 * i + 4 * j) << 24 | msg.charCodeAt(64 * i + 4 * j + 1) << 16 | msg.charCodeAt(64 * i + 4 * j + 2) << 8 | msg.charCodeAt(64 * i + 4 * j + 3) | |
| } | |
| M[N - 1][14] = 8 * (msg.length - 1) / Math.pow(2, 32), M[N - 1][14] = Math.floor(M[N - 1][14]), M[N - 1][15] = 4294967295 & 8 * (msg.length - 1); | |
| for (var a, b, c, d, e, H0 = 1732584193, H1 = 4023233417, H2 = 2562383102, H3 = 271733878, H4 = 3285377520, W = new Array(80), i = 0; N > i; i++) { | |
| for (var t = 0; 16 > t; t++) W[t] = M[i][t]; | |
| for (var t = 16; 80 > t; t++) W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1); | |
| a = H0, b = H1, c = H2, d = H3, e = H4; | |
| for (var t = 0; 80 > t; t++) { | |
| var s = Math.floor(t / 20), | |
| T = 4294967295 & ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t]; | |
| e = d, d = c, c = ROTL(b, 30), b = a, a = T | |
| } | |
| H0 = 4294967295 & H0 + a, H1 = 4294967295 & H1 + b, H2 = 4294967295 & H2 + c, H3 = 4294967295 & H3 + d, H4 = 4294967295 & H4 + e | |
| } | |
| return H0.toHexStr() + H1.toHexStr() + H2.toHexStr() + H3.toHexStr() + H4.toHexStr() | |
| } | |
| function f(s, x, y, z) { | |
| switch (s) { | |
| case 0: | |
| return x & y ^ ~x & z; | |
| case 1: | |
| return x ^ y ^ z; | |
| case 2: | |
| return x & y ^ x & z ^ y & z; | |
| case 3: | |
| return x ^ y ^ z | |
| } | |
| } | |
| function ROTL(x, n) { | |
| return x << n | x >>> 32 - n | |
| } | |
| function is_touchable() { | |
| return !!("ontouchstart" in window) || !! ("onmsgesturechange" in window) | |
| } | |
| function _(key) { | |
| return key | |
| } | |
| var Prototype = { | |
| Version: "1.7.1", | |
| Browser: function () { | |
| var ua = navigator.userAgent, | |
| isOpera = "[object Opera]" == Object.prototype.toString.call(window.opera); | |
| return { | |
| IE: !! window.attachEvent && !isOpera, | |
| Opera: isOpera, | |
| WebKit: ua.indexOf("AppleWebKit/") > -1, | |
| Gecko: ua.indexOf("Gecko") > -1 && -1 === ua.indexOf("KHTML"), | |
| MobileSafari: /Apple.*Mobile/.test(ua) | |
| } | |
| }(), | |
| BrowserFeatures: { | |
| XPath: !! document.evaluate, | |
| SelectorsAPI: !! document.querySelector, | |
| ElementExtensions: function () { | |
| var constructor = window.Element || window.HTMLElement; | |
| return !(!constructor || !constructor.prototype) | |
| }(), | |
| SpecificElementExtensions: function () { | |
| if ("undefined" != typeof window.HTMLDivElement) return !0; | |
| var div = document.createElement("div"), | |
| form = document.createElement("form"), | |
| isSupported = !1; | |
| return div.__proto__ && div.__proto__ !== form.__proto__ && (isSupported = !0), div = form = null, isSupported | |
| }() | |
| }, | |
| ScriptFragment: "<script[^>]*>([\\S\\s]*?)</script\\s*>", | |
| JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, | |
| emptyFunction: function () {}, | |
| K: function (x) { | |
| return x | |
| } | |
| }; | |
| Prototype.Browser.MobileSafari && (Prototype.BrowserFeatures.SpecificElementExtensions = !1); | |
| var Class = function () { | |
| function subclass() {} | |
| function create() { | |
| function klass() { | |
| this.initialize.apply(this, arguments) | |
| } | |
| var parent = null, | |
| properties = $A(arguments); | |
| Object.isFunction(properties[0]) && (parent = properties.shift()), Object.extend(klass, Class.Methods), klass.superclass = parent, klass.subclasses = [], parent && (subclass.prototype = parent.prototype, klass.prototype = new subclass, parent.subclasses.push(klass)); | |
| for (var i = 0, length = properties.length; length > i; i++) klass.addMethods(properties[i]); | |
| return klass.prototype.initialize || (klass.prototype.initialize = Prototype.emptyFunction), klass.prototype.constructor = klass, klass | |
| } | |
| function addMethods(source) { | |
| var ancestor = this.superclass && this.superclass.prototype, | |
| properties = Object.keys(source); | |
| IS_DONTENUM_BUGGY && (source.toString != Object.prototype.toString && properties.push("toString"), source.valueOf != Object.prototype.valueOf && properties.push("valueOf")); | |
| for (var i = 0, length = properties.length; length > i; i++) { | |
| var property = properties[i], | |
| value = source[property]; | |
| if (ancestor && Object.isFunction(value) && "$super" == value.argumentNames()[0]) { | |
| var method = value; | |
| value = function (m) { | |
| return function () { | |
| return ancestor[m].apply(this, arguments) | |
| } | |
| }(property).wrap(method), value.valueOf = function (method) { | |
| return function () { | |
| return method.valueOf.call(method) | |
| } | |
| }(method), value.toString = function (method) { | |
| return function () { | |
| return method.toString.call(method) | |
| } | |
| }(method) | |
| } | |
| this.prototype[property] = value | |
| } | |
| return this | |
| } | |
| var IS_DONTENUM_BUGGY = function () { | |
| for (var p in { | |
| toString: 1 | |
| }) | |
| if ("toString" === p) return !1; | |
| return !0 | |
| }(); | |
| return { | |
| create: create, | |
| Methods: { | |
| addMethods: addMethods | |
| } | |
| } | |
| }(); | |
| ! function () { | |
| function Type(o) { | |
| switch (o) { | |
| case null: | |
| return NULL_TYPE; | |
| case void 0: | |
| return UNDEFINED_TYPE | |
| } | |
| var type = typeof o; | |
| switch (type) { | |
| case "boolean": | |
| return BOOLEAN_TYPE; | |
| case "number": | |
| return NUMBER_TYPE; | |
| case "string": | |
| return STRING_TYPE | |
| } | |
| return OBJECT_TYPE | |
| } | |
| function extend(destination, source) { | |
| for (var property in source) destination[property] = source[property]; | |
| return destination | |
| } | |
| function inspect(object) { | |
| try { | |
| return isUndefined(object) ? "undefined" : null === object ? "null" : object.inspect ? object.inspect() : String(object) | |
| } catch (e) { | |
| if (e instanceof RangeError) return "..."; | |
| throw e | |
| } | |
| } | |
| function toJSON(value) { | |
| return Str("", { | |
| "": value | |
| }, []) | |
| } | |
| function Str(key, holder, stack) { | |
| var value = holder[key]; | |
| Type(value) === OBJECT_TYPE && "function" == typeof value.toJSON && (value = value.toJSON(key)); | |
| var _class = _toString.call(value); | |
| switch (_class) { | |
| case NUMBER_CLASS: | |
| case BOOLEAN_CLASS: | |
| case STRING_CLASS: | |
| value = value.valueOf() | |
| } | |
| switch (value) { | |
| case null: | |
| return "null"; | |
| case !0: | |
| return "true"; | |
| case !1: | |
| return "false" | |
| } | |
| var type = typeof value; | |
| switch (type) { | |
| case "string": | |
| return value.inspect(!0); | |
| case "number": | |
| return isFinite(value) ? String(value) : "null"; | |
| case "object": | |
| for (var i = 0, length = stack.length; length > i; i++) | |
| if (stack[i] === value) throw new TypeError("Cyclic reference to '" + value + "' in object"); | |
| stack.push(value); | |
| var partial = []; | |
| if (_class === ARRAY_CLASS) { | |
| for (var i = 0, length = value.length; length > i; i++) { | |
| var str = Str(i, value, stack); | |
| partial.push("undefined" == typeof str ? "null" : str) | |
| } | |
| partial = "[" + partial.join(",") + "]" | |
| } else { | |
| for (var keys = Object.keys(value), i = 0, length = keys.length; length > i; i++) { | |
| var key = keys[i], | |
| str = Str(key, value, stack); | |
| "undefined" != typeof str && partial.push(key.inspect(!0) + ":" + str) | |
| } | |
| partial = "{" + partial.join(",") + "}" | |
| } | |
| return stack.pop(), partial | |
| } | |
| } | |
| function stringify(object) { | |
| return JSON.stringify(object) | |
| } | |
| function toQueryString(object) { | |
| return $H(object).toQueryString() | |
| } | |
| function toHTML(object) { | |
| return object && object.toHTML ? object.toHTML() : String.interpret(object) | |
| } | |
| function keys(object) { | |
| if (Type(object) !== OBJECT_TYPE) throw new TypeError; | |
| var results = []; | |
| for (var property in object) _hasOwnProperty.call(object, property) && results.push(property); | |
| if (IS_DONTENUM_BUGGY) | |
| for (var i = 0; property = DONT_ENUMS[i]; i++) _hasOwnProperty.call(object, property) && results.push(property); | |
| return results | |
| } | |
| function values(object) { | |
| var results = []; | |
| for (var property in object) results.push(object[property]); | |
| return results | |
| } | |
| function clone(object) { | |
| return extend({}, object) | |
| } | |
| function isElement(object) { | |
| return !(!object || 1 != object.nodeType) | |
| } | |
| function isArray(object) { | |
| return _toString.call(object) === ARRAY_CLASS | |
| } | |
| function isHash(object) { | |
| return object instanceof Hash | |
| } | |
| function isFunction(object) { | |
| return _toString.call(object) === FUNCTION_CLASS | |
| } | |
| function isString(object) { | |
| return _toString.call(object) === STRING_CLASS | |
| } | |
| function isNumber(object) { | |
| return _toString.call(object) === NUMBER_CLASS | |
| } | |
| function isDate(object) { | |
| return _toString.call(object) === DATE_CLASS | |
| } | |
| function isUndefined(object) { | |
| return "undefined" == typeof object | |
| } | |
| var _toString = Object.prototype.toString, | |
| _hasOwnProperty = Object.prototype.hasOwnProperty, | |
| NULL_TYPE = "Null", | |
| UNDEFINED_TYPE = "Undefined", | |
| BOOLEAN_TYPE = "Boolean", | |
| NUMBER_TYPE = "Number", | |
| STRING_TYPE = "String", | |
| OBJECT_TYPE = "Object", | |
| FUNCTION_CLASS = "[object Function]", | |
| BOOLEAN_CLASS = "[object Boolean]", | |
| NUMBER_CLASS = "[object Number]", | |
| STRING_CLASS = "[object String]", | |
| ARRAY_CLASS = "[object Array]", | |
| DATE_CLASS = "[object Date]", | |
| NATIVE_JSON_STRINGIFY_SUPPORT = window.JSON && "function" == typeof JSON.stringify && "0" === JSON.stringify(0) && "undefined" == typeof JSON.stringify(Prototype.K), | |
| DONT_ENUMS = ["toString", "toLocaleString", "valueOf", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "constructor"], | |
| IS_DONTENUM_BUGGY = function () { | |
| for (var p in { | |
| toString: 1 | |
| }) | |
| if ("toString" === p) return !1; | |
| return !0 | |
| }(), | |
| hasNativeIsArray = "function" == typeof Array.isArray && Array.isArray([]) && !Array.isArray({}); | |
| hasNativeIsArray && (isArray = Array.isArray), extend(Object, { | |
| extend: extend, | |
| inspect: inspect, | |
| toJSON: NATIVE_JSON_STRINGIFY_SUPPORT ? stringify : toJSON, | |
| toQueryString: toQueryString, | |
| toHTML: toHTML, | |
| keys: Object.keys || keys, | |
| values: values, | |
| clone: clone, | |
| isElement: isElement, | |
| isArray: isArray, | |
| isHash: isHash, | |
| isFunction: isFunction, | |
| isString: isString, | |
| isNumber: isNumber, | |
| isDate: isDate, | |
| isUndefined: isUndefined | |
| }) | |
| }(), Object.extend(Function.prototype, function () { | |
| function update(array, args) { | |
| for (var arrayLength = array.length, length = args.length; length--;) array[arrayLength + length] = args[length]; | |
| return array | |
| } | |
| function merge(array, args) { | |
| return array = slice.call(array, 0), update(array, args) | |
| } | |
| function argumentNames() { | |
| var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1].replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, "").replace(/\s+/g, "").split(","); | |
| return 1 != names.length || names[0] ? names : [] | |
| } | |
| function bind(context) { | |
| if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this; | |
| if (!Object.isFunction(this)) throw new TypeError("The object is not callable."); | |
| var nop = function () {}, __method = this, | |
| args = slice.call(arguments, 1), | |
| bound = function () { | |
| var a = merge(args, arguments), | |
| c = context, | |
| c = this instanceof bound ? this : context; | |
| return __method.apply(c, a) | |
| }; | |
| return nop.prototype = this.prototype, bound.prototype = new nop, bound | |
| } | |
| function bindAsEventListener(context) { | |
| var __method = this, | |
| args = slice.call(arguments, 1); | |
| return function (event) { | |
| var a = update([event || window.event], args); | |
| return __method.apply(context, a) | |
| } | |
| } | |
| function curry() { | |
| if (!arguments.length) return this; | |
| var __method = this, | |
| args = slice.call(arguments, 0); | |
| return function () { | |
| var a = merge(args, arguments); | |
| return __method.apply(this, a) | |
| } | |
| } | |
| function delay(timeout) { | |
| var __method = this, | |
| args = slice.call(arguments, 1); | |
| return timeout = 1e3 * timeout, window.setTimeout(function () { | |
| return __method.apply(__method, args) | |
| }, timeout) | |
| } | |
| function defer() { | |
| var args = update([.01], arguments); | |
| return this.delay.apply(this, args) | |
| } | |
| function wrap(wrapper) { | |
| var __method = this; | |
| return function () { | |
| var a = update([__method.bind(this)], arguments); | |
| return wrapper.apply(this, a) | |
| } | |
| } | |
| function methodize() { | |
| if (this._methodized) return this._methodized; | |
| var __method = this; | |
| return this._methodized = function () { | |
| var a = update([this], arguments); | |
| return __method.apply(null, a) | |
| } | |
| } | |
| var slice = Array.prototype.slice, | |
| extensions = { | |
| argumentNames: argumentNames, | |
| bindAsEventListener: bindAsEventListener, | |
| curry: curry, | |
| delay: delay, | |
| defer: defer, | |
| wrap: wrap, | |
| methodize: methodize | |
| }; | |
| return Function.prototype.bind || (extensions.bind = bind), extensions | |
| }()), | |
| function (proto) { | |
| function toISOString() { | |
| return this.getUTCFullYear() + "-" + (this.getUTCMonth() + 1).toPaddedString(2) + "-" + this.getUTCDate().toPaddedString(2) + "T" + this.getUTCHours().toPaddedString(2) + ":" + this.getUTCMinutes().toPaddedString(2) + ":" + this.getUTCSeconds().toPaddedString(2) + "Z" | |
| } | |
| function toJSON() { | |
| return this.toISOString() | |
| } | |
| proto.toISOString || (proto.toISOString = toISOString), proto.toJSON || (proto.toJSON = toJSON) | |
| }(Date.prototype), RegExp.prototype.match = RegExp.prototype.test, RegExp.escape = function (str) { | |
| return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, "\\$1") | |
| }; | |
| var PeriodicalExecuter = Class.create({ | |
| initialize: function (callback, frequency) { | |
| this.callback = callback, this.frequency = frequency, this.currentlyExecuting = !1, this.registerCallback() | |
| }, | |
| registerCallback: function () { | |
| this.timer = setInterval(this.onTimerEvent.bind(this), 1e3 * this.frequency) | |
| }, | |
| execute: function () { | |
| this.callback(this) | |
| }, | |
| stop: function () { | |
| this.timer && (clearInterval(this.timer), this.timer = null) | |
| }, | |
| onTimerEvent: function () { | |
| if (!this.currentlyExecuting) try { | |
| this.currentlyExecuting = !0, this.execute(), this.currentlyExecuting = !1 | |
| } catch (e) { | |
| throw this.currentlyExecuting = !1, e | |
| } | |
| } | |
| }); | |
| Object.extend(String, { | |
| interpret: function (value) { | |
| return null == value ? "" : String(value) | |
| }, | |
| specialChar: { | |
| "\b": "\\b", | |
| " ": "\\t", | |
| "\n": "\\n", | |
| "\f": "\\f", | |
| "\r": "\\r", | |
| "\\": "\\\\" | |
| } | |
| }), Object.extend(String.prototype, function () { | |
| function prepareReplacement(replacement) { | |
| if (Object.isFunction(replacement)) return replacement; | |
| var template = new Template(replacement); | |
| return function (match) { | |
| return template.evaluate(match) | |
| } | |
| } | |
| function gsub(pattern, replacement) { | |
| var match, result = "", | |
| source = this; | |
| if (replacement = prepareReplacement(replacement), Object.isString(pattern) && (pattern = RegExp.escape(pattern)), !pattern.length && !pattern.source) return replacement = replacement(""), replacement + source.split("").join(replacement) + replacement; | |
| for (; source.length > 0;)(match = source.match(pattern)) ? (result += source.slice(0, match.index), result += String.interpret(replacement(match)), source = source.slice(match.index + match[0].length)) : (result += source, source = ""); | |
| return result | |
| } | |
| function sub(pattern, replacement, count) { | |
| return replacement = prepareReplacement(replacement), count = Object.isUndefined(count) ? 1 : count, this.gsub(pattern, function (match) { | |
| return --count < 0 ? match[0] : replacement(match) | |
| }) | |
| } | |
| function scan(pattern, iterator) { | |
| return this.gsub(pattern, iterator), String(this) | |
| } | |
| function truncate(length, truncation) { | |
| return length = length || 30, truncation = Object.isUndefined(truncation) ? "..." : truncation, this.length > length ? this.slice(0, length - truncation.length) + truncation : String(this) | |
| } | |
| function strip() { | |
| return this.replace(/^\s+/, "").replace(/\s+$/, "") | |
| } | |
| function stripTags() { | |
| return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, "") | |
| } | |
| function stripScripts() { | |
| return this.replace(new RegExp(Prototype.ScriptFragment, "img"), "") | |
| } | |
| function extractScripts() { | |
| var matchAll = new RegExp(Prototype.ScriptFragment, "img"), | |
| matchOne = new RegExp(Prototype.ScriptFragment, "im"); | |
| return (this.match(matchAll) || []).map(function (scriptTag) { | |
| return (scriptTag.match(matchOne) || ["", ""])[1] | |
| }) | |
| } | |
| function evalScripts() { | |
| return this.extractScripts().map(function (script) { | |
| return eval(script) | |
| }) | |
| } | |
| function escapeHTML() { | |
| return this.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">") | |
| } | |
| function unescapeHTML() { | |
| return this.stripTags().replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&") | |
| } | |
| function toQueryParams(separator) { | |
| var match = this.strip().match(/([^?#]*)(#.*)?$/); | |
| return match ? match[1].split(separator || "&").inject({}, function (hash, pair) { | |
| if ((pair = pair.split("="))[0]) { | |
| var key = decodeURIComponent(pair.shift()), | |
| value = pair.length > 1 ? pair.join("=") : pair[0]; | |
| void 0 != value && (value = decodeURIComponent(value)), key in hash ? (Object.isArray(hash[key]) || (hash[key] = [hash[key]]), hash[key].push(value)) : hash[key] = value | |
| } | |
| return hash | |
| }) : {} | |
| } | |
| function toArray() { | |
| return this.split("") | |
| } | |
| function succ() { | |
| return this.slice(0, this.length - 1) + String.fromCharCode(this.charCodeAt(this.length - 1) + 1) | |
| } | |
| function times(count) { | |
| return 1 > count ? "" : new Array(count + 1).join(this) | |
| } | |
| function camelize() { | |
| return this.replace(/-+(.)?/g, function (match, chr) { | |
| return chr ? chr.toUpperCase() : "" | |
| }) | |
| } | |
| function capitalize() { | |
| return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase() | |
| } | |
| function underscore() { | |
| return this.replace(/::/g, "/").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z\d])([A-Z])/g, "$1_$2").replace(/-/g, "_").toLowerCase() | |
| } | |
| function dasherize() { | |
| return this.replace(/_/g, "-") | |
| } | |
| function inspect(useDoubleQuotes) { | |
| var escapedString = this.replace(/[\x00-\x1f\\]/g, function (character) { | |
| return character in String.specialChar ? String.specialChar[character] : "\\u00" + character.charCodeAt().toPaddedString(2, 16) | |
| }); | |
| return useDoubleQuotes ? '"' + escapedString.replace(/"/g, '\\"') + '"' : "'" + escapedString.replace(/'/g, "\\'") + "'" | |
| } | |
| function unfilterJSON(filter) { | |
| return this.replace(filter || Prototype.JSONFilter, "$1") | |
| } | |
| function isJSON() { | |
| var str = this; | |
| return str.blank() ? !1 : (str = str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@"), str = str.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]"), str = str.replace(/(?:^|:|,)(?:\s*\[)+/g, ""), /^[\],:{}\s]*$/.test(str)) | |
| } | |
| function evalJSON(sanitize) { | |
| var json = this.unfilterJSON(), | |
| cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; | |
| cx.test(json) && (json = json.replace(cx, function (a) { | |
| return "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4) | |
| })); | |
| try { | |
| if (!sanitize || json.isJSON()) return eval("(" + json + ")") | |
| } catch (e) {} | |
| throw new SyntaxError("Badly formed JSON string: " + this.inspect()) | |
| } | |
| function parseJSON() { | |
| var json = this.unfilterJSON(); | |
| return JSON.parse(json) | |
| } | |
| function include(pattern) { | |
| return this.indexOf(pattern) > -1 | |
| } | |
| function startsWith(pattern) { | |
| return 0 === this.lastIndexOf(pattern, 0) | |
| } | |
| function endsWith(pattern) { | |
| var d = this.length - pattern.length; | |
| return d >= 0 && this.indexOf(pattern, d) === d | |
| } | |
| function empty() { | |
| return "" == this | |
| } | |
| function blank() { | |
| return /^\s*$/.test(this) | |
| } | |
| function interpolate(object, pattern) { | |
| return new Template(this, pattern).evaluate(object) | |
| } | |
| var NATIVE_JSON_PARSE_SUPPORT = window.JSON && "function" == typeof JSON.parse && JSON.parse('{"test": true}').test; | |
| return { | |
| gsub: gsub, | |
| sub: sub, | |
| scan: scan, | |
| truncate: truncate, | |
| strip: String.prototype.trim || strip, | |
| stripTags: stripTags, | |
| stripScripts: stripScripts, | |
| extractScripts: extractScripts, | |
| evalScripts: evalScripts, | |
| escapeHTML: escapeHTML, | |
| unescapeHTML: unescapeHTML, | |
| toQueryParams: toQueryParams, | |
| parseQuery: toQueryParams, | |
| toArray: toArray, | |
| succ: succ, | |
| times: times, | |
| camelize: camelize, | |
| capitalize: capitalize, | |
| underscore: underscore, | |
| dasherize: dasherize, | |
| inspect: inspect, | |
| unfilterJSON: unfilterJSON, | |
| isJSON: isJSON, | |
| evalJSON: NATIVE_JSON_PARSE_SUPPORT ? parseJSON : evalJSON, | |
| include: include, | |
| startsWith: startsWith, | |
| endsWith: endsWith, | |
| empty: empty, | |
| blank: blank, | |
| interpolate: interpolate | |
| } | |
| }()); | |
| var Template = Class.create({ | |
| initialize: function (template, pattern) { | |
| this.template = template.toString(), this.pattern = pattern || Template.Pattern | |
| }, | |
| evaluate: function (object) { | |
| return object && Object.isFunction(object.toTemplateReplacements) && (object = object.toTemplateReplacements()), this.template.gsub(this.pattern, function (match) { | |
| if (null == object) return match[1] + ""; | |
| var before = match[1] || ""; | |
| if ("\\" == before) return match[2]; | |
| var ctx = object, | |
| expr = match[3], | |
| pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/; | |
| if (match = pattern.exec(expr), null == match) return before; | |
| for (; null != match;) { | |
| var comp = match[1].startsWith("[") ? match[2].replace(/\\\\]/g, "]") : match[1]; | |
| if (ctx = ctx[comp], null == ctx || "" == match[3]) break; | |
| expr = expr.substring("[" == match[3] ? match[1].length : match[0].length), match = pattern.exec(expr) | |
| } | |
| return before + String.interpret(ctx) | |
| }) | |
| } | |
| }); | |
| Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; | |
| var $break = {}, Enumerable = function () { | |
| function each(iterator, context) { | |
| try { | |
| this._each(iterator, context) | |
| } catch (e) { | |
| if (e != $break) throw e | |
| } | |
| return this | |
| } | |
| function eachSlice(number, iterator, context) { | |
| var index = -number, | |
| slices = [], | |
| array = this.toArray(); | |
| if (1 > number) return array; | |
| for (; | |
| (index += number) < array.length;) slices.push(array.slice(index, index + number)); | |
| return slices.collect(iterator, context) | |
| } | |
| function all(iterator, context) { | |
| iterator = iterator || Prototype.K; | |
| var result = !0; | |
| return this.each(function (value, index) { | |
| if (result = result && !! iterator.call(context, value, index, this), !result) throw $break | |
| }, this), result | |
| } | |
| function any(iterator, context) { | |
| iterator = iterator || Prototype.K; | |
| var result = !1; | |
| return this.each(function (value, index) { | |
| if (result = !! iterator.call(context, value, index, this)) throw $break | |
| }, this), result | |
| } | |
| function collect(iterator, context) { | |
| iterator = iterator || Prototype.K; | |
| var results = []; | |
| return this.each(function (value, index) { | |
| results.push(iterator.call(context, value, index, this)) | |
| }, this), results | |
| } | |
| function detect(iterator, context) { | |
| var result; | |
| return this.each(function (value, index) { | |
| if (iterator.call(context, value, index, this)) throw result = value, $break | |
| }, this), result | |
| } | |
| function findAll(iterator, context) { | |
| var results = []; | |
| return this.each(function (value, index) { | |
| iterator.call(context, value, index, this) && results.push(value) | |
| }, this), results | |
| } | |
| function grep(filter, iterator, context) { | |
| iterator = iterator || Prototype.K; | |
| var results = []; | |
| return Object.isString(filter) && (filter = new RegExp(RegExp.escape(filter))), this.each(function (value, index) { | |
| filter.match(value) && results.push(iterator.call(context, value, index, this)) | |
| }, this), results | |
| } | |
| function include(object) { | |
| if (Object.isFunction(this.indexOf) && -1 != this.indexOf(object)) return !0; | |
| var found = !1; | |
| return this.each(function (value) { | |
| if (value == object) throw found = !0, $break | |
| }), found | |
| } | |
| function inGroupsOf(number, fillWith) { | |
| return fillWith = Object.isUndefined(fillWith) ? null : fillWith, this.eachSlice(number, function (slice) { | |
| for (; slice.length < number;) slice.push(fillWith); | |
| return slice | |
| }) | |
| } | |
| function inject(memo, iterator, context) { | |
| return this.each(function (value, index) { | |
| memo = iterator.call(context, memo, value, index, this) | |
| }, this), memo | |
| } | |
| function invoke(method) { | |
| var args = $A(arguments).slice(1); | |
| return this.map(function (value) { | |
| return value[method].apply(value, args) | |
| }) | |
| } | |
| function max(iterator, context) { | |
| iterator = iterator || Prototype.K; | |
| var result; | |
| return this.each(function (value, index) { | |
| value = iterator.call(context, value, index, this), (null == result || value >= result) && (result = value) | |
| }, this), result | |
| } | |
| function min(iterator, context) { | |
| iterator = iterator || Prototype.K; | |
| var result; | |
| return this.each(function (value, index) { | |
| value = iterator.call(context, value, index, this), (null == result || result > value) && (result = value) | |
| }, this), result | |
| } | |
| function partition(iterator, context) { | |
| iterator = iterator || Prototype.K; | |
| var trues = [], | |
| falses = []; | |
| return this.each(function (value, index) { | |
| (iterator.call(context, value, index, this) ? trues : falses).push(value) | |
| }, this), [trues, falses] | |
| } | |
| function pluck(property) { | |
| var results = []; | |
| return this.each(function (value) { | |
| results.push(value[property]) | |
| }), results | |
| } | |
| function reject(iterator, context) { | |
| var results = []; | |
| return this.each(function (value, index) { | |
| iterator.call(context, value, index, this) || results.push(value) | |
| }, this), results | |
| } | |
| function sortBy(iterator, context) { | |
| return this.map(function (value, index) { | |
| return { | |
| value: value, | |
| criteria: iterator.call(context, value, index, this) | |
| } | |
| }, this).sort(function (left, right) { | |
| var a = left.criteria, | |
| b = right.criteria; | |
| return b > a ? -1 : a > b ? 1 : 0 | |
| }).pluck("value") | |
| } | |
| function toArray() { | |
| return this.map() | |
| } | |
| function zip() { | |
| var iterator = Prototype.K, | |
| args = $A(arguments); | |
| Object.isFunction(args.last()) && (iterator = args.pop()); | |
| var collections = [this].concat(args).map($A); | |
| return this.map(function (value, index) { | |
| return iterator(collections.pluck(index)) | |
| }) | |
| } | |
| function size() { | |
| return this.toArray().length | |
| } | |
| function inspect() { | |
| return "#<Enumerable:" + this.toArray().inspect() + ">" | |
| } | |
| return { | |
| each: each, | |
| eachSlice: eachSlice, | |
| all: all, | |
| every: all, | |
| any: any, | |
| some: any, | |
| collect: collect, | |
| map: collect, | |
| detect: detect, | |
| findAll: findAll, | |
| select: findAll, | |
| filter: findAll, | |
| grep: grep, | |
| include: include, | |
| member: include, | |
| inGroupsOf: inGroupsOf, | |
| inject: inject, | |
| invoke: invoke, | |
| max: max, | |
| min: min, | |
| partition: partition, | |
| pluck: pluck, | |
| reject: reject, | |
| sortBy: sortBy, | |
| toArray: toArray, | |
| entries: toArray, | |
| zip: zip, | |
| size: size, | |
| inspect: inspect, | |
| find: detect | |
| } | |
| }(); | |
| Array.from = $A, | |
| function () { | |
| function each(iterator, context) { | |
| for (var i = 0, length = this.length >>> 0; length > i; i++) i in this && iterator.call(context, this[i], i, this) | |
| } | |
| function clear() { | |
| return this.length = 0, this | |
| } | |
| function first() { | |
| return this[0] | |
| } | |
| function last() { | |
| return this[this.length - 1] | |
| } | |
| function compact() { | |
| return this.select(function (value) { | |
| return null != value | |
| }) | |
| } | |
| function flatten() { | |
| return this.inject([], function (array, value) { | |
| return Object.isArray(value) ? array.concat(value.flatten()) : (array.push(value), array) | |
| }) | |
| } | |
| function without() { | |
| var values = slice.call(arguments, 0); | |
| return this.select(function (value) { | |
| return !values.include(value) | |
| }) | |
| } | |
| function reverse(inline) { | |
| return (inline === !1 ? this.toArray() : this)._reverse() | |
| } | |
| function uniq(sorted) { | |
| return this.inject([], function (array, value, index) { | |
| return 0 != index && (sorted ? array.last() == value : array.include(value)) || array.push(value), array | |
| }) | |
| } | |
| function intersect(array) { | |
| return this.uniq().findAll(function (item) { | |
| return -1 !== array.indexOf(item) | |
| }) | |
| } | |
| function clone() { | |
| return slice.call(this, 0) | |
| } | |
| function size() { | |
| return this.length | |
| } | |
| function inspect() { | |
| return "[" + this.map(Object.inspect).join(", ") + "]" | |
| } | |
| function indexOf(item, i) { | |
| if (null == this) throw new TypeError; | |
| var array = Object(this), | |
| length = array.length >>> 0; | |
| if (0 === length) return -1; | |
| if (i = Number(i), isNaN(i) ? i = 0 : 0 !== i && isFinite(i) && (i = (i > 0 ? 1 : -1) * Math.floor(Math.abs(i))), i > length) return -1; | |
| for (var k = i >= 0 ? i : Math.max(length - Math.abs(i), 0); length > k; k++) | |
| if (k in array && array[k] === item) return k; | |
| return -1 | |
| } | |
| function lastIndexOf(item, i) { | |
| if (null == this) throw new TypeError; | |
| var array = Object(this), | |
| length = array.length >>> 0; | |
| if (0 === length) return -1; | |
| Object.isUndefined(i) ? i = length : (i = Number(i), isNaN(i) ? i = 0 : 0 !== i && isFinite(i) && (i = (i > 0 ? 1 : -1) * Math.floor(Math.abs(i)))); | |
| for (var k = i >= 0 ? Math.min(i, length - 1) : length - Math.abs(i); k >= 0; k--) | |
| if (k in array && array[k] === item) return k; | |
| return -1 | |
| } | |
| function concat() { | |
| var item, array = [], | |
| items = slice.call(arguments, 0), | |
| n = 0; | |
| items.unshift(this); | |
| for (var i = 0, length = items.length; length > i; i++) | |
| if (item = items[i], !Object.isArray(item) || "callee" in item) array[n++] = item; | |
| else | |
| for (var j = 0, arrayLength = item.length; arrayLength > j; j++) j in item && (array[n] = item[j]), n++; | |
| return array.length = n, array | |
| } | |
| function wrapNative(method) { | |
| return function () { | |
| if (0 === arguments.length) return method.call(this, Prototype.K); | |
| if (void 0 === arguments[0]) { | |
| var args = slice.call(arguments, 1); | |
| return args.unshift(Prototype.K), method.apply(this, args) | |
| } | |
| return method.apply(this, arguments) | |
| } | |
| } | |
| function map(iterator) { | |
| if (null == this) throw new TypeError; | |
| iterator = iterator || Prototype.K; | |
| for (var object = Object(this), results = [], context = arguments[1], n = 0, i = 0, length = object.length >>> 0; length > i; i++) i in object && (results[n] = iterator.call(context, object[i], i, object)), n++; | |
| return results.length = n, results | |
| } | |
| function filter(iterator) { | |
| if (null == this || !Object.isFunction(iterator)) throw new TypeError; | |
| for (var value, object = Object(this), results = [], context = arguments[1], i = 0, length = object.length >>> 0; length > i; i++) i in object && (value = object[i], iterator.call(context, value, i, object) && results.push(value)); | |
| return results | |
| } | |
| function some(iterator) { | |
| if (null == this) throw new TypeError; | |
| iterator = iterator || Prototype.K; | |
| for (var context = arguments[1], object = Object(this), i = 0, length = object.length >>> 0; length > i; i++) | |
| if (i in object && iterator.call(context, object[i], i, object)) return !0; | |
| return !1 | |
| } | |
| function every(iterator) { | |
| if (null == this) throw new TypeError; | |
| iterator = iterator || Prototype.K; | |
| for (var context = arguments[1], object = Object(this), i = 0, length = object.length >>> 0; length > i; i++) | |
| if (i in object && !iterator.call(context, object[i], i, object)) return !1; | |
| return !0 | |
| } | |
| function inject(memo, iterator) { | |
| iterator = iterator || Prototype.K; | |
| var context = arguments[2]; | |
| return _reduce.call(this, iterator.bind(context), memo) | |
| } | |
| var arrayProto = Array.prototype, | |
| slice = arrayProto.slice, | |
| _each = arrayProto.forEach; | |
| if (_each || (_each = each), arrayProto.map && (map = wrapNative(Array.prototype.map)), arrayProto.filter && (filter = Array.prototype.filter), arrayProto.some) var some = wrapNative(Array.prototype.some); | |
| if (arrayProto.every) var every = wrapNative(Array.prototype.every); | |
| var _reduce = arrayProto.reduce; | |
| if (!arrayProto.reduce) var inject = Enumerable.inject; | |
| Object.extend(arrayProto, Enumerable), arrayProto._reverse || (arrayProto._reverse = arrayProto.reverse), Object.extend(arrayProto, { | |
| _each: _each, | |
| map: map, | |
| collect: map, | |
| select: filter, | |
| filter: filter, | |
| findAll: filter, | |
| some: some, | |
| any: some, | |
| every: every, | |
| all: every, | |
| inject: inject, | |
| clear: clear, | |
| first: first, | |
| last: last, | |
| compact: compact, | |
| flatten: flatten, | |
| without: without, | |
| reverse: reverse, | |
| uniq: uniq, | |
| intersect: intersect, | |
| clone: clone, | |
| toArray: clone, | |
| size: size, | |
| inspect: inspect | |
| }); | |
| var CONCAT_ARGUMENTS_BUGGY = function () { | |
| return 1 !== [].concat(arguments)[0][0] | |
| }(1, 2); | |
| CONCAT_ARGUMENTS_BUGGY && (arrayProto.concat = concat), arrayProto.indexOf || (arrayProto.indexOf = indexOf), arrayProto.lastIndexOf || (arrayProto.lastIndexOf = lastIndexOf) | |
| }(); | |
| var Hash = Class.create(Enumerable, function () { | |
| function initialize(object) { | |
| this._object = Object.isHash(object) ? object.toObject() : Object.clone(object) | |
| } | |
| function _each(iterator, context) { | |
| for (var key in this._object) { | |
| var value = this._object[key], | |
| pair = [key, value]; | |
| pair.key = key, pair.value = value, iterator.call(context, pair) | |
| } | |
| } | |
| function set(key, value) { | |
| return this._object[key] = value | |
| } | |
| function get(key) { | |
| return this._object[key] !== Object.prototype[key] ? this._object[key] : void 0 | |
| } | |
| function unset(key) { | |
| var value = this._object[key]; | |
| return delete this._object[key], value | |
| } | |
| function toObject() { | |
| return Object.clone(this._object) | |
| } | |
| function keys() { | |
| return this.pluck("key") | |
| } | |
| function values() { | |
| return this.pluck("value") | |
| } | |
| function index(value) { | |
| var match = this.detect(function (pair) { | |
| return pair.value === value | |
| }); | |
| return match && match.key | |
| } | |
| function merge(object) { | |
| return this.clone().update(object) | |
| } | |
| function update(object) { | |
| return new Hash(object).inject(this, function (result, pair) { | |
| return result.set(pair.key, pair.value), result | |
| }) | |
| } | |
| function toQueryPair(key, value) { | |
| if (Object.isUndefined(value)) return key; | |
| var value = String.interpret(value); | |
| return value = value.gsub(/(\r)?\n/, "\r\n"), value = encodeURIComponent(value), value = value.gsub(/%20/, "+"), key + "=" + value | |
| } | |
| function toQueryString() { | |
| return this.inject([], function (results, pair) { | |
| var key = encodeURIComponent(pair.key), | |
| values = pair.value; | |
| if (values && "object" == typeof values) { | |
| if (Object.isArray(values)) { | |
| for (var value, queryValues = [], i = 0, len = values.length; len > i; i++) value = values[i], queryValues.push(toQueryPair(key, value)); | |
| return results.concat(queryValues) | |
| } | |
| } else results.push(toQueryPair(key, values)); | |
| return results | |
| }).join("&") | |
| } | |
| function inspect() { | |
| return "#<Hash:{" + this.map(function (pair) { | |
| return pair.map(Object.inspect).join(": ") | |
| }).join(", ") + "}>" | |
| } | |
| function clone() { | |
| return new Hash(this) | |
| } | |
| return { | |
| initialize: initialize, | |
| _each: _each, | |
| set: set, | |
| get: get, | |
| unset: unset, | |
| toObject: toObject, | |
| toTemplateReplacements: toObject, | |
| keys: keys, | |
| values: values, | |
| index: index, | |
| merge: merge, | |
| update: update, | |
| toQueryString: toQueryString, | |
| inspect: inspect, | |
| toJSON: toObject, | |
| clone: clone | |
| } | |
| }()); | |
| Hash.from = $H, Object.extend(Number.prototype, function () { | |
| function toColorPart() { | |
| return this.toPaddedString(2, 16) | |
| } | |
| function succ() { | |
| return this + 1 | |
| } | |
| function times(iterator, context) { | |
| return $R(0, this, !0).each(iterator, context), this | |
| } | |
| function toPaddedString(length, radix) { | |
| var string = this.toString(radix || 10); | |
| return "0".times(length - string.length) + string | |
| } | |
| function abs() { | |
| return Math.abs(this) | |
| } | |
| function round() { | |
| return Math.round(this) | |
| } | |
| function ceil() { | |
| return Math.ceil(this) | |
| } | |
| function floor() { | |
| return Math.floor(this) | |
| } | |
| return { | |
| toColorPart: toColorPart, | |
| succ: succ, | |
| times: times, | |
| toPaddedString: toPaddedString, | |
| abs: abs, | |
| round: round, | |
| ceil: ceil, | |
| floor: floor | |
| } | |
| }()); | |
| var ObjectRange = Class.create(Enumerable, function () { | |
| function initialize(start, end, exclusive) { | |
| this.start = start, this.end = end, this.exclusive = exclusive | |
| } | |
| function _each(iterator, context) { | |
| for (var value = this.start; this.include(value);) iterator.call(context, value), value = value.succ() | |
| } | |
| function include(value) { | |
| return value < this.start ? !1 : this.exclusive ? value < this.end : value <= this.end | |
| } | |
| return { | |
| initialize: initialize, | |
| _each: _each, | |
| include: include | |
| } | |
| }()), | |
| Abstract = {}, Try = { | |
| these: function () { | |
| for (var returnValue, i = 0, length = arguments.length; length > i; i++) { | |
| var lambda = arguments[i]; | |
| try { | |
| returnValue = lambda(); | |
| break | |
| } catch (e) {} | |
| } | |
| return returnValue | |
| } | |
| }, Ajax = { | |
| getTransport: function () { | |
| return Try.these(function () { | |
| return new XMLHttpRequest | |
| }, function () { | |
| return new ActiveXObject("Msxml2.XMLHTTP") | |
| }, function () { | |
| return new ActiveXObject("Microsoft.XMLHTTP") | |
| }) || !1 | |
| }, | |
| activeRequestCount: 0 | |
| }; | |
| Ajax.Responders = { | |
| responders: [], | |
| _each: function (iterator, context) { | |
| this.responders._each(iterator, context) | |
| }, | |
| register: function (responder) { | |
| this.include(responder) || this.responders.push(responder) | |
| }, | |
| unregister: function (responder) { | |
| this.responders = this.responders.without(responder) | |
| }, | |
| dispatch: function (callback, request, transport, json) { | |
| this.each(function (responder) { | |
| if (Object.isFunction(responder[callback])) try { | |
| responder[callback].apply(responder, [request, transport, json]) | |
| } catch (e) {} | |
| }) | |
| } | |
| }, Object.extend(Ajax.Responders, Enumerable), Ajax.Responders.register({ | |
| onCreate: function () { | |
| Ajax.activeRequestCount++ | |
| }, | |
| onComplete: function () { | |
| Ajax.activeRequestCount-- | |
| } | |
| }), Ajax.Base = Class.create({ | |
| initialize: function (options) { | |
| this.options = { | |
| method: "post", | |
| asynchronous: !0, | |
| contentType: "application/x-www-form-urlencoded", | |
| encoding: "UTF-8", | |
| parameters: "", | |
| evalJSON: !0, | |
| evalJS: !0 | |
| }, Object.extend(this.options, options || {}), this.options.method = this.options.method.toLowerCase(), Object.isHash(this.options.parameters) && (this.options.parameters = this.options.parameters.toObject()) | |
| } | |
| }), Ajax.Request = Class.create(Ajax.Base, { | |
| _complete: !1, | |
| initialize: function ($super, url, options) { | |
| $super(options), this.transport = Ajax.getTransport(), this.request(url) | |
| }, | |
| request: function (url) { | |
| this.url = url, this.method = this.options.method; | |
| var params = Object.isString(this.options.parameters) ? this.options.parameters : Object.toQueryString(this.options.parameters); | |
| ["get", "post"].include(this.method) || (params += (params ? "&" : "") + "_method=" + this.method, this.method = "post"), params && "get" === this.method && (this.url += (this.url.include("?") ? "&" : "?") + params), this.parameters = params.toQueryParams(); | |
| try { | |
| var response = new Ajax.Response(this); | |
| this.options.onCreate && this.options.onCreate(response), Ajax.Responders.dispatch("onCreate", this, response), this.transport.open(this.method.toUpperCase(), this.url, this.options.asynchronous), this.options.asynchronous && this.respondToReadyState.bind(this).defer(1), this.transport.onreadystatechange = this.onStateChange.bind(this), this.setRequestHeaders(), this.body = "post" == this.method ? this.options.postBody || params : null, this.transport.send(this.body), !this.options.asynchronous && this.transport.overrideMimeType && this.onStateChange() | |
| } catch (e) { | |
| this.dispatchException(e) | |
| } | |
| }, | |
| onStateChange: function () { | |
| var readyState = this.transport.readyState; | |
| readyState > 1 && (4 != readyState || !this._complete) && this.respondToReadyState(this.transport.readyState) | |
| }, | |
| setRequestHeaders: function () { | |
| var headers = { | |
| "X-Requested-With": "XMLHttpRequest", | |
| "X-Prototype-Version": Prototype.Version, | |
| Accept: "text/javascript, text/html, application/xml, text/xml, */*" | |
| }; | |
| if ("post" == this.method && (headers["Content-type"] = this.options.contentType + (this.options.encoding ? "; charset=" + this.options.encoding : ""), this.transport.overrideMimeType && (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0, 2005])[1] < 2005 && (headers.Connection = "close")), "object" == typeof this.options.requestHeaders) { | |
| var extras = this.options.requestHeaders; | |
| if (Object.isFunction(extras.push)) | |
| for (var i = 0, length = extras.length; length > i; i += 2) headers[extras[i]] = extras[i + 1]; | |
| else $H(extras).each(function (pair) { | |
| headers[pair.key] = pair.value | |
| }) | |
| } | |
| for (var name in headers) this.transport.setRequestHeader(name, headers[name]) | |
| }, | |
| success: function () { | |
| var status = this.getStatus(); | |
| return !status || status >= 200 && 300 > status || 304 == status | |
| }, | |
| getStatus: function () { | |
| try { | |
| return 1223 === this.transport.status ? 204 : this.transport.status || 0 | |
| } catch (e) { | |
| return 0 | |
| } | |
| }, | |
| respondToReadyState: function (readyState) { | |
| var state = Ajax.Request.Events[readyState], | |
| response = new Ajax.Response(this); | |
| if ("Complete" == state) { | |
| try { | |
| this._complete = !0, (this.options["on" + response.status] || this.options["on" + (this.success() ? "Success" : "Failure")] || Prototype.emptyFunction)(response, response.headerJSON) | |
| } catch (e) { | |
| this.dispatchException(e) | |
| } | |
| var contentType = response.getHeader("Content-type"); | |
| ("force" == this.options.evalJS || this.options.evalJS && this.isSameOrigin() && contentType && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)) && this.evalResponse() | |
| } | |
| try { | |
| (this.options["on" + state] || Prototype.emptyFunction)(response, response.headerJSON), Ajax.Responders.dispatch("on" + state, this, response, response.headerJSON) | |
| } catch (e) { | |
| this.dispatchException(e) | |
| } | |
| "Complete" == state && (this.transport.onreadystatechange = Prototype.emptyFunction) | |
| }, | |
| isSameOrigin: function () { | |
| var m = this.url.match(/^\s*https?:\/\/[^\/]*/); | |
| return !m || m[0] == "#{protocol}//#{domain}#{port}".interpolate({ | |
| protocol: location.protocol, | |
| domain: document.domain, | |
| port: location.port ? ":" + location.port : "" | |
| }) | |
| }, | |
| getHeader: function (name) { | |
| try { | |
| return null | |
| } catch (e) { | |
| return null | |
| } | |
| }, | |
| evalResponse: function () { | |
| try { | |
| return eval((this.transport.responseText || "").unfilterJSON()) | |
| } catch (e) { | |
| this.dispatchException(e) | |
| } | |
| }, | |
| dispatchException: function (exception) { | |
| (this.options.onException || Prototype.emptyFunction)(this, exception), Ajax.Responders.dispatch("onException", this, exception) | |
| } | |
| }), Ajax.Request.Events = ["Uninitialized", "Loading", "Loaded", "Interactive", "Complete"], Ajax.Response = Class.create({ | |
| initialize: function (request) { | |
| this.request = request; | |
| var transport = this.transport = request.transport, | |
| readyState = this.readyState = transport.readyState; | |
| if ((readyState > 2 && !Prototype.Browser.IE || 4 == readyState) && (this.status = this.getStatus(), this.statusText = this.getStatusText(), this.responseText = String.interpret(transport.responseText), this.headerJSON = this._getHeaderJSON()), 4 == readyState) { | |
| var xml = transport.responseXML; | |
| this.responseXML = Object.isUndefined(xml) ? null : xml, this.responseJSON = this._getResponseJSON() | |
| } | |
| }, | |
| status: 0, | |
| statusText: "", | |
| getStatus: Ajax.Request.prototype.getStatus, | |
| getStatusText: function () { | |
| try { | |
| return this.transport.statusText || "" | |
| } catch (e) { | |
| return "" | |
| } | |
| }, | |
| getHeader: Ajax.Request.prototype.getHeader, | |
| getAllHeaders: function () { | |
| try { | |
| return this.getAllResponseHeaders() | |
| } catch (e) { | |
| return null | |
| } | |
| }, | |
| getResponseHeader: function (name) { | |
| return this.transport.getResponseHeader(name) | |
| }, | |
| getAllResponseHeaders: function () { | |
| return this.transport.getAllResponseHeaders() | |
| }, | |
| _getHeaderJSON: function () { | |
| var json = this.getHeader("X-JSON"); | |
| if (!json) return null; | |
| try { | |
| json = decodeURIComponent(escape(json)) | |
| } catch (e) {} | |
| try { | |
| return json.evalJSON(this.request.options.sanitizeJSON || !this.request.isSameOrigin()) | |
| } catch (e) { | |
| this.request.dispatchException(e) | |
| } | |
| }, | |
| _getResponseJSON: function () { | |
| var options = this.request.options; | |
| if (!options.evalJSON || "force" != options.evalJSON && !(this.getHeader("Content-type") || "").include("application/json") || this.responseText.blank()) return null; | |
| try { | |
| return this.responseText.evalJSON(options.sanitizeJSON || !this.request.isSameOrigin()) | |
| } catch (e) { | |
| this.request.dispatchException(e) | |
| } | |
| } | |
| }), Ajax.Updater = Class.create(Ajax.Request, { | |
| initialize: function ($super, container, url, options) { | |
| this.container = { | |
| success: container.success || container, | |
| failure: container.failure || (container.success ? null : container) | |
| }, options = Object.clone(options); | |
| var onComplete = options.onComplete; | |
| options.onComplete = function (response, json) { | |
| this.updateContent(response.responseText), Object.isFunction(onComplete) && onComplete(response, json) | |
| }.bind(this), $super(url, options) | |
| }, | |
| updateContent: function (responseText) { | |
| var receiver = this.container[this.success() ? "success" : "failure"], | |
| options = this.options; | |
| if (options.evalScripts || (responseText = responseText.stripScripts()), receiver = $(receiver)) | |
| if (options.insertion) | |
| if (Object.isString(options.insertion)) { | |
| var insertion = {}; | |
| insertion[options.insertion] = responseText, receiver.insert(insertion) | |
| } else options.insertion(receiver, responseText); | |
| else receiver.update(responseText) | |
| } | |
| }), Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { | |
| initialize: function ($super, container, url, options) { | |
| $super(options), this.onComplete = this.options.onComplete, this.frequency = this.options.frequency || 2, this.decay = this.options.decay || 1, this.updater = {}, this.container = container, this.url = url, this.start() | |
| }, | |
| start: function () { | |
| this.options.onComplete = this.updateComplete.bind(this), this.onTimerEvent() | |
| }, | |
| stop: function () { | |
| this.updater.options.onComplete = void 0, clearTimeout(this.timer), (this.onComplete || Prototype.emptyFunction).apply(this, arguments) | |
| }, | |
| updateComplete: function (response) { | |
| this.options.decay && (this.decay = response.responseText == this.lastText ? this.decay * this.options.decay : 1, this.lastText = response.responseText), this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency) | |
| }, | |
| onTimerEvent: function () { | |
| this.updater = new Ajax.Updater(this.container, this.url, this.options) | |
| } | |
| }), | |
| function (GLOBAL) { | |
| function $(element) { | |
| if (arguments.length > 1) { | |
| for (var i = 0, elements = [], length = arguments.length; length > i; i++) elements.push($(arguments[i])); | |
| return elements | |
| } | |
| return Object.isString(element) && (element = document.getElementById(element)), Element.extend(element) | |
| } | |
| function shouldUseCreationCache(tagName, attributes) { | |
| return "select" === tagName ? !1 : "type" in attributes ? !1 : !0 | |
| } | |
| function Element(tagName, attributes) { | |
| if (attributes = attributes || {}, tagName = tagName.toLowerCase(), HAS_EXTENDED_CREATE_ELEMENT_SYNTAX && attributes.name) return tagName = "<" + tagName + ' name="' + attributes.name + '">', delete attributes.name, Element.writeAttribute(document.createElement(tagName), attributes); | |
| ELEMENT_CACHE[tagName] || (ELEMENT_CACHE[tagName] = Element.extend(document.createElement(tagName))); | |
| var node = shouldUseCreationCache(tagName, attributes) ? ELEMENT_CACHE[tagName].cloneNode(!1) : document.createElement(tagName); | |
| return Element.writeAttribute(node, attributes) | |
| } | |
| function inspect(element) { | |
| element = $(element); | |
| var attribute, value, result = "<" + element.tagName.toLowerCase(); | |
| for (var property in INSPECT_ATTRIBUTES) attribute = INSPECT_ATTRIBUTES[property], value = (element[property] || "").toString(), value && (result += " " + attribute + "=" + value.inspect(!0)); | |
| return result + ">" | |
| } | |
| function visible(element) { | |
| return "none" !== $(element).style.display | |
| } | |
| function toggle(element, bool) { | |
| return element = $(element), Object.isUndefined(bool) && (bool = !Element.visible(element)), Element[bool ? "show" : "hide"](element), element | |
| } | |
| function hide(element) { | |
| return element = $(element), element.style.display = "none", element | |
| } | |
| function show(element) { | |
| return element = $(element), element.style.display = "", element | |
| } | |
| function remove(element) { | |
| return element = $(element), element.parentNode.removeChild(element), element | |
| } | |
| function update(element, content) { | |
| element = $(element); | |
| for (var descendants = element.getElementsByTagName("*"), i = descendants.length; i--;) purgeElement(descendants[i]); | |
| if (content && content.toElement && (content = content.toElement()), Object.isElement(content)) return element.update().insert(content); | |
| content = Object.toHTML(content); | |
| var tagName = element.tagName.toUpperCase(); | |
| if ("SCRIPT" === tagName && SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING) return element.text = content, element; | |
| if (ANY_INNERHTML_BUGGY) | |
| if (tagName in INSERTION_TRANSLATIONS.tags) { | |
| for (; element.firstChild;) element.removeChild(element.firstChild); | |
| for (var node, nodes = getContentFromAnonymousElement(tagName, content.stripScripts()), i = 0; node = nodes[i]; i++) element.appendChild(node) | |
| } else if (LINK_ELEMENT_INNERHTML_BUGGY && Object.isString(content) && content.indexOf("<link") > -1) { | |
| for (; element.firstChild;) element.removeChild(element.firstChild); | |
| for (var node, nodes = getContentFromAnonymousElement(tagName, content.stripScripts(), !0), i = 0; node = nodes[i]; i++) element.appendChild(node) | |
| } else element.innerHTML = content.stripScripts(); | |
| else element.innerHTML = content.stripScripts(); | |
| return content.evalScripts.bind(content).defer(), element | |
| } | |
| function replace(element, content) { | |
| if (element = $(element), content && content.toElement) content = content.toElement(); | |
| else if (!Object.isElement(content)) { | |
| content = Object.toHTML(content); | |
| var range = element.ownerDocument.createRange(); | |
| range.selectNode(element), content.evalScripts.bind(content).defer(), content = range.createContextualFragment(content.stripScripts()) | |
| } | |
| return element.parentNode.replaceChild(content, element), element | |
| } | |
| function replace_IE(element, content) { | |
| if (element = $(element), content && content.toElement && (content = content.toElement()), Object.isElement(content)) return element.parentNode.replaceChild(content, element), element; | |
| content = Object.toHTML(content); | |
| var parent = element.parentNode, | |
| tagName = parent.tagName.toUpperCase(); | |
| if (tagName in INSERTION_TRANSLATIONS.tags) { | |
| var nextSibling = Element.next(element), | |
| fragments = getContentFromAnonymousElement(tagName, content.stripScripts()); | |
| parent.removeChild(element); | |
| var iterator; | |
| iterator = nextSibling ? function (node) { | |
| parent.insertBefore(node, nextSibling) | |
| } : function (node) { | |
| parent.appendChild(node) | |
| }, fragments.each(iterator) | |
| } else element.outerHTML = content.stripScripts(); | |
| return content.evalScripts.bind(content).defer(), element | |
| } | |
| function isContent(content) { | |
| return Object.isUndefined(content) || null === content ? !1 : Object.isString(content) || Object.isNumber(content) ? !0 : Object.isElement(content) ? !0 : content.toElement || content.toHTML ? !0 : !1 | |
| } | |
| function insertContentAt(element, content, position) { | |
| position = position.toLowerCase(); | |
| var method = INSERTION_TRANSLATIONS[position]; | |
| if (content && content.toElement && (content = content.toElement()), Object.isElement(content)) return method(element, content), element; | |
| content = Object.toHTML(content); | |
| var tagName = ("before" === position || "after" === position ? element.parentNode : element).tagName.toUpperCase(), | |
| childNodes = getContentFromAnonymousElement(tagName, content.stripScripts()); | |
| ("top" === position || "after" === position) && childNodes.reverse(); | |
| for (var node, i = 0; node = childNodes[i]; i++) method(element, node); | |
| content.evalScripts.bind(content).defer() | |
| } | |
| function insert(element, insertions) { | |
| element = $(element), isContent(insertions) && (insertions = { | |
| bottom: insertions | |
| }); | |
| for (var position in insertions) insertContentAt(element, insertions[position], position); | |
| return element | |
| } | |
| function wrap(element, wrapper, attributes) { | |
| return element = $(element), Object.isElement(wrapper) ? $(wrapper).writeAttribute(attributes || {}) : wrapper = Object.isString(wrapper) ? new Element(wrapper, attributes) : new Element("div", wrapper), element.parentNode && element.parentNode.replaceChild(wrapper, element), wrapper.appendChild(element), wrapper | |
| } | |
| function cleanWhitespace(element) { | |
| element = $(element); | |
| for (var node = element.firstChild; node;) { | |
| var nextNode = node.nextSibling; | |
| node.nodeType !== Node.TEXT_NODE || /\S/.test(node.nodeValue) || element.removeChild(node), node = nextNode | |
| } | |
| return element | |
| } | |
| function empty(element) { | |
| return $(element).innerHTML.blank() | |
| } | |
| function getContentFromAnonymousElement(tagName, html, force) { | |
| var t = INSERTION_TRANSLATIONS.tags[tagName], | |
| div = DIV, | |
| workaround = !! t; | |
| if (!workaround && force && (workaround = !0, t = ["", "", 0]), workaround) { | |
| div.innerHTML = " " + t[0] + html + t[1], div.removeChild(div.firstChild); | |
| for (var i = t[2]; i--;) div = div.firstChild | |
| } else div.innerHTML = html; | |
| return $A(div.childNodes) | |
| } | |
| function clone(element, deep) { | |
| if (element = $(element)) { | |
| var clone = element.cloneNode(deep); | |
| if (!HAS_UNIQUE_ID_PROPERTY && (clone._prototypeUID = UNDEFINED, deep)) | |
| for (var descendants = Element.select(clone, "*"), i = descendants.length; i--;) descendants[i]._prototypeUID = UNDEFINED; | |
| return Element.extend(clone) | |
| } | |
| } | |
| function purgeElement(element) { | |
| var uid = getUniqueElementID(element); | |
| uid && (Element.stopObserving(element), HAS_UNIQUE_ID_PROPERTY || (element._prototypeUID = UNDEFINED), delete Element.Storage[uid]) | |
| } | |
| function purgeCollection(elements) { | |
| for (var i = elements.length; i--;) purgeElement(elements[i]) | |
| } | |
| function purgeCollection_IE(elements) { | |
| for (var element, uid, i = elements.length; i--;) element = elements[i], uid = getUniqueElementID(element), delete Element.Storage[uid], delete Event.cache[uid] | |
| } | |
| function purge(element) { | |
| if (element = $(element)) { | |
| purgeElement(element); | |
| for (var descendants = element.getElementsByTagName("*"), i = descendants.length; i--;) purgeElement(descendants[i]); | |
| return null | |
| } | |
| } | |
| function recursivelyCollect(element, property, maximumLength) { | |
| element = $(element), maximumLength = maximumLength || -1; | |
| for (var elements = []; | |
| (element = element[property]) && (element.nodeType === Node.ELEMENT_NODE && elements.push(Element.extend(element)), elements.length !== maximumLength);); | |
| return elements | |
| } | |
| function ancestors(element) { | |
| return recursivelyCollect(element, "parentNode") | |
| } | |
| function descendants(element) { | |
| return Element.select(element, "*") | |
| } | |
| function firstDescendant(element) { | |
| for (element = $(element).firstChild; element && element.nodeType !== Node.ELEMENT_NODE;) element = element.nextSibling; | |
| return $(element) | |
| } | |
| function immediateDescendants(element) { | |
| for (var results = [], child = $(element).firstChild; child;) child.nodeType === Node.ELEMENT_NODE && results.push(Element.extend(child)), child = child.nextSibling; | |
| return results | |
| } | |
| function previousSiblings(element) { | |
| return recursivelyCollect(element, "previousSibling") | |
| } | |
| function nextSiblings(element) { | |
| return recursivelyCollect(element, "nextSibling") | |
| } | |
| function siblings(element) { | |
| element = $(element); | |
| var previous = previousSiblings(element), | |
| next = nextSiblings(element); | |
| return previous.reverse().concat(next) | |
| } | |
| function match(element, selector) { | |
| return element = $(element), Object.isString(selector) ? Prototype.Selector.match(element, selector) : selector.match(element) | |
| } | |
| function _recursivelyFind(element, property, expression, index) { | |
| for (element = $(element), expression = expression || 0, index = index || 0, Object.isNumber(expression) && (index = expression, expression = null); element = element[property];) | |
| if (1 === element.nodeType && !(expression && !Prototype.Selector.match(element, expression) || --index >= 0)) return Element.extend(element) | |
| } | |
| function up(element, expression, index) { | |
| return element = $(element), 1 === arguments.length ? $(element.parentNode) : _recursivelyFind(element, "parentNode", expression, index) | |
| } | |
| function down(element, expression, index) { | |
| element = $(element), expression = expression || 0, index = index || 0, Object.isNumber(expression) && (index = expression, expression = "*"); | |
| var node = Prototype.Selector.select(expression, element)[index]; | |
| return Element.extend(node) | |
| } | |
| function previous(element, expression, index) { | |
| return _recursivelyFind(element, "previousSibling", expression, index) | |
| } | |
| function next(element, expression, index) { | |
| return _recursivelyFind(element, "nextSibling", expression, index) | |
| } | |
| function select(element) { | |
| element = $(element); | |
| var expressions = SLICE.call(arguments, 1).join(", "); | |
| return Prototype.Selector.select(expressions, element) | |
| } | |
| function adjacent(element) { | |
| element = $(element); | |
| for (var sibling, expressions = SLICE.call(arguments, 1).join(", "), siblings = Element.siblings(element), results = [], i = 0; sibling = siblings[i]; i++) Prototype.Selector.match(sibling, expressions) && results.push(sibling); | |
| return results | |
| } | |
| function descendantOf_DOM(element, ancestor) { | |
| for (element = $(element), ancestor = $(ancestor); element = element.parentNode;) | |
| if (element === ancestor) return !0; | |
| return !1 | |
| } | |
| function descendantOf_contains(element, ancestor) { | |
| return element = $(element), ancestor = $(ancestor), ancestor.contains ? ancestor.contains(element) && ancestor !== element : descendantOf_DOM(element, ancestor) | |
| } | |
| function descendantOf_compareDocumentPosition(element, ancestor) { | |
| return element = $(element), ancestor = $(ancestor), 8 === (8 & element.compareDocumentPosition(ancestor)) | |
| } | |
| function identify(element) { | |
| element = $(element); | |
| var id = Element.readAttribute(element, "id"); | |
| if (id) return id; | |
| do id = "anonymous_element_" + idCounter++; while ($(id)); | |
| return Element.writeAttribute(element, "id", id), id | |
| } | |
| function readAttribute(element, name) { | |
| return $(element).getAttribute(name) | |
| } | |
| function readAttribute_IE(element, name) { | |
| element = $(element); | |
| var table = ATTRIBUTE_TRANSLATIONS.read; | |
| return table.values[name] ? table.values[name](element, name) : (table.names[name] && (name = table.names[name]), name.include(":") ? element.attributes && element.attributes[name] ? element.attributes[name].value : null : element.getAttribute(name)) | |
| } | |
| function readAttribute_Opera(element, name) { | |
| return "title" === name ? element.title : element.getAttribute(name) | |
| } | |
| function writeAttribute(element, name, value) { | |
| element = $(element); | |
| var attributes = {}, table = ATTRIBUTE_TRANSLATIONS.write; | |
| "object" == typeof name ? attributes = name : attributes[name] = Object.isUndefined(value) ? !0 : value; | |
| for (var attr in attributes) name = table.names[attr] || attr, value = attributes[attr], table.values[attr] && (name = table.values[attr](element, value)), value === !1 || null === value ? element.removeAttribute(name) : value === !0 ? element.setAttribute(name, name) : element.setAttribute(name, value); | |
| return element | |
| } | |
| function hasAttribute(element, attribute) { | |
| attribute = ATTRIBUTE_TRANSLATIONS.has[attribute] || attribute; | |
| var node = $(element).getAttributeNode(attribute); | |
| return !(!node || !node.specified) | |
| } | |
| function classNames(element) { | |
| return new Element.ClassNames(element) | |
| } | |
| function getRegExpForClassName(className) { | |
| if (regExpCache[className]) return regExpCache[className]; | |
| var re = new RegExp("(^|\\s+)" + className + "(\\s+|$)"); | |
| return regExpCache[className] = re, re | |
| } | |
| function hasClassName(element, className) { | |
| if (element = $(element)) { | |
| var elementClassName = element.className; | |
| return 0 === elementClassName.length ? !1 : elementClassName === className ? !0 : getRegExpForClassName(className).test(elementClassName) | |
| } | |
| } | |
| function addClassName(element, className) { | |
| return (element = $(element)) ? (hasClassName(element, className) || (element.className += (element.className ? " " : "") + className), element) : void 0 | |
| } | |
| function removeClassName(element, className) { | |
| return (element = $(element)) ? (element.className = element.className.replace(getRegExpForClassName(className), " ").strip(), element) : void 0 | |
| } | |
| function toggleClassName(element, className, bool) { | |
| if (element = $(element)) { | |
| Object.isUndefined(bool) && (bool = !hasClassName(element, className)); | |
| var method = Element[bool ? "addClassName" : "removeClassName"]; | |
| return method(element, className) | |
| } | |
| } | |
| function _getAttr(element, attribute) { | |
| return element.getAttribute(attribute) | |
| } | |
| function _getAttr2(element, attribute) { | |
| return element.getAttribute(attribute, 2) | |
| } | |
| function _getAttrNode(element, attribute) { | |
| var node = element.getAttributeNode(attribute); | |
| return node ? node.value : "" | |
| } | |
| function _getFlag(element, attribute) { | |
| return $(element).hasAttribute(attribute) ? attribute : null | |
| } | |
| function normalizeStyleName(style) { | |
| return "float" === style || "styleFloat" === style ? "cssFloat" : style.camelize() | |
| } | |
| function normalizeStyleName_IE(style) { | |
| return "float" === style || "cssFloat" === style ? "styleFloat" : style.camelize() | |
| } | |
| function setStyle(element, styles) { | |
| element = $(element); | |
| var elementStyle = element.style; | |
| if (Object.isString(styles)) { | |
| if (elementStyle.cssText += ";" + styles, styles.include("opacity")) { | |
| var opacity = styles.match(/opacity:\s*(\d?\.?\d*)/)[1]; | |
| Element.setOpacity(element, opacity) | |
| } | |
| return element | |
| } | |
| for (var property in styles) | |
| if ("opacity" === property) Element.setOpacity(element, styles[property]); | |
| else { | |
| var value = styles[property]; | |
| ("float" === property || "cssFloat" === property) && (property = Object.isUndefined(elementStyle.styleFloat) ? "cssFloat" : "styleFloat"), elementStyle[property] = value | |
| } | |
| return element | |
| } | |
| function getStyle(element, style) { | |
| element = $(element), style = normalizeStyleName(style); | |
| var value = element.style[style]; | |
| if (!value || "auto" === value) { | |
| var css = document.defaultView.getComputedStyle(element, null); | |
| value = css ? css[style] : null | |
| } | |
| return "opacity" === style ? value ? parseFloat(value) : 1 : "auto" === value ? null : value | |
| } | |
| function getStyle_IE(element, style) { | |
| element = $(element), style = normalizeStyleName_IE(style); | |
| var value = element.style[style]; | |
| return !value && element.currentStyle && (value = element.currentStyle[style]), "opacity" !== style || STANDARD_CSS_OPACITY_SUPPORTED ? "auto" === value ? "width" !== style && "height" !== style || !Element.visible(element) ? null : Element.measure(element, style) + "px" : value : getOpacity_IE(element) | |
| } | |
| function stripAlphaFromFilter_IE(filter) { | |
| return (filter || "").replace(/alpha\([^\)]*\)/gi, "") | |
| } | |
| function hasLayout_IE(element) { | |
| return element.currentStyle.hasLayout || (element.style.zoom = 1), element | |
| } | |
| function setOpacity(element, value) { | |
| return element = $(element), 1 == value || "" === value ? value = "" : 1e-5 > value && (value = 0), element.style.opacity = value, element | |
| } | |
| function setOpacity_IE(element, value) { | |
| if (STANDARD_CSS_OPACITY_SUPPORTED) return setOpacity(element, value); | |
| element = hasLayout_IE($(element)); | |
| var filter = Element.getStyle(element, "filter"), | |
| style = element.style; | |
| return 1 == value || "" === value ? (filter = stripAlphaFromFilter_IE(filter), filter ? style.filter = filter : style.removeAttribute("filter"), element) : (1e-5 > value && (value = 0), style.filter = stripAlphaFromFilter_IE(filter) + "alpha(opacity=" + 100 * value + ")", element) | |
| } | |
| function getOpacity(element) { | |
| return Element.getStyle(element, "opacity") | |
| } | |
| function getOpacity_IE(element) { | |
| if (STANDARD_CSS_OPACITY_SUPPORTED) return getOpacity(element); | |
| var filter = Element.getStyle(element, "filter"); | |
| if (0 === filter.length) return 1; | |
| var match = (filter || "").match(/alpha\(opacity=(.*)\)/); | |
| return match[1] ? parseFloat(match[1]) / 100 : 1 | |
| } | |
| function getUniqueElementID(element) { | |
| return element === window ? 0 : ("undefined" == typeof element._prototypeUID && (element._prototypeUID = Element.Storage.UID++), element._prototypeUID) | |
| } | |
| function getUniqueElementID_IE(element) { | |
| return element === window ? 0 : element == document ? 1 : element.uniqueID | |
| } | |
| function getStorage(element) { | |
| if (element = $(element)) { | |
| var uid = getUniqueElementID(element); | |
| return Element.Storage[uid] || (Element.Storage[uid] = $H()), Element.Storage[uid] | |
| } | |
| } | |
| function store(element, key, value) { | |
| if (element = $(element)) { | |
| var storage = getStorage(element); | |
| return 2 === arguments.length ? storage.update(key) : storage.set(key, value), element | |
| } | |
| } | |
| function retrieve(element, key, defaultValue) { | |
| if (element = $(element)) { | |
| var storage = getStorage(element), | |
| value = storage.get(key); | |
| return Object.isUndefined(value) && (storage.set(key, defaultValue), value = defaultValue), value | |
| } | |
| } | |
| function checkElementPrototypeDeficiency(tagName) { | |
| if ("undefined" == typeof window.Element) return !1; | |
| var proto = window.Element.prototype; | |
| if (proto) { | |
| var id = "_" + (Math.random() + "").slice(2), | |
| el = document.createElement(tagName); | |
| proto[id] = "x"; | |
| var isBuggy = "x" !== el[id]; | |
| return delete proto[id], el = null, isBuggy | |
| } | |
| return !1 | |
| } | |
| function extendElementWith(element, methods) { | |
| for (var property in methods) { | |
| var value = methods[property]; | |
| !Object.isFunction(value) || property in element || (element[property] = value.methodize()) | |
| } | |
| } | |
| function elementIsExtended(element) { | |
| var uid = getUniqueElementID(element); | |
| return uid in EXTENDED | |
| } | |
| function extend(element) { | |
| if (!element || elementIsExtended(element)) return element; | |
| if (element.nodeType !== Node.ELEMENT_NODE || element == window) return element; | |
| var methods = Object.clone(Methods), | |
| tagName = element.tagName.toUpperCase(); | |
| return ByTag[tagName] && Object.extend(methods, ByTag[tagName]), extendElementWith(element, methods), EXTENDED[getUniqueElementID(element)] = !0, element | |
| } | |
| function extend_IE8(element) { | |
| if (!element || elementIsExtended(element)) return element; | |
| var t = element.tagName; | |
| return t && /^(?:object|applet|embed)$/i.test(t) && (extendElementWith(element, Element.Methods), extendElementWith(element, Element.Methods.Simulated), extendElementWith(element, Element.Methods.ByTag[t.toUpperCase()])), element | |
| } | |
| function addMethodsToTagName(tagName, methods) { | |
| tagName = tagName.toUpperCase(), ByTag[tagName] || (ByTag[tagName] = {}), Object.extend(ByTag[tagName], methods) | |
| } | |
| function mergeMethods(destination, methods, onlyIfAbsent) { | |
| Object.isUndefined(onlyIfAbsent) && (onlyIfAbsent = !1); | |
| for (var property in methods) { | |
| var value = methods[property]; | |
| Object.isFunction(value) && (onlyIfAbsent && property in destination || (destination[property] = value.methodize())) | |
| } | |
| } | |
| function findDOMClass(tagName) { | |
| var klass, trans = { | |
| OPTGROUP: "OptGroup", | |
| TEXTAREA: "TextArea", | |
| P: "Paragraph", | |
| FIELDSET: "FieldSet", | |
| UL: "UList", | |
| OL: "OList", | |
| DL: "DList", | |
| DIR: "Directory", | |
| H1: "Heading", | |
| H2: "Heading", | |
| H3: "Heading", | |
| H4: "Heading", | |
| H5: "Heading", | |
| H6: "Heading", | |
| Q: "Quote", | |
| INS: "Mod", | |
| DEL: "Mod", | |
| A: "Anchor", | |
| IMG: "Image", | |
| CAPTION: "TableCaption", | |
| COL: "TableCol", | |
| COLGROUP: "TableCol", | |
| THEAD: "TableSection", | |
| TFOOT: "TableSection", | |
| TBODY: "TableSection", | |
| TR: "TableRow", | |
| TH: "TableCell", | |
| TD: "TableCell", | |
| FRAMESET: "FrameSet", | |
| IFRAME: "IFrame" | |
| }; | |
| if (trans[tagName] && (klass = "HTML" + trans[tagName] + "Element"), window[klass]) return window[klass]; | |
| if (klass = "HTML" + tagName + "Element", window[klass]) return window[klass]; | |
| if (klass = "HTML" + tagName.capitalize() + "Element", window[klass]) return window[klass]; | |
| var element = document.createElement(tagName), | |
| proto = element.__proto__ || element.constructor.prototype; | |
| return element = null, proto | |
| } | |
| function addMethods(methods) { | |
| if (0 === arguments.length && addFormMethods(), 2 === arguments.length) { | |
| var tagName = methods; | |
| methods = arguments[1] | |
| } | |
| if (tagName) | |
| if (Object.isArray(tagName)) | |
| for (var tag, i = 0; tag = tagName[i]; i++) addMethodsToTagName(tag, methods); | |
| else addMethodsToTagName(tagName, methods); | |
| else Object.extend(Element.Methods, methods || {}); | |
| var ELEMENT_PROTOTYPE = window.HTMLElement ? HTMLElement.prototype : Element.prototype; | |
| if (F.ElementExtensions && (mergeMethods(ELEMENT_PROTOTYPE, Element.Methods), mergeMethods(ELEMENT_PROTOTYPE, Element.Methods.Simulated, !0)), F.SpecificElementExtensions) | |
| for (var tag in Element.Methods.ByTag) { | |
| var klass = findDOMClass(tag); | |
| Object.isUndefined(klass) || mergeMethods(klass.prototype, ByTag[tag]) | |
| } | |
| Object.extend(Element, Element.Methods), Object.extend(Element, Element.Methods.Simulated), delete Element.ByTag, delete Element.Simulated, Element.extend.refresh(), ELEMENT_CACHE = {} | |
| } | |
| function addFormMethods() { | |
| Object.extend(Form, Form.Methods), Object.extend(Form.Element, Form.Element.Methods), Object.extend(Element.Methods.ByTag, { | |
| FORM: Object.clone(Form.Methods), | |
| INPUT: Object.clone(Form.Element.Methods), | |
| SELECT: Object.clone(Form.Element.Methods), | |
| TEXTAREA: Object.clone(Form.Element.Methods), | |
| BUTTON: Object.clone(Form.Element.Methods) | |
| }) | |
| } | |
| var UNDEFINED, SLICE = Array.prototype.slice, | |
| DIV = document.createElement("div"); | |
| GLOBAL.$ = $, GLOBAL.Node || (GLOBAL.Node = {}), GLOBAL.Node.ELEMENT_NODE || Object.extend(GLOBAL.Node, { | |
| ELEMENT_NODE: 1, | |
| ATTRIBUTE_NODE: 2, | |
| TEXT_NODE: 3, | |
| CDATA_SECTION_NODE: 4, | |
| ENTITY_REFERENCE_NODE: 5, | |
| ENTITY_NODE: 6, | |
| PROCESSING_INSTRUCTION_NODE: 7, | |
| COMMENT_NODE: 8, | |
| DOCUMENT_NODE: 9, | |
| DOCUMENT_TYPE_NODE: 10, | |
| DOCUMENT_FRAGMENT_NODE: 11, | |
| NOTATION_NODE: 12 | |
| }); | |
| var ELEMENT_CACHE = {}, HAS_EXTENDED_CREATE_ELEMENT_SYNTAX = function () { | |
| try { | |
| var el = document.createElement('<input name="x">'); | |
| return "input" === el.tagName.toLowerCase() && "x" === el.name | |
| } catch (err) { | |
| return !1 | |
| } | |
| }(), | |
| oldElement = GLOBAL.Element; | |
| GLOBAL.Element = Element, Object.extend(GLOBAL.Element, oldElement || {}), oldElement && (GLOBAL.Element.prototype = oldElement.prototype), Element.Methods = { | |
| ByTag: {}, | |
| Simulated: {} | |
| }; | |
| var methods = {}, INSPECT_ATTRIBUTES = { | |
| id: "id", | |
| className: "class" | |
| }; | |
| methods.inspect = inspect, Object.extend(methods, { | |
| visible: visible, | |
| toggle: toggle, | |
| hide: hide, | |
| show: show | |
| }); | |
| var SELECT_ELEMENT_INNERHTML_BUGGY = function () { | |
| var el = document.createElement("select"), | |
| isBuggy = !0; | |
| return el.innerHTML = '<option value="test">test</option>', el.options && el.options[0] && (isBuggy = "OPTION" !== el.options[0].nodeName.toUpperCase()), el = null, isBuggy | |
| }(), | |
| TABLE_ELEMENT_INNERHTML_BUGGY = function () { | |
| try { | |
| var el = document.createElement("table"); | |
| if (el && el.tBodies) { | |
| el.innerHTML = "<tbody><tr><td>test</td></tr></tbody>"; | |
| var isBuggy = "undefined" == typeof el.tBodies[0]; | |
| return el = null, isBuggy | |
| } | |
| } catch (e) { | |
| return !0 | |
| } | |
| }(), | |
| LINK_ELEMENT_INNERHTML_BUGGY = function () { | |
| try { | |
| var el = document.createElement("div"); | |
| el.innerHTML = "<link />"; | |
| var isBuggy = 0 === el.childNodes.length; | |
| return el = null, isBuggy | |
| } catch (e) { | |
| return !0 | |
| } | |
| }(), | |
| ANY_INNERHTML_BUGGY = SELECT_ELEMENT_INNERHTML_BUGGY || TABLE_ELEMENT_INNERHTML_BUGGY || LINK_ELEMENT_INNERHTML_BUGGY, | |
| SCRIPT_ELEMENT_REJECTS_TEXTNODE_APPENDING = function () { | |
| var s = document.createElement("script"), | |
| isBuggy = !1; | |
| try { | |
| s.appendChild(document.createTextNode("")), isBuggy = !s.firstChild || s.firstChild && 3 !== s.firstChild.nodeType | |
| } catch (e) { | |
| isBuggy = !0 | |
| } | |
| return s = null, isBuggy | |
| }(), | |
| INSERTION_TRANSLATIONS = { | |
| before: function (element, node) { | |
| element.parentNode.insertBefore(node, element) | |
| }, | |
| top: function (element, node) { | |
| element.insertBefore(node, element.firstChild) | |
| }, | |
| bottom: function (element, node) { | |
| element.appendChild(node) | |
| }, | |
| after: function (element, node) { | |
| element.parentNode.insertBefore(node, element.nextSibling) | |
| }, | |
| tags: { | |
| TABLE: ["<table>", "</table>", 1], | |
| TBODY: ["<table><tbody>", "</tbody></table>", 2], | |
| TR: ["<table><tbody><tr>", "</tr></tbody></table>", 3], | |
| TD: ["<table><tbody><tr><td>", "</td></tr></tbody></table>", 4], | |
| SELECT: ["<select>", "</select>", 1] | |
| } | |
| }, tags = INSERTION_TRANSLATIONS.tags; | |
| Object.extend(tags, { | |
| THEAD: tags.TBODY, | |
| TFOOT: tags.TBODY, | |
| TH: tags.TD | |
| }), "outerHTML" in document.documentElement && (replace = replace_IE), HAS_UNIQUE_ID_PROPERTY && (purgeCollection = purgeCollection_IE), Object.extend(methods, { | |
| remove: remove, | |
| update: update, | |
| replace: replace, | |
| insert: insert, | |
| wrap: wrap, | |
| cleanWhitespace: cleanWhitespace, | |
| empty: empty, | |
| clone: clone, | |
| purge: purge | |
| }); | |
| var descendantOf; | |
| descendantOf = DIV.compareDocumentPosition ? descendantOf_compareDocumentPosition : DIV.contains ? descendantOf_contains : descendantOf_DOM, Object.extend(methods, { | |
| recursivelyCollect: recursivelyCollect, | |
| ancestors: ancestors, | |
| descendants: descendants, | |
| firstDescendant: firstDescendant, | |
| immediateDescendants: immediateDescendants, | |
| previousSiblings: previousSiblings, | |
| nextSiblings: nextSiblings, | |
| siblings: siblings, | |
| match: match, | |
| up: up, | |
| down: down, | |
| previous: previous, | |
| next: next, | |
| select: select, | |
| adjacent: adjacent, | |
| descendantOf: descendantOf, | |
| getElementsBySelector: select, | |
| childElements: immediateDescendants | |
| }); | |
| var idCounter = 1, | |
| PROBLEMATIC_ATTRIBUTE_READING = function () { | |
| DIV.setAttribute("onclick", Prototype.emptyFunction); | |
| var value = DIV.getAttribute("onclick"), | |
| isFunction = "function" == typeof value; | |
| return DIV.removeAttribute("onclick"), isFunction | |
| }(); | |
| PROBLEMATIC_ATTRIBUTE_READING ? readAttribute = readAttribute_IE : Prototype.Browser.Opera && (readAttribute = readAttribute_Opera), GLOBAL.Element.Methods.Simulated.hasAttribute = hasAttribute; | |
| var regExpCache = {}, ATTRIBUTE_TRANSLATIONS = {}, classProp = "className", | |
| forProp = "for"; | |
| DIV.setAttribute(classProp, "x"), "x" !== DIV.className && (DIV.setAttribute("class", "x"), "x" === DIV.className && (classProp = "class")); | |
| var LABEL = document.createElement("label"); | |
| LABEL.setAttribute(forProp, "x"), "x" !== LABEL.htmlFor && (LABEL.setAttribute("htmlFor", "x"), "x" === LABEL.htmlFor && (forProp = "htmlFor")), LABEL = null, DIV.onclick = Prototype.emptyFunction; | |
| var _getEv, onclickValue = DIV.getAttribute("onclick"); | |
| String(onclickValue).indexOf("{") > -1 ? _getEv = function (element, attribute) { | |
| var value = element.getAttribute(attribute); | |
| return value ? (value = value.toString(), value = value.split("{")[1], value = value.split("}")[0], value.strip()) : null | |
| } : "" === onclickValue && (_getEv = function (element, attribute) { | |
| var value = element.getAttribute(attribute); | |
| return value ? value.strip() : null | |
| }), ATTRIBUTE_TRANSLATIONS.read = { | |
| names: { | |
| "class": classProp, | |
| className: classProp, | |
| "for": forProp, | |
| htmlFor: forProp | |
| }, | |
| values: { | |
| style: function (element) { | |
| return element.style.cssText.toLowerCase() | |
| }, | |
| title: function (element) { | |
| return element.title | |
| } | |
| } | |
| }, ATTRIBUTE_TRANSLATIONS.write = { | |
| names: { | |
| className: "class", | |
| htmlFor: "for", | |
| cellpadding: "cellPadding", | |
| cellspacing: "cellSpacing" | |
| }, | |
| values: { | |
| checked: function (element, value) { | |
| element.checked = !! value | |
| }, | |
| style: function (element, value) { | |
| element.style.cssText = value ? value : "" | |
| } | |
| } | |
| }, ATTRIBUTE_TRANSLATIONS.has = { | |
| names: {} | |
| }, Object.extend(ATTRIBUTE_TRANSLATIONS.write.names, ATTRIBUTE_TRANSLATIONS.read.names); | |
| for (var attr, CAMEL_CASED_ATTRIBUTE_NAMES = $w("colSpan rowSpan vAlign dateTime accessKey tabIndex encType maxLength readOnly longDesc frameBorder"), i = 0; attr = CAMEL_CASED_ATTRIBUTE_NAMES[i]; i++) ATTRIBUTE_TRANSLATIONS.write.names[attr.toLowerCase()] = attr, ATTRIBUTE_TRANSLATIONS.has.names[attr.toLowerCase()] = attr; | |
| Object.extend(ATTRIBUTE_TRANSLATIONS.read.values, { | |
| href: _getAttr2, | |
| src: _getAttr2, | |
| type: _getAttr, | |
| action: _getAttrNode, | |
| disabled: _getFlag, | |
| checked: _getFlag, | |
| readonly: _getFlag, | |
| multiple: _getFlag, | |
| onload: _getEv, | |
| onunload: _getEv, | |
| onclick: _getEv, | |
| ondblclick: _getEv, | |
| onmousedown: _getEv, | |
| onmouseup: _getEv, | |
| onmouseover: _getEv, | |
| onmousemove: _getEv, | |
| onmouseout: _getEv, | |
| onfocus: _getEv, | |
| onblur: _getEv, | |
| onkeypress: _getEv, | |
| onkeydown: _getEv, | |
| onkeyup: _getEv, | |
| onsubmit: _getEv, | |
| onreset: _getEv, | |
| onselect: _getEv, | |
| onchange: _getEv | |
| }), Object.extend(methods, { | |
| identify: identify, | |
| readAttribute: readAttribute, | |
| writeAttribute: writeAttribute, | |
| classNames: classNames, | |
| hasClassName: hasClassName, | |
| addClassName: addClassName, | |
| removeClassName: removeClassName, | |
| toggleClassName: toggleClassName | |
| }); | |
| var STANDARD_CSS_OPACITY_SUPPORTED = function () { | |
| return DIV.style.cssText = "opacity:.55", /^0.55/.test(DIV.style.opacity) | |
| }(); | |
| Object.extend(methods, { | |
| setStyle: setStyle, | |
| getStyle: getStyle, | |
| setOpacity: setOpacity, | |
| getOpacity: getOpacity | |
| }), "styleFloat" in DIV.style && (methods.getStyle = getStyle_IE, methods.setOpacity = setOpacity_IE, methods.getOpacity = getOpacity_IE), GLOBAL.Element.Storage = { | |
| UID: 1 | |
| }; | |
| var HAS_UNIQUE_ID_PROPERTY = "uniqueID" in DIV; | |
| HAS_UNIQUE_ID_PROPERTY && (getUniqueElementID = getUniqueElementID_IE), Object.extend(methods, { | |
| getStorage: getStorage, | |
| store: store, | |
| retrieve: retrieve | |
| }); | |
| var Methods = {}, ByTag = Element.Methods.ByTag, | |
| F = Prototype.BrowserFeatures; | |
| !F.ElementExtensions && "__proto__" in DIV && (GLOBAL.HTMLElement = {}, GLOBAL.HTMLElement.prototype = DIV.__proto__, F.ElementExtensions = !0); | |
| var HTMLOBJECTELEMENT_PROTOTYPE_BUGGY = checkElementPrototypeDeficiency("object"), | |
| EXTENDED = {}; | |
| F.SpecificElementExtensions && (extend = HTMLOBJECTELEMENT_PROTOTYPE_BUGGY ? extend_IE8 : Prototype.K), Object.extend(GLOBAL.Element, { | |
| extend: extend, | |
| addMethods: addMethods | |
| }), GLOBAL.Element.extend.refresh = extend === Prototype.K ? Prototype.emptyFunction : function () { | |
| Prototype.BrowserFeatures.ElementExtensions || (Object.extend(Methods, Element.Methods), Object.extend(Methods, Element.Methods.Simulated), EXTENDED = {}) | |
| }, Element.addMethods(methods) | |
| }(this), | |
| function () { | |
| function toDecimal(pctString) { | |
| var match = pctString.match(/^(\d+)%?$/i); | |
| return match ? Number(match[1]) / 100 : null | |
| } | |
| function getRawStyle(element, style) { | |
| element = $(element); | |
| var value = element.style[style]; | |
| if (!value || "auto" === value) { | |
| var css = document.defaultView.getComputedStyle(element, null); | |
| value = css ? css[style] : null | |
| } | |
| return "opacity" === style ? value ? parseFloat(value) : 1 : "auto" === value ? null : value | |
| } | |
| function getRawStyle_IE(element, style) { | |
| var value = element.style[style]; | |
| return !value && element.currentStyle && (value = element.currentStyle[style]), value | |
| } | |
| function getContentWidth(element, context) { | |
| var boxWidth = element.offsetWidth, | |
| bl = getPixelValue(element, "borderLeftWidth", context) || 0, | |
| br = getPixelValue(element, "borderRightWidth", context) || 0, | |
| pl = getPixelValue(element, "paddingLeft", context) || 0, | |
| pr = getPixelValue(element, "paddingRight", context) || 0; | |
| return boxWidth - bl - br - pl - pr | |
| } | |
| function getPixelValue(value, property, context) { | |
| var element = null; | |
| if (Object.isElement(value) && (element = value, value = getRawStyle(element, property)), null === value || Object.isUndefined(value)) return null; | |
| if (/^(?:-)?\d+(\.\d+)?(px)?$/i.test(value)) return window.parseFloat(value); | |
| var isPercentage = value.include("%"), | |
| isViewport = context === document.viewport; | |
| if (/\d/.test(value) && element && element.runtimeStyle && (!isPercentage || !isViewport)) { | |
| var style = element.style.left, | |
| rStyle = element.runtimeStyle.left; | |
| return element.runtimeStyle.left = element.currentStyle.left, element.style.left = value || 0, value = element.style.pixelLeft, element.style.left = style, element.runtimeStyle.left = rStyle, value | |
| } | |
| if (element && isPercentage) { | |
| context = context || element.parentNode; | |
| var decimal = toDecimal(value), | |
| whole = null, | |
| isHorizontal = property.include("left") || property.include("right") || property.include("width"), | |
| isVertical = property.include("top") || property.include("bottom") || property.include("height"); | |
| return context === document.viewport ? isHorizontal ? whole = document.viewport.getWidth() : isVertical && (whole = document.viewport.getHeight()) : isHorizontal ? whole = $(context).measure("width") : isVertical && (whole = $(context).measure("height")), null === whole ? 0 : whole * decimal | |
| } | |
| return 0 | |
| } | |
| function isDisplayed(element) { | |
| for (; element && element.parentNode;) { | |
| var display = element.getStyle("display"); | |
| if ("none" === display) return !1; | |
| element = $(element.parentNode) | |
| } | |
| return !0 | |
| } | |
| function cssNameFor(key) { | |
| return key.include("border") && (key += "-width"), key.camelize() | |
| } | |
| function getLayout(element, preCompute) { | |
| return new Element.Layout(element, preCompute) | |
| } | |
| function measure(element, property) { | |
| return $(element).getLayout().get(property) | |
| } | |
| function getHeight(element) { | |
| return Element.getDimensions(element).height | |
| } | |
| function getWidth(element) { | |
| return Element.getDimensions(element).width | |
| } | |
| function getDimensions(element) { | |
| element = $(element); | |
| var display = Element.getStyle(element, "display"); | |
| if (display && "none" !== display) return { | |
| width: element.offsetWidth, | |
| height: element.offsetHeight | |
| }; | |
| var style = element.style, | |
| originalStyles = { | |
| visibility: style.visibility, | |
| position: style.position, | |
| display: style.display | |
| }, newStyles = { | |
| visibility: "hidden", | |
| display: "block" | |
| }; | |
| "fixed" !== originalStyles.position && (newStyles.position = "absolute"), Element.setStyle(element, newStyles); | |
| var dimensions = { | |
| width: element.offsetWidth, | |
| height: element.offsetHeight | |
| }; | |
| return Element.setStyle(element, originalStyles), dimensions | |
| } | |
| function getOffsetParent(element) { | |
| if (element = $(element), isDocument(element) || isDetached(element) || isBody(element) || isHtml(element)) return $(document.body); | |
| var isInline = "inline" === Element.getStyle(element, "display"); | |
| if (!isInline && element.offsetParent) return $(element.offsetParent); | |
| for (; | |
| (element = element.parentNode) && element !== document.body;) | |
| if ("static" !== Element.getStyle(element, "position")) return isHtml(element) ? $(document.body) : $(element); | |
| return $(document.body) | |
| } | |
| function cumulativeOffset(element) { | |
| element = $(element); | |
| var valueT = 0, | |
| valueL = 0; | |
| if (element.parentNode) | |
| do valueT += element.offsetTop || 0, valueL += element.offsetLeft || 0, element = element.offsetParent; while (element); | |
| return new Element.Offset(valueL, valueT) | |
| } | |
| function positionedOffset(element) { | |
| element = $(element); | |
| var layout = element.getLayout(), | |
| valueT = 0, | |
| valueL = 0; | |
| do | |
| if (valueT += element.offsetTop || 0, valueL += element.offsetLeft || 0, element = element.offsetParent) { | |
| if (isBody(element)) break; | |
| var p = Element.getStyle(element, "position"); | |
| if ("static" !== p) break | |
| } while (element); | |
| return valueL -= layout.get("margin-top"), valueT -= layout.get("margin-left"), new Element.Offset(valueL, valueT) | |
| } | |
| function cumulativeScrollOffset(element) { | |
| var valueT = 0, | |
| valueL = 0; | |
| do valueT += element.scrollTop || 0, valueL += element.scrollLeft || 0, element = element.parentNode; while (element); | |
| return new Element.Offset(valueL, valueT) | |
| } | |
| function viewportOffset(forElement) { | |
| var valueT = 0, | |
| valueL = 0, | |
| docBody = document.body, | |
| element = $(forElement); | |
| do | |
| if (valueT += element.offsetTop || 0, valueL += element.offsetLeft || 0, element.offsetParent == docBody && "absolute" == Element.getStyle(element, "position")) break; while (element = element.offsetParent); | |
| element = forElement; | |
| do element != docBody && (valueT -= element.scrollTop || 0, valueL -= element.scrollLeft || 0); while (element = element.parentNode); | |
| return new Element.Offset(valueL, valueT) | |
| } | |
| function absolutize(element) { | |
| if (element = $(element), "absolute" === Element.getStyle(element, "position")) return element; | |
| var offsetParent = getOffsetParent(element), | |
| eOffset = element.viewportOffset(), | |
| pOffset = offsetParent.viewportOffset(), | |
| offset = eOffset.relativeTo(pOffset), | |
| layout = element.getLayout(); | |
| return element.store("prototype_absolutize_original_styles", { | |
| left: element.getStyle("left"), | |
| top: element.getStyle("top"), | |
| width: element.getStyle("width"), | |
| height: element.getStyle("height") | |
| }), element.setStyle({ | |
| position: "absolute", | |
| top: offset.top + "px", | |
| left: offset.left + "px", | |
| width: layout.get("width") + "px", | |
| height: layout.get("height") + "px" | |
| }), element | |
| } | |
| function relativize(element) { | |
| if (element = $(element), "relative" === Element.getStyle(element, "position")) return element; | |
| var originalStyles = element.retrieve("prototype_absolutize_original_styles"); | |
| return originalStyles && element.setStyle(originalStyles), element | |
| } | |
| function scrollTo(element) { | |
| element = $(element); | |
| var pos = Element.cumulativeOffset(element); | |
| return window.scrollTo(pos.left, pos.top), element | |
| } | |
| function makePositioned(element) { | |
| element = $(element); | |
| var position = Element.getStyle(element, "position"), | |
| styles = {}; | |
| return "static" !== position && position || (styles.position = "relative", Prototype.Browser.Opera && (styles.top = 0, styles.left = 0), Element.setStyle(element, styles), Element.store(element, "prototype_made_positioned", !0)), element | |
| } | |
| function undoPositioned(element) { | |
| element = $(element); | |
| var storage = Element.getStorage(element), | |
| madePositioned = storage.get("prototype_made_positioned"); | |
| return madePositioned && (storage.unset("prototype_made_positioned"), Element.setStyle(element, { | |
| position: "", | |
| top: "", | |
| bottom: "", | |
| left: "", | |
| right: "" | |
| })), element | |
| } | |
| function makeClipping(element) { | |
| element = $(element); | |
| var storage = Element.getStorage(element), | |
| madeClipping = storage.get("prototype_made_clipping"); | |
| if (Object.isUndefined(madeClipping)) { | |
| var overflow = Element.getStyle(element, "overflow"); | |
| storage.set("prototype_made_clipping", overflow), "hidden" !== overflow && (element.style.overflow = "hidden") | |
| } | |
| return element | |
| } | |
| function undoClipping(element) { | |
| element = $(element); | |
| var storage = Element.getStorage(element), | |
| overflow = storage.get("prototype_made_clipping"); | |
| return Object.isUndefined(overflow) || (storage.unset("prototype_made_clipping"), element.style.overflow = overflow || ""), element | |
| } | |
| function clonePosition(element, source, options) { | |
| options = Object.extend({ | |
| setLeft: !0, | |
| setTop: !0, | |
| setWidth: !0, | |
| setHeight: !0, | |
| offsetTop: 0, | |
| offsetLeft: 0 | |
| }, options || {}), source = $(source), element = $(element); | |
| var p, delta, layout, styles = {}; | |
| if ((options.setLeft || options.setTop) && (p = Element.viewportOffset(source), delta = [0, 0], "absolute" === Element.getStyle(element, "position"))) { | |
| var parent = Element.getOffsetParent(element); | |
| parent !== document.body && (delta = Element.viewportOffset(parent)) | |
| } | |
| return (options.setWidth || options.setHeight) && (layout = Element.getLayout(source)), options.setLeft && (styles.left = p[0] - delta[0] + options.offsetLeft + "px"), options.setTop && (styles.top = p[1] - delta[1] + options.offsetTop + "px"), options.setWidth && (styles.width = layout.get("border-box-width") + "px"), options.setHeight && (styles.height = layout.get("border-box-height") + "px"), Element.setStyle(element, styles) | |
| } | |
| function isBody(element) { | |
| return "BODY" === element.nodeName.toUpperCase() | |
| } | |
| function isHtml(element) { | |
| return "HTML" === element.nodeName.toUpperCase() | |
| } | |
| function isDocument(element) { | |
| return element.nodeType === Node.DOCUMENT_NODE | |
| } | |
| function isDetached(element) { | |
| return element !== document.body && !Element.descendantOf(element, document.body) | |
| } | |
| "currentStyle" in document.documentElement && (getRawStyle = getRawStyle_IE); | |
| var hasLayout = Prototype.K; | |
| "currentStyle" in document.documentElement && (hasLayout = function (element) { | |
| return element.currentStyle.hasLayout || (element.style.zoom = 1), element | |
| }), Element.Layout = Class.create(Hash, { | |
| initialize: function ($super, element, preCompute) { | |
| $super(), this.element = $(element), Element.Layout.PROPERTIES.each(function (property) { | |
| this._set(property, null) | |
| }, this), preCompute && (this._preComputing = !0, this._begin(), Element.Layout.PROPERTIES.each(this._compute, this), this._end(), this._preComputing = !1) | |
| }, | |
| _set: function (property, value) { | |
| return Hash.prototype.set.call(this, property, value) | |
| }, | |
| set: function () { | |
| throw "Properties of Element.Layout are read-only." | |
| }, | |
| get: function ($super, property) { | |
| var value = $super(property); | |
| return null === value ? this._compute(property) : value | |
| }, | |
| _begin: function () { | |
| if (!this._isPrepared()) { | |
| var element = this.element; | |
| if (isDisplayed(element)) return this._setPrepared(!0), void 0; | |
| var originalStyles = { | |
| position: element.style.position || "", | |
| width: element.style.width || "", | |
| visibility: element.style.visibility || "", | |
| display: element.style.display || "" | |
| }; | |
| element.store("prototype_original_styles", originalStyles); | |
| var position = getRawStyle(element, "position"), | |
| width = element.offsetWidth; | |
| (0 === width || null === width) && (element.style.display = "block", width = element.offsetWidth); | |
| var context = "fixed" === position ? document.viewport : element.parentNode, | |
| tempStyles = { | |
| visibility: "hidden", | |
| display: "block" | |
| }; | |
| "fixed" !== position && (tempStyles.position = "absolute"), element.setStyle(tempStyles); | |
| var newWidth, positionedWidth = element.offsetWidth; | |
| if (width && positionedWidth === width) newWidth = getContentWidth(element, context); | |
| else if ("absolute" === position || "fixed" === position) newWidth = getContentWidth(element, context); | |
| else { | |
| var parent = element.parentNode, | |
| pLayout = $(parent).getLayout(); | |
| newWidth = pLayout.get("width") - this.get("margin-left") - this.get("border-left") - this.get("padding-left") - this.get("padding-right") - this.get("border-right") - this.get("margin-right") | |
| } | |
| element.setStyle({ | |
| width: newWidth + "px" | |
| }), this._setPrepared(!0) | |
| } | |
| }, | |
| _end: function () { | |
| var element = this.element, | |
| originalStyles = element.retrieve("prototype_original_styles"); | |
| element.store("prototype_original_styles", null), element.setStyle(originalStyles), this._setPrepared(!1) | |
| }, | |
| _compute: function (property) { | |
| var COMPUTATIONS = Element.Layout.COMPUTATIONS; | |
| if (!(property in COMPUTATIONS)) throw "Property not found."; | |
| return this._set(property, COMPUTATIONS[property].call(this, this.element)) | |
| }, | |
| _isPrepared: function () { | |
| return this.element.retrieve("prototype_element_layout_prepared", !1) | |
| }, | |
| _setPrepared: function (bool) { | |
| return this.element.store("prototype_element_layout_prepared", bool) | |
| }, | |
| toObject: function () { | |
| var args = $A(arguments), | |
| keys = 0 === args.length ? Element.Layout.PROPERTIES : args.join(" ").split(" "), | |
| obj = {}; | |
| return keys.each(function (key) { | |
| if (Element.Layout.PROPERTIES.include(key)) { | |
| var value = this.get(key); | |
| null != value && (obj[key] = value) | |
| } | |
| }, this), obj | |
| }, | |
| toHash: function () { | |
| var obj = this.toObject.apply(this, arguments); | |
| return new Hash(obj) | |
| }, | |
| toCSS: function () { | |
| var args = $A(arguments), | |
| keys = 0 === args.length ? Element.Layout.PROPERTIES : args.join(" ").split(" "), | |
| css = {}; | |
| return keys.each(function (key) { | |
| if (Element.Layout.PROPERTIES.include(key) && !Element.Layout.COMPOSITE_PROPERTIES.include(key)) { | |
| var value = this.get(key); | |
| null != value && (css[cssNameFor(key)] = value + "px") | |
| } | |
| }, this), css | |
| }, | |
| inspect: function () { | |
| return "#<Element.Layout>" | |
| } | |
| }), Object.extend(Element.Layout, { | |
| PROPERTIES: $w("height width top left right bottom border-left border-right border-top border-bottom padding-left padding-right padding-top padding-bottom margin-top margin-bottom margin-left margin-right padding-box-width padding-box-height border-box-width border-box-height margin-box-width margin-box-height"), | |
| COMPOSITE_PROPERTIES: $w("padding-box-width padding-box-height margin-box-width margin-box-height border-box-width border-box-height"), | |
| COMPUTATIONS: { | |
| height: function () { | |
| this._preComputing || this._begin(); | |
| var bHeight = this.get("border-box-height"); | |
| if (0 >= bHeight) return this._preComputing || this._end(), 0; | |
| var bTop = this.get("border-top"), | |
| bBottom = this.get("border-bottom"), | |
| pTop = this.get("padding-top"), | |
| pBottom = this.get("padding-bottom"); | |
| return this._preComputing || this._end(), bHeight - bTop - bBottom - pTop - pBottom | |
| }, | |
| width: function () { | |
| this._preComputing || this._begin(); | |
| var bWidth = this.get("border-box-width"); | |
| if (0 >= bWidth) return this._preComputing || this._end(), 0; | |
| var bLeft = this.get("border-left"), | |
| bRight = this.get("border-right"), | |
| pLeft = this.get("padding-left"), | |
| pRight = this.get("padding-right"); | |
| return this._preComputing || this._end(), bWidth - bLeft - bRight - pLeft - pRight | |
| }, | |
| "padding-box-height": function () { | |
| var height = this.get("height"), | |
| pTop = this.get("padding-top"), | |
| pBottom = this.get("padding-bottom"); | |
| return height + pTop + pBottom | |
| }, | |
| "padding-box-width": function () { | |
| var width = this.get("width"), | |
| pLeft = this.get("padding-left"), | |
| pRight = this.get("padding-right"); | |
| return width + pLeft + pRight | |
| }, | |
| "border-box-height": function (element) { | |
| this._preComputing || this._begin(); | |
| var height = element.offsetHeight; | |
| return this._preComputing || this._end(), height | |
| }, | |
| "border-box-width": function (element) { | |
| this._preComputing || this._begin(); | |
| var width = element.offsetWidth; | |
| return this._preComputing || this._end(), width | |
| }, | |
| "margin-box-height": function () { | |
| var bHeight = this.get("border-box-height"), | |
| mTop = this.get("margin-top"), | |
| mBottom = this.get("margin-bottom"); | |
| return 0 >= bHeight ? 0 : bHeight + mTop + mBottom | |
| }, | |
| "margin-box-width": function () { | |
| var bWidth = this.get("border-box-width"), | |
| mLeft = this.get("margin-left"), | |
| mRight = this.get("margin-right"); | |
| return 0 >= bWidth ? 0 : bWidth + mLeft + mRight | |
| }, | |
| top: function (element) { | |
| var offset = element.positionedOffset(); | |
| return offset.top | |
| }, | |
| bottom: function (element) { | |
| var offset = element.positionedOffset(), | |
| parent = element.getOffsetParent(), | |
| pHeight = parent.measure("height"), | |
| mHeight = this.get("border-box-height"); | |
| return pHeight - mHeight - offset.top | |
| }, | |
| left: function (element) { | |
| var offset = element.positionedOffset(); | |
| return offset.left | |
| }, | |
| right: function (element) { | |
| var offset = element.positionedOffset(), | |
| parent = element.getOffsetParent(), | |
| pWidth = parent.measure("width"), | |
| mWidth = this.get("border-box-width"); | |
| return pWidth - mWidth - offset.left | |
| }, | |
| "padding-top": function (element) { | |
| return getPixelValue(element, "paddingTop") | |
| }, | |
| "padding-bottom": function (element) { | |
| return getPixelValue(element, "paddingBottom") | |
| }, | |
| "padding-left": function (element) { | |
| return getPixelValue(element, "paddingLeft") | |
| }, | |
| "padding-right": function (element) { | |
| return getPixelValue(element, "paddingRight") | |
| }, | |
| "border-top": function (element) { | |
| return getPixelValue(element, "borderTopWidth") | |
| }, | |
| "border-bottom": function (element) { | |
| return getPixelValue(element, "borderBottomWidth") | |
| }, | |
| "border-left": function (element) { | |
| return getPixelValue(element, "borderLeftWidth") | |
| }, | |
| "border-right": function (element) { | |
| return getPixelValue(element, "borderRightWidth") | |
| }, | |
| "margin-top": function (element) { | |
| return getPixelValue(element, "marginTop") | |
| }, | |
| "margin-bottom": function (element) { | |
| return getPixelValue(element, "marginBottom") | |
| }, | |
| "margin-left": function (element) { | |
| return getPixelValue(element, "marginLeft") | |
| }, | |
| "margin-right": function (element) { | |
| return getPixelValue(element, "marginRight") | |
| } | |
| } | |
| }), "getBoundingClientRect" in document.documentElement && Object.extend(Element.Layout.COMPUTATIONS, { | |
| right: function (element) { | |
| var parent = hasLayout(element.getOffsetParent()), | |
| rect = element.getBoundingClientRect(), | |
| pRect = parent.getBoundingClientRect(); | |
| return (pRect.right - rect.right).round() | |
| }, | |
| bottom: function (element) { | |
| var parent = hasLayout(element.getOffsetParent()), | |
| rect = element.getBoundingClientRect(), | |
| pRect = parent.getBoundingClientRect(); | |
| return (pRect.bottom - rect.bottom).round() | |
| } | |
| }), Element.Offset = Class.create({ | |
| initialize: function (left, top) { | |
| this.left = left.round(), this.top = top.round(), this[0] = this.left, this[1] = this.top | |
| }, | |
| relativeTo: function (offset) { | |
| return new Element.Offset(this.left - offset.left, this.top - offset.top) | |
| }, | |
| inspect: function () { | |
| return "#<Element.Offset left: #{left} top: #{top}>".interpolate(this) | |
| }, | |
| toString: function () { | |
| return "[#{left}, #{top}]".interpolate(this) | |
| }, | |
| toArray: function () { | |
| return [this.left, this.top] | |
| } | |
| }), Prototype.Browser.IE ? (getOffsetParent = getOffsetParent.wrap(function (proceed, element) { | |
| if (element = $(element), isDocument(element) || isDetached(element) || isBody(element) || isHtml(element)) return $(document.body); | |
| var position = element.getStyle("position"); | |
| if ("static" !== position) return proceed(element); | |
| element.setStyle({ | |
| position: "relative" | |
| }); | |
| var value = proceed(element); | |
| return element.setStyle({ | |
| position: position | |
| }), value | |
| }), positionedOffset = positionedOffset.wrap(function (proceed, element) { | |
| if (element = $(element), !element.parentNode) return new Element.Offset(0, 0); | |
| var position = element.getStyle("position"); | |
| if ("static" !== position) return proceed(element); | |
| var offsetParent = element.getOffsetParent(); | |
| offsetParent && "fixed" === offsetParent.getStyle("position") && hasLayout(offsetParent), element.setStyle({ | |
| position: "relative" | |
| }); | |
| var value = proceed(element); | |
| return element.setStyle({ | |
| position: position | |
| }), value | |
| })) : Prototype.Browser.Webkit && (cumulativeOffset = function (element) { | |
| element = $(element); | |
| var valueT = 0, | |
| valueL = 0; | |
| do { | |
| if (valueT += element.offsetTop || 0, valueL += element.offsetLeft || 0, element.offsetParent == document.body && "absolute" == Element.getStyle(element, "position")) break; | |
| element = element.offsetParent | |
| } while (element); | |
| return new Element.Offset(valueL, valueT) | |
| }), Element.addMethods({ | |
| getLayout: getLayout, | |
| measure: measure, | |
| getWidth: getWidth, | |
| getHeight: getHeight, | |
| getDimensions: getDimensions, | |
| getOffsetParent: getOffsetParent, | |
| cumulativeOffset: cumulativeOffset, | |
| positionedOffset: positionedOffset, | |
| cumulativeScrollOffset: cumulativeScrollOffset, | |
| viewportOffset: viewportOffset, | |
| absolutize: absolutize, | |
| relativize: relativize, | |
| scrollTo: scrollTo, | |
| makePositioned: makePositioned, | |
| undoPositioned: undoPositioned, | |
| makeClipping: makeClipping, | |
| undoClipping: undoClipping, | |
| clonePosition: clonePosition | |
| }), "getBoundingClientRect" in document.documentElement && Element.addMethods({ | |
| viewportOffset: function (element) { | |
| if (element = $(element), isDetached(element)) return new Element.Offset(0, 0); | |
| var rect = element.getBoundingClientRect(), | |
| docEl = document.documentElement; | |
| return new Element.Offset(rect.left - docEl.clientLeft, rect.top - docEl.clientTop) | |
| } | |
| }) | |
| }(), | |
| function () { | |
| function getRootElement() { | |
| return ROOT ? ROOT : ROOT = IS_OLD_OPERA ? document.body : document.documentElement | |
| } | |
| function getDimensions() { | |
| return { | |
| width: this.getWidth(), | |
| height: this.getHeight() | |
| } | |
| } | |
| function getWidth() { | |
| return getRootElement().clientWidth | |
| } | |
| function getHeight() { | |
| return getRootElement().clientHeight | |
| } | |
| function getScrollOffsets() { | |
| var x = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, | |
| y = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop; | |
| return new Element.Offset(x, y) | |
| } | |
| var IS_OLD_OPERA = Prototype.Browser.Opera && window.parseFloat(window.opera.version()) < 9.5, | |
| ROOT = null; | |
| document.viewport = { | |
| getDimensions: getDimensions, | |
| getWidth: getWidth, | |
| getHeight: getHeight, | |
| getScrollOffsets: getScrollOffsets | |
| } | |
| }(), window.$$ = function () { | |
| var expression = $A(arguments).join(", "); | |
| return Prototype.Selector.select(expression, document) | |
| }, Prototype.Selector = function () { | |
| function select() { | |
| throw new Error('Method "Prototype.Selector.select" must be defined.') | |
| } | |
| function match() { | |
| throw new Error('Method "Prototype.Selector.match" must be defined.') | |
| } | |
| function find(elements, expression, index) { | |
| index = index || 0; | |
| var i, match = Prototype.Selector.match, | |
| length = elements.length, | |
| matchIndex = 0; | |
| for (i = 0; length > i; i++) | |
| if (match(elements[i], expression) && index == matchIndex++) return Element.extend(elements[i]) | |
| } | |
| function extendElements(elements) { | |
| for (var i = 0, length = elements.length; length > i; i++) Element.extend(elements[i]); | |
| return elements | |
| } | |
| var K = Prototype.K; | |
| return { | |
| select: select, | |
| match: match, | |
| find: find, | |
| extendElements: Element.extend === K ? K : extendElements, | |
| extendElement: Element.extend | |
| } | |
| }(), | |
| function () { | |
| function dirNodeCheck(dir, cur, doneName, checkSet, nodeCheck, isXML) { | |
| for (var i = 0, l = checkSet.length; l > i; i++) { | |
| var elem = checkSet[i]; | |
| if (elem) { | |
| var match = !1; | |
| for (elem = elem[dir]; elem;) { | |
| if (elem.sizcache === doneName) { | |
| match = checkSet[elem.sizset]; | |
| break | |
| } | |
| if (1 !== elem.nodeType || isXML || (elem.sizcache = doneName, elem.sizset = i), elem.nodeName.toLowerCase() === cur) { | |
| match = elem; | |
| break | |
| } | |
| elem = elem[dir] | |
| } | |
| checkSet[i] = match | |
| } | |
| } | |
| } | |
| function dirCheck(dir, cur, doneName, checkSet, nodeCheck, isXML) { | |
| for (var i = 0, l = checkSet.length; l > i; i++) { | |
| var elem = checkSet[i]; | |
| if (elem) { | |
| var match = !1; | |
| for (elem = elem[dir]; elem;) { | |
| if (elem.sizcache === doneName) { | |
| match = checkSet[elem.sizset]; | |
| break | |
| } | |
| if (1 === elem.nodeType) | |
| if (isXML || (elem.sizcache = doneName, elem.sizset = i), "string" != typeof cur) { | |
| if (elem === cur) { | |
| match = !0; | |
| break | |
| } | |
| } else if (Sizzle.filter(cur, [elem]).length > 0) { | |
| match = elem; | |
| break | |
| } | |
| elem = elem[dir] | |
| } | |
| checkSet[i] = match | |
| } | |
| } | |
| } | |
| var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, | |
| done = 0, | |
| toString = Object.prototype.toString, | |
| hasDuplicate = !1, | |
| baseHasDuplicate = !0, | |
| rBackslash = /\\/g, | |
| rNonWord = /\W/; | |
| [0, 0].sort(function () { | |
| return baseHasDuplicate = !1, 0 | |
| }); | |
| var Sizzle = function (selector, context, results, seed) { | |
| results = results || [], context = context || document; | |
| var origContext = context; | |
| if (1 !== context.nodeType && 9 !== context.nodeType) return []; | |
| if (!selector || "string" != typeof selector) return results; | |
| var m, set, checkSet, extra, ret, cur, pop, i, prune = !0, | |
| contextXML = Sizzle.isXML(context), | |
| parts = [], | |
| soFar = selector; | |
| do | |
| if (chunker.exec(""), m = chunker.exec(soFar), m && (soFar = m[3], parts.push(m[1]), m[2])) { | |
| extra = m[3]; | |
| break | |
| } while (m); | |
| if (parts.length > 1 && origPOS.exec(selector)) | |
| if (2 === parts.length && Expr.relative[parts[0]]) set = posProcess(parts[0] + parts[1], context); | |
| else | |
| for (set = Expr.relative[parts[0]] ? [context] : Sizzle(parts.shift(), context); parts.length;) selector = parts.shift(), Expr.relative[selector] && (selector += parts.shift()), set = posProcess(selector, set); | |
| else if (!seed && parts.length > 1 && 9 === context.nodeType && !contextXML && Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) && (ret = Sizzle.find(parts.shift(), context, contextXML), context = ret.expr ? Sizzle.filter(ret.expr, ret.set)[0] : ret.set[0]), context) | |
| for (ret = seed ? { | |
| expr: parts.pop(), | |
| set: makeArray(seed) | |
| } : Sizzle.find(parts.pop(), 1 !== parts.length || "~" !== parts[0] && "+" !== parts[0] || !context.parentNode ? context : context.parentNode, contextXML), set = ret.expr ? Sizzle.filter(ret.expr, ret.set) : ret.set, parts.length > 0 ? checkSet = makeArray(set) : prune = !1; parts.length;) cur = parts.pop(), pop = cur, Expr.relative[cur] ? pop = parts.pop() : cur = "", null == pop && (pop = context), Expr.relative[cur](checkSet, pop, contextXML); | |
| else checkSet = parts = []; if (checkSet || (checkSet = set), checkSet || Sizzle.error(cur || selector), "[object Array]" === toString.call(checkSet)) | |
| if (prune) | |
| if (context && 1 === context.nodeType) | |
| for (i = 0; null != checkSet[i]; i++) checkSet[i] && (checkSet[i] === !0 || 1 === checkSet[i].nodeType && Sizzle.contains(context, checkSet[i])) && results.push(set[i]); | |
| else | |
| for (i = 0; null != checkSet[i]; i++) checkSet[i] && 1 === checkSet[i].nodeType && results.push(set[i]); | |
| else results.push.apply(results, checkSet); | |
| else makeArray(checkSet, results); | |
| return extra && (Sizzle(extra, origContext, results, seed), Sizzle.uniqueSort(results)), results | |
| }; | |
| Sizzle.uniqueSort = function (results) { | |
| if (sortOrder && (hasDuplicate = baseHasDuplicate, results.sort(sortOrder), hasDuplicate)) | |
| for (var i = 1; i < results.length; i++) results[i] === results[i - 1] && results.splice(i--, 1); | |
| return results | |
| }, Sizzle.matches = function (expr, set) { | |
| return Sizzle(expr, null, null, set) | |
| }, Sizzle.matchesSelector = function (node, expr) { | |
| return Sizzle(expr, null, null, [node]).length > 0 | |
| }, Sizzle.find = function (expr, context, isXML) { | |
| var set; | |
| if (!expr) return []; | |
| for (var i = 0, l = Expr.order.length; l > i; i++) { | |
| var match, type = Expr.order[i]; | |
| if (match = Expr.leftMatch[type].exec(expr)) { | |
| var left = match[1]; | |
| if (match.splice(1, 1), "\\" !== left.substr(left.length - 1) && (match[1] = (match[1] || "").replace(rBackslash, ""), set = Expr.find[type](match, context, isXML), null != set)) { | |
| expr = expr.replace(Expr.match[type], ""); | |
| break | |
| } | |
| } | |
| } | |
| return set || (set = "undefined" != typeof context.getElementsByTagName ? context.getElementsByTagName("*") : []), { | |
| set: set, | |
| expr: expr | |
| } | |
| }, Sizzle.filter = function (expr, set, inplace, not) { | |
| for (var match, anyFound, old = expr, result = [], curLoop = set, isXMLFilter = set && set[0] && Sizzle.isXML(set[0]); expr && set.length;) { | |
| for (var type in Expr.filter) | |
| if (null != (match = Expr.leftMatch[type].exec(expr)) && match[2]) { | |
| var found, item, filter = Expr.filter[type], | |
| left = match[1]; | |
| if (anyFound = !1, match.splice(1, 1), "\\" === left.substr(left.length - 1)) continue; | |
| if (curLoop === result && (result = []), Expr.preFilter[type]) | |
| if (match = Expr.preFilter[type](match, curLoop, inplace, result, not, isXMLFilter)) { | |
| if (match === !0) continue | |
| } else anyFound = found = !0; | |
| if (match) | |
| for (var i = 0; null != (item = curLoop[i]); i++) | |
| if (item) { | |
| found = filter(item, match, i, curLoop); | |
| var pass = not ^ !! found; | |
| inplace && null != found ? pass ? anyFound = !0 : curLoop[i] = !1 : pass && (result.push(item), anyFound = !0) | |
| } | |
| if (void 0 !== found) { | |
| if (inplace || (curLoop = result), expr = expr.replace(Expr.match[type], ""), !anyFound) return []; | |
| break | |
| } | |
| } | |
| if (expr === old) { | |
| if (null != anyFound) break; | |
| Sizzle.error(expr) | |
| } | |
| old = expr | |
| } | |
| return curLoop | |
| }, Sizzle.error = function (msg) { | |
| throw "Syntax error, unrecognized expression: " + msg | |
| }; | |
| var Expr = Sizzle.selectors = { | |
| order: ["ID", "NAME", "TAG"], | |
| match: { | |
| ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, | |
| CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, | |
| NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, | |
| ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, | |
| TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, | |
| CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, | |
| POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, | |
| PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ | |
| }, | |
| leftMatch: {}, | |
| attrMap: { | |
| "class": "className", | |
| "for": "htmlFor" | |
| }, | |
| attrHandle: { | |
| href: function (elem) { | |
| return elem.getAttribute("href") | |
| }, | |
| type: function (elem) { | |
| return elem.getAttribute("type") | |
| } | |
| }, | |
| relative: { | |
| "+": function (checkSet, part) { | |
| var isPartStr = "string" == typeof part, | |
| isTag = isPartStr && !rNonWord.test(part), | |
| isPartStrNotTag = isPartStr && !isTag; | |
| isTag && (part = part.toLowerCase()); | |
| for (var elem, i = 0, l = checkSet.length; l > i; i++) | |
| if (elem = checkSet[i]) { | |
| for (; | |
| (elem = elem.previousSibling) && 1 !== elem.nodeType;); | |
| checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? elem || !1 : elem === part | |
| } | |
| isPartStrNotTag && Sizzle.filter(part, checkSet, !0) | |
| }, | |
| ">": function (checkSet, part) { | |
| var elem, isPartStr = "string" == typeof part, | |
| i = 0, | |
| l = checkSet.length; | |
| if (isPartStr && !rNonWord.test(part)) { | |
| for (part = part.toLowerCase(); l > i; i++) | |
| if (elem = checkSet[i]) { | |
| var parent = elem.parentNode; | |
| checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : !1 | |
| } | |
| } else { | |
| for (; l > i; i++) elem = checkSet[i], elem && (checkSet[i] = isPartStr ? elem.parentNode : elem.parentNode === part); | |
| isPartStr && Sizzle.filter(part, checkSet, !0) | |
| } | |
| }, | |
| "": function (checkSet, part, isXML) { | |
| var nodeCheck, doneName = done++, | |
| checkFn = dirCheck; | |
| "string" != typeof part || rNonWord.test(part) || (part = part.toLowerCase(), nodeCheck = part, checkFn = dirNodeCheck), checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML) | |
| }, | |
| "~": function (checkSet, part, isXML) { | |
| var nodeCheck, doneName = done++, | |
| checkFn = dirCheck; | |
| "string" != typeof part || rNonWord.test(part) || (part = part.toLowerCase(), nodeCheck = part, checkFn = dirNodeCheck), checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML) | |
| } | |
| }, | |
| find: { | |
| ID: function (match, context, isXML) { | |
| if ("undefined" != typeof context.getElementById && !isXML) { | |
| var m = context.getElementById(match[1]); | |
| return m && m.parentNode ? [m] : [] | |
| } | |
| }, | |
| NAME: function (match, context) { | |
| if ("undefined" != typeof context.getElementsByName) { | |
| for (var ret = [], results = context.getElementsByName(match[1]), i = 0, l = results.length; l > i; i++) results[i].getAttribute("name") === match[1] && ret.push(results[i]); | |
| return 0 === ret.length ? null : ret | |
| } | |
| }, | |
| TAG: function (match, context) { | |
| return "undefined" != typeof context.getElementsByTagName ? context.getElementsByTagName(match[1]) : void 0 | |
| } | |
| }, | |
| preFilter: { | |
| CLASS: function (match, curLoop, inplace, result, not, isXML) { | |
| if (match = " " + match[1].replace(rBackslash, "") + " ", isXML) return match; | |
| for (var elem, i = 0; null != (elem = curLoop[i]); i++) elem && (not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ? inplace || result.push(elem) : inplace && (curLoop[i] = !1)); | |
| return !1 | |
| }, | |
| ID: function (match) { | |
| return match[1].replace(rBackslash, "") | |
| }, | |
| TAG: function (match) { | |
| return match[1].replace(rBackslash, "").toLowerCase() | |
| }, | |
| CHILD: function (match) { | |
| if ("nth" === match[1]) { | |
| match[2] || Sizzle.error(match[0]), match[2] = match[2].replace(/^\+|\s*/g, ""); | |
| var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec("even" === match[2] && "2n" || "odd" === match[2] && "2n+1" || !/\D/.test(match[2]) && "0n+" + match[2] || match[2]); | |
| match[2] = test[1] + (test[2] || 1) - 0, match[3] = test[3] - 0 | |
| } else match[2] && Sizzle.error(match[0]); | |
| return match[0] = done++, match | |
| }, | |
| ATTR: function (match, curLoop, inplace, result, not, isXML) { | |
| var name = match[1] = match[1].replace(rBackslash, ""); | |
| return !isXML && Expr.attrMap[name] && (match[1] = Expr.attrMap[name]), match[4] = (match[4] || match[5] || "").replace(rBackslash, ""), "~=" === match[2] && (match[4] = " " + match[4] + " "), match | |
| }, | |
| PSEUDO: function (match, curLoop, inplace, result, not) { | |
| if ("not" === match[1]) { | |
| if (!((chunker.exec(match[3]) || "").length > 1 || /^\w/.test(match[3]))) { | |
| var ret = Sizzle.filter(match[3], curLoop, inplace, !0 ^ not); | |
| return inplace || result.push.apply(result, ret), !1 | |
| } | |
| match[3] = Sizzle(match[3], null, null, curLoop) | |
| } else if (Expr.match.POS.test(match[0]) || Expr.match.CHILD.test(match[0])) return !0; | |
| return match | |
| }, | |
| POS: function (match) { | |
| return match.unshift(!0), match | |
| } | |
| }, | |
| filters: { | |
| enabled: function (elem) { | |
| return elem.disabled === !1 && "hidden" !== elem.type | |
| }, | |
| disabled: function (elem) { | |
| return elem.disabled === !0 | |
| }, | |
| checked: function (elem) { | |
| return elem.checked === !0 | |
| }, | |
| selected: function (elem) { | |
| return elem.parentNode && elem.parentNode.selectedIndex, elem.selected === !0 | |
| }, | |
| parent: function (elem) { | |
| return !!elem.firstChild | |
| }, | |
| empty: function (elem) { | |
| return !elem.firstChild | |
| }, | |
| has: function (elem, i, match) { | |
| return !!Sizzle(match[3], elem).length | |
| }, | |
| header: function (elem) { | |
| return /h\d/i.test(elem.nodeName) | |
| }, | |
| text: function (elem) { | |
| var attr = elem.getAttribute("type"), | |
| type = elem.type; | |
| return "input" === elem.nodeName.toLowerCase() && "text" === type && (attr === type || null === attr) | |
| }, | |
| radio: function (elem) { | |
| return "input" === elem.nodeName.toLowerCase() && "radio" === elem.type | |
| }, | |
| checkbox: function (elem) { | |
| return "input" === elem.nodeName.toLowerCase() && "checkbox" === elem.type | |
| }, | |
| file: function (elem) { | |
| return "input" === elem.nodeName.toLowerCase() && "file" === elem.type | |
| }, | |
| password: function (elem) { | |
| return "input" === elem.nodeName.toLowerCase() && "password" === elem.type | |
| }, | |
| submit: function (elem) { | |
| var name = elem.nodeName.toLowerCase(); | |
| return ("input" === name || "button" === name) && "submit" === elem.type | |
| }, | |
| image: function (elem) { | |
| return "input" === elem.nodeName.toLowerCase() && "image" === elem.type | |
| }, | |
| reset: function (elem) { | |
| var name = elem.nodeName.toLowerCase(); | |
| return ("input" === name || "button" === name) && "reset" === elem.type | |
| }, | |
| button: function (elem) { | |
| var name = elem.nodeName.toLowerCase(); | |
| return "input" === name && "button" === elem.type || "button" === name | |
| }, | |
| input: function (elem) { | |
| return /input|select|textarea|button/i.test(elem.nodeName) | |
| }, | |
| focus: function (elem) { | |
| return elem === elem.ownerDocument.activeElement | |
| } | |
| }, | |
| setFilters: { | |
| first: function (elem, i) { | |
| return 0 === i | |
| }, | |
| last: function (elem, i, match, array) { | |
| return i === array.length - 1 | |
| }, | |
| even: function (elem, i) { | |
| return 0 === i % 2 | |
| }, | |
| odd: function (elem, i) { | |
| return 1 === i % 2 | |
| }, | |
| lt: function (elem, i, match) { | |
| return i < match[3] - 0 | |
| }, | |
| gt: function (elem, i, match) { | |
| return i > match[3] - 0 | |
| }, | |
| nth: function (elem, i, match) { | |
| return match[3] - 0 === i | |
| }, | |
| eq: function (elem, i, match) { | |
| return match[3] - 0 === i | |
| } | |
| }, | |
| filter: { | |
| PSEUDO: function (elem, match, i, array) { | |
| var name = match[1], | |
| filter = Expr.filters[name]; | |
| if (filter) return filter(elem, i, match, array); | |
| if ("contains" === name) return (elem.textContent || elem.innerText || Sizzle.getText([elem]) || "").indexOf(match[3]) >= 0; | |
| if ("not" === name) { | |
| for (var not = match[3], j = 0, l = not.length; l > j; j++) | |
| if (not[j] === elem) return !1; | |
| return !0 | |
| } | |
| Sizzle.error(name) | |
| }, | |
| CHILD: function (elem, match) { | |
| var type = match[1], | |
| node = elem; | |
| switch (type) { | |
| case "only": | |
| case "first": | |
| for (; node = node.previousSibling;) | |
| if (1 === node.nodeType) return !1; | |
| if ("first" === type) return !0; | |
| node = elem; | |
| case "last": | |
| for (; node = node.nextSibling;) | |
| if (1 === node.nodeType) return !1; | |
| return !0; | |
| case "nth": | |
| var first = match[2], | |
| last = match[3]; | |
| if (1 === first && 0 === last) return !0; | |
| var doneName = match[0], | |
| parent = elem.parentNode; | |
| if (parent && (parent.sizcache !== doneName || !elem.nodeIndex)) { | |
| var count = 0; | |
| for (node = parent.firstChild; node; node = node.nextSibling) 1 === node.nodeType && (node.nodeIndex = ++count); | |
| parent.sizcache = doneName | |
| } | |
| var diff = elem.nodeIndex - last; | |
| return 0 === first ? 0 === diff : 0 === diff % first && diff / first >= 0 | |
| } | |
| }, | |
| ID: function (elem, match) { | |
| return 1 === elem.nodeType && elem.getAttribute("id") === match | |
| }, | |
| TAG: function (elem, match) { | |
| return "*" === match && 1 === elem.nodeType || elem.nodeName.toLowerCase() === match | |
| }, | |
| CLASS: function (elem, match) { | |
| return (" " + (elem.className || elem.getAttribute("class")) + " ").indexOf(match) > -1 | |
| }, | |
| ATTR: function (elem, match) { | |
| var name = match[1], | |
| result = Expr.attrHandle[name] ? Expr.attrHandle[name](elem) : null != elem[name] ? elem[name] : elem.getAttribute(name), | |
| value = result + "", | |
| type = match[2], | |
| check = match[4]; | |
| return null == result ? "!=" === type : "=" === type ? value === check : "*=" === type ? value.indexOf(check) >= 0 : "~=" === type ? (" " + value + " ").indexOf(check) >= 0 : check ? "!=" === type ? value !== check : "^=" === type ? 0 === value.indexOf(check) : "$=" === type ? value.substr(value.length - check.length) === check : "|=" === type ? value === check || value.substr(0, check.length + 1) === check + "-" : !1 : value && result !== !1 | |
| }, | |
| POS: function (elem, match, i, array) { | |
| var name = match[2], | |
| filter = Expr.setFilters[name]; | |
| return filter ? filter(elem, i, match, array) : void 0 | |
| } | |
| } | |
| }, origPOS = Expr.match.POS, | |
| fescape = function (all, num) { | |
| return "\\" + (num - 0 + 1) | |
| }; | |
| for (var type in Expr.match) Expr.match[type] = new RegExp(Expr.match[type].source + /(?![^\[]*\])(?![^\(]*\))/.source), Expr.leftMatch[type] = new RegExp(/(^(?:.|\r|\n)*?)/.source + Expr.match[type].source.replace(/\\(\d+)/g, fescape)); | |
| var makeArray = function (array, results) { | |
| return array = Array.prototype.slice.call(array, 0), results ? (results.push.apply(results, array), results) : array | |
| }; | |
| try { | |
| Array.prototype.slice.call(document.documentElement.childNodes, 0)[0].nodeType | |
| } catch (e) { | |
| makeArray = function (array, results) { | |
| var i = 0, | |
| ret = results || []; | |
| if ("[object Array]" === toString.call(array)) Array.prototype.push.apply(ret, array); | |
| else if ("number" == typeof array.length) | |
| for (var l = array.length; l > i; i++) ret.push(array[i]); | |
| else | |
| for (; array[i]; i++) ret.push(array[i]); | |
| return ret | |
| } | |
| } | |
| var sortOrder, siblingCheck; | |
| document.documentElement.compareDocumentPosition ? sortOrder = function (a, b) { | |
| return a === b ? (hasDuplicate = !0, 0) : a.compareDocumentPosition && b.compareDocumentPosition ? 4 & a.compareDocumentPosition(b) ? -1 : 1 : a.compareDocumentPosition ? -1 : 1 | |
| } : (sortOrder = function (a, b) { | |
| if (a === b) return hasDuplicate = !0, 0; | |
| if (a.sourceIndex && b.sourceIndex) return a.sourceIndex - b.sourceIndex; | |
| var al, bl, ap = [], | |
| bp = [], | |
| aup = a.parentNode, | |
| bup = b.parentNode, | |
| cur = aup; | |
| if (aup === bup) return siblingCheck(a, b); | |
| if (!aup) return -1; | |
| if (!bup) return 1; | |
| for (; cur;) ap.unshift(cur), cur = cur.parentNode; | |
| for (cur = bup; cur;) bp.unshift(cur), cur = cur.parentNode; | |
| al = ap.length, bl = bp.length; | |
| for (var i = 0; al > i && bl > i; i++) | |
| if (ap[i] !== bp[i]) return siblingCheck(ap[i], bp[i]); | |
| return i === al ? siblingCheck(a, bp[i], -1) : siblingCheck(ap[i], b, 1) | |
| }, siblingCheck = function (a, b, ret) { | |
| if (a === b) return ret; | |
| for (var cur = a.nextSibling; cur;) { | |
| if (cur === b) return -1; | |
| cur = cur.nextSibling | |
| } | |
| return 1 | |
| }), Sizzle.getText = function (elems) { | |
| for (var elem, ret = "", i = 0; elems[i]; i++) elem = elems[i], 3 === elem.nodeType || 4 === elem.nodeType ? ret += elem.nodeValue : 8 !== elem.nodeType && (ret += Sizzle.getText(elem.childNodes)); | |
| return ret | |
| }, | |
| function () { | |
| var form = document.createElement("div"), | |
| id = "script" + (new Date).getTime(), | |
| root = document.documentElement; | |
| form.innerHTML = "<a name='" + id + "'/>", root.insertBefore(form, root.firstChild), document.getElementById(id) && (Expr.find.ID = function (match, context, isXML) { | |
| if ("undefined" != typeof context.getElementById && !isXML) { | |
| var m = context.getElementById(match[1]); | |
| return m ? m.id === match[1] || "undefined" != typeof m.getAttributeNode && m.getAttributeNode("id").nodeValue === match[1] ? [m] : void 0 : [] | |
| } | |
| }, Expr.filter.ID = function (elem, match) { | |
| var node = "undefined" != typeof elem.getAttributeNode && elem.getAttributeNode("id"); | |
| return 1 === elem.nodeType && node && node.nodeValue === match | |
| }), root.removeChild(form), root = form = null | |
| }(), | |
| function () { | |
| var div = document.createElement("div"); | |
| div.appendChild(document.createComment("")), div.getElementsByTagName("*").length > 0 && (Expr.find.TAG = function (match, context) { | |
| var results = context.getElementsByTagName(match[1]); | |
| if ("*" === match[1]) { | |
| for (var tmp = [], i = 0; results[i]; i++) 1 === results[i].nodeType && tmp.push(results[i]); | |
| results = tmp | |
| } | |
| return results | |
| }), div.innerHTML = "<a href='#'></a>", div.firstChild && "undefined" != typeof div.firstChild.getAttribute && "#" !== div.firstChild.getAttribute("href") && (Expr.attrHandle.href = function (elem) { | |
| return elem.getAttribute("href", 2) | |
| }), div = null | |
| }(), document.querySelectorAll && ! function () { | |
| var oldSizzle = Sizzle, | |
| div = document.createElement("div"), | |
| id = "__sizzle__"; | |
| if (div.innerHTML = "<p class='TEST'></p>", !div.querySelectorAll || 0 !== div.querySelectorAll(".TEST").length) { | |
| Sizzle = function (query, context, extra, seed) { | |
| if (context = context || document, !seed && !Sizzle.isXML(context)) { | |
| var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(query); | |
| if (match && (1 === context.nodeType || 9 === context.nodeType)) { | |
| if (match[1]) return makeArray(context.getElementsByTagName(query), extra); | |
| if (match[2] && Expr.find.CLASS && context.getElementsByClassName) return makeArray(context.getElementsByClassName(match[2]), extra) | |
| } | |
| if (9 === context.nodeType) { | |
| if ("body" === query && context.body) return makeArray([context.body], extra); | |
| if (match && match[3]) { | |
| var elem = context.getElementById(match[3]); | |
| if (!elem || !elem.parentNode) return makeArray([], extra); | |
| if (elem.id === match[3]) return makeArray([elem], extra) | |
| } | |
| try { | |
| return makeArray(context.querySelectorAll(query), extra) | |
| } catch (qsaError) {} | |
| } else if (1 === context.nodeType && "object" !== context.nodeName.toLowerCase()) { | |
| var oldContext = context, | |
| old = context.getAttribute("id"), | |
| nid = old || id, | |
| hasParent = context.parentNode, | |
| relativeHierarchySelector = /^\s*[+~]/.test(query); | |
| old ? nid = nid.replace(/'/g, "\\$&") : context.setAttribute("id", nid), relativeHierarchySelector && hasParent && (context = context.parentNode); | |
| try { | |
| if (!relativeHierarchySelector || hasParent) return makeArray(context.querySelectorAll("[id='" + nid + "'] " + query), extra) | |
| } catch (pseudoError) {} finally { | |
| old || oldContext.removeAttribute("id") | |
| } | |
| } | |
| } | |
| return oldSizzle(query, context, extra, seed) | |
| }; | |
| for (var prop in oldSizzle) Sizzle[prop] = oldSizzle[prop]; | |
| div = null | |
| } | |
| }(), | |
| function () { | |
| var html = document.documentElement, | |
| matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; | |
| if (matches) { | |
| var disconnectedMatch = !matches.call(document.createElement("div"), "div"), | |
| pseudoWorks = !1; | |
| try { | |
| matches.call(document.documentElement, "[test!='']:sizzle") | |
| } catch (pseudoError) { | |
| pseudoWorks = !0 | |
| } | |
| Sizzle.matchesSelector = function (node, expr) { | |
| if (expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"), !Sizzle.isXML(node)) try { | |
| if (pseudoWorks || !Expr.match.PSEUDO.test(expr) && !/!=/.test(expr)) { | |
| var ret = matches.call(node, expr); | |
| if (ret || !disconnectedMatch || node.document && 11 !== node.document.nodeType) return ret | |
| } | |
| } catch (e) {} | |
| return Sizzle(expr, null, null, [node]).length > 0 | |
| } | |
| } | |
| }(), | |
| function () { | |
| var div = document.createElement("div"); | |
| div.innerHTML = "<div class='test e'></div><div class='test'></div>", div.getElementsByClassName && 0 !== div.getElementsByClassName("e").length && (div.lastChild.className = "e", 1 !== div.getElementsByClassName("e").length && (Expr.order.splice(1, 0, "CLASS"), Expr.find.CLASS = function (match, context, isXML) { | |
| return "undefined" == typeof context.getElementsByClassName || isXML ? void 0 : context.getElementsByClassName(match[1]) | |
| }, div = null)) | |
| }(), Sizzle.contains = document.documentElement.contains ? function (a, b) { | |
| return a !== b && (a.contains ? a.contains(b) : !0) | |
| } : document.documentElement.compareDocumentPosition ? function (a, b) { | |
| return !!(16 & a.compareDocumentPosition(b)) | |
| } : function () { | |
| return !1 | |
| }, Sizzle.isXML = function (elem) { | |
| var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; | |
| return documentElement ? "HTML" !== documentElement.nodeName : !1 | |
| }; | |
| var posProcess = function (selector, context) { | |
| for (var match, tmpSet = [], later = "", root = context.nodeType ? [context] : context; match = Expr.match.PSEUDO.exec(selector);) later += match[0], selector = selector.replace(Expr.match.PSEUDO, ""); | |
| selector = Expr.relative[selector] ? selector + "*" : selector; | |
| for (var i = 0, l = root.length; l > i; i++) Sizzle(selector, root[i], tmpSet); | |
| return Sizzle.filter(later, tmpSet) | |
| }; | |
| window.Sizzle = Sizzle | |
| }(), Prototype._original_property = window.Sizzle, | |
| function (engine) { | |
| function select(selector, scope) { | |
| return extendElements(engine(selector, scope || document)) | |
| } | |
| function match(element, selector) { | |
| return 1 == engine.matches(selector, [element]).length | |
| } | |
| var extendElements = Prototype.Selector.extendElements; | |
| Prototype.Selector.engine = engine, Prototype.Selector.select = select, Prototype.Selector.match = match | |
| }(Sizzle), window.Sizzle = Prototype._original_property, delete Prototype._original_property; | |
| var Form = { | |
| reset: function (form) { | |
| return form = $(form), form.reset(), form | |
| }, | |
| serializeElements: function (elements, options) { | |
| "object" != typeof options ? options = { | |
| hash: !! options | |
| } : Object.isUndefined(options.hash) && (options.hash = !0); | |
| var key, value, accumulator, initial, submitted = !1, | |
| submit = options.submit; | |
| return options.hash ? (initial = {}, accumulator = function (result, key, value) { | |
| return key in result ? (Object.isArray(result[key]) || (result[key] = [result[key]]), result[key].push(value)) : result[key] = value, result | |
| }) : (initial = "", accumulator = function (result, key, value) { | |
| return value = value.gsub(/(\r)?\n/, "\r\n"), value = encodeURIComponent(value), value = value.gsub(/%20/, "+"), result + (result ? "&" : "") + encodeURIComponent(key) + "=" + value | |
| }), elements.inject(initial, function (result, element) { | |
| return !element.disabled && element.name && (key = element.name, value = $(element).getValue(), null == value || "file" == element.type || "submit" == element.type && (submitted || submit === !1 || submit && key != submit || !(submitted = !0)) || (result = accumulator(result, key, value))), result | |
| }) | |
| } | |
| }; | |
| Form.Methods = { | |
| serialize: function (form, options) { | |
| return Form.serializeElements(Form.getElements(form), options) | |
| }, | |
| getElements: function (form) { | |
| for (var element, elements = $(form).getElementsByTagName("*"), results = [], serializers = Form.Element.Serializers, i = 0; element = elements[i]; i++) serializers[element.tagName.toLowerCase()] && results.push(Element.extend(element)); | |
| return results | |
| }, | |
| getInputs: function (form, typeName, name) { | |
| form = $(form); | |
| var inputs = form.getElementsByTagName("input"); | |
| if (!typeName && !name) return $A(inputs).map(Element.extend); | |
| for (var i = 0, matchingInputs = [], length = inputs.length; length > i; i++) { | |
| var input = inputs[i]; | |
| typeName && input.type != typeName || name && input.name != name || matchingInputs.push(Element.extend(input)) | |
| } | |
| return matchingInputs | |
| }, | |
| disable: function (form) { | |
| return form = $(form), Form.getElements(form).invoke("disable"), form | |
| }, | |
| enable: function (form) { | |
| return form = $(form), Form.getElements(form).invoke("enable"), form | |
| }, | |
| findFirstElement: function (form) { | |
| var elements = $(form).getElements().findAll(function (element) { | |
| return "hidden" != element.type && !element.disabled | |
| }), | |
| firstByIndex = elements.findAll(function (element) { | |
| return element.hasAttribute("tabIndex") && element.tabIndex >= 0 | |
| }).sortBy(function (element) { | |
| return element.tabIndex | |
| }).first(); | |
| return firstByIndex ? firstByIndex : elements.find(function (element) { | |
| return /^(?:input|select|textarea)$/i.test(element.tagName) | |
| }) | |
| }, | |
| focusFirstElement: function (form) { | |
| form = $(form); | |
| var element = form.findFirstElement(); | |
| return element && element.activate(), form | |
| }, | |
| request: function (form, options) { | |
| form = $(form), options = Object.clone(options || {}); | |
| var params = options.parameters, | |
| action = form.readAttribute("action") || ""; | |
| return action.blank() && (action = window.location.href), options.parameters = form.serialize(!0), params && (Object.isString(params) && (params = params.toQueryParams()), Object.extend(options.parameters, params)), form.hasAttribute("method") && !options.method && (options.method = form.method), new Ajax.Request(action, options) | |
| } | |
| }, Form.Element = { | |
| focus: function (element) { | |
| return $(element).focus(), element | |
| }, | |
| select: function (element) { | |
| return $(element).select(), element | |
| } | |
| }, Form.Element.Methods = { | |
| serialize: function (element) { | |
| if (element = $(element), !element.disabled && element.name) { | |
| var value = element.getValue(); | |
| if (void 0 != value) { | |
| var pair = {}; | |
| return pair[element.name] = value, Object.toQueryString(pair) | |
| } | |
| } | |
| return "" | |
| }, | |
| getValue: function (element) { | |
| element = $(element); | |
| var method = element.tagName.toLowerCase(); | |
| return Form.Element.Serializers[method](element) | |
| }, | |
| setValue: function (element, value) { | |
| element = $(element); | |
| var method = element.tagName.toLowerCase(); | |
| return Form.Element.Serializers[method](element, value), element | |
| }, | |
| clear: function (element) { | |
| return $(element).value = "", element | |
| }, | |
| present: function (element) { | |
| return "" != $(element).value | |
| }, | |
| activate: function (element) { | |
| element = $(element); | |
| try { | |
| element.focus(), !element.select || "input" == element.tagName.toLowerCase() && /^(?:button|reset|submit)$/i.test(element.type) || element.select() | |
| } catch (e) {} | |
| return element | |
| }, | |
| disable: function (element) { | |
| return element = $(element), element.disabled = !0, element | |
| }, | |
| enable: function (element) { | |
| return element = $(element), element.disabled = !1, element | |
| } | |
| }; | |
| var Field = Form.Element, | |
| $F = Form.Element.Methods.getValue; | |
| Form.Element.Serializers = function () { | |
| function input(element, value) { | |
| switch (element.type.toLowerCase()) { | |
| case "checkbox": | |
| case "radio": | |
| return inputSelector(element, value); | |
| default: | |
| return valueSelector(element, value) | |
| } | |
| } | |
| function inputSelector(element, value) { | |
| return Object.isUndefined(value) ? element.checked ? element.value : null : (element.checked = !! value, void 0) | |
| } | |
| function valueSelector(element, value) { | |
| return Object.isUndefined(value) ? element.value : (element.value = value, void 0) | |
| } | |
| function select(element, value) { | |
| if (Object.isUndefined(value)) return ("select-one" === element.type ? selectOne : selectMany)(element); | |
| for (var opt, currentValue, single = !Object.isArray(value), i = 0, length = element.length; length > i; i++) | |
| if (opt = element.options[i], currentValue = this.optionValue(opt), single) { | |
| if (currentValue == value) return opt.selected = !0, void 0 | |
| } else opt.selected = value.include(currentValue) | |
| } | |
| function selectOne(element) { | |
| var index = element.selectedIndex; | |
| return index >= 0 ? optionValue(element.options[index]) : null | |
| } | |
| function selectMany(element) { | |
| var values, length = element.length; | |
| if (!length) return null; | |
| for (var i = 0, values = []; length > i; i++) { | |
| var opt = element.options[i]; | |
| opt.selected && values.push(optionValue(opt)) | |
| } | |
| return values | |
| } | |
| function optionValue(opt) { | |
| return Element.hasAttribute(opt, "value") ? opt.value : opt.text | |
| } | |
| return { | |
| input: input, | |
| inputSelector: inputSelector, | |
| textarea: valueSelector, | |
| select: select, | |
| selectOne: selectOne, | |
| selectMany: selectMany, | |
| optionValue: optionValue, | |
| button: valueSelector | |
| } | |
| }(), Abstract.TimedObserver = Class.create(PeriodicalExecuter, { | |
| initialize: function ($super, element, frequency, callback) { | |
| $super(callback, frequency), this.element = $(element), this.lastValue = this.getValue() | |
| }, | |
| execute: function () { | |
| var value = this.getValue(); | |
| (Object.isString(this.lastValue) && Object.isString(value) ? this.lastValue != value : String(this.lastValue) != String(value)) && (this.callback(this.element, value), this.lastValue = value) | |
| } | |
| }), Form.Element.Observer = Class.create(Abstract.TimedObserver, { | |
| getValue: function () { | |
| return Form.Element.getValue(this.element) | |
| } | |
| }), Form.Observer = Class.create(Abstract.TimedObserver, { | |
| getValue: function () { | |
| return Form.serialize(this.element) | |
| } | |
| }), Abstract.EventObserver = Class.create({ | |
| initialize: function (element, callback) { | |
| this.element = $(element), this.callback = callback, this.lastValue = this.getValue(), "form" == this.element.tagName.toLowerCase() ? this.registerFormCallbacks() : this.registerCallback(this.element) | |
| }, | |
| onElementEvent: function () { | |
| var value = this.getValue(); | |
| this.lastValue != value && (this.callback(this.element, value), this.lastValue = value) | |
| }, | |
| registerFormCallbacks: function () { | |
| Form.getElements(this.element).each(this.registerCallback, this) | |
| }, | |
| registerCallback: function (element) { | |
| if (element.type) switch (element.type.toLowerCase()) { | |
| case "checkbox": | |
| case "radio": | |
| Event.observe(element, "click", this.onElementEvent.bind(this)); | |
| break; | |
| default: | |
| Event.observe(element, "change", this.onElementEvent.bind(this)) | |
| } | |
| } | |
| }), Form.Element.EventObserver = Class.create(Abstract.EventObserver, { | |
| getValue: function () { | |
| return Form.Element.getValue(this.element) | |
| } | |
| }), Form.EventObserver = Class.create(Abstract.EventObserver, { | |
| getValue: function () { | |
| return Form.serialize(this.element) | |
| } | |
| }), | |
| function (GLOBAL) { | |
| function _isButtonForDOMEvents(event, code) { | |
| return event.which ? event.which === code + 1 : event.button === code | |
| } | |
| function _isButtonForLegacyEvents(event, code) { | |
| return event.button === legacyButtonMap[code] | |
| } | |
| function _isButtonForWebKit(event, code) { | |
| switch (code) { | |
| case 0: | |
| return 1 == event.which && !event.metaKey; | |
| case 1: | |
| return 2 == event.which || 1 == event.which && event.metaKey; | |
| case 2: | |
| return 3 == event.which; | |
| default: | |
| return !1 | |
| } | |
| } | |
| function isLeftClick(event) { | |
| return _isButton(event, 0) | |
| } | |
| function isMiddleClick(event) { | |
| return _isButton(event, 1) | |
| } | |
| function isRightClick(event) { | |
| return _isButton(event, 2) | |
| } | |
| function element(event) { | |
| return Element.extend(_element(event)) | |
| } | |
| function _element(event) { | |
| event = Event.extend(event); | |
| var node = event.target, | |
| type = event.type, | |
| currentTarget = event.currentTarget; | |
| return currentTarget && currentTarget.tagName && ("load" === type || "error" === type || "click" === type && "input" === currentTarget.tagName.toLowerCase() && "radio" === currentTarget.type) && (node = currentTarget), node.nodeType == Node.TEXT_NODE && (node = node.parentNode), Element.extend(node) | |
| } | |
| function findElement(event, expression) { | |
| var element = _element(event), | |
| match = Prototype.Selector.match; | |
| if (!expression) return Element.extend(element); | |
| for (; element;) { | |
| if (Object.isElement(element) && match(element, expression)) return Element.extend(element); | |
| element = element.parentNode | |
| } | |
| } | |
| function pointer(event) { | |
| return { | |
| x: pointerX(event), | |
| y: pointerY(event) | |
| } | |
| } | |
| function pointerX(event) { | |
| var docElement = document.documentElement, | |
| body = document.body || { | |
| scrollLeft: 0 | |
| }; | |
| return event.pageX || event.clientX + (docElement.scrollLeft || body.scrollLeft) - (docElement.clientLeft || 0) | |
| } | |
| function pointerY(event) { | |
| var docElement = document.documentElement, | |
| body = document.body || { | |
| scrollTop: 0 | |
| }; | |
| return event.pageY || event.clientY + (docElement.scrollTop || body.scrollTop) - (docElement.clientTop || 0) | |
| } | |
| function stop(event) { | |
| Event.extend(event), event.preventDefault(), event.stopPropagation(), event.stopped = !0 | |
| } | |
| function _relatedTarget(event) { | |
| var element; | |
| switch (event.type) { | |
| case "mouseover": | |
| case "mouseenter": | |
| element = event.fromElement; | |
| break; | |
| case "mouseout": | |
| case "mouseleave": | |
| element = event.toElement; | |
| break; | |
| default: | |
| return null | |
| } | |
| return Element.extend(element) | |
| } | |
| function getDOMEventName(eventName) { | |
| return EVENT_TRANSLATIONS[eventName] || eventName | |
| } | |
| function getUniqueElementID(element) { | |
| return element === window ? 0 : ("undefined" == typeof element._prototypeUID && (element._prototypeUID = Element.Storage.UID++), element._prototypeUID) | |
| } | |
| function getUniqueElementID_IE(element) { | |
| return element === window ? 0 : element == document ? 1 : element.uniqueID | |
| } | |
| function isCustomEvent(eventName) { | |
| return eventName.include(":") | |
| } | |
| function getRegistryForElement(element, uid) { | |
| var CACHE = GLOBAL.Event.cache; | |
| return Object.isUndefined(uid) && (uid = getUniqueElementID(element)), CACHE[uid] || (CACHE[uid] = { | |
| element: element | |
| }), CACHE[uid] | |
| } | |
| function destroyRegistryForElement(element, uid) { | |
| Object.isUndefined(uid) && (uid = getUniqueElementID(element)), delete GLOBAL.Event.cache[uid] | |
| } | |
| function register(element, eventName, handler) { | |
| var registry = getRegistryForElement(element); | |
| registry[eventName] || (registry[eventName] = []); | |
| for (var entries = registry[eventName], i = entries.length; i--;) | |
| if (entries[i].handler === handler) return null; | |
| var uid = getUniqueElementID(element), | |
| responder = GLOBAL.Event._createResponder(uid, eventName, handler), | |
| entry = { | |
| responder: responder, | |
| handler: handler | |
| }; | |
| return entries.push(entry), entry | |
| } | |
| function unregister(element, eventName, handler) { | |
| var registry = getRegistryForElement(element), | |
| entries = registry[eventName]; | |
| if (entries) { | |
| for (var entry, i = entries.length; i--;) | |
| if (entries[i].handler === handler) { | |
| entry = entries[i]; | |
| break | |
| } | |
| if (entry) { | |
| var index = entries.indexOf(entry); | |
| return entries.splice(index, 1), entry | |
| } | |
| } | |
| } | |
| function observe(element, eventName, handler) { | |
| element = $(element); | |
| var entry = register(element, eventName, handler); | |
| if (null === entry) return element; | |
| var responder = entry.responder; | |
| return isCustomEvent(eventName) ? observeCustomEvent(element, eventName, responder) : observeStandardEvent(element, eventName, responder), element | |
| } | |
| function observeStandardEvent(element, eventName, responder) { | |
| var actualEventName = getDOMEventName(eventName); | |
| element.addEventListener ? element.addEventListener(actualEventName, responder, !1) : element.attachEvent("on" + actualEventName, responder) | |
| } | |
| function observeCustomEvent(element, eventName, responder) { | |
| element.addEventListener ? element.addEventListener("dataavailable", responder, !1) : (element.attachEvent("ondataavailable", responder), element.attachEvent("onlosecapture", responder)) | |
| } | |
| function stopObserving(element, eventName, handler) { | |
| element = $(element); | |
| var handlerGiven = !Object.isUndefined(handler), | |
| eventNameGiven = !Object.isUndefined(eventName); | |
| if (!eventNameGiven && !handlerGiven) return stopObservingElement(element), element; | |
| if (!handlerGiven) return stopObservingEventName(element, eventName), element; | |
| var entry = unregister(element, eventName, handler); | |
| return entry ? (removeEvent(element, eventName, entry.responder), element) : element | |
| } | |
| function stopObservingStandardEvent(element, eventName, responder) { | |
| var actualEventName = getDOMEventName(eventName); | |
| element.removeEventListener ? element.removeEventListener(actualEventName, responder, !1) : element.detachEvent("on" + actualEventName, responder) | |
| } | |
| function stopObservingCustomEvent(element, eventName, responder) { | |
| element.removeEventListener ? element.removeEventListener("dataavailable", responder, !1) : (element.detachEvent("ondataavailable", responder), element.detachEvent("onlosecapture", responder)) | |
| } | |
| function stopObservingElement(element) { | |
| var uid = getUniqueElementID(element), | |
| registry = getRegistryForElement(element, uid); | |
| destroyRegistryForElement(element, uid); | |
| var entries, i; | |
| for (var eventName in registry) | |
| if ("element" !== eventName) | |
| for (entries = registry[eventName], i = entries.length; i--;) removeEvent(element, eventName, entries[i].responder) | |
| } | |
| function stopObservingEventName(element, eventName) { | |
| var registry = getRegistryForElement(element), | |
| entries = registry[eventName]; | |
| if (entries) { | |
| delete registry[eventName]; | |
| for (var i = entries.length; i--;) removeEvent(element, eventName, entries[i].responder) | |
| } | |
| } | |
| function removeEvent(element, eventName, handler) { | |
| isCustomEvent(eventName) ? stopObservingCustomEvent(element, eventName, handler) : stopObservingStandardEvent(element, eventName, handler) | |
| } | |
| function getFireTarget(element) { | |
| return element !== document ? element : document.createEvent && !element.dispatchEvent ? document.documentElement : element | |
| } | |
| function fire(element, eventName, memo, bubble) { | |
| element = getFireTarget($(element)), Object.isUndefined(bubble) && (bubble = !0), memo = memo || {}; | |
| var event = fireEvent(element, eventName, memo, bubble); | |
| return Event.extend(event) | |
| } | |
| function fireEvent_DOM(element, eventName, memo, bubble) { | |
| var event = document.createEvent("HTMLEvents"); | |
| return event.initEvent("dataavailable", bubble, !0), event.eventName = eventName, event.memo = memo, element.dispatchEvent(event), event | |
| } | |
| function fireEvent_IE(element, eventName, memo, bubble) { | |
| var event = document.createEventObject(); | |
| return event.eventType = bubble ? "ondataavailable" : "onlosecapture", event.eventName = eventName, event.memo = memo, element.fireEvent(event.eventType, event), event | |
| } | |
| function on(element, eventName, selector, callback) { | |
| return element = $(element), Object.isFunction(selector) && Object.isUndefined(callback) && (callback = selector, selector = null), new Event.Handler(element, eventName, selector, callback).start() | |
| } | |
| function destroyCache_IE() { | |
| GLOBAL.Event.cache = null | |
| } | |
| var DIV = document.createElement("div"), | |
| docEl = document.documentElement, | |
| MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = "onmouseenter" in docEl && "onmouseleave" in docEl, | |
| Event = { | |
| KEY_BACKSPACE: 8, | |
| KEY_TAB: 9, | |
| KEY_RETURN: 13, | |
| KEY_ESC: 27, | |
| KEY_LEFT: 37, | |
| KEY_UP: 38, | |
| KEY_RIGHT: 39, | |
| KEY_DOWN: 40, | |
| KEY_DELETE: 46, | |
| KEY_HOME: 36, | |
| KEY_END: 35, | |
| KEY_PAGEUP: 33, | |
| KEY_PAGEDOWN: 34, | |
| KEY_INSERT: 45 | |
| }, isIELegacyEvent = function () { | |
| return !1 | |
| }; | |
| window.attachEvent && (isIELegacyEvent = window.addEventListener ? function (event) { | |
| return !(event instanceof window.Event) | |
| } : function () { | |
| return !0 | |
| }); | |
| var _isButton, legacyButtonMap = { | |
| 0: 1, | |
| 1: 4, | |
| 2: 2 | |
| }; | |
| _isButton = window.attachEvent ? window.addEventListener ? function (event, code) { | |
| return isIELegacyEvent(event) ? _isButtonForLegacyEvents(event, code) : _isButtonForDOMEvents(event, code) | |
| } : _isButtonForLegacyEvents : Prototype.Browser.WebKit ? _isButtonForWebKit : _isButtonForDOMEvents, Event.Methods = { | |
| isLeftClick: isLeftClick, | |
| isMiddleClick: isMiddleClick, | |
| isRightClick: isRightClick, | |
| element: element, | |
| findElement: findElement, | |
| pointer: pointer, | |
| pointerX: pointerX, | |
| pointerY: pointerY, | |
| stop: stop | |
| }; | |
| var methods = Object.keys(Event.Methods).inject({}, function (m, name) { | |
| return m[name] = Event.Methods[name].methodize(), m | |
| }); | |
| if (window.attachEvent) { | |
| var additionalMethods = { | |
| stopPropagation: function () { | |
| this.cancelBubble = !0 | |
| }, | |
| preventDefault: function () { | |
| this.returnValue = !1 | |
| }, | |
| inspect: function () { | |
| return "[object Event]" | |
| } | |
| }; | |
| Event.extend = function (event, element) { | |
| if (!event) return !1; | |
| if (!isIELegacyEvent(event)) return event; | |
| if (event._extendedByPrototype) return event; | |
| event._extendedByPrototype = Prototype.emptyFunction; | |
| var pointer = Event.pointer(event); | |
| return Object.extend(event, { | |
| target: event.srcElement || element, | |
| relatedTarget: _relatedTarget(event), | |
| pageX: pointer.x, | |
| pageY: pointer.y | |
| }), Object.extend(event, methods), Object.extend(event, additionalMethods), event | |
| } | |
| } else Event.extend = Prototype.K; | |
| window.addEventListener && (Event.prototype = window.Event.prototype || document.createEvent("HTMLEvents").__proto__, Object.extend(Event.prototype, methods)); | |
| var EVENT_TRANSLATIONS = { | |
| mouseenter: "mouseover", | |
| mouseleave: "mouseout" | |
| }; | |
| MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED && (getDOMEventName = Prototype.K), "uniqueID" in DIV && (getUniqueElementID = getUniqueElementID_IE), Event._isCustomEvent = isCustomEvent; | |
| var fireEvent = document.createEvent ? fireEvent_DOM : fireEvent_IE; | |
| Event.Handler = Class.create({ | |
| initialize: function (element, eventName, selector, callback) { | |
| this.element = $(element), this.eventName = eventName, this.selector = selector, this.callback = callback, this.handler = this.handleEvent.bind(this) | |
| }, | |
| start: function () { | |
| return Event.observe(this.element, this.eventName, this.handler), this | |
| }, | |
| stop: function () { | |
| return Event.stopObserving(this.element, this.eventName, this.handler), this | |
| }, | |
| handleEvent: function (event) { | |
| var element = Event.findElement(event, this.selector); | |
| element && this.callback.call(this.element, event, element) | |
| } | |
| }), Object.extend(Event, Event.Methods), Object.extend(Event, { | |
| fire: fire, | |
| observe: observe, | |
| stopObserving: stopObserving, | |
| on: on | |
| }), Element.addMethods({ | |
| fire: fire, | |
| observe: observe, | |
| stopObserving: stopObserving, | |
| on: on | |
| }), Object.extend(document, { | |
| fire: fire.methodize(), | |
| observe: observe.methodize(), | |
| stopObserving: stopObserving.methodize(), | |
| on: on.methodize(), | |
| loaded: !1 | |
| }), GLOBAL.Event ? Object.extend(window.Event, Event) : GLOBAL.Event = Event, GLOBAL.Event.cache = {}, window.attachEvent && window.attachEvent("onunload", destroyCache_IE), DIV = null, docEl = null | |
| }(this), | |
| function (GLOBAL) { | |
| function isSimulatedMouseEnterLeaveEvent(eventName) { | |
| return !MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED && ("mouseenter" === eventName || "mouseleave" === eventName) | |
| } | |
| /* function createResponder(uid, eventName, handler) { | |
| return Event._isCustomEvent(eventName) ? createResponderForCustomEvent(uid, eventName, handler) : isSimulatedMouseEnterLeaveEvent(eventName) ? createMouseEnterLeaveResponder(uid, eventName, handler) : function (event) { | |
| var cacheEntry = Event.cache[uid], | |
| element = cacheEntry.element; | |
| Event.extend(event, element), handler.call(element, event) | |
| } | |
| } | |
| function createResponderForCustomEvent(uid, eventName, handler) { | |
| return function (event) { | |
| var cacheEntry = Event.cache[uid], | |
| element = cacheEntry.element; | |
| return Object.isUndefined(event.eventName) ? !1 : event.eventName !== eventName ? !1 : (Event.extend(event, element), handler.call(element, event), void 0) | |
| } | |
| } | |
| function createMouseEnterLeaveResponder(uid, eventName, handler) { | |
| return function (event) { | |
| var cacheEntry = Event.cache[uid], | |
| element = cacheEntry.element; | |
| Event.extend(event, element); | |
| for (var parent = event.relatedTarget; parent && parent !== element;) try { | |
| parent = parent.parentNode | |
| } catch (e) { | |
| parent = element | |
| } | |
| parent !== element && handler.call(element, event) | |
| } | |
| } | |
| */ | |
| var docEl = document.documentElement, | |
| MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = "onmouseenter" in docEl && "onmouseleave" in docEl; | |
| GLOBAL.Event._createResponder = createResponder, docEl = null | |
| }(this), | |
| function () { | |
| function fireContentLoadedEvent() { | |
| document.loaded || (TIMER && window.clearTimeout(TIMER), document.loaded = !0, document.fire("dom:loaded")) | |
| } | |
| function checkReadyState() { | |
| "complete" === document.readyState && (document.detachEvent("onreadystatechange", checkReadyState), fireContentLoadedEvent()) | |
| } | |
| function pollDoScroll() { | |
| try { | |
| document.documentElement.doScroll("left") | |
| } catch (e) { | |
| return TIMER = pollDoScroll.defer(), void 0 | |
| } | |
| fireContentLoadedEvent() | |
| } | |
| var TIMER; | |
| document.addEventListener ? document.addEventListener("DOMContentLoaded", fireContentLoadedEvent, !1) : (document.attachEvent("onreadystatechange", checkReadyState), window == top && (TIMER = pollDoScroll.defer())), Event.observe(window, "load", fireContentLoadedEvent) | |
| }(this), Element.addMethods(), Hash.toQueryString = Object.toQueryString; | |
| var Toggle = { | |
| display: Element.toggle | |
| }; | |
| Element.Methods.childOf = Element.Methods.descendantOf; | |
| var Insertion = { | |
| Before: function (element, content) { | |
| return Element.insert(element, { | |
| before: content | |
| }) | |
| }, | |
| Top: function (element, content) { | |
| return Element.insert(element, { | |
| top: content | |
| }) | |
| }, | |
| Bottom: function (element, content) { | |
| return Element.insert(element, { | |
| bottom: content | |
| }) | |
| }, | |
| After: function (element, content) { | |
| return Element.insert(element, { | |
| after: content | |
| }) | |
| } | |
| }, $continue = new Error('"throw $continue" is deprecated, use "return" instead'), | |
| Position = { | |
| includeScrollOffsets: !1, | |
| prepare: function () { | |
| this.deltaX = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0, this.deltaY = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0 | |
| }, | |
| within: function (element, x, y) { | |
| return this.includeScrollOffsets ? this.withinIncludingScrolloffsets(element, x, y) : (this.xcomp = x, this.ycomp = y, this.offset = Element.cumulativeOffset(element), y >= this.offset[1] && y < this.offset[1] + element.offsetHeight && x >= this.offset[0] && x < this.offset[0] + element.offsetWidth) | |
| }, | |
| withinIncludingScrolloffsets: function (element, x, y) { | |
| var offsetcache = Element.cumulativeScrollOffset(element); | |
| return this.xcomp = x + offsetcache[0] - this.deltaX, this.ycomp = y + offsetcache[1] - this.deltaY, this.offset = Element.cumulativeOffset(element), this.ycomp >= this.offset[1] && this.ycomp < this.offset[1] + element.offsetHeight && this.xcomp >= this.offset[0] && this.xcomp < this.offset[0] + element.offsetWidth | |
| }, | |
| overlap: function (mode, element) { | |
| return mode ? "vertical" == mode ? (this.offset[1] + element.offsetHeight - this.ycomp) / element.offsetHeight : "horizontal" == mode ? (this.offset[0] + element.offsetWidth - this.xcomp) / element.offsetWidth : void 0 : 0 | |
| }, | |
| cumulativeOffset: Element.Methods.cumulativeOffset, | |
| positionedOffset: Element.Methods.positionedOffset, | |
| absolutize: function (element) { | |
| return Position.prepare(), Element.absolutize(element) | |
| }, | |
| relativize: function (element) { | |
| return Position.prepare(), Element.relativize(element) | |
| }, | |
| realOffset: Element.Methods.cumulativeScrollOffset, | |
| offsetParent: Element.Methods.getOffsetParent, | |
| page: Element.Methods.viewportOffset, | |
| clone: function (source, target, options) { | |
| return options = options || {}, Element.clonePosition(target, source, options) | |
| } | |
| }; | |
| document.getElementsByClassName || (document.getElementsByClassName = function (instanceMethods) { | |
| function iter(name) { | |
| return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]" | |
| } | |
| return instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ? function (element, className) { | |
| className = className.toString().strip(); | |
| var cond = /\s/.test(className) ? $w(className).map(iter).join("") : iter(className); | |
| return cond ? document._getElementsByXPath(".//*" + cond, element) : [] | |
| } : function (element, className) { | |
| className = className.toString().strip(); | |
| var elements = [], | |
| classNames = /\s/.test(className) ? $w(className) : null; | |
| if (!classNames && !className) return elements; | |
| var nodes = $(element).getElementsByTagName("*"); | |
| className = " " + className + " "; | |
| for (var child, cn, i = 0; child = nodes[i]; i++) child.className && (cn = " " + child.className + " ") && (cn.include(className) || classNames && classNames.all(function (name) { | |
| return !name.toString().blank() && cn.include(" " + name + " ") | |
| })) && elements.push(Element.extend(child)); | |
| return elements | |
| }, | |
| function (className, parentElement) { | |
| return $(parentElement || document.body).getElementsByClassName(className) | |
| } | |
| }(Element.Methods)), Element.ClassNames = Class.create(), Element.ClassNames.prototype = { | |
| initialize: function (element) { | |
| this.element = $(element) | |
| }, | |
| _each: function (iterator, context) { | |
| this.element.className.split(/\s+/).select(function (name) { | |
| return name.length > 0 | |
| })._each(iterator, context) | |
| }, | |
| set: function (className) { | |
| this.element.className = className | |
| }, | |
| add: function (classNameToAdd) { | |
| this.include(classNameToAdd) || this.set($A(this).concat(classNameToAdd).join(" ")) | |
| }, | |
| remove: function (classNameToRemove) { | |
| this.include(classNameToRemove) && this.set($A(this).without(classNameToRemove).join(" ")) | |
| }, | |
| toString: function () { | |
| return $A(this).join(" ") | |
| } | |
| }, Object.extend(Element.ClassNames.prototype, Enumerable), | |
| function () { | |
| window.Selector = Class.create({ | |
| initialize: function (expression) { | |
| this.expression = expression.strip() | |
| }, | |
| findElements: function (rootElement) { | |
| return Prototype.Selector.select(this.expression, rootElement) | |
| }, | |
| match: function (element) { | |
| return Prototype.Selector.match(element, this.expression) | |
| }, | |
| toString: function () { | |
| return this.expression | |
| }, | |
| inspect: function () { | |
| return "#<Selector: " + this.expression + ">" | |
| } | |
| }), Object.extend(Selector, { | |
| matchElements: function (elements, expression) { | |
| for (var match = Prototype.Selector.match, results = [], i = 0, length = elements.length; length > i; i++) { | |
| var element = elements[i]; | |
| match(element, expression) && results.push(Element.extend(element)) | |
| } | |
| return results | |
| }, | |
| findElement: function (elements, expression, index) { | |
| index = index || 0; | |
| for (var element, matchIndex = 0, i = 0, length = elements.length; length > i; i++) | |
| if (element = elements[i], Prototype.Selector.match(element, expression) && index === matchIndex++) return Element.extend(element) | |
| }, | |
| findChildElements: function (element, expressions) { | |
| var selector = expressions.toArray().join(", "); | |
| return Prototype.Selector.select(selector, element || document) | |
| } | |
| }) | |
| }(), String.prototype.parseColor = function () { | |
| var color = "#"; | |
| if ("rgb(" == this.slice(0, 4)) { | |
| var cols = this.slice(4, this.length - 1).split(","), | |
| i = 0; | |
| do color += parseInt(cols[i]).toColorPart(); while (++i < 3) | |
| } else if ("#" == this.slice(0, 1)) { | |
| if (4 == this.length) | |
| for (var i = 1; 4 > i; i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); | |
| 7 == this.length && (color = this.toLowerCase()) | |
| } | |
| return 7 == color.length ? color : arguments[0] || this | |
| }, Element.collectTextNodes = function (element) { | |
| return $A($(element).childNodes).collect(function (node) { | |
| return 3 == node.nodeType ? node.nodeValue : node.hasChildNodes() ? Element.collectTextNodes(node) : "" | |
| }).flatten().join("") | |
| }, Element.collectTextNodesIgnoreClass = function (element, className) { | |
| return $A($(element).childNodes).collect(function (node) { | |
| return 3 == node.nodeType ? node.nodeValue : node.hasChildNodes() && !Element.hasClassName(node, className) ? Element.collectTextNodesIgnoreClass(node, className) : "" | |
| }).flatten().join("") | |
| }, Element.setContentZoom = function (element, percent) { | |
| return element = $(element), element.setStyle({ | |
| fontSize: percent / 100 + "em" | |
| }), Prototype.Browser.WebKit && window.scrollBy(0, 0), element | |
| }, Element.getInlineOpacity = function (element) { | |
| return $(element).style.opacity || "" | |
| }, Element.forceRerendering = function (element) { | |
| try { | |
| element = $(element); | |
| var n = document.createTextNode(" "); | |
| element.appendChild(n), element.removeChild(n) | |
| } catch (e) {} | |
| }; | |
| var Effect = { | |
| _elementDoesNotExistError: { | |
| name: "ElementDoesNotExistError", | |
| message: "The specified DOM element does not exist, but is required for this effect to operate" | |
| }, | |
| Transitions: { | |
| linear: Prototype.K, | |
| sinoidal: function (pos) { | |
| return -Math.cos(pos * Math.PI) / 2 + .5 | |
| }, | |
| reverse: function (pos) { | |
| return 1 - pos | |
| }, | |
| flicker: function (pos) { | |
| var pos = -Math.cos(pos * Math.PI) / 4 + .75 + Math.random() / 4; | |
| return pos > 1 ? 1 : pos | |
| }, | |
| wobble: function (pos) { | |
| return -Math.cos(pos * Math.PI * 9 * pos) / 2 + .5 | |
| }, | |
| pulse: function (pos, pulses) { | |
| return -Math.cos(2 * pos * ((pulses || 5) - .5) * Math.PI) / 2 + .5 | |
| }, | |
| spring: function (pos) { | |
| return 1 - Math.cos(4.5 * pos * Math.PI) * Math.exp(6 * -pos) | |
| }, | |
| none: function () { | |
| return 0 | |
| }, | |
| full: function () { | |
| return 1 | |
| } | |
| }, | |
| DefaultOptions: { | |
| duration: 1, | |
| fps: 100, | |
| sync: !1, | |
| from: 0, | |
| to: 1, | |
| delay: 0, | |
| queue: "parallel" | |
| }, | |
| tagifyText: function (element) { | |
| var tagifyStyle = "position:relative"; | |
| Prototype.Browser.IE && (tagifyStyle += ";zoom:1"), element = $(element), $A(element.childNodes).each(function (child) { | |
| 3 == child.nodeType && (child.nodeValue.toArray().each(function (character) { | |
| element.insertBefore(new Element("span", { | |
| style: tagifyStyle | |
| }).update(" " == character ? String.fromCharCode(160) : character), child) | |
| }), Element.remove(child)) | |
| }) | |
| }, | |
| multiple: function (element, effect) { | |
| var elements; | |
| elements = ("object" == typeof element || Object.isFunction(element)) && element.length ? element : $(element).childNodes; | |
| var options = Object.extend({ | |
| speed: .1, | |
| delay: 0 | |
| }, arguments[2] || {}), | |
| masterDelay = options.delay; | |
| $A(elements).each(function (element, index) { | |
| new effect(element, Object.extend(options, { | |
| delay: index * options.speed + masterDelay | |
| })) | |
| }) | |
| }, | |
| PAIRS: { | |
| slide: ["SlideDown", "SlideUp"], | |
| blind: ["BlindDown", "BlindUp"], | |
| appear: ["Appear", "Fade"] | |
| }, | |
| toggle: function (element, effect, options) { | |
| return element = $(element), effect = (effect || "appear").toLowerCase(), Effect[Effect.PAIRS[effect][element.visible() ? 1 : 0]](element, Object.extend({ | |
| queue: { | |
| position: "end", | |
| scope: element.id || "global", | |
| limit: 1 | |
| } | |
| }, options || {})) | |
| } | |
| }; | |
| if (Effect.DefaultOptions.transition = Effect.Transitions.sinoidal, Effect.ScopedQueue = Class.create(Enumerable, { | |
| initialize: function () { | |
| this.effects = [], this.interval = null | |
| }, | |
| _each: function (iterator) { | |
| this.effects._each(iterator) | |
| }, | |
| add: function (effect) { | |
| var timestamp = (new Date).getTime(), | |
| position = Object.isString(effect.options.queue) ? effect.options.queue : effect.options.queue.position; | |
| switch (position) { | |
| case "front": | |
| this.effects.findAll(function (e) { | |
| return "idle" == e.state | |
| }).each(function (e) { | |
| e.startOn += effect.finishOn, e.finishOn += effect.finishOn | |
| }); | |
| break; | |
| case "with-last": | |
| timestamp = this.effects.pluck("startOn").max() || timestamp; | |
| break; | |
| case "end": | |
| timestamp = this.effects.pluck("finishOn").max() || timestamp | |
| } | |
| effect.startOn += timestamp, effect.finishOn += timestamp, (!effect.options.queue.limit || this.effects.length < effect.options.queue.limit) && this.effects.push(effect), this.interval || (this.interval = setInterval(this.loop.bind(this), 15)) | |
| }, | |
| remove: function (effect) { | |
| this.effects = this.effects.reject(function (e) { | |
| return e == effect | |
| }), 0 == this.effects.length && (clearInterval(this.interval), this.interval = null) | |
| }, | |
| loop: function () { | |
| for (var timePos = (new Date).getTime(), i = 0, len = this.effects.length; len > i; i++) this.effects[i] && this.effects[i].loop(timePos) | |
| } | |
| }), Effect.Queues = { | |
| instances: $H(), | |
| get: function (queueName) { | |
| return Object.isString(queueName) ? this.instances.get(queueName) || this.instances.set(queueName, new Effect.ScopedQueue) : queueName | |
| } | |
| }, Effect.Queue = Effect.Queues.get("global"), Effect.Base = Class.create({ | |
| position: null, | |
| start: function (options) { | |
| options && options.transition === !1 && (options.transition = Effect.Transitions.linear), this.options = Object.extend(Object.extend({}, Effect.DefaultOptions), options || {}), this.currentFrame = 0, this.state = "idle", this.startOn = 1e3 * this.options.delay, this.finishOn = this.startOn + 1e3 * this.options.duration, this.fromToDelta = this.options.to - this.options.from, this.totalTime = this.finishOn - this.startOn, this.totalFrames = this.options.fps * this.options.duration, this.render = function () { | |
| function dispatch(effect, eventName) { | |
| effect.options[eventName + "Internal"] && effect.options[eventName + "Internal"](effect), effect.options[eventName] && effect.options[eventName](effect) | |
| } | |
| return function (pos) { | |
| "idle" === this.state && (this.state = "running", dispatch(this, "beforeSetup"), this.setup && this.setup(), dispatch(this, "afterSetup")), "running" === this.state && (pos = this.options.transition(pos) * this.fromToDelta + this.options.from, this.position = pos, dispatch(this, "beforeUpdate"), this.update && this.update(pos), dispatch(this, "afterUpdate")) | |
| } | |
| }(), this.event("beforeStart"), this.options.sync || Effect.Queues.get(Object.isString(this.options.queue) ? "global" : this.options.queue.scope).add(this) | |
| }, | |
| loop: function (timePos) { | |
| if (timePos >= this.startOn) { | |
| if (timePos >= this.finishOn) return this.render(1), this.cancel(), this.event("beforeFinish"), this.finish && this.finish(), this.event("afterFinish"), void 0; | |
| var pos = (timePos - this.startOn) / this.totalTime, | |
| frame = (pos * this.totalFrames).round(); | |
| frame > this.currentFrame && (this.render(pos), this.currentFrame = frame) | |
| } | |
| }, | |
| cancel: function () { | |
| this.options.sync || Effect.Queues.get(Object.isString(this.options.queue) ? "global" : this.options.queue.scope).remove(this), this.state = "finished" | |
| }, | |
| event: function (eventName) { | |
| this.options[eventName + "Internal"] && this.options[eventName + "Internal"](this), this.options[eventName] && this.options[eventName](this) | |
| }, | |
| inspect: function () { | |
| var data = $H(); | |
| for (property in this) Object.isFunction(this[property]) || data.set(property, this[property]); | |
| return "#<Effect:" + data.inspect() + ",options:" + $H(this.options).inspect() + ">" | |
| } | |
| }), Effect.Parallel = Class.create(Effect.Base, { | |
| initialize: function (effects) { | |
| this.effects = effects || [], this.start(arguments[1]) | |
| }, | |
| update: function (position) { | |
| this.effects.invoke("render", position) | |
| }, | |
| finish: function (position) { | |
| this.effects.each(function (effect) { | |
| effect.render(1), effect.cancel(), effect.event("beforeFinish"), effect.finish && effect.finish(position), effect.event("afterFinish") | |
| }) | |
| } | |
| }), Effect.Tween = Class.create(Effect.Base, { | |
| initialize: function (object, from, to) { | |
| object = Object.isString(object) ? $(object) : object; | |
| var args = $A(arguments), | |
| method = args.last(), | |
| options = 5 == args.length ? args[3] : null; | |
| this.method = Object.isFunction(method) ? method.bind(object) : Object.isFunction(object[method]) ? object[method].bind(object) : function (value) { | |
| object[method] = value | |
| }, this.start(Object.extend({ | |
| from: from, | |
| to: to | |
| }, options || {})) | |
| }, | |
| update: function (position) { | |
| this.method(position) | |
| } | |
| }), Effect.Event = Class.create(Effect.Base, { | |
| initialize: function () { | |
| this.start(Object.extend({ | |
| duration: 0 | |
| }, arguments[0] || {})) | |
| }, | |
| update: Prototype.emptyFunction | |
| }), Effect.Opacity = Class.create(Effect.Base, { | |
| initialize: function (element) { | |
| if (this.element = $(element), !this.element) throw Effect._elementDoesNotExistError; | |
| Prototype.Browser.IE && !this.element.currentStyle.hasLayout && this.element.setStyle({ | |
| zoom: 1 | |
| }); | |
| var options = Object.extend({ | |
| from: this.element.getOpacity() || 0, | |
| to: 1 | |
| }, arguments[1] || {}); | |
| this.start(options) | |
| }, | |
| update: function (position) { | |
| this.element.setOpacity(position) | |
| } | |
| }), Effect.Move = Class.create(Effect.Base, { | |
| initialize: function (element) { | |
| if (this.element = $(element), !this.element) throw Effect._elementDoesNotExistError; | |
| var options = Object.extend({ | |
| x: 0, | |
| y: 0, | |
| mode: "relative" | |
| }, arguments[1] || {}); | |
| this.start(options) | |
| }, | |
| setup: function () { | |
| this.element.makePositioned(), this.originalLeft = parseFloat(this.element.getStyle("left") || "0"), this.originalTop = parseFloat(this.element.getStyle("top") || "0"), "absolute" == this.options.mode && (this.options.x = this.options.x - this.originalLeft, this.options.y = this.options.y - this.originalTop) | |
| }, | |
| update: function (position) { | |
| this.element.setStyle({ | |
| left: (this.options.x * position + this.originalLeft).round() + "px", | |
| top: (this.options.y * position + this.originalTop).round() + "px" | |
| }) | |
| } | |
| }), Effect.MoveBy = function (element, toTop, toLeft) { | |
| return new Effect.Move(element, Object.extend({ | |
| x: toLeft, | |
| y: toTop | |
| }, arguments[3] || {})) | |
| }, Effect.Scale = Class.create(Effect.Base, { | |
| initialize: function (element, percent) { | |
| if (this.element = $(element), !this.element) throw Effect._elementDoesNotExistError; | |
| var options = Object.extend({ | |
| scaleX: !0, | |
| scaleY: !0, | |
| scaleContent: !0, | |
| scaleFromCenter: !1, | |
| scaleMode: "box", | |
| scaleFrom: 100, | |
| scaleTo: percent | |
| }, arguments[2] || {}); | |
| this.start(options) | |
| }, | |
| setup: function () { | |
| this.restoreAfterFinish = this.options.restoreAfterFinish || !1, this.elementPositioning = this.element.getStyle("position"), this.originalStyle = {}, ["top", "left", "width", "height", "fontSize"].each(function (k) { | |
| this.originalStyle[k] = this.element.style[k] | |
| }.bind(this)), this.originalTop = this.element.offsetTop, this.originalLeft = this.element.offsetLeft; | |
| var fontSize = this.element.getStyle("font-size") || "100%"; | |
| ["em", "px", "%", "pt"].each(function (fontSizeType) { | |
| fontSize.indexOf(fontSizeType) > 0 && (this.fontSize = parseFloat(fontSize), this.fontSizeType = fontSizeType) | |
| }.bind(this)), this.factor = (this.options.scaleTo - this.options.scaleFrom) / 100, this.dims = null, "box" == this.options.scaleMode && (this.dims = [this.element.offsetHeight, this.element.offsetWidth]), /^content/.test(this.options.scaleMode) && (this.dims = [this.element.scrollHeight, this.element.scrollWidth]), this.dims || (this.dims = [this.options.scaleMode.originalHeight, this.options.scaleMode.originalWidth]) | |
| }, | |
| update: function (position) { | |
| var currentScale = this.options.scaleFrom / 100 + this.factor * position; | |
| this.options.scaleContent && this.fontSize && this.element.setStyle({ | |
| fontSize: this.fontSize * currentScale + this.fontSizeType | |
| }), this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale) | |
| }, | |
| finish: function () { | |
| this.restoreAfterFinish && this.element.setStyle(this.originalStyle) | |
| }, | |
| setDimensions: function (height, width) { | |
| var d = {}; | |
| if (this.options.scaleX && (d.width = width.round() + "px"), this.options.scaleY && (d.height = height.round() + "px"), this.options.scaleFromCenter) { | |
| var topd = (height - this.dims[0]) / 2, | |
| leftd = (width - this.dims[1]) / 2; | |
| "absolute" == this.elementPositioning ? (this.options.scaleY && (d.top = this.originalTop - topd + "px"), this.options.scaleX && (d.left = this.originalLeft - leftd + "px")) : (this.options.scaleY && (d.top = -topd + "px"), this.options.scaleX && (d.left = -leftd + "px")) | |
| } | |
| this.element.setStyle(d) | |
| } | |
| }), Effect.Highlight = Class.create(Effect.Base, { | |
| initialize: function (element) { | |
| if (this.element = $(element), !this.element) throw Effect._elementDoesNotExistError; | |
| var options = Object.extend({ | |
| startcolor: "#ffff99" | |
| }, arguments[1] || {}); | |
| this.start(options) | |
| }, | |
| setup: function () { | |
| return "none" == this.element.getStyle("display") ? (this.cancel(), void 0) : (this.oldStyle = {}, this.options.keepBackgroundImage || (this.oldStyle.backgroundImage = this.element.getStyle("background-image"), this.element.setStyle({ | |
| backgroundImage: "none" | |
| })), this.options.endcolor || (this.options.endcolor = this.element.getStyle("background-color").parseColor("#ffffff")), this.options.restorecolor || (this.options.restorecolor = this.element.getStyle("background-color")), this._base = $R(0, 2).map(function (i) { | |
| return parseInt(this.options.startcolor.slice(2 * i + 1, 2 * i + 3), 16) | |
| }.bind(this)), this._delta = $R(0, 2).map(function (i) { | |
| return parseInt(this.options.endcolor.slice(2 * i + 1, 2 * i + 3), 16) - this._base[i] | |
| }.bind(this)), void 0) | |
| }, | |
| update: function (position) { | |
| this.element.setStyle({ | |
| backgroundColor: $R(0, 2).inject("#", function (m, v, i) { | |
| return m + (this._base[i] + this._delta[i] * position).round().toColorPart() | |
| }.bind(this)) | |
| }) | |
| }, | |
| finish: function () { | |
| this.element.setStyle(Object.extend(this.oldStyle, { | |
| backgroundColor: this.options.restorecolor | |
| })) | |
| } | |
| }), Effect.ScrollTo = function (element) { | |
| var options = arguments[1] || {}, scrollOffsets = document.viewport.getScrollOffsets(), | |
| elementOffsets = $(element).cumulativeOffset(); | |
| return options.offset && (elementOffsets[1] += options.offset), new Effect.Tween(null, scrollOffsets.top, elementOffsets[1], options, function (p) { | |
| scrollTo(scrollOffsets.left, p.round()) | |
| }) | |
| }, Effect.Fade = function (element) { | |
| element = $(element); | |
| var oldOpacity = element.getInlineOpacity(), | |
| options = Object.extend({ | |
| from: element.getOpacity() || 1, | |
| to: 0, | |
| afterFinishInternal: function (effect) { | |
| 0 == effect.options.to && effect.element.hide().setStyle({ | |
| opacity: oldOpacity | |
| }) | |
| } | |
| }, arguments[1] || {}); | |
| return new Effect.Opacity(element, options) | |
| }, Effect.Appear = function (element) { | |
| element = $(element); | |
| var options = Object.extend({ | |
| from: "none" == element.getStyle("display") ? 0 : element.getOpacity() || 0, | |
| to: 1, | |
| afterFinishInternal: function (effect) { | |
| effect.element.forceRerendering() | |
| }, | |
| beforeSetup: function (effect) { | |
| effect.element.setOpacity(effect.options.from).show() | |
| } | |
| }, arguments[1] || {}); | |
| return new Effect.Opacity(element, options) | |
| }, Effect.Puff = function (element) { | |
| element = $(element); | |
| var oldStyle = { | |
| opacity: element.getInlineOpacity(), | |
| position: element.getStyle("position"), | |
| top: element.style.top, | |
| left: element.style.left, | |
| width: element.style.width, | |
| height: element.style.height | |
| }; | |
| return new Effect.Parallel([new Effect.Scale(element, 200, { | |
| sync: !0, | |
| scaleFromCenter: !0, | |
| scaleContent: !0, | |
| restoreAfterFinish: !0 | |
| }), new Effect.Opacity(element, { | |
| sync: !0, | |
| to: 0 | |
| })], Object.extend({ | |
| duration: 1, | |
| beforeSetupInternal: function (effect) { | |
| Position.absolutize(effect.effects[0].element) | |
| }, | |
| afterFinishInternal: function (effect) { | |
| effect.effects[0].element.hide().setStyle(oldStyle) | |
| } | |
| }, arguments[1] || {})) | |
| }, Effect.BlindUp = function (element) { | |
| return element = $(element), element.makeClipping(), new Effect.Scale(element, 0, Object.extend({ | |
| scaleContent: !1, | |
| scaleX: !1, | |
| restoreAfterFinish: !0, | |
| afterFinishInternal: function (effect) { | |
| effect.element.hide().undoClipping() | |
| } | |
| }, arguments[1] || {})) | |
| }, Effect.BlindDown = function (element) { | |
| element = $(element); | |
| var elementDimensions = element.getDimensions(); | |
| return new Effect.Scale(element, 100, Object.extend({ | |
| scaleContent: !1, | |
| scaleX: !1, | |
| scaleFrom: 0, | |
| scaleMode: { | |
| originalHeight: elementDimensions.height, | |
| originalWidth: elementDimensions.width | |
| }, | |
| restoreAfterFinish: !0, | |
| afterSetup: function (effect) { | |
| effect.element.makeClipping().setStyle({ | |
| height: "0px" | |
| }).show() | |
| }, | |
| afterFinishInternal: function (effect) { | |
| effect.element.undoClipping() | |
| } | |
| }, arguments[1] || {})) | |
| }, Effect.SwitchOff = function (element) { | |
| element = $(element); | |
| var oldOpacity = element.getInlineOpacity(); | |
| return new Effect.Appear(element, Object.extend({ | |
| duration: .4, | |
| from: 0, | |
| transition: Effect.Transitions.flicker, | |
| afterFinishInternal: function (effect) { | |
| new Effect.Scale(effect.element, 1, { | |
| duration: .3, | |
| scaleFromCenter: !0, | |
| scaleX: !1, | |
| scaleContent: !1, | |
| restoreAfterFinish: !0, | |
| beforeSetup: function (effect) { | |
| effect.element.makePositioned().makeClipping() | |
| }, | |
| afterFinishInternal: function (effect) { | |
| effect.element.hide().undoClipping().undoPositioned().setStyle({ | |
| opacity: oldOpacity | |
| }) | |
| } | |
| }) | |
| } | |
| }, arguments[1] || {})) | |
| }, Effect.DropOut = function (element) { | |
| element = $(element); | |
| var oldStyle = { | |
| top: element.getStyle("top"), | |
| left: element.getStyle("left"), | |
| opacity: element.getInlineOpacity() | |
| }; | |
| return new Effect.Parallel([new Effect.Move(element, { | |
| x: 0, | |
| y: 100, | |
| sync: !0 | |
| }), new Effect.Opacity(element, { | |
| sync: !0, | |
| to: 0 | |
| })], Object.extend({ | |
| duration: .5, | |
| beforeSetup: function (effect) { | |
| effect.effects[0].element.makePositioned() | |
| }, | |
| afterFinishInternal: function (effect) { | |
| effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle) | |
| } | |
| }, arguments[1] || {})) | |
| }, Effect.Shake = function (element) { | |
| element = $(element); | |
| var options = Object.extend({ | |
| distance: 20, | |
| duration: .5 | |
| }, arguments[1] || {}), | |
| distance = parseFloat(options.distance), | |
| split = parseFloat(options.duration) / 10, | |
| oldStyle = { | |
| top: element.getStyle("top"), | |
| left: element.getStyle("left") | |
| }; | |
| return new Effect.Move(element, { | |
| x: distance, | |
| y: 0, | |
| duration: split, | |
| afterFinishInternal: function (effect) { | |
| new Effect.Move(effect.element, { | |
| x: 2 * -distance, | |
| y: 0, | |
| duration: 2 * split, | |
| afterFinishInternal: function (effect) { | |
| new Effect.Move(effect.element, { | |
| x: 2 * distance, | |
| y: 0, | |
| duration: 2 * split, | |
| afterFinishInternal: function (effect) { | |
| new Effect.Move(effect.element, { | |
| x: 2 * -distance, | |
| y: 0, | |
| duration: 2 * split, | |
| afterFinishInternal: function (effect) { | |
| new Effect.Move(effect.element, { | |
| x: 2 * distance, | |
| y: 0, | |
| duration: 2 * split, | |
| afterFinishInternal: function (effect) { | |
| new Effect.Move(effect.element, { | |
| x: -distance, | |
| y: 0, | |
| duration: split, | |
| afterFinishInternal: function (effect) { | |
| effect.element.undoPositioned().setStyle(oldStyle) | |
| } | |
| }) | |
| } | |
| }) | |
| } | |
| }) | |
| } | |
| }) | |
| } | |
| }) | |
| } | |
| }) | |
| }, Effect.SlideDown = function (element) { | |
| element = $(element).cleanWhitespace(); | |
| var oldInnerBottom = element.down().getStyle("bottom"), | |
| elementDimensions = element.getDimensions(); | |
| return new Effect.Scale(element, 100, Object.extend({ | |
| scaleContent: !1, | |
| scaleX: !1, | |
| scaleFrom: window.opera ? 0 : 1, | |
| scaleMode: { | |
| originalHeight: elementDimensions.height, | |
| originalWidth: elementDimensions.width | |
| }, | |
| restoreAfterFinish: !0, | |
| afterSetup: function (effect) { | |
| effect.element.makePositioned(), effect.element.down().makePositioned(), window.opera && effect.element.setStyle({ | |
| top: "" | |
| }), effect.element.makeClipping().setStyle({ | |
| height: "0px" | |
| }).show() | |
| }, | |
| afterUpdateInternal: function (effect) { | |
| effect.element.down().setStyle({ | |
| bottom: effect.dims[0] - effect.element.clientHeight + "px" | |
| }) | |
| }, | |
| afterFinishInternal: function (effect) { | |
| effect.element.undoClipping().undoPositioned(), effect.element.down().undoPositioned().setStyle({ | |
| bottom: oldInnerBottom | |
| }) | |
| } | |
| }, arguments[1] || {})) | |
| }, Effect.SlideUp = function (element) { | |
| element = $(element).cleanWhitespace(); | |
| var oldInnerBottom = element.down().getStyle("bottom"), | |
| elementDimensions = element.getDimensions(); | |
| return new Effect.Scale(element, window.opera ? 0 : 1, Object.extend({ | |
| scaleContent: !1, | |
| scaleX: !1, | |
| scaleMode: "box", | |
| scaleFrom: 100, | |
| scaleMode: { | |
| originalHeight: elementDimensions.height, | |
| originalWidth: elementDimensions.width | |
| }, | |
| restoreAfterFinish: !0, | |
| afterSetup: function (effect) { | |
| effect.element.makePositioned(), effect.element.down().makePositioned(), window.opera && effect.element.setStyle({ | |
| top: "" | |
| }), effect.element.makeClipping().show() | |
| }, | |
| afterUpdateInternal: function (effect) { | |
| effect.element.down().setStyle({ | |
| bottom: effect.dims[0] - effect.element.clientHeight + "px" | |
| }) | |
| }, | |
| afterFinishInternal: function (effect) { | |
| effect.element.hide().undoClipping().undoPositioned(), effect.element.down().undoPositioned().setStyle({ | |
| bottom: oldInnerBottom | |
| }) | |
| } | |
| }, arguments[1] || {})) | |
| }, Effect.Squish = function (element) { | |
| return new Effect.Scale(element, window.opera ? 1 : 0, { | |
| restoreAfterFinish: !0, | |
| beforeSetup: function (effect) { | |
| effect.element.makeClipping() | |
| }, | |
| afterFinishInternal: function (effect) { | |
| effect.element.hide().undoClipping() | |
| } | |
| }) | |
| }, Effect.Grow = function (element) { | |
| element = $(element); | |
| var initialMoveX, initialMoveY, moveX, moveY, options = Object.extend({ | |
| direction: "center", | |
| moveTransition: Effect.Transitions.sinoidal, | |
| scaleTransition: Effect.Transitions.sinoidal, | |
| opacityTransition: Effect.Transitions.full | |
| }, arguments[1] || {}), | |
| oldStyle = { | |
| top: element.style.top, | |
| left: element.style.left, | |
| height: element.style.height, | |
| width: element.style.width, | |
| opacity: element.getInlineOpacity() | |
| }, dims = element.getDimensions(); | |
| switch (options.direction) { | |
| case "top-left": | |
| initialMoveX = initialMoveY = moveX = moveY = 0; | |
| break; | |
| case "top-right": | |
| initialMoveX = dims.width, initialMoveY = moveY = 0, moveX = -dims.width; | |
| break; | |
| case "bottom-left": | |
| initialMoveX = moveX = 0, initialMoveY = dims.height, moveY = -dims.height; | |
| break; | |
| case "bottom-right": | |
| initialMoveX = dims.width, initialMoveY = dims.height, moveX = -dims.width, moveY = -dims.height; | |
| break; | |
| case "center": | |
| initialMoveX = dims.width / 2, initialMoveY = dims.height / 2, moveX = -dims.width / 2, moveY = -dims.height / 2 | |
| } | |
| return new Effect.Move(element, { | |
| x: initialMoveX, | |
| y: initialMoveY, | |
| duration: .01, | |
| beforeSetup: function (effect) { | |
| effect.element.hide().makeClipping().makePositioned() | |
| }, | |
| afterFinishInternal: function (effect) { | |
| new Effect.Parallel([new Effect.Opacity(effect.element, { | |
| sync: !0, | |
| to: 1, | |
| from: 0, | |
| transition: options.opacityTransition | |
| }), new Effect.Move(effect.element, { | |
| x: moveX, | |
| y: moveY, | |
| sync: !0, | |
| transition: options.moveTransition | |
| }), new Effect.Scale(effect.element, 100, { | |
| scaleMode: { | |
| originalHeight: dims.height, | |
| originalWidth: dims.width | |
| }, | |
| sync: !0, | |
| scaleFrom: window.opera ? 1 : 0, | |
| transition: options.scaleTransition, | |
| restoreAfterFinish: !0 | |
| })], Object.extend({ | |
| beforeSetup: function (effect) { | |
| effect.effects[0].element.setStyle({ | |
| height: "0px" | |
| }).show() | |
| }, | |
| afterFinishInternal: function (effect) { | |
| effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle) | |
| } | |
| }, options)) | |
| } | |
| }) | |
| }, Effect.Shrink = function (element) { | |
| element = $(element); | |
| var moveX, moveY, options = Object.extend({ | |
| direction: "center", | |
| moveTransition: Effect.Transitions.sinoidal, | |
| scaleTransition: Effect.Transitions.sinoidal, | |
| opacityTransition: Effect.Transitions.none | |
| }, arguments[1] || {}), | |
| oldStyle = { | |
| top: element.style.top, | |
| left: element.style.left, | |
| height: element.style.height, | |
| width: element.style.width, | |
| opacity: element.getInlineOpacity() | |
| }, dims = element.getDimensions(); | |
| switch (options.direction) { | |
| case "top-left": | |
| moveX = moveY = 0; | |
| break; | |
| case "top-right": | |
| moveX = dims.width, moveY = 0; | |
| break; | |
| case "bottom-left": | |
| moveX = 0, moveY = dims.height; | |
| break; | |
| case "bottom-right": | |
| moveX = dims.width, moveY = dims.height; | |
| break; | |
| case "center": | |
| moveX = dims.width / 2, moveY = dims.height / 2 | |
| } | |
| return new Effect.Parallel([new Effect.Opacity(element, { | |
| sync: !0, | |
| to: 0, | |
| from: 1, | |
| transition: options.opacityTransition | |
| }), new Effect.Scale(element, window.opera ? 1 : 0, { | |
| sync: !0, | |
| transition: options.scaleTransition, | |
| restoreAfterFinish: !0 | |
| }), new Effect.Move(element, { | |
| x: moveX, | |
| y: moveY, | |
| sync: !0, | |
| transition: options.moveTransition | |
| })], Object.extend({ | |
| beforeStartInternal: function (effect) { | |
| effect.effects[0].element.makePositioned().makeClipping() | |
| }, | |
| afterFinishInternal: function (effect) { | |
| effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle) | |
| } | |
| }, options)) | |
| }, Effect.Pulsate = function (element) { | |
| element = $(element); | |
| var options = arguments[1] || {}, oldOpacity = element.getInlineOpacity(), | |
| transition = options.transition || Effect.Transitions.linear, | |
| reverser = function (pos) { | |
| return 1 - transition(-Math.cos(2 * pos * (options.pulses || 5) * Math.PI) / 2 + .5) | |
| }; | |
| return new Effect.Opacity(element, Object.extend(Object.extend({ | |
| duration: 2, | |
| from: 0, | |
| afterFinishInternal: function (effect) { | |
| effect.element.setStyle({ | |
| opacity: oldOpacity | |
| }) | |
| } | |
| }, options), { | |
| transition: reverser | |
| })) | |
| }, Effect.Fold = function (element) { | |
| element = $(element); | |
| var oldStyle = { | |
| top: element.style.top, | |
| left: element.style.left, | |
| width: element.style.width, | |
| height: element.style.height | |
| }; | |
| return element.makeClipping(), new Effect.Scale(element, 5, Object.extend({ | |
| scaleContent: !1, | |
| scaleX: !1, | |
| afterFinishInternal: function () { | |
| new Effect.Scale(element, 1, { | |
| scaleContent: !1, | |
| scaleY: !1, | |
| afterFinishInternal: function (effect) { | |
| effect.element.hide().undoClipping().setStyle(oldStyle) | |
| } | |
| }) | |
| } | |
| }, arguments[1] || {})) | |
| }, Effect.Morph = Class.create(Effect.Base, { | |
| initialize: function (element) { | |
| if (this.element = $(element), !this.element) throw Effect._elementDoesNotExistError; | |
| var options = Object.extend({ | |
| style: {} | |
| }, arguments[1] || {}); | |
| if (Object.isString(options.style)) | |
| if (options.style.include(":")) this.style = options.style.parseStyle(); | |
| else { | |
| this.element.addClassName(options.style), this.style = $H(this.element.getStyles()), this.element.removeClassName(options.style); | |
| var css = this.element.getStyles(); | |
| this.style = this.style.reject(function (style) { | |
| return style.value == css[style.key] | |
| }), options.afterFinishInternal = function (effect) { | |
| effect.element.addClassName(effect.options.style), effect.transforms.each(function (transform) { | |
| effect.element.style[transform.style] = "" | |
| }) | |
| } | |
| } else this.style = $H(options.style); | |
| this.start(options) | |
| }, | |
| setup: function () { | |
| function parseColor(color) { | |
| return (!color || ["rgba(0, 0, 0, 0)", "transparent"].include(color)) && (color = "#ffffff"), color = color.parseColor(), $R(0, 2).map(function (i) { | |
| return parseInt(color.slice(2 * i + 1, 2 * i + 3), 16) | |
| }) | |
| } | |
| this.transforms = this.style.map(function (pair) { | |
| var property = pair[0], | |
| value = pair[1], | |
| unit = null; | |
| if ("#zzzzzz" != value.parseColor("#zzzzzz")) value = value.parseColor(), unit = "color"; | |
| else if ("opacity" == property) value = parseFloat(value), Prototype.Browser.IE && !this.element.currentStyle.hasLayout && this.element.setStyle({ | |
| zoom: 1 | |
| }); | |
| else if (Element.CSS_LENGTH.test(value)) { | |
| var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/); | |
| value = parseFloat(components[1]), unit = 3 == components.length ? components[2] : null | |
| } | |
| var originalValue = this.element.getStyle(property); | |
| return { | |
| style: property.camelize(), | |
| originalValue: "color" == unit ? parseColor(originalValue) : parseFloat(originalValue || 0), | |
| targetValue: "color" == unit ? parseColor(value) : value, | |
| unit: unit | |
| } | |
| }.bind(this)).reject(function (transform) { | |
| return transform.originalValue == transform.targetValue || "color" != transform.unit && (isNaN(transform.originalValue) || isNaN(transform.targetValue)) | |
| }) | |
| }, | |
| update: function (position) { | |
| for (var transform, style = {}, i = this.transforms.length; i--;) style[(transform = this.transforms[i]).style] = "color" == transform.unit ? "#" + Math.round(transform.originalValue[0] + (transform.targetValue[0] - transform.originalValue[0]) * position).toColorPart() + Math.round(transform.originalValue[1] + (transform.targetValue[1] - transform.originalValue[1]) * position).toColorPart() + Math.round(transform.originalValue[2] + (transform.targetValue[2] - transform.originalValue[2]) * position).toColorPart() : (transform.originalValue + (transform.targetValue - transform.originalValue) * position).toFixed(3) + (null === transform.unit ? "" : transform.unit); | |
| this.element.setStyle(style, !0) | |
| } | |
| }), Effect.Transform = Class.create({ | |
| initialize: function (tracks) { | |
| this.tracks = [], this.options = arguments[1] || {}, this.addTracks(tracks) | |
| }, | |
| addTracks: function (tracks) { | |
| return tracks.each(function (track) { | |
| track = $H(track); | |
| var data = track.values().first(); | |
| this.tracks.push($H({ | |
| ids: track.keys().first(), | |
| effect: Effect.Morph, | |
| options: { | |
| style: data | |
| } | |
| })) | |
| }.bind(this)), this | |
| }, | |
| play: function () { | |
| return new Effect.Parallel(this.tracks.map(function (track) { | |
| var ids = track.get("ids"), | |
| effect = track.get("effect"), | |
| options = track.get("options"), | |
| elements = [$(ids) || $$(ids)].flatten(); | |
| return elements.map(function (e) { | |
| return new effect(e, Object.extend({ | |
| sync: !0 | |
| }, options)) | |
| }) | |
| }).flatten(), this.options) | |
| } | |
| }), Element.CSS_PROPERTIES = $w("backgroundColor backgroundPosition borderBottomColor borderBottomStyle borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth borderRightColor borderRightStyle borderRightWidth borderSpacing borderTopColor borderTopStyle borderTopWidth bottom clip color fontSize fontWeight height left letterSpacing lineHeight marginBottom marginLeft marginRight marginTop markerOffset maxHeight maxWidth minHeight minWidth opacity outlineColor outlineOffset outlineWidth paddingBottom paddingLeft paddingRight paddingTop right textIndent top width wordSpacing zIndex"), Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/, String.__parseStyleElement = document.createElement("div"), String.prototype.parseStyle = function () { | |
| var style, styleRules = $H(); | |
| return Prototype.Browser.WebKit ? style = new Element("div", { | |
| style: this | |
| }).style : (String.__parseStyleElement.innerHTML = '<div style="' + this + '"></div>', style = String.__parseStyleElement.childNodes[0].style), Element.CSS_PROPERTIES.each(function (property) { | |
| style[property] && styleRules.set(property, style[property]) | |
| }), Prototype.Browser.IE && this.include("opacity") && styleRules.set("opacity", this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]), styleRules | |
| }, Element.getStyles = document.defaultView && document.defaultView.getComputedStyle ? function (element) { | |
| var css = document.defaultView.getComputedStyle($(element), null); | |
| return Element.CSS_PROPERTIES.inject({}, function (styles, property) { | |
| return styles[property] = css[property], styles | |
| }) | |
| } : function (element) { | |
| element = $(element); | |
| var styles, css = element.currentStyle; | |
| return styles = Element.CSS_PROPERTIES.inject({}, function (results, property) { | |
| return results[property] = css[property], results | |
| }), styles.opacity || (styles.opacity = element.getOpacity()), styles | |
| }, Effect.Methods = { | |
| morph: function (element, style) { | |
| return element = $(element), new Effect.Morph(element, Object.extend({ | |
| style: style | |
| }, arguments[2] || {})), element | |
| }, | |
| visualEffect: function (element, effect, options) { | |
| element = $(element); | |
| var s = effect.dasherize().camelize(), | |
| klass = s.charAt(0).toUpperCase() + s.substring(1); | |
| return new Effect[klass](element, options), element | |
| }, | |
| highlight: function (element, options) { | |
| return element = $(element), new Effect.Highlight(element, options), element | |
| } | |
| }, $w("fade appear grow shrink fold blindUp blindDown slideUp slideDown pulsate shake puff squish switchOff dropOut").each(function (effect) { | |
| Effect.Methods[effect] = function (element, options) { | |
| return element = $(element), Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options), element | |
| } | |
| }), $w("getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles").each(function (f) { | |
| Effect.Methods[f] = Element[f] | |
| }), Element.addMethods(Effect.Methods), Object.isUndefined(Effect)) throw "dragdrop.js requires including script.aculo.us' effects.js library"; | |
| var Droppables = { | |
| drops: [], | |
| remove: function (element) { | |
| this.drops = this.drops.reject(function (d) { | |
| return d.element == $(element) | |
| }) | |
| }, | |
| add: function (element) { | |
| element = $(element); | |
| var options = Object.extend({ | |
| greedy: !0, | |
| hoverclass: null, | |
| tree: !1 | |
| }, arguments[1] || {}); | |
| if (options.containment) { | |
| options._containers = []; | |
| var containment = options.containment; | |
| Object.isArray(containment) ? containment.each(function (c) { | |
| options._containers.push($(c)) | |
| }) : options._containers.push($(containment)) | |
| } | |
| options.accept && (options.accept = [options.accept].flatten()), Element.makePositioned(element), options.element = element, this.drops.push(options) | |
| }, | |
| findDeepestChild: function (drops) { | |
| for (deepest = drops[0], i = 1; i < drops.length; ++i) Element.isParent(drops[i].element, deepest.element) && (deepest = drops[i]); | |
| return deepest | |
| }, | |
| isContained: function (element, drop) { | |
| var containmentNode; | |
| return containmentNode = drop.tree ? element.treeNode : element.parentNode, drop._containers.detect(function (c) { | |
| return containmentNode == c | |
| }) | |
| }, | |
| isAffected: function (point, element, drop) { | |
| return drop.element != element && (!drop._containers || this.isContained(element, drop)) && (!drop.accept || Element.classNames(element).detect(function (v) { | |
| return drop.accept.include(v) | |
| })) && Position.within(drop.element, point[0], point[1]) | |
| }, | |
| deactivate: function (drop) { | |
| drop.hoverclass && Element.removeClassName(drop.element, drop.hoverclass), this.last_active = null | |
| }, | |
| activate: function (drop) { | |
| drop.hoverclass && Element.addClassName(drop.element, drop.hoverclass), this.last_active = drop | |
| }, | |
| show: function (point, element) { | |
| if (this.drops.length) { | |
| var drop, affected = []; | |
| this.drops.each(function (drop) { | |
| Droppables.isAffected(point, element, drop) && affected.push(drop) | |
| }), affected.length > 0 && (drop = Droppables.findDeepestChild(affected)), this.last_active && this.last_active != drop && this.deactivate(this.last_active), drop && (Position.within(drop.element, point[0], point[1]), drop.onHover && drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)), drop != this.last_active && Droppables.activate(drop)) | |
| } | |
| }, | |
| fire: function (event, element) { | |
| return this.last_active ? (Position.prepare(), this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active) && this.last_active.onDrop ? (this.last_active.onDrop(element, this.last_active.element, event), !0) : void 0) : void 0 | |
| }, | |
| reset: function () { | |
| this.last_active && this.deactivate(this.last_active) | |
| } | |
| }, Draggables = { | |
| drags: [], | |
| observers: [], | |
| register: function (draggable) { | |
| 0 == this.drags.length && (this.eventMouseUp = this.endDrag.bindAsEventListener(this), this.eventMouseMove = this.updateDrag.bindAsEventListener(this), this.eventKeypress = this.keyPress.bindAsEventListener(this), Event.observe(document, "mouseup", this.eventMouseUp), Event.observe(document, "mousemove", this.eventMouseMove), Event.observe(document, "keypress", this.eventKeypress)), this.drags.push(draggable) | |
| }, | |
| unregister: function (draggable) { | |
| this.drags = this.drags.reject(function (d) { | |
| return d == draggable | |
| }), 0 == this.drags.length && (Event.stopObserving(document, "mouseup", this.eventMouseUp), Event.stopObserving(document, "mousemove", this.eventMouseMove), Event.stopObserving(document, "keypress", this.eventKeypress)) | |
| }, | |
| activate: function (draggable) { | |
| draggable.options.delay ? this._timeout = setTimeout(function () { | |
| Draggables._timeout = null, window.focus(), Draggables.activeDraggable = draggable | |
| }.bind(this), draggable.options.delay) : (window.focus(), this.activeDraggable = draggable) | |
| }, | |
| deactivate: function () { | |
| this.activeDraggable = null | |
| }, | |
| updateDrag: function (event) { | |
| if (this.activeDraggable) { | |
| var pointer = [Event.pointerX(event), Event.pointerY(event)]; | |
| this._lastPointer && this._lastPointer.inspect() == pointer.inspect() || (this._lastPointer = pointer, this.activeDraggable.updateDrag(event, pointer)) | |
| } | |
| }, | |
| endDrag: function (event) { | |
| this._timeout && (clearTimeout(this._timeout), this._timeout = null), this.activeDraggable && (this._lastPointer = null, this.activeDraggable.endDrag(event), this.activeDraggable = null) | |
| }, | |
| keyPress: function (event) { | |
| this.activeDraggable && this.activeDraggable.keyPress(event) | |
| }, | |
| addObserver: function (observer) { | |
| this.observers.push(observer), this._cacheObserverCallbacks() | |
| }, | |
| removeObserver: function (element) { | |
| this.observers = this.observers.reject(function (o) { | |
| return o.element == element | |
| }), this._cacheObserverCallbacks() | |
| }, | |
| notify: function (eventName, draggable, event) { | |
| this[eventName + "Count"] > 0 && this.observers.each(function (o) { | |
| o[eventName] && o[eventName](eventName, draggable, event) | |
| }), draggable.options[eventName] && draggable.options[eventName](draggable, event) | |
| }, | |
| _cacheObserverCallbacks: function () { | |
| ["onStart", "onEnd", "onDrag"].each(function (eventName) { | |
| Draggables[eventName + "Count"] = Draggables.observers.select(function (o) { | |
| return o[eventName] | |
| }).length | |
| }) | |
| } | |
| }, Draggable = Class.create({ | |
| initialize: function (element) { | |
| var defaults = { | |
| handle: !1, | |
| reverteffect: function (element, top_offset, left_offset) { | |
| var dur = .02 * Math.sqrt(Math.abs(2 ^ top_offset) + Math.abs(2 ^ left_offset)); | |
| new Effect.Move(element, { | |
| x: -left_offset, | |
| y: -top_offset, | |
| duration: dur, | |
| queue: { | |
| scope: "_draggable", | |
| position: "end" | |
| } | |
| }) | |
| }, | |
| endeffect: function (element) { | |
| var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1; | |
| new Effect.Opacity(element, { | |
| duration: .2, | |
| from: .7, | |
| to: toOpacity, | |
| queue: { | |
| scope: "_draggable", | |
| position: "end" | |
| }, | |
| afterFinish: function () { | |
| Draggable._dragging[element] = !1 | |
| } | |
| }) | |
| }, | |
| zindex: 1e3, | |
| revert: !1, | |
| quiet: !1, | |
| scroll: !1, | |
| scrollSensitivity: 20, | |
| scrollSpeed: 15, | |
| snap: !1, | |
| delay: 0 | |
| }; | |
| (!arguments[1] || Object.isUndefined(arguments[1].endeffect)) && Object.extend(defaults, { | |
| starteffect: function (element) { | |
| element._opacity = Element.getOpacity(element), Draggable._dragging[element] = !0, new Effect.Opacity(element, { | |
| duration: .2, | |
| from: element._opacity, | |
| to: .7 | |
| }) | |
| } | |
| }); | |
| var options = Object.extend(defaults, arguments[1] || {}); | |
| this.element = $(element), options.handle && Object.isString(options.handle) && (this.handle = this.element.down("." + options.handle, 0)), this.handle || (this.handle = $(options.handle)), this.handle || (this.handle = this.element), !options.scroll || options.scroll.scrollTo || options.scroll.outerHTML || (options.scroll = $(options.scroll), this._isScrollChild = Element.childOf(this.element, options.scroll)), Element.makePositioned(this.element), this.options = options, this.dragging = !1, this.eventMouseDown = this.initDrag.bindAsEventListener(this), Event.observe(this.handle, "mousedown", this.eventMouseDown), Draggables.register(this) | |
| }, | |
| destroy: function () { | |
| Event.stopObserving(this.handle, "mousedown", this.eventMouseDown), Draggables.unregister(this) | |
| }, | |
| currentDelta: function () { | |
| return [parseInt(Element.getStyle(this.element, "left") || "0"), parseInt(Element.getStyle(this.element, "top") || "0")] | |
| }, | |
| initDrag: function (event) { | |
| if ((Object.isUndefined(Draggable._dragging[this.element]) || !Draggable._dragging[this.element]) && Event.isLeftClick(event)) { | |
| var src = Event.element(event); | |
| if ((tag_name = src.tagName.toUpperCase()) && ("INPUT" == tag_name || "SELECT" == tag_name || "OPTION" == tag_name || "BUTTON" == tag_name || "TEXTAREA" == tag_name)) return; | |
| var pointer = [Event.pointerX(event), Event.pointerY(event)], | |
| pos = this.element.cumulativeOffset(); | |
| this.offset = [0, 1].map(function (i) { | |
| return pointer[i] - pos[i] | |
| }), Draggables.activate(this), Event.stop(event) | |
| } | |
| }, | |
| startDrag: function (event) { | |
| if (this.dragging = !0, this.delta || (this.delta = this.currentDelta()), this.options.zindex && (this.originalZ = parseInt(Element.getStyle(this.element, "z-index") || 0), this.element.style.zIndex = this.options.zindex), this.options.ghosting && (this._clone = this.element.cloneNode(!0), this._originallyAbsolute = "absolute" !== this.element.getStyle("position"), this._originallyAbsolute || Position.absolutize(this.element), this.element.parentNode.insertBefore(this._clone, this.element)), this.options.scroll) | |
| if (this.options.scroll == window) { | |
| var where = this._getWindowScroll(this.options.scroll); | |
| this.originalScrollLeft = where.left, this.originalScrollTop = where.top | |
| } else this.originalScrollLeft = this.options.scroll.scrollLeft, this.originalScrollTop = this.options.scroll.scrollTop; | |
| Draggables.notify("onStart", this, event), this.options.starteffect && this.options.starteffect(this.element) | |
| }, | |
| updateDrag: function (event, pointer) { | |
| if (this.dragging || this.startDrag(event), this.options.quiet || (Position.prepare(), Droppables.show(pointer, this.element)), Draggables.notify("onDrag", this, event), this.draw(pointer), this.options.change && this.options.change(this), this.options.scroll) { | |
| this.stopScrolling(); | |
| var p; | |
| if (this.options.scroll == window) with(this._getWindowScroll(this.options.scroll)) p = [left, top, left + width, top + height]; | |
| else p = Position.page(this.options.scroll).toArray(), p[0] += this.options.scroll.scrollLeft + Position.deltaX, p[1] += this.options.scroll.scrollTop + Position.deltaY, p.push(p[0] + this.options.scroll.offsetWidth), p.push(p[1] + this.options.scroll.offsetHeight); | |
| var speed = [0, 0]; | |
| pointer[0] < p[0] + this.options.scrollSensitivity && (speed[0] = pointer[0] - (p[0] + this.options.scrollSensitivity)), pointer[1] < p[1] + this.options.scrollSensitivity && (speed[1] = pointer[1] - (p[1] + this.options.scrollSensitivity)), pointer[0] > p[2] - this.options.scrollSensitivity && (speed[0] = pointer[0] - (p[2] - this.options.scrollSensitivity)), pointer[1] > p[3] - this.options.scrollSensitivity && (speed[1] = pointer[1] - (p[3] - this.options.scrollSensitivity)), this.startScrolling(speed) | |
| } | |
| Prototype.Browser.WebKit && window.scrollBy(0, 0), Event.stop(event) | |
| }, | |
| finishDrag: function (event, success) { | |
| if (this.dragging = !1, this.options.quiet) { | |
| Position.prepare(); | |
| var pointer = [Event.pointerX(event), Event.pointerY(event)]; | |
| Droppables.show(pointer, this.element) | |
| } | |
| this.options.ghosting && (this._originallyAbsolute || Position.relativize(this.element), delete this._originallyAbsolute, Element.remove(this._clone), this._clone = null); | |
| var dropped = !1; | |
| success && (dropped = Droppables.fire(event, this.element), dropped || (dropped = !1)), dropped && this.options.onDropped && this.options.onDropped(this.element), Draggables.notify("onEnd", this, event); | |
| var revert = this.options.revert; | |
| revert && Object.isFunction(revert) && (revert = revert(this.element)); | |
| var d = this.currentDelta(); | |
| revert && this.options.reverteffect ? (0 == dropped || "failure" != revert) && this.options.reverteffect(this.element, d[1] - this.delta[1], d[0] - this.delta[0]) : this.delta = d, this.options.zindex && (this.element.style.zIndex = this.originalZ), this.options.endeffect && this.options.endeffect(this.element), Draggables.deactivate(this), Droppables.reset() | |
| }, | |
| keyPress: function (event) { | |
| event.keyCode == Event.KEY_ESC && (this.finishDrag(event, !1), Event.stop(event)) | |
| }, | |
| endDrag: function (event) { | |
| this.dragging && (this.stopScrolling(), this.finishDrag(event, !0), Event.stop(event)) | |
| }, | |
| draw: function (point) { | |
| var pos = this.element.cumulativeOffset(); | |
| if (this.options.ghosting) { | |
| var r = Position.realOffset(this.element); | |
| pos[0] += r[0] - Position.deltaX, pos[1] += r[1] - Position.deltaY | |
| } | |
| var d = this.currentDelta(); | |
| pos[0] -= d[0], pos[1] -= d[1], this.options.scroll && this.options.scroll != window && this._isScrollChild && (pos[0] -= this.options.scroll.scrollLeft - this.originalScrollLeft, pos[1] -= this.options.scroll.scrollTop - this.originalScrollTop); | |
| var p = [0, 1].map(function (i) { | |
| return point[i] - pos[i] - this.offset[i] | |
| }.bind(this)); | |
| this.options.snap && (p = Object.isFunction(this.options.snap) ? this.options.snap(p[0], p[1], this) : Object.isArray(this.options.snap) ? p.map(function (v, i) { | |
| return (v / this.options.snap[i]).round() * this.options.snap[i] | |
| }.bind(this)) : p.map(function (v) { | |
| return (v / this.options.snap).round() * this.options.snap | |
| }.bind(this))); | |
| var style = this.element.style; | |
| this.options.constraint && "horizontal" != this.options.constraint || (style.left = p[0] + "px"), this.options.constraint && "vertical" != this.options.constraint || (style.top = p[1] + "px"), "hidden" == style.visibility && (style.visibility = "") | |
| }, | |
| stopScrolling: function () { | |
| this.scrollInterval && (clearInterval(this.scrollInterval), this.scrollInterval = null, Draggables._lastScrollPointer = null) | |
| }, | |
| startScrolling: function (speed) { | |
| (speed[0] || speed[1]) && (this.scrollSpeed = [speed[0] * this.options.scrollSpeed, speed[1] * this.options.scrollSpeed], this.lastScrolled = new Date, this.scrollInterval = setInterval(this.scroll.bind(this), 10)) | |
| }, | |
| scroll: function () { | |
| var current = new Date, | |
| delta = current - this.lastScrolled; | |
| if (this.lastScrolled = current, this.options.scroll == window) { | |
| with(this._getWindowScroll(this.options.scroll)) if (this.scrollSpeed[0] || this.scrollSpeed[1]) { | |
| var d = delta / 1e3; | |
| this.options.scroll.scrollTo(left + d * this.scrollSpeed[0], top + d * this.scrollSpeed[1]) | |
| } | |
| } else this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1e3, this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1e3; | |
| Position.prepare(), Droppables.show(Draggables._lastPointer, this.element), Draggables.notify("onDrag", this), this._isScrollChild && (Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer), Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1e3, Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1e3, Draggables._lastScrollPointer[0] < 0 && (Draggables._lastScrollPointer[0] = 0), Draggables._lastScrollPointer[1] < 0 && (Draggables._lastScrollPointer[1] = 0), this.draw(Draggables._lastScrollPointer)), this.options.change && this.options.change(this) | |
| }, | |
| _getWindowScroll: function (w) { | |
| var T, L, W, H; | |
| with(w.document) w.document.documentElement && documentElement.scrollTop ? (T = documentElement.scrollTop, L = documentElement.scrollLeft) : w.document.body && (T = body.scrollTop, L = body.scrollLeft), w.innerWidth ? (W = w.innerWidth, H = w.innerHeight) : w.document.documentElement && documentElement.clientWidth ? (W = documentElement.clientWidth, H = documentElement.clientHeight) : (W = body.offsetWidth, H = body.offsetHeight); | |
| return { | |
| top: T, | |
| left: L, | |
| width: W, | |
| height: H | |
| } | |
| } | |
| }); | |
| Draggable._dragging = {}; | |
| var SortableObserver = Class.create({ | |
| initialize: function (element, observer) { | |
| this.element = $(element), this.observer = observer, this.lastValue = Sortable.serialize(this.element) | |
| }, | |
| onStart: function () { | |
| this.lastValue = Sortable.serialize(this.element) | |
| }, | |
| onEnd: function () { | |
| Sortable.unmark(), this.lastValue != Sortable.serialize(this.element) && this.observer(this.element) | |
| } | |
| }), | |
| Sortable = { | |
| SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/, | |
| sortables: {}, | |
| _findRootElement: function (element) { | |
| for (; | |
| "BODY" != element.tagName.toUpperCase();) { | |
| if (element.id && Sortable.sortables[element.id]) return element; | |
| element = element.parentNode | |
| } | |
| }, | |
| options: function (element) { | |
| return (element = Sortable._findRootElement($(element))) ? Sortable.sortables[element.id] : void 0 | |
| }, | |
| destroy: function (element) { | |
| element = $(element); | |
| var s = Sortable.sortables[element.id]; | |
| s && (Draggables.removeObserver(s.element), s.droppables.each(function (d) { | |
| Droppables.remove(d) | |
| }), s.draggables.invoke("destroy"), delete Sortable.sortables[s.element.id]) | |
| }, | |
| create: function (element) { | |
| element = $(element); | |
| var options = Object.extend({ | |
| element: element, | |
| tag: "li", | |
| dropOnEmpty: !1, | |
| tree: !1, | |
| treeTag: "ul", | |
| overlap: "vertical", | |
| constraint: "vertical", | |
| containment: element, | |
| handle: !1, | |
| only: !1, | |
| delay: 0, | |
| hoverclass: null, | |
| ghosting: !1, | |
| quiet: !1, | |
| scroll: !1, | |
| scrollSensitivity: 20, | |
| scrollSpeed: 15, | |
| format: this.SERIALIZE_RULE, | |
| elements: !1, | |
| handles: !1, | |
| onChange: Prototype.emptyFunction, | |
| onUpdate: Prototype.emptyFunction | |
| }, arguments[1] || {}); | |
| this.destroy(element); | |
| var options_for_draggable = { | |
| revert: !0, | |
| quiet: options.quiet, | |
| scroll: options.scroll, | |
| scrollSpeed: options.scrollSpeed, | |
| scrollSensitivity: options.scrollSensitivity, | |
| delay: options.delay, | |
| ghosting: options.ghosting, | |
| constraint: options.constraint, | |
| handle: options.handle | |
| }; | |
| options.starteffect && (options_for_draggable.starteffect = options.starteffect), options.reverteffect ? options_for_draggable.reverteffect = options.reverteffect : options.ghosting && (options_for_draggable.reverteffect = function (element) { | |
| element.style.top = 0, element.style.left = 0 | |
| }), options.endeffect && (options_for_draggable.endeffect = options.endeffect), options.zindex && (options_for_draggable.zindex = options.zindex); | |
| var options_for_droppable = { | |
| overlap: options.overlap, | |
| containment: options.containment, | |
| tree: options.tree, | |
| hoverclass: options.hoverclass, | |
| onHover: Sortable.onHover | |
| }, options_for_tree = { | |
| onHover: Sortable.onEmptyHover, | |
| overlap: options.overlap, | |
| containment: options.containment, | |
| hoverclass: options.hoverclass | |
| }; | |
| Element.cleanWhitespace(element), options.draggables = [], options.droppables = [], (options.dropOnEmpty || options.tree) && (Droppables.add(element, options_for_tree), options.droppables.push(element)), (options.elements || this.findElements(element, options) || []).each(function (e, i) { | |
| var handle = options.handles ? $(options.handles[i]) : options.handle ? $(e).select("." + options.handle)[0] : e; | |
| options.draggables.push(new Draggable(e, Object.extend(options_for_draggable, { | |
| handle: handle | |
| }))), Droppables.add(e, options_for_droppable), options.tree && (e.treeNode = element), options.droppables.push(e) | |
| }), options.tree && (Sortable.findTreeElements(element, options) || []).each(function (e) { | |
| Droppables.add(e, options_for_tree), e.treeNode = element, options.droppables.push(e) | |
| }), this.sortables[element.identify()] = options, Draggables.addObserver(new SortableObserver(element, options.onUpdate)) | |
| }, | |
| findElements: function (element, options) { | |
| return Element.findChildren(element, options.only, options.tree ? !0 : !1, options.tag) | |
| }, | |
| findTreeElements: function (element, options) { | |
| return Element.findChildren(element, options.only, options.tree ? !0 : !1, options.treeTag) | |
| }, | |
| onHover: function (element, dropon, overlap) { | |
| if (!(Element.isParent(dropon, element) || overlap > .33 && .66 > overlap && Sortable.options(dropon).tree)) | |
| if (overlap > .5) { | |
| if (Sortable.mark(dropon, "before"), dropon.previousSibling != element) { | |
| var oldParentNode = element.parentNode; | |
| element.style.visibility = "hidden", dropon.parentNode.insertBefore(element, dropon), dropon.parentNode != oldParentNode && Sortable.options(oldParentNode).onChange(element), Sortable.options(dropon.parentNode).onChange(element) | |
| } | |
| } else { | |
| Sortable.mark(dropon, "after"); | |
| var nextElement = dropon.nextSibling || null; | |
| if (nextElement != element) { | |
| var oldParentNode = element.parentNode; | |
| element.style.visibility = "hidden", dropon.parentNode.insertBefore(element, nextElement), dropon.parentNode != oldParentNode && Sortable.options(oldParentNode).onChange(element), Sortable.options(dropon.parentNode).onChange(element) | |
| } | |
| } | |
| }, | |
| onEmptyHover: function (element, dropon, overlap) { | |
| var oldParentNode = element.parentNode, | |
| droponOptions = Sortable.options(dropon); | |
| if (!Element.isParent(dropon, element)) { | |
| var index, children = Sortable.findElements(dropon, { | |
| tag: droponOptions.tag, | |
| only: droponOptions.only | |
| }), | |
| child = null; | |
| if (children) { | |
| var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1 - overlap); | |
| for (index = 0; index < children.length; index += 1) { | |
| if (!(offset - Element.offsetSize(children[index], droponOptions.overlap) >= 0)) { | |
| if (offset - Element.offsetSize(children[index], droponOptions.overlap) / 2 >= 0) { | |
| child = index + 1 < children.length ? children[index + 1] : null; | |
| break | |
| } | |
| child = children[index]; | |
| break | |
| } | |
| offset -= Element.offsetSize(children[index], droponOptions.overlap) | |
| } | |
| } | |
| dropon.insertBefore(element, child), Sortable.options(oldParentNode).onChange(element), droponOptions.onChange(element) | |
| } | |
| }, | |
| unmark: function () { | |
| Sortable._marker && Sortable._marker.hide() | |
| }, | |
| mark: function (dropon, position) { | |
| var sortable = Sortable.options(dropon.parentNode); | |
| if (!sortable || sortable.ghosting) { | |
| Sortable._marker || (Sortable._marker = ($("dropmarker") || Element.extend(document.createElement("DIV"))).hide().addClassName("dropmarker").setStyle({ | |
| position: "absolute" | |
| }), document.getElementsByTagName("body").item(0).appendChild(Sortable._marker)); | |
| var offsets = dropon.cumulativeOffset(); | |
| Sortable._marker.setStyle({ | |
| left: offsets[0] + "px", | |
| top: offsets[1] + "px" | |
| }), "after" == position && ("horizontal" == sortable.overlap ? Sortable._marker.setStyle({ | |
| left: offsets[0] + dropon.clientWidth + "px" | |
| }) : Sortable._marker.setStyle({ | |
| top: offsets[1] + dropon.clientHeight + "px" | |
| })), Sortable._marker.show() | |
| } | |
| }, | |
| _tree: function (element, options, parent) { | |
| for (var children = Sortable.findElements(element, options) || [], i = 0; i < children.length; ++i) { | |
| var match = children[i].id.match(options.format); | |
| if (match) { | |
| var child = { | |
| id: encodeURIComponent(match ? match[1] : null), | |
| element: element, | |
| parent: parent, | |
| children: [], | |
| position: parent.children.length, | |
| container: $(children[i]).down(options.treeTag) | |
| }; | |
| child.container && this._tree(child.container, options, child), parent.children.push(child) | |
| } | |
| } | |
| return parent | |
| }, | |
| tree: function (element) { | |
| element = $(element); | |
| var sortableOptions = this.options(element), | |
| options = Object.extend({ | |
| tag: sortableOptions.tag, | |
| treeTag: sortableOptions.treeTag, | |
| only: sortableOptions.only, | |
| name: element.id, | |
| format: sortableOptions.format | |
| }, arguments[1] || {}), | |
| root = { | |
| id: null, | |
| parent: null, | |
| children: [], | |
| container: element, | |
| position: 0 | |
| }; | |
| return Sortable._tree(element, options, root) | |
| }, | |
| _constructIndex: function (node) { | |
| var index = ""; | |
| do node.id && (index = "[" + node.position + "]" + index); while (null != (node = node.parent)); | |
| return index | |
| }, | |
| sequence: function (element) { | |
| element = $(element); | |
| var options = Object.extend(this.options(element), arguments[1] || {}); | |
| return $(this.findElements(element, options) || []).map(function (item) { | |
| return item.id.match(options.format) ? item.id.match(options.format)[1] : "" | |
| }) | |
| }, | |
| setSequence: function (element, new_sequence) { | |
| element = $(element); | |
| var options = Object.extend(this.options(element), arguments[2] || {}), | |
| nodeMap = {}; | |
| this.findElements(element, options).each(function (n) { | |
| n.id.match(options.format) && (nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode]), n.parentNode.removeChild(n) | |
| }), new_sequence.each(function (ident) { | |
| var n = nodeMap[ident]; | |
| n && (n[1].appendChild(n[0]), delete nodeMap[ident]) | |
| }) | |
| }, | |
| serialize: function (element) { | |
| element = $(element); | |
| var options = Object.extend(Sortable.options(element), arguments[1] || {}), | |
| name = encodeURIComponent(arguments[1] && arguments[1].name ? arguments[1].name : element.id); | |
| return options.tree ? Sortable.tree(element, arguments[1]).children.map(function (item) { | |
| return [name + Sortable._constructIndex(item) + "[id]=" + encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)) | |
| }).flatten().join("&") : Sortable.sequence(element, arguments[1]).map(function (item) { | |
| return name + "[]=" + encodeURIComponent(item) | |
| }).join("&") | |
| } | |
| }; | |
| Element.isParent = function (child, element) { | |
| return child.parentNode && child != element ? child.parentNode == element ? !0 : Element.isParent(child.parentNode, element) : !1 | |
| }, Element.findChildren = function (element, only, recursive, tagName) { | |
| if (!element.hasChildNodes()) return null; | |
| tagName = tagName.toUpperCase(), only && (only = [only].flatten()); | |
| var elements = []; | |
| return $A(element.childNodes).each(function (e) { | |
| if (!e.tagName || e.tagName.toUpperCase() != tagName || only && !Element.classNames(e).detect(function (v) { | |
| return only.include(v) | |
| }) || elements.push(e), recursive) { | |
| var grandchildren = Element.findChildren(e, only, recursive, tagName); | |
| grandchildren && elements.push(grandchildren) | |
| } | |
| }), elements.length > 0 ? elements.flatten() : [] | |
| }, Element.offsetSize = function (element, type) { | |
| return element["offset" + ("vertical" == type || "height" == type ? "Height" : "Width")] | |
| }, Date.CultureInfo = { | |
| name: "en-US", | |
| englishName: "English (United States)", | |
| nativeName: "English (United States)", | |
| dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], | |
| abbreviatedDayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], | |
| shortestDayNames: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], | |
| firstLetterDayNames: ["S", "M", "T", "W", "T", "F", "S"], | |
| monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], | |
| abbreviatedMonthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], | |
| amDesignator: "AM", | |
| pmDesignator: "PM", | |
| firstDayOfWeek: 0, | |
| twoDigitYearMax: 2029, | |
| dateElementOrder: "mdy", | |
| formatPatterns: { | |
| shortDate: "M/d/yyyy", | |
| longDate: "dddd, MMMM dd, yyyy", | |
| shortTime: "h:mm tt", | |
| longTime: "h:mm:ss tt", | |
| fullDateTime: "dddd, MMMM dd, yyyy h:mm:ss tt", | |
| sortableDateTime: "yyyy-MM-ddTHH:mm:ss", | |
| universalSortableDateTime: "yyyy-MM-dd HH:mm:ssZ", | |
| rfc1123: "ddd, dd MMM yyyy HH:mm:ss GMT", | |
| monthDay: "MMMM dd", | |
| yearMonth: "MMMM, yyyy" | |
| }, | |
| regexPatterns: { | |
| jan: /^jan(uary)?/i, | |
| feb: /^feb(ruary)?/i, | |
| mar: /^mar(ch)?/i, | |
| apr: /^apr(il)?/i, | |
| may: /^may/i, | |
| jun: /^jun(e)?/i, | |
| jul: /^jul(y)?/i, | |
| aug: /^aug(ust)?/i, | |
| sep: /^sep(t(ember)?)?/i, | |
| oct: /^oct(ober)?/i, | |
| nov: /^nov(ember)?/i, | |
| dec: /^dec(ember)?/i, | |
| sun: /^su(n(day)?)?/i, | |
| mon: /^mo(n(day)?)?/i, | |
| tue: /^tu(e(s(day)?)?)?/i, | |
| wed: /^we(d(nesday)?)?/i, | |
| thu: /^th(u(r(s(day)?)?)?)?/i, | |
| fri: /^fr(i(day)?)?/i, | |
| sat: /^sa(t(urday)?)?/i, | |
| future: /^next/i, | |
| past: /^last|past|prev(ious)?/i, | |
| add: /^(\+|after|from)/i, | |
| subtract: /^(\-|before|ago)/i, | |
| yesterday: /^yesterday/i, | |
| today: /^t(oday)?/i, | |
| tomorrow: /^tomorrow/i, | |
| now: /^n(ow)?/i, | |
| millisecond: /^ms|milli(second)?s?/i, | |
| second: /^sec(ond)?s?/i, | |
| minute: /^min(ute)?s?/i, | |
| hour: /^h(ou)?rs?/i, | |
| week: /^w(ee)?k/i, | |
| month: /^m(o(nth)?s?)?/i, | |
| day: /^d(ays?)?/i, | |
| year: /^y((ea)?rs?)?/i, | |
| shortMeridian: /^(a|p)/i, | |
| longMeridian: /^(a\.?m?\.?|p\.?m?\.?)/i, | |
| timezone: /^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt)/i, | |
| ordinalSuffix: /^\s*(st|nd|rd|th)/i, | |
| timeContext: /^\s*(\:|a|p)/i | |
| }, | |
| abbreviatedTimeZoneStandard: { | |
| GMT: "-000", | |
| EST: "-0400", | |
| CST: "-0500", | |
| MST: "-0600", | |
| PST: "-0700" | |
| }, | |
| abbreviatedTimeZoneDST: { | |
| GMT: "-000", | |
| EDT: "-0500", | |
| CDT: "-0600", | |
| MDT: "-0700", | |
| PDT: "-0800" | |
| } | |
| }, Date.getMonthNumberFromName = function (name) { | |
| for (var n = Date.CultureInfo.monthNames, m = Date.CultureInfo.abbreviatedMonthNames, s = name.toLowerCase(), i = 0; i < n.length; i++) | |
| if (n[i].toLowerCase() == s || m[i].toLowerCase() == s) return i; | |
| return -1 | |
| }, Date.getDayNumberFromName = function (name) { | |
| for (var n = Date.CultureInfo.dayNames, m = Date.CultureInfo.abbreviatedDayNames, s = (Date.CultureInfo.shortestDayNames, name.toLowerCase()), i = 0; i < n.length; i++) | |
| if (n[i].toLowerCase() == s || m[i].toLowerCase() == s) return i; | |
| return -1 | |
| }, Date.isLeapYear = function (year) { | |
| return 0 === year % 4 && 0 !== year % 100 || 0 === year % 400 | |
| }, Date.getDaysInMonth = function (year, month) { | |
| return [31, Date.isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month] | |
| }, Date.getTimezoneOffset = function (s, dst) { | |
| return dst ? Date.CultureInfo.abbreviatedTimeZoneDST[s.toUpperCase()] : Date.CultureInfo.abbreviatedTimeZoneStandard[s.toUpperCase()] | |
| }, Date.getTimezoneAbbreviation = function (offset, dst) { | |
| var p, n = dst ? Date.CultureInfo.abbreviatedTimeZoneDST : Date.CultureInfo.abbreviatedTimeZoneStandard; | |
| for (p in n) | |
| if (n[p] === offset) return p; | |
| return null | |
| }, Date.prototype.clone = function () { | |
| return new Date(this.getTime()) | |
| }, Date.prototype.compareTo = function (date) { | |
| if (isNaN(this)) throw new Error(this); | |
| if (date instanceof Date && !isNaN(date)) return this > date ? 1 : date > this ? -1 : 0; | |
| throw new TypeError(date) | |
| }, Date.prototype.equals = function (date) { | |
| return 0 === this.compareTo(date) | |
| }, Date.prototype.between = function (start, end) { | |
| var t = this.getTime(); | |
| return t >= start.getTime() && t <= end.getTime() | |
| }, Date.prototype.addMilliseconds = function (value) { | |
| return this.setMilliseconds(this.getMilliseconds() + value), this | |
| }, Date.prototype.addSeconds = function (value) { | |
| return this.addMilliseconds(1e3 * value) | |
| }, Date.prototype.addMinutes = function (value) { | |
| return this.addMilliseconds(6e4 * value) | |
| }, Date.prototype.addHours = function (value) { | |
| return this.addMilliseconds(36e5 * value) | |
| }, Date.prototype.addDays = function (value) { | |
| return this.addMilliseconds(864e5 * value) | |
| }, Date.prototype.addWeeks = function (value) { | |
| return this.addMilliseconds(6048e5 * value) | |
| }, Date.prototype.addMonths = function (value) { | |
| var n = this.getDate(); | |
| return this.setDate(1), this.setMonth(this.getMonth() + value), this.setDate(Math.min(n, this.getDaysInMonth())), this | |
| }, Date.prototype.addYears = function (value) { | |
| return this.addMonths(12 * value) | |
| }, Date.prototype.add = function (config) { | |
| if ("number" == typeof config) return this._orient = config, this; | |
| var x = config; | |
| return (x.millisecond || x.milliseconds) && this.addMilliseconds(x.millisecond || x.milliseconds), (x.second || x.seconds) && this.addSeconds(x.second || x.seconds), (x.minute || x.minutes) && this.addMinutes(x.minute || x.minutes), (x.hour || x.hours) && this.addHours(x.hour || x.hours), (x.month || x.months) && this.addMonths(x.month || x.months), (x.year || x.years) && this.addYears(x.year || x.years), (x.day || x.days) && this.addDays(x.day || x.days), this | |
| }, Date._validate = function (value, min, max, name) { | |
| if ("number" != typeof value) throw new TypeError(value + " is not a Number."); | |
| if (min > value || value > max) throw new RangeError(value + " is not a valid value for " + name + "."); | |
| return !0 | |
| }, Date.validateMillisecond = function (n) { | |
| return Date._validate(n, 0, 999, "milliseconds") | |
| }, Date.validateSecond = function (n) { | |
| return Date._validate(n, 0, 59, "seconds") | |
| }, Date.validateMinute = function (n) { | |
| return Date._validate(n, 0, 59, "minutes") | |
| }, Date.validateHour = function (n) { | |
| return Date._validate(n, 0, 23, "hours") | |
| }, Date.validateDay = function (n, year, month) { | |
| return Date._validate(n, 1, Date.getDaysInMonth(year, month), "days") | |
| }, Date.validateMonth = function (n) { | |
| return Date._validate(n, 0, 11, "months") | |
| }, Date.validateYear = function (n) { | |
| return Date._validate(n, 1, 9999, "seconds") | |
| }, Date.prototype.set = function (config) { | |
| var x = config; | |
| return x.millisecond || 0 === x.millisecond || (x.millisecond = -1), x.second || 0 === x.second || (x.second = -1), x.minute || 0 === x.minute || (x.minute = -1), x.hour || 0 === x.hour || (x.hour = -1), x.day || 0 === x.day || (x.day = -1), x.month || 0 === x.month || (x.month = -1), x.year || 0 === x.year || (x.year = -1), -1 != x.millisecond && Date.validateMillisecond(x.millisecond) && this.addMilliseconds(x.millisecond - this.getMilliseconds()), -1 != x.second && Date.validateSecond(x.second) && this.addSeconds(x.second - this.getSeconds()), -1 != x.minute && Date.validateMinute(x.minute) && this.addMinutes(x.minute - this.getMinutes()), -1 != x.hour && Date.validateHour(x.hour) && this.addHours(x.hour - this.getHours()), -1 !== x.month && Date.validateMonth(x.month) && this.addMonths(x.month - this.getMonth()), -1 != x.year && Date.validateYear(x.year) && this.addYears(x.year - this.getFullYear()), -1 != x.day && Date.validateDay(x.day, this.getFullYear(), this.getMonth()) && this.addDays(x.day - this.getDate()), x.timezone && this.setTimezone(x.timezone), x.timezoneOffset && this.setTimezoneOffset(x.timezoneOffset), this | |
| }, Date.prototype.clearTime = function () { | |
| return this.setHours(0), this.setMinutes(0), this.setSeconds(0), this.setMilliseconds(0), this | |
| }, Date.prototype.isLeapYear = function () { | |
| var y = this.getFullYear(); | |
| return 0 === y % 4 && 0 !== y % 100 || 0 === y % 400 | |
| }, Date.prototype.isWeekday = function () { | |
| return !(this.is().sat() || this.is().sun()) | |
| }, Date.prototype.getDaysInMonth = function () { | |
| return Date.getDaysInMonth(this.getFullYear(), this.getMonth()) | |
| }, Date.prototype.moveToFirstDayOfMonth = function () { | |
| return this.set({ | |
| day: 1 | |
| }) | |
| }, Date.prototype.moveToLastDayOfMonth = function () { | |
| return this.set({ | |
| day: this.getDaysInMonth() | |
| }) | |
| }, Date.prototype.moveToDayOfWeek = function (day, orient) { | |
| var diff = (day - this.getDay() + 7 * (orient || 1)) % 7; | |
| return this.addDays(0 === diff ? diff += 7 * (orient || 1) : diff) | |
| }, Date.prototype.moveToMonth = function (month, orient) { | |
| var diff = (month - this.getMonth() + 12 * (orient || 1)) % 12; | |
| return this.addMonths(0 === diff ? diff += 12 * (orient || 1) : diff) | |
| }, Date.prototype.getDayOfYear = function () { | |
| return Math.floor((this - new Date(this.getFullYear(), 0, 1)) / 864e5) | |
| }, Date.prototype.getWeekOfYear = function (firstDayOfWeek) { | |
| var y = this.getFullYear(), | |
| m = this.getMonth(), | |
| d = this.getDate(), | |
| dow = firstDayOfWeek || Date.CultureInfo.firstDayOfWeek, | |
| offset = 8 - new Date(y, 0, 1).getDay(); | |
| 8 == offset && (offset = 1); | |
| var daynum = (Date.UTC(y, m, d, 0, 0, 0) - Date.UTC(y, 0, 1, 0, 0, 0)) / 864e5 + 1, | |
| w = Math.floor((daynum - offset + 7) / 7); | |
| if (w === dow) { | |
| y--; | |
| var prevOffset = 8 - new Date(y, 0, 1).getDay(); | |
| w = 2 == prevOffset || 8 == prevOffset ? 53 : 52 | |
| } | |
| return w | |
| }, Date.prototype.isDST = function () { | |
| return console.log("isDST"), "D" == this.toString().match(/(E|C|M|P)(S|D)T/)[2] | |
| }, Date.prototype.getTimezone = function () { | |
| return Date.getTimezoneAbbreviation(this.getUTCOffset, this.isDST()) | |
| }, Date.prototype.setTimezoneOffset = function (s) { | |
| var here = this.getTimezoneOffset(), | |
| there = -6 * Number(s) / 10; | |
| return this.addMinutes(there - here), this | |
| }, Date.prototype.setTimezone = function (s) { | |
| return this.setTimezoneOffset(Date.getTimezoneOffset(s)) | |
| }, Date.prototype.getUTCOffset = function () { | |
| var r, n = -10 * this.getTimezoneOffset() / 6; | |
| return 0 > n ? (r = (n - 1e4).toString(), r[0] + r.substr(2)) : (r = (n + 1e4).toString(), "+" + r.substr(1)) | |
| }, Date.prototype.getDayName = function (abbrev) { | |
| return abbrev ? Date.CultureInfo.abbreviatedDayNames[this.getDay()] : Date.CultureInfo.dayNames[this.getDay()] | |
| }, Date.prototype.getMonthName = function (abbrev) { | |
| return abbrev ? Date.CultureInfo.abbreviatedMonthNames[this.getMonth()] : Date.CultureInfo.monthNames[this.getMonth()] | |
| }, Date.prototype._toString = Date.prototype.toString, Date.prototype.toString = function (format) { | |
| var self = this, | |
| p = function (s) { | |
| return 1 == s.toString().length ? "0" + s : s | |
| }; | |
| return format ? format.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g, function (format) { | |
| switch (format) { | |
| case "hh": | |
| return p(self.getHours() < 13 ? self.getHours() : self.getHours() - 12); | |
| case "h": | |
| return self.getHours() < 13 ? self.getHours() : self.getHours() - 12; | |
| case "HH": | |
| return p(self.getHours()); | |
| case "H": | |
| return self.getHours(); | |
| case "mm": | |
| return p(self.getMinutes()); | |
| case "m": | |
| return self.getMinutes(); | |
| case "ss": | |
| return p(self.getSeconds()); | |
| case "s": | |
| return self.getSeconds(); | |
| case "yyyy": | |
| return self.getFullYear(); | |
| case "yy": | |
| return self.getFullYear().toString().substring(2, 4); | |
| case "dddd": | |
| return self.getDayName(); | |
| case "ddd": | |
| return self.getDayName(!0); | |
| case "dd": | |
| return p(self.getDate()); | |
| case "d": | |
| return self.getDate().toString(); | |
| case "MMMM": | |
| return self.getMonthName(); | |
| case "MMM": | |
| return self.getMonthName(!0); | |
| case "MM": | |
| return p(self.getMonth() + 1); | |
| case "M": | |
| return self.getMonth() + 1; | |
| case "t": | |
| return self.getHours() < 12 ? Date.CultureInfo.amDesignator.substring(0, 1) : Date.CultureInfo.pmDesignator.substring(0, 1); | |
| case "tt": | |
| return self.getHours() < 12 ? Date.CultureInfo.amDesignator : Date.CultureInfo.pmDesignator; | |
| case "zzz": | |
| case "zz": | |
| case "z": | |
| return "" | |
| } | |
| }) : this._toString() | |
| }, Date.now = function () { | |
| return new Date | |
| }, Date.today = function () { | |
| return Date.now().clearTime() | |
| }, Date.prototype._orient = 1, Date.prototype.next = function () { | |
| return this._orient = 1, this | |
| }, Date.prototype.last = Date.prototype.prev = Date.prototype.previous = function () { | |
| return this._orient = -1, this | |
| }, Date.prototype._is = !1, Date.prototype.is = function () { | |
| return this._is = !0, this | |
| }, Number.prototype._dateElement = "day", Number.prototype.fromNow = function () { | |
| var c = {}; | |
| return c[this._dateElement] = this, Date.now().add(c) | |
| }, Number.prototype.ago = function () { | |
| var c = {}; | |
| return c[this._dateElement] = -1 * this, Date.now().add(c) | |
| }, | |
| function () { | |
| for (var de, $D = Date.prototype, $N = Number.prototype, dx = "sunday monday tuesday wednesday thursday friday saturday".split(/\s/), mx = "january february march april may june july august september october november december".split(/\s/), px = "Millisecond Second Minute Hour Day Week Month Year".split(/\s/), df = function (n) { | |
| return function () { | |
| return this._is ? (this._is = !1, this.getDay() == n) : this.moveToDayOfWeek(n, this._orient) | |
| } | |
| }, i = 0; i < dx.length; i++) $D[dx[i]] = $D[dx[i].substring(0, 3)] = df(i); | |
| for (var mf = function (n) { | |
| return function () { | |
| return this._is ? (this._is = !1, this.getMonth() === n) : this.moveToMonth(n, this._orient) | |
| } | |
| }, j = 0; j < mx.length; j++) $D[mx[j]] = $D[mx[j].substring(0, 3)] = mf(j); | |
| for (var ef = function (j) { | |
| return function () { | |
| return "s" != j.substring(j.length - 1) && (j += "s"), this["add" + j](this._orient) | |
| } | |
| }, nf = function (n) { | |
| return function () { | |
| return this._dateElement = n, this | |
| } | |
| }, k = 0; k < px.length; k++) de = px[k].toLowerCase(), $D[de] = $D[de + "s"] = ef(px[k]), $N[de] = $N[de + "s"] = nf(de) | |
| }(), Date.prototype.toJSONString = function () { | |
| return this.toString("yyyy-MM-ddThh:mm:ssZ") | |
| }, Date.prototype.toShortDateString = function () { | |
| return this.toString(Date.CultureInfo.formatPatterns.shortDatePattern) | |
| }, Date.prototype.toLongDateString = function () { | |
| return this.toString(Date.CultureInfo.formatPatterns.longDatePattern) | |
| }, Date.prototype.toShortTimeString = function () { | |
| return this.toString(Date.CultureInfo.formatPatterns.shortTimePattern) | |
| }, Date.prototype.toLongTimeString = function () { | |
| return this.toString(Date.CultureInfo.formatPatterns.longTimePattern) | |
| }, Date.prototype.getOrdinal = function () { | |
| switch (this.getDate()) { | |
| case 1: | |
| case 21: | |
| case 31: | |
| return "st"; | |
| case 2: | |
| case 22: | |
| return "nd"; | |
| case 3: | |
| case 23: | |
| return "rd"; | |
| default: | |
| return "th" | |
| } | |
| }, | |
| function () { | |
| Date.Parsing = { | |
| Exception: function (s) { | |
| this.message = "Parse error at '" + s.substring(0, 10) + " ...'" | |
| } | |
| }; | |
| for (var $P = Date.Parsing, _ = $P.Operators = { | |
| rtoken: function (r) { | |
| return function (s) { | |
| var mx = s.match(r); | |
| if (mx) return [mx[0], s.substring(mx[0].length)]; | |
| throw new $P.Exception(s) | |
| } | |
| }, | |
| token: function () { | |
| return function (s) { | |
| return _.rtoken(new RegExp("^s*" + s + "s*"))(s) | |
| } | |
| }, | |
| stoken: function (s) { | |
| return _.rtoken(new RegExp("^" + s)) | |
| }, | |
| until: function (p) { | |
| return function (s) { | |
| for (var qx = [], rx = null; s.length;) { | |
| try { | |
| rx = p.call(this, s) | |
| } catch (e) { | |
| qx.push(rx[0]), s = rx[1]; | |
| continue | |
| } | |
| break | |
| } | |
| return [qx, s] | |
| } | |
| }, | |
| many: function (p) { | |
| return function (s) { | |
| for (var rx = [], r = null; s.length;) { | |
| try { | |
| r = p.call(this, s) | |
| } catch (e) { | |
| return [rx, s] | |
| } | |
| rx.push(r[0]), s = r[1] | |
| } | |
| return [rx, s] | |
| } | |
| }, | |
| optional: function (p) { | |
| return function (s) { | |
| var r = null; | |
| try { | |
| r = p.call(this, s) | |
| } catch (e) { | |
| return [null, s] | |
| } | |
| return [r[0], r[1]] | |
| } | |
| }, | |
| not: function (p) { | |
| return function (s) { | |
| try { | |
| p.call(this, s) | |
| } catch (e) { | |
| return [null, s] | |
| } | |
| throw new $P.Exception(s) | |
| } | |
| }, | |
| ignore: function (p) { | |
| return p ? function (s) { | |
| var r = null; | |
| return r = p.call(this, s), [null, r[1]] | |
| } : null | |
| }, | |
| product: function () { | |
| for (var px = arguments[0], qx = Array.prototype.slice.call(arguments, 1), rx = [], i = 0; i < px.length; i++) rx.push(_.each(px[i], qx)); | |
| return rx | |
| }, | |
| cache: function (rule) { | |
| var cache = {}, r = null; | |
| return function (s) { | |
| try { | |
| r = cache[s] = cache[s] || rule.call(this, s) | |
| } catch (e) { | |
| r = cache[s] = e | |
| } | |
| if (r instanceof $P.Exception) throw r; | |
| return r | |
| } | |
| }, | |
| any: function () { | |
| var px = arguments; | |
| return function (s) { | |
| for (var r = null, i = 0; i < px.length; i++) | |
| if (null != px[i]) { | |
| try { | |
| r = px[i].call(this, s) | |
| } catch (e) { | |
| r = null | |
| } | |
| if (r) return r | |
| } | |
| throw new $P.Exception(s) | |
| } | |
| }, | |
| each: function () { | |
| var px = arguments; | |
| return function (s) { | |
| for (var rx = [], r = null, i = 0; i < px.length; i++) | |
| if (null != px[i]) { | |
| try { | |
| r = px[i].call(this, s) | |
| } catch (e) { | |
| throw new $P.Exception(s) | |
| } | |
| rx.push(r[0]), s = r[1] | |
| } | |
| return [rx, s] | |
| } | |
| }, | |
| all: function () { | |
| var px = arguments, | |
| _ = _; | |
| return _.each(_.optional(px)) | |
| }, | |
| sequence: function (px, d, c) { | |
| return d = d || _.rtoken(/^\s*/), c = c || null, 1 == px.length ? px[0] : function (s) { | |
| for (var r = null, q = null, rx = [], i = 0; i < px.length; i++) { | |
| try { | |
| r = px[i].call(this, s) | |
| } catch (e) { | |
| break | |
| } | |
| rx.push(r[0]); | |
| try { | |
| q = d.call(this, r[1]) | |
| } catch (ex) { | |
| q = null; | |
| break | |
| } | |
| s = q[1] | |
| } | |
| if (!r) throw new $P.Exception(s); | |
| if (q) throw new $P.Exception(q[1]); | |
| if (c) try { | |
| r = c.call(this, r[1]) | |
| } catch (ey) { | |
| throw new $P.Exception(r[1]) | |
| } | |
| return [rx, r ? r[1] : s] | |
| } | |
| }, | |
| between: function (d1, p, d2) { | |
| d2 = d2 || d1; | |
| var _fn = _.each(_.ignore(d1), p, _.ignore(d2)); | |
| return function (s) { | |
| var rx = _fn.call(this, s); | |
| return [[rx[0][0], r[0][2]], rx[1]] | |
| } | |
| }, | |
| list: function (p, d, c) { | |
| return d = d || _.rtoken(/^\s*/), c = c || null, p instanceof Array ? _.each(_.product(p.slice(0, -1), _.ignore(d)), p.slice(-1), _.ignore(c)) : _.each(_.many(_.each(p, _.ignore(d))), px, _.ignore(c)) | |
| }, | |
| set: function (px, d, c) { | |
| return d = d || _.rtoken(/^\s*/), c = c || null, | |
| function (s) { | |
| for (var r = null, p = null, q = null, rx = null, best = [ | |
| [], s | |
| ], last = !1, i = 0; i < px.length; i++) { | |
| q = null, p = null, r = null, last = 1 == px.length; | |
| try { | |
| r = px[i].call(this, s) | |
| } catch (e) { | |
| continue | |
| } | |
| if (rx = [ | |
| [r[0]], r[1] | |
| ], r[1].length > 0 && !last) try { | |
| q = d.call(this, r[1]) | |
| } catch (ex) { | |
| last = !0 | |
| } else last = !0; | |
| if (last || 0 !== q[1].length || (last = !0), !last) { | |
| for (var qx = [], j = 0; j < px.length; j++) i != j && qx.push(px[j]); | |
| p = _.set(qx, d).call(this, q[1]), p[0].length > 0 && (rx[0] = rx[0].concat(p[0]), rx[1] = p[1]) | |
| } | |
| if (rx[1].length < best[1].length && (best = rx), 0 === best[1].length) break | |
| } | |
| if (0 === best[0].length) return best; | |
| if (c) { | |
| try { | |
| q = c.call(this, best[1]) | |
| } catch (ey) { | |
| throw new $P.Exception(best[1]) | |
| } | |
| best[1] = q[1] | |
| } | |
| return best | |
| } | |
| }, | |
| forward: function (gr, fname) { | |
| return function (s) { | |
| return gr[fname].call(this, s) | |
| } | |
| }, | |
| replace: function (rule, repl) { | |
| return function (s) { | |
| var r = rule.call(this, s); | |
| return [repl, r[1]] | |
| } | |
| }, | |
| process: function (rule, fn) { | |
| return function (s) { | |
| var r = rule.call(this, s); | |
| return [fn.call(this, r[0]), r[1]] | |
| } | |
| }, | |
| min: function (min, rule) { | |
| return function (s) { | |
| var rx = rule.call(this, s); | |
| if (rx[0].length < min) throw new $P.Exception(s); | |
| return rx | |
| } | |
| } | |
| }, _generator = function (op) { | |
| return function () { | |
| var args = null, | |
| rx = []; | |
| if (arguments.length > 1 ? args = Array.prototype.slice.call(arguments) : arguments[0] instanceof Array && (args = arguments[0]), !args) return op.apply(null, arguments); | |
| for (var i = 0, px = args.shift(); i < px.length; i++) return args.unshift(px[i]), rx.push(op.apply(null, args)), args.shift(), rx | |
| } | |
| }, gx = "optional not ignore cache".split(/\s/), i = 0; i < gx.length; i++) _[gx[i]] = _generator(_[gx[i]]); | |
| for (var _vector = function (op) { | |
| return function () { | |
| return arguments[0] instanceof Array ? op.apply(null, arguments[0]) : op.apply(null, arguments) | |
| } | |
| }, vx = "each any all".split(/\s/), j = 0; j < vx.length; j++) _[vx[j]] = _vector(_[vx[j]]) | |
| }(), | |
| function () { | |
| var flattenAndCompact = function (ax) { | |
| for (var rx = [], i = 0; i < ax.length; i++) ax[i] instanceof Array ? rx = rx.concat(flattenAndCompact(ax[i])) : ax[i] && rx.push(ax[i]); | |
| return rx | |
| }; | |
| Date.Grammar = {}, Date.Translator = { | |
| hour: function (s) { | |
| return function () { | |
| this.hour = Number(s) | |
| } | |
| }, | |
| minute: function (s) { | |
| return function () { | |
| this.minute = Number(s) | |
| } | |
| }, | |
| second: function (s) { | |
| return function () { | |
| this.second = Number(s) | |
| } | |
| }, | |
| meridian: function (s) { | |
| return function () { | |
| this.meridian = s.slice(0, 1).toLowerCase() | |
| } | |
| }, | |
| timezone: function (s) { | |
| return function () { | |
| var n = s.replace(/[^\d\+\-]/g, ""); | |
| n.length ? this.timezoneOffset = Number(n) : this.timezone = s.toLowerCase() | |
| } | |
| }, | |
| day: function (x) { | |
| var s = x[0]; | |
| return function () { | |
| this.day = Number(s.match(/\d+/)[0]) | |
| } | |
| }, | |
| month: function (s) { | |
| return function () { | |
| this.month = 3 == s.length ? Date.getMonthNumberFromName(s) : Number(s) - 1 | |
| } | |
| }, | |
| year: function (s) { | |
| return function () { | |
| var n = Number(s); | |
| this.year = s.length > 2 ? n : n + (n + 2e3 < Date.CultureInfo.twoDigitYearMax ? 2e3 : 1900) | |
| } | |
| }, | |
| rday: function (s) { | |
| return function () { | |
| switch (s) { | |
| case "yesterday": | |
| this.days = -1; | |
| break; | |
| case "tomorrow": | |
| this.days = 1; | |
| break; | |
| case "today": | |
| this.days = 0; | |
| break; | |
| case "now": | |
| this.days = 0, this.now = !0 | |
| } | |
| } | |
| }, | |
| finishExact: function (x) { | |
| x = x instanceof Array ? x : [x]; | |
| var now = new Date; | |
| this.year = now.getFullYear(), this.month = now.getMonth(), this.day = 1, this.hour = 0, this.minute = 0, this.second = 0; | |
| for (var i = 0; i < x.length; i++) x[i] && x[i].call(this); | |
| if (this.hour = "p" == this.meridian && this.hour < 13 ? this.hour + 12 : this.hour, this.day > Date.getDaysInMonth(this.year, this.month)) throw new RangeError(this.day + " is not a valid value for days."); | |
| var r = new Date(this.year, this.month, this.day, this.hour, this.minute, this.second); | |
| return this.timezone ? r.set({ | |
| timezone: this.timezone | |
| }) : this.timezoneOffset && r.set({ | |
| timezoneOffset: this.timezoneOffset | |
| }), r | |
| }, | |
| finish: function (x) { | |
| if (x = x instanceof Array ? flattenAndCompact(x) : [x], 0 === x.length) return null; | |
| for (var i = 0; i < x.length; i++) "function" == typeof x[i] && x[i].call(this); | |
| if (this.now) return new Date; | |
| var today = Date.today(), | |
| expression = !(null == this.days && !this.orient && !this.operator); | |
| if (expression) { | |
| var gap, mod, orient; | |
| return orient = "past" == this.orient || "subtract" == this.operator ? -1 : 1, this.weekday && (this.unit = "day", gap = Date.getDayNumberFromName(this.weekday) - today.getDay(), mod = 7, this.days = gap ? (gap + orient * mod) % mod : orient * mod), this.month && (this.unit = "month", gap = this.month - today.getMonth(), mod = 12, this.months = gap ? (gap + orient * mod) % mod : orient * mod, this.month = null), this.unit || (this.unit = "day"), (null == this[this.unit + "s"] || null != this.operator) && (this.value || (this.value = 1), "week" == this.unit && (this.unit = "day", this.value = 7 * this.value), this[this.unit + "s"] = this.value * orient), today.add(this) | |
| } | |
| return this.meridian && this.hour && (this.hour = this.hour < 13 && "p" == this.meridian ? this.hour + 12 : this.hour), this.weekday && !this.day && (this.day = today.addDays(Date.getDayNumberFromName(this.weekday) - today.getDay()).getDate()), this.month && !this.day && (this.day = 1), today.set(this) | |
| } | |
| }; | |
| var _fn, _ = Date.Parsing.Operators, | |
| g = Date.Grammar, | |
| t = Date.Translator; | |
| g.datePartDelimiter = _.rtoken(/^([\s\-\.\,\/\x27]+)/), g.timePartDelimiter = _.stoken(":"), g.whiteSpace = _.rtoken(/^\s*/), g.generalDelimiter = _.rtoken(/^(([\s\,]|at|on)+)/); | |
| var _C = {}; | |
| g.ctoken = function (keys) { | |
| var fn = _C[keys]; | |
| if (!fn) { | |
| for (var c = Date.CultureInfo.regexPatterns, kx = keys.split(/\s+/), px = [], i = 0; i < kx.length; i++) px.push(_.replace(_.rtoken(c[kx[i]]), kx[i])); | |
| fn = _C[keys] = _.any.apply(null, px) | |
| } | |
| return fn | |
| }, g.ctoken2 = function (key) { | |
| return _.rtoken(Date.CultureInfo.regexPatterns[key]) | |
| }, g.h = _.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2]|[1-9])/), t.hour)), g.hh = _.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2])/), t.hour)), g.H = _.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3]|[0-9])/), t.hour)), g.HH = _.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3])/), t.hour)), g.m = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.minute)), g.mm = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.minute)), g.s = _.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/), t.second)), g.ss = _.cache(_.process(_.rtoken(/^[0-5][0-9]/), t.second)), g.hms = _.cache(_.sequence([g.H, g.mm, g.ss], g.timePartDelimiter)), g.t = _.cache(_.process(g.ctoken2("shortMeridian"), t.meridian)), g.tt = _.cache(_.process(g.ctoken2("longMeridian"), t.meridian)), g.z = _.cache(_.process(_.rtoken(/^(\+|\-)?\s*\d\d\d\d?/), t.timezone)), g.zz = _.cache(_.process(_.rtoken(/^(\+|\-)\s*\d\d\d\d/), t.timezone)), g.zzz = _.cache(_.process(g.ctoken2("timezone"), t.timezone)), g.timeSuffix = _.each(_.ignore(g.whiteSpace), _.set([g.tt, g.zzz])), g.time = _.each(_.optional(_.ignore(_.stoken("T"))), g.hms, g.timeSuffix), g.d = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1]|\d)/), _.optional(g.ctoken2("ordinalSuffix"))), t.day)), g.dd = _.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1])/), _.optional(g.ctoken2("ordinalSuffix"))), t.day)), g.ddd = g.dddd = _.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"), function (s) { | |
| return function () { | |
| this.weekday = s | |
| } | |
| })), g.M = _.cache(_.process(_.rtoken(/^(1[0-2]|0\d|\d)/), t.month)), g.MM = _.cache(_.process(_.rtoken(/^(1[0-2]|0\d)/), t.month)), g.MMM = g.MMMM = _.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"), t.month)), g.y = _.cache(_.process(_.rtoken(/^(\d\d?)/), t.year)), g.yy = _.cache(_.process(_.rtoken(/^(\d\d)/), t.year)), g.yyy = _.cache(_.process(_.rtoken(/^(\d\d?\d?\d?)/), t.year)), g.yyyy = _.cache(_.process(_.rtoken(/^(\d\d\d\d)/), t.year)), _fn = function () { | |
| return _.each(_.any.apply(null, arguments), _.not(g.ctoken2("timeContext"))) | |
| }, g.day = _fn(g.d, g.dd), g.month = _fn(g.M, g.MMM), g.year = _fn(g.yyyy, g.yy), g.orientation = _.process(g.ctoken("past future"), function (s) { | |
| return function () { | |
| this.orient = s | |
| } | |
| }), g.operator = _.process(g.ctoken("add subtract"), function (s) { | |
| return function () { | |
| this.operator = s | |
| } | |
| }), g.rday = _.process(g.ctoken("yesterday tomorrow today now"), t.rday), g.unit = _.process(g.ctoken("minute hour day week month year"), function (s) { | |
| return function () { | |
| this.unit = s | |
| } | |
| }), g.value = _.process(_.rtoken(/^\d\d?(st|nd|rd|th)?/), function (s) { | |
| return function () { | |
| this.value = s.replace(/\D/g, "") | |
| } | |
| }), g.expression = _.set([g.rday, g.operator, g.value, g.unit, g.orientation, g.ddd, g.MMM]), _fn = function () { | |
| return _.set(arguments, g.datePartDelimiter) | |
| }, g.mdy = _fn(g.ddd, g.month, g.day, g.year), g.ymd = _fn(g.ddd, g.year, g.month, g.day), g.dmy = _fn(g.ddd, g.day, g.month, g.year), g.date = function (s) { | |
| return (g[Date.CultureInfo.dateElementOrder] || g.mdy).call(this, s) | |
| }, g.format = _.process(_.many(_.any(_.process(_.rtoken(/^(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/), function (fmt) { | |
| if (g[fmt]) return g[fmt]; | |
| throw Date.Parsing.Exception(fmt) | |
| }), _.process(_.rtoken(/^[^dMyhHmstz]+/), function (s) { | |
| return _.ignore(_.stoken(s)) | |
| }))), function (rules) { | |
| return _.process(_.each.apply(null, rules), t.finishExact) | |
| }); | |
| var _F = {}, _get = function (f) { | |
| return _F[f] = _F[f] || g.format(f)[0] | |
| }; | |
| g.formats = function (fx) { | |
| if (fx instanceof Array) { | |
| for (var rx = [], i = 0; i < fx.length; i++) rx.push(_get(fx[i])); | |
| return _.any.apply(null, rx) | |
| } | |
| return _get(fx) | |
| }, g._formats = g.formats(["yyyy-MM-ddTHH:mm:ss", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "d"]), g._start = _.process(_.set([g.date, g.time, g.expression], g.generalDelimiter, g.whiteSpace), t.finish), g.start = function (s) { | |
| try { | |
| var r = g._formats.call({}, s); | |
| if (0 === r[1].length) return r | |
| } catch (e) {} | |
| return g._start.call({}, s) | |
| } | |
| }(), Date._parse = Date.parse, Date.parse = function (s) { | |
| var r = null; | |
| if (!s) return null; | |
| try { | |
| r = Date.Grammar.start.call({}, s) | |
| } catch (e) { | |
| return null | |
| } | |
| return 0 === r[1].length ? r[0] : null | |
| }, Date.getParseFunction = function (fx) { | |
| var fn = Date.Grammar.formats(fx); | |
| return function (s) { | |
| var r = null; | |
| try { | |
| r = fn.call({}, s) | |
| } catch (e) { | |
| return null | |
| } | |
| return 0 === r[1].length ? r[0] : null | |
| } | |
| }, Date.parseExact = function (s, fx) { | |
| return Date.getParseFunction(fx)(s) | |
| }, | |
| function (context, factory) { | |
| function constructAMD() { | |
| function init() { | |
| var library; | |
| return library = factory("amd"), library.fork = init, library | |
| } | |
| return init() | |
| } | |
| function constructGlobal() { | |
| function init() { | |
| function noConflict() { | |
| var nI, newNamespaces; | |
| for (newNamespaces = Array.prototype.slice.apply(arguments), nI = 0; nI < namespaces.length; nI += 1) "undefined" == typeof previousValues[namespaces[nI]] ? delete context[namespaces[nI]] : context[namespaces[nI]] = previousValues[namespaces[nI]]; | |
| for (previousValues = {}, nI = 0; nI < newNamespaces.length; nI += 1) { | |
| if ("string" != typeof newNamespaces[nI]) throw new Error("Cannot replace namespaces. All new namespaces must be strings."); | |
| previousValues[newNamespaces[nI]] = context[newNamespaces[nI]], context[newNamespaces[nI]] = library | |
| } | |
| return namespaces = newNamespaces | |
| } | |
| var library, namespaces = [], | |
| previousValues = {}; | |
| return library = factory("global"), library.fork = init, library.noConflict = noConflict, library | |
| } | |
| var library; | |
| library = init(), library.noConflict("KeyboardJS", "k") | |
| }[].indexOf || (Array.prototype.indexOf = function (a, b, c) { | |
| for (c = this.length, b = (c + ~~b) % c; c > b && (!(b in this) || this[b] !== a); b++); | |
| return b ^ c ? b : -1 | |
| }), "function" == typeof define && define.amd ? define(constructAMD) : constructGlobal() | |
| }(this, function () { | |
| function enable() { | |
| window.addEventListener ? (document.addEventListener("keydown", keydown, !1), document.addEventListener("keyup", keyup, !1), window.addEventListener("blur", reset, !1), window.addEventListener("webkitfullscreenchange", reset, !1), window.addEventListener("mozfullscreenchange", reset, !1)) : window.attachEvent && (document.attachEvent("onkeydown", keydown), document.attachEvent("onkeyup", keyup), window.attachEvent("onblur", reset)) | |
| } | |
| function disable() { | |
| reset(), window.removeEventListener ? (document.removeEventListener("keydown", keydown, !1), document.removeEventListener("keyup", keyup, !1), window.removeEventListener("blur", reset, !1), window.removeEventListener("webkitfullscreenchange", reset, !1), window.removeEventListener("mozfullscreenchange", reset, !1)) : window.detachEvent && (document.detachEvent("onkeydown", keydown), document.detachEvent("onkeyup", keyup), window.detachEvent("onblur", reset)) | |
| } | |
| function reset(event) { | |
| activeKeys = [], pruneMacros(), pruneBindings(event) | |
| } | |
| function keydown(event) { | |
| var keyNames, kI; | |
| if (keyNames = getKeyName(event.keyCode), !(keyNames.length < 1)) { | |
| for (kI = 0; kI < keyNames.length; kI += 1) addActiveKey(keyNames[kI]); | |
| executeMacros(), executeBindings(event) | |
| } | |
| } | |
| function keyup(event) { | |
| var keyNames, kI; | |
| if (keyNames = getKeyName(event.keyCode), !(keyNames.length < 1)) { | |
| for (kI = 0; kI < keyNames.length; kI += 1) removeActiveKey(keyNames[kI]); | |
| pruneMacros(), pruneBindings(event) | |
| } | |
| } | |
| function getKeyName(keyCode) { | |
| return map[keyCode] || [] | |
| } | |
| function getKeyCode(keyName) { | |
| var keyCode; | |
| for (keyCode in map) | |
| if (map.hasOwnProperty(keyCode) && map[keyCode].indexOf(keyName) > -1) return keyCode; | |
| return !1 | |
| } | |
| function createMacro(combo, injectedKeys) { | |
| if ("string" != typeof combo && ("object" != typeof combo || "function" != typeof combo.push)) throw new Error("Cannot create macro. The combo must be a string or array."); | |
| if ("object" != typeof injectedKeys || "function" != typeof injectedKeys.push) throw new Error("Cannot create macro. The injectedKeys must be an array."); | |
| macros.push([combo, injectedKeys]) | |
| } | |
| function removeMacro(combo) { | |
| var macro; | |
| if ("string" != typeof combo && ("object" != typeof combo || "function" != typeof combo.push)) throw new Error("Cannot remove macro. The combo must be a string or array."); | |
| for (mI = 0; mI < macros.length; mI += 1) | |
| if (macro = macros[mI], compareCombos(combo, macro[0])) { | |
| removeActiveKey(macro[1]), macros.splice(mI, 1); | |
| break | |
| } | |
| } | |
| function executeMacros() { | |
| var mI, combo, kI; | |
| for (mI = 0; mI < macros.length; mI += 1) | |
| if (combo = parseKeyCombo(macros[mI][0]), -1 === activeMacros.indexOf(macros[mI]) && isSatisfiedCombo(combo)) | |
| for (activeMacros.push(macros[mI]), kI = 0; kI < macros[mI][1].length; kI += 1) addActiveKey(macros[mI][1][kI]) | |
| } | |
| function pruneMacros() { | |
| var mI, combo, kI; | |
| for (mI = 0; mI < activeMacros.length; mI += 1) | |
| if (combo = parseKeyCombo(activeMacros[mI][0]), isSatisfiedCombo(combo) === !1) { | |
| for (kI = 0; kI < activeMacros[mI][1].length; kI += 1) removeActiveKey(activeMacros[mI][1][kI]); | |
| activeMacros.splice(mI, 1), mI -= 1 | |
| } | |
| } | |
| function createBinding(keyCombo, keyDownCallback, keyUpCallback) { | |
| function clear() { | |
| var bI; | |
| for (bI = 0; bI < subBindings.length; bI += 1) bindings.splice(bindings.indexOf(subBindings[bI]), 1) | |
| } | |
| function on(eventName) { | |
| function clear() { | |
| var cI, bI; | |
| for (cI = 0; cI < callbacks.length; cI += 1) | |
| if ("function" == typeof callbacks[cI]) | |
| if ("keyup" === eventName) | |
| for (bI = 0; bI < subBindings.length; bI += 1) subBindings[bI].keyUpCallback.splice(subBindings[bI].keyUpCallback.indexOf(callbacks[cI]), 1); | |
| else | |
| for (bI = 0; bI < subBindings.length; bI += 1) subBindings[bI].keyDownCallback.splice(subBindings[bI].keyDownCallback.indexOf(callbacks[cI]), 1) | |
| } | |
| var callbacks, cI, bI, api = {}; | |
| if ("string" != typeof eventName) throw new Error("Cannot bind callback. The event name must be a string."); | |
| if ("keyup" !== eventName && "keydown" !== eventName) throw new Error('Cannot bind callback. The event name must be a "keyup" or "keydown".'); | |
| for (callbacks = Array.prototype.slice.apply(arguments, [1]), cI = 0; cI < callbacks.length; cI += 1) | |
| if ("function" == typeof callbacks[cI]) | |
| if ("keyup" === eventName) | |
| for (bI = 0; bI < subBindings.length; bI += 1) subBindings[bI].keyUpCallback.push(callbacks[cI]); | |
| else if ("keydown" === eventName) | |
| for (bI = 0; bI < subBindings.length; bI += 1) subBindings[bI].keyDownCallback.push(callbacks[cI]); | |
| return api.clear = clear, api | |
| } | |
| var binding, kI, subCombo, api = {}, subBindings = []; | |
| for ("string" == typeof keyCombo && (keyCombo = parseKeyCombo(keyCombo)), kI = 0; kI < keyCombo.length; kI += 1) { | |
| if (binding = {}, subCombo = stringifyKeyCombo([keyCombo[kI]]), "string" != typeof subCombo) throw new Error("Failed to bind key combo. The key combo must be string."); | |
| binding.keyCombo = subCombo, binding.keyDownCallback = [], binding.keyUpCallback = [], keyDownCallback && binding.keyDownCallback.push(keyDownCallback), keyUpCallback && binding.keyUpCallback.push(keyUpCallback), bindings.push(binding), subBindings.push(binding) | |
| } | |
| return api.clear = clear, api.on = on, api | |
| } | |
| function removeBindingByKeyCombo(keyCombo) { | |
| var bI, binding; | |
| for (bI = 0; bI < bindings.length; bI += 1) binding = bindings[bI], compareCombos(keyCombo, binding.keyCombo) && (bindings.splice(bI, 1), bI -= 1) | |
| } | |
| function removeBindingByKeyName(keyName) { | |
| var bI, cI, binding; | |
| if (keyName) { | |
| for (bI = 0; bI < bindings.length; bI += 1) | |
| for (binding = bindings[bI], cI = 0; cI < binding.keyCombo.length; cI += 1) | |
| if (binding.keyCombo[kI].indexOf(keyName) > -1) { | |
| bindings.splice(bI, 1), bI -= 1; | |
| break | |
| } | |
| } else bindings = [] | |
| } | |
| function executeBindings(event) { | |
| var bI, sBI, binding, remainingKeys, cI, killEventBubble, kI, bindingKeysSatisfied, index, bindingWeight, sortedBindings = []; | |
| for (remainingKeys = [].concat(activeKeys), bI = 0; bI < bindings.length; bI += 1) bindingWeight = extractComboKeys(bindings[bI].keyCombo).length, sortedBindings[bindingWeight] || (sortedBindings[bindingWeight] = []), sortedBindings[bindingWeight].push(bindings[bI]); | |
| for (sBI = sortedBindings.length - 1; sBI >= 0; sBI -= 1) | |
| if (sortedBindings[sBI]) | |
| for (bI = 0; bI < sortedBindings[sBI].length; bI += 1) { | |
| for (binding = sortedBindings[sBI][bI], bindingKeys = extractComboKeys(binding.keyCombo), bindingKeysSatisfied = !0, kI = 0; kI < bindingKeys.length; kI += 1) | |
| if (-1 === remainingKeys.indexOf(bindingKeys[kI])) { | |
| bindingKeysSatisfied = !1; | |
| break | |
| } | |
| if (bindingKeysSatisfied && isSatisfiedCombo(binding.keyCombo)) { | |
| for (activeBindings.push(binding), kI = 0; kI < bindingKeys.length; kI += 1) index = remainingKeys.indexOf(bindingKeys[kI]), index > -1 && (remainingKeys.splice(index, 1), kI -= 1); | |
| for (cI = 0; cI < binding.keyDownCallback.length; cI += 1) binding.keyDownCallback[cI](event, getActiveKeys(), binding.keyCombo) === !1 && (killEventBubble = !0); | |
| killEventBubble === !0 && (event.preventDefault(), event.stopPropagation()) | |
| } | |
| } | |
| } | |
| function pruneBindings(event) { | |
| var bI, cI, binding, killEventBubble; | |
| for (bI = 0; bI < activeBindings.length; bI += 1) | |
| if (binding = activeBindings[bI], isSatisfiedCombo(binding.keyCombo) === !1) { | |
| for (cI = 0; cI < binding.keyUpCallback.length; cI += 1) binding.keyUpCallback[cI](event, getActiveKeys(), binding.keyCombo) === !1 && (killEventBubble = !0); | |
| killEventBubble === !0 && (event.preventDefault(), event.stopPropagation()), activeBindings.splice(bI, 1), bI -= 1 | |
| } | |
| } | |
| function compareCombos(keyComboArrayA, keyComboArrayB) { | |
| var cI, sI, kI; | |
| if (keyComboArrayA = parseKeyCombo(keyComboArrayA), keyComboArrayB = parseKeyCombo(keyComboArrayB), keyComboArrayA.length !== keyComboArrayB.length) return !1; | |
| for (cI = 0; cI < keyComboArrayA.length; cI += 1) { | |
| if (keyComboArrayA[cI].length !== keyComboArrayB[cI].length) return !1; | |
| for (sI = 0; sI < keyComboArrayA[cI].length; sI += 1) { | |
| if (keyComboArrayA[cI][sI].length !== keyComboArrayB[cI][sI].length) return !1; | |
| for (kI = 0; kI < keyComboArrayA[cI][sI].length; kI += 1) | |
| if (-1 === keyComboArrayB[cI][sI].indexOf(keyComboArrayA[cI][sI][kI])) return !1 | |
| } | |
| } | |
| return !0 | |
| } | |
| function isSatisfiedCombo(keyCombo) { | |
| var cI, sI, stage, kI, index, comboMatches, stageOffset = 0; | |
| for (keyCombo = parseKeyCombo(keyCombo), cI = 0; cI < keyCombo.length; cI += 1) { | |
| for (comboMatches = !0, stageOffset = 0, sI = 0; sI < keyCombo[cI].length; sI += 1) { | |
| for (stage = [].concat(keyCombo[cI][sI]), kI = stageOffset; kI < activeKeys.length; kI += 1) index = stage.indexOf(activeKeys[kI]), index > -1 && (stage.splice(index, 1), stageOffset = kI); | |
| if (0 !== stage.length) { | |
| comboMatches = !1; | |
| break | |
| } | |
| } | |
| if (comboMatches) return !0 | |
| } | |
| return !1 | |
| } | |
| function extractComboKeys(keyCombo) { | |
| var cI, sI, keys = []; | |
| for (keyCombo = parseKeyCombo(keyCombo), cI = 0; cI < keyCombo.length; cI += 1) | |
| for (sI = 0; sI < keyCombo[cI].length; sI += 1) keys = keys.concat(keyCombo[cI][sI]); | |
| return keys | |
| } | |
| function parseKeyCombo(keyCombo) { | |
| var s = keyCombo, | |
| i = 0, | |
| op = 0, | |
| ws = !1, | |
| nc = !1, | |
| combos = [], | |
| combo = [], | |
| stage = [], | |
| key = ""; | |
| if ("object" == typeof keyCombo && "function" == typeof keyCombo.push) return keyCombo; | |
| if ("string" != typeof keyCombo) throw new Error('Cannot parse "keyCombo" because its type is "' + typeof keyCombo + '". It must be a "string".'); | |
| for (; | |
| " " === s.charAt(i);) i += 1; | |
| for (;;) { | |
| if (" " === s.charAt(i)) { | |
| for (; | |
| " " === s.charAt(i);) i += 1; | |
| ws = !0 | |
| } else if ("," === s.charAt(i)) { | |
| if (op || nc) throw new Error("Failed to parse key combo. Unexpected , at character index " + i + "."); | |
| nc = !0, i += 1 | |
| } else if ("+" === s.charAt(i)) { | |
| if (key.length && (stage.push(key), key = ""), op || nc) throw new Error("Failed to parse key combo. Unexpected + at character index " + i + "."); | |
| op = !0, i += 1 | |
| } else if (">" === s.charAt(i)) { | |
| if (key.length && (stage.push(key), key = ""), stage.length && (combo.push(stage), stage = []), op || nc) throw new Error("Failed to parse key combo. Unexpected > at character index " + i + "."); | |
| op = !0, i += 1 | |
| } else if (i < s.length - 1 && "!" === s.charAt(i) && (">" === s.charAt(i + 1) || "," === s.charAt(i + 1) || "+" === s.charAt(i + 1))) key += s.charAt(i + 1), op = !1, ws = !1, nc = !1, i += 2; | |
| else { | |
| if (!(i < s.length && "+" !== s.charAt(i) && ">" !== s.charAt(i) && "," !== s.charAt(i) && " " !== s.charAt(i))) { | |
| i += 1; | |
| continue | |
| } | |
| for ((op === !1 && ws === !0 || nc === !0) && (key.length && (stage.push(key), key = ""), stage.length && (combo.push(stage), stage = []), combo.length && (combos.push(combo), combo = [])), op = !1, ws = !1, nc = !1; i < s.length && "+" !== s.charAt(i) && ">" !== s.charAt(i) && "," !== s.charAt(i) && " " !== s.charAt(i);) key += s.charAt(i), i += 1 | |
| } if (i >= s.length) { | |
| key.length && (stage.push(key), key = ""), stage.length && (combo.push(stage), stage = []), combo.length && (combos.push(combo), combo = []); | |
| break | |
| } | |
| } | |
| return combos | |
| } | |
| function stringifyKeyCombo(keyComboArray) { | |
| var cI, ccI, output = []; | |
| if ("string" == typeof keyComboArray) return keyComboArray; | |
| if ("object" != typeof keyComboArray || "function" != typeof keyComboArray.push) throw new Error("Cannot stringify key combo."); | |
| for (cI = 0; cI < keyComboArray.length; cI += 1) { | |
| for (output[cI] = [], ccI = 0; ccI < keyComboArray[cI].length; ccI += 1) output[cI][ccI] = keyComboArray[cI][ccI].join(" + "); | |
| output[cI] = output[cI].join(" > ") | |
| } | |
| return output.join(" ") | |
| } | |
| function getActiveKeys() { | |
| return [].concat(activeKeys) | |
| } | |
| function addActiveKey(keyName) { | |
| if (keyName.match(/\s/)) throw new Error("Cannot add key name " + keyName + " to active keys because it contains whitespace."); | |
| activeKeys.indexOf(keyName) > -1 || activeKeys.push(keyName) | |
| } | |
| function removeActiveKey(keyName) { | |
| var keyCode = getKeyCode(keyName); | |
| "91" === keyCode || "92" === keyCode ? activeKeys = [] : activeKeys.splice(activeKeys.indexOf(keyName), 1) | |
| } | |
| function registerLocale(localeName, localeMap) { | |
| if ("string" != typeof localeName) throw new Error("Cannot register new locale. The locale name must be a string."); | |
| if ("object" != typeof localeMap) throw new Error("Cannot register " + localeName + " locale. The locale map must be an object."); | |
| if ("object" != typeof localeMap.map) throw new Error("Cannot register " + localeName + " locale. The locale map is invalid."); | |
| localeMap.macros || (localeMap.macros = []), locales[localeName] = localeMap | |
| } | |
| function getSetLocale(localeName) { | |
| if (localeName) { | |
| if ("string" != typeof localeName) throw new Error("Cannot set locale. The locale name must be a string."); | |
| if (!locales[localeName]) throw new Error("Cannot set locale to " + localeName + " because it does not exist. If you would like to submit a " + localeName + " locale map for KeyboardJS please submit it at https://github.com/RobertWHurst/KeyboardJS/issues."); | |
| map = locales[localeName].map, macros = locales[localeName].macros, locale = localeName | |
| } | |
| return locale | |
| } | |
| var locale, map, macros, aI, usLocale, KeyboardJS = {}, locales = {}, activeKeys = [], | |
| bindings = [], | |
| activeBindings = [], | |
| activeMacros = []; | |
| for (usLocale = { | |
| map: { | |
| 3: ["cancel"], | |
| 8: ["backspace"], | |
| 9: ["tab"], | |
| 12: ["clear"], | |
| 13: ["enter"], | |
| 16: ["shift"], | |
| 17: ["ctrl"], | |
| 18: ["alt", "menu"], | |
| 19: ["pause", "break"], | |
| 20: ["capslock"], | |
| 27: ["escape", "esc"], | |
| 32: ["space", "spacebar"], | |
| 33: ["pageup"], | |
| 34: ["pagedown"], | |
| 35: ["end"], | |
| 36: ["home"], | |
| 37: ["left"], | |
| 38: ["up"], | |
| 39: ["right"], | |
| 40: ["down"], | |
| 41: ["select"], | |
| 42: ["printscreen"], | |
| 43: ["execute"], | |
| 44: ["snapshot"], | |
| 45: ["insert", "ins"], | |
| 46: ["delete", "del"], | |
| 47: ["help"], | |
| 91: ["command", "windows", "win", "super", "leftcommand", "leftwindows", "leftwin", "leftsuper"], | |
| 92: ["command", "windows", "win", "super", "rightcommand", "rightwindows", "rightwin", "rightsuper"], | |
| 145: ["scrolllock", "scroll"], | |
| 186: ["semicolon", ";"], | |
| 187: ["equal", "equalsign", "="], | |
| 188: ["comma", ","], | |
| 189: ["dash", "-"], | |
| 190: ["period", "."], | |
| 191: ["slash", "forwardslash", "/"], | |
| 192: ["graveaccent", "`"], | |
| 219: ["openbracket", "["], | |
| 220: ["backslash", "\\"], | |
| 221: ["closebracket", "]"], | |
| 222: ["apostrophe", "'"], | |
| 48: ["zero", "0"], | |
| 49: ["one", "1"], | |
| 50: ["two", "2"], | |
| 51: ["three", "3"], | |
| 52: ["four", "4"], | |
| 53: ["five", "5"], | |
| 54: ["six", "6"], | |
| 55: ["seven", "7"], | |
| 56: ["eight", "8"], | |
| 57: ["nine", "9"], | |
| 96: ["numzero", "num0"], | |
| 97: ["numone", "num1"], | |
| 98: ["numtwo", "num2"], | |
| 99: ["numthree", "num3"], | |
| 100: ["numfour", "num4"], | |
| 101: ["numfive", "num5"], | |
| 102: ["numsix", "num6"], | |
| 103: ["numseven", "num7"], | |
| 104: ["numeight", "num8"], | |
| 105: ["numnine", "num9"], | |
| 106: ["nummultiply", "num*"], | |
| 107: ["numadd", "num+"], | |
| 108: ["numenter"], | |
| 109: ["numsubtract", "num-"], | |
| 110: ["numdecimal", "num."], | |
| 111: ["numdevide", "num/"], | |
| 144: ["numlock", "num"], | |
| 112: ["f1"], | |
| 113: ["f2"], | |
| 114: ["f3"], | |
| 115: ["f4"], | |
| 116: ["f5"], | |
| 117: ["f6"], | |
| 118: ["f7"], | |
| 119: ["f8"], | |
| 120: ["f9"], | |
| 121: ["f10"], | |
| 122: ["f11"], | |
| 123: ["f12"] | |
| }, | |
| macros: [ | |
| ["shift + `", ["tilde", "~"]], | |
| ["shift + 1", ["exclamation", "exclamationpoint", "!"]], | |
| ["shift + 2", ["at", "@"]], | |
| ["shift + 3", ["number", "#"]], | |
| ["shift + 4", ["dollar", "dollars", "dollarsign", "$"]], | |
| ["shift + 5", ["percent", "%"]], | |
| ["shift + 6", ["caret", "^"]], | |
| ["shift + 7", ["ampersand", "and", "&"]], | |
| ["shift + 8", ["asterisk", "*"]], | |
| ["shift + 9", ["openparen", "("]], | |
| ["shift + 0", ["closeparen", ")"]], | |
| ["shift + -", ["underscore", "_"]], | |
| ["shift + =", ["plus", "+"]], | |
| ["shift + (", ["opencurlybrace", "opencurlybracket", "{"]], | |
| ["shift + )", ["closecurlybrace", "closecurlybracket", "}"]], | |
| ["shift + \\", ["verticalbar", "|"]], | |
| ["shift + ;", ["colon", ":"]], | |
| ["shift + '", ["quotationmark", '"']], | |
| ["shift + !,", ["openanglebracket", "<"]], | |
| ["shift + .", ["closeanglebracket", ">"]], | |
| ["shift + /", ["questionmark", "?"]] | |
| ] | |
| }, aI = 65; 90 >= aI; aI += 1) usLocale.map[aI] = String.fromCharCode(aI + 32), usLocale.macros.push(["shift + " + String.fromCharCode(aI + 32) + ", capslock + " + String.fromCharCode(aI + 32), [String.fromCharCode(aI)]]); | |
| return registerLocale("us", usLocale), getSetLocale("us"), enable(), KeyboardJS.enable = enable, KeyboardJS.disable = disable, KeyboardJS.activeKeys = getActiveKeys, KeyboardJS.on = createBinding, KeyboardJS.clear = removeBindingByKeyCombo, KeyboardJS.clear.key = removeBindingByKeyName, KeyboardJS.locale = getSetLocale, KeyboardJS.locale.register = registerLocale, KeyboardJS.macro = createMacro, KeyboardJS.macro.remove = removeMacro, KeyboardJS.key = {}, KeyboardJS.key.name = getKeyName, KeyboardJS.key.code = getKeyCode, KeyboardJS.combo = {}, KeyboardJS.combo.active = isSatisfiedCombo, KeyboardJS.combo.parse = parseKeyCombo, KeyboardJS.combo.stringify = stringifyKeyCombo, KeyboardJS | |
| }), Number.prototype.toHexStr = function () { | |
| for (var v, s = "", i = 7; i >= 0; i--) v = 15 & this >>> 4 * i, s += v.toString(16); | |
| return s | |
| }, String.prototype.toSHA1 = function () { | |
| return hash_SHA1(this) | |
| }, | |
| function (a, b) { | |
| "use strict"; | |
| var c = a.History = a.History || {}; | |
| if ("undefined" != typeof c.Adapter) throw new Error("History.js Adapter has already been loaded..."); | |
| c.Adapter = { | |
| handlers: {}, | |
| _uid: 1, | |
| uid: function (a) { | |
| return a._uid || (a._uid = c.Adapter._uid++) | |
| }, | |
| bind: function (a, b, d) { | |
| var e = c.Adapter.uid(a); | |
| c.Adapter.handlers[e] = c.Adapter.handlers[e] || {}, c.Adapter.handlers[e][b] = c.Adapter.handlers[e][b] || [], c.Adapter.handlers[e][b].push(d), a["on" + b] = function (a, b) { | |
| return function (d) { | |
| c.Adapter.trigger(a, b, d) | |
| } | |
| }(a, b) | |
| }, | |
| trigger: function (a, b, d) { | |
| d = d || {}; | |
| var f, g, e = c.Adapter.uid(a); | |
| for (c.Adapter.handlers[e] = c.Adapter.handlers[e] || {}, c.Adapter.handlers[e][b] = c.Adapter.handlers[e][b] || [], f = 0, g = c.Adapter.handlers[e][b].length; g > f; ++f) c.Adapter.handlers[e][b][f].apply(this, [d]) | |
| }, | |
| extractEventData: function (a, c) { | |
| var d = c && c[a] || b; | |
| return d | |
| }, | |
| onDomLoad: function (b) { | |
| var c = a.setTimeout(function () { | |
| b() | |
| }, 2e3); | |
| a.onload = function () { | |
| clearTimeout(c), b() | |
| } | |
| } | |
| }, "undefined" != typeof c.init && c.init() | |
| }(window), | |
| function (a, b) { | |
| "use strict"; | |
| var c = a.console || b, | |
| d = a.document, | |
| e = a.navigator, | |
| f = a.sessionStorage || !1, | |
| g = a.setTimeout, | |
| h = a.clearTimeout, | |
| i = a.setInterval, | |
| j = a.clearInterval, | |
| k = a.JSON, | |
| l = a.alert, | |
| m = a.History = a.History || {}, n = a.history; | |
| if (k.stringify = k.stringify || k.encode, k.parse = k.parse || k.decode, "undefined" != typeof m.init) throw new Error("History.js Core has already been loaded..."); | |
| m.init = function () { | |
| return "undefined" == typeof m.Adapter ? !1 : ("undefined" != typeof m.initCore && m.initCore(), "undefined" != typeof m.initHtml4 && m.initHtml4(), !0) | |
| }, m.initCore = function () { | |
| if ("undefined" != typeof m.initCore.initialized) return !1; | |
| if (m.initCore.initialized = !0, m.options = m.options || {}, m.options.hashChangeInterval = m.options.hashChangeInterval || 100, m.options.safariPollInterval = m.options.safariPollInterval || 500, m.options.doubleCheckInterval = m.options.doubleCheckInterval || 500, m.options.storeInterval = m.options.storeInterval || 1e3, m.options.busyDelay = m.options.busyDelay || 250, m.options.debug = m.options.debug || !1, m.options.initialTitle = m.options.initialTitle || d.title, m.intervalList = [], m.clearAllIntervals = function () { | |
| var a, b = m.intervalList; | |
| if ("undefined" != typeof b && null !== b) { | |
| for (a = 0; a < b.length; a++) j(b[a]); | |
| m.intervalList = null | |
| } | |
| }, m.debug = function () { | |
| (m.options.debug || !1) && m.log.apply(m, arguments) | |
| }, m.log = function () { | |
| var e, f, g, h, i, a = "undefined" != typeof c && "undefined" != typeof c.log && "undefined" != typeof c.log.apply, | |
| b = d.getElementById("log"); | |
| for (a ? (h = Array.prototype.slice.call(arguments), e = h.shift(), "undefined" != typeof c.debug ? c.debug.apply(c, [e, h]) : c.log.apply(c, [e, h])) : e = "\n" + arguments[0] + "\n", f = 1, g = arguments.length; g > f; ++f) { | |
| if (i = arguments[f], "object" == typeof i && "undefined" != typeof k) try { | |
| i = k.stringify(i) | |
| } catch (j) {} | |
| e += "\n" + i + "\n" | |
| } | |
| return b ? (b.value += e + "\n-----\n", b.scrollTop = b.scrollHeight - b.clientHeight) : a || l(e), !0 | |
| }, m.getInternetExplorerMajorVersion = function () { | |
| var a = m.getInternetExplorerMajorVersion.cached = "undefined" != typeof m.getInternetExplorerMajorVersion.cached ? m.getInternetExplorerMajorVersion.cached : function () { | |
| for (var a = 3, b = d.createElement("div"), c = b.getElementsByTagName("i"); | |
| (b.innerHTML = "<!--[if gt IE " + ++a + "]><i></i><![endif]-->") && c[0];); | |
| return a > 4 ? a : !1 | |
| }(); | |
| return a | |
| }, m.isInternetExplorer = function () { | |
| var a = m.isInternetExplorer.cached = "undefined" != typeof m.isInternetExplorer.cached ? m.isInternetExplorer.cached : Boolean(m.getInternetExplorerMajorVersion()); | |
| return a | |
| }, m.emulated = { | |
| pushState: !Boolean(a.history && a.history.pushState && a.history.replaceState && !/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(e.userAgent) && !/AppleWebKit\/5([0-2]|3[0-2])/i.test(e.userAgent)), | |
| hashChange: Boolean(!("onhashchange" in a || "onhashchange" in d) || m.isInternetExplorer() && m.getInternetExplorerMajorVersion() < 8) | |
| }, m.enabled = !m.emulated.pushState, m.bugs = { | |
| setHash: Boolean(!m.emulated.pushState && "Apple Computer, Inc." === e.vendor && /AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)), | |
| safariPoll: Boolean(!m.emulated.pushState && "Apple Computer, Inc." === e.vendor && /AppleWebKit\/5([0-2]|3[0-3])/.test(e.userAgent)), | |
| ieDoubleCheck: Boolean(m.isInternetExplorer() && m.getInternetExplorerMajorVersion() < 8), | |
| hashEscape: Boolean(m.isInternetExplorer() && m.getInternetExplorerMajorVersion() < 7) | |
| }, m.isEmptyObject = function (a) { | |
| for (var b in a) return !1; | |
| return !0 | |
| }, m.cloneObject = function (a) { | |
| var b, c; | |
| return a ? (b = k.stringify(a), c = k.parse(b)) : c = {}, c | |
| }, m.getRootUrl = function () { | |
| var a = d.location.protocol + "//" + (d.location.hostname || d.location.host); | |
| return d.location.port && (a += ":" + d.location.port), a += "/" | |
| }, m.getBaseHref = function () { | |
| var a = d.getElementsByTagName("base"), | |
| b = null, | |
| c = ""; | |
| return 1 === a.length && (b = a[0], c = b.href.replace(/[^\/]+$/, "")), c = c.replace(/\/+$/, ""), c && (c += "/"), c | |
| }, m.getBaseUrl = function () { | |
| var a = m.getBaseHref() || m.getBasePageUrl() || m.getRootUrl(); | |
| return a | |
| }, m.getPageUrl = function () { | |
| var c, a = m.getState(!1, !1), | |
| b = (a || {}).url || d.location.href; | |
| return c = b.replace(/\/+$/, "").replace(/[^\/]+$/, function (a) { | |
| return /\./.test(a) ? a : a + "/" | |
| }) | |
| }, m.getBasePageUrl = function () { | |
| var a = d.location.href.replace(/[#\?].*/, "").replace(/[^\/]+$/, function (a) { | |
| return /[^\/]$/.test(a) ? "" : a | |
| }).replace(/\/+$/, "") + "/"; | |
| return a | |
| }, m.getFullUrl = function (a, b) { | |
| var c = a, | |
| d = a.substring(0, 1); | |
| return b = "undefined" == typeof b ? !0 : b, /[a-z]+\:\/\//.test(a) || (c = "/" === d ? m.getRootUrl() + a.replace(/^\/+/, "") : "#" === d ? m.getPageUrl().replace(/#.*/, "") + a : "?" === d ? m.getPageUrl().replace(/[\?#].*/, "") + a : b ? m.getBaseUrl() + a.replace(/^(\.\/)+/, "") : m.getBasePageUrl() + a.replace(/^(\.\/)+/, "")), c.replace(/\#$/, "") | |
| }, m.getShortUrl = function (a) { | |
| var b = a, | |
| c = m.getBaseUrl(), | |
| d = m.getRootUrl(); | |
| return m.emulated.pushState && (b = b.replace(c, "")), b = b.replace(d, "/"), m.isTraditionalAnchor(b) && (b = "./" + b), b = b.replace(/^(\.\/)+/g, "./").replace(/\#$/, "") | |
| }, m.store = {}, m.idToState = m.idToState || {}, m.stateToId = m.stateToId || {}, m.urlToId = m.urlToId || {}, m.storedStates = m.storedStates || [], m.savedStates = m.savedStates || [], m.normalizeStore = function () { | |
| m.store.idToState = m.store.idToState || {}, m.store.urlToId = m.store.urlToId || {}, m.store.stateToId = m.store.stateToId || {} | |
| }, m.getState = function (a, b) { | |
| "undefined" == typeof a && (a = !0), "undefined" == typeof b && (b = !0); | |
| var c = m.getLastSavedState(); | |
| return !c && b && (c = m.createStateObject()), a && (c = m.cloneObject(c), c.url = c.cleanUrl || c.url), c | |
| }, m.getIdByState = function (a) { | |
| var c, b = m.extractId(a.url); | |
| if (!b) | |
| if (c = m.getStateString(a), "undefined" != typeof m.stateToId[c]) b = m.stateToId[c]; | |
| else if ("undefined" != typeof m.store.stateToId[c]) b = m.store.stateToId[c]; | |
| else { | |
| for (; b = (new Date).getTime() + String(Math.random()).replace(/\D/g, ""), "undefined" != typeof m.idToState[b] || "undefined" != typeof m.store.idToState[b];); | |
| m.stateToId[c] = b, m.idToState[b] = a | |
| } | |
| return b | |
| }, m.normalizeState = function (a) { | |
| var b, c; | |
| return a && "object" == typeof a || (a = {}), "undefined" != typeof a.normalized ? a : (a.data && "object" == typeof a.data || (a.data = {}), b = {}, b.normalized = !0, b.title = a.title || "", b.url = m.getFullUrl(m.unescapeString(a.url || d.location.href)), b.hash = m.getShortUrl(b.url), b.data = m.cloneObject(a.data), b.id = m.getIdByState(b), b.cleanUrl = b.url.replace(/\??\&_suid.*/, ""), b.url = b.cleanUrl, c = !m.isEmptyObject(b.data), (b.title || c) && (b.hash = m.getShortUrl(b.url).replace(/\??\&_suid.*/, ""), /\?/.test(b.hash) || (b.hash += "?"), b.hash += "&_suid=" + b.id), b.hashedUrl = m.getFullUrl(b.hash), (m.emulated.pushState || m.bugs.safariPoll) && m.hasUrlDuplicate(b) && (b.url = b.hashedUrl), b) | |
| }, m.createStateObject = function (a, b, c) { | |
| var d = { | |
| data: a, | |
| title: b, | |
| url: c | |
| }; | |
| return d = m.normalizeState(d) | |
| }, m.getStateById = function (a) { | |
| a = String(a); | |
| var c = m.idToState[a] || m.store.idToState[a] || b; | |
| return c | |
| }, m.getStateString = function (a) { | |
| var b, c, d; | |
| return b = m.normalizeState(a), c = { | |
| data: b.data, | |
| title: a.title, | |
| url: a.url | |
| }, d = k.stringify(c) | |
| }, m.getStateId = function (a) { | |
| var b, c; | |
| return b = m.normalizeState(a), c = b.id | |
| }, m.getHashByState = function (a) { | |
| var b, c; | |
| return b = m.normalizeState(a), c = b.hash | |
| }, m.extractId = function (a) { | |
| var b, c, d; | |
| return c = /(.*)\&_suid=([0-9]+)$/.exec(a), d = c ? c[1] || a : a, b = c ? String(c[2] || "") : "", b || !1 | |
| }, m.isTraditionalAnchor = function (a) { | |
| var b = !/[\/\?\.]/.test(a); | |
| return b | |
| }, m.extractState = function (a, b) { | |
| var d, e, c = null; | |
| return b = b || !1, d = m.extractId(a), d && (c = m.getStateById(d)), c || (e = m.getFullUrl(a), d = m.getIdByUrl(e) || !1, d && (c = m.getStateById(d)), !c && b && !m.isTraditionalAnchor(a) && (c = m.createStateObject(null, null, e))), c | |
| }, m.getIdByUrl = function (a) { | |
| var c = m.urlToId[a] || m.store.urlToId[a] || b; | |
| return c | |
| }, m.getLastSavedState = function () { | |
| return m.savedStates[m.savedStates.length - 1] || b | |
| }, m.getLastStoredState = function () { | |
| return m.storedStates[m.storedStates.length - 1] || b | |
| }, m.hasUrlDuplicate = function (a) { | |
| var c, b = !1; | |
| return c = m.extractState(a.url), b = c && c.id !== a.id | |
| }, m.storeState = function (a) { | |
| return m.urlToId[a.url] = a.id, m.storedStates.push(m.cloneObject(a)), a | |
| }, m.isLastSavedState = function (a) { | |
| var c, d, e, b = !1; | |
| return m.savedStates.length && (c = a.id, d = m.getLastSavedState(), e = d.id, b = c === e), b | |
| }, m.saveState = function (a) { | |
| return m.isLastSavedState(a) ? !1 : (m.savedStates.push(m.cloneObject(a)), !0) | |
| }, m.getStateByIndex = function (a) { | |
| var b = null; | |
| return b = "undefined" == typeof a ? m.savedStates[m.savedStates.length - 1] : 0 > a ? m.savedStates[m.savedStates.length + a] : m.savedStates[a] | |
| }, m.getHash = function () { | |
| var a = m.unescapeHash(d.location.hash); | |
| return a | |
| }, m.unescapeString = function (b) { | |
| for (var d, c = b; d = a.unescape(c), d !== c;) c = d; | |
| return c | |
| }, m.unescapeHash = function (a) { | |
| var b = m.normalizeHash(a); | |
| return b = m.unescapeString(b) | |
| }, m.normalizeHash = function (a) { | |
| var b = a.replace(/[^#]*#/, "").replace(/#.*/, ""); | |
| return b | |
| }, m.setHash = function (a, b) { | |
| var c, e, f; | |
| return b !== !1 && m.busy() ? (m.pushQueue({ | |
| scope: m, | |
| callback: m.setHash, | |
| args: arguments, | |
| queue: b | |
| }), !1) : (c = m.escapeHash(a), m.busy(!0), e = m.extractState(a, !0), e && !m.emulated.pushState ? m.pushState(e.data, e.title, e.url, !1) : d.location.hash !== c && (m.bugs.setHash ? (f = m.getPageUrl(), m.pushState(null, null, f + "#" + c, !1)) : d.location.hash = c), m) | |
| }, m.escapeHash = function (b) { | |
| var c = m.normalizeHash(b); | |
| return c = a.escape(c), m.bugs.hashEscape || (c = c.replace(/\%21/g, "!").replace(/\%26/g, "&").replace(/\%3D/g, "=").replace(/\%3F/g, "?")), c | |
| }, m.getHashByUrl = function (a) { | |
| var b = String(a).replace(/([^#]*)#?([^#]*)#?(.*)/, "$2"); | |
| return b = m.unescapeHash(b) | |
| }, m.setTitle = function (a) { | |
| var c, b = a.title; | |
| b || (c = m.getStateByIndex(0), c && c.url === a.url && (b = c.title || m.options.initialTitle)); | |
| try { | |
| d.getElementsByTagName("title")[0].innerHTML = b.replace("<", "<").replace(">", ">").replace(" & ", " & ") | |
| } catch (e) {} | |
| return d.title = b, m | |
| }, m.queues = [], m.busy = function (a) { | |
| if ("undefined" != typeof a ? m.busy.flag = a : "undefined" == typeof m.busy.flag && (m.busy.flag = !1), !m.busy.flag) { | |
| h(m.busy.timeout); | |
| var b = function () { | |
| var a, c, d; | |
| if (!m.busy.flag) | |
| for (a = m.queues.length - 1; a >= 0; --a) c = m.queues[a], 0 !== c.length && (d = c.shift(), m.fireQueueItem(d), m.busy.timeout = g(b, m.options.busyDelay)) | |
| }; | |
| m.busy.timeout = g(b, m.options.busyDelay) | |
| } | |
| return m.busy.flag | |
| }, m.busy.flag = !1, m.fireQueueItem = function (a) { | |
| return a.callback.apply(a.scope || m, a.args || []) | |
| }, m.pushQueue = function (a) { | |
| return m.queues[a.queue || 0] = m.queues[a.queue || 0] || [], m.queues[a.queue || 0].push(a), m | |
| }, m.queue = function (a, b) { | |
| return "function" == typeof a && (a = { | |
| callback: a | |
| }), "undefined" != typeof b && (a.queue = b), m.busy() ? m.pushQueue(a) : m.fireQueueItem(a), m | |
| }, m.clearQueue = function () { | |
| return m.busy.flag = !1, m.queues = [], m | |
| }, m.stateChanged = !1, m.doubleChecker = !1, m.doubleCheckComplete = function () { | |
| return m.stateChanged = !0, m.doubleCheckClear(), m | |
| }, m.doubleCheckClear = function () { | |
| return m.doubleChecker && (h(m.doubleChecker), m.doubleChecker = !1), m | |
| }, m.doubleCheck = function (a) { | |
| return m.stateChanged = !1, m.doubleCheckClear(), m.bugs.ieDoubleCheck && (m.doubleChecker = g(function () { | |
| return m.doubleCheckClear(), m.stateChanged || a(), !0 | |
| }, m.options.doubleCheckInterval)), m | |
| }, m.safariStatePoll = function () { | |
| var c, b = m.extractState(d.location.href); | |
| if (!m.isLastSavedState(b)) return c = b, c || (c = m.createStateObject()), m.Adapter.trigger(a, "popstate"), m | |
| }, m.back = function (a) { | |
| return a !== !1 && m.busy() ? (m.pushQueue({ | |
| scope: m, | |
| callback: m.back, | |
| args: arguments, | |
| queue: a | |
| }), !1) : (m.busy(!0), m.doubleCheck(function () { | |
| m.back(!1) | |
| }), n.go(-1), !0) | |
| }, m.forward = function (a) { | |
| return a !== !1 && m.busy() ? (m.pushQueue({ | |
| scope: m, | |
| callback: m.forward, | |
| args: arguments, | |
| queue: a | |
| }), !1) : (m.busy(!0), m.doubleCheck(function () { | |
| m.forward(!1) | |
| }), n.go(1), !0) | |
| }, m.go = function (a, b) { | |
| var c; | |
| if (a > 0) | |
| for (c = 1; a >= c; ++c) m.forward(b); | |
| else { | |
| if (!(0 > a)) throw new Error("History.go: History.go requires a positive or negative integer passed."); | |
| for (c = -1; c >= a; --c) m.back(b) | |
| } | |
| return m | |
| }, m.emulated.pushState) { | |
| var o = function () {}; | |
| m.pushState = m.pushState || o, m.replaceState = m.replaceState || o | |
| } else m.onPopState = function (b, c) { | |
| var g, h, e = !1, | |
| f = !1; | |
| return m.doubleCheckComplete(), g = m.getHash(), g ? (h = m.extractState(g || d.location.href, !0), h ? m.replaceState(h.data, h.title, h.url, !1) : (m.Adapter.trigger(a, "anchorchange"), m.busy(!1)), m.expectedStateId = !1, !1) : (e = m.Adapter.extractEventData("state", b, c) || !1, f = e ? m.getStateById(e) : m.expectedStateId ? m.getStateById(m.expectedStateId) : m.extractState(d.location.href), f || (f = m.createStateObject(null, null, d.location.href)), m.expectedStateId = !1, m.isLastSavedState(f) ? (m.busy(!1), !1) : (m.storeState(f), m.saveState(f), m.setTitle(f), m.Adapter.trigger(a, "statechange"), m.busy(!1), !0)) | |
| }, m.Adapter.bind(a, "popstate", m.onPopState), m.pushState = function (b, c, d, e) { | |
| if (m.getHashByUrl(d) && m.emulated.pushState) throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors)."); | |
| if (e !== !1 && m.busy()) return m.pushQueue({ | |
| scope: m, | |
| callback: m.pushState, | |
| args: arguments, | |
| queue: e | |
| }), !1; | |
| m.busy(!0); | |
| var f = m.createStateObject(b, c, d); | |
| return m.isLastSavedState(f) ? m.busy(!1) : (m.storeState(f), m.expectedStateId = f.id, n.pushState(f.id, f.title, f.url), m.Adapter.trigger(a, "popstate")), !0 | |
| }, m.replaceState = function (b, c, d, e) { | |
| if (m.getHashByUrl(d) && m.emulated.pushState) throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors)."); | |
| if (e !== !1 && m.busy()) return m.pushQueue({ | |
| scope: m, | |
| callback: m.replaceState, | |
| args: arguments, | |
| queue: e | |
| }), !1; | |
| m.busy(!0); | |
| var f = m.createStateObject(b, c, d); | |
| return m.isLastSavedState(f) ? m.busy(!1) : (m.storeState(f), m.expectedStateId = f.id, n.replaceState(f.id, f.title, f.url), m.Adapter.trigger(a, "popstate")), !0 | |
| }; if (f) { | |
| try { | |
| m.store = k.parse(f.getItem("History.store")) || {} | |
| } catch (p) { | |
| m.store = {} | |
| } | |
| m.normalizeStore() | |
| } else m.store = {}, m.normalizeStore(); | |
| m.Adapter.bind(a, "beforeunload", m.clearAllIntervals), m.Adapter.bind(a, "unload", m.clearAllIntervals), m.saveState(m.storeState(m.extractState(d.location.href, !0))), f && (m.onUnload = function () { | |
| var a, b; | |
| try { | |
| a = k.parse(f.getItem("History.store")) || {} | |
| } catch (c) { | |
| a = {} | |
| } | |
| a.idToState = a.idToState || {}, a.urlToId = a.urlToId || {}, a.stateToId = a.stateToId || {}; | |
| for (b in m.idToState) m.idToState.hasOwnProperty(b) && (a.idToState[b] = m.idToState[b]); | |
| for (b in m.urlToId) m.urlToId.hasOwnProperty(b) && (a.urlToId[b] = m.urlToId[b]); | |
| for (b in m.stateToId) m.stateToId.hasOwnProperty(b) && (a.stateToId[b] = m.stateToId[b]); | |
| m.store = a, m.normalizeStore(), f.setItem("History.store", k.stringify(a)) | |
| }, m.intervalList.push(i(m.onUnload, m.options.storeInterval)), m.Adapter.bind(a, "beforeunload", m.onUnload), m.Adapter.bind(a, "unload", m.onUnload)), m.emulated.pushState || (m.bugs.safariPoll && m.intervalList.push(i(m.safariStatePoll, m.options.safariPollInterval)), ("Apple Computer, Inc." === e.vendor || "Mozilla" === (e.appCodeName || "")) && (m.Adapter.bind(a, "hashchange", function () { | |
| m.Adapter.trigger(a, "popstate") | |
| }), m.getHash() && m.Adapter.onDomLoad(function () { | |
| m.Adapter.trigger(a, "hashchange") | |
| }))) | |
| }, m.init() | |
| }(window); | |
| var debug = !0, | |
| c_count = 0, | |
| c = function (param) { | |
| if ("object" != typeof console || !console.log) return null; | |
| if (debug === !0) return Object.isUndefined(param) && (arguments[0] = c_count), c_count++, console.log.apply(console, arguments) | |
| }, ca = function () { | |
| c(arguments) | |
| }, log = c, | |
| u = { | |
| ef: function (f) { | |
| return "function" == typeof f ? f : function () {} | |
| }, | |
| sanitize: function (html) { | |
| function sanitizeTag(tag) { | |
| return tag.match(basic_tag_whitelist) || tag.match(a_white) || tag.match(img_white) ? tag : "" | |
| } | |
| var basic_tag_whitelist = /^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|i|kbd|li|ol|p|pre|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i, | |
| a_white = /^(<a\shref="((https?|ftp):\/\/|\/)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+"(\stitle="[^"<>]+")?\s?>|<\/a>)$/i, | |
| img_white = /^(<img\ssrc="(https?:\/\/|\/)[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+"(\swidth="\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i; | |
| return html.replace(/<[^>]*>?/gi, sanitizeTag) | |
| }, | |
| ts: function () { | |
| return +((new Date).getTime() / 1e3).toFixed(0) | |
| }, | |
| id: function (id) { | |
| return id || (id = (new Date).getTime() + "" + this.generate()), id = id.replace(/\:/g, ""), ("_" === id.substr(0, 1) ? "" : "_") + id | |
| }, | |
| arr: function (value) { | |
| return Object.isArray(value) ? value : Object.isString(value) ? value.split(",") : [value] | |
| }, | |
| res: function (t, parent) { | |
| return t.responseJSON.e ? (new C.WinAlert(t.responseJSON.e, { | |
| parent: parent || I.Windows.activeWindow || null | |
| }), !0) : null | |
| }, | |
| hideTooltip: function () { | |
| $$(".tooltip").invoke("hide") | |
| }, | |
| generate: function (len) { | |
| return (!len || 1 > len || len > 8) && (len = 8), Math.random().toString(36).slice(-1 * len) | |
| } | |
| }, C = {}, I = { | |
| DB: {}, | |
| Element: {} | |
| }; | |
| I.History = window.History, C.Base = Class.create({ | |
| _timeoutEvents: [], | |
| _bindings: {}, | |
| timeout: function (funct, duration) { | |
| var pointer = window.setTimeout(funct.bind(this), 1e3 * duration); | |
| return this._timeoutEvents.push(pointer), pointer | |
| }, | |
| triggerEvent: function (eventName) { | |
| return Object.isFunction(this[eventName]) ? this[eventName](arguments) : void 0 | |
| }, | |
| getBody: function () { | |
| return $$("body")[0] | |
| }, | |
| destroy: function () { | |
| this._timeoutEvents.each(function (event) { | |
| clearTimeout(event) | |
| }.bind(this)) | |
| } | |
| }), C.Keyboard = Class.create({ | |
| instances: {}, | |
| initialize: function () {}, | |
| on: function (key, eventType, eventFunct) { | |
| var hash = "_" + key.toSHA1(); | |
| return this.instances[hash] || ("keydown" == eventType && (this.instances[hash] = KeyboardJS.on(key, null)), "keyup" == eventType && (this.instances[hash] = KeyboardJS.on(key, null, null))), this.instances[hash].on(eventType, eventFunct) | |
| } | |
| }), I.Keyboard = new C.Keyboard, C.Apps = Class.create({ | |
| instances: {}, | |
| initialize: function () { | |
| window.addEventListener("message", this.receive.bind(this), !1) | |
| }, | |
| receive: function (event) { | |
| c("ORIGIN", event.origin), c(event.data), "http://example.org:8080" !== event.origin | |
| }, | |
| open: function (appElement, src) { | |
| I.User.req("app/run/" + appElement.data.id, function (t) { | |
| if (!u.res(t)) { | |
| var json = t.responseJSON, | |
| instance = this.instances[appElement.data.id]; | |
| if (instance) return instance.run(); | |
| var iframe = document.createElement("iframe"); | |
| iframe.id = "app" + json.id, iframe.src = src, iframe.frameborder = "0", iframe.setStyle("position:fixed;width:0px;height:0px"), $$("body").first().insert(iframe), this.instances[appElement.data.id] = { | |
| id: json.id, | |
| run: function () { | |
| c("c", iframe.contentWindow), iframe.contentWindow.postMessage({ | |
| event: "run" | |
| }), c("postMes") | |
| }, | |
| iframe: iframe | |
| } | |
| } | |
| }.bind(this)) | |
| } | |
| }), I.Apps = new C.Apps, C.Socket = Class.create(C.Base, { | |
| ready: !1, | |
| initialize: function () {}, | |
| load: function () { | |
| 0 == this.ready && (this.ready = -1, I.Project.load(["socket.io/socket.io.js", | |
| function () { | |
| this.ready = 0, this.connect() | |
| }.bind(this) | |
| ])) | |
| }, | |
| connect: function (cb) { | |
| return this.ready ? cb ? cb() : null : (this.io = io.connect(safebyte.url + "?token=" + safebyte.token, { | |
| reconnect: !1 | |
| }), this.io.on("connect", function () { | |
| this.ready = !0 | |
| }.bind(this)), this.io.on("error", function () { | |
| return I.Project.pageReady(), new C.WinAlert("Authorization error__Please report to [email protected]!", { | |
| onClose: function () { | |
| top.location.href = "reboot" | |
| } | |
| }) | |
| }), this.io.on("disconnect", function () { | |
| setTimeout(function () { | |
| this.Win || (I.Project.setTitle("Update available!"), this.Win = new C.WinAlert("Update available!__safebyte just became a bit more awesome.", { | |
| okText: "Please wait…", | |
| onInsert: function (Win) { | |
| var elem = Win.elem, | |
| s = function (t) { | |
| return elem.down("button").update(t) | |
| }; | |
| elem.down("button").disable(), setTimeout(s.bind(this, "Loading Packages…"), 1e3), setTimeout(s.bind(this, "Extending Features…"), 2500), setTimeout(s.bind(this, "Updating Layout…"), 4500), setTimeout(s.bind(this, "Finishing…"), 6e3), setTimeout(function () { | |
| s("Apply Update").enable() | |
| }, 6800), $("container").select("> div").each(function (elem) { | |
| "bg" != elem.id && elem.setClass("trans05 o0") | |
| }) | |
| }, | |
| onClose: function () { | |
| I.Project.pageLoad(), top.location.href = top.location.href | |
| } | |
| })) | |
| }.bind(this), 500) | |
| }.bind(this)), void 0) | |
| }, | |
| on: function () { | |
| return this.io.on.apply(this.io, arguments) | |
| } | |
| }), I.Socket = new C.Socket, C.GUI = Class.create(C.Base, { | |
| elem: null, | |
| init: function () { | |
| if (this.css) { | |
| if (this.css === !0 && (this.css = { | |
| file: this.name + ".css" | |
| }), Object.isString(this.css) && (this.css = { | |
| file: this.css | |
| }), this.activeCSS = [], this.css.file) { | |
| this.ready = 0, -1 == this.css.file.indexOf(".") && (this.css.file += ".css"); | |
| var stylesheet = $$("head").first().insert('<link rel="stylesheet" href="/css/inline/' + this.css.file + '" />').select("link:last-child").first(); | |
| stylesheet.observe("load", function () { | |
| this.ready = !0 | |
| }.bind(this)), this.activeCSS.push(stylesheet) | |
| } | |
| this.css.text && this.activeCSS.push($$("head").first().insert('<style type="text/css">' + this.css.text + "</style>").select("style:last-child").first()) | |
| } | |
| }, | |
| insert: function (id) { | |
| Object.isString(id) || (arguments[1] = arguments[0]); | |
| var data = Object.extend({ | |
| id: Object.isString(id) ? id : "id" + (1e4 * Math.random()).round(), | |
| target: I.Content.elem, | |
| position: "after", | |
| html: this.html || "", | |
| className: "", | |
| height: null, | |
| template: null, | |
| style: "" | |
| }, arguments[1] || {}); | |
| if (Object.isElement(this.elem)) return this.elem; | |
| var insertObj = {}; | |
| switch (data.html = new Template('<div id="#{id}" class="#{className}" style="#{style}">#{html}</div>').evaluate(data), data.position) { | |
| case "after": | |
| insertObj.after = data.html; | |
| break; | |
| case "before": | |
| insertObj.before = data.html; | |
| break; | |
| case "top": | |
| insertObj.top = data.html; | |
| break; | |
| case "bottom": | |
| insertObj.bottom = data.html | |
| } | |
| return $(data.target).insert(insertObj), this.elem = $(data.id), data.height && (this.elem.setClass("middle"), this.elem.setStyle({ | |
| height: data.height + "px", | |
| marginTop: "-" + data.height / 2 + "px" | |
| })), this.elem | |
| }, | |
| _keysWaited: !1, | |
| enableKeys: function (keys) { | |
| return KeyboardJS.activeKeys().length > 0 ? setTimeout(this.enableKeys.bind(this, keys), 50) : (Object.isArray(keys) || (keys = [keys]), Object.isArray(this._keys) || (this._keys = []), keys.each(function (key) { | |
| this._keys.push(I.Keyboard.on(key, "keydown", this._keyDown.bind(this))), this._keys.push(I.Keyboard.on(key, "keyup", this._keyUp.bind(this))) | |
| }.bind(this)), void 0) | |
| }, | |
| disableKeys: function () { | |
| this._keys && (this._keys.each(function (instance) { | |
| instance.clear(), delete instance | |
| }.bind(this)), this._keys = []) | |
| }, | |
| key: Prototype.emptyFunction, | |
| _keyDown: function (event, keyArray, keyString) { | |
| I.Windows.activeWindow && I.Windows.activeWindow != this || this._minimized || (event.type = "keydown", this.key(event, keyString, keyArray)) | |
| }, | |
| _keyUp: function (event, keyArray, keyString) { | |
| I.Windows.activeWindow && I.Windows.activeWindow != this || this._minimized || (event.type = "keyup", this.key(event, keyString, keyArray)) | |
| }, | |
| enableScrollEvent: function () { | |
| this._bindings.onScroll = function (e) { | |
| Object.isFunction(this.scroll) && this.scroll(e) | |
| }.bind(this), Event.observe(document.onscroll ? document : window, "scroll", this._bindings.onScroll), this.scroll() | |
| }, | |
| enableWheelEvent: function () { | |
| this._bindings.onWheel = function (e) { | |
| Object.isFunction(this.wheel) && this.wheel(e) | |
| }.bind(this), Event.observe(window, "DOMMouseScroll", this._bindings.onWheel, !1) | |
| }, | |
| enableResizeEvent: function () { | |
| this._bindings.onResize = function (e) { | |
| Object.isFunction(this.resize) && this.resize(e) | |
| }.bind(this), Event.observe(document.onresize ? document : window, "resize", this._bindings.onResize), this.resize() | |
| }, | |
| disableWheelEvent: function () { | |
| this._bindings.onWheel && (Event.stopObserving(window, "DOMMouseScroll", this._bindings.onWheel), this._bindings.onWheel = null) | |
| }, | |
| disableScrollEvent: function () { | |
| this._bindings.onScroll && (Event.stopObserving(document.onscroll ? document : window, "scroll", this._bindings.onScroll), this._bindings.onScroll = null) | |
| }, | |
| disableResizeEvent: function () { | |
| this._bindings.onResize && (Event.stopObserving(document.onresize ? document : window, "resize", this._bindings.onResize), this._bindings.onResize = null) | |
| }, | |
| _visible: !0, | |
| hide: function () { | |
| this._visible && this.elem && (Object.isNumber(arguments[0]) ? this.elem.fade({ | |
| duration: arguments[0] | |
| }) : this.elem.hide(), this._visible = !1) | |
| }, | |
| show: function () { | |
| !this._visible && this.elem && (Object.isNumber(arguments[0]) && arguments[0] > 0 ? this.elem.appear({ | |
| duration: arguments[0] | |
| }) : this.elem.show(), this._visible = !0) | |
| }, | |
| destroy: function ($super) { | |
| $super(), Object.isElement(this.elem) && (this.elem.remove(), this.elem = null), this.disableKeys(), this.disableResizeEvent(), this.disableScrollEvent(), this.disableWheelEvent(), Object.isArray(this.activeCSS) && this.activeCSS.invoke("remove") | |
| } | |
| }), C.Page = Class.create(C.GUI, { | |
| _guiElements: ["content", "navigation", "safebox", "sidebar", "footer"], | |
| initialize: function (req) { | |
| this.init(req) | |
| }, | |
| init: function ($super) { | |
| if ($super(), this.title && this.setTitle(this.title), !Object.isArray(this.visible)) switch (this.visible) { | |
| case "none": | |
| this.visible = []; | |
| break; | |
| case "center": | |
| this.visible = ["content", "navigation", "safebox"]; | |
| break; | |
| default: | |
| case "full": | |
| this.visible = this._guiElements | |
| } | |
| this._guiElements.each(function (key) { | |
| I[key.ucFirst()] && (this.visible.include(key) ? I[key.ucFirst()].show() : I[key.ucFirst()].hide()) | |
| }.bind(this)) | |
| }, | |
| setTitle: function (title, appendName) { | |
| I.Project.setTitle(title + (appendName !== !1 ? (title ? " ~ " : "") + "safebyte" : "")) | |
| }, | |
| history: Prototype.emptyFunction, | |
| destroy: function ($super) { | |
| $super(), I.Content.hideTitle(), Object.isArray(this.visible) && this.visible.each(function (key) { | |
| I[key.ucFirst()] && I[key.ucFirst()].hide() | |
| }.bind(this)) | |
| } | |
| }), C.PageCenter = Class.create(C.Page, { | |
| visible: "center", | |
| init: function ($super) { | |
| $super(), I.Content.hideTitle(), I.Content.setCenterMode(!0), this.enableScrollEvent(), this.enableResizeEvent() | |
| }, | |
| scroll: function () { | |
| document.viewport.getScrollOffsets().top > 50 ? I.Safebox.elem.addClassName("trans03").addClassName("buttonOnly scrollTop") : I.Safebox.elem.hasClassName("scrollTop") && I.Safebox.elem.removeClassName("buttonOnly") | |
| }, | |
| resize: function () { | |
| this.scroll() | |
| }, | |
| destroy: function ($super) { | |
| $super(), I.Safebox.elem.removeClassName("buttonOnly"), I.Content.setCenterMode(!1) | |
| } | |
| }), C.Project = Class.create(C.Base, { | |
| req: null, | |
| pages: {}, | |
| currentPage: null, | |
| lastPage: null, | |
| keyspace: null, | |
| onUnload: null, | |
| useHash: !1, | |
| disableGo: !1, | |
| data: { | |
| p: "http", | |
| url: "www.safebyte.com", | |
| url_short: "safeb.yt", | |
| url_cdn: "clados.safebyte.com", | |
| url_plain: "safebyte.com" | |
| }, | |
| getURL: function (string) { | |
| return string || (string = "p:url"), string.include(":") && (string = string.sub(":", "://")), Object.keys(this.data).reverse().each(function (key) { | |
| string = string.sub(key, this.data[key]) | |
| }.bind(this)), string | |
| }, | |
| _lastAction: null, | |
| initialize: function () { | |
| if (this.useHash = Object.isFunction(history.pushState) ? !1 : !0, this.getBody().observe("mousemove", this.lastAction.bind(this)), this.getBody().observe("keydown", this.lastAction.bind(this)), this.lastAction(), is_touchable() && this.load(["js/lib/hammer/hammer.min.js", | |
| function () {}.bind(this) | |
| ]), window.onbeforeunload = function () { | |
| this._beforeUnload.each(function (func) { | |
| func() | |
| }) | |
| }.bind(this), this.useHash) { | |
| if (window.location.pathname && !location.href.include("#")) return location.href = "/#" + window.location.pathname.substr(1); | |
| window.onhashchange = this.history.bind(this) | |
| } else I.History.Adapter.bind(window, "statechange", this.history.bind(this)); | |
| this.history() | |
| }, | |
| lastAction: function () { | |
| this._lastAction = (new Date).getTime() | |
| }, | |
| require: function (vars, onReady) { | |
| if (!Object.isUndefined(vars)) { | |
| var wait = !1; | |
| return Object.isArray(vars) || (vars = [vars]), vars.each(function (v) { | |
| v.ready !== !0 && (wait = !0), v.ready === !1 && v.load() | |
| }.bind(this)), wait ? this.timeout(this.require.bind(this, vars, onReady), .005) : (onReady(), void 0) | |
| } | |
| }, | |
| load: function () { | |
| $A(arguments).each(function (argument) { | |
| function loadScriptHandler() { | |
| var rs = this.readyState; | |
| ("loaded" == rs || "complete" == rs) && (this.onreadystatechange = null, this.onload = null, argument.onFinish()) | |
| } | |
| function scriptOnload() { | |
| this.onreadystatechange = null, this.onload = null, window.setTimeout(argument.onFinish, 20) | |
| } | |
| if (argument = Object.isString(argument) ? { | |
| uri: argument, | |
| sync: !0 | |
| } : Object.isArray(argument) ? { | |
| uri: argument[0], | |
| onFinish: argument[1] | |
| } : argument, argument.sync && argument.uri.include(".js")) new Ajax.Request(argument.uri, { | |
| method: "get", | |
| asynchronous: !1 | |
| }); | |
| else if (Object.isFunction(argument.onFinish)) { | |
| var elem = document.createElement("script"); | |
| elem.type = "text/javascript", elem.onreadystatechange = loadScriptHandler, elem.onload = scriptOnload, elem.src = argument.uri, $$("head").first().appendChild(elem) | |
| } else argument.uri.include(".css") && $$("head").first().insert('<link rel="stylesheet" href="' + argument.uri + '" />') | |
| }.bind(this)) | |
| }, | |
| parseReq: function () { | |
| var req = (arguments[0] || (this.useHash ? location.hash : I.History.getState().hash)).sub("#", ""); | |
| return this.useHash && "." == req.substr(0, 1) && (req = req.substr(1)), "/" == req ? this.req = ["start"] : (this.req = req.split("/"), "" == this.req[0] && this.req.shift()), this.req | |
| }, | |
| _beforeUnload: [], | |
| addBeforeUnload: function (funct) { | |
| this._beforeUnload.push(funct) | |
| }, | |
| clearBeforeUnload: function () { | |
| this._beforeUnload = [] | |
| }, | |
| go: function (url) { | |
| if (this.disableGo === !0 || Object.isFunction(this.disableGo) && this.disableGo()) return null; | |
| if (url = url.sub(I.History.getBaseUrl(), ""), this.useHash) return top.location.href = "/#" + url; | |
| var data = arguments[2] || null, | |
| title = arguments[1] || null; | |
| History.pushState(data, title, url) | |
| }, | |
| share: function (url, service) { | |
| var d = { | |
| win: {} | |
| }; | |
| switch (service) { | |
| case "facebook": | |
| d.uri = "https://www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(url); | |
| break; | |
| case "twitter": | |
| d.win.height = 230, d.uri = "http://www.twitter.com/?status=" + encodeURIComponent(url); | |
| break; | |
| case "google": | |
| d.win.height = 600, d.uri = "https://plus.google.com/share?url=" + encodeURIComponent(url) | |
| } | |
| d.uri && this.popup(d.uri, d.win) | |
| }, | |
| popup: function (url, data, name) { | |
| name = name || "popup" + u.generate(), data = Object.extend({ | |
| width: 500, | |
| height: 300, | |
| center: !0 | |
| }, data), data.center && (data.left = (window.screen.width - data.width) / 2, data.top = (window.screen.height - data.height) / 2); | |
| var options = ""; | |
| Object.keys(data).each(function (key) { | |
| options += key + "=" + data[key] + "," | |
| }), window.open(url, name, options.substr(0, options.length - 1)) | |
| }, | |
| history: function () { | |
| $$(".tooltip").invoke("hide"); | |
| var req = this.parseReq(), | |
| page = req[0] || ""; | |
| return Object.isFunction(this.onUnload) && !this.onUnload() ? null : ("~" == page.substr(0, 1) && (page = "explorer"), "+" == page.substr(0, 1) && (page = "file"), this.currentPage && page != this.currentPage && ("lock" == page ? setTimeout(function (lastPage) { | |
| this.pages[lastPage].destroy(page) | |
| }.bind(this, this.currentPage), 1e3) : this.pages[this.currentPage] && this.pages[this.currentPage].destroy(page)), this.lastPage = this.currentPage, this.currentPage = page, this.onUnload = null, "object" == typeof this.pages[page] ? this.currentPage == this.lastPage && Object.isFunction(this.pages[page].history) ? this.pages[page].history(req) : this.pages[page].init(req) : (this.pageLoad(), new Ajax.Request("js/page/" + page + ".js", { | |
| method: "get", | |
| onFailure: function () { | |
| "error/404".go() | |
| } | |
| }), void 0)) | |
| }, | |
| _theme: null, | |
| theme: function (name) { | |
| if (name || (name = I.User.setting("theme:current") || (this._theme ? !1 : "grass")), !name || this._theme == name) return null; | |
| var bg = $("bg"); | |
| "none" != bg.getStyle("background-image") && ($$("#bgclone").invoke("remove"), bg.insert({ | |
| after: '<div id="bgclone" class="trans2" style="background-image:' + bg.getStyle("background-image").gsub('"', "'") + '"></div>' | |
| }), setTimeout(function () { | |
| $("bgclone").setStyle({ | |
| opacity: 0 | |
| }) | |
| }, 50)), this._theme && $("theme" + this._theme).remove(), this._theme = name, I.User.ready && (I.User.setting("theme:last_change", ((new Date).getTime() / 1e3).round()), I.User.setting("theme:current", name)), $$("head")[0].insert('<link rel="stylesheet" id="theme' + name + '" href="/css/theme/' + name + '.css" />') | |
| }, | |
| extensions: ["3gp", "7z", "ai", "asf", "asp", "avi", "bas", "bat", "bmp", "bz", "com", "css", "csv", "db", "dll", "dmg", "doc", "docx", "eps", "exe", "f4v", "fla", "flv", "gif", "gz", "gzip", "htm", "html", "ini", "iso", "java", "jpg", "jpeg", "js", "m3u", "mkv", "mov", "mp3", "mp4", "mpeg", "mpg", "mv4", "nfo", "ogg", "otf", "pdf", "php", "png", "ppt", "psd", "rar", "rtf", "sb", "sql", "swf", "tar", "ttf", "txt", "wav", "wma", "wmv", "xls", "xml", "zip"], | |
| elementTemplate: new Template('<div id="element#{id}" class="element #{type} #{perspective} #{className}"> <div class="info" title="#{tooltip}"> <label class="icon #{iconClass}" style="background-image:url(\'#{icon}\')"> <div class="shadow"></div> </label> <span class="type">#{typeInfo}</span> <h3>#{title}</h3> <span class="sub">#{sub}</span> <span class="date">#{date}</span> </div></div>'), | |
| element: function (data) { | |
| switch (data.title || (data.title = data.name), data.type) { | |
| case "file": | |
| var ext = data.name.indexOf(".") > -1 ? data.name.split(".").last().toLowerCase() : ""; | |
| data.user && ["jpg", "jpeg", "gif", "png"].include(ext) ? data.img = safebyte.url + "~" + data.user + "/:thumb/" + data.id : data.icon = this.extensions.include(ext) ? "/img/icon/ext/" + ext + ".png" : "/img/icon/file.png", data.img || (data.iconClass = "background"), data.iconClass += " custom", data.sub = parseInt(data.size).toSize(), data.perspective || (data.perspective = "icon"); | |
| break; | |
| case "folder": | |
| data.icon = "img/icon/folder" + (data.childrenVisible > 0 ? "_document" : "") + ".png" | |
| } | |
| return data.img && (data.icon = data.img, data.className = "custom"), data.id || (data.id = u.generate()), this.elementTemplate.evaluate(data) | |
| }, | |
| _titleBody: "", | |
| _titlePrefix: null, | |
| setTitle: function (title) { | |
| this._titleBody = title || this._titleBody, document.title = (this._titlePrefix || "") + this._titleBody | |
| }, | |
| setTitleNotification: function (nr) { | |
| this._titlePrefix = nr > 0 ? "(" + nr.number(0) + ") " : null, this.setTitle() | |
| }, | |
| pageRegister: function (object) { | |
| var instance = new object(this.req); | |
| return this.pages[instance.name] = instance, this.pages[instance.name] | |
| }, | |
| pageLoad: function () { | |
| $("loading").show(), this.getBody().addClassName("loading") | |
| }, | |
| pageReady: function () { | |
| this.theme(), $("loading").hide(), this.getBody().removeClassName("loading") | |
| } | |
| }), C.Module = Class.create(C.Base, { | |
| data: {}, | |
| initialize: function () {}, | |
| get: function (name) { | |
| return this.data[name] | |
| }, | |
| load: function (name, cb) { | |
| c("load module", name); | |
| var argStart = Object.isFunction(cb) ? 2 : 1, | |
| args = Array.prototype.slice.call(arguments, argStart); | |
| return this.data[name] || (this.data[name] = new C.App(name)), c("require module", name, this.data[name]), I.Project.require(this.data[name], function () { | |
| c("init module"), c(name, this.data[name]), this.data[name].Instance.init.apply(this.data[name].Instance, args), Object.isFunction(cb) && (c("cb!"), cb(this.data[name].Instance)) | |
| }.bind(this)), this.data[name] | |
| }, | |
| kill: function (name) { | |
| return this.data[name] && Object.isFunction(this.data[name].Instance.destroy) ? this.data[name].Instance.destroy() : !1 | |
| }, | |
| register: function (name, className) { | |
| this.data[name].Instance = new className | |
| } | |
| }), I.Module = new C.Module, C.App = Class.create(C.Base, { | |
| ready: !1, | |
| initialize: function (name) { | |
| this.name = name, this.load(name) | |
| }, | |
| load: function (name) { | |
| this.ready = 0, this.triggerEvent("beforeLoad"), new Ajax.Request("js/module/" + name + ".js", { | |
| method: "get", | |
| onComplete: this._onLoad.bind(this) | |
| }) | |
| }, | |
| _onLoad: function () { | |
| this.triggerEvent("onLoad"), c("onload, set ready"), this.ready = !0 | |
| } | |
| }); | |
| var safebyte = { | |
| url: "//sb1." + top.location.host.sub("www.", "") + "/", | |
| token: "", | |
| valid: !1, | |
| _methods: ["GET", "POST", "PUT", "DELETE"], | |
| request: function (path) { | |
| var method = this._methods.first(), | |
| options = arguments[1]; | |
| return Object.isFunction(options) && (options = { | |
| onComplete: options | |
| }), this._methods.include(path.toUpperCase()) && (method = path.toUpperCase(), path = arguments[1], options = arguments[2]), options = Object.extend({ | |
| method: method, | |
| requestHeaders: { | |
| "X-Auth-Token": this.token | |
| } | |
| }, options || {}), new Ajax.Request(this.url + path, options) | |
| }, | |
| batch: function (data) { | |
| var options = Object.extend({ | |
| method: "POST" | |
| }, arguments[1] || {}), | |
| output = []; | |
| return data.each(function (row) { | |
| var obj = Object.extend({ | |
| method: "GET", | |
| ident: "_" + u.generate(), | |
| params: { | |
| token: this.token | |
| } | |
| }, row); | |
| obj._method = obj.method, output.push(obj) | |
| }.bind(this)), options.parameters = "data=" + Object.toJSON(output), this.request("batch", options) | |
| } | |
| }; | |
| C.User = Class.create(C.App, { | |
| DB: null, | |
| initialize: function () { | |
| this.name = arguments[0] || null | |
| }, | |
| img: function (userName) { | |
| if (userName = userName || this.name, userName == this.name && this.ready) { | |
| var img = this.DB.get("user", "_person") ? this.DB.get("user", "_person").img : null; | |
| switch (img || (img = ""), img.substr(0, 2)) { | |
| case "fb": | |
| return "//graph.facebook.com/" + parseInt(img.substr(3)) + "/picture?width=226&height=130"; | |
| case "sb": | |
| return safebyte.url + "~" + userName + "/:thumb/_img?" + this.imgVersion; | |
| default: | |
| return "/img/icon/user_large.jpg" | |
| } | |
| } | |
| return safebyte.url + "~" + userName + "/:img" | |
| }, | |
| imgVersion: 0, | |
| load: function (onLoad) { | |
| if (!this.ready && 0 !== this.ready) { | |
| if (this.ready = 0, Object.isUndefined(onLoad)) var onLoad = this.create.bind(this); | |
| if (!this.data) { | |
| var cache = localStorage.getItem("currentUser"); | |
| if (cache) return this.onLoad(cache.evalJSON(!0)) | |
| } | |
| return onLoad() | |
| } | |
| }, | |
| login: function (name, pw) { | |
| pw = pw.toSHA1(); | |
| var options = Object.extend({ | |
| onSuccess: Prototype.emptyFunction, | |
| onError: Prototype.emptyFunction | |
| }, arguments[2] || {}); | |
| safebyte.request("POST", "~James/:login", { | |
| parameters: "mail=" + name + "&pw=" + pw, | |
| onComplete: function (event) { | |
| var json = event.responseJSON; | |
| json.pwHint = pw.substr(0, 5), "object" != typeof json || json.e ? options.onError(json) : (this.onLoad(json), options.onSuccess(json)) | |
| }.bind(this) | |
| }) | |
| }, | |
| tokenParse: function (string) { | |
| var token = string.split(":"), | |
| ls = localStorage.getItem("currentUser").evalJSON(); | |
| return ls.token = string, localStorage.setItem("currentUser", Object.toJSON(ls)), safebyte.token = string, safebyte.valid = !1, this.token = { | |
| user: token[0], | |
| pw: token[1], | |
| date: parseInt(token[2]), | |
| check: token[3] | |
| }, this.token | |
| }, | |
| tokenExpired: function () { | |
| return ((new Date).getTime() / 1e3).toFixed(0) > this.token.date + 3600 | |
| }, | |
| tokenRenew: function (pw, callback) { | |
| Object.isFunction(callback) || (callback = Prototype.emptyFunction); | |
| var param = pw || I.User.setting("system:session:pw") || null; | |
| this.req("session", { | |
| method: "post", | |
| parameters: param ? "pw=" + param.toSHA1() : "", | |
| onFailure: function () { | |
| return callback(!0), this.isActivated() ? "lock".go() : void 0 | |
| }.bind(this), | |
| onComplete: function (t) { | |
| t && t.responseJSON.token && this.tokenParse(t.responseJSON.token), callback(null) | |
| }.bind(this) | |
| }) | |
| }, | |
| onLoad: function (user) { | |
| if (this.name = user.name, this.data = { | |
| id: this.name.toLowerCase(), | |
| name: this.name, | |
| pwHint: user.pwHint | |
| }, this.ready = 0, this.name == I.User.name) { | |
| if (user.cached || localStorage.setItem("currentUser", Object.toJSON(user)), this.tokenParse(user.token), this.isActivated() && this.tokenExpired()) return "lock/✖".go(); | |
| this.DB || (this.DB = new C.Database(this.name)), I.Project.require(this.DB, function () { | |
| this.ready = !0; | |
| var now = ((new Date).getTime() / 1e3).toFixed(0); | |
| this.setting("system:session:last", this.setting("system:session:start")), this.setting("system:session:start", now), this.generatedPW && this.setting("system:session:pw", this.generatedPW), I.Navigation.onUserLoad(), this.watchActivity() | |
| }.bind(this)) | |
| } else this.ready = !0 | |
| }, | |
| isActivated: function () { | |
| return this.DB && this.DB.ready ? this.DB.get("user", "mail").address : !1 | |
| }, | |
| watchActivity: function () { | |
| if (this.timeoutActivity && clearTimeout(this.timeoutActivity), safebyte.token && !((new Date).getTime() / 1e3 > this.setting("system:session:start") + 120)) { | |
| if (this.ready && this.isActivated() && I.Project._lastAction < (new Date).getTime() - 60 * 1e3 * this.setting("system:lock:timeout")) return "lock".go(); | |
| if (this.ready && this.tokenExpired() && this.tokenRenew(), document.hasFocus() && this.setting("theme:timeout") > 0 && (!this.setting("theme:last_change") || ((new Date).getTime() / 1e3).round() > this.setting("theme:last_change") + parseInt(this.setting("theme:timeout")))) { | |
| var current = this.setting("theme:current"), | |
| selection = this.setting("theme:active"); | |
| this.setting("theme:shuffle") && selection.shuffle(); | |
| var index = selection.indexOf(current); | |
| index++, (0 > index || index > selection.length - 1) && (index = 0), I.Project.theme(selection[index]) | |
| } | |
| this.timeoutActivity = setTimeout(this.watchActivity.bind(this), 2e3) | |
| } | |
| }, | |
| get: function (key) { | |
| return this.data ? Object.isUndefined(this.data[key]) ? (key = "_" == key.substr(0, 1) ? "" : "_" + key, this.DB.get("user", key)) : this.data[key] : !1 | |
| }, | |
| req: function (cmd, data) { | |
| return safebyte.request("~" + this.name + "/:" + cmd, data) | |
| }, | |
| isPro: function () { | |
| var isPro = this.get("membership").expire.parseDate() > (new Date).getTime(); | |
| return isPro | |
| }, | |
| isAdmin: function () { | |
| var obj = this.DB.get("user", "_admin"), | |
| auth = !1; | |
| return obj ? (obj.expire > u.ts() && (auth = +obj.level), this.level = auth, auth || !1) : !1 | |
| }, | |
| setting: function (key) { | |
| if (!this.DB) return null; | |
| if (!key) return this.DB.data.setting; | |
| if (key = ("_" == key.substr(0, 1) ? "" : "_") + key, Object.isUndefined(arguments[1]) || arguments[1] === this.setting(key) || this.DB.insert({ | |
| table: "setting", | |
| id: key, | |
| data: arguments[1] | |
| }), Object.isUndefined(this.DB.get("setting", key))) { | |
| var v = "#!"; | |
| switch (key.substr(1)) { | |
| case "explorer:perspective": | |
| v = "icon"; | |
| break; | |
| case "explorer:separate": | |
| v = !0; | |
| break; | |
| case "system:lock:timeout": | |
| v = 30; | |
| break; | |
| case "system:lock:minimize": | |
| v = !0; | |
| break; | |
| case "theme:last_change": | |
| v = (new Date).getTime() / 1e3 - 60; | |
| break; | |
| case "theme:timeout": | |
| v = 86400; | |
| break; | |
| case "theme:active": | |
| v = ["grass", "floor", "flower", "veins"]; | |
| break; | |
| case "theme:current": | |
| v = "grass"; | |
| break; | |
| case "theme:shuffle": | |
| v = !1 | |
| } | |
| "#!" != v && this.DB.insert({ | |
| table: "setting", | |
| id: key, | |
| data: v | |
| }) | |
| } | |
| return this.DB.get("setting", key) || null | |
| }, | |
| promptTraffic: function (size) { | |
| var cb = u.ef(arguments[arguments.length - 1]), | |
| traffic = this.calcTraffic(); | |
| return traffic.live >= size ? null : traffic.max < size ? new C.WinConfirm("Not enough Traffic Capacity") : new C.WinConfirm('<span class="fs4">Not enough Traffic</span><div class="fs5 b4 mT5 i wait" style="margin-bottom:15px"></div>', { | |
| html: '<div class="trafficBar pR w80" style="margin:-5px auto 20px"></div>', | |
| width: 500, | |
| no: !0, | |
| noText: '<div class="pR">Extend <span class="o05 fs8">(free)</span></div>', | |
| onNo: function () { | |
| "rewards".go() | |
| }, | |
| okText: "Continue", | |
| okDisabled: !0, | |
| onInsert: function (Win) { | |
| var percentNeeded = 100 - (100 * (size / traffic.max)).toFixed(3), | |
| countdown = function (Win) { | |
| if (Win._closed) return null; | |
| var traffic = I.User.calcTraffic(), | |
| missing = size - traffic.live; | |
| if (1 > missing) return Win.elem.down(".fs4").update("Ready!").removeClassName("markedRed").setClass("tBox markedGreen"), Win.elem.down(".wait").update(""), Win.elem.down(".trafficBar").remove(), Win.elem.down("button.ok").disabled = !1, void 0; | |
| var wait = new Date(1e3 * (missing / (traffic.growth / 3600) + 1)), | |
| minutes = wait.getMinutes(), | |
| seconds = wait.getSeconds(); | |
| return Win.elem.down(".wait").update('<span class="o05">Traffic will be recharged in ' + ["", "1 minute &", "%n minutes &"].numerus(minutes) + " " + ["0 seconds", "1 second", "%n seconds"].numerus(seconds) + "</span>"), Win.elem.down(".marker").setStyle("left:" + Win.elem.down(".progress").getStyle("width")), Win.elem.down(".missing").update('<span class="white"> <span class="b5">Traffic required:</span> ' + missing.toSize() + "</span>"), setTimeout(countdown.bind(this), 1e3) | |
| }.bind(this, Win); | |
| I.Sidebar.reset(), Win.elem.down(".trafficBar").update(I.Sidebar.elem.down(".bar", 1).cloneNode(!0)), Win.elem.down(".trafficBar").insert('<div class="marker pA" style="right:' + percentNeeded + '%"></div>'), Win.elem.down(".trafficBar .progress").setClass("visible"), Win.elem.down(".update_traffic_available").removeClassName("update_traffic_available").setClass("missing").setStyle("font-size:12px;line-height:20px;padding-bottom:3px"), countdown() | |
| }, | |
| onConfirm: cb | |
| }) | |
| }, | |
| enoughTraffic: function (size) { | |
| var traffic = this.calcTraffic(); | |
| return traffic.max < size ? -1 : traffic.live >= size | |
| }, | |
| calcTraffic: function () { | |
| var traffic = this.DB.get("user", "_traffic"); | |
| return traffic.timestamp || (traffic.timestamp = (new Date).getTime() / 1e3), traffic.live = traffic.available + traffic.growth * ((((new Date).getTime() / 1e3).toFixed(0) - traffic.timestamp) / 3600), traffic.live = traffic.live > traffic.max ? traffic.max : traffic.live, traffic | |
| }, | |
| rewardIsUndone: function (id) { | |
| var row = I.User.DB.get("reward", "_reward" + id); | |
| return row && (!row.done || row.repeat && "false" != row.repeat) ? !0 : !1 | |
| }, | |
| reward: function (id, data) { | |
| return id = ("_" != id.substr(0, 1) ? "_" : "") + id, this.DB && this.rewardIsUndone(id) ? (data || (data = null), safebyte.request("POST", "~" + this.name + "/:reward/" + id, { | |
| asynchronous: !1, | |
| parameters: "data=" + (Object.isString ? data : Object.toJSON(data)) + "&version=" + this.DB.version, | |
| onComplete: this.DB._onLoad.bind(this.DB) | |
| }), void 0) : null | |
| }, | |
| logout: function () { | |
| I.Project.clearBeforeUnload(), delete this | |
| }, | |
| create: function () { | |
| I.Project.theme(), I.Project.pageReady(), I.Content.elem.addClassName("o0"); | |
| var lastReq = null, | |
| lastCheck = null, | |
| isAvailable = !1, | |
| checkName = function (event) { | |
| var elem = event.element().up(".html"), | |
| elemStatus = elem.down(".createStatus"), | |
| value = event.element().getValue(); | |
| if (elem.down("button").addClassName("o05"), !(value.length < 1 || lastCheck == value)) { | |
| if (lastCheck = value, value.length < 3) return elemStatus.update(_('Please use at least <span class="b7">3 characters</span>.')); | |
| if (value.length > 16) return elemStatus.update(_("Please use at most 16 characters.")); | |
| var loadingPlace = elemStatus.down(".state") || elemStatus; | |
| loadingPlace.update('<span class="o06 b3">' + _("Checking availability…") + "</span>"), lastReq && clearTimeout(lastReq), lastReq = setTimeout(function () { | |
| safebyte.request("~" + value + "/:state", { | |
| onComplete: function (e) { | |
| var json = e.responseJSON; | |
| elem.down("h1").update('<span class="o02" style="font-size:76%"> <span style="opacity:.25;margin-left:-35px">~</span>' + value + '</span><div class="border w50" style="margin:8px auto 12px"></div>'), elemStatus.removeClassName("o03"), json.available ? (elemStatus.update('<span class="state i">is available</span>'), elem.down(".butSubmit").setStyle("height:50px"), isAvailable = value, elem.down("button").removeClassName("o05"), elem.down(".memberInfo").hasClassName("o04") && elem.down(".memberInfo").removeClassName("o04").addClassName("o0").setStyle("height:0px")) : (elem.down("button").addClassName("o05"), isAvailable = !1, elemStatus.update('<span class="state">is already taken − <a href="login" class="a">Sign in</a>?</span>').parseLinks()) | |
| }.bind(this) | |
| }) | |
| }.bind(this), 300) | |
| } | |
| }, finishSetup = function (event) { | |
| event.stop(), I.Project.onUnload = null; | |
| var form = event.element(); | |
| isAvailable == form.down("input").getValue() && new C.WinPrompt({ | |
| text: "Enter your invitation code", | |
| width: 400, | |
| parent: win, | |
| okDisabled: !0, | |
| onInsert: function (Window) { | |
| var lastValue = ""; | |
| Window.elem.down("input").setStyle("width:35%").setClass("uc aC").observe("keyup", function () { | |
| var val = Window.elem.down("input").getValue(); | |
| val.length < 4 || val.length > 8 || val == lastValue || (lastValue = val, Window.elem.down("input").disable(), safebyte.request("~safebyte/:invite", { | |
| parameters: "value=" + val, | |
| onComplete: function (t) { | |
| var r = t.responseJSON; | |
| r.valid ? (Window.elem.down("button.ok").enable(), Window.elem.down("input").removeClassName("cRd").setClass("cGd").blur()) : (Window.elem.down("button.ok").disable(), Window.elem.down("input").removeClassName("cGd").setClass("cRd")), Window.elem.down("input").enable() | |
| }.bind(this) | |
| })) | |
| }.bind(this)).setAttribute("maxlength", "6"); | |
| var elem = Window.elem.down(".html > .aC.b6.fs3").setStyle("margin:18px auto 23px"); | |
| Window.elem.down(".html > .uc").insert({ | |
| after: elem | |
| }) | |
| }, | |
| onShow: function () { | |
| win.elem.setClass("o01") | |
| }, | |
| onClose: function () { | |
| win.elem.removeClassName("o01") | |
| }, | |
| onAction: function (isOk, value) { | |
| isOk && (this.invite = value, I.Project.theme("grass"), setTimeout(function () { | |
| win.elem.removeClassName("hasFocus").setClass("trans2 zoomMini o0"), setTimeout(function () { | |
| win.close({ | |
| duration: 0 | |
| }) | |
| }, 1e3), this.generatedPW = u.generate(), safebyte.request("POST", "~" + isAvailable + "/:create", { | |
| parameters: { | |
| pw: this.generatedPW.toSHA1(), | |
| invite: this.invite, | |
| ref: this.ref || "" | |
| }, | |
| onComplete: function (event) { | |
| event.responseJSON.token && (I.Project.pageLoad(), this.onLoad({ | |
| name: isAvailable, | |
| token: event.responseJSON.token, | |
| pwHint: this.generatedPW.toSHA1().substr(0, 5) | |
| }), I.Content.elem.removeClassName("blured").setClass("o0 z09"), this.timeout(function () { | |
| I.Project.pageLoad(), I.Content.elem.removeClassName("trans02").setClass("trans1"), this.timeout(function () { | |
| I.Project.pageReady(), I.Content.elem.removeClassName("o0 z09"), this.timeout(function () { | |
| I.Content.elem.removeClassName("trans1"), setTimeout(function () { | |
| I.Content.elem.down("#title").setStyle("position:inherit"), I.Navigation.elem.down().setStyle("position:fixed") | |
| }, 500) | |
| }.bind(this), 1.3) | |
| }.bind(this), .7) | |
| }.bind(this), .1)) | |
| }.bind(this) | |
| }) | |
| }.bind(this), 300)) | |
| }.bind(this) | |
| }) | |
| }.bind(this), | |
| win = new C.Window({ | |
| style: "margin-top:-20px;padding:30px 0 0", | |
| width: 660, | |
| className: "aC", | |
| visible: 1e3, | |
| cover: !0, | |
| onInsert: function (Window) { | |
| Window.elem.parseLinks() | |
| }, | |
| onShow: function (Window) { | |
| setTimeout(function () { | |
| Window.elem.down("input").focus() | |
| }, 100), Window.elem.down("input").watchInput({ | |
| replace: { | |
| from: ["-", " "], | |
| to: "_" | |
| }, | |
| length: 20 | |
| }).observe("keyup", checkName.bind(this)), Window.elem.down("form").observe("submit", finishSetup.bind(this)), Window.elem.down(".html").setStyle("overflow:visible"), setTimeout(function () { | |
| Window.elem.down(".memberInfo").xcss("transition:height 1s, opacity 1s .5s").removeClassName("o0").setStyle("height:100px") | |
| }.bind(this), 1e3) | |
| }, | |
| html: '<div style="height:175px" class="aC pR"><h1 class="b3" style="margin:0 50px 5px 50px;font-size:80px">Hi!</h1><h2 class="b4 fs2 o03 createStatus" style="line-height:30px">You need to choose a <span class="b4">Username</span><br />to use the requested Feature</h2></div><form method="post" action="" class="bR bg oH cB" style="margin:15px 0 0;box-shadow:none;padding:25px 0 25px"> <div style="width:530px;margin:0 auto"> <div class="pA o05 trans02 b3" style="margin:12px 0 0 22px;font-size:23px;"><span class="b6">safe</span><span class="b3">byte</span>.com<span class="o02">/</span>~</div> <input autocomplete="off" type="text" name="user" onfocus="$(this).previous().removeClassName(\'o05\')" onblur="$(this).previous().addClassName(\'o05\')" class="b6 defaultFont" style="margin:0;color:#000;font-size:23px;padding-left:180px;padding-top:11px;padding-bottom:10px;width:345px" /> </div> <div class="oH trans03 butSubmit" style="height:0"> <button class="large" style="margin-top:18px;width:534px">Finish setup</button> </div></form><div class="pA fs6 w100 aC b4 i o0 oH trans1 bgText memberInfo" style="bottom:-100px;height:0px"> <hr class="w50 o02" style="margin:20px auto 10px" /> You are already one of our great users? <a href="login" class="a">Click here to Sign in!</a></div>' | |
| }); | |
| I.Project.onUnload = function () { | |
| return this._timeoutEvents.each(function (event) { | |
| clearTimeout(event) | |
| }.bind(this)), this.ready = !1, win.close(), I.Content.elem.removeClassName("o0"), !0 | |
| }.bind(this) | |
| }, | |
| addMail: function (onReady, onCancel) { | |
| onReady = Object.isFunction(onReady) ? onReady : Prototype.emptyFunction, onCancel = Object.isFunction(onCancel) ? onCancel : function () { | |
| location.reload() | |
| }; | |
| var win = new C.WinPrompt({ | |
| placeholder: "Email address", | |
| width: 400, | |
| onChange: function (value) { | |
| win.elem.down("button.ok").disabled = !value.isMail() | |
| }, | |
| onShow: function (win) { | |
| win.elem.down("button.ok").disabled = !0, win.elem.down("button.ok").title = "!+5", win.elem.down(".buttons").parseTitle() | |
| }, | |
| onCancel: function () { | |
| return I.Windows.resetSpawn(), new C.WinConfirm('Are you really sure?__You won\'t be able to access your account again!<br><span class="fs6 i">That would be like throwing away a brand new toy.</span>', { | |
| parent: win, | |
| type: "email", | |
| okText: '<span class="cRd">I am sure, exit</span>', | |
| cancelText: '<span class="cGd">Hell no, back please!</span>', | |
| onInsert: function (Window) { | |
| Window.elem.down("button.cancel").title = "!+5", Window.elem.down(".buttons").parseTitle() | |
| }, | |
| onAction: function (isOK) { | |
| return isOK ? (win.close(null), onCancel(win), !0) : void 0 | |
| } | |
| }), !1 | |
| }, | |
| onConfirm: function (value, Window) { | |
| return (value + "").isMail() ? (win.elem.setClass("o03"), this.createFinish(value, function (isReady) { | |
| return isReady ? (win.options.onCancel = function () {}, win.close(), onReady(value), void 0) : win.elem.removeClass("o03") | |
| }), !1) : (new C.WinAlert("Please enter a valid address", { | |
| parent: Window | |
| }), !1) | |
| }.bind(this) | |
| }) | |
| }, | |
| createFinish: function (mail, cb, quiet, parent) { | |
| I.Navigation.elem.select(".warning").invoke("remove"), I.User.DB.query('UPDATE user SET address = "' + mail + '"' + (I.User.setting("system:session:pw") ? ', sendpw = "' + I.User.setting("system:session:pw") + '"' : "") + " WHERE" + ' id = "_mail"', function (t) { | |
| if (!quiet && t.responseJSON.e) { | |
| var winError = new C.WinConfirm('"' + mail + '" is already in use!__' + "Do you want safebyte to recover the account?" + '<div class="fs7 o06 mT7">This requires you to have access to ' + mail + "!</div>", { | |
| blur: !1, | |
| cancelText: "use another email", | |
| okText: "recover", | |
| parent: parent, | |
| onConfirm: function () { | |
| new C.WinAlert("Not yet implemented!__Please use another email address :)", { | |
| parent: winError, | |
| blur: !1 | |
| }) | |
| } | |
| }); | |
| return cb(!1), !1 | |
| } | |
| return t.responseJSON.e || I.User.setting("system:session:pw", !1), Object.isFunction(cb) ? cb(!0, t.responseJSON) : void 0 | |
| }) | |
| } | |
| }), I.User = new C.User; | |
| var clearLS = function () { | |
| window.onbeforeunload = Prototype.emptyFunction, localStorage.clear(), top.location.href = "hi" | |
| }, x = clearLS; | |
| C.Database = Class.create(C.Base, { | |
| name: null, | |
| db: "main", | |
| data: {}, | |
| info: {}, | |
| version: 0, | |
| tables: ["user", "element", "reward:50:done"], | |
| syncStop: !1, | |
| syncLast: null, | |
| syncTimeout: null, | |
| ready: !1, | |
| onInsert: null, | |
| onUpdate: null, | |
| onRemove: null, | |
| _onQueryComplete: Prototype.emptyFunction, | |
| preSave: {}, | |
| initialize: function (name) { | |
| return this.ready = !1, this.name = name, this.data = {}, this.info = {}, this.version = 0, "object" != typeof I.DB[this.name] ? (this.readLocalStorage(), I.DB[this.name] = this) : this.ready = !0, I.DB[this.name] | |
| }, | |
| localStorage: null, | |
| readLocalStorage: function () { | |
| return "object" != typeof localStorage ? null : (this.version = localStorage.getItem(this.name + ":database:version") || 0, this.version > 0 && (this.data = {}, this.info = localStorage.getItem(this.name + ":database:info").evalJSON(), Object.keys(this.info).each(function (tableName) { | |
| var key = this.name + ":database:data:" + tableName; | |
| localStorage.getItem(key) && (this.data[tableName] = localStorage.getItem(key).evalJSON()) | |
| }.bind(this))), void 0) | |
| }, | |
| writeLocalStorage: function () { | |
| return "object" != typeof localStorage ? null : (Object.keys(this.info).each(function (tableName) { | |
| this.info[tableName].lastChange > this.info[tableName].lastSave && (this.info[tableName].lastSave = ((new Date).getTime() / 1e3).round(), localStorage.setItem(this.name + ":database:data:" + tableName, Object.toJSON(this.data[tableName]))) | |
| }.bind(this)), localStorage.setItem(this.name + ":database:info", Object.toJSON(this.info)), localStorage.setItem(this.name + ":database:version", this.version), this) | |
| }, | |
| collect: function (table, funct) { | |
| if (!this.data[table]) return -1; | |
| var output = {}; | |
| return Object.keys(this.data[table]).each(function (id) { | |
| funct(this.data[table][id]) && (output[id] = this.data[table][id]) | |
| }.bind(this)), output | |
| }, | |
| find: function (table, funct) { | |
| if (!this.data[table]) return -1; | |
| var output = null, | |
| skip = !1; | |
| return Object.keys(this.data[table]).each(function (id) { | |
| skip || funct(this.data[table][id]) && (output = this.data[table][id], skip = !0) | |
| }.bind(this)), output | |
| }, | |
| get: function (table) { | |
| if (!this.data[table]) return null; | |
| var id = arguments[1] || !1; | |
| return id ? (id = ("_" == id.substr(0, 1) ? "" : "_") + id, this.data[table][id]) : this.data[table] | |
| }, | |
| set: function (table, id, key, value) { | |
| return this.data[table] ? (!value && key && "object" == typeof key ? this.data[table][id] = key : this.data[table][id] || (this.data[table][id] = {}), this.data[table][id] && "object" == typeof this.data[table][id] && (this.data[table][id][key] = value), this.changed(table), this.data[table][id]) : null | |
| }, | |
| incr: function (table, id, key, value) { | |
| return this.data[table] && "object" == typeof this.data[table][id] && this.data[table][id].hasOwnProperty(key) ? (this.data[table][id][key] += value, this.changed(table), this.data[table][id][key]) : null | |
| }, | |
| tableCreate: function (row) { | |
| this.data[row.table] = {}, this.info[row.table] = { | |
| lastSave: 0, | |
| lastChange: 0, | |
| inserted: 0, | |
| updated: 0 | |
| } | |
| }, | |
| _writeOnExit: !1, | |
| changed: function (tableName) { | |
| return this.info[tableName].lastChange = ((new Date).getTime() / 1e3).round(), this._writeOnExit || (this._writeOnExit = !0, I.Project.addBeforeUnload(this.writeLocalStorage.bind(this))), this | |
| }, | |
| insert: function (row) { | |
| return "object" != typeof this.data[row.table] && this.tableCreate(row), row.data && "delete" === row.data ? this.remove(row) : this.data[row.table][row.id] ? this.update(row) : (this.info[row.table].inserted++, this.changed(row.table), this.data[row.table][row.id] = row.data, row.data && "object" == typeof row.data && (this.data[row.table][row.id].id = row.id), "element" == row.table && this.calculateElementDataInsert(row), Object.isFunction(this.onInsert) && this.onInsert(row), "insert") | |
| }, | |
| update: function (row) { | |
| var oldData = { | |
| id: row.id | |
| }; | |
| return "object" != typeof row.data || Object.isArray(row.data) ? this.data[row.table][row.id] = row.data : Object.keys(row.data).each(function (key) { | |
| oldData[key] = this.data[row.table][row.id][key], this.data[row.table][row.id][key] = row.data[key] | |
| }.bind(this)), this.info[row.table].updated++, this.changed(row.table), "element" == row.table && this.calculateElementDataUpdate(row, oldData), Object.isFunction(this.onUpdate) && this.onUpdate(oldData), "update" | |
| }, | |
| remove: function (row) { | |
| if ("delete" != row.data) return "remove"; | |
| if (!this.data[row.table].hasOwnProperty(row.id)) return "remove"; | |
| var oldData = this.data[row.table][row.id]; | |
| return delete this.data[row.table][row.id], this.changed(row.table), "element" == row.table && this.calculateElementDataDelete(row, oldData), Object.isFunction(this.onRemove) && this.onRemove(row), "remove" | |
| }, | |
| calculateElementDataInsert: function (row) { | |
| if (row.data.parent) { | |
| if ("_" != row.data.parent.substr(0, 1)) return row.data.parent = "_" + row.data.parent; | |
| "folder" == row.data.type && (Object.isArray(this.preSave[row.id]) || (this.preSave[row.id] = []), this.data.element[row.id].children = this.preSave[row.id]), "_0" != row.data.parent && ("object" == typeof this.data.element[row.data.parent] ? (Object.isArray(this.data.element[row.data.parent].children) || (this.data.element[row.data.parent].children = []), this.data.element[row.data.parent].children.push(row.id)) : (Object.isArray(this.preSave[row.data.parent]) || (this.preSave[row.data.parent] = []), this.preSave[row.data.parent].push(row.id)), I.Element[row.data.parent] && I.Element[row.data.parent].refresh()) | |
| } | |
| }, | |
| calculateElementDataUpdate: function (row, oldData) { | |
| row.data.parent != oldData.parent && ("_0" != oldData.parent && (this.data.element[oldData.parent].children = this.data.element[oldData.parent].children.without(oldData.id), I.Element[oldData.parent] && I.Element[oldData.parent].refresh()), "_0" != row.data.parent && ("object" != typeof this.data.element[row.data.parent].children && (this.data.element[row.data.parent].children = []), this.data.element[row.data.parent].children.push(row.id), I.Element[row.data.parent] && I.Element[row.data.parent].refresh()), I.Element[row.id] && I.Element[row.id].refresh()) | |
| }, | |
| calculateElementDataDelete: function (row, oldData) { | |
| "_0" != oldData.parent && this.data.element[oldData.parent] && (this.data.element[oldData.parent].children = this.data.element[oldData.parent].children.without(oldData.id), I.Element[oldData.parent] && I.Element[oldData.parent].refresh()), I.Element[row.id] && I.Element[row.id].destroy() | |
| }, | |
| load: function () { | |
| return 0 === this.ready ? null : (this.ready = 0, this.syncTimeout || (this.syncTimeout = setInterval(this.syncAuto.bind(this), 2e3)), this.syncLastVersion == this.version && c("Duplicate Sync Request"), this.syncLast = (new Date).getTime(), this.syncLastVersion = this.version, safebyte.request("~" + this.name + "/:sync", { | |
| method: "POST", | |
| parameters: "version=" + this.version + "&db=" + this.db + "&tables=" + this.tables.join(",") + (this.name ? "&name=" + this.name : null), | |
| onComplete: this._onLoad.bind(this) | |
| }), void 0) | |
| }, | |
| syncAuto: function () { | |
| var timeout = 10; | |
| return document.hasFocus() || (timeout = 120), this.syncStop || !this.ready || this.syncLast + 1e3 * timeout > (new Date).getTime() ? null : (this.load(), void 0) | |
| }, | |
| sync: function (onComplete) { | |
| return this._onQueryComplete = Object.isFunction(onComplete) ? onComplete : Prototype.emptyFunction, this.load() | |
| }, | |
| query: function (query) { | |
| Object.isArray(query) || (query = [query]); | |
| var options = arguments[1] || {}; | |
| Object.isFunction(options) && (options = { | |
| onComplete: options | |
| }), Object.isFunction(options.onComplete) && (this._onQueryComplete = options.onComplete), options.asynchronous = !1, options.onComplete = this._onLoad.bind(this), options.parameters = "version=" + this.version + "&db=" + this.db + "&query=" + encodeURIComponent(query.join(";")), safebyte.request("POST", "~" + I.User.get("name") + "/:query", options) | |
| }, | |
| addNotifications: function (res) { | |
| !Object.isArray(res.data) || this.version < 1 || res.data.each(function (row) { | |
| if ("element" == row.table && "insert" == row.action) { | |
| var pointer = this.data.element[row.data.parent], | |
| childId = row.data.id || row.id; | |
| row.data.seen = !1; | |
| for (var i = 0; pointer; i++) Object.isArray(pointer.notifications) || (pointer.notifications = []), childId && !pointer.notifications.include(childId) && pointer.notifications.push(childId), I.Element[pointer.id] && I.Element[pointer.id].refresh(row.data), pointer = this.data.element[pointer.parent] | |
| } else "element" == row.table && "delete" == row.action || "event" == row.table && "insert" == row.action && (this.get("user", "_notifications").event += 1, row.data.seen = !1) | |
| }.bind(this)) | |
| }, | |
| _onLoad: function (t) { | |
| if (t.responseJSON.e) switch (t.status) { | |
| case 404: | |
| return "error/404".go(); | |
| case 401: | |
| if (I.User.isActivated()) return "lock".go() | |
| } | |
| var oldVersion = this.version; | |
| t.responseJSON.version >= this.version && (t.responseJSON.data.each(function (row) { | |
| row.action = this.insert(row) | |
| }.bind(this)), this.version = t.responseJSON.version, oldVersion > 0 && this.addNotifications(t.responseJSON), I.Safebox.onDB(this)), this._onQueryComplete(t), this._onQueryComplete = Prototype.emptyFunction, this.syncLast = (new Date).getTime(), this.ready = !0 | |
| } | |
| }), C.Fullscreen = Class.create(C.Base, { | |
| api: null, | |
| active: !1, | |
| initialize: function () { | |
| var element = $$("body").first(); | |
| this.api = element.requestFullScreen || element.mozRequestFullScreen || element.webkitRequestFullScreen, Object.isFunction(this.api) || (this.api = !1) | |
| }, | |
| toggle: function () { | |
| this.active ? this.leave() : this.enter() | |
| }, | |
| enter: function () { | |
| var body = $$("body").first(); | |
| body.requestFullScreen ? body.requestFullScreen() : body.mozRequestFullScreen ? body.mozRequestFullScreen() : body.webkitRequestFullScreen && body.webkitRequestFullScreen(), this.active = !0 | |
| }, | |
| leave: function () { | |
| var body = $$("body").first(); | |
| body.requestFullScreen ? document.fullScreen && body.exitFullScreen() : document.mozFullScreen ? document.mozCancelFullScreen() : body.webkitRequestFullScreen && document.webkitIsFullScreen && document.webkitCancelFullScreen(), this.active = !1 | |
| }, | |
| available: function () { | |
| return this.api ? !0 : !1 | |
| } | |
| }), Draggable.prototype.initialize = Draggable.prototype.initialize.wrap(function ($super, element) { | |
| $super(element, arguments[2]), Event.observe(this.handle, "touchstart", this.eventMouseDown) | |
| }), Draggables.register = Draggables.register.wrap(function ($super, draggable) { | |
| $super(draggable), 1 == this.drags.length && (Event.observe(document, "touchend", this.eventMouseUp), Event.observe(document, "touchcancel", this.eventMouseUp), Event.observe(document, "touchleave", this.eventMouseUp), Event.observe(document, "touchmove", this.eventMouseMove)) | |
| }); | |
| var fastDraggable = Class.create(Draggable, { | |
| startDrag: function ($super, event) { | |
| $super(event), fastDroppables.onDragStart(event) | |
| }, | |
| updateDrag: function ($super, event, pointer) { | |
| $super(event, pointer), fastDroppables.show(pointer, this.element) | |
| }, | |
| finishDrag: function ($super, event, success) { | |
| $super(event, success), success && (dropped = fastDroppables.fire(event, this.element)), fastDroppables.reset() | |
| } | |
| }), | |
| fastDroppables = { | |
| drops: [], | |
| positions: [], | |
| onDragStart: function () { | |
| this.insertTrigger() | |
| }, | |
| onDragFinish: function () { | |
| this.removeTrigger() | |
| }, | |
| remove: function (element) { | |
| this.drops = this.drops.reject(function (d) { | |
| return d.element == $(element) | |
| }) | |
| }, | |
| add: function (element) { | |
| element = $(element); | |
| var options = Object.extend({ | |
| greedy: !0, | |
| interactive: !1, | |
| hoverclass: null, | |
| tree: !1 | |
| }, arguments[1] || {}); | |
| return options.accept && (options.accept = [options.accept].flatten()), Element.makePositioned(element), options.element = element, this.drops.push(options), this | |
| }, | |
| insertTrigger: function () { | |
| this.drops.each(function (drop) { | |
| var data = { | |
| point: drop.element.viewportOffset(), | |
| size: drop.element.getDimensions() | |
| }; | |
| data.point[1] + data.size.height < 0 || $(document.body).insert({ | |
| bottom: '<div class="dropTrigger" id="dropTrigger_' + drop.element.identify() + '" ' + 'style="z-index:999; position:absolute; left:' + data.point[0] + "px;" + " top:" + data.point[1] + "px; width:" + data.size.width + "px;" + " height:" + data.size.height + "px; opacity:0;" + ' background:rgba(255,255,255,0);"></div>' | |
| }) | |
| }.bind(this)), $$(".dropTrigger").invoke("observe", "mouseover", this.onTriggerHover.bind(this)).invoke("observe", "mouseout", this.onTriggerOut.bind(this)) | |
| }, | |
| refreshTrigger: function () { | |
| this.drops.each(function (drop) { | |
| return drop.refresh && this.dragElem.id != drop.element.id && $("dropTrigger_" + drop.element.id) ? (setTimeout(function () { | |
| if ($("dropTrigger_" + drop.element.id)) { | |
| var data = { | |
| point: drop.element.viewportOffset(), | |
| size: drop.element.getDimensions() | |
| }; | |
| data.point[1] + data.size.height < 0 || $("dropTrigger_" + drop.element.id).setStyle({ | |
| top: data.point[1] + "px", | |
| left: data.point[0] + "px", | |
| width: data.size.width + "px", | |
| height: data.size.height + "px" | |
| }) | |
| } | |
| }, drop.refresh > 0 ? drop.refresh : 1), void 0) : null | |
| }.bind(this)) | |
| }, | |
| removeTrigger: function () { | |
| $$(".dropTrigger").invoke("stopObserving").invoke("remove") | |
| }, | |
| onTriggerHover: function (e) { | |
| var elem = e.element(), | |
| drop = this.drops.detect(function (drop) { | |
| return drop.element.id == elem.id.sub("dropTrigger_", "") | |
| }); | |
| drop && (this.last_active && this.last_active != drop && this.deactivate(this.last_active), this.activate(drop), drop.onHover && drop.onHover($(elem.id.sub("dropTrigger_", "")), drop.element, Position.overlap(drop.overlap, drop.element))) | |
| }, | |
| onTriggerOut: function () { | |
| this.deactivate(this.last_active) | |
| }, | |
| deactivate: function (drop) { | |
| this.dragElem.removeClassName("fastDroppable"), drop.hoverclass && Element.removeClassName(drop.element, drop.hoverclass), this.last_active = null, this.refreshTrigger(drop) | |
| }, | |
| activate: function (drop) { | |
| this.dragElem.addClassName("fastDroppable"), drop.hoverclass && Element.addClassName(drop.element, drop.hoverclass), this.last_active = drop, this.refreshTrigger(drop) | |
| }, | |
| show: function (point, element) { | |
| this.dragElem = element | |
| }, | |
| fire: function (event, element) { | |
| return this.last_active ? (Position.prepare(), this.last_active.element.id == element.id ? !1 : this.last_active.onDrop ? (this.last_active.onDrop(element, this.last_active.element, event), !0) : void 0) : void 0 | |
| }, | |
| reset: function () { | |
| this.removeTrigger(), this.last_active && this.deactivate(this.last_active) | |
| } | |
| }; | |
| Object.isFunction(document.hasFocus) || (document.hasFocus = function () { | |
| return "visible" == document.visibilityState | |
| }), String.prototype.go = function () { | |
| return Object.isNumber(arguments[0]) ? window.setTimeout(function () { | |
| I.Project.go(this) | |
| }.bind(this), 1e3 * arguments[0]) : I.Project.go(this) | |
| }, String.prototype.isMail = function () { | |
| var mailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/; | |
| return mailPattern.test(this) | |
| }, String.prototype.ucFirst = function () { | |
| return this.substr(0, 1).toUpperCase() + this.substr(1) | |
| }, String.prototype.toURL = function () { | |
| return encodeURI(this.gsub(" ", "-")) | |
| }, String.prototype.fromURL = function () { | |
| return decodeURI(this.gsub("-", " ")) | |
| }, String.prototype.fromISOString = function () { | |
| function fastDateParse(y, m, d, h, i, s, ms) { | |
| return new Date(y, m - 1, d, h || 0, +(i || 0) - this, s || 0, ms || 0) | |
| } | |
| function isoDateString(str) { | |
| var tz = str.substr(10).match(/([\-\+])(\d{1,2}):?(\d{1,2})?/) || 0; | |
| return tz && (tz = tzoffset + ("-" == tz[1] ? -1 : 1) * (null != tz[3] ? 60 * +tz[2] + +tz[3] : +tz[2])), fastDateParse.apply(tz || 0, str.split(/\D/)) | |
| } | |
| var tzoffset = (new Date).getTimezoneOffset(); | |
| return isoDateString(this) | |
| }, String.prototype.reverse = function () { | |
| return this.split("").reverse().join("") | |
| }, String.prototype.parseDate = function () { | |
| if ((this + "").indexOf(":") < 0) return (new Date).setTime(0); | |
| var date = new Date, | |
| parts = String(this).split(/[- :TZ+]/); | |
| return date.setFullYear(parts[0]), date.setMonth(parts[1] - 1), date.setDate(parts[2]), date.setHours(parts[3]), date.setMinutes(parts[4]), date.setSeconds(parts[5]), date.setMilliseconds(0), parts[6] && (c("parseDate6:" + parts[6]), date.setHours(parseInt(parts[3]) + parseInt(parts[6]))), date | |
| }, String.prototype.makeSortable = function () { | |
| return this.gsub("ä", "ae").gsub("ö", "oe").gsub("ü", "ue").gsub("ß", "ss") | |
| }, String.prototype.parseNumber = function () { | |
| var nr = parseFloat(this.gsub(",", "")); | |
| return !isNaN(parseFloat(nr)) && isFinite(nr) ? nr : 0 | |
| }, Number.prototype.parseDate = function () { | |
| var number = this; | |
| return number.toString().length < 13 && (number = 1e3 * number), new Date(number) | |
| }, Number.prototype.number = function (c, d, t) { | |
| var n = this; | |
| if (c === !0) return n > 1e6 ? (n / 1e6).toFixed(0) + "m" : n > 1e3 ? (n / 1e3).toFixed(0) + "k" : n.toFixed(0); | |
| var c = isNaN(c = Math.abs(c)) ? 2 : c, | |
| d = void 0 == d ? "." : d, | |
| t = void 0 == t ? "," : t, | |
| s = 0 > n ? "-" : "", | |
| i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", | |
| j = (j = i.length) > 3 ? j % 3 : 0; | |
| return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "") | |
| }, Number.prototype.random = function (min) { | |
| var max = this; | |
| return min || (min = 0), Math.floor(Math.random() * (max - min + 1)) + min | |
| }, Number.prototype.toSize = function (options) { | |
| "number" == typeof options && (options = { | |
| decimals: options | |
| }); | |
| var options = Object.extend({ | |
| decimals: 2, | |
| hide00: !0, | |
| labels: ["byte", "KB", "MB", "GB", "TB"] | |
| }, arguments[0] || {}), | |
| size = this; | |
| if (1024 >= size) return size.number(0) + ' <span class="sizelabel">' + options.labels[0] + "</span>"; | |
| for (var i = 0; size > 1024;) size /= 1024, i++; | |
| var res = size.number(options.decimals); | |
| return options.hide00 && parseInt(res.split(".").last()) < 1 && (res = size.number(0)), res + ' <span class="sizelabel">' + options.labels[i] + "</span>" | |
| }, Element.prototype.xcss = function (css) { | |
| var prefix = ["-moz-", "-o-", "-webkit-", "-ms-", ""]; | |
| return prefix.each(function (p) { | |
| $(this).style.cssText += ";" + p + css | |
| }.bind(this)), this | |
| }, Element.prototype.data = function (key) { | |
| if (arguments.length > 1) { | |
| for (var i = 0; i < arguments.length; i += 2) this.setAttribute("data-" + arguments[i], arguments[i + 1]); | |
| return this | |
| } | |
| return this.getAttribute("data-" + key) | |
| }, Element.removeClassNames = function (elem, classNames) { | |
| if (!Object.isElement(elem)) return null; | |
| var array = classNames.split(" "); | |
| return array.each(function (className) { | |
| elem.removeClassName(className) | |
| }), elem | |
| }, Element.prototype.removeClassNames = function (classNames) { | |
| return Element.removeClassNames($(this), classNames) | |
| }, Element.setClass = function (elem, classNames) { | |
| var array = classNames.split(" "); | |
| return array.each(function (className) { | |
| elem.removeClassName(className), elem.addClassName(className) | |
| }), elem | |
| }, Element.prototype.setClass = function (classNames) { | |
| return Element.setClass($(this), classNames) | |
| }, Element.prototype.eCountBox = function (nr) { | |
| var elem = $(this); | |
| "static" == elem.getStyle("position") && elem.setStyle("position:relative"), elem.insert('<div class="eCount effect o0">' + (nr > 0 ? "+" : "") + nr.number(0) + "</div>"); | |
| var child = elem.down(".eCount.effect"); | |
| return child.setStyle("margin:-" + child.getHeight() / 2 + "px 0 0 -" + child.getWidth() / 2 + "px"), setTimeout(function () { | |
| child.setClass("trans05 z25").removeClassNames(" o0"), setTimeout(function () { | |
| child.removeClassNames("z25 trans05").setClass("trans15 z05 o0"), setTimeout(function () { | |
| child.remove() | |
| }, 1510) | |
| }, 600) | |
| }, 1), elem | |
| }, Element.prototype.isInput = function () { | |
| return ["input", "textarea", "select"].include(this.tagName.toLowerCase()) | |
| }, Element.prototype.zoomOut = function (classNames) { | |
| Object.isUndefined(classNames) ? this.setClass("tEaseIn z09 o0 trans03") : this.setClass(classNames); | |
| var remove = function () { | |
| return this.getOpacity() > 0 ? remove.delay(.2) : (this.remove(), void 0) | |
| }.bind(this); | |
| remove() | |
| }, Element.prototype.familyOf = function (selector) { | |
| return Object.isFunction(this.up) ? "#" == selector.substr(0, 1) ? this.up(selector) || this.id == selector.substr(1) : this.up(selector) || (this.up() && this.up().down(selector)) == this : !1 | |
| }, Element.prototype.parseSlides = function () { | |
| return Object.isFunction($(this).down(".bull").onmousedown) ? void 0 : ($(this).select(".bull").each(function (elem) { | |
| elem.onmousedown = function (e) { | |
| var elem = Object.isElement(e) ? e : $(e.element()), | |
| li = elem.up("ul").down("li", elem.data("i")), | |
| old = elem.up("ul").down("li.focus"); | |
| elem.up("ul").select(".bull.focus").invoke("removeClassName", "focus"), Object.isElement(old) && old.removeClassName("focus"), elem.addClassName("focus"), li.addClassName("focus") | |
| }.bind(this) | |
| }.bind(this)), $(this).down(".bull").onmousedown($(this).down(".bull")), this) | |
| }, Element.prototype.parseLinks = function () { | |
| return $(this).select("a").each(function (elem) { | |
| "_blank" != elem.target && (elem.onmousedown = function () { | |
| return I.Project.go(elem.href), !1 | |
| }, elem.onclick = function () { | |
| return !1 | |
| }) | |
| }), this | |
| }, Element.prototype.parseFlags = function () { | |
| var container = $(this); | |
| return $(this).select(".navigation > div").each(function (elem) { | |
| elem.onmousedown = function () { | |
| if (elem.data("show")) { | |
| elem.up(".flags").select(".navigation > div").invoke("removeClassName", "open"), elem.addClassName("open"), elem.up(".flags").data("active", elem.data("show")), elem.up(".flags").select(".content > div").invoke("hide"), $(elem.data("show")).show(); | |
| var width = elem.data("width") || container.data("width"); | |
| if (width && width != elem.up(".window").getWidth()) { | |
| var targetElem = container.up(".window") || container; | |
| I.Windows.activeWindow ? (I.Windows.activeWindow.setSize({ | |
| width: width | |
| }), I.Windows.activeWindow.setPos()) : targetElem.setStyle("width:" + width + (Object.isNumber(width) ? "px" : "")) | |
| } | |
| } | |
| }.bind(this) | |
| }), this | |
| }, Element.prototype.toggleNext = function () { | |
| return $(this).next().toggleClassName("visible"), this | |
| }, Element.prototype.parseTitle = function () { | |
| return $(this).select("*").each(function (elem) { | |
| if (elem.title && Object.isString(elem.title) && "" != elem.title) { | |
| var mouseover = function (event) { | |
| var tooltip = $$(".tooltip").length > 0 ? $$(".tooltip")[0] : $$("body")[0].insert('<div class="tooltip"></div>').down(".tooltip"); | |
| "true" === elem.data("titleHighlight") ? tooltip.setClass("highlight") : tooltip.removeClassName("highlight"), tooltip.update(elem.data("title")), elem.stopObserving("mousemove").observe("mousemove", mousemove.bind(this, tooltip)), elem.stopObserving("mouseout").observe("mouseout", mouseout.bind(this, tooltip)), mousemove(tooltip, event), tooltip.show() | |
| }, mousemove = function (tooltip, event) { | |
| if (Object.isElement(tooltip)) { | |
| var vp = document.viewport.getDimensions(), | |
| pos = { | |
| top: event.clientY + 1, | |
| left: event.clientX + 20 | |
| }; | |
| pos.top + tooltip.getHeight() > vp.height && (pos.top = vp.height - tooltip.getHeight()), pos.left + tooltip.getWidth() > vp.width && (pos.left -= tooltip.getWidth() + 30), tooltip.setStyle({ | |
| top: pos.top + "px", | |
| left: pos.left + "px" | |
| }) | |
| } | |
| }, mouseout = function (tooltip) { | |
| Object.isElement(tooltip) && tooltip.hide() | |
| }; | |
| "!" == elem.title.substr(0, 1) && (elem.title = elem.title.substr(1), elem.data("titleHighlight", "true"), "+" == elem.title.substr(0, 1) && -1 == elem.title.indexOf(" ") && (elem.title = '<span class="b5" style="padding-right:2px">+</span>' + elem.title.substr(1) + '<span class="b3"> Reputation</span>')), elem.data("title", elem.title), elem.title = "", elem.observe("mouseover", mouseover) | |
| } | |
| }), this | |
| }, Element.prototype.watchInput = function (data) { | |
| Object.isString(data) && (data = { | |
| allow: data | |
| }); | |
| var data = Object.extend({ | |
| letters: !0, | |
| numbers: !0, | |
| umlauts: !1, | |
| allow: "_", | |
| deny: !1, | |
| toUpper: !1, | |
| toLower: !1, | |
| maxlength: null, | |
| replace: null, | |
| onType: null, | |
| onBlur: null | |
| }, data || {}); | |
| if (data.allow !== !0) { | |
| var regex = ""; | |
| data.letters && (regex += "a-zA-Z"), data.numbers && (regex += "0-9"), data.umlauts && (data.allow += "äöüßáàâéèêíìîóòôúùû"), data.allow && (regex += data.allow.split("").join("\\")), data.regex = "[^" + regex + "]" + (data.length > 0 ? "{0," + data.length + "}" : "*") | |
| } | |
| return data.replace && (Object.isArray(data.replace.from) || (data.replace.from = [data.replace.from]), Object.isArray(data.replace.to) || (data.replace.to = [data.replace.to])), Object.isFunction(data.onBlur) && $(this).observe("blur", function (e) { | |
| var res = data.onBlur(e.element(), e.element().getValue()); | |
| res && e.element().setValue(res) | |
| }), $(this).observe("keypress", function (e) { | |
| e.element().getValue(), setTimeout(function () { | |
| var value = e.element().getValue(); | |
| if (data.replace && data.replace.from.each(function (from, i) { | |
| var to = data.replace.to[i] || data.replace.to.last(); | |
| value = value.gsub(from, to) | |
| }), value = value.replace(new RegExp(data.regex, "g"), ""), data.maxlength > 0 && value.length > data.maxlength && (value = value.substr(0, data.maxlength)), data.toUpper && (value = value.toUpperCase()), data.toLower && (value = value.toLowerCase()), e.element().setValue(value), Object.isFunction(data.onType)) { | |
| var res = data.onType(e.element(), value); | |
| Object.isString(res) && e.element().setValue(res) | |
| } | |
| }, 1) | |
| }), this | |
| }, Date.prototype.display = function () { | |
| var method = arguments[0] ? arguments[0] : "default", | |
| interpret = arguments[1] ? arguments[1] : !1; | |
| if (interpret) { | |
| var secAgo = ((new Date).getTime() - this.getTime()) / 1e3, | |
| l = ""; | |
| switch (interpret) { | |
| case "m": | |
| l = "now, sec, min, min, hr, hr, day, day"; | |
| break; | |
| case "s": | |
| l = "now,s,s,m,m,h,h,d,d"; | |
| break; | |
| default: | |
| l = " now, second, seconds, minute, minutes, hour, hours, day, days" | |
| } | |
| return l = _(l).split(","), out = 10 > secAgo ? l[0] : 60 > secAgo ? secAgo.toFixed(0) + l[2] : 3600 > secAgo ? ["", "%n" + l[3], "%n" + l[4]].numerus((secAgo / 60).toFixed(0)) : 86400 > secAgo ? ["", "%n" + l[5], "%n" + l[6]].numerus((secAgo / 3600).toFixed(0)) : 259200 > secAgo ? ["", "%n" + l[7], "%n" + l[8]].numerus((secAgo / 86400).toFixed(0)) : this.display(method, 0), '<span class="idate" data-method="' + method + '" data-label="' + interpret + '" data-time="' + this.getTime() + '">' + out + "</span>" | |
| } | |
| var out = ""; | |
| switch (method) { | |
| case "default": | |
| out = this.toString("dd.MM.yyyy hh:mm"); | |
| break; | |
| case "plain": | |
| out = this.toString("dd.MM.yyyy"); | |
| break; | |
| case "locale": | |
| out = this.toLocaleString(); | |
| break; | |
| case "time": | |
| out = this.toString("hh:mm:ss") | |
| } | |
| return out | |
| }, setInterval(function () { | |
| $$(".idate").each(function (elem) { | |
| elem.visible() && elem.data("time") && elem.data("method") && elem.update(new Date(parseInt(elem.data("time"))).display(elem.data("method"), elem.data("label"))) | |
| }) | |
| }, 1e4), Array.prototype.numerus = function (i, append) { | |
| if (Object.isUndefined(i)) return ""; | |
| append = ["<", ">"].include(append) ? append : !1; | |
| var n = i; | |
| return i = parseInt(i), 2 == this.length && (i = 1 != i ? 1 : 0), i > this.length - 1 && (i = this.length - 1), 0 > i && (i = 0), "" + ("<" == append ? n : "") + this[i].gsub("%n", n) + (">" == append ? n : "") | |
| }, Array.prototype.shuffle = function () { | |
| for (var tmp, rand, i = 0; i < this.length; i++) rand = Math.floor(Math.random() * this.length), tmp = this[i], this[i] = this[rand], this[rand] = tmp; | |
| return this | |
| }, Object.isEvent = function (obj) { | |
| return "object" != typeof obj ? !1 : Object.isFunction(obj.element) | |
| }, Object.extend(Event, { | |
| wheel: function (event) { | |
| var delta = 0; | |
| return event || (event = window.event), event.wheelDelta ? delta = event.wheelDelta / 120 : event.detail && (delta = -event.detail / 3), Math.round(delta) | |
| } | |
| }), Effect.Transitions.EaseFromTo = function (pos) { | |
| return -.5 * ((pos -= 2) * pos * pos * pos - 2) | |
| }, Effect.Transitions.EaseFrom = function (pos) { | |
| return Math.pow(pos, 4) | |
| }, Effect.Transitions.EaseTo = function (pos) { | |
| return (pos - 1) * pos * pos * pos - 1 | |
| }, window.onload = function () { | |
| I.Content = new C.Content, I.Windows = new C.Windows, I.Project = new C.Project, I.Fullscreen = new C.Fullscreen, I.Navigation = new C.Navigation, I.Sidebar = new C.Sidebar, I.Safebox = new C.Safebox, I.Player = new C.Player, I.Footer = new C.Footer, I.Taskbar = new C.Taskbar | |
| }, C.Content = Class.create(C.GUI, { | |
| _visible: !0, | |
| initialize: function () { | |
| $("content") || this.getBody().update('<div id="loading"><img src="img/load/gear.gif" /></div><div id="watermark"></div><div id="container"> <div id="bg"></div> <div id="content" class="maxWidth"> <div id="head" style="display:none"> <div class="maxWidth"><div id="title" class="bgText"><div class="text"></div></div></div> </div> <div id="main"></div> </div></div>'), this.elem = $("content"), this.enableScrollEvent() | |
| }, | |
| _className: "", | |
| setClass: function (str, duration) { | |
| duration > 0 && setTimeout(this.setClass.bind(this, this._className), 1e3 * duration), this.elem.setClass(str).removeClassName(this._className), this.elem.next() && this.elem.next().setClass(str).removeClassName(this._className), this._className = str | |
| }, | |
| setCenterMode: function (enable) { | |
| enable ? (this.elem.setClass("centerMode").setStyle("min-width:274px;width:274px"), I.Sidebar.hide(), I.Footer.hide(), I.Content.hideTitle()) : (this.elem.removeClassName("centerMode").setStyle("min-width:980px;width:auto"), $("navDrag").show(), I.Sidebar.show(), I.Footer.show()) | |
| }, | |
| minimize: function () { | |
| this._minimizeClass = Object.isString(arguments[0]) ? arguments[0] : "trans1", this.setClass("trans1", 1.1), $$("#container > .center").invoke("addClassName", "zoomMini o0"), this.elem.setClass("zoomMini o0") | |
| }, | |
| _minimizeClass: null, | |
| _maximizeClass: null, | |
| maximize: function () { | |
| this.setClass("trans1", 1.1), this.elem.show().removeClassNames("o0 zoomMini"), I.Navigation.elem.down().setStyle("position:inherit"), this.timeout(function () { | |
| I.Content.elem.down("#title").setStyle("position:inherit"), I.Navigation.elem.down().setStyle("position:fixed") | |
| }, 1.1) | |
| }, | |
| scroll: function () { | |
| var scrollTop = document.viewport.getScrollOffsets().top; | |
| scrollTop > 30 ? this.elem.down("#title").addClassName("scrolled") : this.elem.down("#title").removeClassName("scrolled") | |
| }, | |
| verticalOffset: function () { | |
| return (document.viewport.getWidth() - this.elem.getWidth()) / 2 | |
| }, | |
| hideTitle: function () { | |
| this.elem.down("#head").hide(), $("main").removeClassName("paddingTitle") | |
| }, | |
| setTitle: function (html, borderVisible) { | |
| if (Object.isUndefined(borderVisible)) var borderVisible = !0; | |
| return borderVisible ? this.elem.down("#title").removeClassName("noBG") : this.elem.down("#title").addClassName("noBG"), this.elem.down("#head").show(), this.elem.down("#title .text").update(html).parseLinks(), $("main").addClassName("paddingTitle"), this.elem.down("#title") | |
| } | |
| }), C.Navigation = Class.create(C.GUI, { | |
| _visible: !1, | |
| initialize: function () { | |
| $("nav") || I.Content.elem.insert('<div id="nav" style="display:none"><div style="position:fixed;margin-left:-230px"> <div id="navDrag" class="trans03 gui"></div></div>'), this.elem = $("nav").parseLinks(), this.setPosition("right"), this.dragInit(), this.enableResizeEvent() | |
| }, | |
| resize: function () { | |
| if (this._visible) { | |
| var main = $("main"); | |
| if (document.viewport.getWidth() < 800 || document.viewport.getHeight() < 550) main.setStyle("padding-right:0;padding-left:0;"), $$("#title").invoke("setStyle", "margin-left:0px"), this.elem.hide(); | |
| else { | |
| var css = "left" == this._position ? { | |
| paddingLeft: "280px" | |
| } : { | |
| paddingRight: "280px" | |
| }; | |
| main.setStyle(css), $$("#title").invoke("setStyle", "margin-left:" + ("left" == this._position ? 275 : 0) + "px"), this.elem.show() | |
| } | |
| } | |
| }, | |
| infoActive: function (bool) { | |
| this.elem.select(".warning").invoke(bool ? "removeClassName" : "setClass", "invisible") | |
| }, | |
| info: function (data) { | |
| this.elem.down(".warning") || (I.Sidebar.elem.insert({ | |
| after: '<div class="warning trans03"> <div class="box gloss light aL aC pR" style="margin:14px 0 6px"><div style="padding:16px 22px"> <b class="pA close fs7 cP o03" style="top:8px;right:12px">X</b>' + (data.red ? '<p style="margin:-4px 0 13px 0"><span class="red">' + data.red + "</span></p>" : "") + ' <div class="inlineBlock w40 aL fs5">' + (data.left || "") + "</div>" + ' <div class="inlineBlock vborder gradient o01 aT" style="margin:0 10px;height:' + data.height + 'px"></div>' + ' <div class="inlineBlock w45 aC fs6 aL i b5">' + (data.right || "") + " </div>" + " </div></div>" + "</div>" | |
| }), this.elem.down(".warning span.a").observe("click", data.link), this.elem.down(".warning .close").observe("click", function (e) { | |
| e.element().up(".warning").remove() | |
| })) | |
| }, | |
| onUserLoad: function () { | |
| I.User.DB.get("user", "mail") && I.User.DB.get("user", "mail").verified ? (this.elem.select(".warning").invoke("remove"), 0 == I.User.DB.get("reward", "_reward_tour").done && this.info({ | |
| height: 42, | |
| left: "Take the <b>Tour</b>!", | |
| right: '<span class="a">Learn more</span> about <b class="b8">safe</b>byte', | |
| link: function () { | |
| I.Navigation.elem.select(".warning").invoke("remove"), I.Module.load("intro") | |
| } | |
| })) : this.info({ | |
| height: 66, | |
| left: "This is a <b>single-use</b> account!", | |
| right: '<span class="o05">»</span> <span class="a">Activate</span> account by email <span class="o05">(free)</span>', | |
| link: I.User.addMail.bind(I.User) | |
| }), this._position = I.User.setting("navigation:position") || "right", this.setPosition(this._position), this.resize() | |
| }, | |
| dragInit: function () { | |
| Prototype.Browser.Gecko ? (this.elem.down("#navDrag").stopObserving("dblclick").observe("dblclick", this.switchSide.bind(this)), this.draggable = new Draggable(this.elem.down(), { | |
| handle: this.elem.down("#navDrag"), | |
| revert: !0, | |
| constraint: "horizontal", | |
| starteffect: Prototype.emptyFunction, | |
| endeffect: Prototype.emptyFunction, | |
| onStart: this.dragStart.bind(this), | |
| onEnd: this.dragEnd.bind(this), | |
| change: this.dragActive.bind(this) | |
| })) : this.elem.down("#navDrag").stopObserving("mousedown").observe("mousedown", this.switchSide.bind(this)) | |
| }, | |
| dragStart: function (e) { | |
| this.elem.down().setStyle("position:fixed"), this.draggable.options.start = e.currentDelta(), this.draggable.options.revert = !0, this.draggable.options.delta = this.draggable.options.start | |
| }, | |
| dragEnd: function () { | |
| I.User.reward("navigation_position") | |
| }, | |
| dragActive: function (e) { | |
| if (this.draggable.options.start) { | |
| var distance = this.draggable.options.delta[0] - e.currentDelta()[0]; | |
| ("left" == this._position && -100 > distance || "right" == this._position && distance > 100) && (this.draggable.options.revert = !1, this.draggable.finishDrag(e, !1), this.draggable.destroy(), this.switchSide()) | |
| } | |
| }, | |
| switchSide: function () { | |
| var data, targetPos = "right" == this._position ? "left" : "right", | |
| vpWidth = document.viewport.getWidth(), | |
| options = { | |
| duration: .5, | |
| afterFinish: this.setPosition.bind(this, targetPos) | |
| }; | |
| data = "left" == targetPos ? { | |
| marginLeft: 0, | |
| left: (vpWidth - I.Content.elem.getWidth()) / 2 + 20, | |
| contentLeft: 275 | |
| } : { | |
| marginLeft: -230, | |
| left: (vpWidth - I.Content.elem.getWidth()) / 2 + I.Content.elem.getWidth() - 20, | |
| contentLeft: 0 | |
| }, this.elem.down().morph("margin-left:" + data.marginLeft + "px;left:" + data.left + "px", options), $$("#title").invoke("morph", "margin-left:" + data.contentLeft + "px", { | |
| duration: .5 | |
| }), $("main").morph("padding-left:" + ("left" == targetPos ? 280 : 0) + "px;padding-right:" + ("right" == targetPos ? 280 : 0) + "px", { | |
| duration: .5 | |
| }) | |
| }, | |
| setPosition: function () { | |
| var pos = arguments[0] || this._position; | |
| arguments[1], css = { | |
| left: "20px", | |
| right: "auto" | |
| }, "right" == pos && (css = { | |
| right: "20px", | |
| left: "auto" | |
| }), this.elem.setStyle(css), this.elem.down().setStyle("position:fixed;left:auto;margin-left:" + ("left" == pos ? "0" : "-230px") + "px"), $$("#title").invoke("setStyle", "margin-left:" + ("left" == pos ? 275 : 0) + "px"), $("main").setStyle("padding-left:" + ("left" == pos ? 280 : 0) + "px;padding-right:" + ("right" == pos ? 280 : 0) + "px"), this._position = pos, this.elem.setClass(pos).removeClassName("left" == pos ? "right" : "left"), I.User.setting("navigation:position", pos), this.dragInit() | |
| } | |
| }), C.Safebox = Class.create(C.GUI, { | |
| _visible: !1, | |
| initialize: function () { | |
| I.Navigation.elem.down().insert({ | |
| top: '<div id="safebox" class="box aC oH" style="display:none"> <img class="logo" src="img/safebyte.png" /> <div class="gui trans03 terminalMode" style="display:none" title="Terminal Mode"></div> <div class="bg" id="navButton"> <div class="search trans05"> <input type="text" autocomplete="off" class="defaultFont" /> <div class="close gui" title="Go back"></div> </div> <a class="butSearch" title="Press <u>s</u> to Search"><div class="gui"></div></a> <a href="" class="butHome" title="Go to your Desk"><div style="background-position:-44px -83px" class="gui"></div></a> <a href="events" class="butEvent" title="See whats going on"><div class="gui" style="background-position:-85px -82px"></div><b class="eCount notification_event trans03 o0"></b></a> <a class="butChat" title="Activate Chat"><div class="gui" style="background-position:-124px -83px"></div><b class="eCount notification_chat trans03 o0"></b></a> <a href="lock" class="butLock" title="Lock System"><div class="gui" style="background-position:-164px -83px"></div></a> <input style="display:none" type="text" /></div>' | |
| }), this.elem = $("safebox").parseTitle().parseLinks(), this.elem.select(".logo, .butHome").invoke("observe", "click", function () { | |
| I.Project.go(I.User.ready ? "~" + I.User.get("name") : "hi") | |
| }), this.elem.select(".butSearch, .#navButton .close").invoke("observe", "mousedown", this.toggleSearch.bind(this)), this.elem.down(".butChat").observe("mousedown", this.enableChat.bind(this)), this.elem.down(".search input").observe("keydown", this.onSearch.bind(this)), I.Fullscreen.available() && this.elem.down(".terminalMode").show().observe("mousedown", I.Fullscreen.toggle.bind(I.Fullscreen)), this.enableKeys(["s", "esc", "f3", "pause, break"]) | |
| }, | |
| counter: 0, | |
| onDB: function (DB) { | |
| if (DB.name === I.User.get("name")) { | |
| var counter = DB.get("user", "_notifications"); | |
| counter && (counter.event + counter.chat > this.counter && (this.audio ? (new Date).getTime() - 5e3 > this.audio.lastPlay && (this.audio.play(), this.audio.lastPlay = (new Date).getTime()) : I.Project.require(I.Audio, function () { | |
| this.audio = I.Audio.play("static/sound/msgNew.mp3", { | |
| volume: 10 | |
| }), this.audio.lastPlay = (new Date).getTime() | |
| }.bind(this))), this.counter = counter.event + counter.chat, I.Project.setTitleNotification(this.counter), counter.event > 0 ? $$(".notification_event").invoke("update", counter.event).invoke("removeClassName", "o0") : $$(".notification_event").invoke("setClass", "o0"), counter.chat > 0 ? $$(".notification_chat").invoke("update", counter.chat).invoke("removeClassName", "o0") : $$(".notification_chat").invoke("setClass", "o0")) | |
| } | |
| }, | |
| key: function (event, keys) { | |
| switch (keys) { | |
| case "f3": | |
| case "s": | |
| "keydown" != event.type || document.activeElement.isInput() || (event.preventDefault(), this.toggleSearch(), this.elem.down(".search input").setValue("")); | |
| break; | |
| case "pause": | |
| case "break": | |
| "lock".go(); | |
| break; | |
| case "esc": | |
| if (document.activeElement == this.elem.down("#navButton .search input")) { | |
| if (event.preventDefault(), this.elem.down("#navButton .search input").setValue("").blur(), this.toggleSearch(), !I.Explorer) return; | |
| I.Explorer.browse() | |
| } | |
| } | |
| }, | |
| enableChat: function () { | |
| "chat".go() | |
| }, | |
| toggleSearch: function () { | |
| var elem = this.elem.down("#navButton .search").toggleClassName("visible"); | |
| elem.hasClassName("visible") && elem.down("input").focus() | |
| }, | |
| activate: function (buttonName) { | |
| this.reset(), this.elem.down("a.but" + buttonName.ucFirst()).addClassName("active") | |
| }, | |
| reset: function () { | |
| $$("#sbText").invoke("remove"), this.elem.down("#navButton").show(), this.elem.select("#navButton > a").invoke("removeClassName", "active") | |
| }, | |
| showText: function (html) { | |
| this.elem.down("#navButton").hide(), $$("#sbText").invoke("remove"), this.elem.insert('<h1 id="sbText" class="aC bg">' + html + "</h1>") | |
| }, | |
| onSearch: function (e) { | |
| return I.Explorer ? (this.timeout(function () { | |
| I.Explorer.search(e.element()) | |
| }.bind(this), .001), void 0) : (this.timeout(this.onSearch.bind(this, e), .4), I.Project.go("~" + I.User.get("name"))) | |
| } | |
| }), C.Audio = Class.create(C.GUI, { | |
| ready: !1, | |
| play: function () { | |
| if ("object" != typeof soundManager) { | |
| var args = arguments; | |
| return I.Project.require(this, function () { | |
| this.play.apply(this.play, args) | |
| }.bind(this)) | |
| } | |
| var data = Object.extend({ | |
| id: "player" + u.generate(), | |
| url: arguments[0], | |
| autoLoad: !0, | |
| autoPlay: !0, | |
| onid3: null, | |
| onfinish: null | |
| }, arguments[arguments.length - 1] || {}); | |
| return soundManager.createSound(data) | |
| }, | |
| load: function () { | |
| this.ready = 0, I.Project.load(["js/lib/soundmanager/script/soundmanager2-nodebug-jsmin.js", | |
| function () { | |
| soundManager.setup({ | |
| url: "js/lib/soundmanager/swf/", | |
| onready: function () { | |
| this.ready = !0 | |
| }.bind(this), | |
| ontimeout: function () { | |
| c("Loaded OK, but unable to start: unsupported/flash blocked, etc.") | |
| } | |
| }) | |
| }.bind(this) | |
| ]) | |
| } | |
| }), I.Audio = new C.Audio, C.Player = Class.create(C.GUI, { | |
| ready: !1, | |
| shuffle: !1, | |
| playing: !1, | |
| current: 0, | |
| playlist: [], | |
| history: [], | |
| Sortables: [], | |
| initialize: function () { | |
| I.Safebox.elem.insert({ | |
| bottom: '<div id="player" class="trans03 noselect"> <div class="aC info" style="padding:5px 0">» ' + _("Add to Playlist") + '</div> <div class="controls bg trans03 aL" style="padding:0;margin-top:-1px"> <div class="fL" style="padding:8px 0 8px 8px"><button class="group left aPrev"><div class="gui trans05" style="background-position:-90px -140px"></div></button><button class="group middle aPlay"><div class="gui trans05" style="background-position:-118px -140px"></div></button><button class="group right aNext"><div class="gui trans05" style="background-position:-144px -140px"></div></button> </div> <div class="fL aC" style="padding:8px 0 8px;width:50px"> <span class="sTime"></span> </div> <div class="fR" style="padding:8px 8px 8px 0"><button class="group left aShuffle" title="' + _("Shuffle Playback") + '"><div class="gui trans05" style="background-position:-174px -140px"></div></button><button class="group middle aSave" style="display:none" title="' + _("Save Playlist") + '"><div class="gui trans05" style="background-position:-205px -140px"></div></button><button class="group right aClose" title="' + _("Close Audio Player") + '"><div class="gui trans05" style="background-position:-228px -140px"></div></button> </div> </div> <div class="playlist aL" style="padding:4px 0 4px"></div> </div>' | |
| }), this.elem = $("player").parseTitle().parseLinks(), this.elem.down(".aPlay").observe("click", function () { | |
| this.playing ? this.pause() : this.play() | |
| }.bind(this)), this.elem.down(".aPrev").observe("click", this.prev.bind(this)), this.elem.down(".aNext").observe("click", this.next.bind(this)), this.elem.down(".aShuffle").observe("click", this.toggleShuffle.bind(this)), this.elem.down(".aSave").observe("click", this.exportPlaylist.bind(this)), this.elem.down(".aClose").observe("click", this.close.bind(this)), fastDroppables.add(this.elem, { | |
| accept: "dragging", | |
| hoverclass: "dragHover", | |
| onDrop: this.onDrop.bind(this) | |
| }) | |
| }, | |
| load: function () { | |
| this.ready = 0, I.Project.require(I.Audio, function () { | |
| this.ready = !0 | |
| }.bind(this)) | |
| }, | |
| toggleShuffle: function (event) { | |
| var activate = event.element().hasClassName("pressed") ? !1 : !0; | |
| this.shuffle = activate, activate ? event.element().setClass("pressed") : event.element().removeClassName("pressed") | |
| }, | |
| getTime: function (pos) { | |
| var time = new Date(pos), | |
| arr = [(time.getSeconds() < 10 ? "0" : "") + time.getSeconds(), time.getMinutes()]; | |
| return time.getHours() > 1 && arr.push(time.getHours() - 1), arr.reverse().join(":") | |
| }, | |
| showPosition: function () { | |
| if (this.playing) { | |
| if (this.sound.position > 0) { | |
| var time = this.getTime(this.sound.position), | |
| progress = (100 * (this.sound.position / this.sound.duration)).toFixed(2); | |
| this.elem.down(".sTime").update(time), this.elem.down(".name.active .progress").setStyle("width:" + progress + "%") | |
| } | |
| this.timeout(this.showPosition.bind(this), .5) | |
| } | |
| }, | |
| add: function (id) { | |
| if (this.playlist.include(id)) return null; | |
| this.playlist.push(id); | |
| var Element = I.Explorer.getElementObject(id); | |
| this.elem.down(".playlist").insert('<div class="name track' + id + '" id="track_' + (this.elem.select(".playlist .name").length + 1) + '" data-id="' + id + '" data-sound="' + Element.getURL("view") + '&start=0&ptype=sbplayer"> <div class="progress trans05"></div> <span class="setPos black o0" data-pos="0"></span> ' + Element._getTitle(!1) + " </div>"); | |
| var elem = this.elem.down(".track" + id); | |
| elem.observe("click", this.select.bind(this)), elem.observe("mouseover", this.mouseOver.bind(this)), elem.observe("mouseout", this.mouseOut.bind(this)), elem.observe("dblclick", function (event) { | |
| var elem = event.element(); | |
| elem.up(".name") && (elem = elem.up(".name")), this.goto(elem.data("id")) | |
| }.bind(this)), elem.down(".setPos").observe("click", function () { | |
| this.playPosition(this.elem.down(".active .setPos").data("pos")) | |
| }.bind(this)), this.playlist.length > 0 && this.elem.removeClassName("active").addClassName("active") | |
| }, | |
| mouseOver: function (elem) { | |
| elem = Object.isEvent(elem) ? elem.element() : elem, elem.up(".name.active") && (elem = elem.up(".name.active")), elem.observe("mousemove", this.mouseMove.bind(this)) | |
| }, | |
| mouseMove: function (event) { | |
| var elem = event.element(); | |
| if (elem.up(".name.active") && (elem = elem.up(".name.active")), elem.hasClassName("active")) { | |
| var px = event.clientX - elem.cumulativeOffset().left, | |
| percent = (100 * (px / elem.getWidth())).toFixed(1), | |
| position = this.sound.duration * (percent / 100), | |
| time = this.getTime(position); | |
| elem.down(".setPos").removeClassName("o0").update(time).setStyle("left:" + (px - elem.down(".setPos").getWidth() / 2).toFixed(0) + "px").data("pos", position / 1e3) | |
| } | |
| }, | |
| mouseOut: function (event) { | |
| var elem = event.element(); | |
| elem.up(".name.active") && (elem = elem.up(".name.active")), elem.stopObserving("mousemove"), elem.hasClassName("active") && elem.down(".setPos").setClass("o0") | |
| }, | |
| select: function (event) { | |
| var elem = event.element(); | |
| elem.up(".name") && (elem = elem.up(".name")), elem.hasClassName("active") && this.playPosition(this.elem.down(".active .setPos").data("pos")), this.elem.select(".clicked").invoke("removeClassName", "clicked"), elem.setClass("clicked") | |
| }, | |
| postprocess: function () { | |
| Sortable.create(this.elem.down(".playlist"), { | |
| elements: this.elem.select(".playlist .name"), | |
| onChange: this.rebuildPlaylist.bind(this) | |
| }) | |
| }, | |
| "goto": function (id) { | |
| this.current = this.playlist.indexOf(id), this.stop(), this.play() | |
| }, | |
| rebuildPlaylist: function () { | |
| var currentID = this.playlist[this.current]; | |
| this.playlist = [], this.elem.select(".playlist .name").each(function (elem) { | |
| this.playlist.push(elem.data("id")) | |
| }.bind(this)), this.current = this.playlist.indexOf(currentID) | |
| }, | |
| importPlaylist: function (Element) { | |
| this.playlist.length > 0, Element.getContent(function (content) { | |
| var entries = content.split("#EXTINF"); | |
| entries.each(function (entry) { | |
| if (":" == entry.substr(0, 1) && (entry = entry.split("\n"), !(entry.length < 2) && entry[1].indexOf("_"))) { | |
| var id = entry[1].substr(entry[1].indexOf("_")); | |
| id.include("?") && (id = id.substr(0, id.indexOf("?"))), this.add(id) | |
| } | |
| }.bind(this)), this.stop(), this.postprocess(), this.play.bind(this).delay(.2) | |
| }.bind(this)) | |
| }, | |
| exportPlaylist: function () { | |
| return I.Explorer ? (new C.WinPrompt({ | |
| text: "Playlist Name", | |
| onConfirm: function (input) { | |
| if (input.length < 1) return !1; | |
| var content = "#EXTM3U\n"; | |
| this.playlist.each(function (id) { | |
| var Element = I.Explorer.getElementObject(id); | |
| content += "#EXTINF:-1," + Element.data.name + "\n" + Element.getURL() + "\n" | |
| }.bind(this)), I.Explorer.createFile(input + ".m3u", function (Element) { | |
| Element.write(content) | |
| }) | |
| }.bind(this) | |
| }), void 0) : ("~" + I.User.get("name")).go() | |
| }, | |
| play: function () { | |
| return this.playing === !0 ? !1 : (this.sound && 0 === this.playing ? this.sound.play() : this.sound = soundManager.createSound({ | |
| id: "player", | |
| url: this.elem.down(".track" + this.playlist[this.current]).data("sound"), | |
| autoLoad: !0, | |
| autoPlay: !0, | |
| onid3: function () { | |
| c("ID3", this.id3) | |
| }, | |
| onfinish: this.next.bind(this) | |
| }), this.elem.select(".name").invoke("removeClassName", "active"), this.elem.down(".track" + this.playlist[this.current]).setClass("active"), this.history.include(this.playlist[this.current]) || this.history.push(this.playlist[this.current]), this.playing = !0, this.elem.setClass("playing"), this.elem.down(".aPlay").setClass("pressed"), this.showPosition(), void 0) | |
| }, | |
| stop: function () { | |
| this.playing = !1, this.elem.removeClassName("playing"), this.elem.down(".aPlay").removeClassName("pressed"), this.elem.select(".name .progress").invoke("setStyle", "width:0px"), this.sound && this.sound.destruct() | |
| }, | |
| pause: function () { | |
| this.playing = 0, this.elem.down(".aPlay").removeClassName("pressed"), this.sound.pause() | |
| }, | |
| playPosition: function (offset, pauseAfter) { | |
| offset = parseInt(offset), this.playPosTimeout && clearTimeout(this.playPosTimeout), this.sound.stop(), this.sound.setPosition(1e3 * offset), this.sound.play(), this.showPosition(), this.playing = !0, this.elem.setClass("playing"), this.elem.down(".aPlay").setClass("pressed"), pauseAfter > 0 && (this.playPosTimeout = setTimeout(function () { | |
| this.pause() | |
| }.bind(this), 1e3 * pauseAfter)) | |
| }, | |
| getRandomTrackPointer: function (i) { | |
| if (i || (i = 1), this.playlist.length < 2) return 0; | |
| this.history.length == this.playlist.length && (this.history = []); | |
| var pointer = (Math.random() * (this.playlist.length - 1)).round(); | |
| return this.history.include(this.playlist[pointer]) ? this.getRandomTrackPointer(i++) : pointer | |
| }, | |
| next: function () { | |
| this.stop(), this.shuffle ? this.current = this.getRandomTrackPointer() : this.current++, this.current >= this.playlist.length && (this.current = 0), this.play() | |
| }, | |
| prev: function () { | |
| this.stop(), this.current--, this.current < 0 && (this.current = this.playlist.length - 1), this.play() | |
| }, | |
| onDragStart: function (Explorer) { | |
| var playable = !1; | |
| Explorer.Selection.ids.each(function (Element) { | |
| "file" == Element.data.type && "mp3" == Element._getExt() && (playable = !0) | |
| }), playable && (this.elem.addClassName("dragging"), this.elem.down(".controls").hide(), this.timeout(function () { | |
| $("dropTrigger_player").setStyle("height:50px") | |
| }, .1)) | |
| }, | |
| onDragEnd: function () { | |
| this.elem.removeClassName("dragging"), this.elem.down(".controls").show() | |
| }, | |
| onDrop: function (drag) { | |
| drag.id.gsub("element", ""), I.Explorer.Selection.ids.each(function (Element) { | |
| this.add(Element.get("id")) | |
| }.bind(this)), this.postprocess(), this.playing === !1 && this.play() | |
| }, | |
| close: function () { | |
| this.stop(), this.playlist = [], this.history = [], this.elem.down(".playlist").update(""), this.elem.removeClassName("active") | |
| } | |
| }), C.Sidebar = Class.create(C.GUI, { | |
| _visible: !1, | |
| _default: null, | |
| initialize: function () { | |
| $("sidebar") || I.Navigation.elem.down().insert({ | |
| bottom: '<div id="sidebar" class="box aC oH sidebar" style="display:none"></div>' | |
| }), this.elem = $("sidebar"), this._slideKeys = Object.keys(this._slideObj), I.Content.elem.observe("click", this.reset.bind(this)) | |
| }, | |
| hide: function ($super) { | |
| $super(), $("navDrag").hide() | |
| }, | |
| show: function ($super) { | |
| $super(), $("navDrag").show() | |
| }, | |
| setDefault: function (id) { | |
| return id || this.hide(), this._default = id, this | |
| }, | |
| reset: function () { | |
| if (Object.isEvent(arguments[0])) { | |
| var elem = arguments[0].element(); | |
| if (elem.up("#nav") || elem.up(".explorer")) return !1 | |
| } | |
| this.hideAll(), I.Safebox.reset(), this._default && (this.show(), $(this._default).show()) | |
| }, | |
| hideAll: function () { | |
| arguments[0], this.elem.select(">div").invoke("hide") | |
| }, | |
| insert: function (id, html, setAsDefault) { | |
| return $(id) || (this.elem.insert('<div id="' + id + '"></div>'), $(id).insert(html)), Object.isUndefined(setAsDefault) || this.setDefault(id), this.hideAll(), $(id).show() | |
| }, | |
| _tplMe: ' <div class="bgi black mono" style="height:151px"> <h1 class="cP fadeToBlack trans02" onclick="I.Module.load(\'account\', \'info\');"><span class="pre">~</span><b class="name"></b></h1> </div> <div style="sdisplay:none;padding-top:7px"> <div class="inlineBlock aC o09 opacityHover cNumber" style="width:40%" onclick=""> <h2 class="update_slide">99%</h2> <span class="o04">Loading</span> </div> <div class="inlineBlock aC cP o09 trans03 opacityHover cNumber" style="width:40%" onclick="\'rewards\'.go();"> <h2 class="update_reputation inlineBlock"></h2> <span class="o04 cP">Reputation</span> </div> </div> <div style="margin:16px 0 8px 0"></div> <div class="bars padding aC"> <div class="bar trans03" style="" title="Space (used)" onclick="I.Module.load(\'account\', \'space\');"> <div class="progress red trans1"></div> <div class="aC b6 o07 cP trans1 update_space_used" style="margin:1px 0 0"></div> </div> <div class="bar trans03" style="margin-top:8px" title="Traffic (available)" onclick="I.Module.load(\'account\', \'traffic\');"> <div class="progress green trans1" style="width:75%"></div> <div class="aC b6 o07 cP trans1 update_traffic_available" style="margin:1px 0 0"></div> </div> </div> <div class="bg aC padding"> </div>', | |
| Me: function () { | |
| var data = Object.extend({ | |
| bars: !0, | |
| bg: ' <button class="left aExtend" style="position:relative" onclick="\'rewards\'.go()"> <div class="eCount trans05 o0"></div> Extend </button> <button class="group right w50" style="display:none;position:relative" onclick="\'pro\'.go()">go Pro</button> <br class="cB" />' | |
| }, arguments[0] || 0); | |
| I.Navigation.infoActive(!0), I.Project.require(I.User, function () { | |
| var elem = this.insert("sbMe", this._tplMe, 1); | |
| elem.down(".bg").update(data.bg).parseTitle(), elem.down(".bgi").setStyle({ | |
| backgroundImage: "url(" + I.User.img() + ")" | |
| }), elem.down(".bgi h1 .name").update(I.User.get("name")), this.fitTextSize(I.User.get("name"), elem), elem.down(".bars")[data.bars ? "show" : "hide"](), this.meRefresh($("sbMe"), 1), this.meSlideinfo($("sbMe"), 1) | |
| }.bind(this)) | |
| }, | |
| _slideObj: { | |
| files: function (db) { | |
| var nr = 0; | |
| return db.collect("element", function (obj) { | |
| "file" == obj.type && nr++ | |
| }), [nr, "Files"] | |
| }, | |
| folders: function (db) { | |
| var nr = 0; | |
| return db.collect("element", function (obj) { | |
| "folder" == obj.type && nr++ | |
| }), [nr, "Folders"] | |
| }, | |
| contacts: function (db) { | |
| return [Object.keys(db.collect("element", function (obj) { | |
| return "contact" == obj.type ? !0 : void 0 | |
| })).length.number(0), '<a href="~' + I.User.get("name") + '/Contact" class="a">Contacts</a>'] | |
| }, | |
| buckets: function (db) { | |
| var nr = 0; | |
| return db.get("element", "_13").children.each(function (id) { | |
| "bucket" == db.get("element", id).type && nr++ | |
| }), [nr, '<a href="~' + I.User.get("name") + '/System/Buckets" class="a">Buckets</a>'] | |
| }, | |
| images: function (db) { | |
| var nr = 0, | |
| ext = ["jpg", "jpeg", "gif", "bmp"]; | |
| return db.collect("element", function (obj) { | |
| "file" == obj.type && ext.include(obj.name.split(".").last().toLowerCase()) && nr++ | |
| }), [nr.number(0), "Images"] | |
| }, | |
| videos: function (db) { | |
| var nr = 0, | |
| ext = ["avi", "mpg", "m1s", "mpa", "mp4", "mov", "qt", "asf", "asx", "wmv", "wma", "wmx", "3gp", "ogm", "mkv"]; | |
| return db.collect("element", function (obj) { | |
| "file" == obj.type && ext.include(obj.name.split(".").last().toLowerCase()) && nr++ | |
| }), [nr.number(0), "Videos"] | |
| }, | |
| mp3s: function (db) { | |
| var nr = 0; | |
| return db.collect("element", function (obj) { | |
| "file" == obj.type && ["mp3"].include(obj.name.split(".").last().toLowerCase()) && nr++ | |
| }), nr--, nr >= 50 && I.User.reward("mp3_50"), nr >= 100 && I.User.reward("mp3_100"), nr >= 500 && I.User.reward("mp3_500"), [nr.number(0), "MP3s"] | |
| }, | |
| tasksDone: function (db) { | |
| var nr = 0; | |
| return db.collect("reward", function (obj) { | |
| obj.done && (nr += obj.done > 1 ? obj.done : 1) | |
| }), [nr, '<a href="rewards" class="a">Tasks done</a>'] | |
| }, | |
| tasksUndone: function (db) { | |
| var nr = 0; | |
| return db.collect("reward", function (obj) { | |
| 0 == obj.done && nr++ | |
| }), 0 == nr ? !1 : [nr, '<a href="rewards" class="a">Goals</a>'] | |
| }, | |
| comQuestions: function (db) { | |
| return db.get("user", "_community") && db.get("user", "_community").question ? [db.get("user", "_community").question.number(0), '<a href="munity/tag/~' + I.User.get("name") + '" class="a">Questions</a>'] : !1 | |
| }, | |
| comAnswers: function (db) { | |
| return db.get("user", "_community") && db.get("user", "_community").answer ? [db.get("user", "_community").answer.number(0), '<a href="munity" class="a">Answers</a>'] : !1 | |
| }, | |
| comComments: function (db) { | |
| return db.get("user", "_community") && db.get("user", "_community").comment ? [db.get("user", "_community").comment.number(0), '<a href="munity" class="a">Comments</a>'] : !1 | |
| }, | |
| points: function (db) { | |
| return [(db.get("user", "_info").reputation - I.User.DB.get("user", "_info").spent).number(0), '<a href="rewards" class="a">Points</a>'] | |
| }, | |
| publishes: function () { | |
| var nr = 0; | |
| return I.Explorer && I.Explorer.descendants("_4").each(function () { | |
| nr++ | |
| }), 1 > nr ? !1 : [nr, '<a href="~' + I.User.get("name") + '/Public" class="a">Public Elements</a>'] | |
| } | |
| }, | |
| _slideKeys: null, | |
| meSlideinfo: function (elem, force) { | |
| if (elem && elem.visible() && I.User.DB.ready && !safebyte.valid && (document.hasFocus() || !Object.isUndefined(force))) { | |
| var random = (this._slideKeys.length - 1).random(), | |
| info = this._slideObj[this._slideKeys[random]](I.User.DB); | |
| if (0 == info) return this.meSlideinfo(elem, force); | |
| force ? elem.down(".update_slide").update(info[0]).next().update(info[1]).parseLinks() : elem.down(".update_slide").next().innerHTML != info[1] && (elem.down(".update_slide").up().setClass("trans05 z07 o01"), setTimeout(function () { | |
| elem.down(".update_slide").update(info[0]).next().update(info[1]).up().parseLinks().removeClassNames("z07 o01") | |
| }.bind(this), 500)) | |
| } | |
| this.timeoutSlideinfo && clearTimeout(this.timeoutSlideinfo), this.timeoutSlideinfo = setTimeout(this.meSlideinfo.bind(this, elem), 8e3) | |
| }, | |
| meRefresh: function (elem, force) { | |
| if (elem && elem.visible() && I.User.DB.ready && !safebyte.valid && (document.hasFocus() || !Object.isUndefined(force))) { | |
| var g = function (k) { | |
| return I.User.DB.get("user", k) | |
| }.bind(this); | |
| $$(".update_reputation").each(function (elem) { | |
| elem.innerHTML != g("info").reputation.number(0) && ("" != elem.innerHTML && I.Explorer.isMe() && elem.up().eCountBox(g("info").reputation - elem.innerHTML.parseNumber()), elem.update(g("info").reputation.number(0))) | |
| }); | |
| var point = g("info").reputation - g("info").spent; | |
| elem.down(".aExtend") && elem.down("button.aExtend .eCount").innerHTML != point && point > 0 && elem.down("button.aExtend .eCount").removeClassName("o0").update(point.number(0)), 1 > point && elem.down("button.aExtend .eCount").setClass("o0"); | |
| var space = g("space"); | |
| 0 == space.used && elem.up(".sidebar") ? elem.down(".bar.trans03").hide() : elem.down(".bar.trans03").show(), $$(".update_space_used").invoke("update", space.used.toSize({ | |
| hide00: !1, | |
| decimals: 2 | |
| })), $$(".sidebar .bar .progress.red").invoke("setStyle", "width:" + (100 * (space.used / space.available)).toFixed(2) + "%"); | |
| var traffic = I.User.calcTraffic(); | |
| $$(".update_traffic_available").invoke("update", traffic.live.toSize({ | |
| hide00: !1, | |
| decimals: 2 | |
| })); | |
| var percent = (100 * (traffic.live / traffic.max)).toFixed(2); | |
| percent = percent > 99 ? 100 : percent, $$(".sidebar .bar .progress.green").invoke("setStyle", "width:" + percent + "%") | |
| } | |
| this.timeoutMeRefresh && clearTimeout(this.timeoutMeRefresh), this.timeoutMeRefresh = setTimeout(this.meRefresh.bind(this, elem), 1e3) | |
| }, | |
| _tplUser: ' <div class="bgi" style="background-image:url(img/icon/user_large.jpg);height:150px"> <h1 class="trans02 fadeToBlack" style=""><span class="pre">~</span><b class="name"></b></h1> </div> <div class="onHoverHeight visible trans1"><div> <div style="margin:8px 0 12px;width:70%" class="inlineBlock aC trans03 cNumber"> <h2 class="update_reputation">…</h2> <span class="o05">Reputation</span> </div> </div> <div class="bg aC padding" style="margin-top:0"> <button class="">Add Contact</button> </div></div>', | |
| User: function (Explorer) { | |
| I.Navigation.infoActive(!0), I.Project.require(Explorer.DB, function () { | |
| var elem = this.insert("sbUser", this._tplUser, 1).parseTitle().setClass("onHoverParent"); | |
| elem.down(".bgi").setStyle({ | |
| backgroundImage: "url(" + I.User.img(Explorer.user) + ")" | |
| }), elem.down(".bgi h1 .name").update(Explorer.user), this.fitTextSize(Explorer.user, elem); | |
| var info = Explorer.DB.get("user", "_info"); | |
| info && $$(".update_reputation").invoke("update", parseInt(info.reputation).number(0)) | |
| }.bind(this)) | |
| }, | |
| fitTextSize: function (name, elem) { | |
| var fS = 23, | |
| l = name.length; | |
| l > 8 && (fS = 23), l > 10 && (fS = 22), l > 12 && (fS = 20), l > 15 && (fS = 19), l > 18 && (fS = 18), l > 21 && (fS = 17), l > 23 && (fS = 16), l > 25 && (fS = 15), l > 27 && (fS = 14), elem.down(".bgi h1") && elem.down(".bgi h1").setStyle({ | |
| fontSize: fS + "px", | |
| lineHeight: 1.2 * fS + "px" | |
| }) | |
| }, | |
| _tplSelection: '<div id="sbSelection"> <div class="cover"></div> <div class="info"> <h2 class="title padding"></h2> <h4 class="sub o03 b6"></h4> <div class="border"></div> <table class="table padding"></table> </div> <div class="bg"> <div class="padding"> <button class="aOpen aReadable">Open</button> <button class="aImport aImportable">Import</button> <div class="aMoveable"> <button class="aCut aMoveable w25 inlineBlock" style="display:none">Cut</button> <button class="aCopy aMoveable w30 inlineBlock" style="margin:4px 9px;display:none">Copy</button> </div> <button class="aShare aShareable half fL">Share</button> <button class="aDelete aRemoveable fR cR inlineBlock">Delete</button> <button style="display:none" class="aComment aCommentable">Comment</button> <br class="cB"/> </div> </div></div>', | |
| Selection: function (Selection) { | |
| I.Navigation.infoActive(!0); | |
| var elem = $("sbSelection"); | |
| if (elem || (elem = this.elem.insert(this._tplSelection).down("#sbSelection"), elem.down(".aOpen").observe("mousedown", function () { | |
| I.Explorer.Selection.ids[0].open() | |
| }), elem.down(".aImport").observe("click", function () { | |
| I.Explorer.Selection.imp0rt() | |
| }), elem.down(".aCut").observe("click", function () { | |
| I.Explorer.Selection.cut() | |
| }), elem.down(".aCopy").observe("click", function () { | |
| I.Explorer.Selection.cut("c") | |
| }), elem.down(".aDelete").observe("click", function () { | |
| I.Explorer.Selection.deleteElements() | |
| }), elem.down(".aShare").observe("click", this.Contact.bind(this, I.Explorer))), this.hideAll(), 0 == Selection.getLength()) return this.reset(); | |
| if (1 == Selection.getLength()) { | |
| var data = Selection.ids[0].getSidebarInfo(); | |
| elem.data("id", Selection.ids[0].id), elem.down(".info").show(), Object.keys(data).each(function (key) { | |
| if (elem.down("." + key)) { | |
| var value = Object.isFunction(data[key]) ? data[key]() : data[key]; | |
| elem.down("." + key).update(value) | |
| } | |
| }.bind(this)), elem.parseLinks() | |
| } else elem.down(".cover").update(Selection.getStack().setStyle("margin-top:10px")), elem.down(".info").hide(); | |
| elem.down(".aRemoveable").setClass("half"), elem.select(".hide").invoke("removeClassName", "hide"); | |
| var sumSize = 0; | |
| return I.Explorer.Selection.ids.each(function (Element, i) { | |
| if (sumSize += Element.data.size || 0, !(i > 3)) { | |
| if (1 == i) return elem.down(".aRemoveable").removeClassName("half"), elem.select(".aReadable", ".aShareable, .aCommentable").invoke("addClassName", "hide"), void 0; | |
| var ElemData = Element.data; | |
| ElemData.shareable || elem.down(".aRemoveable").removeClassName("half"), Object.keys(ElemData).each(function (key) { | |
| ElemData[key] === !1 && elem.down(".a" + key.ucFirst()) && elem.select(".a" + key.ucFirst()).invoke("setClass", "hide") | |
| }.bind(this)) | |
| } | |
| }.bind(this)), Selection.getLength() > 1 && sumSize > 0 && elem.down(".stack").insert({ | |
| after: '<h4 class="sub o03 b6">' + sumSize.toSize() + "</h4>" | |
| }), elem.down(".table tr") ? elem.down(".border").show() : elem.down(".border").hide(), elem.show(), 15 == elem.down(".bg .padding").getHeight() ? elem.down(".bg").setClass("invisible") : elem.down(".bg").removeClassName("invisible"), this | |
| }, | |
| _tplContact: ' <div id="sbContact" class="noselect"> <div class="dropBox bg" style="margin-top:0;padding:5px 0 0"> <button id="shareLink" class="group left half droppable input trans03"> <span class="gui ico link fL trans03"></span>Create<br /><span class="b6">Link</span> </button> <button id="shareMail" class="group right half droppable input trans03"> <span class="gui ico mail fL trans03"></span>Share by<br /><span class="b6">eMail</span> </button> <button id="shareFacebook" class="group left half droppable input trans03"> <span class="gui ico facebook fL trans03"></span>Share on<br /><span class="b6">Facebook</span> </button> <button id="shareTwitter" class="group right half droppable input trans03"> <span class="gui ico twitter fL trans03"></span>Share on<br /><span class="b6">Twitter</span> </button> <button disabled="disabled" class="input trans03 butSend" style="width:93%;text-align:center"> <span class="o03">↓</span> Select Contact <span class="o03">↓</span> </button> </div> </div>', | |
| Contact: function (Explorer) { | |
| I.Navigation.infoActive(!1); | |
| var elem = $("sbContact"); | |
| if (I.Safebox.activate("chat"), !elem) { | |
| elem = this.elem.insert(this._tplContact).down("#sbContact").parseTitle(), this.insertContactList(elem); | |
| var shareThirdParty = function (id) { | |
| switch (I.Project.pageLoad(), id) { | |
| case "shareFacebook": | |
| $(id).disable(), I.Module.load("facebook", function (Facebook) { | |
| Facebook.onConnectForce(Facebook.publish.bind(Facebook, I.Explorer)) | |
| }); | |
| break; | |
| case "shareTwitter": | |
| var selection = Explorer.Selection.getIds(!0); | |
| Explorer.createBucket(selection, null, null, null, function (t, bucketId) { | |
| I.Project.pageReady(); | |
| var url = "https://twitter.com/share?url=" + encodeURI(I.Project.getURL("p:url_short") + "/e" + bucketId.substr(7)); | |
| I.Project.popup(url, { | |
| height: 230 | |
| }) | |
| }); | |
| break; | |
| case "shareLink": | |
| Explorer.Selection.shareLink(); | |
| break; | |
| case "shareMail": | |
| Explorer.Selection.shareMail() | |
| } | |
| }; | |
| elem.down(".butSend").observe("click", function () { | |
| I.Explorer.Selection.share(this._selectedContact) | |
| }.bind(this)), elem.select(".dropBox > .droppable").each(function (elemButton) { | |
| elemButton.observe("click", shareThirdParty.bind(this, elemButton.id)), fastDroppables.add(elemButton, { | |
| accept: "dragging", | |
| hoverclass: "dragHover", | |
| onDrop: function (drag, drop) { | |
| shareThirdParty(drop.id) | |
| } | |
| }) | |
| }) | |
| } | |
| return this.hideAll(), elem.show(), this | |
| }, | |
| _tplChat: '<div id="sbChat" class="noselect"></div>', | |
| Chat: function () { | |
| I.Navigation.infoActive(!1), I.Project.pageLoad(), I.Project.require(I.User, function () { | |
| var elem = $("sbChat"); | |
| I.Safebox.activate("chat"), $("navDrag").show(), I.Sidebar.show(), elem || (elem = this.elem.insert(this._tplChat).down("#sbChat"), this.insertContactList(elem, { | |
| max: 15, | |
| onMouseDown: function (elemUser, Element, event) { | |
| if ("h2" == event.element().tagName.toLowerCase()) { | |
| var win = new C.Window({ | |
| minimizeable: !0, | |
| resizeable: !0, | |
| width: 280, | |
| height: 400, | |
| maximizeable: !0, | |
| title: { | |
| text: "<span>~</span>kadoc", | |
| size: 30, | |
| height: 110, | |
| image: "img/user/enrico.jpg" | |
| }, | |
| className: "chat", | |
| closeable: !0, | |
| html: '<div class="conversation"> <div class="border label"><span><span>28.12.2012 12:45</span></span></div> <div class="message"><span>Guten morgen</span><div class="corner gui"></div></div> <div class="message own"><span>Seid gegrüßt</span><div class="corner gui"></div></div> <div class="message own"><span>Die Übertragung erfolgt über einen Socket</span><div class="corner gui"></div></div> <div class="message"><span>Das bedeutet, dass sie nahezu ohne Zeitverzögerung stattfindet</span><div class="corner gui"></div></div> <br class="cb"/></div><form method="post" class="send bg"> <input type="text" /></form>' | |
| }).show(); | |
| return win | |
| } | |
| } | |
| })), this.hideAll(), elem.show(), elem.down("input.search").select(), I.Project.pageReady() | |
| }.bind(this)) | |
| }, | |
| _selectedContact: [], | |
| selectContact: function (elemUser, Element) { | |
| var activate = elemUser.hasClassName("selected") ? !1 : !0; | |
| activate ? (this._selectedContact.push(Element), elemUser.addClassName("selected")) : (this._selectedContact = this._selectedContact.without(Element), elemUser.removeClassName("selected")), Element.selected = activate, this.elem.down(".butSend") && (this._selectedContact.length > 0 ? (this.elem.down(".butSend").update(_('Share with <b class="b6">%contacts</b>').sub("%contacts", ["", this._selectedContact[0].data.name, "%n Contacts"].numerus(this._selectedContact.length))), this.elem.down(".butSend").disabled = !1) : this.elem.down(".butSend").update("↓ Select Contact ↓").disabled = !0) | |
| }, | |
| insertContactList: function (elem) { | |
| var option = Object.extend({ | |
| onMouseDown: this.selectContact.bind(this), | |
| max: 5 | |
| }, arguments[1] || {}), | |
| dropData = { | |
| accept: "dragging", | |
| refresh: 300, | |
| hoverclass: "dragHover", | |
| onDrop: function (drag, drop) { | |
| var Element = I.Explorer.getElementObject(drop.data("id")); | |
| I.Explorer.Selection.share([Element]) | |
| }, | |
| onHover: function () {} | |
| }; | |
| elem.insert('<div class="contactSearch bg" style="box-shadow:none;margin-top:-3px;padding:0"> <input type="text" autocomplete="off" class="search defaultFont" name="search" value="' + ($$(".contactSearch input")[0] ? $$(".contactSearch input")[0].getValue() : "") + '" />' + "</div>" + '<div class="border cB" style="margin:0"></div>' + '<div class="contacts"></div>'); | |
| var contacts = Object.values(I.User.DB.collect("element", function (row) { | |
| return "contact" == row.type ? !0 : void 0 | |
| })); | |
| contacts.length < 1 && elem.down(".contacts").insert('<div style="margin:10px" class="fs6 i errNotFound">No contacts found.</div>'), (!I.User.DB.get("user", "_accounts").facebook || contacts.length < 1) && (elem.select(".contactSearch, .border.cB").invoke("hide"), elem.down(".contacts").insert('<div class="bg fs7" style="margin-top:0;padding:5px 7px"> <button class="fbLogin" title="!+100" style="line-height:19px;text-transform:none">Import my friends<br/>from Facebook</button></div>').parseTitle(), I.Module.load("facebook"), elem.down("button.fbLogin").observe("click", this.importFb.bind(this))), contacts = contacts.sort(function (o1, o2) { | |
| var a, b; | |
| return (o1.sortIndex || o2.sortIndex) && o1.sortIndex != o2.sortIndex ? o1.sortIndex < o2.sortIndex ? 1 : -1 : a == b ? 0 : b > a ? 1 : -1 | |
| }.bind(this)); | |
| var updateContact = function () { | |
| var search = elem.down("input.search").getValue(), | |
| inserted = 0; | |
| elem.down(".contacts").select(".user").each(function (oldElem) { | |
| fastDroppables.remove(oldElem), oldElem.remove() | |
| }), contacts.each(function (data) { | |
| if (!(inserted > option.max || search && "" != search && !data.name.toLowerCase().include(search.toLowerCase()))) { | |
| var img = data.img; | |
| img || (img = data.facebook ? "//graph.facebook.com/" + data.facebook + "/picture?width=226&height=130" : "img/icon/user_large_2.png"); | |
| var name = data.name.trim(17, "…"); | |
| name.include(" ") ? name = name.substr(0, name.indexOf(" ")) + ' <span class="b6">' + name.substr(name.indexOf(" ") + 1) + "</span>" : name.include("@") && (name = '<span class="b5">' + name.substr(0, name.indexOf("@")) + '</span><span class="o07">' + name.substr(name.indexOf("@")) + "</span>"), elem.down(".contacts").insert('<div class="user trans02" data-id="' + data.id + '"> <img src="img/s.png" class="icon trans02" style="background-image:url(' + img + ')" /> <h2 class="fadeToBlack b3 bgText trans02"> <span class="cP">' + name + "</span> " + (data.safebyte || data.facebook ? ' <div class="connect trans02"> Is on ' + (data.safebyte ? '<span class="black a" onclick="\'~' + data.safebyte + "'.go()\">" + " safebyte</span>" : "") + " " + (data.facebook ? '<span class="black a" onclick="window.open(\'http://www.facebook.com/' + data.facebook + "')\">" + " facebook</span>" : "") + " </div> " : "") + " </h2> </div>"); | |
| var elemUser = elem.select(".contacts .user").last().parseTitle(); | |
| if (I.Explorer) { | |
| var Element = I.Explorer.getElementObject(data.id, data); | |
| Element.selected && elemUser.addClassName("selected") | |
| } | |
| fastDroppables.add(elemUser, dropData), elemUser.down("h2 > span").stopObserving().observe("mousedown", option.onMouseDown.bind(this, elemUser, Element)), inserted++ | |
| } | |
| }) | |
| }; | |
| elem.down("input.search").observe("keyup", updateContact), updateContact() | |
| }, | |
| refreshContact: function () { | |
| var elem = $("sbContact") || $("sbChat"); | |
| I.Explorer && "_2" == I.Explorer._currentFolderID && (I.Explorer.refresh(), this.Chat()), elem.select(".contactSearch, .border.cB, .contacts").invoke("remove"), this.insertContactList(elem) | |
| }, | |
| importFb: function () { | |
| I.Module.get("facebook").Instance.cb = this.refreshContact.bind(this), I.Module.get("facebook").Instance.login() | |
| } | |
| }), C.Footer = Class.create(C.GUI, { | |
| _visible: !1, | |
| initialize: function () { | |
| $("footer") || I.Navigation.elem.down().insert({ | |
| bottom: '<div id="footer" class="trans05 noselect" style="display:none"> <div class="upload"> <div class="gui cloud cP trans03" title="File upload"></div> <div class="vborder o01 gradient"></div> </div> <a href="munity/tag/blog" class="trans03">Blog</a> ⋅ <a href="privacy" class="trans03">Privacy</a> ⋅ <a href="copyright" class="trans03">Copyright</a><br> <a href="tos" class="trans03">ToS</a> ⋅ <a href="munity" class="trans03">Help</a> ⋅ <a href="press" class="trans03">Press</a> ⋅ <a href="contact" class="trans03">Contact</a></div>' | |
| }), this.elem = $("footer").parseLinks().parseTitle() | |
| } | |
| }), C.ContextMenu = Class.create(C.GUI, { | |
| _open: null, | |
| _visible: !1, | |
| initialize: function (elemTrigger, data) { | |
| this.elemTrigger = $(elemTrigger), this.build(data), this.elemTrigger.oncontextmenu = function (event) { | |
| return this.show(event), !1 | |
| }.bind(this), this.elemTrigger.observe("mousedown", this.hideAll.bind(this)) | |
| }, | |
| build: function (data) { | |
| Object.isArray(data) || (data = [data]), this.data = data, this.elem = this.elemTrigger.insert('<div class="contextmenu"></div>').select(".contextmenu").last(), this.data.each(this.insertBox.bind(this)) | |
| }, | |
| insertBox: function (obj) { | |
| obj.elem = this.elem.insert('<div class="box' + (obj.trigger ? " cmBox" + obj.trigger.substr(1) : "") + '" style="display:none">' + " <table><tbody></tbody></table>" + "</div>").down(".box:last-child"), obj.elem.data("trigger", obj.trigger || !1), obj.rows.each(function (row) { | |
| if (Object.isString(row) && "-" == row.substr(0, 1)) return obj.elem.down("table tbody").insert('<tr class="blind' + (row.length > 1 ? " " + row.substr(1) : "") + '">' + '<td colspan="2"><div class="border"></div></td></tr>'); | |
| row = Object.extend({ | |
| id: "cmRow" + (99999999 * Math.random()).round(), | |
| desc: "", | |
| group: !1, | |
| expand: null, | |
| className: null, | |
| onMouseOver: Prototype.emptyFunction, | |
| onMouseDown: Prototype.emptyFunction, | |
| onMouseUp: Prototype.emptyFunction, | |
| onClick: Prototype.emptyFunction | |
| }, row), row.expand && (row.desc = '<div class="gui arrow right"></div>'); | |
| var elem = obj.elem.down("table tbody").insert('<tr id="' + row.id + '" class="' + (row.group ? "cmGroup" + row.group.gsub("!", "") : "") + '">' + " <th>" + row.label + "</th>" + " <td>" + row.desc + "</td>" + "</tr>").select("tr").last(); | |
| row.className && elem.addClassName(row.className), row.expand && elem.addClassName("expandable").data("expand", row.expand), row.group && "!" == row.group.substr(0, 1) && this.selectRow(elem), elem.stopObserving().observe("mouseover", function (e) { | |
| this._onMouseOver(e), row.onMouseOver(e) | |
| }.bind(this)).observe("mousedown", function (e) { | |
| this.selectRow(e), row.onMouseDown(e) | |
| }.bind(this)).observe("mouseup", function (e) { | |
| row.onMouseUp(e) | |
| }.bind(this)).observe("click", function (e) { | |
| row.onClick(e) !== !1 && this.close() | |
| }.bind(this)) | |
| }.bind(this)) | |
| }, | |
| selectRow: function (elem) { | |
| Object.isEvent(elem) && (elem = elem.element().up("tr")), elem.className && elem.className.include("cmGroup") && (this.elem.select("tr." + elem.className + " .selected").invoke("remove"), elem.down("th").insert({ | |
| top: '<div class="selected">•</div>' | |
| })) | |
| }, | |
| _onMouseOver: function (event) { | |
| var tr = event.element(); | |
| tr = "tr" != tr.tagName ? tr.up("tr") : tr; | |
| var open = null; | |
| if (tr.up("table").select(".open").invoke("removeClassName", "open"), this.elem.select(".box").each(function (div) { | |
| div.visible() && !div.hasClassName("baseMenu") && (tr.up(".box").data("expand") != open || tr.up(".baseMenu")) && div.hide() | |
| }.bind(this)), tr.hasClassName("expandable")) { | |
| var pos = tr.viewportOffset(); | |
| pos.top = pos.top + tr.getHeight() - 26, pos.left = pos.left + tr.getWidth() - 8, pos.left -= I.Content.elem.positionedOffset().left, this._open = tr.data("expand"); | |
| var expand = this.elem.down(".cmBox" + tr.data("expand").substr(1)); | |
| this.setPosition(expand, pos), expand.show(), tr.addClassName("open") | |
| } | |
| }, | |
| show: function (event) { | |
| var use = null; | |
| this.data.each(function (obj) { | |
| return obj.trigger && !use ? Object.isElement(event.element()) && event.element().familyOf(obj.trigger) ? use = obj : void 0 : void 0 | |
| }.bind(this)), use || (use = this.data[0]), Object.isFunction(use.onShow) && use.onShow(this, use.elem); | |
| var position = { | |
| top: document.viewport.getScrollOffsets().top + event.clientY, | |
| left: event.clientX - (use.elem.up("#content") ? I.Content.elem.positionedOffset().left : 0) | |
| }; | |
| this.setPosition(use.elem, position), use.elem.addClassName("baseMenu").show(), this._visible = !0 | |
| }, | |
| expand: function (data) { | |
| var result = null; | |
| this.data.each(function (obj) { | |
| obj.trigger == data.expand && (result = obj) | |
| }.bind(this)), result && !result.visible && (this.elem.select(".expanded").invoke("removeClassName", "expanded"), result.visible = !0, result.elem.addClassName("expanded").show(), result.elem.setStyle("top:" + data.y + "px;left:" + data.x + "px"), result.elem.data("trigger", data.expand)) | |
| }, | |
| setPosition: function (elem, pos) { | |
| var vp = document.viewport.getDimensions(); | |
| pos.top + elem.getHeight() > vp.height + document.viewport.getScrollOffsets().top && (pos.top -= elem.getHeight()), pos.left + elem.getWidth() > vp.width && (pos.left -= elem.getWidth()), pos.top = pos.top + "px", pos.left = pos.left + "px", elem.setStyle(pos) | |
| }, | |
| close: function () { | |
| this._visible && (this.elem.select(".open").invoke("removeClassName", "open"), this.elem.select(".box").invoke("hide"), this.elem.down(".baseMenu").removeClassName("baseMenu"), this._visible = !1, "explorer" == I.Project.currentPage && I.Explorer.Grid && this.timeout(I.Explorer.Grid.finish.bind(I.Explorer.Grid), .01)) | |
| }, | |
| hideAll: function (event) { | |
| this._visible && (event.element().familyOf(".contextmenu .box") || this.close()) | |
| }, | |
| destroy: function () { | |
| this.elemTrigger.oncontextmenu = Prototype.emptyFunction, this.elem && (this.elem.remove(), this._visible = !1) | |
| } | |
| }), C.Windows = Class.create(C.Base, { | |
| data: {}, | |
| zIndex: 100, | |
| activeWindow: null, | |
| initialize: function () { | |
| document.observe("click", function (e) { | |
| !Object.isElement(e.element()) || e.element().familyOf(".window") || e.element().hasClassName("cover") || this.blurAll() | |
| }.bind(this)), this.resetSpawn() | |
| }, | |
| resetSpawn: function () { | |
| this.spawnPosition = [-12, -25] | |
| }, | |
| focusNext: function () { | |
| var keys = Object.keys(this.data); | |
| keys.length > 0 ? (keys.each(function (key) { | |
| this.data[key]._visible && (this.activeWindow = this.data[key]) | |
| }.bind(this)), this.activeWindow && this.activeWindow.focus()) : this.activeWindow = null | |
| }, | |
| focus: function (Window) { | |
| return this.data[Window.data.id] ? (this.blurAll(), this.activeWindow = this.data[Window.data.id], this.zIndex++, this.activeWindow.elem.style.zIndex = this.zIndex, void 0) : !1 | |
| }, | |
| register: function (Window) { | |
| this.data[Window.data.id] = Window, this.spawnPosition = [this.spawnPosition[0] + 12, this.spawnPosition[1] + 25], this.spawnPosition[0] > 100 && this.resetSpawn(), Window.focus() | |
| }, | |
| minimize: function (Window) { | |
| I.Taskbar.insert(Window), this.focusNext() | |
| }, | |
| minimizeAll: function () { | |
| Object.keys(this.data).each(function (key) { | |
| this.data[key].minimize() | |
| }.bind(this)) | |
| }, | |
| move: function () {}, | |
| close: function (Window) { | |
| delete this.data[Window.data.id], this.resetSpawn(), this.focusNext() | |
| }, | |
| blurAll: function () { | |
| Object.keys(this.data).each(function (id) { | |
| this.data[id].blur() | |
| }.bind(this)), this.activeWindow = null | |
| } | |
| }), C.Taskbar = Class.create(C.GUI, { | |
| initialize: function () { | |
| this.elem = I.Content.elem.insert('<div id="taskbar"></div>').down("#taskbar"), this.win = {} | |
| }, | |
| insert: function (Window) { | |
| this.elem.insert('<div id="taskbar' + Window.data.id + '" class="trans03 task noselect">' + " <h2>" + Window.data.title.text + "</h2>" + "</div>"), this.win[Window.data.id] = this.elem.select("div.task:last-child")[0], this.win[Window.data.id].addClassName("visible"), this.win[Window.data.id].observe("mouseover", function () { | |
| Window.elem.hasClassName("maximized") || Window.elem.show().setOpacity(.3) | |
| }.bind(this)).observe("mouseout", function () { | |
| Window.elem.hide().setOpacity(0) | |
| }.bind(this)).observe("mousedown", this.restore.bind(this, Window)) | |
| }, | |
| restore: function (Window) { | |
| this.win[Window.data.id].stopObserving().removeClassName("visible").addClassName("invisible"), this.timeout(function () { | |
| this.win[Window.data.id].remove() | |
| }, .5), Window.taskbarRestore() | |
| } | |
| }), C.Window = Class.create(C.GUI, { | |
| _template: new Template('<div id="#{id}" class="window box #{className}" style="display:none;width:#{width}px;#{style}"> <div class="controls"></div> <div class="html">#{html}</div></div>'), | |
| _id: null, | |
| _keys: {}, | |
| hasFocus: !1, | |
| initialize: function () { | |
| return this.data = Object.extend({ | |
| id: "win" + (1e3 * Math.random()).toFixed(0), | |
| title: !1, | |
| html: null, | |
| maximized: !1, | |
| minimized: !1, | |
| pos: null, | |
| draggable: null, | |
| resizeable: null, | |
| closeable: !1, | |
| maximizeable: !1, | |
| minimizeable: !1, | |
| minimizedTitle: null, | |
| height: null, | |
| notifications: null, | |
| width: 270, | |
| style: null, | |
| hideX: !1, | |
| cover: null, | |
| blur: !1, | |
| visible: !0, | |
| parent: null, | |
| wrap: !1, | |
| insert2Elem: document.body, | |
| dropAllowType: [], | |
| dropAllowExt: [], | |
| dropAllowSize: null, | |
| dropMax: null, | |
| dropFilter: null, | |
| dropError: null, | |
| onDrop: null, | |
| onResize: Prototype.emptyFunction, | |
| onInsert: Prototype.emptyFunction, | |
| onShow: Prototype.emptyFunction, | |
| onClose: Prototype.emptyFunction, | |
| afterClose: Prototype.emptyFunction | |
| }, arguments[0] || {}), this.id = this.data.id, this.data.html && this.insert(), this | |
| }, | |
| focus: function () { | |
| I.Windows.focus(this), this.hasFocus = !0, this.elem.addClassName("hasFocus") | |
| }, | |
| blur: function () { | |
| this.hasFocus = !1, this.elem.removeClassName("hasFocus") | |
| }, | |
| insert: function () { | |
| arguments[0] && (this.data.html = arguments[0]), $(this.data.insert2Elem).insert(this._template.evaluate(this.data)), this.elem = $(this.id).parseTitle().parseLinks(), this.data.wrap && ($$("body").invoke("setClass", "oH"), this.elem.wrap("div", { | |
| "class": "wrapper" | |
| }), this.elem = $(this.id), this.data.closeable && this.elem.up(".wrapper").observe("click", function (event) { | |
| event.element().hasClassName("wrapper") && this.close() | |
| }.bind(this))); | |
| var dragData = { | |
| onStart: function (obj) { | |
| I.Windows.move(this), obj.element.setClass("dragged dragging") | |
| }.bind(this), | |
| starteffect: function (element) { | |
| Prototype.Browser.IE || (element._opacity = Element.getOpacity(element), Draggable._dragging[element] = !0, new Effect.Opacity(element, { | |
| duration: .2, | |
| from: element._opacity, | |
| to: .7 | |
| })) | |
| }, | |
| onEnd: function (obj) { | |
| obj.element.removeClassName("dragging") | |
| } | |
| }; | |
| return this.data.minimizeable && this.elem.down(".controls").insert('<div class="gui minimize" title="' + _("Minimize") + '"></div>').parseTitle().down(".minimize").observe("click", this.minimize.bind(this)), this.data.maximizeable && this.elem.down(".controls").insert('<div class="gui maximize" title="' + _("Maximize") + '"></div>').parseTitle().down(".maximize").observe("mousedown", this.maximize.bind(this)), this.data.closeable && (this.enableKeys("esc"), this.data.hideX || this.elem.down(".controls").insert('<div class="gui close" title="' + _("Close") + '"></div>').parseTitle().down(".close").observe("click", this.close.bind(this))), this.data.notifications && this.setNotifications(this.data.notifications), this.data.parent && (this.data.blur = !1, this.data.cover = !0, this.data.parent.elem.setClass("trans05 z09 o03")), this.data.blur && (this.data.cover = !0), this.data.cover && (I.Content.setClass("trans03", .3), this.elem.insert({ | |
| before: '<div class="trans03 cover"></div>' | |
| }), this.data.closeable && this.elem.previous(".cover").observe("click", this.close.bind(this))), this.data.resizeable && (this.elem.insert('<div class="resize gui"></div>'), this.elem.moveposition = { | |
| x: 0, | |
| y: 0 | |
| }, this._bindings.resizeMouseDown = this.resizeMouseDown.bind(this), this._bindings.resizeMouseUp = this.resizeMouseUp.bind(this), this.elem.down(".resize").observe("mousedown", this._bindings.resizeMouseDown), Event.observe(document.body, "mouseup", this._bindings.resizeMouseUp)), this.data.title && (Object.isString(this.data.title) && (this.data.title = { | |
| text: this.data.title | |
| }), this.data.title = Object.extend({ | |
| image: null, | |
| size: 13, | |
| height: 30 | |
| }, this.data.title || {}), this.elem.insert({ | |
| top: '<div class="title"> <span style="line-height:' + 1.2 * this.data.title.size + "px;font-size:" + this.data.title.size + 'px">' + this.data.title.text + "</span>" + "</div>" | |
| }), dragData.handle = this.elem.down(".title"), this.data.title.image ? (dragData.handle.down("span").setClass("fadeToBlack"), dragData.handle.setStyle("background-image:url(" + this.data.title.image + ");min-height:" + this.data.title.height + "px;")) : dragData.handle.addClassName("small"), this.data.maximizeable && this.elem.down(".title").observe("dblclick", this.maximize.bind(this)), this.elem.down(".title").observe("mousedown", this.focus.bind(this))), this.data.maximized ? this.maximize() : this.data.height && this.setSize({ | |
| height: this.data.height, | |
| width: this.data.width | |
| }), this.enableResizeEvent(), (this.data.draggable || this.data.title && null === this.data.draggable) && new Draggable(this.elem, dragData), this.data.dropAllowType = u.arr(this.data.dropAllowType), this.data.dropAllowExt = u.arr(this.data.dropAllowExt), Object.isFunction(this.data.onDrop) && fastDroppables.add(this.elem, { | |
| accept: "dragging", | |
| hoverclass: "trans02 dropHover", | |
| onDrop: this.onDrop.bind(this) | |
| }), this.elem.observe("mousedown", this.focus.bind(this)), I.Windows.register(this), this.data.onInsert(this), this.data.visible && this.show(), this | |
| }, | |
| key: function (event, keys) { | |
| if (event.preventDefault(), "keyup" == event.type) return !0; | |
| switch (keys) { | |
| case "esc": | |
| case "escape": | |
| this.data.closeable && this.close() | |
| } | |
| return !0 | |
| }, | |
| saveSize: function () { | |
| this.elem.normalSize = { | |
| css: { | |
| top: this.elem.getStyle("top"), | |
| left: this.elem.getStyle("left"), | |
| width: this.elem.getWidth() + "px", | |
| height: this.elem.getHeight() + "px" | |
| }, | |
| title: { | |
| height: this.data.title.height | |
| } | |
| } | |
| }, | |
| maximize: function () { | |
| if (this.data.maximized) { | |
| if (!this.elem.normalSize) return this.setSize({ | |
| width: document.viewport.getWidth() / 2, | |
| height: document.viewport.getHeight() / 2 | |
| }), this.setPos(), this.saveSize(); | |
| this.elem.setStyle(this.elem.normalSize.css), this.setSize.bind(this).delay(.3, { | |
| height: this.elem.normalSize.css.height.gsub("px", ""), | |
| width: this.elem.normalSize.css.width.gsub("px", "") | |
| }) | |
| } else { | |
| var vp = document.viewport.getDimensions(); | |
| this.saveSize(), this.elem.setStyle("width:" + vp.width + "px;height:" + vp.height + "px;top:0;left:0"), this.setSize.bind(this).delay(.3, vp) | |
| } | |
| return this | |
| }, | |
| minimize: function () { | |
| this._visible = !1, this._minimized = !0, I.Windows.minimize(this), this.data.maximized || this.elem.setClass("trans02 z08"), this.elem.setClass("minimized"), this.timeout(function () { | |
| this.hide(), this.elem.removeClassNames("minimized z08 trans02") | |
| }.bind(this), .3) | |
| }, | |
| taskbarRestore: function () { | |
| this._visible = !0, this._minimized = !1, this.show().elem.setOpacity(1), this.focus() | |
| }, | |
| toggleMinimize: function () { | |
| var size = {}; | |
| this.elem.hasClassName("minimized") ? size = this.elem.normalSize : (this.saveSize(), size = { | |
| width: 226, | |
| height: 46, | |
| title: { | |
| height: 46 | |
| } | |
| }), this.elem.morph("width:" + size.width + "px;height:" + size.height + "px", { | |
| duration: .4 | |
| }), this.elem.down(".title").morph({ | |
| minHeight: size.title.height + "px" | |
| }, { | |
| duration: .4 | |
| }), this.elem.down(".html").morph({ | |
| height: "0px" | |
| }, { | |
| duration: .4, | |
| afterFinish: this.setSize.bind(this, size) | |
| }), this.elem.toggleClassName("minimized") | |
| }, | |
| resizeMouseDown: function (event) { | |
| return this.elem.moveposition = { | |
| x: event.pointerX(), | |
| y: event.pointerY() | |
| }, this._bindings.resizeMouseMove = this.resizeMouseMove.bind(this), Event.observe(document.body, "mousemove", this._bindings.resizeMouseMove), !1 | |
| }, | |
| resizeMouseUp: function () { | |
| this.data.onResize(this, this.elem.getDimensions()), Event.stopObserving(document.body, "mousemove", this._bindings.resizeMouseMove) | |
| }, | |
| resizeMouseMove: function (event) { | |
| if (event.buttons < 1) return this.resizeMouseUp(); | |
| var pos = this.elem.down(".resize").viewportOffset(), | |
| size = this.elem.getDimensions(); | |
| return size.titleHeight = this.elem.down(".title") ? this.elem.down(".title").getHeight() : 0, size.height += event.pointerY() - pos.top - 10, size.width += event.pointerX() - pos.left - 10, size.height < size.titleHeight && (size.height = size.titleHeight), size.width < 72 && (size.width = 72), this.setSize(size, !0), !0 | |
| }, | |
| setNotifications: function (number) { | |
| var elem = this.elem.down(".notifications"); | |
| elem || (elem = this.elem.insert('<div class="notifications trans1 eCount">' + number + "</div>").down(".notifications")), this._notifications = 0 > number ? this._notifications - number.abs() : number, elem.update(this._notifications) | |
| }, | |
| setTitle: function () { | |
| if (!this.data.title) return console.error("title not inited"); | |
| var text = arguments[0] || null; | |
| text && this.elem.down(".title").update(text), this.data.title.text = this.elem.down(".title").innerHTML | |
| }, | |
| resize: function () { | |
| this.elem.hasClassName("dragged") || this.setPos(this.data.pos) | |
| }, | |
| setSize: function (size) { | |
| var vp = document.viewport.getDimensions(); | |
| return size.width >= vp.width && size.height >= vp.height ? (this.elem.setClass("maximized"), this.data.maximized = !0) : (this.elem.removeClassName("maximized"), this.data.maximized = !1), this.data.title && (size.height <= this.elem.down(".title").getHeight() ? this.elem.down(".title").setStyle("border-radius:3px") : this.elem.down(".title").setStyle("border-radius:3px 3px 0 0")), this.elem.setStyle({ | |
| height: size.height + "px", | |
| width: size.width + "px" | |
| }), this.elem.down(".html").setStyle({ | |
| height: size.height - (this.data.title ? this.data.title.height : 0) + "px" | |
| }), arguments[1] || this.data.onResize(this, this.elem.getDimensions()), this | |
| }, | |
| setPos: function (data) { | |
| if (this.elem) { | |
| this.data.pos = Object.extend({ | |
| x: I.Windows.spawnPosition[0], | |
| y: I.Windows.spawnPosition[1], | |
| fromCenter: !0, | |
| animate: 0 | |
| }, data || {}); | |
| var pos = { | |
| x: this.data.pos.x, | |
| y: this.data.pos.y | |
| }; | |
| return this.data.pos.fromCenter && (pos.x = pos.x + (document.viewport.getWidth() - this.elem.getWidth()) / 2, pos.y = pos.y + (document.viewport.getHeight() - this.elem.getHeight()) / 2), pos.y < 1 && (pos.y = 0), pos.y < 1 || pos.x < 1 ? this.elem.setClass("maximized") : this.elem.removeClassName("maximized"), this.data.pos.animate > 0 ? (this.elem.morph("top:" + pos.y + "px", { | |
| duration: this.data.pos.animate | |
| }), this.elem.morph("left:" + pos.x + "px", { | |
| duration: this.data.pos.animate | |
| })) : (this.elem.setStyle("top:" + pos.y + "px"), this.elem.setStyle("left:" + pos.x + "px")), this | |
| } | |
| }, | |
| onDrop: function () { | |
| var Selection = I.Explorer.Selection, | |
| err = [], | |
| error = function (error, data) { | |
| return err.push([error, data]), !1 | |
| }.bind(this), | |
| ids = Selection.getIds(!0, function (id, i) { | |
| if (this.data.dropMax > 0 && i + 1 > this.data.dropMax) return error("max", null); | |
| var data = I.Explorer.DB.get("element", id); | |
| return Object.isFunction(this.dropFilter) && this.dropFilter(data) === !1 ? error("filter", data) : this.data.dropAllowType.length > 0 && !this.data.dropAllowType.include(data.type) ? error("type", data) : this.data.dropAllowExt.length > 0 && "file" == data.type && !this.data.dropAllowExt.include(data.name.split(".").last().toLowerCase()) ? error("ext", data) : this.data.dropAllowSize > 0 && "file" == data.type && data.size > this.data.dropAllowSize ? error("size", data) : void 0 | |
| }.bind(this)); | |
| return err.length > 0 && Object.isFunction(this.data.dropError) ? this.data.dropError(err) : (this.data.onDrop(ids), void 0) | |
| }, | |
| close: function (event) { | |
| if (this._closed) return null; | |
| if (this._closed = !0, this.data.onClose(event) === !1) return this._closed = !1; | |
| var options = Object.extend({ | |
| duration: .2 | |
| }, arguments[1] || {}); | |
| this.data.onClose = function () { | |
| return !1 | |
| }, Object.keys(this._keys).each(function (key) { | |
| this._keys[key].clear() | |
| }.bind(this)), this.disableResizeEvent(); | |
| var remove = function () { | |
| this.data.wrap ? ($$("body").invoke("removeClassName", "oH"), this.elem.up(".wrapper").remove()) : this.elem.remove(), this.data.afterClose(event) | |
| }.bind(this); | |
| options.duration > 0 ? (this.elem.setClass("tEaseIn o0 trans0" + (10 * options.duration + "").substr(0, 1)), this.data.maximized || this.elem.setClass("z09"), setTimeout(remove, 1e3 * options.duration + 150)) : remove(), this.data.parent && (this.data.parent.elem.removeClassNames("z09 o03"), setTimeout(function () { | |
| this.data.parent.elem.removeClassName("trans05"), Object.isElement(this.data.parent) && this.data.parent.remove() | |
| }.bind(this), 400)), this.data.cover && (I.Content.setClass("trans03", .3), this.elem.previous(".cover").remove()), this.data.blur && $$("#container").first().removeClassName("blured"), I.Windows.close(this), setTimeout(function () { | |
| $$(".tooltip").invoke("hide") | |
| }, 400) | |
| }, | |
| renderText: function (text) { | |
| for (var i = 0; | |
| (text + "").include("__"); i++) i > 0 && (text.include("__") ? text = text.sub("__", "</div>__") : text += "</div>"), text = text.sub("__", '<div class="border w50"></div><div class="sub o06 fs5 b4">'); | |
| return text | |
| }, | |
| onShow: function () { | |
| Object.isFunction(this.data.onShow) && this.data.onShow(this) | |
| }, | |
| show: function () { | |
| var duration = Object.isUndefined(arguments[0]) ? .2 : arguments[0]; | |
| return this.onShow(this), this.elem.setClass("tEaseOut o0 z09").show(), this.timeout(function () { | |
| this.elem.setClass("trans0" + (10 * duration + "").substr(0, 1)), this.elem.removeClassNames("o0 z09") | |
| }.bind(this), .1), this.timeout(function () { | |
| this.elem.removeClassNames("tEaseOut trans0" + (10 * duration + "")) | |
| }.bind(this), duration), this._visible = !0, this.data.cover && this.elem.previous(".cover").setStyle("z-index:" + I.Windows.zIndex).show(), this.data.blur && setTimeout(function () { | |
| $$("#container").first().setClass("blured") | |
| }, 0), this | |
| }, | |
| hide: function () { | |
| return this.elem.hide(), this._visible = !1, this.data.cover && this.elem.previous(".cover").hide(), this.data.blur && $$("#container").first().removeClassName("blured"), this | |
| }, | |
| handleBG: function () {} | |
| }), C.WinApp = Class.create(C.Window, { | |
| initialize: function ($super, obj) { | |
| obj.id = "app" + obj.id.toSHA1(); | |
| var options = Object.extend({ | |
| className: "app" | |
| }, arguments[1] || {}); | |
| return $super(options), this | |
| }, | |
| insert: function ($super) { | |
| var html = '<iframe class="appIframe" frameborder="0" src="' + this.data.iframe + '"></iframe>'; | |
| $super(html), this.elem.down("iframe").observe("load", function () { | |
| this.timeout(function () { | |
| this.elem.down("iframe").contentWindow.focus() | |
| }.bind(this), .1) | |
| }.bind(this)) | |
| } | |
| }), C.WinAlert = Class.create(C.Window, { | |
| initialize: function ($super, text) { | |
| var options = Object.extend({ | |
| okText: "OK", | |
| width: 400, | |
| blur: !0, | |
| className: "alert", | |
| okDisabled: !1 | |
| }, arguments[2] || {}); | |
| $super(options), I.Windows.resetSpawn(), this.enableKeys(["enter", "esc"]); | |
| var html = '<h2 class="p aC">' + this.renderText(text) + "</h2>" + '<div class="bg buttons">' + ' <button class="ok" style="width:100%">' + options.okText + "</button>" + "</div>"; | |
| return this.insert(html), this.elem.down(".ok").observe("click", this.close.bind(this)), options.okDisabled && (this.elem.down("button.ok").disabled = !0), this | |
| }, | |
| key: function ($super, event, key) { | |
| $super(event, key) && "keyup" != event.type && this.close() | |
| } | |
| }), C.WinConfirm = Class.create(C.Window, { | |
| initialize: function ($super, text) { | |
| this.options = Object.extend({ | |
| closeable: !1, | |
| width: 450, | |
| blur: !0, | |
| no: !1, | |
| className: "confirm", | |
| cancelText: "Cancel", | |
| okText: "OK", | |
| okDisabled: !1, | |
| noText: "NO", | |
| onAction: Prototype.emptyFunction, | |
| onConfirm: Prototype.emptyFunction, | |
| onCancel: Prototype.emptyFunction, | |
| onNo: Prototype.emptyFunction | |
| }, arguments[2] || {}), this.options.html && (this.options.HTML = this.options.html, delete this.options.html), $super(this.options), I.Windows.resetSpawn(), this.enableKeys(["enter", "esc"]); | |
| var html = (text ? '<h2 class="p aC">' + this.renderText(text) + "</h2>" : "") + (this.options.HTML || "") + '<div class="bg buttons">' + ' <button class="fL half cancel" style="position:relative">' + this.options.cancelText + "</button>" + ' <button class="fR half ok" style="position:relative">' + this.options.okText + "</button>" + "</div>"; | |
| return this.insert(html), this.elem.down(".cancel").observe("click", this.close.bind(this, !1)), this.elem.down(".ok").observe("click", this.close.bind(this, !0)), this.options.okDisabled && (this.elem.down("button.ok").disabled = !0), this.options.no && (this.elem.select(".half").invoke("removeClassName", "half").invoke("setStyle", "width:31%"), this.elem.down(".buttons").insert('<button class="fR no" style="width:31%">' + this.options.noText + "</button>"), this.elem.down(".no").observe("click", this.close.bind(this, null))), this | |
| }, | |
| key: function ($super, event, key) { | |
| if (!document.activeElement.isInput() && $super(event, key) && "keyup" != event.type) switch (key) { | |
| case "esc": | |
| this.elem.down("button.cancel").disabled || this.close(!1); | |
| break; | |
| case "enter": | |
| this.elem.down("button.ok").disabled || this.close(!0) | |
| } | |
| }, | |
| close: function ($super, isOK) { | |
| if (this.options.onAction(isOK, this) === !1) return !1; | |
| if (isOK) { | |
| if (this.options.onConfirm(this) === !1) return !1 | |
| } else if (null === isOK) { | |
| if (this.options.onNo(this) === !1) return !1 | |
| } else if (this.options.onCancel(this) === !1) return !1; | |
| $super() | |
| } | |
| }), C.WinPrompt = Class.create(C.Window, { | |
| initialize: function ($super) { | |
| this.options = Object.extend({ | |
| closeable: !1, | |
| width: 450, | |
| blur: !0, | |
| no: !1, | |
| className: "prompt", | |
| placeholder: "", | |
| select: !1, | |
| text: !1, | |
| type: "text", | |
| watchInput: null, | |
| cancelText: "Cancel", | |
| okText: "OK", | |
| noText: "NO", | |
| okDisabled: !1, | |
| onAction: Prototype.emptyFunction, | |
| onConfirm: Prototype.emptyFunction, | |
| onChange: Prototype.emptyFunction, | |
| onCancel: Prototype.emptyFunction, | |
| onNo: Prototype.emptyFunction | |
| }, arguments[1] || {}), $super(this.options), I.Windows.resetSpawn(), this.enableKeys(["enter", "esc"]); | |
| var html = (this.options.text ? '<div class="aC b6 fs3" style="margin:23px 0 -2px">' + this.renderText(this.options.text) + "</div>" : "") + '<input type="' + this.options.type + '" name="value" placeholder="' + this.options.placeholder + '" />' + '<div class="bg buttons">' + ' <button class="half cancel" style="float:left">' + this.options.cancelText + "</button>" + ' <button class="half ok" style="float:right">' + this.options.okText + "</button>" + "</div>"; | |
| if (this.insert(html), this.elem.down(".cancel").observe("click", this.close.bind(this, !1)), this.elem.down(".ok").observe("click", this.close.bind(this, !0)), this.elem.down("input").observe("keyup", function (e) { | |
| this.options.onChange(this.elem.down("input").getValue(), this, e) | |
| }.bind(this)), this.options.watchInput && this.elem.down("input").watchInput(this.options.watchInput), this.options.okDisabled && (this.elem.down("button.ok").disabled = !0), this.options.select) { | |
| this.elem.down("input").replace("<select></select>"), this.elem.down("select").observe("change", function () { | |
| this.options.onChange(this.elem.down("select").getValue()) | |
| }.bind(this)); | |
| var options = []; | |
| Object.isString(this.options.select[0]) ? options = "<option>" + this.options.select.join("</option><option>") + "</option>" : this.options.select.each(function (obj) { | |
| options.push('<option value="' + (obj.value || obj.text) + '"' + (obj.selected ? ' selected="selected"' : "") + (obj.disabled ? ' disabled="disabled"' : "") + ">" + obj.text + "</option>") | |
| }.bind(this)), this.elem.down("select").update(options) | |
| } | |
| return this.options.no && (this.elem.select(".half").invoke("removeClassName", "half").invoke("setStyle", "width:31%"), this.elem.down(".buttons").insert('<button class="fR no" style="width:31%">' + this.options.noText + "</button>"), this.elem.down(".no").observe("click", this.close.bind(this, null))), this | |
| }, | |
| key: function ($super, event, key) { | |
| if ($super(event, key) && "keyup" != event.type) switch (key) { | |
| case "esc": | |
| this.elem.down("button.cancel").disabled || this.close(!1); | |
| break; | |
| case "enter": | |
| this.elem.down("button.ok").disabled || this.close(!0) | |
| } | |
| }, | |
| onShow: function ($super) { | |
| $super(), this.timeout(function () { | |
| this.elem.down("input") && this.elem.down("input").focus() | |
| }.bind(this), .2) | |
| }, | |
| close: function ($super, isOK) { | |
| var value = this.elem.down("input") ? this.elem.down("input").getValue() : this.elem.down("select").getValue(); | |
| if (this.options.onAction(isOK, value, this) === !1) return !1; | |
| if (isOK) { | |
| if (this.options.onConfirm(value, this) === !1) return !1 | |
| } else if (null === isOK) { | |
| if (this.options.onNo(value, this) === !1) return !1 | |
| } else if (this.options.onCancel(value, this) === !1) return !1; | |
| $super() | |
| } | |
| }), C.WinDrop = Class.create(C.Window, { | |
| initialize: function ($super) { | |
| c("WX"), this.options = Object.extend({ | |
| draggable: !0, | |
| width: 180, | |
| text: "Drop Elements", | |
| label: "", | |
| className: "drop", | |
| text: "Drop Elements", | |
| onCancel: Prototype.emptyFunction | |
| }, Array.prototype.last.call(arguments) || {}), $super(this.options), I.Windows.resetSpawn(); | |
| var html = '<div class="text padding">' + this.options.text + "</div>" + (this.options.label ? '<div class="oH trans05"><h4 class="bg padding">' + this.options.label + "</h4></div>" : "") + '<div class="gui ico close trans03" title="Close"></div>'; | |
| return this.insert(html), this.elem.down(".oH.trans05").setStyle("height:" + (this.elem.down("h4.bg").getHeight() + 10) + "px"), this.elem.down(".ico.close").observe("click", this.close.bind(this)), this | |
| }, | |
| loading: function () { | |
| this.elem.down(".text").update("Processing…"), this.elem.down(".oH.trans05").setStyle("height:0px;margin-bottom:-23px"), this.elem.down(".ico.close").setClass("o0") | |
| }, | |
| close: function ($super) { | |
| return this.options.onCancel(this) === !1 ? !1 : ($super(), void 0) | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment