Index: trunk/extensions/MobileFrontend2/modules/zepto/zepto.js |
— | — | @@ -0,0 +1,1420 @@ |
| 2 | +// Zepto.js |
| 3 | +// (c) 2010-2012 Thomas Fuchs |
| 4 | +// Zepto.js may be freely distributed under the MIT license. |
| 5 | + |
| 6 | +(function(undefined){ |
| 7 | + if (String.prototype.trim === undefined) // fix for iOS 3.2 |
| 8 | + String.prototype.trim = function(){ return this.replace(/^\s+/, '').replace(/\s+$/, '') }; |
| 9 | + |
| 10 | + // For iOS 3.x |
| 11 | + // from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduce |
| 12 | + if (Array.prototype.reduce === undefined) |
| 13 | + Array.prototype.reduce = function(fun){ |
| 14 | + if(this === void 0 || this === null) throw new TypeError(); |
| 15 | + var t = Object(this), len = t.length >>> 0, k = 0, accumulator; |
| 16 | + if(typeof fun != 'function') throw new TypeError(); |
| 17 | + if(len == 0 && arguments.length == 1) throw new TypeError(); |
| 18 | + |
| 19 | + if(arguments.length >= 2) |
| 20 | + accumulator = arguments[1]; |
| 21 | + else |
| 22 | + do{ |
| 23 | + if(k in t){ |
| 24 | + accumulator = t[k++]; |
| 25 | + break; |
| 26 | + } |
| 27 | + if(++k >= len) throw new TypeError(); |
| 28 | + } while (true); |
| 29 | + |
| 30 | + while (k < len){ |
| 31 | + if(k in t) accumulator = fun.call(undefined, accumulator, t[k], k, t); |
| 32 | + k++; |
| 33 | + } |
| 34 | + return accumulator; |
| 35 | + }; |
| 36 | + |
| 37 | +})(); |
| 38 | +// Zepto.js |
| 39 | +// (c) 2010-2012 Thomas Fuchs |
| 40 | +// Zepto.js may be freely distributed under the MIT license. |
| 41 | + |
| 42 | +var Zepto = (function() { |
| 43 | + var undefined, key, $$, classList, emptyArray = [], slice = emptyArray.slice, |
| 44 | + document = window.document, |
| 45 | + elementDisplay = {}, classCache = {}, |
| 46 | + getComputedStyle = document.defaultView.getComputedStyle, |
| 47 | + cssNumber = { 'column-count': 1, 'columns': 1, 'font-weight': 1, 'line-height': 1,'opacity': 1, 'z-index': 1, 'zoom': 1 }, |
| 48 | + fragmentRE = /^\s*<(\w+)[^>]*>/, |
| 49 | + elementTypes = [1, 9, 11], |
| 50 | + adjacencyOperators = [ 'after', 'prepend', 'before', 'append' ], |
| 51 | + table = document.createElement('table'), |
| 52 | + tableRow = document.createElement('tr'), |
| 53 | + containers = { |
| 54 | + 'tr': document.createElement('tbody'), |
| 55 | + 'tbody': table, 'thead': table, 'tfoot': table, |
| 56 | + 'td': tableRow, 'th': tableRow, |
| 57 | + '*': document.createElement('div') |
| 58 | + }, |
| 59 | + readyRE = /complete|loaded|interactive/, |
| 60 | + classSelectorRE = /^\.([\w-]+)$/, |
| 61 | + idSelectorRE = /^#([\w-]+)$/, |
| 62 | + tagSelectorRE = /^[\w-]+$/; |
| 63 | + |
| 64 | + function isF(value) { return ({}).toString.call(value) == "[object Function]" } |
| 65 | + function isO(value) { return value instanceof Object } |
| 66 | + function isA(value) { return value instanceof Array } |
| 67 | + function likeArray(obj) { return typeof obj.length == 'number' } |
| 68 | + |
| 69 | + function compact(array) { return array.filter(function(item){ return item !== undefined && item !== null }) } |
| 70 | + function flatten(array) { return array.length > 0 ? [].concat.apply([], array) : array } |
| 71 | + function camelize(str) { return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) } |
| 72 | + function dasherize(str){ |
| 73 | + return str.replace(/::/g, '/') |
| 74 | + .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2') |
| 75 | + .replace(/([a-z\d])([A-Z])/g, '$1_$2') |
| 76 | + .replace(/_/g, '-') |
| 77 | + .toLowerCase(); |
| 78 | + } |
| 79 | + function uniq(array) { return array.filter(function(item,index,array){ return array.indexOf(item) == index }) } |
| 80 | + |
| 81 | + function classRE(name){ |
| 82 | + return name in classCache ? |
| 83 | + classCache[name] : (classCache[name] = new RegExp('(^|\\s)' + name + '(\\s|$)')); |
| 84 | + } |
| 85 | + |
| 86 | + function maybeAddPx(name, value) { return (typeof value == "number" && !cssNumber[dasherize(name)]) ? value + "px" : value; } |
| 87 | + |
| 88 | + function defaultDisplay(nodeName) { |
| 89 | + var element, display; |
| 90 | + if (!elementDisplay[nodeName]) { |
| 91 | + element = document.createElement(nodeName); |
| 92 | + document.body.appendChild(element); |
| 93 | + display = getComputedStyle(element, '').getPropertyValue("display"); |
| 94 | + element.parentNode.removeChild(element); |
| 95 | + display == "none" && (display = "block"); |
| 96 | + elementDisplay[nodeName] = display; |
| 97 | + } |
| 98 | + return elementDisplay[nodeName]; |
| 99 | + } |
| 100 | + |
| 101 | + function fragment(html, name) { |
| 102 | + if (name === undefined) name = fragmentRE.test(html) && RegExp.$1; |
| 103 | + if (!(name in containers)) name = '*'; |
| 104 | + var container = containers[name]; |
| 105 | + container.innerHTML = '' + html; |
| 106 | + return slice.call(container.childNodes); |
| 107 | + } |
| 108 | + |
| 109 | + function Z(dom, selector){ |
| 110 | + dom = dom || emptyArray; |
| 111 | + dom.__proto__ = Z.prototype; |
| 112 | + dom.selector = selector || ''; |
| 113 | + return dom; |
| 114 | + } |
| 115 | + |
| 116 | + function $(selector, context){ |
| 117 | + if (!selector) return Z(); |
| 118 | + if (context !== undefined) return $(context).find(selector); |
| 119 | + else if (isF(selector)) return $(document).ready(selector); |
| 120 | + else if (selector instanceof Z) return selector; |
| 121 | + else { |
| 122 | + var dom; |
| 123 | + if (isA(selector)) dom = compact(selector); |
| 124 | + else if (elementTypes.indexOf(selector.nodeType) >= 0 || selector === window) |
| 125 | + dom = [selector], selector = null; |
| 126 | + else if (fragmentRE.test(selector)) |
| 127 | + dom = fragment(selector.trim(), RegExp.$1), selector = null; |
| 128 | + else if (selector.nodeType && selector.nodeType == 3) dom = [selector]; |
| 129 | + else dom = $$(document, selector); |
| 130 | + return Z(dom, selector); |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + $.extend = function(target){ |
| 135 | + slice.call(arguments, 1).forEach(function(source) { |
| 136 | + for (key in source) target[key] = source[key]; |
| 137 | + }) |
| 138 | + return target; |
| 139 | + } |
| 140 | + |
| 141 | + $.qsa = $$ = function(element, selector){ |
| 142 | + var found; |
| 143 | + return (element === document && idSelectorRE.test(selector)) ? |
| 144 | + ( (found = element.getElementById(RegExp.$1)) ? [found] : emptyArray ) : |
| 145 | + slice.call( |
| 146 | + classSelectorRE.test(selector) ? element.getElementsByClassName(RegExp.$1) : |
| 147 | + tagSelectorRE.test(selector) ? element.getElementsByTagName(selector) : |
| 148 | + element.querySelectorAll(selector) |
| 149 | + ); |
| 150 | + } |
| 151 | + |
| 152 | + function filtered(nodes, selector){ |
| 153 | + return selector === undefined ? $(nodes) : $(nodes).filter(selector); |
| 154 | + } |
| 155 | + |
| 156 | + function funcArg(context, arg, idx, payload){ |
| 157 | + return isF(arg) ? arg.call(context, idx, payload) : arg; |
| 158 | + } |
| 159 | + |
| 160 | + $.isFunction = isF; |
| 161 | + $.isObject = isO; |
| 162 | + $.isArray = isA; |
| 163 | + |
| 164 | + $.inArray = function(elem, array, i) { |
| 165 | + return emptyArray.indexOf.call(array, elem, i); |
| 166 | + } |
| 167 | + |
| 168 | + $.map = function(elements, callback) { |
| 169 | + var value, values = [], i, key; |
| 170 | + if (likeArray(elements)) |
| 171 | + for (i = 0; i < elements.length; i++) { |
| 172 | + value = callback(elements[i], i); |
| 173 | + if (value != null) values.push(value); |
| 174 | + } |
| 175 | + else |
| 176 | + for (key in elements) { |
| 177 | + value = callback(elements[key], key); |
| 178 | + if (value != null) values.push(value); |
| 179 | + } |
| 180 | + return flatten(values); |
| 181 | + } |
| 182 | + |
| 183 | + $.each = function(elements, callback) { |
| 184 | + var i, key; |
| 185 | + if (likeArray(elements)) |
| 186 | + for(i = 0; i < elements.length; i++) { |
| 187 | + if(callback.call(elements[i], i, elements[i]) === false) return elements; |
| 188 | + } |
| 189 | + else |
| 190 | + for(key in elements) { |
| 191 | + if(callback.call(elements[key], key, elements[key]) === false) return elements; |
| 192 | + } |
| 193 | + return elements; |
| 194 | + } |
| 195 | + |
| 196 | + $.fn = { |
| 197 | + forEach: emptyArray.forEach, |
| 198 | + reduce: emptyArray.reduce, |
| 199 | + push: emptyArray.push, |
| 200 | + indexOf: emptyArray.indexOf, |
| 201 | + concat: emptyArray.concat, |
| 202 | + map: function(fn){ |
| 203 | + return $.map(this, function(el, i){ return fn.call(el, i, el) }); |
| 204 | + }, |
| 205 | + slice: function(){ |
| 206 | + return $(slice.apply(this, arguments)); |
| 207 | + }, |
| 208 | + ready: function(callback){ |
| 209 | + if (readyRE.test(document.readyState)) callback($); |
| 210 | + else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false); |
| 211 | + return this; |
| 212 | + }, |
| 213 | + get: function(idx){ return idx === undefined ? this : this[idx] }, |
| 214 | + size: function(){ return this.length }, |
| 215 | + remove: function () { |
| 216 | + return this.each(function () { |
| 217 | + if (this.parentNode != null) { |
| 218 | + this.parentNode.removeChild(this); |
| 219 | + } |
| 220 | + }); |
| 221 | + }, |
| 222 | + each: function(callback){ |
| 223 | + this.forEach(function(el, idx){ callback.call(el, idx, el) }); |
| 224 | + return this; |
| 225 | + }, |
| 226 | + filter: function(selector){ |
| 227 | + return $([].filter.call(this, function(element){ |
| 228 | + return element.parentNode && $$(element.parentNode, selector).indexOf(element) >= 0; |
| 229 | + })); |
| 230 | + }, |
| 231 | + end: function(){ |
| 232 | + return this.prevObject || $(); |
| 233 | + }, |
| 234 | + andSelf:function(){ |
| 235 | + return this.add(this.prevObject || $()) |
| 236 | + }, |
| 237 | + add:function(selector,context){ |
| 238 | + return $(uniq(this.concat($(selector,context)))); |
| 239 | + }, |
| 240 | + is: function(selector){ |
| 241 | + return this.length > 0 && $(this[0]).filter(selector).length > 0; |
| 242 | + }, |
| 243 | + not: function(selector){ |
| 244 | + var nodes=[]; |
| 245 | + if (isF(selector) && selector.call !== undefined) |
| 246 | + this.each(function(idx){ |
| 247 | + if (!selector.call(this,idx)) nodes.push(this); |
| 248 | + }); |
| 249 | + else { |
| 250 | + var excludes = typeof selector == 'string' ? this.filter(selector) : |
| 251 | + (likeArray(selector) && isF(selector.item)) ? slice.call(selector) : $(selector); |
| 252 | + this.forEach(function(el){ |
| 253 | + if (excludes.indexOf(el) < 0) nodes.push(el); |
| 254 | + }); |
| 255 | + } |
| 256 | + return $(nodes); |
| 257 | + }, |
| 258 | + eq: function(idx){ |
| 259 | + return idx === -1 ? this.slice(idx) : this.slice(idx, + idx + 1); |
| 260 | + }, |
| 261 | + first: function(){ var el = this[0]; return el && !isO(el) ? el : $(el) }, |
| 262 | + last: function(){ var el = this[this.length - 1]; return el && !isO(el) ? el : $(el) }, |
| 263 | + find: function(selector){ |
| 264 | + var result; |
| 265 | + if (this.length == 1) result = $$(this[0], selector); |
| 266 | + else result = this.map(function(){ return $$(this, selector) }); |
| 267 | + return $(result); |
| 268 | + }, |
| 269 | + closest: function(selector, context){ |
| 270 | + var node = this[0], candidates = $$(context || document, selector); |
| 271 | + if (!candidates.length) node = null; |
| 272 | + while (node && candidates.indexOf(node) < 0) |
| 273 | + node = node !== context && node !== document && node.parentNode; |
| 274 | + return $(node); |
| 275 | + }, |
| 276 | + parents: function(selector){ |
| 277 | + var ancestors = [], nodes = this; |
| 278 | + while (nodes.length > 0) |
| 279 | + nodes = $.map(nodes, function(node){ |
| 280 | + if ((node = node.parentNode) && node !== document && ancestors.indexOf(node) < 0) { |
| 281 | + ancestors.push(node); |
| 282 | + return node; |
| 283 | + } |
| 284 | + }); |
| 285 | + return filtered(ancestors, selector); |
| 286 | + }, |
| 287 | + parent: function(selector){ |
| 288 | + return filtered(uniq(this.pluck('parentNode')), selector); |
| 289 | + }, |
| 290 | + children: function(selector){ |
| 291 | + return filtered(this.map(function(){ return slice.call(this.children) }), selector); |
| 292 | + }, |
| 293 | + siblings: function(selector){ |
| 294 | + return filtered(this.map(function(i, el){ |
| 295 | + return slice.call(el.parentNode.children).filter(function(child){ return child!==el }); |
| 296 | + }), selector); |
| 297 | + }, |
| 298 | + empty: function(){ return this.each(function(){ this.innerHTML = '' }) }, |
| 299 | + pluck: function(property){ return this.map(function(){ return this[property] }) }, |
| 300 | + show: function(){ |
| 301 | + return this.each(function() { |
| 302 | + this.style.display == "none" && (this.style.display = null); |
| 303 | + if (getComputedStyle(this, '').getPropertyValue("display") == "none") { |
| 304 | + this.style.display = defaultDisplay(this.nodeName) |
| 305 | + } |
| 306 | + }) |
| 307 | + }, |
| 308 | + replaceWith: function(newContent) { |
| 309 | + return this.each(function() { |
| 310 | + $(this).before(newContent).remove(); |
| 311 | + }); |
| 312 | + }, |
| 313 | + wrap: function(newContent) { |
| 314 | + return this.each(function() { |
| 315 | + $(this).wrapAll($(newContent)[0].cloneNode(false)); |
| 316 | + }); |
| 317 | + }, |
| 318 | + wrapAll: function(newContent) { |
| 319 | + if (this[0]) { |
| 320 | + $(this[0]).before(newContent = $(newContent)); |
| 321 | + newContent.append(this); |
| 322 | + } |
| 323 | + return this; |
| 324 | + }, |
| 325 | + unwrap: function(){ |
| 326 | + this.parent().each(function(){ |
| 327 | + $(this).replaceWith($(this).children()); |
| 328 | + }); |
| 329 | + return this; |
| 330 | + }, |
| 331 | + hide: function(){ |
| 332 | + return this.css("display", "none") |
| 333 | + }, |
| 334 | + toggle: function(setting){ |
| 335 | + return (setting === undefined ? this.css("display") == "none" : setting) ? this.show() : this.hide(); |
| 336 | + }, |
| 337 | + prev: function(){ return $(this.pluck('previousElementSibling')) }, |
| 338 | + next: function(){ return $(this.pluck('nextElementSibling')) }, |
| 339 | + html: function(html){ |
| 340 | + return html === undefined ? |
| 341 | + (this.length > 0 ? this[0].innerHTML : null) : |
| 342 | + this.each(function (idx) { |
| 343 | + var originHtml = this.innerHTML; |
| 344 | + $(this).empty().append( funcArg(this, html, idx, originHtml) ); |
| 345 | + }); |
| 346 | + }, |
| 347 | + text: function(text){ |
| 348 | + return text === undefined ? |
| 349 | + (this.length > 0 ? this[0].textContent : null) : |
| 350 | + this.each(function(){ this.textContent = text }); |
| 351 | + }, |
| 352 | + attr: function(name, value){ |
| 353 | + var res; |
| 354 | + return (typeof name == 'string' && value === undefined) ? |
| 355 | + (this.length == 0 ? undefined : |
| 356 | + (name == 'value' && this[0].nodeName == 'INPUT') ? this.val() : |
| 357 | + (!(res = this[0].getAttribute(name)) && name in this[0]) ? this[0][name] : res |
| 358 | + ) : |
| 359 | + this.each(function(idx){ |
| 360 | + if (isO(name)) for (key in name) this.setAttribute(key, name[key]) |
| 361 | + else this.setAttribute(name, funcArg(this, value, idx, this.getAttribute(name))); |
| 362 | + }); |
| 363 | + }, |
| 364 | + removeAttr: function(name) { |
| 365 | + return this.each(function() { this.removeAttribute(name); }); |
| 366 | + }, |
| 367 | + data: function(name, value){ |
| 368 | + return this.attr('data-' + name, value); |
| 369 | + }, |
| 370 | + val: function(value){ |
| 371 | + return (value === undefined) ? |
| 372 | + (this.length > 0 ? this[0].value : null) : |
| 373 | + this.each(function(idx){ |
| 374 | + this.value = funcArg(this, value, idx, this.value); |
| 375 | + }); |
| 376 | + }, |
| 377 | + offset: function(){ |
| 378 | + if(this.length==0) return null; |
| 379 | + var obj = this[0].getBoundingClientRect(); |
| 380 | + return { |
| 381 | + left: obj.left + window.pageXOffset, |
| 382 | + top: obj.top + window.pageYOffset, |
| 383 | + width: obj.width, |
| 384 | + height: obj.height |
| 385 | + }; |
| 386 | + }, |
| 387 | + css: function(property, value){ |
| 388 | + if (value === undefined && typeof property == 'string') { |
| 389 | + return( |
| 390 | + this.length == 0 |
| 391 | + ? undefined |
| 392 | + : this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property) |
| 393 | + ); |
| 394 | + } |
| 395 | + var css = ''; |
| 396 | + for (key in property) css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';'; |
| 397 | + if (typeof property == 'string') css = dasherize(property) + ":" + maybeAddPx(property, value); |
| 398 | + return this.each(function() { this.style.cssText += ';' + css }); |
| 399 | + }, |
| 400 | + index: function(element){ |
| 401 | + return element ? this.indexOf($(element)[0]) : this.parent().children().indexOf(this[0]); |
| 402 | + }, |
| 403 | + hasClass: function(name){ |
| 404 | + if (this.length < 1) return false; |
| 405 | + else return classRE(name).test(this[0].className); |
| 406 | + }, |
| 407 | + addClass: function(name){ |
| 408 | + return this.each(function(idx) { |
| 409 | + classList = []; |
| 410 | + var cls = this.className, newName = funcArg(this, name, idx, cls); |
| 411 | + newName.split(/\s+/g).forEach(function(klass) { |
| 412 | + if (!$(this).hasClass(klass)) { |
| 413 | + classList.push(klass) |
| 414 | + } |
| 415 | + }, this); |
| 416 | + classList.length && (this.className += (cls ? " " : "") + classList.join(" ")) |
| 417 | + }); |
| 418 | + }, |
| 419 | + removeClass: function(name){ |
| 420 | + return this.each(function(idx) { |
| 421 | + if(name === undefined) |
| 422 | + return this.className = ''; |
| 423 | + classList = this.className; |
| 424 | + funcArg(this, name, idx, classList).split(/\s+/g).forEach(function(klass) { |
| 425 | + classList = classList.replace(classRE(klass), " ") |
| 426 | + }); |
| 427 | + this.className = classList.trim() |
| 428 | + }); |
| 429 | + }, |
| 430 | + toggleClass: function(name, when){ |
| 431 | + return this.each(function(idx){ |
| 432 | + var newName = funcArg(this, name, idx, this.className); |
| 433 | + (when === undefined ? !$(this).hasClass(newName) : when) ? |
| 434 | + $(this).addClass(newName) : $(this).removeClass(newName); |
| 435 | + }); |
| 436 | + } |
| 437 | + }; |
| 438 | + |
| 439 | + 'filter,add,not,eq,first,last,find,closest,parents,parent,children,siblings'.split(',').forEach(function(property){ |
| 440 | + var fn = $.fn[property]; |
| 441 | + $.fn[property] = function() { |
| 442 | + var ret = fn.apply(this, arguments); |
| 443 | + ret.prevObject = this; |
| 444 | + return ret; |
| 445 | + } |
| 446 | + }); |
| 447 | + |
| 448 | + ['width', 'height'].forEach(function(dimension){ |
| 449 | + $.fn[dimension] = function(value) { |
| 450 | + var offset, Dimension = dimension.replace(/./, function(m) { return m[0].toUpperCase() }); |
| 451 | + if (value === undefined) return this[0] == window ? window['inner' + Dimension] : |
| 452 | + this[0] == document ? document.documentElement['offset' + Dimension] : |
| 453 | + (offset = this.offset()) && offset[dimension]; |
| 454 | + else return this.each(function(idx){ |
| 455 | + var el = $(this); |
| 456 | + el.css(dimension, funcArg(this, value, idx, el[dimension]())); |
| 457 | + }); |
| 458 | + } |
| 459 | + }); |
| 460 | + |
| 461 | + function insert(operator, target, node) { |
| 462 | + var parent = (operator % 2) ? target : target.parentNode; |
| 463 | + parent && parent.insertBefore(node, |
| 464 | + !operator ? target.nextSibling : // after |
| 465 | + operator == 1 ? parent.firstChild : // prepend |
| 466 | + operator == 2 ? target : // before |
| 467 | + null); // append |
| 468 | + } |
| 469 | + |
| 470 | + function traverseNode (node, fun) { |
| 471 | + fun(node); |
| 472 | + for (var key in node.childNodes) { |
| 473 | + traverseNode(node.childNodes[key], fun); |
| 474 | + } |
| 475 | + } |
| 476 | + |
| 477 | + adjacencyOperators.forEach(function(key, operator) { |
| 478 | + $.fn[key] = function(html){ |
| 479 | + var nodes = isO(html) ? html : fragment(html); |
| 480 | + if (!('length' in nodes) || nodes.nodeType) nodes = [nodes]; |
| 481 | + if (nodes.length < 1) return this; |
| 482 | + var size = this.length, copyByClone = size > 1, inReverse = operator < 2; |
| 483 | + |
| 484 | + return this.each(function(index, target){ |
| 485 | + for (var i = 0; i < nodes.length; i++) { |
| 486 | + var node = nodes[inReverse ? nodes.length-i-1 : i]; |
| 487 | + traverseNode(node, function (node) { |
| 488 | + if (node.nodeName != null && node.nodeName.toUpperCase() === 'SCRIPT' && (!node.type || node.type === 'text/javascript')) { |
| 489 | + window['eval'].call(window, node.innerHTML); |
| 490 | + } |
| 491 | + }); |
| 492 | + if (copyByClone && index < size - 1) node = node.cloneNode(true); |
| 493 | + insert(operator, target, node); |
| 494 | + } |
| 495 | + }); |
| 496 | + }; |
| 497 | + |
| 498 | + var reverseKey = (operator % 2) ? key+'To' : 'insert'+(operator ? 'Before' : 'After'); |
| 499 | + $.fn[reverseKey] = function(html) { |
| 500 | + $(html)[key](this); |
| 501 | + return this; |
| 502 | + }; |
| 503 | + }); |
| 504 | + |
| 505 | + Z.prototype = $.fn; |
| 506 | + |
| 507 | + return $; |
| 508 | +})(); |
| 509 | + |
| 510 | +window.Zepto = Zepto; |
| 511 | +'$' in window || (window.$ = Zepto); |
| 512 | +// Zepto.js |
| 513 | +// (c) 2010-2012 Thomas Fuchs |
| 514 | +// Zepto.js may be freely distributed under the MIT license. |
| 515 | + |
| 516 | +(function($){ |
| 517 | + var $$ = $.qsa, handlers = {}, _zid = 1, specialEvents={}; |
| 518 | + |
| 519 | + specialEvents.click = specialEvents.mousedown = specialEvents.mouseup = specialEvents.mousemove = 'MouseEvents'; |
| 520 | + |
| 521 | + function zid(element) { |
| 522 | + return element._zid || (element._zid = _zid++); |
| 523 | + } |
| 524 | + function findHandlers(element, event, fn, selector) { |
| 525 | + event = parse(event); |
| 526 | + if (event.ns) var matcher = matcherFor(event.ns); |
| 527 | + return (handlers[zid(element)] || []).filter(function(handler) { |
| 528 | + return handler |
| 529 | + && (!event.e || handler.e == event.e) |
| 530 | + && (!event.ns || matcher.test(handler.ns)) |
| 531 | + && (!fn || handler.fn == fn) |
| 532 | + && (!selector || handler.sel == selector); |
| 533 | + }); |
| 534 | + } |
| 535 | + function parse(event) { |
| 536 | + var parts = ('' + event).split('.'); |
| 537 | + return {e: parts[0], ns: parts.slice(1).sort().join(' ')}; |
| 538 | + } |
| 539 | + function matcherFor(ns) { |
| 540 | + return new RegExp('(?:^| )' + ns.replace(' ', ' .* ?') + '(?: |$)'); |
| 541 | + } |
| 542 | + |
| 543 | + function eachEvent(events, fn, iterator){ |
| 544 | + if ($.isObject(events)) $.each(events, iterator); |
| 545 | + else events.split(/\s/).forEach(function(type){ iterator(type, fn) }); |
| 546 | + } |
| 547 | + |
| 548 | + function add(element, events, fn, selector, getDelegate){ |
| 549 | + var id = zid(element), set = (handlers[id] || (handlers[id] = [])); |
| 550 | + eachEvent(events, fn, function(event, fn){ |
| 551 | + var delegate = getDelegate && getDelegate(fn, event), |
| 552 | + callback = delegate || fn; |
| 553 | + var proxyfn = function (event) { |
| 554 | + var result = callback.apply(element, [event].concat(event.data)); |
| 555 | + if (result === false) event.preventDefault(); |
| 556 | + return result; |
| 557 | + }; |
| 558 | + var handler = $.extend(parse(event), {fn: fn, proxy: proxyfn, sel: selector, del: delegate, i: set.length}); |
| 559 | + set.push(handler); |
| 560 | + element.addEventListener(handler.e, proxyfn, false); |
| 561 | + }); |
| 562 | + } |
| 563 | + function remove(element, events, fn, selector){ |
| 564 | + var id = zid(element); |
| 565 | + eachEvent(events || '', fn, function(event, fn){ |
| 566 | + findHandlers(element, event, fn, selector).forEach(function(handler){ |
| 567 | + delete handlers[id][handler.i]; |
| 568 | + element.removeEventListener(handler.e, handler.proxy, false); |
| 569 | + }); |
| 570 | + }); |
| 571 | + } |
| 572 | + |
| 573 | + $.event = { add: add, remove: remove } |
| 574 | + |
| 575 | + $.fn.bind = function(event, callback){ |
| 576 | + return this.each(function(){ |
| 577 | + add(this, event, callback); |
| 578 | + }); |
| 579 | + }; |
| 580 | + $.fn.unbind = function(event, callback){ |
| 581 | + return this.each(function(){ |
| 582 | + remove(this, event, callback); |
| 583 | + }); |
| 584 | + }; |
| 585 | + $.fn.one = function(event, callback){ |
| 586 | + return this.each(function(i, element){ |
| 587 | + add(this, event, callback, null, function(fn, type){ |
| 588 | + return function(){ |
| 589 | + var result = fn.apply(element, arguments); |
| 590 | + remove(element, type, fn); |
| 591 | + return result; |
| 592 | + } |
| 593 | + }); |
| 594 | + }); |
| 595 | + }; |
| 596 | + |
| 597 | + var returnTrue = function(){return true}, |
| 598 | + returnFalse = function(){return false}, |
| 599 | + eventMethods = { |
| 600 | + preventDefault: 'isDefaultPrevented', |
| 601 | + stopImmediatePropagation: 'isImmediatePropagationStopped', |
| 602 | + stopPropagation: 'isPropagationStopped' |
| 603 | + }; |
| 604 | + function createProxy(event) { |
| 605 | + var proxy = $.extend({originalEvent: event}, event); |
| 606 | + $.each(eventMethods, function(name, predicate) { |
| 607 | + proxy[name] = function(){ |
| 608 | + this[predicate] = returnTrue; |
| 609 | + return event[name].apply(event, arguments); |
| 610 | + }; |
| 611 | + proxy[predicate] = returnFalse; |
| 612 | + }) |
| 613 | + return proxy; |
| 614 | + } |
| 615 | + |
| 616 | + // emulates the 'defaultPrevented' property for browsers that have none |
| 617 | + function fix(event) { |
| 618 | + if (!('defaultPrevented' in event)) { |
| 619 | + event.defaultPrevented = false; |
| 620 | + var prevent = event.preventDefault; |
| 621 | + event.preventDefault = function() { |
| 622 | + this.defaultPrevented = true; |
| 623 | + prevent.call(this); |
| 624 | + } |
| 625 | + } |
| 626 | + } |
| 627 | + |
| 628 | + $.fn.delegate = function(selector, event, callback){ |
| 629 | + return this.each(function(i, element){ |
| 630 | + add(element, event, callback, selector, function(fn){ |
| 631 | + return function(e){ |
| 632 | + var evt, match = $(e.target).closest(selector, element).get(0); |
| 633 | + if (match) { |
| 634 | + evt = $.extend(createProxy(e), {currentTarget: match, liveFired: element}); |
| 635 | + return fn.apply(match, [evt].concat([].slice.call(arguments, 1))); |
| 636 | + } |
| 637 | + } |
| 638 | + }); |
| 639 | + }); |
| 640 | + }; |
| 641 | + $.fn.undelegate = function(selector, event, callback){ |
| 642 | + return this.each(function(){ |
| 643 | + remove(this, event, callback, selector); |
| 644 | + }); |
| 645 | + } |
| 646 | + |
| 647 | + $.fn.live = function(event, callback){ |
| 648 | + $(document.body).delegate(this.selector, event, callback); |
| 649 | + return this; |
| 650 | + }; |
| 651 | + $.fn.die = function(event, callback){ |
| 652 | + $(document.body).undelegate(this.selector, event, callback); |
| 653 | + return this; |
| 654 | + }; |
| 655 | + |
| 656 | + $.fn.on = function(event, selector, callback){ |
| 657 | + return selector === undefined || $.isFunction(selector) ? |
| 658 | + this.bind(event, selector) : this.delegate(selector, event, callback); |
| 659 | + }; |
| 660 | + $.fn.off = function(event, selector, callback){ |
| 661 | + return selector === undefined || $.isFunction(selector) ? |
| 662 | + this.unbind(event, selector) : this.undelegate(selector, event, callback); |
| 663 | + }; |
| 664 | + |
| 665 | + $.fn.trigger = function(event, data){ |
| 666 | + if (typeof event == 'string') event = $.Event(event); |
| 667 | + fix(event); |
| 668 | + event.data = data; |
| 669 | + return this.each(function(){ this.dispatchEvent(event) }); |
| 670 | + }; |
| 671 | + |
| 672 | + // triggers event handlers on current element just as if an event occurred, |
| 673 | + // doesn't trigger an actual event, doesn't bubble |
| 674 | + $.fn.triggerHandler = function(event, data){ |
| 675 | + var e, result; |
| 676 | + this.each(function(i, element){ |
| 677 | + e = createProxy(typeof event == 'string' ? $.Event(event) : event); |
| 678 | + e.data = data; e.target = element; |
| 679 | + $.each(findHandlers(element, event.type || event), function(i, handler){ |
| 680 | + result = handler.proxy(e); |
| 681 | + if (e.isImmediatePropagationStopped()) return false; |
| 682 | + }); |
| 683 | + }); |
| 684 | + return result; |
| 685 | + }; |
| 686 | + |
| 687 | + // shortcut methods for `.bind(event, fn)` for each event type |
| 688 | + ('focusin focusout load resize scroll unload click dblclick '+ |
| 689 | + 'mousedown mouseup mousemove mouseover mouseout '+ |
| 690 | + 'change select keydown keypress keyup error').split(' ').forEach(function(event) { |
| 691 | + $.fn[event] = function(callback){ return this.bind(event, callback) }; |
| 692 | + }); |
| 693 | + |
| 694 | + ['focus', 'blur'].forEach(function(name) { |
| 695 | + $.fn[name] = function(callback) { |
| 696 | + if (callback) this.bind(name, callback); |
| 697 | + else if (this.length) try { this.get(0)[name]() } catch(e){}; |
| 698 | + return this; |
| 699 | + }; |
| 700 | + }); |
| 701 | + |
| 702 | + $.Event = function(type, props) { |
| 703 | + var event = document.createEvent(specialEvents[type] || 'Events'), bubbles = true; |
| 704 | + if (props) for (var name in props) (name == 'bubbles') ? (bubbles = !!props[name]) : (event[name] = props[name]); |
| 705 | + event.initEvent(type, bubbles, true, null, null, null, null, null, null, null, null, null, null, null, null); |
| 706 | + return event; |
| 707 | + }; |
| 708 | + |
| 709 | +})(Zepto); |
| 710 | +// Zepto.js |
| 711 | +// (c) 2010-2012 Thomas Fuchs |
| 712 | +// Zepto.js may be freely distributed under the MIT license. |
| 713 | + |
| 714 | +(function($){ |
| 715 | + function detect(ua){ |
| 716 | + var os = (this.os = {}), browser = (this.browser = {}), |
| 717 | + webkit = ua.match(/WebKit\/([\d.]+)/), |
| 718 | + android = ua.match(/(Android)\s+([\d.]+)/), |
| 719 | + ipad = ua.match(/(iPad).*OS\s([\d_]+)/), |
| 720 | + iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/), |
| 721 | + webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/), |
| 722 | + touchpad = webos && ua.match(/TouchPad/), |
| 723 | + blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/); |
| 724 | + |
| 725 | + if (webkit) browser.version = webkit[1]; |
| 726 | + browser.webkit = !!webkit; |
| 727 | + |
| 728 | + if (android) os.android = true, os.version = android[2]; |
| 729 | + if (iphone) os.ios = true, os.version = iphone[2].replace(/_/g, '.'), os.iphone = true; |
| 730 | + if (ipad) os.ios = true, os.version = ipad[2].replace(/_/g, '.'), os.ipad = true; |
| 731 | + if (webos) os.webos = true, os.version = webos[2]; |
| 732 | + if (touchpad) os.touchpad = true; |
| 733 | + if (blackberry) os.blackberry = true, os.version = blackberry[2]; |
| 734 | + } |
| 735 | + |
| 736 | + // ### $.os |
| 737 | + // |
| 738 | + // Object containing information about browser platform |
| 739 | + // |
| 740 | + // *Example:* |
| 741 | + // |
| 742 | + // $.os.ios // => true if running on Apple iOS |
| 743 | + // $.os.android // => true if running on Android |
| 744 | + // $.os.webos // => true if running on HP/Palm WebOS |
| 745 | + // $.os.touchpad // => true if running on a HP TouchPad |
| 746 | + // $.os.version // => string with a version number, e.g. |
| 747 | + // "4.0", "3.1.1", "2.1", etc. |
| 748 | + // $.os.iphone // => true if running on iPhone |
| 749 | + // $.os.ipad // => true if running on iPad |
| 750 | + // $.os.blackberry // => true if running on BlackBerry |
| 751 | + // |
| 752 | + // ### $.browser |
| 753 | + // |
| 754 | + // *Example:* |
| 755 | + // |
| 756 | + // $.browser.webkit // => true if the browser is WebKit-based |
| 757 | + // $.browser.version // => WebKit version string |
| 758 | + detect.call($, navigator.userAgent); |
| 759 | + |
| 760 | + // make available to unit tests |
| 761 | + $.__detect = detect; |
| 762 | + |
| 763 | +})(Zepto); |
| 764 | +// Zepto.js |
| 765 | +// (c) 2010-2012 Thomas Fuchs |
| 766 | +// Zepto.js may be freely distributed under the MIT license. |
| 767 | + |
| 768 | +(function($, undefined){ |
| 769 | + var prefix = '', eventPrefix, endEventName, endAnimationName, |
| 770 | + vendors = {Webkit: 'webkit', Moz: '', O: 'o', ms: 'MS'}, |
| 771 | + document = window.document, testEl = document.createElement('div'), |
| 772 | + supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i; |
| 773 | + |
| 774 | + function downcase(str) { return str.toLowerCase() } |
| 775 | + function normalizeEvent(name) { return eventPrefix ? eventPrefix + name : downcase(name) }; |
| 776 | + |
| 777 | + $.each(vendors, function(vendor, event){ |
| 778 | + if (testEl.style[vendor + 'TransitionProperty'] !== undefined) { |
| 779 | + prefix = '-' + downcase(vendor) + '-'; |
| 780 | + eventPrefix = event; |
| 781 | + return false; |
| 782 | + } |
| 783 | + }); |
| 784 | + |
| 785 | + $.fx = { |
| 786 | + off: (eventPrefix === undefined && testEl.style.transitionProperty === undefined), |
| 787 | + cssPrefix: prefix, |
| 788 | + transitionEnd: normalizeEvent('TransitionEnd'), |
| 789 | + animationEnd: normalizeEvent('AnimationEnd') |
| 790 | + }; |
| 791 | + |
| 792 | + $.fn.animate = function(properties, duration, ease, callback){ |
| 793 | + if ($.isObject(duration)) |
| 794 | + ease = duration.easing, callback = duration.complete, duration = duration.duration; |
| 795 | + if (duration) duration = duration / 1000; |
| 796 | + return this.anim(properties, duration, ease, callback); |
| 797 | + }; |
| 798 | + |
| 799 | + $.fn.anim = function(properties, duration, ease, callback){ |
| 800 | + var transforms, cssProperties = {}, key, that = this, wrappedCallback, endEvent = $.fx.transitionEnd; |
| 801 | + if (duration === undefined) duration = 0.4; |
| 802 | + if ($.fx.off) duration = 0; |
| 803 | + |
| 804 | + if (typeof properties == 'string') { |
| 805 | + // keyframe animation |
| 806 | + cssProperties[prefix + 'animation-name'] = properties; |
| 807 | + cssProperties[prefix + 'animation-duration'] = duration + 's'; |
| 808 | + endEvent = $.fx.animationEnd; |
| 809 | + } else { |
| 810 | + // CSS transitions |
| 811 | + for (key in properties) |
| 812 | + if (supportedTransforms.test(key)) { |
| 813 | + transforms || (transforms = []); |
| 814 | + transforms.push(key + '(' + properties[key] + ')'); |
| 815 | + } |
| 816 | + else cssProperties[key] = properties[key]; |
| 817 | + |
| 818 | + if (transforms) cssProperties[prefix + 'transform'] = transforms.join(' '); |
| 819 | + if (!$.fx.off) cssProperties[prefix + 'transition'] = 'all ' + duration + 's ' + (ease || ''); |
| 820 | + } |
| 821 | + |
| 822 | + wrappedCallback = function(){ |
| 823 | + var props = {}; |
| 824 | + props[prefix + 'transition'] = props[prefix + 'animation-name'] = 'none'; |
| 825 | + $(this).css(props); |
| 826 | + callback && callback.call(this); |
| 827 | + } |
| 828 | + if (duration > 0) this.one(endEvent, wrappedCallback); |
| 829 | + |
| 830 | + setTimeout(function() { |
| 831 | + that.css(cssProperties); |
| 832 | + if (duration <= 0) setTimeout(function() { |
| 833 | + that.each(function(){ wrappedCallback.call(this) }); |
| 834 | + }, 0); |
| 835 | + }, 0); |
| 836 | + |
| 837 | + return this; |
| 838 | + }; |
| 839 | + |
| 840 | + testEl = null; |
| 841 | +})(Zepto); |
| 842 | +// Zepto.js |
| 843 | +// (c) 2010-2012 Thomas Fuchs |
| 844 | +// Zepto.js may be freely distributed under the MIT license. |
| 845 | + |
| 846 | +(function($){ |
| 847 | + var jsonpID = 0, |
| 848 | + isObject = $.isObject, |
| 849 | + document = window.document, |
| 850 | + key, |
| 851 | + name; |
| 852 | + |
| 853 | + // trigger a custom event and return false if it was cancelled |
| 854 | + function triggerAndReturn(context, eventName, data) { |
| 855 | + var event = $.Event(eventName); |
| 856 | + $(context).trigger(event, data); |
| 857 | + return !event.defaultPrevented; |
| 858 | + } |
| 859 | + |
| 860 | + // trigger an Ajax "global" event |
| 861 | + function triggerGlobal(settings, context, eventName, data) { |
| 862 | + if (settings.global) return triggerAndReturn(context || document, eventName, data); |
| 863 | + } |
| 864 | + |
| 865 | + // Number of active Ajax requests |
| 866 | + $.active = 0; |
| 867 | + |
| 868 | + function ajaxStart(settings) { |
| 869 | + if (settings.global && $.active++ === 0) triggerGlobal(settings, null, 'ajaxStart'); |
| 870 | + } |
| 871 | + function ajaxStop(settings) { |
| 872 | + if (settings.global && !(--$.active)) triggerGlobal(settings, null, 'ajaxStop'); |
| 873 | + } |
| 874 | + |
| 875 | + // triggers an extra global event "ajaxBeforeSend" that's like "ajaxSend" but cancelable |
| 876 | + function ajaxBeforeSend(xhr, settings) { |
| 877 | + var context = settings.context; |
| 878 | + if (settings.beforeSend.call(context, xhr, settings) === false || |
| 879 | + triggerGlobal(settings, context, 'ajaxBeforeSend', [xhr, settings]) === false) |
| 880 | + return false; |
| 881 | + |
| 882 | + triggerGlobal(settings, context, 'ajaxSend', [xhr, settings]); |
| 883 | + } |
| 884 | + function ajaxSuccess(data, xhr, settings) { |
| 885 | + var context = settings.context, status = 'success'; |
| 886 | + settings.success.call(context, data, status, xhr); |
| 887 | + triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data]); |
| 888 | + ajaxComplete(status, xhr, settings); |
| 889 | + } |
| 890 | + // type: "timeout", "error", "abort", "parsererror" |
| 891 | + function ajaxError(error, type, xhr, settings) { |
| 892 | + var context = settings.context; |
| 893 | + settings.error.call(context, xhr, type, error); |
| 894 | + triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error]); |
| 895 | + ajaxComplete(type, xhr, settings); |
| 896 | + } |
| 897 | + // status: "success", "notmodified", "error", "timeout", "abort", "parsererror" |
| 898 | + function ajaxComplete(status, xhr, settings) { |
| 899 | + var context = settings.context; |
| 900 | + settings.complete.call(context, xhr, status); |
| 901 | + triggerGlobal(settings, context, 'ajaxComplete', [xhr, settings]); |
| 902 | + ajaxStop(settings); |
| 903 | + } |
| 904 | + |
| 905 | + // Empty function, used as default callback |
| 906 | + function empty() {} |
| 907 | + |
| 908 | + // ### $.ajaxJSONP |
| 909 | + // |
| 910 | + // Load JSON from a server in a different domain (JSONP) |
| 911 | + // |
| 912 | + // *Arguments:* |
| 913 | + // |
| 914 | + // options — object that configure the request, |
| 915 | + // see avaliable options below |
| 916 | + // |
| 917 | + // *Avaliable options:* |
| 918 | + // |
| 919 | + // url — url to which the request is sent |
| 920 | + // success — callback that is executed if the request succeeds |
| 921 | + // error — callback that is executed if the server drops error |
| 922 | + // context — in which context to execute the callbacks in |
| 923 | + // |
| 924 | + // *Example:* |
| 925 | + // |
| 926 | + // $.ajaxJSONP({ |
| 927 | + // url: 'http://example.com/projects?callback=?', |
| 928 | + // success: function (data) { |
| 929 | + // projects.push(json); |
| 930 | + // } |
| 931 | + // }); |
| 932 | + // |
| 933 | + $.ajaxJSONP = function(options){ |
| 934 | + var callbackName = 'jsonp' + (++jsonpID), |
| 935 | + script = document.createElement('script'), |
| 936 | + abort = function(){ |
| 937 | + $(script).remove(); |
| 938 | + if (callbackName in window) window[callbackName] = empty; |
| 939 | + ajaxComplete('abort', xhr, options); |
| 940 | + }, |
| 941 | + xhr = { abort: abort }, abortTimeout; |
| 942 | + |
| 943 | + window[callbackName] = function(data){ |
| 944 | + clearTimeout(abortTimeout); |
| 945 | + $(script).remove(); |
| 946 | + delete window[callbackName]; |
| 947 | + ajaxSuccess(data, xhr, options); |
| 948 | + }; |
| 949 | + |
| 950 | + script.src = options.url.replace(/=\?/, '=' + callbackName); |
| 951 | + $('head').append(script); |
| 952 | + |
| 953 | + if (options.timeout > 0) abortTimeout = setTimeout(function(){ |
| 954 | + xhr.abort(); |
| 955 | + ajaxComplete('timeout', xhr, options); |
| 956 | + }, options.timeout); |
| 957 | + |
| 958 | + return xhr; |
| 959 | + }; |
| 960 | + |
| 961 | + // ### $.ajaxSettings |
| 962 | + // |
| 963 | + // AJAX settings |
| 964 | + // |
| 965 | + $.ajaxSettings = { |
| 966 | + // Default type of request |
| 967 | + type: 'GET', |
| 968 | + // Callback that is executed before request |
| 969 | + beforeSend: empty, |
| 970 | + // Callback that is executed if the request succeeds |
| 971 | + success: empty, |
| 972 | + // Callback that is executed the the server drops error |
| 973 | + error: empty, |
| 974 | + // Callback that is executed on request complete (both: error and success) |
| 975 | + complete: empty, |
| 976 | + // The context for the callbacks |
| 977 | + context: null, |
| 978 | + // Whether to trigger "global" Ajax events |
| 979 | + global: true, |
| 980 | + // Transport |
| 981 | + xhr: function () { |
| 982 | + return new window.XMLHttpRequest(); |
| 983 | + }, |
| 984 | + // MIME types mapping |
| 985 | + accepts: { |
| 986 | + script: 'text/javascript, application/javascript', |
| 987 | + json: 'application/json', |
| 988 | + xml: 'application/xml, text/xml', |
| 989 | + html: 'text/html', |
| 990 | + text: 'text/plain' |
| 991 | + }, |
| 992 | + // Whether the request is to another domain |
| 993 | + crossDomain: false, |
| 994 | + // Default timeout |
| 995 | + timeout: 0 |
| 996 | + }; |
| 997 | + |
| 998 | + // ### $.ajax |
| 999 | + // |
| 1000 | + // Perform AJAX request |
| 1001 | + // |
| 1002 | + // *Arguments:* |
| 1003 | + // |
| 1004 | + // options — object that configure the request, |
| 1005 | + // see avaliable options below |
| 1006 | + // |
| 1007 | + // *Avaliable options:* |
| 1008 | + // |
| 1009 | + // type ('GET') — type of request GET / POST |
| 1010 | + // url (window.location) — url to which the request is sent |
| 1011 | + // data — data to send to server, |
| 1012 | + // can be string or object |
| 1013 | + // dataType ('json') — what response type you accept from |
| 1014 | + // the server: |
| 1015 | + // 'json', 'xml', 'html', or 'text' |
| 1016 | + // timeout (0) — request timeout |
| 1017 | + // beforeSend — callback that is executed before |
| 1018 | + // request send |
| 1019 | + // complete — callback that is executed on request |
| 1020 | + // complete (both: error and success) |
| 1021 | + // success — callback that is executed if |
| 1022 | + // the request succeeds |
| 1023 | + // error — callback that is executed if |
| 1024 | + // the server drops error |
| 1025 | + // context — in which context to execute the |
| 1026 | + // callbacks in |
| 1027 | + // |
| 1028 | + // *Example:* |
| 1029 | + // |
| 1030 | + // $.ajax({ |
| 1031 | + // type: 'POST', |
| 1032 | + // url: '/projects', |
| 1033 | + // data: { name: 'Zepto.js' }, |
| 1034 | + // dataType: 'html', |
| 1035 | + // timeout: 100, |
| 1036 | + // context: $('body'), |
| 1037 | + // success: function (data) { |
| 1038 | + // this.append(data); |
| 1039 | + // }, |
| 1040 | + // error: function (xhr, type) { |
| 1041 | + // alert('Error!'); |
| 1042 | + // } |
| 1043 | + // }); |
| 1044 | + // |
| 1045 | + $.ajax = function(options){ |
| 1046 | + var settings = $.extend({}, options || {}); |
| 1047 | + for (key in $.ajaxSettings) if (settings[key] === undefined) settings[key] = $.ajaxSettings[key]; |
| 1048 | + |
| 1049 | + ajaxStart(settings); |
| 1050 | + |
| 1051 | + if (!settings.crossDomain) settings.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(settings.url) && |
| 1052 | + RegExp.$2 != window.location.host; |
| 1053 | + |
| 1054 | + if (/=\?/.test(settings.url)) return $.ajaxJSONP(settings); |
| 1055 | + |
| 1056 | + if (!settings.url) settings.url = window.location.toString(); |
| 1057 | + if (settings.data && !settings.contentType) settings.contentType = 'application/x-www-form-urlencoded'; |
| 1058 | + if (isObject(settings.data)) settings.data = $.param(settings.data); |
| 1059 | + |
| 1060 | + if (settings.type.match(/get/i) && settings.data) { |
| 1061 | + var queryString = settings.data; |
| 1062 | + if (settings.url.match(/\?.*=/)) { |
| 1063 | + queryString = '&' + queryString; |
| 1064 | + } else if (queryString[0] != '?') { |
| 1065 | + queryString = '?' + queryString; |
| 1066 | + } |
| 1067 | + settings.url += queryString; |
| 1068 | + } |
| 1069 | + |
| 1070 | + var mime = settings.accepts[settings.dataType], |
| 1071 | + baseHeaders = { }, |
| 1072 | + protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol, |
| 1073 | + xhr = $.ajaxSettings.xhr(), abortTimeout; |
| 1074 | + |
| 1075 | + if (!settings.crossDomain) baseHeaders['X-Requested-With'] = 'XMLHttpRequest'; |
| 1076 | + if (mime) baseHeaders['Accept'] = mime; |
| 1077 | + settings.headers = $.extend(baseHeaders, settings.headers || {}); |
| 1078 | + |
| 1079 | + xhr.onreadystatechange = function(){ |
| 1080 | + if (xhr.readyState == 4) { |
| 1081 | + clearTimeout(abortTimeout); |
| 1082 | + var result, error = false; |
| 1083 | + if ((xhr.status >= 200 && xhr.status < 300) || (xhr.status == 0 && protocol == 'file:')) { |
| 1084 | + if (mime == 'application/json' && !(/^\s*$/.test(xhr.responseText))) { |
| 1085 | + try { result = JSON.parse(xhr.responseText); } |
| 1086 | + catch (e) { error = e; } |
| 1087 | + } |
| 1088 | + else result = xhr.responseText; |
| 1089 | + if (error) ajaxError(error, 'parsererror', xhr, settings); |
| 1090 | + else ajaxSuccess(result, xhr, settings); |
| 1091 | + } else { |
| 1092 | + ajaxError(null, 'error', xhr, settings); |
| 1093 | + } |
| 1094 | + } |
| 1095 | + }; |
| 1096 | + |
| 1097 | + var async = 'async' in settings ? settings.async : true; |
| 1098 | + xhr.open(settings.type, settings.url, async); |
| 1099 | + |
| 1100 | + if (settings.contentType) settings.headers['Content-Type'] = settings.contentType; |
| 1101 | + for (name in settings.headers) xhr.setRequestHeader(name, settings.headers[name]); |
| 1102 | + |
| 1103 | + if (ajaxBeforeSend(xhr, settings) === false) { |
| 1104 | + xhr.abort(); |
| 1105 | + return false; |
| 1106 | + } |
| 1107 | + |
| 1108 | + if (settings.timeout > 0) abortTimeout = setTimeout(function(){ |
| 1109 | + xhr.onreadystatechange = empty; |
| 1110 | + xhr.abort(); |
| 1111 | + ajaxError(null, 'timeout', xhr, settings); |
| 1112 | + }, settings.timeout); |
| 1113 | + |
| 1114 | + xhr.send(settings.data); |
| 1115 | + return xhr; |
| 1116 | + }; |
| 1117 | + |
| 1118 | + // ### $.get |
| 1119 | + // |
| 1120 | + // Load data from the server using a GET request |
| 1121 | + // |
| 1122 | + // *Arguments:* |
| 1123 | + // |
| 1124 | + // url — url to which the request is sent |
| 1125 | + // success — callback that is executed if the request succeeds |
| 1126 | + // |
| 1127 | + // *Example:* |
| 1128 | + // |
| 1129 | + // $.get( |
| 1130 | + // '/projects/42', |
| 1131 | + // function (data) { |
| 1132 | + // $('body').append(data); |
| 1133 | + // } |
| 1134 | + // ); |
| 1135 | + // |
| 1136 | + $.get = function(url, success){ return $.ajax({ url: url, success: success }) }; |
| 1137 | + |
| 1138 | + // ### $.post |
| 1139 | + // |
| 1140 | + // Load data from the server using POST request |
| 1141 | + // |
| 1142 | + // *Arguments:* |
| 1143 | + // |
| 1144 | + // url — url to which the request is sent |
| 1145 | + // [data] — data to send to server, can be string or object |
| 1146 | + // [success] — callback that is executed if the request succeeds |
| 1147 | + // [dataType] — type of expected response |
| 1148 | + // 'json', 'xml', 'html', or 'text' |
| 1149 | + // |
| 1150 | + // *Example:* |
| 1151 | + // |
| 1152 | + // $.post( |
| 1153 | + // '/projects', |
| 1154 | + // { name: 'Zepto.js' }, |
| 1155 | + // function (data) { |
| 1156 | + // $('body').append(data); |
| 1157 | + // }, |
| 1158 | + // 'html' |
| 1159 | + // ); |
| 1160 | + // |
| 1161 | + $.post = function(url, data, success, dataType){ |
| 1162 | + if ($.isFunction(data)) dataType = dataType || success, success = data, data = null; |
| 1163 | + return $.ajax({ type: 'POST', url: url, data: data, success: success, dataType: dataType }); |
| 1164 | + }; |
| 1165 | + |
| 1166 | + // ### $.getJSON |
| 1167 | + // |
| 1168 | + // Load JSON from the server using GET request |
| 1169 | + // |
| 1170 | + // *Arguments:* |
| 1171 | + // |
| 1172 | + // url — url to which the request is sent |
| 1173 | + // success — callback that is executed if the request succeeds |
| 1174 | + // |
| 1175 | + // *Example:* |
| 1176 | + // |
| 1177 | + // $.getJSON( |
| 1178 | + // '/projects/42', |
| 1179 | + // function (json) { |
| 1180 | + // projects.push(json); |
| 1181 | + // } |
| 1182 | + // ); |
| 1183 | + // |
| 1184 | + $.getJSON = function(url, success){ |
| 1185 | + return $.ajax({ url: url, success: success, dataType: 'json' }); |
| 1186 | + }; |
| 1187 | + |
| 1188 | + // ### $.fn.load |
| 1189 | + // |
| 1190 | + // Load data from the server into an element |
| 1191 | + // |
| 1192 | + // *Arguments:* |
| 1193 | + // |
| 1194 | + // url — url to which the request is sent |
| 1195 | + // [success] — callback that is executed if the request succeeds |
| 1196 | + // |
| 1197 | + // *Examples:* |
| 1198 | + // |
| 1199 | + // $('#project_container').get( |
| 1200 | + // '/projects/42', |
| 1201 | + // function () { |
| 1202 | + // alert('Project was successfully loaded'); |
| 1203 | + // } |
| 1204 | + // ); |
| 1205 | + // |
| 1206 | + // $('#project_comments').get( |
| 1207 | + // '/projects/42 #comments', |
| 1208 | + // function () { |
| 1209 | + // alert('Comments was successfully loaded'); |
| 1210 | + // } |
| 1211 | + // ); |
| 1212 | + // |
| 1213 | + $.fn.load = function(url, success){ |
| 1214 | + if (!this.length) return this; |
| 1215 | + var self = this, parts = url.split(/\s/), selector; |
| 1216 | + if (parts.length > 1) url = parts[0], selector = parts[1]; |
| 1217 | + $.get(url, function(response){ |
| 1218 | + self.html(selector ? |
| 1219 | + $(document.createElement('div')).html(response).find(selector).html() |
| 1220 | + : response); |
| 1221 | + success && success.call(self); |
| 1222 | + }); |
| 1223 | + return this; |
| 1224 | + }; |
| 1225 | + |
| 1226 | + var escape = encodeURIComponent; |
| 1227 | + |
| 1228 | + function serialize(params, obj, traditional, scope){ |
| 1229 | + var array = $.isArray(obj); |
| 1230 | + $.each(obj, function(key, value) { |
| 1231 | + if (scope) key = traditional ? scope : scope + '[' + (array ? '' : key) + ']'; |
| 1232 | + // handle data in serializeArray() format |
| 1233 | + if (!scope && array) params.add(value.name, value.value); |
| 1234 | + // recurse into nested objects |
| 1235 | + else if (traditional ? $.isArray(value) : isObject(value)) |
| 1236 | + serialize(params, value, traditional, key); |
| 1237 | + else params.add(key, value); |
| 1238 | + }); |
| 1239 | + } |
| 1240 | + |
| 1241 | + // ### $.param |
| 1242 | + // |
| 1243 | + // Encode object as a string of URL-encoded key-value pairs |
| 1244 | + // |
| 1245 | + // *Arguments:* |
| 1246 | + // |
| 1247 | + // obj — object to serialize |
| 1248 | + // [traditional] — perform shallow serialization |
| 1249 | + // |
| 1250 | + // *Example:* |
| 1251 | + // |
| 1252 | + // $.param( { name: 'Zepto.js', version: '0.6' } ); |
| 1253 | + // |
| 1254 | + $.param = function(obj, traditional){ |
| 1255 | + var params = []; |
| 1256 | + params.add = function(k, v){ this.push(escape(k) + '=' + escape(v)) }; |
| 1257 | + serialize(params, obj, traditional); |
| 1258 | + return params.join('&').replace('%20', '+'); |
| 1259 | + }; |
| 1260 | +})(Zepto); |
| 1261 | +// Zepto.js |
| 1262 | +// (c) 2010-2012 Thomas Fuchs |
| 1263 | +// Zepto.js may be freely distributed under the MIT license. |
| 1264 | + |
| 1265 | +(function ($) { |
| 1266 | + |
| 1267 | + // ### $.fn.serializeArray |
| 1268 | + // |
| 1269 | + // Encode a set of form elements as an array of names and values |
| 1270 | + // |
| 1271 | + // *Example:* |
| 1272 | + // |
| 1273 | + // $('#login_form').serializeArray(); |
| 1274 | + // |
| 1275 | + // returns |
| 1276 | + // |
| 1277 | + // [ |
| 1278 | + // { |
| 1279 | + // name: 'email', |
| 1280 | + // value: 'koss@nocorp.me' |
| 1281 | + // }, |
| 1282 | + // { |
| 1283 | + // name: 'password', |
| 1284 | + // value: '123456' |
| 1285 | + // } |
| 1286 | + // ] |
| 1287 | + // |
| 1288 | + $.fn.serializeArray = function () { |
| 1289 | + var result = [], el; |
| 1290 | + $( Array.prototype.slice.call(this.get(0).elements) ).each(function () { |
| 1291 | + el = $(this); |
| 1292 | + var type = el.attr('type'); |
| 1293 | + if ( |
| 1294 | + this.nodeName.toLowerCase() != 'fieldset' && |
| 1295 | + !this.disabled && type != 'submit' && type != 'reset' && type != 'button' && |
| 1296 | + ((type != 'radio' && type != 'checkbox') || this.checked) |
| 1297 | + ) { |
| 1298 | + result.push({ |
| 1299 | + name: el.attr('name'), |
| 1300 | + value: el.val() |
| 1301 | + }); |
| 1302 | + } |
| 1303 | + }); |
| 1304 | + return result; |
| 1305 | + }; |
| 1306 | + |
| 1307 | + // ### $.fn.serialize |
| 1308 | + // |
| 1309 | + // |
| 1310 | + // Encode a set of form elements as a string for submission |
| 1311 | + // |
| 1312 | + // *Example:* |
| 1313 | + // |
| 1314 | + // $('#login_form').serialize(); |
| 1315 | + // |
| 1316 | + // returns |
| 1317 | + // |
| 1318 | + // "email=koss%40nocorp.me&password=123456" |
| 1319 | + // |
| 1320 | + $.fn.serialize = function () { |
| 1321 | + var result = []; |
| 1322 | + this.serializeArray().forEach(function (elm) { |
| 1323 | + result.push( encodeURIComponent(elm.name) + '=' + encodeURIComponent(elm.value) ); |
| 1324 | + }); |
| 1325 | + return result.join('&'); |
| 1326 | + }; |
| 1327 | + |
| 1328 | + // ### $.fn.submit |
| 1329 | + // |
| 1330 | + // Bind or trigger the submit event for a form |
| 1331 | + // |
| 1332 | + // *Examples:* |
| 1333 | + // |
| 1334 | + // To bind a handler for the submit event: |
| 1335 | + // |
| 1336 | + // $('#login_form').submit(function (e) { |
| 1337 | + // alert('Form was submitted!'); |
| 1338 | + // e.preventDefault(); |
| 1339 | + // }); |
| 1340 | + // |
| 1341 | + // To trigger form submit: |
| 1342 | + // |
| 1343 | + // $('#login_form').submit(); |
| 1344 | + // |
| 1345 | + $.fn.submit = function (callback) { |
| 1346 | + if (callback) this.bind('submit', callback) |
| 1347 | + else if (this.length) { |
| 1348 | + var event = $.Event('submit'); |
| 1349 | + this.eq(0).trigger(event); |
| 1350 | + if (!event.defaultPrevented) this.get(0).submit() |
| 1351 | + } |
| 1352 | + return this; |
| 1353 | + } |
| 1354 | + |
| 1355 | +})(Zepto); |
| 1356 | +// Zepto.js |
| 1357 | +// (c) 2010-2012 Thomas Fuchs |
| 1358 | +// Zepto.js may be freely distributed under the MIT license. |
| 1359 | + |
| 1360 | +(function($){ |
| 1361 | + var touch = {}, touchTimeout; |
| 1362 | + |
| 1363 | + function parentIfText(node){ |
| 1364 | + return 'tagName' in node ? node : node.parentNode; |
| 1365 | + } |
| 1366 | + |
| 1367 | + function swipeDirection(x1, x2, y1, y2){ |
| 1368 | + var xDelta = Math.abs(x1 - x2), yDelta = Math.abs(y1 - y2); |
| 1369 | + if (xDelta >= yDelta) { |
| 1370 | + return (x1 - x2 > 0 ? 'Left' : 'Right'); |
| 1371 | + } else { |
| 1372 | + return (y1 - y2 > 0 ? 'Up' : 'Down'); |
| 1373 | + } |
| 1374 | + } |
| 1375 | + |
| 1376 | + var longTapDelay = 750; |
| 1377 | + function longTap(){ |
| 1378 | + if (touch.last && (Date.now() - touch.last >= longTapDelay)) { |
| 1379 | + touch.el.trigger('longTap'); |
| 1380 | + touch = {}; |
| 1381 | + } |
| 1382 | + } |
| 1383 | + |
| 1384 | + $(document).ready(function(){ |
| 1385 | + $(document.body).bind('touchstart', function(e){ |
| 1386 | + var now = Date.now(), delta = now - (touch.last || now); |
| 1387 | + touch.el = $(parentIfText(e.touches[0].target)); |
| 1388 | + touchTimeout && clearTimeout(touchTimeout); |
| 1389 | + touch.x1 = e.touches[0].pageX; |
| 1390 | + touch.y1 = e.touches[0].pageY; |
| 1391 | + if (delta > 0 && delta <= 250) touch.isDoubleTap = true; |
| 1392 | + touch.last = now; |
| 1393 | + setTimeout(longTap, longTapDelay); |
| 1394 | + }).bind('touchmove', function(e){ |
| 1395 | + touch.x2 = e.touches[0].pageX; |
| 1396 | + touch.y2 = e.touches[0].pageY; |
| 1397 | + }).bind('touchend', function(e){ |
| 1398 | + if (touch.isDoubleTap) { |
| 1399 | + touch.el.trigger('doubleTap'); |
| 1400 | + touch = {}; |
| 1401 | + } else if (touch.x2 > 0 || touch.y2 > 0) { |
| 1402 | + (Math.abs(touch.x1 - touch.x2) > 30 || Math.abs(touch.y1 - touch.y2) > 30) && |
| 1403 | + touch.el.trigger('swipe') && |
| 1404 | + touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2))); |
| 1405 | + touch.x1 = touch.x2 = touch.y1 = touch.y2 = touch.last = 0; |
| 1406 | + } else if ('last' in touch) { |
| 1407 | + touch.el.trigger('tap'); |
| 1408 | + |
| 1409 | + touchTimeout = setTimeout(function(){ |
| 1410 | + touchTimeout = null; |
| 1411 | + touch.el.trigger('singleTap'); |
| 1412 | + touch = {}; |
| 1413 | + }, 250); |
| 1414 | + } |
| 1415 | + }).bind('touchcancel', function(){ touch = {} }); |
| 1416 | + }); |
| 1417 | + |
| 1418 | + ['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(m){ |
| 1419 | + $.fn[m] = function(callback){ return this.bind(m, callback) } |
| 1420 | + }); |
| 1421 | +})(Zepto); |
\ No newline at end of file |
Property changes on: trunk/extensions/MobileFrontend2/modules/zepto/zepto.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 1422 | + native |