├── .c9settings.xml ├── .nfs6FF14 ├── .project ├── Examples ├── img1.jpg ├── img2.jpg ├── index.html ├── mootools-core-1.3-full-nocompat.js ├── mootools-more-1.3.2.1.js ├── test.html ├── test1.html ├── test2.html └── test3.html ├── README.md ├── Source ├── .nfs9FF14 └── Fx.CSS3.js ├── license ├── package.yml └── screen.png /.c9settings.xml: -------------------------------------------------------------------------------- 1 | {"ext/editors/editors":{"parent":{"visible":2,"flex":1},"visible":2,"flex":1},"ext/tree/tree":{"parent":{"visible":2,"width":"200"},"visible":true,"flex":3,"state":"normal"},"ext/console/console":{"parent":{"visible":2,"height":200},"visible":true,"flex":1}}["folder[1]","folder[1]/folder[2]","folder[1]/folder[2]/file[2]","folder[1]/folder[1]","folder[1]/folder[1]/file[3]","folder[1]/folder[2]/file[1]"] -------------------------------------------------------------------------------- /.nfs6FF14: -------------------------------------------------------------------------------- 1 | {"ext/editors/editors":{"parent":{"visible":2,"flex":1},"visible":2,"flex":1},"ext/tree/tree":{"parent":{"visible":2,"width":"200"},"visible":true,"flex":3,"state":"normal"},"ext/console/console":{"parent":{"visible":2,"height":"41"},"visible":false,"flex":1}} -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Mootools - Fx.Tween.CSS3 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Examples/img1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunboX/mootools-fx-tween-css3/87ff7a71b512ebeb78de4dd46744a18de9720add/Examples/img1.jpg -------------------------------------------------------------------------------- /Examples/img2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunboX/mootools-fx-tween-css3/87ff7a71b512ebeb78de4dd46744a18de9720add/Examples/img2.jpg -------------------------------------------------------------------------------- /Examples/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fx.Tween.CSS3 Demo 6 | 7 | 19 | 20 | 21 | 22 | 23 | 82 | 83 | 84 | 85 |
86 | click here to test tween 87 |
​ 88 |
89 | click here to test morph 90 |
​ 91 |
92 | click here to test elements 93 |
​ 94 |
95 | click here to test elements 96 |
​ 97 | 98 | -------------------------------------------------------------------------------- /Examples/mootools-core-1.3-full-nocompat.js: -------------------------------------------------------------------------------- 1 | /* 2 | --- 3 | MooTools: the javascript framework 4 | 5 | web build: 6 | - http://mootools.net/core/7c56cfef9dddcf170a5d68e3fb61cfd7 7 | 8 | packager build: 9 | - packager build Core/Core Core/Array Core/String Core/Number Core/Function Core/Object Core/Event Core/Browser Core/Class Core/Class.Extras Core/Slick.Parser Core/Slick.Finder Core/Element Core/Element.Style Core/Element.Event Core/Element.Dimensions Core/Fx Core/Fx.CSS Core/Fx.Tween Core/Fx.Morph Core/Fx.Transitions Core/Request Core/Request.HTML Core/Request.JSON Core/Cookie Core/JSON Core/DOMReady Core/Swiff 10 | 11 | /* 12 | --- 13 | 14 | name: Core 15 | 16 | description: The heart of MooTools. 17 | 18 | license: MIT-style license. 19 | 20 | copyright: Copyright (c) 2006-2010 [Valerio Proietti](http://mad4milk.net/). 21 | 22 | authors: The MooTools production team (http://mootools.net/developers/) 23 | 24 | inspiration: 25 | - Class implementation inspired by [Base.js](http://dean.edwards.name/weblog/2006/03/base/) Copyright (c) 2006 Dean Edwards, [GNU Lesser General Public License](http://opensource.org/licenses/lgpl-license.php) 26 | - Some functionality inspired by [Prototype.js](http://prototypejs.org) Copyright (c) 2005-2007 Sam Stephenson, [MIT License](http://opensource.org/licenses/mit-license.php) 27 | 28 | provides: [Core, MooTools, Type, typeOf, instanceOf, Native] 29 | 30 | ... 31 | */ 32 | 33 | (function(){ 34 | 35 | this.MooTools = { 36 | version: '1.3', 37 | build: 'a3eed692dd85050d80168ec2c708efe901bb7db3' 38 | }; 39 | 40 | // typeOf, instanceOf 41 | 42 | var typeOf = this.typeOf = function(item){ 43 | if (item == null) return 'null'; 44 | if (item.$family) return item.$family(); 45 | 46 | if (item.nodeName){ 47 | if (item.nodeType == 1) return 'element'; 48 | if (item.nodeType == 3) return (/\S/).test(item.nodeValue) ? 'textnode' : 'whitespace'; 49 | } else if (typeof item.length == 'number'){ 50 | if (item.callee) return 'arguments'; 51 | if ('item' in item) return 'collection'; 52 | } 53 | 54 | return typeof item; 55 | }; 56 | 57 | var instanceOf = this.instanceOf = function(item, object){ 58 | if (item == null) return false; 59 | var constructor = item.$constructor || item.constructor; 60 | while (constructor){ 61 | if (constructor === object) return true; 62 | constructor = constructor.parent; 63 | } 64 | return item instanceof object; 65 | }; 66 | 67 | // Function overloading 68 | 69 | var Function = this.Function; 70 | 71 | var enumerables = true; 72 | for (var i in {toString: 1}) enumerables = null; 73 | if (enumerables) enumerables = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'constructor']; 74 | 75 | Function.prototype.overloadSetter = function(usePlural){ 76 | var self = this; 77 | return function(a, b){ 78 | if (a == null) return this; 79 | if (usePlural || typeof a != 'string'){ 80 | for (var k in a) self.call(this, k, a[k]); 81 | if (enumerables) for (var i = enumerables.length; i--;){ 82 | k = enumerables[i]; 83 | if (a.hasOwnProperty(k)) self.call(this, k, a[k]); 84 | } 85 | } else { 86 | self.call(this, a, b); 87 | } 88 | return this; 89 | }; 90 | }; 91 | 92 | Function.prototype.overloadGetter = function(usePlural){ 93 | var self = this; 94 | return function(a){ 95 | var args, result; 96 | if (usePlural || typeof a != 'string') args = a; 97 | else if (arguments.length > 1) args = arguments; 98 | if (args){ 99 | result = {}; 100 | for (var i = 0; i < args.length; i++) result[args[i]] = self.call(this, args[i]); 101 | } else { 102 | result = self.call(this, a); 103 | } 104 | return result; 105 | }; 106 | }; 107 | 108 | Function.prototype.extend = function(key, value){ 109 | this[key] = value; 110 | }.overloadSetter(); 111 | 112 | Function.prototype.implement = function(key, value){ 113 | this.prototype[key] = value; 114 | }.overloadSetter(); 115 | 116 | // From 117 | 118 | var slice = Array.prototype.slice; 119 | 120 | Function.from = function(item){ 121 | return (typeOf(item) == 'function') ? item : function(){ 122 | return item; 123 | }; 124 | }; 125 | 126 | Array.from = function(item){ 127 | if (item == null) return []; 128 | return (Type.isEnumerable(item) && typeof item != 'string') ? (typeOf(item) == 'array') ? item : slice.call(item) : [item]; 129 | }; 130 | 131 | Number.from = function(item){ 132 | var number = parseFloat(item); 133 | return isFinite(number) ? number : null; 134 | }; 135 | 136 | String.from = function(item){ 137 | return item + ''; 138 | }; 139 | 140 | // hide, protect 141 | 142 | Function.implement({ 143 | 144 | hide: function(){ 145 | this.$hidden = true; 146 | return this; 147 | }, 148 | 149 | protect: function(){ 150 | this.$protected = true; 151 | return this; 152 | } 153 | 154 | }); 155 | 156 | // Type 157 | 158 | var Type = this.Type = function(name, object){ 159 | if (name){ 160 | var lower = name.toLowerCase(); 161 | var typeCheck = function(item){ 162 | return (typeOf(item) == lower); 163 | }; 164 | 165 | Type['is' + name] = typeCheck; 166 | if (object != null){ 167 | object.prototype.$family = (function(){ 168 | return lower; 169 | }).hide(); 170 | 171 | } 172 | } 173 | 174 | if (object == null) return null; 175 | 176 | object.extend(this); 177 | object.$constructor = Type; 178 | object.prototype.$constructor = object; 179 | 180 | return object; 181 | }; 182 | 183 | var toString = Object.prototype.toString; 184 | 185 | Type.isEnumerable = function(item){ 186 | return (item != null && typeof item.length == 'number' && toString.call(item) != '[object Function]' ); 187 | }; 188 | 189 | var hooks = {}; 190 | 191 | var hooksOf = function(object){ 192 | var type = typeOf(object.prototype); 193 | return hooks[type] || (hooks[type] = []); 194 | }; 195 | 196 | var implement = function(name, method){ 197 | if (method && method.$hidden) return this; 198 | 199 | var hooks = hooksOf(this); 200 | 201 | for (var i = 0; i < hooks.length; i++){ 202 | var hook = hooks[i]; 203 | if (typeOf(hook) == 'type') implement.call(hook, name, method); 204 | else hook.call(this, name, method); 205 | } 206 | 207 | var previous = this.prototype[name]; 208 | if (previous == null || !previous.$protected) this.prototype[name] = method; 209 | 210 | if (this[name] == null && typeOf(method) == 'function') extend.call(this, name, function(item){ 211 | return method.apply(item, slice.call(arguments, 1)); 212 | }); 213 | 214 | return this; 215 | }; 216 | 217 | var extend = function(name, method){ 218 | if (method && method.$hidden) return this; 219 | var previous = this[name]; 220 | if (previous == null || !previous.$protected) this[name] = method; 221 | return this; 222 | }; 223 | 224 | Type.implement({ 225 | 226 | implement: implement.overloadSetter(), 227 | 228 | extend: extend.overloadSetter(), 229 | 230 | alias: function(name, existing){ 231 | implement.call(this, name, this.prototype[existing]); 232 | }.overloadSetter(), 233 | 234 | mirror: function(hook){ 235 | hooksOf(this).push(hook); 236 | return this; 237 | } 238 | 239 | }); 240 | 241 | new Type('Type', Type); 242 | 243 | // Default Types 244 | 245 | var force = function(name, object, methods){ 246 | var isType = (object != Object), 247 | prototype = object.prototype; 248 | 249 | if (isType) object = new Type(name, object); 250 | 251 | for (var i = 0, l = methods.length; i < l; i++){ 252 | var key = methods[i], 253 | generic = object[key], 254 | proto = prototype[key]; 255 | 256 | if (generic) generic.protect(); 257 | 258 | if (isType && proto){ 259 | delete prototype[key]; 260 | prototype[key] = proto.protect(); 261 | } 262 | } 263 | 264 | if (isType) object.implement(prototype); 265 | 266 | return force; 267 | }; 268 | 269 | force('String', String, [ 270 | 'charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', 'match', 'quote', 'replace', 'search', 271 | 'slice', 'split', 'substr', 'substring', 'toLowerCase', 'toUpperCase' 272 | ])('Array', Array, [ 273 | 'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice', 274 | 'indexOf', 'lastIndexOf', 'filter', 'forEach', 'every', 'map', 'some', 'reduce', 'reduceRight' 275 | ])('Number', Number, [ 276 | 'toExponential', 'toFixed', 'toLocaleString', 'toPrecision' 277 | ])('Function', Function, [ 278 | 'apply', 'call', 'bind' 279 | ])('RegExp', RegExp, [ 280 | 'exec', 'test' 281 | ])('Object', Object, [ 282 | 'create', 'defineProperty', 'defineProperties', 'keys', 283 | 'getPrototypeOf', 'getOwnPropertyDescriptor', 'getOwnPropertyNames', 284 | 'preventExtensions', 'isExtensible', 'seal', 'isSealed', 'freeze', 'isFrozen' 285 | ])('Date', Date, ['now']); 286 | 287 | Object.extend = extend.overloadSetter(); 288 | 289 | Date.extend('now', function(){ 290 | return +(new Date); 291 | }); 292 | 293 | new Type('Boolean', Boolean); 294 | 295 | // fixes NaN returning as Number 296 | 297 | Number.prototype.$family = function(){ 298 | return isFinite(this) ? 'number' : 'null'; 299 | }.hide(); 300 | 301 | // Number.random 302 | 303 | Number.extend('random', function(min, max){ 304 | return Math.floor(Math.random() * (max - min + 1) + min); 305 | }); 306 | 307 | // forEach, each 308 | 309 | Object.extend('forEach', function(object, fn, bind){ 310 | for (var key in object){ 311 | if (object.hasOwnProperty(key)) fn.call(bind, object[key], key, object); 312 | } 313 | }); 314 | 315 | Object.each = Object.forEach; 316 | 317 | Array.implement({ 318 | 319 | forEach: function(fn, bind){ 320 | for (var i = 0, l = this.length; i < l; i++){ 321 | if (i in this) fn.call(bind, this[i], i, this); 322 | } 323 | }, 324 | 325 | each: function(fn, bind){ 326 | Array.forEach(this, fn, bind); 327 | return this; 328 | } 329 | 330 | }); 331 | 332 | // Array & Object cloning, Object merging and appending 333 | 334 | var cloneOf = function(item){ 335 | switch (typeOf(item)){ 336 | case 'array': return item.clone(); 337 | case 'object': return Object.clone(item); 338 | default: return item; 339 | } 340 | }; 341 | 342 | Array.implement('clone', function(){ 343 | var i = this.length, clone = new Array(i); 344 | while (i--) clone[i] = cloneOf(this[i]); 345 | return clone; 346 | }); 347 | 348 | var mergeOne = function(source, key, current){ 349 | switch (typeOf(current)){ 350 | case 'object': 351 | if (typeOf(source[key]) == 'object') Object.merge(source[key], current); 352 | else source[key] = Object.clone(current); 353 | break; 354 | case 'array': source[key] = current.clone(); break; 355 | default: source[key] = current; 356 | } 357 | return source; 358 | }; 359 | 360 | Object.extend({ 361 | 362 | merge: function(source, k, v){ 363 | if (typeOf(k) == 'string') return mergeOne(source, k, v); 364 | for (var i = 1, l = arguments.length; i < l; i++){ 365 | var object = arguments[i]; 366 | for (var key in object) mergeOne(source, key, object[key]); 367 | } 368 | return source; 369 | }, 370 | 371 | clone: function(object){ 372 | var clone = {}; 373 | for (var key in object) clone[key] = cloneOf(object[key]); 374 | return clone; 375 | }, 376 | 377 | append: function(original){ 378 | for (var i = 1, l = arguments.length; i < l; i++){ 379 | var extended = arguments[i] || {}; 380 | for (var key in extended) original[key] = extended[key]; 381 | } 382 | return original; 383 | } 384 | 385 | }); 386 | 387 | // Object-less types 388 | 389 | ['Object', 'WhiteSpace', 'TextNode', 'Collection', 'Arguments'].each(function(name){ 390 | new Type(name); 391 | }); 392 | 393 | // Unique ID 394 | 395 | var UID = Date.now(); 396 | 397 | String.extend('uniqueID', function(){ 398 | return (UID++).toString(36); 399 | }); 400 | 401 | 402 | 403 | })(); 404 | 405 | 406 | /* 407 | --- 408 | 409 | name: Array 410 | 411 | description: Contains Array Prototypes like each, contains, and erase. 412 | 413 | license: MIT-style license. 414 | 415 | requires: Type 416 | 417 | provides: Array 418 | 419 | ... 420 | */ 421 | 422 | Array.implement({ 423 | 424 | invoke: function(methodName){ 425 | var args = Array.slice(arguments, 1); 426 | return this.map(function(item){ 427 | return item[methodName].apply(item, args); 428 | }); 429 | }, 430 | 431 | every: function(fn, bind){ 432 | for (var i = 0, l = this.length; i < l; i++){ 433 | if ((i in this) && !fn.call(bind, this[i], i, this)) return false; 434 | } 435 | return true; 436 | }, 437 | 438 | filter: function(fn, bind){ 439 | var results = []; 440 | for (var i = 0, l = this.length; i < l; i++){ 441 | if ((i in this) && fn.call(bind, this[i], i, this)) results.push(this[i]); 442 | } 443 | return results; 444 | }, 445 | 446 | clean: function(){ 447 | return this.filter(function(item){ 448 | return item != null; 449 | }); 450 | }, 451 | 452 | indexOf: function(item, from){ 453 | var len = this.length; 454 | for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++){ 455 | if (this[i] === item) return i; 456 | } 457 | return -1; 458 | }, 459 | 460 | map: function(fn, bind){ 461 | var results = []; 462 | for (var i = 0, l = this.length; i < l; i++){ 463 | if (i in this) results[i] = fn.call(bind, this[i], i, this); 464 | } 465 | return results; 466 | }, 467 | 468 | some: function(fn, bind){ 469 | for (var i = 0, l = this.length; i < l; i++){ 470 | if ((i in this) && fn.call(bind, this[i], i, this)) return true; 471 | } 472 | return false; 473 | }, 474 | 475 | associate: function(keys){ 476 | var obj = {}, length = Math.min(this.length, keys.length); 477 | for (var i = 0; i < length; i++) obj[keys[i]] = this[i]; 478 | return obj; 479 | }, 480 | 481 | link: function(object){ 482 | var result = {}; 483 | for (var i = 0, l = this.length; i < l; i++){ 484 | for (var key in object){ 485 | if (object[key](this[i])){ 486 | result[key] = this[i]; 487 | delete object[key]; 488 | break; 489 | } 490 | } 491 | } 492 | return result; 493 | }, 494 | 495 | contains: function(item, from){ 496 | return this.indexOf(item, from) != -1; 497 | }, 498 | 499 | append: function(array){ 500 | this.push.apply(this, array); 501 | return this; 502 | }, 503 | 504 | getLast: function(){ 505 | return (this.length) ? this[this.length - 1] : null; 506 | }, 507 | 508 | getRandom: function(){ 509 | return (this.length) ? this[Number.random(0, this.length - 1)] : null; 510 | }, 511 | 512 | include: function(item){ 513 | if (!this.contains(item)) this.push(item); 514 | return this; 515 | }, 516 | 517 | combine: function(array){ 518 | for (var i = 0, l = array.length; i < l; i++) this.include(array[i]); 519 | return this; 520 | }, 521 | 522 | erase: function(item){ 523 | for (var i = this.length; i--;){ 524 | if (this[i] === item) this.splice(i, 1); 525 | } 526 | return this; 527 | }, 528 | 529 | empty: function(){ 530 | this.length = 0; 531 | return this; 532 | }, 533 | 534 | flatten: function(){ 535 | var array = []; 536 | for (var i = 0, l = this.length; i < l; i++){ 537 | var type = typeOf(this[i]); 538 | if (type == 'null') continue; 539 | array = array.concat((type == 'array' || type == 'collection' || type == 'arguments' || instanceOf(this[i], Array)) ? Array.flatten(this[i]) : this[i]); 540 | } 541 | return array; 542 | }, 543 | 544 | pick: function(){ 545 | for (var i = 0, l = this.length; i < l; i++){ 546 | if (this[i] != null) return this[i]; 547 | } 548 | return null; 549 | }, 550 | 551 | hexToRgb: function(array){ 552 | if (this.length != 3) return null; 553 | var rgb = this.map(function(value){ 554 | if (value.length == 1) value += value; 555 | return value.toInt(16); 556 | }); 557 | return (array) ? rgb : 'rgb(' + rgb + ')'; 558 | }, 559 | 560 | rgbToHex: function(array){ 561 | if (this.length < 3) return null; 562 | if (this.length == 4 && this[3] == 0 && !array) return 'transparent'; 563 | var hex = []; 564 | for (var i = 0; i < 3; i++){ 565 | var bit = (this[i] - 0).toString(16); 566 | hex.push((bit.length == 1) ? '0' + bit : bit); 567 | } 568 | return (array) ? hex : '#' + hex.join(''); 569 | } 570 | 571 | }); 572 | 573 | 574 | 575 | 576 | /* 577 | --- 578 | 579 | name: String 580 | 581 | description: Contains String Prototypes like camelCase, capitalize, test, and toInt. 582 | 583 | license: MIT-style license. 584 | 585 | requires: Type 586 | 587 | provides: String 588 | 589 | ... 590 | */ 591 | 592 | String.implement({ 593 | 594 | test: function(regex, params){ 595 | return ((typeOf(regex) == 'regexp') ? regex : new RegExp('' + regex, params)).test(this); 596 | }, 597 | 598 | contains: function(string, separator){ 599 | return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : this.indexOf(string) > -1; 600 | }, 601 | 602 | trim: function(){ 603 | return this.replace(/^\s+|\s+$/g, ''); 604 | }, 605 | 606 | clean: function(){ 607 | return this.replace(/\s+/g, ' ').trim(); 608 | }, 609 | 610 | camelCase: function(){ 611 | return this.replace(/-\D/g, function(match){ 612 | return match.charAt(1).toUpperCase(); 613 | }); 614 | }, 615 | 616 | hyphenate: function(){ 617 | return this.replace(/[A-Z]/g, function(match){ 618 | return ('-' + match.charAt(0).toLowerCase()); 619 | }); 620 | }, 621 | 622 | capitalize: function(){ 623 | return this.replace(/\b[a-z]/g, function(match){ 624 | return match.toUpperCase(); 625 | }); 626 | }, 627 | 628 | escapeRegExp: function(){ 629 | return this.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1'); 630 | }, 631 | 632 | toInt: function(base){ 633 | return parseInt(this, base || 10); 634 | }, 635 | 636 | toFloat: function(){ 637 | return parseFloat(this); 638 | }, 639 | 640 | hexToRgb: function(array){ 641 | var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/); 642 | return (hex) ? hex.slice(1).hexToRgb(array) : null; 643 | }, 644 | 645 | rgbToHex: function(array){ 646 | var rgb = this.match(/\d{1,3}/g); 647 | return (rgb) ? rgb.rgbToHex(array) : null; 648 | }, 649 | 650 | substitute: function(object, regexp){ 651 | return this.replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){ 652 | if (match.charAt(0) == '\\') return match.slice(1); 653 | return (object[name] != null) ? object[name] : ''; 654 | }); 655 | } 656 | 657 | }); 658 | 659 | 660 | /* 661 | --- 662 | 663 | name: Number 664 | 665 | description: Contains Number Prototypes like limit, round, times, and ceil. 666 | 667 | license: MIT-style license. 668 | 669 | requires: Type 670 | 671 | provides: Number 672 | 673 | ... 674 | */ 675 | 676 | Number.implement({ 677 | 678 | limit: function(min, max){ 679 | return Math.min(max, Math.max(min, this)); 680 | }, 681 | 682 | round: function(precision){ 683 | precision = Math.pow(10, precision || 0).toFixed(precision < 0 ? -precision : 0); 684 | return Math.round(this * precision) / precision; 685 | }, 686 | 687 | times: function(fn, bind){ 688 | for (var i = 0; i < this; i++) fn.call(bind, i, this); 689 | }, 690 | 691 | toFloat: function(){ 692 | return parseFloat(this); 693 | }, 694 | 695 | toInt: function(base){ 696 | return parseInt(this, base || 10); 697 | } 698 | 699 | }); 700 | 701 | Number.alias('each', 'times'); 702 | 703 | (function(math){ 704 | var methods = {}; 705 | math.each(function(name){ 706 | if (!Number[name]) methods[name] = function(){ 707 | return Math[name].apply(null, [this].concat(Array.from(arguments))); 708 | }; 709 | }); 710 | Number.implement(methods); 711 | })(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']); 712 | 713 | 714 | /* 715 | --- 716 | 717 | name: Function 718 | 719 | description: Contains Function Prototypes like create, bind, pass, and delay. 720 | 721 | license: MIT-style license. 722 | 723 | requires: Type 724 | 725 | provides: Function 726 | 727 | ... 728 | */ 729 | 730 | Function.extend({ 731 | 732 | attempt: function(){ 733 | for (var i = 0, l = arguments.length; i < l; i++){ 734 | try { 735 | return arguments[i](); 736 | } catch (e){} 737 | } 738 | return null; 739 | } 740 | 741 | }); 742 | 743 | Function.implement({ 744 | 745 | attempt: function(args, bind){ 746 | try { 747 | return this.apply(bind, Array.from(args)); 748 | } catch (e){} 749 | 750 | return null; 751 | }, 752 | 753 | bind: function(bind){ 754 | var self = this, 755 | args = (arguments.length > 1) ? Array.slice(arguments, 1) : null; 756 | 757 | return function(){ 758 | if (!args && !arguments.length) return self.call(bind); 759 | if (args && arguments.length) return self.apply(bind, args.concat(Array.from(arguments))); 760 | return self.apply(bind, args || arguments); 761 | }; 762 | }, 763 | 764 | pass: function(args, bind){ 765 | var self = this; 766 | if (args != null) args = Array.from(args); 767 | return function(){ 768 | return self.apply(bind, args || arguments); 769 | }; 770 | }, 771 | 772 | delay: function(delay, bind, args){ 773 | return setTimeout(this.pass(args, bind), delay); 774 | }, 775 | 776 | periodical: function(periodical, bind, args){ 777 | return setInterval(this.pass(args, bind), periodical); 778 | } 779 | 780 | }); 781 | 782 | 783 | 784 | 785 | /* 786 | --- 787 | 788 | name: Object 789 | 790 | description: Object generic methods 791 | 792 | license: MIT-style license. 793 | 794 | requires: Type 795 | 796 | provides: [Object, Hash] 797 | 798 | ... 799 | */ 800 | 801 | 802 | Object.extend({ 803 | 804 | subset: function(object, keys){ 805 | var results = {}; 806 | for (var i = 0, l = keys.length; i < l; i++){ 807 | var k = keys[i]; 808 | results[k] = object[k]; 809 | } 810 | return results; 811 | }, 812 | 813 | map: function(object, fn, bind){ 814 | var results = {}; 815 | for (var key in object){ 816 | if (object.hasOwnProperty(key)) results[key] = fn.call(bind, object[key], key, object); 817 | } 818 | return results; 819 | }, 820 | 821 | filter: function(object, fn, bind){ 822 | var results = {}; 823 | Object.each(object, function(value, key){ 824 | if (fn.call(bind, value, key, object)) results[key] = value; 825 | }); 826 | return results; 827 | }, 828 | 829 | every: function(object, fn, bind){ 830 | for (var key in object){ 831 | if (object.hasOwnProperty(key) && !fn.call(bind, object[key], key)) return false; 832 | } 833 | return true; 834 | }, 835 | 836 | some: function(object, fn, bind){ 837 | for (var key in object){ 838 | if (object.hasOwnProperty(key) && fn.call(bind, object[key], key)) return true; 839 | } 840 | return false; 841 | }, 842 | 843 | keys: function(object){ 844 | var keys = []; 845 | for (var key in object){ 846 | if (object.hasOwnProperty(key)) keys.push(key); 847 | } 848 | return keys; 849 | }, 850 | 851 | values: function(object){ 852 | var values = []; 853 | for (var key in object){ 854 | if (object.hasOwnProperty(key)) values.push(object[key]); 855 | } 856 | return values; 857 | }, 858 | 859 | getLength: function(object){ 860 | return Object.keys(object).length; 861 | }, 862 | 863 | keyOf: function(object, value){ 864 | for (var key in object){ 865 | if (object.hasOwnProperty(key) && object[key] === value) return key; 866 | } 867 | return null; 868 | }, 869 | 870 | contains: function(object, value){ 871 | return Object.keyOf(object, value) != null; 872 | }, 873 | 874 | toQueryString: function(object, base){ 875 | var queryString = []; 876 | 877 | Object.each(object, function(value, key){ 878 | if (base) key = base + '[' + key + ']'; 879 | var result; 880 | switch (typeOf(value)){ 881 | case 'object': result = Object.toQueryString(value, key); break; 882 | case 'array': 883 | var qs = {}; 884 | value.each(function(val, i){ 885 | qs[i] = val; 886 | }); 887 | result = Object.toQueryString(qs, key); 888 | break; 889 | default: result = key + '=' + encodeURIComponent(value); 890 | } 891 | if (value != null) queryString.push(result); 892 | }); 893 | 894 | return queryString.join('&'); 895 | } 896 | 897 | }); 898 | 899 | 900 | 901 | 902 | 903 | /* 904 | --- 905 | 906 | name: Browser 907 | 908 | description: The Browser Object. Contains Browser initialization, Window and Document, and the Browser Hash. 909 | 910 | license: MIT-style license. 911 | 912 | requires: [Array, Function, Number, String] 913 | 914 | provides: [Browser, Window, Document] 915 | 916 | ... 917 | */ 918 | 919 | (function(){ 920 | 921 | var document = this.document; 922 | var window = document.window = this; 923 | 924 | var UID = 1; 925 | 926 | this.$uid = (window.ActiveXObject) ? function(item){ 927 | return (item.uid || (item.uid = [UID++]))[0]; 928 | } : function(item){ 929 | return item.uid || (item.uid = UID++); 930 | }; 931 | 932 | $uid(window); 933 | $uid(document); 934 | 935 | var ua = navigator.userAgent.toLowerCase(), 936 | platform = navigator.platform.toLowerCase(), 937 | UA = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0], 938 | mode = UA[1] == 'ie' && document.documentMode; 939 | 940 | var Browser = this.Browser = { 941 | 942 | extend: Function.prototype.extend, 943 | 944 | name: (UA[1] == 'version') ? UA[3] : UA[1], 945 | 946 | version: mode || parseFloat((UA[1] == 'opera' && UA[4]) ? UA[4] : UA[2]), 947 | 948 | Platform: { 949 | name: ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0] 950 | }, 951 | 952 | Features: { 953 | xpath: !!(document.evaluate), 954 | air: !!(window.runtime), 955 | query: !!(document.querySelector), 956 | json: !!(window.JSON) 957 | }, 958 | 959 | Plugins: {} 960 | 961 | }; 962 | 963 | Browser[Browser.name] = true; 964 | Browser[Browser.name + parseInt(Browser.version, 10)] = true; 965 | Browser.Platform[Browser.Platform.name] = true; 966 | 967 | // Request 968 | 969 | Browser.Request = (function(){ 970 | 971 | var XMLHTTP = function(){ 972 | return new XMLHttpRequest(); 973 | }; 974 | 975 | var MSXML2 = function(){ 976 | return new ActiveXObject('MSXML2.XMLHTTP'); 977 | }; 978 | 979 | var MSXML = function(){ 980 | return new ActiveXObject('Microsoft.XMLHTTP'); 981 | }; 982 | 983 | return Function.attempt(function(){ 984 | XMLHTTP(); 985 | return XMLHTTP; 986 | }, function(){ 987 | MSXML2(); 988 | return MSXML2; 989 | }, function(){ 990 | MSXML(); 991 | return MSXML; 992 | }); 993 | 994 | })(); 995 | 996 | Browser.Features.xhr = !!(Browser.Request); 997 | 998 | // Flash detection 999 | 1000 | var version = (Function.attempt(function(){ 1001 | return navigator.plugins['Shockwave Flash'].description; 1002 | }, function(){ 1003 | return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version'); 1004 | }) || '0 r0').match(/\d+/g); 1005 | 1006 | Browser.Plugins.Flash = { 1007 | version: Number(version[0] || '0.' + version[1]) || 0, 1008 | build: Number(version[2]) || 0 1009 | }; 1010 | 1011 | // String scripts 1012 | 1013 | Browser.exec = function(text){ 1014 | if (!text) return text; 1015 | if (window.execScript){ 1016 | window.execScript(text); 1017 | } else { 1018 | var script = document.createElement('script'); 1019 | script.setAttribute('type', 'text/javascript'); 1020 | script.text = text; 1021 | document.head.appendChild(script); 1022 | document.head.removeChild(script); 1023 | } 1024 | return text; 1025 | }; 1026 | 1027 | String.implement('stripScripts', function(exec){ 1028 | var scripts = ''; 1029 | var text = this.replace(/]*>([\s\S]*?)<\/script>/gi, function(all, code){ 1030 | scripts += code + '\n'; 1031 | return ''; 1032 | }); 1033 | if (exec === true) Browser.exec(scripts); 1034 | else if (typeOf(exec) == 'function') exec(scripts, text); 1035 | return text; 1036 | }); 1037 | 1038 | // Window, Document 1039 | 1040 | Browser.extend({ 1041 | Document: this.Document, 1042 | Window: this.Window, 1043 | Element: this.Element, 1044 | Event: this.Event 1045 | }); 1046 | 1047 | this.Window = this.$constructor = new Type('Window', function(){}); 1048 | 1049 | this.$family = Function.from('window').hide(); 1050 | 1051 | Window.mirror(function(name, method){ 1052 | window[name] = method; 1053 | }); 1054 | 1055 | this.Document = document.$constructor = new Type('Document', function(){}); 1056 | 1057 | document.$family = Function.from('document').hide(); 1058 | 1059 | Document.mirror(function(name, method){ 1060 | document[name] = method; 1061 | }); 1062 | 1063 | document.html = document.documentElement; 1064 | document.head = document.getElementsByTagName('head')[0]; 1065 | 1066 | if (document.execCommand) try { 1067 | document.execCommand("BackgroundImageCache", false, true); 1068 | } catch (e){} 1069 | 1070 | if (this.attachEvent && !this.addEventListener){ 1071 | var unloadEvent = function(){ 1072 | this.detachEvent('onunload', unloadEvent); 1073 | document.head = document.html = document.window = null; 1074 | }; 1075 | this.attachEvent('onunload', unloadEvent); 1076 | } 1077 | 1078 | // IE fails on collections and ) 1079 | var arrayFrom = Array.from; 1080 | try { 1081 | arrayFrom(document.html.childNodes); 1082 | } catch(e){ 1083 | Array.from = function(item){ 1084 | if (typeof item != 'string' && Type.isEnumerable(item) && typeOf(item) != 'array'){ 1085 | var i = item.length, array = new Array(i); 1086 | while (i--) array[i] = item[i]; 1087 | return array; 1088 | } 1089 | return arrayFrom(item); 1090 | }; 1091 | 1092 | var prototype = Array.prototype, 1093 | slice = prototype.slice; 1094 | ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice'].each(function(name){ 1095 | var method = prototype[name]; 1096 | Array[name] = function(item){ 1097 | return method.apply(Array.from(item), slice.call(arguments, 1)); 1098 | }; 1099 | }); 1100 | } 1101 | 1102 | 1103 | 1104 | })(); 1105 | 1106 | 1107 | /* 1108 | --- 1109 | 1110 | name: Event 1111 | 1112 | description: Contains the Event Class, to make the event object cross-browser. 1113 | 1114 | license: MIT-style license. 1115 | 1116 | requires: [Window, Document, Array, Function, String, Object] 1117 | 1118 | provides: Event 1119 | 1120 | ... 1121 | */ 1122 | 1123 | var Event = new Type('Event', function(event, win){ 1124 | if (!win) win = window; 1125 | var doc = win.document; 1126 | event = event || win.event; 1127 | if (event.$extended) return event; 1128 | this.$extended = true; 1129 | var type = event.type, 1130 | target = event.target || event.srcElement, 1131 | page = {}, 1132 | client = {}; 1133 | while (target && target.nodeType == 3) target = target.parentNode; 1134 | 1135 | if (type.indexOf('key') != -1){ 1136 | var code = event.which || event.keyCode; 1137 | var key = Object.keyOf(Event.Keys, code); 1138 | if (type == 'keydown'){ 1139 | var fKey = code - 111; 1140 | if (fKey > 0 && fKey < 13) key = 'f' + fKey; 1141 | } 1142 | if (!key) key = String.fromCharCode(code).toLowerCase(); 1143 | } else if (type.test(/click|mouse|menu/i)){ 1144 | doc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body; 1145 | page = { 1146 | x: (event.pageX != null) ? event.pageX : event.clientX + doc.scrollLeft, 1147 | y: (event.pageY != null) ? event.pageY : event.clientY + doc.scrollTop 1148 | }; 1149 | client = { 1150 | x: (event.pageX != null) ? event.pageX - win.pageXOffset : event.clientX, 1151 | y: (event.pageY != null) ? event.pageY - win.pageYOffset : event.clientY 1152 | }; 1153 | if (type.test(/DOMMouseScroll|mousewheel/)){ 1154 | var wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3; 1155 | } 1156 | var rightClick = (event.which == 3) || (event.button == 2), 1157 | related = null; 1158 | if (type.test(/over|out/)){ 1159 | related = event.relatedTarget || event[(type == 'mouseover' ? 'from' : 'to') + 'Element']; 1160 | var testRelated = function(){ 1161 | while (related && related.nodeType == 3) related = related.parentNode; 1162 | return true; 1163 | }; 1164 | var hasRelated = (Browser.firefox2) ? testRelated.attempt() : testRelated(); 1165 | related = (hasRelated) ? related : null; 1166 | } 1167 | } else if (type.test(/gesture|touch/i)){ 1168 | this.rotation = event.rotation; 1169 | this.scale = event.scale; 1170 | this.targetTouches = event.targetTouches; 1171 | this.changedTouches = event.changedTouches; 1172 | var touches = this.touches = event.touches; 1173 | if (touches && touches[0]){ 1174 | var touch = touches[0]; 1175 | page = {x: touch.pageX, y: touch.pageY}; 1176 | client = {x: touch.clientX, y: touch.clientY}; 1177 | } 1178 | } 1179 | 1180 | return Object.append(this, { 1181 | event: event, 1182 | type: type, 1183 | 1184 | page: page, 1185 | client: client, 1186 | rightClick: rightClick, 1187 | 1188 | wheel: wheel, 1189 | 1190 | relatedTarget: document.id(related), 1191 | target: document.id(target), 1192 | 1193 | code: code, 1194 | key: key, 1195 | 1196 | shift: event.shiftKey, 1197 | control: event.ctrlKey, 1198 | alt: event.altKey, 1199 | meta: event.metaKey 1200 | }); 1201 | }); 1202 | 1203 | Event.Keys = { 1204 | 'enter': 13, 1205 | 'up': 38, 1206 | 'down': 40, 1207 | 'left': 37, 1208 | 'right': 39, 1209 | 'esc': 27, 1210 | 'space': 32, 1211 | 'backspace': 8, 1212 | 'tab': 9, 1213 | 'delete': 46 1214 | }; 1215 | 1216 | 1217 | 1218 | Event.implement({ 1219 | 1220 | stop: function(){ 1221 | return this.stopPropagation().preventDefault(); 1222 | }, 1223 | 1224 | stopPropagation: function(){ 1225 | if (this.event.stopPropagation) this.event.stopPropagation(); 1226 | else this.event.cancelBubble = true; 1227 | return this; 1228 | }, 1229 | 1230 | preventDefault: function(){ 1231 | if (this.event.preventDefault) this.event.preventDefault(); 1232 | else this.event.returnValue = false; 1233 | return this; 1234 | } 1235 | 1236 | }); 1237 | 1238 | 1239 | /* 1240 | --- 1241 | 1242 | name: Class 1243 | 1244 | description: Contains the Class Function for easily creating, extending, and implementing reusable Classes. 1245 | 1246 | license: MIT-style license. 1247 | 1248 | requires: [Array, String, Function, Number] 1249 | 1250 | provides: Class 1251 | 1252 | ... 1253 | */ 1254 | 1255 | (function(){ 1256 | 1257 | var Class = this.Class = new Type('Class', function(params){ 1258 | if (instanceOf(params, Function)) params = {initialize: params}; 1259 | 1260 | var newClass = function(){ 1261 | reset(this); 1262 | if (newClass.$prototyping) return this; 1263 | this.$caller = null; 1264 | var value = (this.initialize) ? this.initialize.apply(this, arguments) : this; 1265 | this.$caller = this.caller = null; 1266 | return value; 1267 | }.extend(this).implement(params); 1268 | 1269 | newClass.$constructor = Class; 1270 | newClass.prototype.$constructor = newClass; 1271 | newClass.prototype.parent = parent; 1272 | 1273 | return newClass; 1274 | }); 1275 | 1276 | var parent = function(){ 1277 | if (!this.$caller) throw new Error('The method "parent" cannot be called.'); 1278 | var name = this.$caller.$name, 1279 | parent = this.$caller.$owner.parent, 1280 | previous = (parent) ? parent.prototype[name] : null; 1281 | if (!previous) throw new Error('The method "' + name + '" has no parent.'); 1282 | return previous.apply(this, arguments); 1283 | }; 1284 | 1285 | var reset = function(object){ 1286 | for (var key in object){ 1287 | var value = object[key]; 1288 | switch (typeOf(value)){ 1289 | case 'object': 1290 | var F = function(){}; 1291 | F.prototype = value; 1292 | object[key] = reset(new F); 1293 | break; 1294 | case 'array': object[key] = value.clone(); break; 1295 | } 1296 | } 1297 | return object; 1298 | }; 1299 | 1300 | var wrap = function(self, key, method){ 1301 | if (method.$origin) method = method.$origin; 1302 | var wrapper = function(){ 1303 | if (method.$protected && this.$caller == null) throw new Error('The method "' + key + '" cannot be called.'); 1304 | var caller = this.caller, current = this.$caller; 1305 | this.caller = current; this.$caller = wrapper; 1306 | var result = method.apply(this, arguments); 1307 | this.$caller = current; this.caller = caller; 1308 | return result; 1309 | }.extend({$owner: self, $origin: method, $name: key}); 1310 | return wrapper; 1311 | }; 1312 | 1313 | var implement = function(key, value, retain){ 1314 | if (Class.Mutators.hasOwnProperty(key)){ 1315 | value = Class.Mutators[key].call(this, value); 1316 | if (value == null) return this; 1317 | } 1318 | 1319 | if (typeOf(value) == 'function'){ 1320 | if (value.$hidden) return this; 1321 | this.prototype[key] = (retain) ? value : wrap(this, key, value); 1322 | } else { 1323 | Object.merge(this.prototype, key, value); 1324 | } 1325 | 1326 | return this; 1327 | }; 1328 | 1329 | var getInstance = function(klass){ 1330 | klass.$prototyping = true; 1331 | var proto = new klass; 1332 | delete klass.$prototyping; 1333 | return proto; 1334 | }; 1335 | 1336 | Class.implement('implement', implement.overloadSetter()); 1337 | 1338 | Class.Mutators = { 1339 | 1340 | Extends: function(parent){ 1341 | this.parent = parent; 1342 | this.prototype = getInstance(parent); 1343 | }, 1344 | 1345 | Implements: function(items){ 1346 | Array.from(items).each(function(item){ 1347 | var instance = new item; 1348 | for (var key in instance) implement.call(this, key, instance[key], true); 1349 | }, this); 1350 | } 1351 | }; 1352 | 1353 | })(); 1354 | 1355 | 1356 | /* 1357 | --- 1358 | 1359 | name: Class.Extras 1360 | 1361 | description: Contains Utility Classes that can be implemented into your own Classes to ease the execution of many common tasks. 1362 | 1363 | license: MIT-style license. 1364 | 1365 | requires: Class 1366 | 1367 | provides: [Class.Extras, Chain, Events, Options] 1368 | 1369 | ... 1370 | */ 1371 | 1372 | (function(){ 1373 | 1374 | this.Chain = new Class({ 1375 | 1376 | $chain: [], 1377 | 1378 | chain: function(){ 1379 | this.$chain.append(Array.flatten(arguments)); 1380 | return this; 1381 | }, 1382 | 1383 | callChain: function(){ 1384 | return (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false; 1385 | }, 1386 | 1387 | clearChain: function(){ 1388 | this.$chain.empty(); 1389 | return this; 1390 | } 1391 | 1392 | }); 1393 | 1394 | var removeOn = function(string){ 1395 | return string.replace(/^on([A-Z])/, function(full, first){ 1396 | return first.toLowerCase(); 1397 | }); 1398 | }; 1399 | 1400 | this.Events = new Class({ 1401 | 1402 | $events: {}, 1403 | 1404 | addEvent: function(type, fn, internal){ 1405 | type = removeOn(type); 1406 | 1407 | 1408 | 1409 | this.$events[type] = (this.$events[type] || []).include(fn); 1410 | if (internal) fn.internal = true; 1411 | return this; 1412 | }, 1413 | 1414 | addEvents: function(events){ 1415 | for (var type in events) this.addEvent(type, events[type]); 1416 | return this; 1417 | }, 1418 | 1419 | fireEvent: function(type, args, delay){ 1420 | type = removeOn(type); 1421 | var events = this.$events[type]; 1422 | if (!events) return this; 1423 | args = Array.from(args); 1424 | events.each(function(fn){ 1425 | if (delay) fn.delay(delay, this, args); 1426 | else fn.apply(this, args); 1427 | }, this); 1428 | return this; 1429 | }, 1430 | 1431 | removeEvent: function(type, fn){ 1432 | type = removeOn(type); 1433 | var events = this.$events[type]; 1434 | if (events && !fn.internal){ 1435 | var index = events.indexOf(fn); 1436 | if (index != -1) delete events[index]; 1437 | } 1438 | return this; 1439 | }, 1440 | 1441 | removeEvents: function(events){ 1442 | var type; 1443 | if (typeOf(events) == 'object'){ 1444 | for (type in events) this.removeEvent(type, events[type]); 1445 | return this; 1446 | } 1447 | if (events) events = removeOn(events); 1448 | for (type in this.$events){ 1449 | if (events && events != type) continue; 1450 | var fns = this.$events[type]; 1451 | for (var i = fns.length; i--;) this.removeEvent(type, fns[i]); 1452 | } 1453 | return this; 1454 | } 1455 | 1456 | }); 1457 | 1458 | this.Options = new Class({ 1459 | 1460 | setOptions: function(){ 1461 | var options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments)); 1462 | if (!this.addEvent) return this; 1463 | for (var option in options){ 1464 | if (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue; 1465 | this.addEvent(option, options[option]); 1466 | delete options[option]; 1467 | } 1468 | return this; 1469 | } 1470 | 1471 | }); 1472 | 1473 | })(); 1474 | 1475 | 1476 | /* 1477 | --- 1478 | name: Slick.Parser 1479 | description: Standalone CSS3 Selector parser 1480 | provides: Slick.Parser 1481 | ... 1482 | */ 1483 | 1484 | (function(){ 1485 | 1486 | var parsed, 1487 | separatorIndex, 1488 | combinatorIndex, 1489 | reversed, 1490 | cache = {}, 1491 | reverseCache = {}, 1492 | reUnescape = /\\/g; 1493 | 1494 | var parse = function(expression, isReversed){ 1495 | if (expression == null) return null; 1496 | if (expression.Slick === true) return expression; 1497 | expression = ('' + expression).replace(/^\s+|\s+$/g, ''); 1498 | reversed = !!isReversed; 1499 | var currentCache = (reversed) ? reverseCache : cache; 1500 | if (currentCache[expression]) return currentCache[expression]; 1501 | parsed = {Slick: true, expressions: [], raw: expression, reverse: function(){ 1502 | return parse(this.raw, true); 1503 | }}; 1504 | separatorIndex = -1; 1505 | while (expression != (expression = expression.replace(regexp, parser))); 1506 | parsed.length = parsed.expressions.length; 1507 | return currentCache[expression] = (reversed) ? reverse(parsed) : parsed; 1508 | }; 1509 | 1510 | var reverseCombinator = function(combinator){ 1511 | if (combinator === '!') return ' '; 1512 | else if (combinator === ' ') return '!'; 1513 | else if ((/^!/).test(combinator)) return combinator.replace(/^!/, ''); 1514 | else return '!' + combinator; 1515 | }; 1516 | 1517 | var reverse = function(expression){ 1518 | var expressions = expression.expressions; 1519 | for (var i = 0; i < expressions.length; i++){ 1520 | var exp = expressions[i]; 1521 | var last = {parts: [], tag: '*', combinator: reverseCombinator(exp[0].combinator)}; 1522 | 1523 | for (var j = 0; j < exp.length; j++){ 1524 | var cexp = exp[j]; 1525 | if (!cexp.reverseCombinator) cexp.reverseCombinator = ' '; 1526 | cexp.combinator = cexp.reverseCombinator; 1527 | delete cexp.reverseCombinator; 1528 | } 1529 | 1530 | exp.reverse().push(last); 1531 | } 1532 | return expression; 1533 | }; 1534 | 1535 | var escapeRegExp = function(string){// Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Levithan MIT License 1536 | return string.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, "\\$&"); 1537 | }; 1538 | 1539 | var regexp = new RegExp( 1540 | /* 1541 | #!/usr/bin/env ruby 1542 | puts "\t\t" + DATA.read.gsub(/\(\?x\)|\s+#.*$|\s+|\\$|\\n/,'') 1543 | __END__ 1544 | "(?x)^(?:\ 1545 | \\s* ( , ) \\s* # Separator \n\ 1546 | | \\s* ( + ) \\s* # Combinator \n\ 1547 | | ( \\s+ ) # CombinatorChildren \n\ 1548 | | ( + | \\* ) # Tag \n\ 1549 | | \\# ( + ) # ID \n\ 1550 | | \\. ( + ) # ClassName \n\ 1551 | | # Attribute \n\ 1552 | \\[ \ 1553 | \\s* (+) (?: \ 1554 | \\s* ([*^$!~|]?=) (?: \ 1555 | \\s* (?:\ 1556 | ([\"']?)(.*?)\\9 \ 1557 | )\ 1558 | ) \ 1559 | )? \\s* \ 1560 | \\](?!\\]) \n\ 1561 | | :+ ( + )(?:\ 1562 | \\( (?:\ 1563 | (?:([\"'])([^\\12]*)\\12)|((?:\\([^)]+\\)|[^()]*)+)\ 1564 | ) \\)\ 1565 | )?\ 1566 | )" 1567 | */ 1568 | "^(?:\\s*(,)\\s*|\\s*(+)\\s*|(\\s+)|(+|\\*)|\\#(+)|\\.(+)|\\[\\s*(+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|:+(+)(?:\\((?:(?:([\"'])([^\\12]*)\\12)|((?:\\([^)]+\\)|[^()]*)+))\\))?)" 1569 | .replace(//, '[' + escapeRegExp(">+~`!@$%^&={}\\;/g, '(?:[\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])') 1571 | .replace(//g, '(?:[:\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])') 1572 | ); 1573 | 1574 | function parser( 1575 | rawMatch, 1576 | 1577 | separator, 1578 | combinator, 1579 | combinatorChildren, 1580 | 1581 | tagName, 1582 | id, 1583 | className, 1584 | 1585 | attributeKey, 1586 | attributeOperator, 1587 | attributeQuote, 1588 | attributeValue, 1589 | 1590 | pseudoClass, 1591 | pseudoQuote, 1592 | pseudoClassQuotedValue, 1593 | pseudoClassValue 1594 | ){ 1595 | if (separator || separatorIndex === -1){ 1596 | parsed.expressions[++separatorIndex] = []; 1597 | combinatorIndex = -1; 1598 | if (separator) return ''; 1599 | } 1600 | 1601 | if (combinator || combinatorChildren || combinatorIndex === -1){ 1602 | combinator = combinator || ' '; 1603 | var currentSeparator = parsed.expressions[separatorIndex]; 1604 | if (reversed && currentSeparator[combinatorIndex]) 1605 | currentSeparator[combinatorIndex].reverseCombinator = reverseCombinator(combinator); 1606 | currentSeparator[++combinatorIndex] = {combinator: combinator, tag: '*'}; 1607 | } 1608 | 1609 | var currentParsed = parsed.expressions[separatorIndex][combinatorIndex]; 1610 | 1611 | if (tagName){ 1612 | currentParsed.tag = tagName.replace(reUnescape, ''); 1613 | 1614 | } else if (id){ 1615 | currentParsed.id = id.replace(reUnescape, ''); 1616 | 1617 | } else if (className){ 1618 | className = className.replace(reUnescape, ''); 1619 | 1620 | if (!currentParsed.classList) currentParsed.classList = []; 1621 | if (!currentParsed.classes) currentParsed.classes = []; 1622 | currentParsed.classList.push(className); 1623 | currentParsed.classes.push({ 1624 | value: className, 1625 | regexp: new RegExp('(^|\\s)' + escapeRegExp(className) + '(\\s|$)') 1626 | }); 1627 | 1628 | } else if (pseudoClass){ 1629 | pseudoClassValue = pseudoClassValue || pseudoClassQuotedValue; 1630 | pseudoClassValue = pseudoClassValue ? pseudoClassValue.replace(reUnescape, '') : null; 1631 | 1632 | if (!currentParsed.pseudos) currentParsed.pseudos = []; 1633 | currentParsed.pseudos.push({ 1634 | key: pseudoClass.replace(reUnescape, ''), 1635 | value: pseudoClassValue 1636 | }); 1637 | 1638 | } else if (attributeKey){ 1639 | attributeKey = attributeKey.replace(reUnescape, ''); 1640 | attributeValue = (attributeValue || '').replace(reUnescape, ''); 1641 | 1642 | var test, regexp; 1643 | 1644 | switch (attributeOperator){ 1645 | case '^=' : regexp = new RegExp( '^'+ escapeRegExp(attributeValue) ); break; 1646 | case '$=' : regexp = new RegExp( escapeRegExp(attributeValue) +'$' ); break; 1647 | case '~=' : regexp = new RegExp( '(^|\\s)'+ escapeRegExp(attributeValue) +'(\\s|$)' ); break; 1648 | case '|=' : regexp = new RegExp( '^'+ escapeRegExp(attributeValue) +'(-|$)' ); break; 1649 | case '=' : test = function(value){ 1650 | return attributeValue == value; 1651 | }; break; 1652 | case '*=' : test = function(value){ 1653 | return value && value.indexOf(attributeValue) > -1; 1654 | }; break; 1655 | case '!=' : test = function(value){ 1656 | return attributeValue != value; 1657 | }; break; 1658 | default : test = function(value){ 1659 | return !!value; 1660 | }; 1661 | } 1662 | 1663 | if (attributeValue == '' && (/^[*$^]=$/).test(attributeOperator)) test = function(){ 1664 | return false; 1665 | }; 1666 | 1667 | if (!test) test = function(value){ 1668 | return value && regexp.test(value); 1669 | }; 1670 | 1671 | if (!currentParsed.attributes) currentParsed.attributes = []; 1672 | currentParsed.attributes.push({ 1673 | key: attributeKey, 1674 | operator: attributeOperator, 1675 | value: attributeValue, 1676 | test: test 1677 | }); 1678 | 1679 | } 1680 | 1681 | return ''; 1682 | }; 1683 | 1684 | // Slick NS 1685 | 1686 | var Slick = (this.Slick || {}); 1687 | 1688 | Slick.parse = function(expression){ 1689 | return parse(expression); 1690 | }; 1691 | 1692 | Slick.escapeRegExp = escapeRegExp; 1693 | 1694 | if (!this.Slick) this.Slick = Slick; 1695 | 1696 | }).apply(/**/(typeof exports != 'undefined') ? exports : /**/this); 1697 | 1698 | 1699 | /* 1700 | --- 1701 | name: Slick.Finder 1702 | description: The new, superfast css selector engine. 1703 | provides: Slick.Finder 1704 | requires: Slick.Parser 1705 | ... 1706 | */ 1707 | 1708 | (function(){ 1709 | 1710 | var local = {}; 1711 | 1712 | // Feature / Bug detection 1713 | 1714 | local.isNativeCode = function(fn){ 1715 | return (/\{\s*\[native code\]\s*\}/).test('' + fn); 1716 | }; 1717 | 1718 | local.isXML = function(document){ 1719 | return (!!document.xmlVersion) || (!!document.xml) || (Object.prototype.toString.call(document) === '[object XMLDocument]') || 1720 | (document.nodeType === 9 && document.documentElement.nodeName !== 'HTML'); 1721 | }; 1722 | 1723 | local.setDocument = function(document){ 1724 | 1725 | // convert elements / window arguments to document. if document cannot be extrapolated, the function returns. 1726 | 1727 | if (document.nodeType === 9); // document 1728 | else if (document.ownerDocument) document = document.ownerDocument; // node 1729 | else if (document.navigator) document = document.document; // window 1730 | else return; 1731 | 1732 | // check if it's the old document 1733 | 1734 | if (this.document === document) return; 1735 | this.document = document; 1736 | var root = this.root = document.documentElement; 1737 | 1738 | this.isXMLDocument = this.isXML(document); 1739 | 1740 | this.brokenStarGEBTN 1741 | = this.starSelectsClosedQSA 1742 | = this.idGetsName 1743 | = this.brokenMixedCaseQSA 1744 | = this.brokenGEBCN 1745 | = this.brokenCheckedQSA 1746 | = this.brokenEmptyAttributeQSA 1747 | = this.isHTMLDocument 1748 | = false; 1749 | 1750 | var starSelectsClosed, starSelectsComments, 1751 | brokenSecondClassNameGEBCN, cachedGetElementsByClassName; 1752 | 1753 | var selected, id; 1754 | var testNode = document.createElement('div'); 1755 | root.appendChild(testNode); 1756 | 1757 | // on non-HTML documents innerHTML and getElementsById doesnt work properly 1758 | try { 1759 | id = 'slick_getbyid_test'; 1760 | testNode.innerHTML = ''; 1761 | this.isHTMLDocument = !!document.getElementById(id); 1762 | } catch(e){}; 1763 | 1764 | if (this.isHTMLDocument){ 1765 | 1766 | testNode.style.display = 'none'; 1767 | 1768 | // IE returns comment nodes for getElementsByTagName('*') for some documents 1769 | testNode.appendChild(document.createComment('')); 1770 | starSelectsComments = (testNode.getElementsByTagName('*').length > 0); 1771 | 1772 | // IE returns closed nodes (EG:"") for getElementsByTagName('*') for some documents 1773 | try { 1774 | testNode.innerHTML = 'foo'; 1775 | selected = testNode.getElementsByTagName('*'); 1776 | starSelectsClosed = (selected && selected.length && selected[0].nodeName.charAt(0) == '/'); 1777 | } catch(e){}; 1778 | 1779 | this.brokenStarGEBTN = starSelectsComments || starSelectsClosed; 1780 | 1781 | // IE 8 returns closed nodes (EG:"") for querySelectorAll('*') for some documents 1782 | if (testNode.querySelectorAll) try { 1783 | testNode.innerHTML = 'foo'; 1784 | selected = testNode.querySelectorAll('*'); 1785 | this.starSelectsClosedQSA = (selected && selected.length && selected[0].nodeName.charAt(0) == '/'); 1786 | } catch(e){}; 1787 | 1788 | // IE returns elements with the name instead of just id for getElementsById for some documents 1789 | try { 1790 | id = 'slick_id_gets_name'; 1791 | testNode.innerHTML = ''; 1792 | this.idGetsName = document.getElementById(id) === testNode.firstChild; 1793 | } catch(e){}; 1794 | 1795 | // Safari 3.2 querySelectorAll doesnt work with mixedcase on quirksmode 1796 | try { 1797 | testNode.innerHTML = ''; 1798 | this.brokenMixedCaseQSA = !testNode.querySelectorAll('.MiXedCaSe').length; 1799 | } catch(e){}; 1800 | 1801 | try { 1802 | testNode.innerHTML = ''; 1803 | testNode.getElementsByClassName('b').length; 1804 | testNode.firstChild.className = 'b'; 1805 | cachedGetElementsByClassName = (testNode.getElementsByClassName('b').length != 2); 1806 | } catch(e){}; 1807 | 1808 | // Opera 9.6 getElementsByClassName doesnt detects the class if its not the first one 1809 | try { 1810 | testNode.innerHTML = ''; 1811 | brokenSecondClassNameGEBCN = (testNode.getElementsByClassName('a').length != 2); 1812 | } catch(e){}; 1813 | 1814 | this.brokenGEBCN = cachedGetElementsByClassName || brokenSecondClassNameGEBCN; 1815 | 1816 | // Webkit dont return selected options on querySelectorAll 1817 | try { 1818 | testNode.innerHTML = ''; 1819 | this.brokenCheckedQSA = (testNode.querySelectorAll(':checked').length == 0); 1820 | } catch(e){}; 1821 | 1822 | // IE returns incorrect results for attr[*^$]="" selectors on querySelectorAll 1823 | try { 1824 | testNode.innerHTML = ''; 1825 | this.brokenEmptyAttributeQSA = (testNode.querySelectorAll('[class*=""]').length != 0); 1826 | } catch(e){}; 1827 | 1828 | } 1829 | 1830 | root.removeChild(testNode); 1831 | testNode = null; 1832 | 1833 | // hasAttribute 1834 | 1835 | this.hasAttribute = (root && this.isNativeCode(root.hasAttribute)) ? function(node, attribute) { 1836 | return node.hasAttribute(attribute); 1837 | } : function(node, attribute) { 1838 | node = node.getAttributeNode(attribute); 1839 | return !!(node && (node.specified || node.nodeValue)); 1840 | }; 1841 | 1842 | // contains 1843 | // FIXME: Add specs: local.contains should be different for xml and html documents? 1844 | this.contains = (root && this.isNativeCode(root.contains)) ? function(context, node){ 1845 | return context.contains(node); 1846 | } : (root && root.compareDocumentPosition) ? function(context, node){ 1847 | return context === node || !!(context.compareDocumentPosition(node) & 16); 1848 | } : function(context, node){ 1849 | if (node) do { 1850 | if (node === context) return true; 1851 | } while ((node = node.parentNode)); 1852 | return false; 1853 | }; 1854 | 1855 | // document order sorting 1856 | // credits to Sizzle (http://sizzlejs.com/) 1857 | 1858 | this.documentSorter = (root.compareDocumentPosition) ? function(a, b){ 1859 | if (!a.compareDocumentPosition || !b.compareDocumentPosition) return 0; 1860 | return a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; 1861 | } : ('sourceIndex' in root) ? function(a, b){ 1862 | if (!a.sourceIndex || !b.sourceIndex) return 0; 1863 | return a.sourceIndex - b.sourceIndex; 1864 | } : (document.createRange) ? function(a, b){ 1865 | if (!a.ownerDocument || !b.ownerDocument) return 0; 1866 | var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); 1867 | aRange.setStart(a, 0); 1868 | aRange.setEnd(a, 0); 1869 | bRange.setStart(b, 0); 1870 | bRange.setEnd(b, 0); 1871 | return aRange.compareBoundaryPoints(Range.START_TO_END, bRange); 1872 | } : null ; 1873 | 1874 | this.getUID = (this.isHTMLDocument) ? this.getUIDHTML : this.getUIDXML; 1875 | 1876 | }; 1877 | 1878 | // Main Method 1879 | 1880 | local.search = function(context, expression, append, first){ 1881 | 1882 | var found = this.found = (first) ? null : (append || []); 1883 | 1884 | // context checks 1885 | 1886 | if (!context) return found; // No context 1887 | if (context.navigator) context = context.document; // Convert the node from a window to a document 1888 | else if (!context.nodeType) return found; // Reject misc junk input 1889 | 1890 | // setup 1891 | 1892 | var parsed, i; 1893 | 1894 | var uniques = this.uniques = {}; 1895 | 1896 | if (this.document !== (context.ownerDocument || context)) this.setDocument(context); 1897 | 1898 | // should sort if there are nodes in append and if you pass multiple expressions. 1899 | // should remove duplicates if append already has items 1900 | var shouldUniques = !!(append && append.length); 1901 | 1902 | // avoid duplicating items already in the append array 1903 | if (shouldUniques) for (i = found.length; i--;) this.uniques[this.getUID(found[i])] = true; 1904 | 1905 | // expression checks 1906 | 1907 | if (typeof expression == 'string'){ // expression is a string 1908 | 1909 | // Overrides 1910 | 1911 | for (i = this.overrides.length; i--;){ 1912 | var override = this.overrides[i]; 1913 | if (override.regexp.test(expression)){ 1914 | var result = override.method.call(context, expression, found, first); 1915 | if (result === false) continue; 1916 | if (result === true) return found; 1917 | return result; 1918 | } 1919 | } 1920 | 1921 | parsed = this.Slick.parse(expression); 1922 | if (!parsed.length) return found; 1923 | } else if (expression == null){ // there is no expression 1924 | return found; 1925 | } else if (expression.Slick){ // expression is a parsed Slick object 1926 | parsed = expression; 1927 | } else if (this.contains(context.documentElement || context, expression)){ // expression is a node 1928 | (found) ? found.push(expression) : found = expression; 1929 | return found; 1930 | } else { // other junk 1931 | return found; 1932 | } 1933 | 1934 | // cache elements for the nth selectors 1935 | 1936 | /**//**/ 1937 | 1938 | this.posNTH = {}; 1939 | this.posNTHLast = {}; 1940 | this.posNTHType = {}; 1941 | this.posNTHTypeLast = {}; 1942 | 1943 | /**//**/ 1944 | 1945 | // if append is null and there is only a single selector with one expression use pushArray, else use pushUID 1946 | this.push = (!shouldUniques && (first || (parsed.length == 1 && parsed.expressions[0].length == 1))) ? this.pushArray : this.pushUID; 1947 | 1948 | if (found == null) found = []; 1949 | 1950 | // default engine 1951 | 1952 | var j, m, n; 1953 | var combinator, tag, id, classList, classes, attributes, pseudos; 1954 | var currentItems, currentExpression, currentBit, lastBit, expressions = parsed.expressions; 1955 | 1956 | search: for (i = 0; (currentExpression = expressions[i]); i++) for (j = 0; (currentBit = currentExpression[j]); j++){ 1957 | 1958 | combinator = 'combinator:' + currentBit.combinator; 1959 | if (!this[combinator]) continue search; 1960 | 1961 | tag = (this.isXMLDocument) ? currentBit.tag : currentBit.tag.toUpperCase(); 1962 | id = currentBit.id; 1963 | classList = currentBit.classList; 1964 | classes = currentBit.classes; 1965 | attributes = currentBit.attributes; 1966 | pseudos = currentBit.pseudos; 1967 | lastBit = (j === (currentExpression.length - 1)); 1968 | 1969 | this.bitUniques = {}; 1970 | 1971 | if (lastBit){ 1972 | this.uniques = uniques; 1973 | this.found = found; 1974 | } else { 1975 | this.uniques = {}; 1976 | this.found = []; 1977 | } 1978 | 1979 | if (j === 0){ 1980 | this[combinator](context, tag, id, classes, attributes, pseudos, classList); 1981 | if (first && lastBit && found.length) break search; 1982 | } else { 1983 | if (first && lastBit) for (m = 0, n = currentItems.length; m < n; m++){ 1984 | this[combinator](currentItems[m], tag, id, classes, attributes, pseudos, classList); 1985 | if (found.length) break search; 1986 | } else for (m = 0, n = currentItems.length; m < n; m++) this[combinator](currentItems[m], tag, id, classes, attributes, pseudos, classList); 1987 | } 1988 | 1989 | currentItems = this.found; 1990 | } 1991 | 1992 | if (shouldUniques || (parsed.expressions.length > 1)) this.sort(found); 1993 | 1994 | return (first) ? (found[0] || null) : found; 1995 | }; 1996 | 1997 | // Utils 1998 | 1999 | local.uidx = 1; 2000 | local.uidk = 'slick:uniqueid'; 2001 | 2002 | local.getUIDXML = function(node){ 2003 | var uid = node.getAttribute(this.uidk); 2004 | if (!uid){ 2005 | uid = this.uidx++; 2006 | node.setAttribute(this.uidk, uid); 2007 | } 2008 | return uid; 2009 | }; 2010 | 2011 | local.getUIDHTML = function(node){ 2012 | return node.uniqueNumber || (node.uniqueNumber = this.uidx++); 2013 | }; 2014 | 2015 | // sort based on the setDocument documentSorter method. 2016 | 2017 | local.sort = function(results){ 2018 | if (!this.documentSorter) return results; 2019 | results.sort(this.documentSorter); 2020 | return results; 2021 | }; 2022 | 2023 | /**//**/ 2024 | 2025 | local.cacheNTH = {}; 2026 | 2027 | local.matchNTH = /^([+-]?\d*)?([a-z]+)?([+-]\d+)?$/; 2028 | 2029 | local.parseNTHArgument = function(argument){ 2030 | var parsed = argument.match(this.matchNTH); 2031 | if (!parsed) return false; 2032 | var special = parsed[2] || false; 2033 | var a = parsed[1] || 1; 2034 | if (a == '-') a = -1; 2035 | var b = +parsed[3] || 0; 2036 | parsed = 2037 | (special == 'n') ? {a: a, b: b} : 2038 | (special == 'odd') ? {a: 2, b: 1} : 2039 | (special == 'even') ? {a: 2, b: 0} : {a: 0, b: a}; 2040 | 2041 | return (this.cacheNTH[argument] = parsed); 2042 | }; 2043 | 2044 | local.createNTHPseudo = function(child, sibling, positions, ofType){ 2045 | return function(node, argument){ 2046 | var uid = this.getUID(node); 2047 | if (!this[positions][uid]){ 2048 | var parent = node.parentNode; 2049 | if (!parent) return false; 2050 | var el = parent[child], count = 1; 2051 | if (ofType){ 2052 | var nodeName = node.nodeName; 2053 | do { 2054 | if (el.nodeName !== nodeName) continue; 2055 | this[positions][this.getUID(el)] = count++; 2056 | } while ((el = el[sibling])); 2057 | } else { 2058 | do { 2059 | if (el.nodeType !== 1) continue; 2060 | this[positions][this.getUID(el)] = count++; 2061 | } while ((el = el[sibling])); 2062 | } 2063 | } 2064 | argument = argument || 'n'; 2065 | var parsed = this.cacheNTH[argument] || this.parseNTHArgument(argument); 2066 | if (!parsed) return false; 2067 | var a = parsed.a, b = parsed.b, pos = this[positions][uid]; 2068 | if (a == 0) return b == pos; 2069 | if (a > 0){ 2070 | if (pos < b) return false; 2071 | } else { 2072 | if (b < pos) return false; 2073 | } 2074 | return ((pos - b) % a) == 0; 2075 | }; 2076 | }; 2077 | 2078 | /**//**/ 2079 | 2080 | local.pushArray = function(node, tag, id, classes, attributes, pseudos){ 2081 | if (this.matchSelector(node, tag, id, classes, attributes, pseudos)) this.found.push(node); 2082 | }; 2083 | 2084 | local.pushUID = function(node, tag, id, classes, attributes, pseudos){ 2085 | var uid = this.getUID(node); 2086 | if (!this.uniques[uid] && this.matchSelector(node, tag, id, classes, attributes, pseudos)){ 2087 | this.uniques[uid] = true; 2088 | this.found.push(node); 2089 | } 2090 | }; 2091 | 2092 | local.matchNode = function(node, selector){ 2093 | var parsed = this.Slick.parse(selector); 2094 | if (!parsed) return true; 2095 | 2096 | // simple (single) selectors 2097 | if(parsed.length == 1 && parsed.expressions[0].length == 1){ 2098 | var exp = parsed.expressions[0][0]; 2099 | return this.matchSelector(node, (this.isXMLDocument) ? exp.tag : exp.tag.toUpperCase(), exp.id, exp.classes, exp.attributes, exp.pseudos); 2100 | } 2101 | 2102 | var nodes = this.search(this.document, parsed); 2103 | for (var i = 0, item; item = nodes[i++];){ 2104 | if (item === node) return true; 2105 | } 2106 | return false; 2107 | }; 2108 | 2109 | local.matchPseudo = function(node, name, argument){ 2110 | var pseudoName = 'pseudo:' + name; 2111 | if (this[pseudoName]) return this[pseudoName](node, argument); 2112 | var attribute = this.getAttribute(node, name); 2113 | return (argument) ? argument == attribute : !!attribute; 2114 | }; 2115 | 2116 | local.matchSelector = function(node, tag, id, classes, attributes, pseudos){ 2117 | if (tag){ 2118 | if (tag == '*'){ 2119 | if (node.nodeName < '@') return false; // Fix for comment nodes and closed nodes 2120 | } else { 2121 | if (node.nodeName != tag) return false; 2122 | } 2123 | } 2124 | 2125 | if (id && node.getAttribute('id') != id) return false; 2126 | 2127 | var i, part, cls; 2128 | if (classes) for (i = classes.length; i--;){ 2129 | cls = ('className' in node) ? node.className : node.getAttribute('class'); 2130 | if (!(cls && classes[i].regexp.test(cls))) return false; 2131 | } 2132 | if (attributes) for (i = attributes.length; i--;){ 2133 | part = attributes[i]; 2134 | if (part.operator ? !part.test(this.getAttribute(node, part.key)) : !this.hasAttribute(node, part.key)) return false; 2135 | } 2136 | if (pseudos) for (i = pseudos.length; i--;){ 2137 | part = pseudos[i]; 2138 | if (!this.matchPseudo(node, part.key, part.value)) return false; 2139 | } 2140 | return true; 2141 | }; 2142 | 2143 | var combinators = { 2144 | 2145 | ' ': function(node, tag, id, classes, attributes, pseudos, classList){ // all child nodes, any level 2146 | 2147 | var i, item, children; 2148 | 2149 | if (this.isHTMLDocument){ 2150 | getById: if (id){ 2151 | item = this.document.getElementById(id); 2152 | if ((!item && node.all) || (this.idGetsName && item && item.getAttributeNode('id').nodeValue != id)){ 2153 | // all[id] returns all the elements with that name or id inside node 2154 | // if theres just one it will return the element, else it will be a collection 2155 | children = node.all[id]; 2156 | if (!children) return; 2157 | if (!children[0]) children = [children]; 2158 | for (i = 0; item = children[i++];) if (item.getAttributeNode('id').nodeValue == id){ 2159 | this.push(item, tag, null, classes, attributes, pseudos); 2160 | break; 2161 | } 2162 | return; 2163 | } 2164 | if (!item){ 2165 | // if the context is in the dom we return, else we will try GEBTN, breaking the getById label 2166 | if (this.contains(this.document.documentElement, node)) return; 2167 | else break getById; 2168 | } else if (this.document !== node && !this.contains(node, item)) return; 2169 | this.push(item, tag, null, classes, attributes, pseudos); 2170 | return; 2171 | } 2172 | getByClass: if (classes && node.getElementsByClassName && !this.brokenGEBCN){ 2173 | children = node.getElementsByClassName(classList.join(' ')); 2174 | if (!(children && children.length)) break getByClass; 2175 | for (i = 0; item = children[i++];) this.push(item, tag, id, null, attributes, pseudos); 2176 | return; 2177 | } 2178 | } 2179 | getByTag: { 2180 | children = node.getElementsByTagName(tag); 2181 | if (!(children && children.length)) break getByTag; 2182 | if (!this.brokenStarGEBTN) tag = null; 2183 | for (i = 0; item = children[i++];) this.push(item, tag, id, classes, attributes, pseudos); 2184 | } 2185 | }, 2186 | 2187 | '>': function(node, tag, id, classes, attributes, pseudos){ // direct children 2188 | if ((node = node.firstChild)) do { 2189 | if (node.nodeType === 1) this.push(node, tag, id, classes, attributes, pseudos); 2190 | } while ((node = node.nextSibling)); 2191 | }, 2192 | 2193 | '+': function(node, tag, id, classes, attributes, pseudos){ // next sibling 2194 | while ((node = node.nextSibling)) if (node.nodeType === 1){ 2195 | this.push(node, tag, id, classes, attributes, pseudos); 2196 | break; 2197 | } 2198 | }, 2199 | 2200 | '^': function(node, tag, id, classes, attributes, pseudos){ // first child 2201 | node = node.firstChild; 2202 | if (node){ 2203 | if (node.nodeType === 1) this.push(node, tag, id, classes, attributes, pseudos); 2204 | else this['combinator:+'](node, tag, id, classes, attributes, pseudos); 2205 | } 2206 | }, 2207 | 2208 | '~': function(node, tag, id, classes, attributes, pseudos){ // next siblings 2209 | while ((node = node.nextSibling)){ 2210 | if (node.nodeType !== 1) continue; 2211 | var uid = this.getUID(node); 2212 | if (this.bitUniques[uid]) break; 2213 | this.bitUniques[uid] = true; 2214 | this.push(node, tag, id, classes, attributes, pseudos); 2215 | } 2216 | }, 2217 | 2218 | '++': function(node, tag, id, classes, attributes, pseudos){ // next sibling and previous sibling 2219 | this['combinator:+'](node, tag, id, classes, attributes, pseudos); 2220 | this['combinator:!+'](node, tag, id, classes, attributes, pseudos); 2221 | }, 2222 | 2223 | '~~': function(node, tag, id, classes, attributes, pseudos){ // next siblings and previous siblings 2224 | this['combinator:~'](node, tag, id, classes, attributes, pseudos); 2225 | this['combinator:!~'](node, tag, id, classes, attributes, pseudos); 2226 | }, 2227 | 2228 | '!': function(node, tag, id, classes, attributes, pseudos){ // all parent nodes up to document 2229 | while ((node = node.parentNode)) if (node !== this.document) this.push(node, tag, id, classes, attributes, pseudos); 2230 | }, 2231 | 2232 | '!>': function(node, tag, id, classes, attributes, pseudos){ // direct parent (one level) 2233 | node = node.parentNode; 2234 | if (node !== this.document) this.push(node, tag, id, classes, attributes, pseudos); 2235 | }, 2236 | 2237 | '!+': function(node, tag, id, classes, attributes, pseudos){ // previous sibling 2238 | while ((node = node.previousSibling)) if (node.nodeType === 1){ 2239 | this.push(node, tag, id, classes, attributes, pseudos); 2240 | break; 2241 | } 2242 | }, 2243 | 2244 | '!^': function(node, tag, id, classes, attributes, pseudos){ // last child 2245 | node = node.lastChild; 2246 | if (node){ 2247 | if (node.nodeType === 1) this.push(node, tag, id, classes, attributes, pseudos); 2248 | else this['combinator:!+'](node, tag, id, classes, attributes, pseudos); 2249 | } 2250 | }, 2251 | 2252 | '!~': function(node, tag, id, classes, attributes, pseudos){ // previous siblings 2253 | while ((node = node.previousSibling)){ 2254 | if (node.nodeType !== 1) continue; 2255 | var uid = this.getUID(node); 2256 | if (this.bitUniques[uid]) break; 2257 | this.bitUniques[uid] = true; 2258 | this.push(node, tag, id, classes, attributes, pseudos); 2259 | } 2260 | } 2261 | 2262 | }; 2263 | 2264 | for (var c in combinators) local['combinator:' + c] = combinators[c]; 2265 | 2266 | var pseudos = { 2267 | 2268 | /**/ 2269 | 2270 | 'empty': function(node){ 2271 | var child = node.firstChild; 2272 | return !(child && child.nodeType == 1) && !(node.innerText || node.textContent || '').length; 2273 | }, 2274 | 2275 | 'not': function(node, expression){ 2276 | return !this.matchNode(node, expression); 2277 | }, 2278 | 2279 | 'contains': function(node, text){ 2280 | return (node.innerText || node.textContent || '').indexOf(text) > -1; 2281 | }, 2282 | 2283 | 'first-child': function(node){ 2284 | while ((node = node.previousSibling)) if (node.nodeType === 1) return false; 2285 | return true; 2286 | }, 2287 | 2288 | 'last-child': function(node){ 2289 | while ((node = node.nextSibling)) if (node.nodeType === 1) return false; 2290 | return true; 2291 | }, 2292 | 2293 | 'only-child': function(node){ 2294 | var prev = node; 2295 | while ((prev = prev.previousSibling)) if (prev.nodeType === 1) return false; 2296 | var next = node; 2297 | while ((next = next.nextSibling)) if (next.nodeType === 1) return false; 2298 | return true; 2299 | }, 2300 | 2301 | /**/ 2302 | 2303 | 'nth-child': local.createNTHPseudo('firstChild', 'nextSibling', 'posNTH'), 2304 | 2305 | 'nth-last-child': local.createNTHPseudo('lastChild', 'previousSibling', 'posNTHLast'), 2306 | 2307 | 'nth-of-type': local.createNTHPseudo('firstChild', 'nextSibling', 'posNTHType', true), 2308 | 2309 | 'nth-last-of-type': local.createNTHPseudo('lastChild', 'previousSibling', 'posNTHTypeLast', true), 2310 | 2311 | 'index': function(node, index){ 2312 | return this['pseudo:nth-child'](node, '' + index + 1); 2313 | }, 2314 | 2315 | 'even': function(node, argument){ 2316 | return this['pseudo:nth-child'](node, '2n'); 2317 | }, 2318 | 2319 | 'odd': function(node, argument){ 2320 | return this['pseudo:nth-child'](node, '2n+1'); 2321 | }, 2322 | 2323 | /**/ 2324 | 2325 | /**/ 2326 | 2327 | 'first-of-type': function(node){ 2328 | var nodeName = node.nodeName; 2329 | while ((node = node.previousSibling)) if (node.nodeName === nodeName) return false; 2330 | return true; 2331 | }, 2332 | 2333 | 'last-of-type': function(node){ 2334 | var nodeName = node.nodeName; 2335 | while ((node = node.nextSibling)) if (node.nodeName === nodeName) return false; 2336 | return true; 2337 | }, 2338 | 2339 | 'only-of-type': function(node){ 2340 | var prev = node, nodeName = node.nodeName; 2341 | while ((prev = prev.previousSibling)) if (prev.nodeName === nodeName) return false; 2342 | var next = node; 2343 | while ((next = next.nextSibling)) if (next.nodeName === nodeName) return false; 2344 | return true; 2345 | }, 2346 | 2347 | /**/ 2348 | 2349 | // custom pseudos 2350 | 2351 | 'enabled': function(node){ 2352 | return (node.disabled === false); 2353 | }, 2354 | 2355 | 'disabled': function(node){ 2356 | return (node.disabled === true); 2357 | }, 2358 | 2359 | 'checked': function(node){ 2360 | return node.checked || node.selected; 2361 | }, 2362 | 2363 | 'focus': function(node){ 2364 | return this.isHTMLDocument && this.document.activeElement === node && (node.href || node.type || this.hasAttribute(node, 'tabindex')); 2365 | }, 2366 | 2367 | 'root': function(node){ 2368 | return (node === this.root); 2369 | }, 2370 | 2371 | 'selected': function(node){ 2372 | return node.selected; 2373 | } 2374 | 2375 | /**/ 2376 | }; 2377 | 2378 | for (var p in pseudos) local['pseudo:' + p] = pseudos[p]; 2379 | 2380 | // attributes methods 2381 | 2382 | local.attributeGetters = { 2383 | 2384 | 'class': function(){ 2385 | return ('className' in this) ? this.className : this.getAttribute('class'); 2386 | }, 2387 | 2388 | 'for': function(){ 2389 | return ('htmlFor' in this) ? this.htmlFor : this.getAttribute('for'); 2390 | }, 2391 | 2392 | 'href': function(){ 2393 | return ('href' in this) ? this.getAttribute('href', 2) : this.getAttribute('href'); 2394 | }, 2395 | 2396 | 'style': function(){ 2397 | return (this.style) ? this.style.cssText : this.getAttribute('style'); 2398 | } 2399 | 2400 | }; 2401 | 2402 | local.getAttribute = function(node, name){ 2403 | // FIXME: check if getAttribute() will get input elements on a form on this browser 2404 | // getAttribute is faster than getAttributeNode().nodeValue 2405 | var method = this.attributeGetters[name]; 2406 | if (method) return method.call(node); 2407 | var attributeNode = node.getAttributeNode(name); 2408 | return attributeNode ? attributeNode.nodeValue : null; 2409 | }; 2410 | 2411 | // overrides 2412 | 2413 | local.overrides = []; 2414 | 2415 | local.override = function(regexp, method){ 2416 | this.overrides.push({regexp: regexp, method: method}); 2417 | }; 2418 | 2419 | /**/ 2420 | 2421 | /**/ 2422 | 2423 | var reEmptyAttribute = /\[.*[*$^]=(?:["']{2})?\]/; 2424 | 2425 | local.override(/./, function(expression, found, first){ //querySelectorAll override 2426 | 2427 | if (!this.querySelectorAll || this.nodeType != 9 || !local.isHTMLDocument || local.brokenMixedCaseQSA || 2428 | (local.brokenCheckedQSA && expression.indexOf(':checked') > -1) || 2429 | (local.brokenEmptyAttributeQSA && reEmptyAttribute.test(expression)) || Slick.disableQSA) return false; 2430 | 2431 | var nodes, node; 2432 | try { 2433 | if (first) return this.querySelector(expression) || null; 2434 | else nodes = this.querySelectorAll(expression); 2435 | } catch(error){ 2436 | return false; 2437 | } 2438 | 2439 | var i, hasOthers = !!(found.length); 2440 | 2441 | if (local.starSelectsClosedQSA) for (i = 0; node = nodes[i++];){ 2442 | if (node.nodeName > '@' && (!hasOthers || !local.uniques[local.getUIDHTML(node)])) found.push(node); 2443 | } else for (i = 0; node = nodes[i++];){ 2444 | if (!hasOthers || !local.uniques[local.getUIDHTML(node)]) found.push(node); 2445 | } 2446 | 2447 | if (hasOthers) local.sort(found); 2448 | 2449 | return true; 2450 | 2451 | }); 2452 | 2453 | /**/ 2454 | 2455 | /**/ 2456 | 2457 | local.override(/^[\w-]+$|^\*$/, function(expression, found, first){ // tag override 2458 | var tag = expression; 2459 | if (tag == '*' && local.brokenStarGEBTN) return false; 2460 | 2461 | var nodes = this.getElementsByTagName(tag); 2462 | 2463 | if (first) return nodes[0] || null; 2464 | var i, node, hasOthers = !!(found.length); 2465 | 2466 | for (i = 0; node = nodes[i++];){ 2467 | if (!hasOthers || !local.uniques[local.getUID(node)]) found.push(node); 2468 | } 2469 | 2470 | if (hasOthers) local.sort(found); 2471 | 2472 | return true; 2473 | }); 2474 | 2475 | /**/ 2476 | 2477 | /**/ 2478 | 2479 | local.override(/^\.[\w-]+$/, function(expression, found, first){ // class override 2480 | if (!local.isHTMLDocument || (!this.getElementsByClassName && this.querySelectorAll)) return false; 2481 | 2482 | var nodes, node, i, hasOthers = !!(found && found.length), className = expression.substring(1); 2483 | if (this.getElementsByClassName && !local.brokenGEBCN){ 2484 | nodes = this.getElementsByClassName(className); 2485 | if (first) return nodes[0] || null; 2486 | for (i = 0; node = nodes[i++];){ 2487 | if (!hasOthers || !local.uniques[local.getUIDHTML(node)]) found.push(node); 2488 | } 2489 | } else { 2490 | var matchClass = new RegExp('(^|\\s)'+ Slick.escapeRegExp(className) +'(\\s|$)'); 2491 | nodes = this.getElementsByTagName('*'); 2492 | for (i = 0; node = nodes[i++];){ 2493 | className = node.className; 2494 | if (!className || !matchClass.test(className)) continue; 2495 | if (first) return node; 2496 | if (!hasOthers || !local.uniques[local.getUIDHTML(node)]) found.push(node); 2497 | } 2498 | } 2499 | if (hasOthers) local.sort(found); 2500 | return (first) ? null : true; 2501 | }); 2502 | 2503 | /**/ 2504 | 2505 | /**/ 2506 | 2507 | local.override(/^#[\w-]+$/, function(expression, found, first){ // ID override 2508 | if (!local.isHTMLDocument || this.nodeType != 9) return false; 2509 | 2510 | var id = expression.substring(1), el = this.getElementById(id); 2511 | if (!el) return found; 2512 | if (local.idGetsName && el.getAttributeNode('id').nodeValue != id) return false; 2513 | if (first) return el || null; 2514 | var hasOthers = !!(found.length); 2515 | if (!hasOthers || !local.uniques[local.getUIDHTML(el)]) found.push(el); 2516 | if (hasOthers) local.sort(found); 2517 | return true; 2518 | }); 2519 | 2520 | /**/ 2521 | 2522 | /**/ 2523 | 2524 | if (typeof document != 'undefined') local.setDocument(document); 2525 | 2526 | // Slick 2527 | 2528 | var Slick = local.Slick = (this.Slick || {}); 2529 | 2530 | Slick.version = '0.9dev'; 2531 | 2532 | // Slick finder 2533 | 2534 | Slick.search = function(context, expression, append){ 2535 | return local.search(context, expression, append); 2536 | }; 2537 | 2538 | Slick.find = function(context, expression){ 2539 | return local.search(context, expression, null, true); 2540 | }; 2541 | 2542 | // Slick containment checker 2543 | 2544 | Slick.contains = function(container, node){ 2545 | local.setDocument(container); 2546 | return local.contains(container, node); 2547 | }; 2548 | 2549 | // Slick attribute getter 2550 | 2551 | Slick.getAttribute = function(node, name){ 2552 | return local.getAttribute(node, name); 2553 | }; 2554 | 2555 | // Slick matcher 2556 | 2557 | Slick.match = function(node, selector){ 2558 | if (!(node && selector)) return false; 2559 | if (!selector || selector === node) return true; 2560 | if (typeof selector != 'string') return false; 2561 | local.setDocument(node); 2562 | return local.matchNode(node, selector); 2563 | }; 2564 | 2565 | // Slick attribute accessor 2566 | 2567 | Slick.defineAttributeGetter = function(name, fn){ 2568 | local.attributeGetters[name] = fn; 2569 | return this; 2570 | }; 2571 | 2572 | Slick.lookupAttributeGetter = function(name){ 2573 | return local.attributeGetters[name]; 2574 | }; 2575 | 2576 | // Slick pseudo accessor 2577 | 2578 | Slick.definePseudo = function(name, fn){ 2579 | local['pseudo:' + name] = function(node, argument){ 2580 | return fn.call(node, argument); 2581 | }; 2582 | return this; 2583 | }; 2584 | 2585 | Slick.lookupPseudo = function(name){ 2586 | var pseudo = local['pseudo:' + name]; 2587 | if (pseudo) return function(argument){ 2588 | return pseudo.call(this, argument); 2589 | }; 2590 | return null; 2591 | }; 2592 | 2593 | // Slick overrides accessor 2594 | 2595 | Slick.override = function(regexp, fn){ 2596 | local.override(regexp, fn); 2597 | return this; 2598 | }; 2599 | 2600 | Slick.isXML = local.isXML; 2601 | 2602 | Slick.uidOf = function(node){ 2603 | return local.getUIDHTML(node); 2604 | }; 2605 | 2606 | if (!this.Slick) this.Slick = Slick; 2607 | 2608 | }).apply(/**/(typeof exports != 'undefined') ? exports : /**/this); 2609 | 2610 | 2611 | /* 2612 | --- 2613 | 2614 | name: Element 2615 | 2616 | description: One of the most important items in MooTools. Contains the dollar function, the dollars function, and an handful of cross-browser, time-saver methods to let you easily work with HTML Elements. 2617 | 2618 | license: MIT-style license. 2619 | 2620 | requires: [Window, Document, Array, String, Function, Number, Slick.Parser, Slick.Finder] 2621 | 2622 | provides: [Element, Elements, $, $$, Iframe, Selectors] 2623 | 2624 | ... 2625 | */ 2626 | 2627 | var Element = function(tag, props){ 2628 | var konstructor = Element.Constructors[tag]; 2629 | if (konstructor) return konstructor(props); 2630 | if (typeof tag != 'string') return document.id(tag).set(props); 2631 | 2632 | if (!props) props = {}; 2633 | 2634 | if (!tag.test(/^[\w-]+$/)){ 2635 | var parsed = Slick.parse(tag).expressions[0][0]; 2636 | tag = (parsed.tag == '*') ? 'div' : parsed.tag; 2637 | if (parsed.id && props.id == null) props.id = parsed.id; 2638 | 2639 | var attributes = parsed.attributes; 2640 | if (attributes) for (var i = 0, l = attributes.length; i < l; i++){ 2641 | var attr = attributes[i]; 2642 | if (attr.value != null && attr.operator == '=' && props[attr.key] == null) 2643 | props[attr.key] = attr.value; 2644 | } 2645 | 2646 | if (parsed.classList && props['class'] == null) props['class'] = parsed.classList.join(' '); 2647 | } 2648 | 2649 | return document.newElement(tag, props); 2650 | }; 2651 | 2652 | if (Browser.Element) Element.prototype = Browser.Element.prototype; 2653 | 2654 | new Type('Element', Element).mirror(function(name){ 2655 | if (Array.prototype[name]) return; 2656 | 2657 | var obj = {}; 2658 | obj[name] = function(){ 2659 | var results = [], args = arguments, elements = true; 2660 | for (var i = 0, l = this.length; i < l; i++){ 2661 | var element = this[i], result = results[i] = element[name].apply(element, args); 2662 | elements = (elements && typeOf(result) == 'element'); 2663 | } 2664 | return (elements) ? new Elements(results) : results; 2665 | }; 2666 | 2667 | Elements.implement(obj); 2668 | }); 2669 | 2670 | if (!Browser.Element){ 2671 | Element.parent = Object; 2672 | 2673 | Element.Prototype = {'$family': Function.from('element').hide()}; 2674 | 2675 | Element.mirror(function(name, method){ 2676 | Element.Prototype[name] = method; 2677 | }); 2678 | } 2679 | 2680 | Element.Constructors = {}; 2681 | 2682 | 2683 | 2684 | var IFrame = new Type('IFrame', function(){ 2685 | var params = Array.link(arguments, { 2686 | properties: Type.isObject, 2687 | iframe: function(obj){ 2688 | return (obj != null); 2689 | } 2690 | }); 2691 | 2692 | var props = params.properties || {}, iframe; 2693 | if (params.iframe) iframe = document.id(params.iframe); 2694 | var onload = props.onload || function(){}; 2695 | delete props.onload; 2696 | props.id = props.name = [props.id, props.name, iframe ? (iframe.id || iframe.name) : 'IFrame_' + String.uniqueID()].pick(); 2697 | iframe = new Element(iframe || 'iframe', props); 2698 | 2699 | var onLoad = function(){ 2700 | onload.call(iframe.contentWindow); 2701 | }; 2702 | 2703 | if (window.frames[props.id]) onLoad(); 2704 | else iframe.addListener('load', onLoad); 2705 | return iframe; 2706 | }); 2707 | 2708 | var Elements = this.Elements = function(nodes){ 2709 | if (nodes && nodes.length){ 2710 | var uniques = {}, node; 2711 | for (var i = 0; node = nodes[i++];){ 2712 | var uid = Slick.uidOf(node); 2713 | if (!uniques[uid]){ 2714 | uniques[uid] = true; 2715 | this.push(node); 2716 | } 2717 | } 2718 | } 2719 | }; 2720 | 2721 | Elements.prototype = {length: 0}; 2722 | Elements.parent = Array; 2723 | 2724 | new Type('Elements', Elements).implement({ 2725 | 2726 | filter: function(filter, bind){ 2727 | if (!filter) return this; 2728 | return new Elements(Array.filter(this, (typeOf(filter) == 'string') ? function(item){ 2729 | return item.match(filter); 2730 | } : filter, bind)); 2731 | }.protect(), 2732 | 2733 | push: function(){ 2734 | var length = this.length; 2735 | for (var i = 0, l = arguments.length; i < l; i++){ 2736 | var item = document.id(arguments[i]); 2737 | if (item) this[length++] = item; 2738 | } 2739 | return (this.length = length); 2740 | }.protect(), 2741 | 2742 | concat: function(){ 2743 | var newElements = new Elements(this); 2744 | for (var i = 0, l = arguments.length; i < l; i++){ 2745 | var item = arguments[i]; 2746 | if (Type.isEnumerable(item)) newElements.append(item); 2747 | else newElements.push(item); 2748 | } 2749 | return newElements; 2750 | }.protect(), 2751 | 2752 | append: function(collection){ 2753 | for (var i = 0, l = collection.length; i < l; i++) this.push(collection[i]); 2754 | return this; 2755 | }.protect(), 2756 | 2757 | empty: function(){ 2758 | while (this.length) delete this[--this.length]; 2759 | return this; 2760 | }.protect() 2761 | 2762 | }); 2763 | 2764 | (function(){ 2765 | 2766 | // FF, IE 2767 | var splice = Array.prototype.splice, object = {'0': 0, '1': 1, length: 2}; 2768 | 2769 | splice.call(object, 1, 1); 2770 | if (object[1] == 1) Elements.implement('splice', function(){ 2771 | var length = this.length; 2772 | splice.apply(this, arguments); 2773 | while (length >= this.length) delete this[length--]; 2774 | return this; 2775 | }.protect()); 2776 | 2777 | Elements.implement(Array.prototype); 2778 | 2779 | Array.mirror(Elements); 2780 | 2781 | /**/ 2782 | var createElementAcceptsHTML; 2783 | try { 2784 | var x = document.createElement(''); 2785 | createElementAcceptsHTML = (x.name == 'x'); 2786 | } catch(e){} 2787 | 2788 | var escapeQuotes = function(html){ 2789 | return ('' + html).replace(/&/g, '&').replace(/"/g, '"'); 2790 | }; 2791 | /**/ 2792 | 2793 | Document.implement({ 2794 | 2795 | newElement: function(tag, props){ 2796 | if (props && props.checked != null) props.defaultChecked = props.checked; 2797 | /**/// Fix for readonly name and type properties in IE < 8 2798 | if (createElementAcceptsHTML && props){ 2799 | tag = '<' + tag; 2800 | if (props.name) tag += ' name="' + escapeQuotes(props.name) + '"'; 2801 | if (props.type) tag += ' type="' + escapeQuotes(props.type) + '"'; 2802 | tag += '>'; 2803 | delete props.name; 2804 | delete props.type; 2805 | } 2806 | /**/ 2807 | return this.id(this.createElement(tag)).set(props); 2808 | } 2809 | 2810 | }); 2811 | 2812 | })(); 2813 | 2814 | Document.implement({ 2815 | 2816 | newTextNode: function(text){ 2817 | return this.createTextNode(text); 2818 | }, 2819 | 2820 | getDocument: function(){ 2821 | return this; 2822 | }, 2823 | 2824 | getWindow: function(){ 2825 | return this.window; 2826 | }, 2827 | 2828 | id: (function(){ 2829 | 2830 | var types = { 2831 | 2832 | string: function(id, nocash, doc){ 2833 | id = Slick.find(doc, '#' + id.replace(/(\W)/g, '\\$1')); 2834 | return (id) ? types.element(id, nocash) : null; 2835 | }, 2836 | 2837 | element: function(el, nocash){ 2838 | $uid(el); 2839 | if (!nocash && !el.$family && !(/^object|embed$/i).test(el.tagName)){ 2840 | Object.append(el, Element.Prototype); 2841 | } 2842 | return el; 2843 | }, 2844 | 2845 | object: function(obj, nocash, doc){ 2846 | if (obj.toElement) return types.element(obj.toElement(doc), nocash); 2847 | return null; 2848 | } 2849 | 2850 | }; 2851 | 2852 | types.textnode = types.whitespace = types.window = types.document = function(zero){ 2853 | return zero; 2854 | }; 2855 | 2856 | return function(el, nocash, doc){ 2857 | if (el && el.$family && el.uid) return el; 2858 | var type = typeOf(el); 2859 | return (types[type]) ? types[type](el, nocash, doc || document) : null; 2860 | }; 2861 | 2862 | })() 2863 | 2864 | }); 2865 | 2866 | if (window.$ == null) Window.implement('$', function(el, nc){ 2867 | return document.id(el, nc, this.document); 2868 | }); 2869 | 2870 | Window.implement({ 2871 | 2872 | getDocument: function(){ 2873 | return this.document; 2874 | }, 2875 | 2876 | getWindow: function(){ 2877 | return this; 2878 | } 2879 | 2880 | }); 2881 | 2882 | [Document, Element].invoke('implement', { 2883 | 2884 | getElements: function(expression){ 2885 | return Slick.search(this, expression, new Elements); 2886 | }, 2887 | 2888 | getElement: function(expression){ 2889 | return document.id(Slick.find(this, expression)); 2890 | } 2891 | 2892 | }); 2893 | 2894 | 2895 | 2896 | if (window.$$ == null) Window.implement('$$', function(selector){ 2897 | if (arguments.length == 1){ 2898 | if (typeof selector == 'string') return Slick.search(this.document, selector, new Elements); 2899 | else if (Type.isEnumerable(selector)) return new Elements(selector); 2900 | } 2901 | return new Elements(arguments); 2902 | }); 2903 | 2904 | (function(){ 2905 | 2906 | var collected = {}, storage = {}; 2907 | var props = {input: 'checked', option: 'selected', textarea: 'value'}; 2908 | 2909 | var get = function(uid){ 2910 | return (storage[uid] || (storage[uid] = {})); 2911 | }; 2912 | 2913 | var clean = function(item){ 2914 | if (item.removeEvents) item.removeEvents(); 2915 | if (item.clearAttributes) item.clearAttributes(); 2916 | var uid = item.uid; 2917 | if (uid != null){ 2918 | delete collected[uid]; 2919 | delete storage[uid]; 2920 | } 2921 | return item; 2922 | }; 2923 | 2924 | var camels = ['defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan', 'frameBorder', 'maxLength', 'readOnly', 2925 | 'rowSpan', 'tabIndex', 'useMap' 2926 | ]; 2927 | var bools = ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readOnly', 'multiple', 'selected', 2928 | 'noresize', 'defer' 2929 | ]; 2930 | var attributes = { 2931 | 'html': 'innerHTML', 2932 | 'class': 'className', 2933 | 'for': 'htmlFor', 2934 | 'text': (function(){ 2935 | var temp = document.createElement('div'); 2936 | return (temp.innerText == null) ? 'textContent' : 'innerText'; 2937 | })() 2938 | }; 2939 | var readOnly = ['type']; 2940 | var expandos = ['value', 'defaultValue']; 2941 | var uriAttrs = /^(?:href|src|usemap)$/i; 2942 | 2943 | bools = bools.associate(bools); 2944 | camels = camels.associate(camels.map(String.toLowerCase)); 2945 | readOnly = readOnly.associate(readOnly); 2946 | 2947 | Object.append(attributes, expandos.associate(expandos)); 2948 | 2949 | var inserters = { 2950 | 2951 | before: function(context, element){ 2952 | var parent = element.parentNode; 2953 | if (parent) parent.insertBefore(context, element); 2954 | }, 2955 | 2956 | after: function(context, element){ 2957 | var parent = element.parentNode; 2958 | if (parent) parent.insertBefore(context, element.nextSibling); 2959 | }, 2960 | 2961 | bottom: function(context, element){ 2962 | element.appendChild(context); 2963 | }, 2964 | 2965 | top: function(context, element){ 2966 | element.insertBefore(context, element.firstChild); 2967 | } 2968 | 2969 | }; 2970 | 2971 | inserters.inside = inserters.bottom; 2972 | 2973 | 2974 | 2975 | var injectCombinator = function(expression, combinator){ 2976 | if (!expression) return combinator; 2977 | 2978 | expression = Slick.parse(expression); 2979 | 2980 | var expressions = expression.expressions; 2981 | for (var i = expressions.length; i--;) 2982 | expressions[i][0].combinator = combinator; 2983 | 2984 | return expression; 2985 | }; 2986 | 2987 | Element.implement({ 2988 | 2989 | set: function(prop, value){ 2990 | var property = Element.Properties[prop]; 2991 | (property && property.set) ? property.set.call(this, value) : this.setProperty(prop, value); 2992 | }.overloadSetter(), 2993 | 2994 | get: function(prop){ 2995 | var property = Element.Properties[prop]; 2996 | return (property && property.get) ? property.get.apply(this) : this.getProperty(prop); 2997 | }.overloadGetter(), 2998 | 2999 | erase: function(prop){ 3000 | var property = Element.Properties[prop]; 3001 | (property && property.erase) ? property.erase.apply(this) : this.removeProperty(prop); 3002 | return this; 3003 | }, 3004 | 3005 | setProperty: function(attribute, value){ 3006 | attribute = camels[attribute] || attribute; 3007 | if (value == null) return this.removeProperty(attribute); 3008 | var key = attributes[attribute]; 3009 | (key) ? this[key] = value : 3010 | (bools[attribute]) ? this[attribute] = !!value : this.setAttribute(attribute, '' + value); 3011 | return this; 3012 | }, 3013 | 3014 | setProperties: function(attributes){ 3015 | for (var attribute in attributes) this.setProperty(attribute, attributes[attribute]); 3016 | return this; 3017 | }, 3018 | 3019 | getProperty: function(attribute){ 3020 | attribute = camels[attribute] || attribute; 3021 | var key = attributes[attribute] || readOnly[attribute]; 3022 | return (key) ? this[key] : 3023 | (bools[attribute]) ? !!this[attribute] : 3024 | (uriAttrs.test(attribute) ? this.getAttribute(attribute, 2) : 3025 | (key = this.getAttributeNode(attribute)) ? key.nodeValue : null) || null; 3026 | }, 3027 | 3028 | getProperties: function(){ 3029 | var args = Array.from(arguments); 3030 | return args.map(this.getProperty, this).associate(args); 3031 | }, 3032 | 3033 | removeProperty: function(attribute){ 3034 | attribute = camels[attribute] || attribute; 3035 | var key = attributes[attribute]; 3036 | (key) ? this[key] = '' : 3037 | (bools[attribute]) ? this[attribute] = false : this.removeAttribute(attribute); 3038 | return this; 3039 | }, 3040 | 3041 | removeProperties: function(){ 3042 | Array.each(arguments, this.removeProperty, this); 3043 | return this; 3044 | }, 3045 | 3046 | hasClass: function(className){ 3047 | return this.className.clean().contains(className, ' '); 3048 | }, 3049 | 3050 | addClass: function(className){ 3051 | if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean(); 3052 | return this; 3053 | }, 3054 | 3055 | removeClass: function(className){ 3056 | this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1'); 3057 | return this; 3058 | }, 3059 | 3060 | toggleClass: function(className, force){ 3061 | if (force == null) force = !this.hasClass(className); 3062 | return (force) ? this.addClass(className) : this.removeClass(className); 3063 | }, 3064 | 3065 | adopt: function(){ 3066 | var parent = this, fragment, elements = Array.flatten(arguments), length = elements.length; 3067 | if (length > 1) parent = fragment = document.createDocumentFragment(); 3068 | 3069 | for (var i = 0; i < length; i++){ 3070 | var element = document.id(elements[i], true); 3071 | if (element) parent.appendChild(element); 3072 | } 3073 | 3074 | if (fragment) this.appendChild(fragment); 3075 | 3076 | return this; 3077 | }, 3078 | 3079 | appendText: function(text, where){ 3080 | return this.grab(this.getDocument().newTextNode(text), where); 3081 | }, 3082 | 3083 | grab: function(el, where){ 3084 | inserters[where || 'bottom'](document.id(el, true), this); 3085 | return this; 3086 | }, 3087 | 3088 | inject: function(el, where){ 3089 | inserters[where || 'bottom'](this, document.id(el, true)); 3090 | return this; 3091 | }, 3092 | 3093 | replaces: function(el){ 3094 | el = document.id(el, true); 3095 | el.parentNode.replaceChild(this, el); 3096 | return this; 3097 | }, 3098 | 3099 | wraps: function(el, where){ 3100 | el = document.id(el, true); 3101 | return this.replaces(el).grab(el, where); 3102 | }, 3103 | 3104 | getPrevious: function(expression){ 3105 | return document.id(Slick.find(this, injectCombinator(expression, '!~'))); 3106 | }, 3107 | 3108 | getAllPrevious: function(expression){ 3109 | return Slick.search(this, injectCombinator(expression, '!~'), new Elements); 3110 | }, 3111 | 3112 | getNext: function(expression){ 3113 | return document.id(Slick.find(this, injectCombinator(expression, '~'))); 3114 | }, 3115 | 3116 | getAllNext: function(expression){ 3117 | return Slick.search(this, injectCombinator(expression, '~'), new Elements); 3118 | }, 3119 | 3120 | getFirst: function(expression){ 3121 | return document.id(Slick.search(this, injectCombinator(expression, '>'))[0]); 3122 | }, 3123 | 3124 | getLast: function(expression){ 3125 | return document.id(Slick.search(this, injectCombinator(expression, '>')).getLast()); 3126 | }, 3127 | 3128 | getParent: function(expression){ 3129 | return document.id(Slick.find(this, injectCombinator(expression, '!'))); 3130 | }, 3131 | 3132 | getParents: function(expression){ 3133 | return Slick.search(this, injectCombinator(expression, '!'), new Elements); 3134 | }, 3135 | 3136 | getSiblings: function(expression){ 3137 | return Slick.search(this, injectCombinator(expression, '~~'), new Elements); 3138 | }, 3139 | 3140 | getChildren: function(expression){ 3141 | return Slick.search(this, injectCombinator(expression, '>'), new Elements); 3142 | }, 3143 | 3144 | getWindow: function(){ 3145 | return this.ownerDocument.window; 3146 | }, 3147 | 3148 | getDocument: function(){ 3149 | return this.ownerDocument; 3150 | }, 3151 | 3152 | getElementById: function(id){ 3153 | return document.id(Slick.find(this, '#' + ('' + id).replace(/(\W)/g, '\\$1'))); 3154 | }, 3155 | 3156 | getSelected: function(){ 3157 | this.selectedIndex; // Safari 3.2.1 3158 | return new Elements(Array.from(this.options).filter(function(option){ 3159 | return option.selected; 3160 | })); 3161 | }, 3162 | 3163 | toQueryString: function(){ 3164 | var queryString = []; 3165 | this.getElements('input, select, textarea').each(function(el){ 3166 | var type = el.type; 3167 | if (!el.name || el.disabled || type == 'submit' || type == 'reset' || type == 'file' || type == 'image') return; 3168 | 3169 | var value = (el.get('tag') == 'select') ? el.getSelected().map(function(opt){ 3170 | // IE 3171 | return document.id(opt).get('value'); 3172 | }) : ((type == 'radio' || type == 'checkbox') && !el.checked) ? null : el.get('value'); 3173 | 3174 | Array.from(value).each(function(val){ 3175 | if (typeof val != 'undefined') queryString.push(encodeURIComponent(el.name) + '=' + encodeURIComponent(val)); 3176 | }); 3177 | }); 3178 | return queryString.join('&'); 3179 | }, 3180 | 3181 | clone: function(contents, keepid){ 3182 | contents = contents !== false; 3183 | var clone = this.cloneNode(contents); 3184 | var clean = function(node, element){ 3185 | if (!keepid) node.removeAttribute('id'); 3186 | if (Browser.ie){ 3187 | node.clearAttributes(); 3188 | node.mergeAttributes(element); 3189 | node.removeAttribute('uid'); 3190 | if (node.options){ 3191 | var no = node.options, eo = element.options; 3192 | for (var j = no.length; j--;) no[j].selected = eo[j].selected; 3193 | } 3194 | } 3195 | var prop = props[element.tagName.toLowerCase()]; 3196 | if (prop && element[prop]) node[prop] = element[prop]; 3197 | }; 3198 | 3199 | var i; 3200 | if (contents){ 3201 | var ce = clone.getElementsByTagName('*'), te = this.getElementsByTagName('*'); 3202 | for (i = ce.length; i--;) clean(ce[i], te[i]); 3203 | } 3204 | 3205 | clean(clone, this); 3206 | if (Browser.ie){ 3207 | var ts = this.getElementsByTagName('object'), 3208 | cs = clone.getElementsByTagName('object'), 3209 | tl = ts.length, cl = cs.length; 3210 | for (i = 0; i < tl && i < cl; i++) 3211 | cs[i].outerHTML = ts[i].outerHTML; 3212 | } 3213 | return document.id(clone); 3214 | }, 3215 | 3216 | destroy: function(){ 3217 | var children = clean(this).getElementsByTagName('*'); 3218 | Array.each(children, clean); 3219 | Element.dispose(this); 3220 | return null; 3221 | }, 3222 | 3223 | empty: function(){ 3224 | Array.from(this.childNodes).each(Element.dispose); 3225 | return this; 3226 | }, 3227 | 3228 | dispose: function(){ 3229 | return (this.parentNode) ? this.parentNode.removeChild(this) : this; 3230 | }, 3231 | 3232 | match: function(expression){ 3233 | return !expression || Slick.match(this, expression); 3234 | } 3235 | 3236 | }); 3237 | 3238 | var contains = {contains: function(element){ 3239 | return Slick.contains(this, element); 3240 | }}; 3241 | 3242 | if (!document.contains) Document.implement(contains); 3243 | if (!document.createElement('div').contains) Element.implement(contains); 3244 | 3245 | 3246 | 3247 | [Element, Window, Document].invoke('implement', { 3248 | 3249 | addListener: function(type, fn){ 3250 | if (type == 'unload'){ 3251 | var old = fn, self = this; 3252 | fn = function(){ 3253 | self.removeListener('unload', fn); 3254 | old(); 3255 | }; 3256 | } else { 3257 | collected[this.uid] = this; 3258 | } 3259 | if (this.addEventListener) this.addEventListener(type, fn, false); 3260 | else this.attachEvent('on' + type, fn); 3261 | return this; 3262 | }, 3263 | 3264 | removeListener: function(type, fn){ 3265 | if (this.removeEventListener) this.removeEventListener(type, fn, false); 3266 | else this.detachEvent('on' + type, fn); 3267 | return this; 3268 | }, 3269 | 3270 | retrieve: function(property, dflt){ 3271 | var storage = get(this.uid), prop = storage[property]; 3272 | if (dflt != null && prop == null) prop = storage[property] = dflt; 3273 | return prop != null ? prop : null; 3274 | }, 3275 | 3276 | store: function(property, value){ 3277 | var storage = get(this.uid); 3278 | storage[property] = value; 3279 | return this; 3280 | }, 3281 | 3282 | eliminate: function(property){ 3283 | var storage = get(this.uid); 3284 | delete storage[property]; 3285 | return this; 3286 | } 3287 | 3288 | }); 3289 | 3290 | // IE purge 3291 | if (window.attachEvent && !window.addEventListener) window.addListener('unload', function(){ 3292 | Object.each(collected, clean); 3293 | if (window.CollectGarbage) CollectGarbage(); 3294 | }); 3295 | 3296 | })(); 3297 | 3298 | Element.Properties = {}; 3299 | 3300 | 3301 | 3302 | Element.Properties.style = { 3303 | 3304 | set: function(style){ 3305 | this.style.cssText = style; 3306 | }, 3307 | 3308 | get: function(){ 3309 | return this.style.cssText; 3310 | }, 3311 | 3312 | erase: function(){ 3313 | this.style.cssText = ''; 3314 | } 3315 | 3316 | }; 3317 | 3318 | Element.Properties.tag = { 3319 | 3320 | get: function(){ 3321 | return this.tagName.toLowerCase(); 3322 | } 3323 | 3324 | }; 3325 | 3326 | (function(maxLength){ 3327 | if (maxLength != null) Element.Properties.maxlength = Element.Properties.maxLength = { 3328 | get: function(){ 3329 | var maxlength = this.getAttribute('maxLength'); 3330 | return maxlength == maxLength ? null : maxlength; 3331 | } 3332 | }; 3333 | })(document.createElement('input').getAttribute('maxLength')); 3334 | 3335 | Element.Properties.html = (function(){ 3336 | 3337 | var tableTest = Function.attempt(function(){ 3338 | var table = document.createElement('table'); 3339 | table.innerHTML = ''; 3340 | }); 3341 | 3342 | var wrapper = document.createElement('div'); 3343 | 3344 | var translations = { 3345 | table: [1, '', '
'], 3346 | select: [1, ''], 3347 | tbody: [2, '', '
'], 3348 | tr: [3, '', '
'] 3349 | }; 3350 | translations.thead = translations.tfoot = translations.tbody; 3351 | 3352 | var html = { 3353 | set: function(){ 3354 | var html = Array.flatten(arguments).join(''); 3355 | var wrap = (!tableTest && translations[this.get('tag')]); 3356 | if (wrap){ 3357 | var first = wrapper; 3358 | first.innerHTML = wrap[1] + html + wrap[2]; 3359 | for (var i = wrap[0]; i--;) first = first.firstChild; 3360 | this.empty().adopt(first.childNodes); 3361 | } else { 3362 | this.innerHTML = html; 3363 | } 3364 | } 3365 | }; 3366 | 3367 | html.erase = html.set; 3368 | 3369 | return html; 3370 | })(); 3371 | 3372 | 3373 | /* 3374 | --- 3375 | 3376 | name: Element.Style 3377 | 3378 | description: Contains methods for interacting with the styles of Elements in a fashionable way. 3379 | 3380 | license: MIT-style license. 3381 | 3382 | requires: Element 3383 | 3384 | provides: Element.Style 3385 | 3386 | ... 3387 | */ 3388 | 3389 | (function(){ 3390 | 3391 | var html = document.html; 3392 | 3393 | Element.Properties.styles = {set: function(styles){ 3394 | this.setStyles(styles); 3395 | }}; 3396 | 3397 | var hasOpacity = (html.style.opacity != null); 3398 | var reAlpha = /alpha\(opacity=([\d.]+)\)/i; 3399 | 3400 | var setOpacity = function(element, opacity){ 3401 | if (!element.currentStyle || !element.currentStyle.hasLayout) element.style.zoom = 1; 3402 | if (hasOpacity){ 3403 | element.style.opacity = opacity; 3404 | } else { 3405 | opacity = (opacity == 1) ? '' : 'alpha(opacity=' + opacity * 100 + ')'; 3406 | var filter = element.style.filter || element.getComputedStyle('filter') || ''; 3407 | element.style.filter = filter.test(reAlpha) ? filter.replace(reAlpha, opacity) : filter + opacity; 3408 | } 3409 | }; 3410 | 3411 | Element.Properties.opacity = { 3412 | 3413 | set: function(opacity){ 3414 | var visibility = this.style.visibility; 3415 | if (opacity == 0 && visibility != 'hidden') this.style.visibility = 'hidden'; 3416 | else if (opacity != 0 && visibility != 'visible') this.style.visibility = 'visible'; 3417 | 3418 | setOpacity(this, opacity); 3419 | }, 3420 | 3421 | get: (hasOpacity) ? function(){ 3422 | var opacity = this.style.opacity || this.getComputedStyle('opacity'); 3423 | return (opacity == '') ? 1 : opacity; 3424 | } : function(){ 3425 | var opacity, filter = (this.style.filter || this.getComputedStyle('filter')); 3426 | if (filter) opacity = filter.match(reAlpha); 3427 | return (opacity == null || filter == null) ? 1 : (opacity[1] / 100); 3428 | } 3429 | 3430 | }; 3431 | 3432 | var floatName = (html.style.cssFloat == null) ? 'styleFloat' : 'cssFloat'; 3433 | 3434 | Element.implement({ 3435 | 3436 | getComputedStyle: function(property){ 3437 | if (this.currentStyle) return this.currentStyle[property.camelCase()]; 3438 | var defaultView = Element.getDocument(this).defaultView, 3439 | computed = defaultView ? defaultView.getComputedStyle(this, null) : null; 3440 | return (computed) ? computed.getPropertyValue((property == floatName) ? 'float' : property.hyphenate()) : null; 3441 | }, 3442 | 3443 | setOpacity: function(value){ 3444 | setOpacity(this, value); 3445 | return this; 3446 | }, 3447 | 3448 | getOpacity: function(){ 3449 | return this.get('opacity'); 3450 | }, 3451 | 3452 | setStyle: function(property, value){ 3453 | switch (property){ 3454 | case 'opacity': return this.set('opacity', parseFloat(value)); 3455 | case 'float': property = floatName; 3456 | } 3457 | property = property.camelCase(); 3458 | if (typeOf(value) != 'string'){ 3459 | var map = (Element.Styles[property] || '@').split(' '); 3460 | value = Array.from(value).map(function(val, i){ 3461 | if (!map[i]) return ''; 3462 | return (typeOf(val) == 'number') ? map[i].replace('@', Math.round(val)) : val; 3463 | }).join(' '); 3464 | } else if (value == String(Number(value))){ 3465 | value = Math.round(value); 3466 | } 3467 | this.style[property] = value; 3468 | return this; 3469 | }, 3470 | 3471 | getStyle: function(property){ 3472 | switch (property){ 3473 | case 'opacity': return this.get('opacity'); 3474 | case 'float': property = floatName; 3475 | } 3476 | property = property.camelCase(); 3477 | var result = this.style[property]; 3478 | if (!result || property == 'zIndex'){ 3479 | result = []; 3480 | for (var style in Element.ShortStyles){ 3481 | if (property != style) continue; 3482 | for (var s in Element.ShortStyles[style]) result.push(this.getStyle(s)); 3483 | return result.join(' '); 3484 | } 3485 | result = this.getComputedStyle(property); 3486 | } 3487 | if (result){ 3488 | result = String(result); 3489 | var color = result.match(/rgba?\([\d\s,]+\)/); 3490 | if (color) result = result.replace(color[0], color[0].rgbToHex()); 3491 | } 3492 | if (Browser.opera || (Browser.ie && isNaN(parseFloat(result)))){ 3493 | if (property.test(/^(height|width)$/)){ 3494 | var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0; 3495 | values.each(function(value){ 3496 | size += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt(); 3497 | }, this); 3498 | return this['offset' + property.capitalize()] - size + 'px'; 3499 | } 3500 | if (Browser.opera && String(result).indexOf('px') != -1) return result; 3501 | if (property.test(/(border(.+)Width|margin|padding)/)) return '0px'; 3502 | } 3503 | return result; 3504 | }, 3505 | 3506 | setStyles: function(styles){ 3507 | for (var style in styles) this.setStyle(style, styles[style]); 3508 | return this; 3509 | }, 3510 | 3511 | getStyles: function(){ 3512 | var result = {}; 3513 | Array.flatten(arguments).each(function(key){ 3514 | result[key] = this.getStyle(key); 3515 | }, this); 3516 | return result; 3517 | } 3518 | 3519 | }); 3520 | 3521 | Element.Styles = { 3522 | left: '@px', top: '@px', bottom: '@px', right: '@px', 3523 | width: '@px', height: '@px', maxWidth: '@px', maxHeight: '@px', minWidth: '@px', minHeight: '@px', 3524 | backgroundColor: 'rgb(@, @, @)', backgroundPosition: '@px @px', color: 'rgb(@, @, @)', 3525 | fontSize: '@px', letterSpacing: '@px', lineHeight: '@px', clip: 'rect(@px @px @px @px)', 3526 | margin: '@px @px @px @px', padding: '@px @px @px @px', border: '@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)', 3527 | borderWidth: '@px @px @px @px', borderStyle: '@ @ @ @', borderColor: 'rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)', 3528 | zIndex: '@', 'zoom': '@', fontWeight: '@', textIndent: '@px', opacity: '@' 3529 | }; 3530 | 3531 | 3532 | 3533 | Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, borderStyle: {}, borderColor: {}}; 3534 | 3535 | ['Top', 'Right', 'Bottom', 'Left'].each(function(direction){ 3536 | var Short = Element.ShortStyles; 3537 | var All = Element.Styles; 3538 | ['margin', 'padding'].each(function(style){ 3539 | var sd = style + direction; 3540 | Short[style][sd] = All[sd] = '@px'; 3541 | }); 3542 | var bd = 'border' + direction; 3543 | Short.border[bd] = All[bd] = '@px @ rgb(@, @, @)'; 3544 | var bdw = bd + 'Width', bds = bd + 'Style', bdc = bd + 'Color'; 3545 | Short[bd] = {}; 3546 | Short.borderWidth[bdw] = Short[bd][bdw] = All[bdw] = '@px'; 3547 | Short.borderStyle[bds] = Short[bd][bds] = All[bds] = '@'; 3548 | Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)'; 3549 | }); 3550 | 3551 | })(); 3552 | 3553 | 3554 | /* 3555 | --- 3556 | 3557 | name: Element.Event 3558 | 3559 | description: Contains Element methods for dealing with events. This file also includes mouseenter and mouseleave custom Element Events. 3560 | 3561 | license: MIT-style license. 3562 | 3563 | requires: [Element, Event] 3564 | 3565 | provides: Element.Event 3566 | 3567 | ... 3568 | */ 3569 | 3570 | (function(){ 3571 | 3572 | Element.Properties.events = {set: function(events){ 3573 | this.addEvents(events); 3574 | }}; 3575 | 3576 | [Element, Window, Document].invoke('implement', { 3577 | 3578 | addEvent: function(type, fn){ 3579 | var events = this.retrieve('events', {}); 3580 | if (!events[type]) events[type] = {keys: [], values: []}; 3581 | if (events[type].keys.contains(fn)) return this; 3582 | events[type].keys.push(fn); 3583 | var realType = type, 3584 | custom = Element.Events[type], 3585 | condition = fn, 3586 | self = this; 3587 | if (custom){ 3588 | if (custom.onAdd) custom.onAdd.call(this, fn); 3589 | if (custom.condition){ 3590 | condition = function(event){ 3591 | if (custom.condition.call(this, event)) return fn.call(this, event); 3592 | return true; 3593 | }; 3594 | } 3595 | realType = custom.base || realType; 3596 | } 3597 | var defn = function(){ 3598 | return fn.call(self); 3599 | }; 3600 | var nativeEvent = Element.NativeEvents[realType]; 3601 | if (nativeEvent){ 3602 | if (nativeEvent == 2){ 3603 | defn = function(event){ 3604 | event = new Event(event, self.getWindow()); 3605 | if (condition.call(self, event) === false) event.stop(); 3606 | }; 3607 | } 3608 | this.addListener(realType, defn); 3609 | } 3610 | events[type].values.push(defn); 3611 | return this; 3612 | }, 3613 | 3614 | removeEvent: function(type, fn){ 3615 | var events = this.retrieve('events'); 3616 | if (!events || !events[type]) return this; 3617 | var list = events[type]; 3618 | var index = list.keys.indexOf(fn); 3619 | if (index == -1) return this; 3620 | var value = list.values[index]; 3621 | delete list.keys[index]; 3622 | delete list.values[index]; 3623 | var custom = Element.Events[type]; 3624 | if (custom){ 3625 | if (custom.onRemove) custom.onRemove.call(this, fn); 3626 | type = custom.base || type; 3627 | } 3628 | return (Element.NativeEvents[type]) ? this.removeListener(type, value) : this; 3629 | }, 3630 | 3631 | addEvents: function(events){ 3632 | for (var event in events) this.addEvent(event, events[event]); 3633 | return this; 3634 | }, 3635 | 3636 | removeEvents: function(events){ 3637 | var type; 3638 | if (typeOf(events) == 'object'){ 3639 | for (type in events) this.removeEvent(type, events[type]); 3640 | return this; 3641 | } 3642 | var attached = this.retrieve('events'); 3643 | if (!attached) return this; 3644 | if (!events){ 3645 | for (type in attached) this.removeEvents(type); 3646 | this.eliminate('events'); 3647 | } else if (attached[events]){ 3648 | attached[events].keys.each(function(fn){ 3649 | this.removeEvent(events, fn); 3650 | }, this); 3651 | delete attached[events]; 3652 | } 3653 | return this; 3654 | }, 3655 | 3656 | fireEvent: function(type, args, delay){ 3657 | var events = this.retrieve('events'); 3658 | if (!events || !events[type]) return this; 3659 | args = Array.from(args); 3660 | 3661 | events[type].keys.each(function(fn){ 3662 | if (delay) fn.delay(delay, this, args); 3663 | else fn.apply(this, args); 3664 | }, this); 3665 | return this; 3666 | }, 3667 | 3668 | cloneEvents: function(from, type){ 3669 | from = document.id(from); 3670 | var events = from.retrieve('events'); 3671 | if (!events) return this; 3672 | if (!type){ 3673 | for (var eventType in events) this.cloneEvents(from, eventType); 3674 | } else if (events[type]){ 3675 | events[type].keys.each(function(fn){ 3676 | this.addEvent(type, fn); 3677 | }, this); 3678 | } 3679 | return this; 3680 | } 3681 | 3682 | }); 3683 | 3684 | // IE9 3685 | try { 3686 | if (typeof HTMLElement != 'undefined') 3687 | HTMLElement.prototype.fireEvent = Element.prototype.fireEvent; 3688 | } catch(e){} 3689 | 3690 | Element.NativeEvents = { 3691 | click: 2, dblclick: 2, mouseup: 2, mousedown: 2, contextmenu: 2, //mouse buttons 3692 | mousewheel: 2, DOMMouseScroll: 2, //mouse wheel 3693 | mouseover: 2, mouseout: 2, mousemove: 2, selectstart: 2, selectend: 2, //mouse movement 3694 | keydown: 2, keypress: 2, keyup: 2, //keyboard 3695 | orientationchange: 2, // mobile 3696 | touchstart: 2, touchmove: 2, touchend: 2, touchcancel: 2, // touch 3697 | gesturestart: 2, gesturechange: 2, gestureend: 2, // gesture 3698 | focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, //form elements 3699 | load: 2, unload: 1, beforeunload: 2, resize: 1, move: 1, DOMContentLoaded: 1, readystatechange: 1, //window 3700 | error: 1, abort: 1, scroll: 1 //misc 3701 | }; 3702 | 3703 | var check = function(event){ 3704 | var related = event.relatedTarget; 3705 | if (related == null) return true; 3706 | if (!related) return false; 3707 | return (related != this && related.prefix != 'xul' && typeOf(this) != 'document' && !this.contains(related)); 3708 | }; 3709 | 3710 | Element.Events = { 3711 | 3712 | mouseenter: { 3713 | base: 'mouseover', 3714 | condition: check 3715 | }, 3716 | 3717 | mouseleave: { 3718 | base: 'mouseout', 3719 | condition: check 3720 | }, 3721 | 3722 | mousewheel: { 3723 | base: (Browser.firefox) ? 'DOMMouseScroll' : 'mousewheel' 3724 | } 3725 | 3726 | }; 3727 | 3728 | 3729 | 3730 | })(); 3731 | 3732 | 3733 | /* 3734 | --- 3735 | 3736 | name: Element.Dimensions 3737 | 3738 | description: Contains methods to work with size, scroll, or positioning of Elements and the window object. 3739 | 3740 | license: MIT-style license. 3741 | 3742 | credits: 3743 | - Element positioning based on the [qooxdoo](http://qooxdoo.org/) code and smart browser fixes, [LGPL License](http://www.gnu.org/licenses/lgpl.html). 3744 | - Viewport dimensions based on [YUI](http://developer.yahoo.com/yui/) code, [BSD License](http://developer.yahoo.com/yui/license.html). 3745 | 3746 | requires: [Element, Element.Style] 3747 | 3748 | provides: [Element.Dimensions] 3749 | 3750 | ... 3751 | */ 3752 | 3753 | (function(){ 3754 | 3755 | Element.implement({ 3756 | 3757 | scrollTo: function(x, y){ 3758 | if (isBody(this)){ 3759 | this.getWindow().scrollTo(x, y); 3760 | } else { 3761 | this.scrollLeft = x; 3762 | this.scrollTop = y; 3763 | } 3764 | return this; 3765 | }, 3766 | 3767 | getSize: function(){ 3768 | if (isBody(this)) return this.getWindow().getSize(); 3769 | return {x: this.offsetWidth, y: this.offsetHeight}; 3770 | }, 3771 | 3772 | getScrollSize: function(){ 3773 | if (isBody(this)) return this.getWindow().getScrollSize(); 3774 | return {x: this.scrollWidth, y: this.scrollHeight}; 3775 | }, 3776 | 3777 | getScroll: function(){ 3778 | if (isBody(this)) return this.getWindow().getScroll(); 3779 | return {x: this.scrollLeft, y: this.scrollTop}; 3780 | }, 3781 | 3782 | getScrolls: function(){ 3783 | var element = this.parentNode, position = {x: 0, y: 0}; 3784 | while (element && !isBody(element)){ 3785 | position.x += element.scrollLeft; 3786 | position.y += element.scrollTop; 3787 | element = element.parentNode; 3788 | } 3789 | return position; 3790 | }, 3791 | 3792 | getOffsetParent: function(){ 3793 | var element = this; 3794 | if (isBody(element)) return null; 3795 | if (!Browser.ie) return element.offsetParent; 3796 | while ((element = element.parentNode)){ 3797 | if (styleString(element, 'position') != 'static' || isBody(element)) return element; 3798 | } 3799 | return null; 3800 | }, 3801 | 3802 | getOffsets: function(){ 3803 | if (this.getBoundingClientRect && !Browser.Platform.ios){ 3804 | var bound = this.getBoundingClientRect(), 3805 | html = document.id(this.getDocument().documentElement), 3806 | htmlScroll = html.getScroll(), 3807 | elemScrolls = this.getScrolls(), 3808 | isFixed = (styleString(this, 'position') == 'fixed'); 3809 | 3810 | return { 3811 | x: bound.left.toInt() + elemScrolls.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft, 3812 | y: bound.top.toInt() + elemScrolls.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop 3813 | }; 3814 | } 3815 | 3816 | var element = this, position = {x: 0, y: 0}; 3817 | if (isBody(this)) return position; 3818 | 3819 | while (element && !isBody(element)){ 3820 | position.x += element.offsetLeft; 3821 | position.y += element.offsetTop; 3822 | 3823 | if (Browser.firefox){ 3824 | if (!borderBox(element)){ 3825 | position.x += leftBorder(element); 3826 | position.y += topBorder(element); 3827 | } 3828 | var parent = element.parentNode; 3829 | if (parent && styleString(parent, 'overflow') != 'visible'){ 3830 | position.x += leftBorder(parent); 3831 | position.y += topBorder(parent); 3832 | } 3833 | } else if (element != this && Browser.safari){ 3834 | position.x += leftBorder(element); 3835 | position.y += topBorder(element); 3836 | } 3837 | 3838 | element = element.offsetParent; 3839 | } 3840 | if (Browser.firefox && !borderBox(this)){ 3841 | position.x -= leftBorder(this); 3842 | position.y -= topBorder(this); 3843 | } 3844 | return position; 3845 | }, 3846 | 3847 | getPosition: function(relative){ 3848 | if (isBody(this)) return {x: 0, y: 0}; 3849 | var offset = this.getOffsets(), 3850 | scroll = this.getScrolls(); 3851 | var position = { 3852 | x: offset.x - scroll.x, 3853 | y: offset.y - scroll.y 3854 | }; 3855 | 3856 | if (relative && (relative = document.id(relative))){ 3857 | var relativePosition = relative.getPosition(); 3858 | return {x: position.x - relativePosition.x - leftBorder(relative), y: position.y - relativePosition.y - topBorder(relative)}; 3859 | } 3860 | return position; 3861 | }, 3862 | 3863 | getCoordinates: function(element){ 3864 | if (isBody(this)) return this.getWindow().getCoordinates(); 3865 | var position = this.getPosition(element), 3866 | size = this.getSize(); 3867 | var obj = { 3868 | left: position.x, 3869 | top: position.y, 3870 | width: size.x, 3871 | height: size.y 3872 | }; 3873 | obj.right = obj.left + obj.width; 3874 | obj.bottom = obj.top + obj.height; 3875 | return obj; 3876 | }, 3877 | 3878 | computePosition: function(obj){ 3879 | return { 3880 | left: obj.x - styleNumber(this, 'margin-left'), 3881 | top: obj.y - styleNumber(this, 'margin-top') 3882 | }; 3883 | }, 3884 | 3885 | setPosition: function(obj){ 3886 | return this.setStyles(this.computePosition(obj)); 3887 | } 3888 | 3889 | }); 3890 | 3891 | 3892 | [Document, Window].invoke('implement', { 3893 | 3894 | getSize: function(){ 3895 | var doc = getCompatElement(this); 3896 | return {x: doc.clientWidth, y: doc.clientHeight}; 3897 | }, 3898 | 3899 | getScroll: function(){ 3900 | var win = this.getWindow(), doc = getCompatElement(this); 3901 | return {x: win.pageXOffset || doc.scrollLeft, y: win.pageYOffset || doc.scrollTop}; 3902 | }, 3903 | 3904 | getScrollSize: function(){ 3905 | var doc = getCompatElement(this), 3906 | min = this.getSize(), 3907 | body = this.getDocument().body; 3908 | 3909 | return {x: Math.max(doc.scrollWidth, body.scrollWidth, min.x), y: Math.max(doc.scrollHeight, body.scrollHeight, min.y)}; 3910 | }, 3911 | 3912 | getPosition: function(){ 3913 | return {x: 0, y: 0}; 3914 | }, 3915 | 3916 | getCoordinates: function(){ 3917 | var size = this.getSize(); 3918 | return {top: 0, left: 0, bottom: size.y, right: size.x, height: size.y, width: size.x}; 3919 | } 3920 | 3921 | }); 3922 | 3923 | // private methods 3924 | 3925 | var styleString = Element.getComputedStyle; 3926 | 3927 | function styleNumber(element, style){ 3928 | return styleString(element, style).toInt() || 0; 3929 | }; 3930 | 3931 | function borderBox(element){ 3932 | return styleString(element, '-moz-box-sizing') == 'border-box'; 3933 | }; 3934 | 3935 | function topBorder(element){ 3936 | return styleNumber(element, 'border-top-width'); 3937 | }; 3938 | 3939 | function leftBorder(element){ 3940 | return styleNumber(element, 'border-left-width'); 3941 | }; 3942 | 3943 | function isBody(element){ 3944 | return (/^(?:body|html)$/i).test(element.tagName); 3945 | }; 3946 | 3947 | function getCompatElement(element){ 3948 | var doc = element.getDocument(); 3949 | return (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body; 3950 | }; 3951 | 3952 | })(); 3953 | 3954 | //aliases 3955 | Element.alias({position: 'setPosition'}); //compatability 3956 | 3957 | [Window, Document, Element].invoke('implement', { 3958 | 3959 | getHeight: function(){ 3960 | return this.getSize().y; 3961 | }, 3962 | 3963 | getWidth: function(){ 3964 | return this.getSize().x; 3965 | }, 3966 | 3967 | getScrollTop: function(){ 3968 | return this.getScroll().y; 3969 | }, 3970 | 3971 | getScrollLeft: function(){ 3972 | return this.getScroll().x; 3973 | }, 3974 | 3975 | getScrollHeight: function(){ 3976 | return this.getScrollSize().y; 3977 | }, 3978 | 3979 | getScrollWidth: function(){ 3980 | return this.getScrollSize().x; 3981 | }, 3982 | 3983 | getTop: function(){ 3984 | return this.getPosition().y; 3985 | }, 3986 | 3987 | getLeft: function(){ 3988 | return this.getPosition().x; 3989 | } 3990 | 3991 | }); 3992 | 3993 | 3994 | /* 3995 | --- 3996 | 3997 | name: Fx 3998 | 3999 | description: Contains the basic animation logic to be extended by all other Fx Classes. 4000 | 4001 | license: MIT-style license. 4002 | 4003 | requires: [Chain, Events, Options] 4004 | 4005 | provides: Fx 4006 | 4007 | ... 4008 | */ 4009 | 4010 | (function(){ 4011 | 4012 | var Fx = this.Fx = new Class({ 4013 | 4014 | Implements: [Chain, Events, Options], 4015 | 4016 | options: { 4017 | /* 4018 | onStart: nil, 4019 | onCancel: nil, 4020 | onComplete: nil, 4021 | */ 4022 | fps: 50, 4023 | unit: false, 4024 | duration: 500, 4025 | link: 'ignore' 4026 | }, 4027 | 4028 | initialize: function(options){ 4029 | this.subject = this.subject || this; 4030 | this.setOptions(options); 4031 | }, 4032 | 4033 | getTransition: function(){ 4034 | return function(p){ 4035 | return -(Math.cos(Math.PI * p) - 1) / 2; 4036 | }; 4037 | }, 4038 | 4039 | step: function(){ 4040 | var time = Date.now(); 4041 | if (time < this.time + this.options.duration){ 4042 | var delta = this.transition((time - this.time) / this.options.duration); 4043 | this.set(this.compute(this.from, this.to, delta)); 4044 | } else { 4045 | this.set(this.compute(this.from, this.to, 1)); 4046 | this.complete(); 4047 | } 4048 | }, 4049 | 4050 | set: function(now){ 4051 | return now; 4052 | }, 4053 | 4054 | compute: function(from, to, delta){ 4055 | return Fx.compute(from, to, delta); 4056 | }, 4057 | 4058 | check: function(){ 4059 | if (!this.timer) return true; 4060 | switch (this.options.link){ 4061 | case 'cancel': this.cancel(); return true; 4062 | case 'chain': this.chain(this.caller.pass(arguments, this)); return false; 4063 | } 4064 | return false; 4065 | }, 4066 | 4067 | start: function(from, to){ 4068 | if (!this.check(from, to)) return this; 4069 | var duration = this.options.duration; 4070 | this.options.duration = Fx.Durations[duration] || duration.toInt(); 4071 | this.from = from; 4072 | this.to = to; 4073 | this.time = 0; 4074 | this.transition = this.getTransition(); 4075 | this.startTimer(); 4076 | this.onStart(); 4077 | return this; 4078 | }, 4079 | 4080 | complete: function(){ 4081 | if (this.stopTimer()) this.onComplete(); 4082 | return this; 4083 | }, 4084 | 4085 | cancel: function(){ 4086 | if (this.stopTimer()) this.onCancel(); 4087 | return this; 4088 | }, 4089 | 4090 | onStart: function(){ 4091 | this.fireEvent('start', this.subject); 4092 | }, 4093 | 4094 | onComplete: function(){ 4095 | this.fireEvent('complete', this.subject); 4096 | if (!this.callChain()) this.fireEvent('chainComplete', this.subject); 4097 | }, 4098 | 4099 | onCancel: function(){ 4100 | this.fireEvent('cancel', this.subject).clearChain(); 4101 | }, 4102 | 4103 | pause: function(){ 4104 | this.stopTimer(); 4105 | return this; 4106 | }, 4107 | 4108 | resume: function(){ 4109 | this.startTimer(); 4110 | return this; 4111 | }, 4112 | 4113 | stopTimer: function(){ 4114 | if (!this.timer) return false; 4115 | this.time = Date.now() - this.time; 4116 | this.timer = removeInstance(this); 4117 | return true; 4118 | }, 4119 | 4120 | startTimer: function(){ 4121 | if (this.timer) return false; 4122 | this.time = Date.now() - this.time; 4123 | this.timer = addInstance(this); 4124 | return true; 4125 | } 4126 | 4127 | }); 4128 | 4129 | Fx.compute = function(from, to, delta){ 4130 | return (to - from) * delta + from; 4131 | }; 4132 | 4133 | Fx.Durations = {'short': 250, 'normal': 500, 'long': 1000}; 4134 | 4135 | // global timers 4136 | 4137 | var instances = {}, timers = {}; 4138 | 4139 | var loop = function(){ 4140 | for (var i = this.length; i--;){ 4141 | if (this[i]) this[i].step(); 4142 | } 4143 | }; 4144 | 4145 | var addInstance = function(instance){ 4146 | var fps = instance.options.fps, 4147 | list = instances[fps] || (instances[fps] = []); 4148 | list.push(instance); 4149 | if (!timers[fps]) timers[fps] = loop.periodical(Math.round(1000 / fps), list); 4150 | return true; 4151 | }; 4152 | 4153 | var removeInstance = function(instance){ 4154 | var fps = instance.options.fps, 4155 | list = instances[fps] || []; 4156 | list.erase(instance); 4157 | if (!list.length && timers[fps]) timers[fps] = clearInterval(timers[fps]); 4158 | return false; 4159 | }; 4160 | 4161 | })(); 4162 | 4163 | 4164 | /* 4165 | --- 4166 | 4167 | name: Fx.CSS 4168 | 4169 | description: Contains the CSS animation logic. Used by Fx.Tween, Fx.Morph, Fx.Elements. 4170 | 4171 | license: MIT-style license. 4172 | 4173 | requires: [Fx, Element.Style] 4174 | 4175 | provides: Fx.CSS 4176 | 4177 | ... 4178 | */ 4179 | 4180 | Fx.CSS = new Class({ 4181 | 4182 | Extends: Fx, 4183 | 4184 | //prepares the base from/to object 4185 | 4186 | prepare: function(element, property, values){ 4187 | values = Array.from(values); 4188 | if (values[1] == null){ 4189 | values[1] = values[0]; 4190 | values[0] = element.getStyle(property); 4191 | } 4192 | var parsed = values.map(this.parse); 4193 | return {from: parsed[0], to: parsed[1]}; 4194 | }, 4195 | 4196 | //parses a value into an array 4197 | 4198 | parse: function(value){ 4199 | value = Function.from(value)(); 4200 | value = (typeof value == 'string') ? value.split(' ') : Array.from(value); 4201 | return value.map(function(val){ 4202 | val = String(val); 4203 | var found = false; 4204 | Object.each(Fx.CSS.Parsers, function(parser, key){ 4205 | if (found) return; 4206 | var parsed = parser.parse(val); 4207 | if (parsed || parsed === 0) found = {value: parsed, parser: parser}; 4208 | }); 4209 | found = found || {value: val, parser: Fx.CSS.Parsers.String}; 4210 | return found; 4211 | }); 4212 | }, 4213 | 4214 | //computes by a from and to prepared objects, using their parsers. 4215 | 4216 | compute: function(from, to, delta){ 4217 | var computed = []; 4218 | (Math.min(from.length, to.length)).times(function(i){ 4219 | computed.push({value: from[i].parser.compute(from[i].value, to[i].value, delta), parser: from[i].parser}); 4220 | }); 4221 | computed.$family = Function.from('fx:css:value'); 4222 | return computed; 4223 | }, 4224 | 4225 | //serves the value as settable 4226 | 4227 | serve: function(value, unit){ 4228 | if (typeOf(value) != 'fx:css:value') value = this.parse(value); 4229 | var returned = []; 4230 | value.each(function(bit){ 4231 | returned = returned.concat(bit.parser.serve(bit.value, unit)); 4232 | }); 4233 | return returned; 4234 | }, 4235 | 4236 | //renders the change to an element 4237 | 4238 | render: function(element, property, value, unit){ 4239 | element.setStyle(property, this.serve(value, unit)); 4240 | }, 4241 | 4242 | //searches inside the page css to find the values for a selector 4243 | 4244 | search: function(selector){ 4245 | if (Fx.CSS.Cache[selector]) return Fx.CSS.Cache[selector]; 4246 | var to = {}; 4247 | Array.each(document.styleSheets, function(sheet, j){ 4248 | var href = sheet.href; 4249 | if (href && href.contains('://') && !href.contains(document.domain)) return; 4250 | var rules = sheet.rules || sheet.cssRules; 4251 | Array.each(rules, function(rule, i){ 4252 | if (!rule.style) return; 4253 | var selectorText = (rule.selectorText) ? rule.selectorText.replace(/^\w+/, function(m){ 4254 | return m.toLowerCase(); 4255 | }) : null; 4256 | if (!selectorText || !selectorText.test('^' + selector + '$')) return; 4257 | Element.Styles.each(function(value, style){ 4258 | if (!rule.style[style] || Element.ShortStyles[style]) return; 4259 | value = String(rule.style[style]); 4260 | to[style] = (value.test(/^rgb/)) ? value.rgbToHex() : value; 4261 | }); 4262 | }); 4263 | }); 4264 | return Fx.CSS.Cache[selector] = to; 4265 | } 4266 | 4267 | }); 4268 | 4269 | Fx.CSS.Cache = {}; 4270 | 4271 | Fx.CSS.Parsers = { 4272 | 4273 | Color: { 4274 | parse: function(value){ 4275 | if (value.match(/^#[0-9a-f]{3,6}$/i)) return value.hexToRgb(true); 4276 | return ((value = value.match(/(\d+),\s*(\d+),\s*(\d+)/))) ? [value[1], value[2], value[3]] : false; 4277 | }, 4278 | compute: function(from, to, delta){ 4279 | return from.map(function(value, i){ 4280 | return Math.round(Fx.compute(from[i], to[i], delta)); 4281 | }); 4282 | }, 4283 | serve: function(value){ 4284 | return value.map(Number); 4285 | } 4286 | }, 4287 | 4288 | Number: { 4289 | parse: parseFloat, 4290 | compute: Fx.compute, 4291 | serve: function(value, unit){ 4292 | return (unit) ? value + unit : value; 4293 | } 4294 | }, 4295 | 4296 | String: { 4297 | parse: Function.from(false), 4298 | compute: function(zero, one){ 4299 | return one; 4300 | }, 4301 | serve: function(zero){ 4302 | return zero; 4303 | } 4304 | } 4305 | 4306 | }; 4307 | 4308 | 4309 | 4310 | 4311 | /* 4312 | --- 4313 | 4314 | name: Fx.Tween 4315 | 4316 | description: Formerly Fx.Style, effect to transition any CSS property for an element. 4317 | 4318 | license: MIT-style license. 4319 | 4320 | requires: Fx.CSS 4321 | 4322 | provides: [Fx.Tween, Element.fade, Element.highlight] 4323 | 4324 | ... 4325 | */ 4326 | 4327 | Fx.Tween = new Class({ 4328 | 4329 | Extends: Fx.CSS, 4330 | 4331 | initialize: function(element, options){ 4332 | this.element = this.subject = document.id(element); 4333 | this.parent(options); 4334 | }, 4335 | 4336 | set: function(property, now){ 4337 | if (arguments.length == 1){ 4338 | now = property; 4339 | property = this.property || this.options.property; 4340 | } 4341 | this.render(this.element, property, now, this.options.unit); 4342 | return this; 4343 | }, 4344 | 4345 | start: function(property, from, to){ 4346 | if (!this.check(property, from, to)) return this; 4347 | var args = Array.flatten(arguments); 4348 | this.property = this.options.property || args.shift(); 4349 | var parsed = this.prepare(this.element, this.property, args); 4350 | return this.parent(parsed.from, parsed.to); 4351 | } 4352 | 4353 | }); 4354 | 4355 | Element.Properties.tween = { 4356 | 4357 | set: function(options){ 4358 | this.get('tween').cancel().setOptions(options); 4359 | return this; 4360 | }, 4361 | 4362 | get: function(){ 4363 | var tween = this.retrieve('tween'); 4364 | if (!tween){ 4365 | tween = new Fx.Tween(this, {link: 'cancel'}); 4366 | this.store('tween', tween); 4367 | } 4368 | return tween; 4369 | } 4370 | 4371 | }; 4372 | 4373 | Element.implement({ 4374 | 4375 | tween: function(property, from, to){ 4376 | this.get('tween').start(arguments); 4377 | return this; 4378 | }, 4379 | 4380 | fade: function(how){ 4381 | var fade = this.get('tween'), o = 'opacity', toggle; 4382 | how = [how, 'toggle'].pick(); 4383 | switch (how){ 4384 | case 'in': fade.start(o, 1); break; 4385 | case 'out': fade.start(o, 0); break; 4386 | case 'show': fade.set(o, 1); break; 4387 | case 'hide': fade.set(o, 0); break; 4388 | case 'toggle': 4389 | var flag = this.retrieve('fade:flag', this.get('opacity') == 1); 4390 | fade.start(o, (flag) ? 0 : 1); 4391 | this.store('fade:flag', !flag); 4392 | toggle = true; 4393 | break; 4394 | default: fade.start(o, arguments); 4395 | } 4396 | if (!toggle) this.eliminate('fade:flag'); 4397 | return this; 4398 | }, 4399 | 4400 | highlight: function(start, end){ 4401 | if (!end){ 4402 | end = this.retrieve('highlight:original', this.getStyle('background-color')); 4403 | end = (end == 'transparent') ? '#fff' : end; 4404 | } 4405 | var tween = this.get('tween'); 4406 | tween.start('background-color', start || '#ffff88', end).chain(function(){ 4407 | this.setStyle('background-color', this.retrieve('highlight:original')); 4408 | tween.callChain(); 4409 | }.bind(this)); 4410 | return this; 4411 | } 4412 | 4413 | }); 4414 | 4415 | 4416 | /* 4417 | --- 4418 | 4419 | name: Fx.Morph 4420 | 4421 | description: Formerly Fx.Styles, effect to transition any number of CSS properties for an element using an object of rules, or CSS based selector rules. 4422 | 4423 | license: MIT-style license. 4424 | 4425 | requires: Fx.CSS 4426 | 4427 | provides: Fx.Morph 4428 | 4429 | ... 4430 | */ 4431 | 4432 | Fx.Morph = new Class({ 4433 | 4434 | Extends: Fx.CSS, 4435 | 4436 | initialize: function(element, options){ 4437 | this.element = this.subject = document.id(element); 4438 | this.parent(options); 4439 | }, 4440 | 4441 | set: function(now){ 4442 | if (typeof now == 'string') now = this.search(now); 4443 | for (var p in now) this.render(this.element, p, now[p], this.options.unit); 4444 | return this; 4445 | }, 4446 | 4447 | compute: function(from, to, delta){ 4448 | var now = {}; 4449 | for (var p in from) now[p] = this.parent(from[p], to[p], delta); 4450 | return now; 4451 | }, 4452 | 4453 | start: function(properties){ 4454 | if (!this.check(properties)) return this; 4455 | if (typeof properties == 'string') properties = this.search(properties); 4456 | var from = {}, to = {}; 4457 | for (var p in properties){ 4458 | var parsed = this.prepare(this.element, p, properties[p]); 4459 | from[p] = parsed.from; 4460 | to[p] = parsed.to; 4461 | } 4462 | return this.parent(from, to); 4463 | } 4464 | 4465 | }); 4466 | 4467 | Element.Properties.morph = { 4468 | 4469 | set: function(options){ 4470 | this.get('morph').cancel().setOptions(options); 4471 | return this; 4472 | }, 4473 | 4474 | get: function(){ 4475 | var morph = this.retrieve('morph'); 4476 | if (!morph){ 4477 | morph = new Fx.Morph(this, {link: 'cancel'}); 4478 | this.store('morph', morph); 4479 | } 4480 | return morph; 4481 | } 4482 | 4483 | }; 4484 | 4485 | Element.implement({ 4486 | 4487 | morph: function(props){ 4488 | this.get('morph').start(props); 4489 | return this; 4490 | } 4491 | 4492 | }); 4493 | 4494 | 4495 | /* 4496 | --- 4497 | 4498 | name: Fx.Transitions 4499 | 4500 | description: Contains a set of advanced transitions to be used with any of the Fx Classes. 4501 | 4502 | license: MIT-style license. 4503 | 4504 | credits: 4505 | - Easing Equations by Robert Penner, , modified and optimized to be used with MooTools. 4506 | 4507 | requires: Fx 4508 | 4509 | provides: Fx.Transitions 4510 | 4511 | ... 4512 | */ 4513 | 4514 | Fx.implement({ 4515 | 4516 | getTransition: function(){ 4517 | var trans = this.options.transition || Fx.Transitions.Sine.easeInOut; 4518 | if (typeof trans == 'string'){ 4519 | var data = trans.split(':'); 4520 | trans = Fx.Transitions; 4521 | trans = trans[data[0]] || trans[data[0].capitalize()]; 4522 | if (data[1]) trans = trans['ease' + data[1].capitalize() + (data[2] ? data[2].capitalize() : '')]; 4523 | } 4524 | return trans; 4525 | } 4526 | 4527 | }); 4528 | 4529 | Fx.Transition = function(transition, params){ 4530 | params = Array.from(params); 4531 | return Object.append(transition, { 4532 | easeIn: function(pos){ 4533 | return transition(pos, params); 4534 | }, 4535 | easeOut: function(pos){ 4536 | return 1 - transition(1 - pos, params); 4537 | }, 4538 | easeInOut: function(pos){ 4539 | return (pos <= 0.5) ? transition(2 * pos, params) / 2 : (2 - transition(2 * (1 - pos), params)) / 2; 4540 | } 4541 | }); 4542 | }; 4543 | 4544 | Fx.Transitions = { 4545 | 4546 | linear: function(zero){ 4547 | return zero; 4548 | } 4549 | 4550 | }; 4551 | 4552 | 4553 | 4554 | Fx.Transitions.extend = function(transitions){ 4555 | for (var transition in transitions) Fx.Transitions[transition] = new Fx.Transition(transitions[transition]); 4556 | }; 4557 | 4558 | Fx.Transitions.extend({ 4559 | 4560 | Pow: function(p, x){ 4561 | return Math.pow(p, x && x[0] || 6); 4562 | }, 4563 | 4564 | Expo: function(p){ 4565 | return Math.pow(2, 8 * (p - 1)); 4566 | }, 4567 | 4568 | Circ: function(p){ 4569 | return 1 - Math.sin(Math.acos(p)); 4570 | }, 4571 | 4572 | Sine: function(p){ 4573 | return 1 - Math.sin((1 - p) * Math.PI / 2); 4574 | }, 4575 | 4576 | Back: function(p, x){ 4577 | x = x && x[0] || 1.618; 4578 | return Math.pow(p, 2) * ((x + 1) * p - x); 4579 | }, 4580 | 4581 | Bounce: function(p){ 4582 | var value; 4583 | for (var a = 0, b = 1; 1; a += b, b /= 2){ 4584 | if (p >= (7 - 4 * a) / 11){ 4585 | value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2); 4586 | break; 4587 | } 4588 | } 4589 | return value; 4590 | }, 4591 | 4592 | Elastic: function(p, x){ 4593 | return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x && x[0] || 1) / 3); 4594 | } 4595 | 4596 | }); 4597 | 4598 | ['Quad', 'Cubic', 'Quart', 'Quint'].each(function(transition, i){ 4599 | Fx.Transitions[transition] = new Fx.Transition(function(p){ 4600 | return Math.pow(p, [i + 2]); 4601 | }); 4602 | }); 4603 | 4604 | 4605 | /* 4606 | --- 4607 | 4608 | name: Request 4609 | 4610 | description: Powerful all purpose Request Class. Uses XMLHTTPRequest. 4611 | 4612 | license: MIT-style license. 4613 | 4614 | requires: [Object, Element, Chain, Events, Options, Browser] 4615 | 4616 | provides: Request 4617 | 4618 | ... 4619 | */ 4620 | 4621 | (function(){ 4622 | 4623 | var progressSupport = ('onprogress' in new Browser.Request); 4624 | 4625 | var Request = this.Request = new Class({ 4626 | 4627 | Implements: [Chain, Events, Options], 4628 | 4629 | options: {/* 4630 | onRequest: function(){}, 4631 | onLoadstart: function(event, xhr){}, 4632 | onProgress: function(event, xhr){}, 4633 | onComplete: function(){}, 4634 | onCancel: function(){}, 4635 | onSuccess: function(responseText, responseXML){}, 4636 | onFailure: function(xhr){}, 4637 | onException: function(headerName, value){}, 4638 | onTimeout: function(){}, 4639 | user: '', 4640 | password: '',*/ 4641 | url: '', 4642 | data: '', 4643 | headers: { 4644 | 'X-Requested-With': 'XMLHttpRequest', 4645 | 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' 4646 | }, 4647 | async: true, 4648 | format: false, 4649 | method: 'post', 4650 | link: 'ignore', 4651 | isSuccess: null, 4652 | emulation: true, 4653 | urlEncoded: true, 4654 | encoding: 'utf-8', 4655 | evalScripts: false, 4656 | evalResponse: false, 4657 | timeout: 0, 4658 | noCache: false 4659 | }, 4660 | 4661 | initialize: function(options){ 4662 | this.xhr = new Browser.Request(); 4663 | this.setOptions(options); 4664 | this.headers = this.options.headers; 4665 | }, 4666 | 4667 | onStateChange: function(){ 4668 | var xhr = this.xhr; 4669 | if (xhr.readyState != 4 || !this.running) return; 4670 | this.running = false; 4671 | this.status = 0; 4672 | Function.attempt(function(){ 4673 | var status = xhr.status; 4674 | this.status = (status == 1223) ? 204 : status; 4675 | }.bind(this)); 4676 | xhr.onreadystatechange = function(){}; 4677 | clearTimeout(this.timer); 4678 | 4679 | this.response = {text: this.xhr.responseText || '', xml: this.xhr.responseXML}; 4680 | if (this.options.isSuccess.call(this, this.status)) 4681 | this.success(this.response.text, this.response.xml); 4682 | else 4683 | this.failure(); 4684 | }, 4685 | 4686 | isSuccess: function(){ 4687 | var status = this.status; 4688 | return (status >= 200 && status < 300); 4689 | }, 4690 | 4691 | isRunning: function(){ 4692 | return !!this.running; 4693 | }, 4694 | 4695 | processScripts: function(text){ 4696 | if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) return Browser.exec(text); 4697 | return text.stripScripts(this.options.evalScripts); 4698 | }, 4699 | 4700 | success: function(text, xml){ 4701 | this.onSuccess(this.processScripts(text), xml); 4702 | }, 4703 | 4704 | onSuccess: function(){ 4705 | this.fireEvent('complete', arguments).fireEvent('success', arguments).callChain(); 4706 | }, 4707 | 4708 | failure: function(){ 4709 | this.onFailure(); 4710 | }, 4711 | 4712 | onFailure: function(){ 4713 | this.fireEvent('complete').fireEvent('failure', this.xhr); 4714 | }, 4715 | 4716 | loadstart: function(event){ 4717 | this.fireEvent('loadstart', [event, this.xhr]); 4718 | }, 4719 | 4720 | progress: function(event){ 4721 | this.fireEvent('progress', [event, this.xhr]); 4722 | }, 4723 | 4724 | timeout: function(){ 4725 | this.fireEvent('timeout', this.xhr); 4726 | }, 4727 | 4728 | setHeader: function(name, value){ 4729 | this.headers[name] = value; 4730 | return this; 4731 | }, 4732 | 4733 | getHeader: function(name){ 4734 | return Function.attempt(function(){ 4735 | return this.xhr.getResponseHeader(name); 4736 | }.bind(this)); 4737 | }, 4738 | 4739 | check: function(){ 4740 | if (!this.running) return true; 4741 | switch (this.options.link){ 4742 | case 'cancel': this.cancel(); return true; 4743 | case 'chain': this.chain(this.caller.pass(arguments, this)); return false; 4744 | } 4745 | return false; 4746 | }, 4747 | 4748 | send: function(options){ 4749 | if (!this.check(options)) return this; 4750 | 4751 | this.options.isSuccess = this.options.isSuccess || this.isSuccess; 4752 | this.running = true; 4753 | 4754 | var type = typeOf(options); 4755 | if (type == 'string' || type == 'element') options = {data: options}; 4756 | 4757 | var old = this.options; 4758 | options = Object.append({data: old.data, url: old.url, method: old.method}, options); 4759 | var data = options.data, url = String(options.url), method = options.method.toLowerCase(); 4760 | 4761 | switch (typeOf(data)){ 4762 | case 'element': data = document.id(data).toQueryString(); break; 4763 | case 'object': case 'hash': data = Object.toQueryString(data); 4764 | } 4765 | 4766 | if (this.options.format){ 4767 | var format = 'format=' + this.options.format; 4768 | data = (data) ? format + '&' + data : format; 4769 | } 4770 | 4771 | if (this.options.emulation && !['get', 'post'].contains(method)){ 4772 | var _method = '_method=' + method; 4773 | data = (data) ? _method + '&' + data : _method; 4774 | method = 'post'; 4775 | } 4776 | 4777 | if (this.options.urlEncoded && ['post', 'put'].contains(method)){ 4778 | var encoding = (this.options.encoding) ? '; charset=' + this.options.encoding : ''; 4779 | this.headers['Content-type'] = 'application/x-www-form-urlencoded' + encoding; 4780 | } 4781 | 4782 | if (!url) url = document.location.pathname; 4783 | 4784 | var trimPosition = url.lastIndexOf('/'); 4785 | if (trimPosition > -1 && (trimPosition = url.indexOf('#')) > -1) url = url.substr(0, trimPosition); 4786 | 4787 | if (this.options.noCache) 4788 | url += (url.contains('?') ? '&' : '?') + String.uniqueID(); 4789 | 4790 | if (data && method == 'get'){ 4791 | url += (url.contains('?') ? '&' : '?') + data; 4792 | data = null; 4793 | } 4794 | 4795 | var xhr = this.xhr; 4796 | if (progressSupport){ 4797 | xhr.onloadstart = this.loadstart.bind(this); 4798 | xhr.onprogress = this.progress.bind(this); 4799 | } 4800 | 4801 | xhr.open(method.toUpperCase(), url, this.options.async, this.options.user, this.options.password); 4802 | if (this.options.user && 'withCredentials' in xhr) xhr.withCredentials = true; 4803 | 4804 | xhr.onreadystatechange = this.onStateChange.bind(this); 4805 | 4806 | Object.each(this.headers, function(value, key){ 4807 | try { 4808 | xhr.setRequestHeader(key, value); 4809 | } catch (e){ 4810 | this.fireEvent('exception', [key, value]); 4811 | } 4812 | }, this); 4813 | 4814 | this.fireEvent('request'); 4815 | xhr.send(data); 4816 | if (!this.options.async) this.onStateChange(); 4817 | if (this.options.timeout) this.timer = this.timeout.delay(this.options.timeout, this); 4818 | return this; 4819 | }, 4820 | 4821 | cancel: function(){ 4822 | if (!this.running) return this; 4823 | this.running = false; 4824 | var xhr = this.xhr; 4825 | xhr.abort(); 4826 | clearTimeout(this.timer); 4827 | xhr.onreadystatechange = xhr.onprogress = xhr.onloadstart = function(){}; 4828 | this.xhr = new Browser.Request(); 4829 | this.fireEvent('cancel'); 4830 | return this; 4831 | } 4832 | 4833 | }); 4834 | 4835 | var methods = {}; 4836 | ['get', 'post', 'put', 'delete', 'GET', 'POST', 'PUT', 'DELETE'].each(function(method){ 4837 | methods[method] = function(data){ 4838 | return this.send({ 4839 | data: data, 4840 | method: method 4841 | }); 4842 | }; 4843 | }); 4844 | 4845 | Request.implement(methods); 4846 | 4847 | Element.Properties.send = { 4848 | 4849 | set: function(options){ 4850 | var send = this.get('send').cancel(); 4851 | send.setOptions(options); 4852 | return this; 4853 | }, 4854 | 4855 | get: function(){ 4856 | var send = this.retrieve('send'); 4857 | if (!send){ 4858 | send = new Request({ 4859 | data: this, link: 'cancel', method: this.get('method') || 'post', url: this.get('action') 4860 | }); 4861 | this.store('send', send); 4862 | } 4863 | return send; 4864 | } 4865 | 4866 | }; 4867 | 4868 | Element.implement({ 4869 | 4870 | send: function(url){ 4871 | var sender = this.get('send'); 4872 | sender.send({data: this, url: url || sender.options.url}); 4873 | return this; 4874 | } 4875 | 4876 | }); 4877 | 4878 | })(); 4879 | 4880 | /* 4881 | --- 4882 | 4883 | name: Request.HTML 4884 | 4885 | description: Extends the basic Request Class with additional methods for interacting with HTML responses. 4886 | 4887 | license: MIT-style license. 4888 | 4889 | requires: [Element, Request] 4890 | 4891 | provides: Request.HTML 4892 | 4893 | ... 4894 | */ 4895 | 4896 | Request.HTML = new Class({ 4897 | 4898 | Extends: Request, 4899 | 4900 | options: { 4901 | update: false, 4902 | append: false, 4903 | evalScripts: true, 4904 | filter: false, 4905 | headers: { 4906 | Accept: 'text/html, application/xml, text/xml, */*' 4907 | } 4908 | }, 4909 | 4910 | success: function(text){ 4911 | var options = this.options, response = this.response; 4912 | 4913 | response.html = text.stripScripts(function(script){ 4914 | response.javascript = script; 4915 | }); 4916 | 4917 | var match = response.html.match(/]*>([\s\S]*?)<\/body>/i); 4918 | if (match) response.html = match[1]; 4919 | var temp = new Element('div').set('html', response.html); 4920 | 4921 | response.tree = temp.childNodes; 4922 | response.elements = temp.getElements('*'); 4923 | 4924 | if (options.filter) response.tree = response.elements.filter(options.filter); 4925 | if (options.update) document.id(options.update).empty().set('html', response.html); 4926 | else if (options.append) document.id(options.append).adopt(temp.getChildren()); 4927 | if (options.evalScripts) Browser.exec(response.javascript); 4928 | 4929 | this.onSuccess(response.tree, response.elements, response.html, response.javascript); 4930 | } 4931 | 4932 | }); 4933 | 4934 | Element.Properties.load = { 4935 | 4936 | set: function(options){ 4937 | var load = this.get('load').cancel(); 4938 | load.setOptions(options); 4939 | return this; 4940 | }, 4941 | 4942 | get: function(){ 4943 | var load = this.retrieve('load'); 4944 | if (!load){ 4945 | load = new Request.HTML({data: this, link: 'cancel', update: this, method: 'get'}); 4946 | this.store('load', load); 4947 | } 4948 | return load; 4949 | } 4950 | 4951 | }; 4952 | 4953 | Element.implement({ 4954 | 4955 | load: function(){ 4956 | this.get('load').send(Array.link(arguments, {data: Type.isObject, url: Type.isString})); 4957 | return this; 4958 | } 4959 | 4960 | }); 4961 | 4962 | 4963 | /* 4964 | --- 4965 | 4966 | name: JSON 4967 | 4968 | description: JSON encoder and decoder. 4969 | 4970 | license: MIT-style license. 4971 | 4972 | See Also: 4973 | 4974 | requires: [Array, String, Number, Function] 4975 | 4976 | provides: JSON 4977 | 4978 | ... 4979 | */ 4980 | 4981 | if (!this.JSON) this.JSON = {}; 4982 | 4983 | 4984 | 4985 | Object.append(JSON, { 4986 | 4987 | $specialChars: {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'}, 4988 | 4989 | $replaceChars: function(chr){ 4990 | return JSON.$specialChars[chr] || '\\u00' + Math.floor(chr.charCodeAt() / 16).toString(16) + (chr.charCodeAt() % 16).toString(16); 4991 | }, 4992 | 4993 | encode: function(obj){ 4994 | switch (typeOf(obj)){ 4995 | case 'string': 4996 | return '"' + obj.replace(/[\x00-\x1f\\"]/g, JSON.$replaceChars) + '"'; 4997 | case 'array': 4998 | return '[' + String(obj.map(JSON.encode).clean()) + ']'; 4999 | case 'object': case 'hash': 5000 | var string = []; 5001 | Object.each(obj, function(value, key){ 5002 | var json = JSON.encode(value); 5003 | if (json) string.push(JSON.encode(key) + ':' + json); 5004 | }); 5005 | return '{' + string + '}'; 5006 | case 'number': case 'boolean': return String(obj); 5007 | case 'null': return 'null'; 5008 | } 5009 | return null; 5010 | }, 5011 | 5012 | decode: function(string, secure){ 5013 | if (typeOf(string) != 'string' || !string.length) return null; 5014 | if (secure && !(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''))) return null; 5015 | return eval('(' + string + ')'); 5016 | } 5017 | 5018 | }); 5019 | 5020 | 5021 | /* 5022 | --- 5023 | 5024 | name: Request.JSON 5025 | 5026 | description: Extends the basic Request Class with additional methods for sending and receiving JSON data. 5027 | 5028 | license: MIT-style license. 5029 | 5030 | requires: [Request, JSON] 5031 | 5032 | provides: Request.JSON 5033 | 5034 | ... 5035 | */ 5036 | 5037 | Request.JSON = new Class({ 5038 | 5039 | Extends: Request, 5040 | 5041 | options: { 5042 | secure: true 5043 | }, 5044 | 5045 | initialize: function(options){ 5046 | this.parent(options); 5047 | Object.append(this.headers, { 5048 | 'Accept': 'application/json', 5049 | 'X-Request': 'JSON' 5050 | }); 5051 | }, 5052 | 5053 | success: function(text){ 5054 | var secure = this.options.secure; 5055 | var json = this.response.json = Function.attempt(function(){ 5056 | return JSON.decode(text, secure); 5057 | }); 5058 | 5059 | if (json == null) this.onFailure(); 5060 | else this.onSuccess(json, text); 5061 | } 5062 | 5063 | }); 5064 | 5065 | 5066 | /* 5067 | --- 5068 | 5069 | name: Cookie 5070 | 5071 | description: Class for creating, reading, and deleting browser Cookies. 5072 | 5073 | license: MIT-style license. 5074 | 5075 | credits: 5076 | - Based on the functions by Peter-Paul Koch (http://quirksmode.org). 5077 | 5078 | requires: Options 5079 | 5080 | provides: Cookie 5081 | 5082 | ... 5083 | */ 5084 | 5085 | var Cookie = new Class({ 5086 | 5087 | Implements: Options, 5088 | 5089 | options: { 5090 | path: '/', 5091 | domain: false, 5092 | duration: false, 5093 | secure: false, 5094 | document: document, 5095 | encode: true 5096 | }, 5097 | 5098 | initialize: function(key, options){ 5099 | this.key = key; 5100 | this.setOptions(options); 5101 | }, 5102 | 5103 | write: function(value){ 5104 | if (this.options.encode) value = encodeURIComponent(value); 5105 | if (this.options.domain) value += '; domain=' + this.options.domain; 5106 | if (this.options.path) value += '; path=' + this.options.path; 5107 | if (this.options.duration){ 5108 | var date = new Date(); 5109 | date.setTime(date.getTime() + this.options.duration * 24 * 60 * 60 * 1000); 5110 | value += '; expires=' + date.toGMTString(); 5111 | } 5112 | if (this.options.secure) value += '; secure'; 5113 | this.options.document.cookie = this.key + '=' + value; 5114 | return this; 5115 | }, 5116 | 5117 | read: function(){ 5118 | var value = this.options.document.cookie.match('(?:^|;)\\s*' + this.key.escapeRegExp() + '=([^;]*)'); 5119 | return (value) ? decodeURIComponent(value[1]) : null; 5120 | }, 5121 | 5122 | dispose: function(){ 5123 | new Cookie(this.key, Object.merge({}, this.options, {duration: -1})).write(''); 5124 | return this; 5125 | } 5126 | 5127 | }); 5128 | 5129 | Cookie.write = function(key, value, options){ 5130 | return new Cookie(key, options).write(value); 5131 | }; 5132 | 5133 | Cookie.read = function(key){ 5134 | return new Cookie(key).read(); 5135 | }; 5136 | 5137 | Cookie.dispose = function(key, options){ 5138 | return new Cookie(key, options).dispose(); 5139 | }; 5140 | 5141 | 5142 | /* 5143 | --- 5144 | 5145 | name: DOMReady 5146 | 5147 | description: Contains the custom event domready. 5148 | 5149 | license: MIT-style license. 5150 | 5151 | requires: [Browser, Element, Element.Event] 5152 | 5153 | provides: [DOMReady, DomReady] 5154 | 5155 | ... 5156 | */ 5157 | 5158 | (function(window, document){ 5159 | 5160 | var ready, 5161 | loaded, 5162 | checks = [], 5163 | shouldPoll, 5164 | timer, 5165 | isFramed = true; 5166 | 5167 | // Thanks to Rich Dougherty 5168 | try { 5169 | isFramed = window.frameElement != null; 5170 | } catch(e){} 5171 | 5172 | var domready = function(){ 5173 | clearTimeout(timer); 5174 | if (ready) return; 5175 | Browser.loaded = ready = true; 5176 | document.removeListener('DOMContentLoaded', domready).removeListener('readystatechange', check); 5177 | 5178 | document.fireEvent('domready'); 5179 | window.fireEvent('domready'); 5180 | }; 5181 | 5182 | var check = function(){ 5183 | for (var i = checks.length; i--;) if (checks[i]()){ 5184 | domready(); 5185 | return true; 5186 | } 5187 | 5188 | return false; 5189 | }; 5190 | 5191 | var poll = function(){ 5192 | clearTimeout(timer); 5193 | if (!check()) timer = setTimeout(poll, 10); 5194 | }; 5195 | 5196 | document.addListener('DOMContentLoaded', domready); 5197 | 5198 | // doScroll technique by Diego Perini http://javascript.nwbox.com/IEContentLoaded/ 5199 | var testElement = document.createElement('div'); 5200 | if (testElement.doScroll && !isFramed){ 5201 | checks.push(function(){ 5202 | try { 5203 | testElement.doScroll(); 5204 | return true; 5205 | } catch (e){} 5206 | 5207 | return false; 5208 | }); 5209 | shouldPoll = true; 5210 | } 5211 | 5212 | if (document.readyState) checks.push(function(){ 5213 | var state = document.readyState; 5214 | return (state == 'loaded' || state == 'complete'); 5215 | }); 5216 | 5217 | if ('onreadystatechange' in document) document.addListener('readystatechange', check); 5218 | else shouldPoll = true; 5219 | 5220 | if (shouldPoll) poll(); 5221 | 5222 | Element.Events.domready = { 5223 | onAdd: function(fn){ 5224 | if (ready) fn.call(this); 5225 | } 5226 | }; 5227 | 5228 | // Make sure that domready fires before load 5229 | Element.Events.load = { 5230 | base: 'load', 5231 | onAdd: function(fn){ 5232 | if (loaded && this == window) fn.call(this); 5233 | }, 5234 | condition: function(){ 5235 | if (this == window){ 5236 | domready(); 5237 | delete Element.Events.load; 5238 | } 5239 | 5240 | return true; 5241 | } 5242 | }; 5243 | 5244 | // This is based on the custom load event 5245 | window.addEvent('load', function(){ 5246 | loaded = true; 5247 | }); 5248 | 5249 | })(window, document); 5250 | 5251 | 5252 | /* 5253 | --- 5254 | 5255 | name: Swiff 5256 | 5257 | description: Wrapper for embedding SWF movies. Supports External Interface Communication. 5258 | 5259 | license: MIT-style license. 5260 | 5261 | credits: 5262 | - Flash detection & Internet Explorer + Flash Player 9 fix inspired by SWFObject. 5263 | 5264 | requires: [Options, Object] 5265 | 5266 | provides: Swiff 5267 | 5268 | ... 5269 | */ 5270 | 5271 | (function(){ 5272 | 5273 | var id = 0; 5274 | 5275 | var Swiff = this.Swiff = new Class({ 5276 | 5277 | Implements: Options, 5278 | 5279 | options: { 5280 | id: null, 5281 | height: 1, 5282 | width: 1, 5283 | container: null, 5284 | properties: {}, 5285 | params: { 5286 | quality: 'high', 5287 | allowScriptAccess: 'always', 5288 | wMode: 'window', 5289 | swLiveConnect: true 5290 | }, 5291 | callBacks: {}, 5292 | vars: {} 5293 | }, 5294 | 5295 | toElement: function(){ 5296 | return this.object; 5297 | }, 5298 | 5299 | initialize: function(path, options){ 5300 | this.instance = 'Swiff_' + id++; 5301 | 5302 | this.setOptions(options); 5303 | options = this.options; 5304 | var id = this.id = options.id || this.instance; 5305 | var container = document.id(options.container); 5306 | 5307 | Swiff.CallBacks[this.instance] = {}; 5308 | 5309 | var params = options.params, vars = options.vars, callBacks = options.callBacks; 5310 | var properties = Object.append({height: options.height, width: options.width}, options.properties); 5311 | 5312 | var self = this; 5313 | 5314 | for (var callBack in callBacks){ 5315 | Swiff.CallBacks[this.instance][callBack] = (function(option){ 5316 | return function(){ 5317 | return option.apply(self.object, arguments); 5318 | }; 5319 | })(callBacks[callBack]); 5320 | vars[callBack] = 'Swiff.CallBacks.' + this.instance + '.' + callBack; 5321 | } 5322 | 5323 | params.flashVars = Object.toQueryString(vars); 5324 | if (Browser.ie){ 5325 | properties.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; 5326 | params.movie = path; 5327 | } else { 5328 | properties.type = 'application/x-shockwave-flash'; 5329 | } 5330 | properties.data = path; 5331 | 5332 | var build = ''; 5337 | } 5338 | build += ''; 5339 | this.object = ((container) ? container.empty() : new Element('div')).set('html', build).firstChild; 5340 | }, 5341 | 5342 | replaces: function(element){ 5343 | element = document.id(element, true); 5344 | element.parentNode.replaceChild(this.toElement(), element); 5345 | return this; 5346 | }, 5347 | 5348 | inject: function(element){ 5349 | document.id(element, true).appendChild(this.toElement()); 5350 | return this; 5351 | }, 5352 | 5353 | remote: function(){ 5354 | return Swiff.remote.apply(Swiff, [this.toElement()].extend(arguments)); 5355 | } 5356 | 5357 | }); 5358 | 5359 | Swiff.CallBacks = {}; 5360 | 5361 | Swiff.remote = function(obj, fn){ 5362 | var rs = obj.CallFunction('' + __flash__argumentsToXML(arguments, 2) + ''); 5363 | return eval(rs); 5364 | }; 5365 | 5366 | })(); 5367 | 5368 | -------------------------------------------------------------------------------- /Examples/mootools-more-1.3.2.1.js: -------------------------------------------------------------------------------- 1 | // MooTools: the javascript framework. 2 | // Load this file's selection again by visiting: http://mootools.net/more/cbf2909f532bfaecd87d1f6d8da99cb8 3 | // Or build this file again with packager using: packager build More/Fx.Accordion 4 | /* 5 | --- 6 | copyrights: 7 | - [MooTools](http://mootools.net) 8 | 9 | licenses: 10 | - [MIT License](http://mootools.net/license.txt) 11 | ... 12 | */ 13 | MooTools.More={version:"1.3.2.1",build:"e586bcd2496e9b22acfde32e12f84d49ce09e59d"};Fx.Elements=new Class({Extends:Fx.CSS,initialize:function(b,a){this.elements=this.subject=$$(b); 14 | this.parent(a);},compute:function(g,h,j){var c={};for(var d in g){var a=g[d],e=h[d],f=c[d]={};for(var b in a){f[b]=this.parent(a[b],e[b],j);}}return c; 15 | },set:function(b){for(var c in b){if(!this.elements[c]){continue;}var a=b[c];for(var d in a){this.render(this.elements[c],d,a[d],this.options.unit);}}return this; 16 | },start:function(c){if(!this.check(c)){return this;}var h={},j={};for(var d in c){if(!this.elements[d]){continue;}var f=c[d],a=h[d]={},g=j[d]={};for(var b in f){var e=this.prepare(this.elements[d],b,f[b]); 17 | a[b]=e.from;g[b]=e.to;}}return this.parent(h,j);}});Fx.Accordion=new Class({Extends:Fx.Elements,options:{fixedHeight:false,fixedWidth:false,display:0,show:false,height:true,width:false,opacity:true,alwaysHide:false,trigger:"click",initialDisplayFx:true,resetHeight:true},initialize:function(){var g=function(h){return h!=null; 18 | };var f=Array.link(arguments,{container:Type.isElement,options:Type.isObject,togglers:g,elements:g});this.parent(f.elements,f.options);var b=this.options,e=this.togglers=$$(f.togglers); 19 | this.previous=-1;this.internalChain=new Chain();if(b.alwaysHide){this.options.link="chain";}if(b.show||this.options.show===0){b.display=false;this.previous=b.show; 20 | }if(b.start){b.display=false;b.show=false;}var d=this.effects={};if(b.opacity){d.opacity="fullOpacity";}if(b.width){d.width=b.fixedWidth?"fullWidth":"offsetWidth"; 21 | }if(b.height){d.height=b.fixedHeight?"fullHeight":"scrollHeight";}for(var c=0,a=e.length;c=0?a-1:0)).chain(d);}else{d();}return this;},detach:function(b){var a=function(c){c.removeEvent(this.options.trigger,c.retrieve("accordion:display")); 29 | }.bind(this);if(!b){this.togglers.each(a);}else{a(b);}return this;},display:function(b,c){if(!this.check(b,c)){return this;}var h={},g=this.elements,a=this.options,f=this.effects; 30 | if(c==null){c=true;}if(typeOf(b)=="element"){b=g.indexOf(b);}if(b==this.previous&&!a.alwaysHide){return this;}if(a.resetHeight){var e=g[this.previous]; 31 | if(e&&!this.selfHidden){for(var d in f){e.setStyle(d,e[f[d]]);}}}if((this.timer&&a.link=="chain")||(b===this.previous&&!a.alwaysHide)){return this;}this.previous=b; 32 | this.selfHidden=false;g.each(function(l,k){h[k]={};var j;if(k!=b){j=true;}else{if(a.alwaysHide&&((l.offsetHeight>0&&a.height)||l.offsetWidth>0&&a.width)){j=true; 33 | this.selfHidden=true;}}this.fireEvent(j?"background":"active",[this.togglers[k],l]);for(var m in f){h[k][m]=j?0:l[f[m]];}if(!c&&!j&&a.resetHeight){h[k].height="auto"; 34 | }},this);this.internalChain.clearChain();this.internalChain.chain(function(){if(a.resetHeight&&!this.selfHidden){var i=g[b];if(i){i.setStyle("height","auto"); 35 | }}}.bind(this));return c?this.start(h):this.set(h).internalChain.callChain();}}); -------------------------------------------------------------------------------- /Examples/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fx.Tween.CSS3 Demo 6 | 7 | 32 | 33 | 34 | 35 | 133 | 134 | 135 | 136 |
137 | Fx.Tween Fx.Tween.CSS3 138 |
139 |
140 | 141 | 142 |
​ 143 | 144 | -------------------------------------------------------------------------------- /Examples/test1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fx.Tween.CSS3 Demo 6 | 7 | 19 | 20 | 21 | 22 | 62 | 63 | 64 | 65 |
66 | click here to test tween 67 |
​ 68 |
69 | click here to test morph 70 |
​ 71 | 72 | -------------------------------------------------------------------------------- /Examples/test2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fx.Tween.CSS3 Demo 6 | 7 | 31 | 32 | 33 | 34 | 101 | 102 | 103 | 104 |
105 | Fx.Tween Fx.Tween.CSS3 106 |
107 | 108 | -------------------------------------------------------------------------------- /Examples/test3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Fx.Tween.CSS3 Demo 6 | 7 | 24 | 25 | 26 | 27 | 49 | 50 | 51 | 52 |
53 |
54 | click here to test tween 55 |
56 |
57 | 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Fx.CSS3 2 | ========= 3 | 4 | Mimics the Fx behavior but tries to use native CSS3 transition if possible. 5 | Like the Fx effect, Fx.CSS3 is used to transition any CSS property from one value to another. 6 | 7 | 8 | ![Screenshot](https://github.com/mcfedr/mootools-fx-css3/raw/master/screen.png) 9 | 10 | 11 | Demos: 12 | ---------- 13 | 14 | - You can see a simple online demo in [this shell](http://jsfiddle.net/mcfedr/6tX7A/) 15 | - More complex demo: [SqueezeBox using Fx.Tween.CSS3](http://jsfiddle.net/SunboX/bmMCy/) 16 | 17 | 18 | Options, Events: 19 | ---------- 20 | 21 | See: [FX.Tween](http://mootools.net/docs/core/Fx/Fx.Tween) 22 | 23 | 24 | Notes: 25 | ---------- 26 | 27 | Only short notated transitions are supported as option.transition by Fx.Tween.CSS3. 28 | Like: 29 | 30 | new Fx.Tween.CSS3('myElementID', { 31 | 32 | transition: 'sine:in' 33 | 34 | }); 35 | 36 | 37 | Performance: 38 | ---------- 39 | 40 | #### Tested on OSX 10.6: 41 | 42 | - Safari 4: 30% faster than Fx.Tween 43 | - Google Chrome 5: nearly equal compared to Fx.Tween 44 | - Firefox 3.6.3: nearly equal compared to Fx.Tween 45 | - Opera 10.53: nearly equal compared to Fx.Tween 46 | 47 | #### Tested on iPhone 3GS: 48 | 49 | - Mobile Safari: runns a lot faster (and smoother) than Fx.Tween (with default fps) 50 | 51 | #### Tested on Windows 7: 52 | 53 | - Safari 4: a lot faster than Fx.Tween (200 running instances of Fx.Tween hangs the browser, 200 Fx.Tween.CSS3 instances still working (40% CPU usage)) 54 | - Google Chrome 5: 50% faster than Fx.Tween 55 | - Firefox 3.6.3: nearly equal compared to Fx.Tween 56 | - Opera 10.53: nearly equal compared to Fx.Tween 57 | 58 | 59 | How to use 60 | ---------- 61 | 62 | 63 | window.addEvent('domready', function(){ 64 | 65 | var fx = new Fx.Tween.CSS3('myElementID', { 66 | duration: 605, 67 | transition: 'quint:in:out' 68 | }); 69 | 70 | fx.addEvent('complete', function(){ 71 | alert('complete'); 72 | }); 73 | 74 | fx.start('height', 100, 300); 75 | 76 | }); 77 | 78 | 79 | 80 | License 81 | ---------- 82 | 83 | See [license](http://github.com/mcfedr/mootools-fx-css3/blob/master/license) file. -------------------------------------------------------------------------------- /Source/.nfs9FF14: -------------------------------------------------------------------------------- 1 | /* 2 | --- 3 | name: Fx.Tween.CSS3.Replacement 4 | script: Fx.Tween.CSS3.Replacement.js 5 | license: MIT-style license. 6 | description: Same behavior like Fx.Tween but tries to use native CSS3 transition if possible (Overwrites Fx.Tween). 7 | copyright: Copyright (c) 2010, Dipl.-Ing. (FH) André Fiedler , based on code by eskimoblood (mootools users group) 8 | authors: [André Fiedler, eskimoblood] 9 | 10 | requires: [Core/Class.Extras, Core/Element.Event, Core/Element.Style, Core/Fx.Tween] 11 | 12 | provides: [Fx.Tween] 13 | ... 14 | */ 15 | 16 | Element.NativeEvents.transitionend = 2; 17 | Element.NativeEvents.webkitTransitionEnd = 2; 18 | Element.NativeEvents.oTransitionEnd = 2; 19 | 20 | Element.Events.transitionend = { 21 | base: Browser.safari || Browser.chrome ? 'webkitTransitionEnd' : (Browser.opera ? 'oTransitionEnd' : 'transitionend') 22 | }; 23 | 24 | Event.implement({ 25 | 26 | getPropertyName: function(){ 27 | return this.event.propertyName; 28 | }, 29 | 30 | getElapsedTime: function(nativeTime){ 31 | return nativeTime ? this.event.elapsedTime : (this.event.elapsedTime * 1000).toInt(); 32 | } 33 | 34 | }); 35 | 36 | Element.implement({ 37 | 38 | supportStyle: function(style){ 39 | var value = this.style[style]; 40 | return !!(value || value == ''); 41 | }, 42 | 43 | supportVendorStyle: function(style){ 44 | var prefixedStyle = null; 45 | return this.supportStyle(style) ? style : ['webkit', 'Moz', 'o'].some(function(prefix){ 46 | prefixedStyle = prefix + style.capitalize(); 47 | return this.supportStyle(prefixedStyle); 48 | }, this) ? prefixedStyle : null; 49 | } 50 | 51 | }); 52 | 53 | Fx.TweenCSS2 = Fx.Tween; 54 | 55 | Fx.Tween = new Class({ 56 | 57 | Extends: Fx.TweenCSS2, 58 | 59 | transitionTimings: { 60 | 'linear' : '0,0,1,1', 61 | 'expo:in' : '0.71,0.01,0.83,0', 62 | 'expo:out' : '0.14,1,0.32,0.99', 63 | 'expo:in:out' : '0.85,0,0.15,1', 64 | 'circ:in' : '0.34,0,0.96,0.23', 65 | 'circ:out' : '0,0.5,0.37,0.98', 66 | 'circ:in:out' : '0.88,0.1,0.12,0.9', 67 | 'sine:in' : '0.22,0.04,0.36,0', 68 | 'sine:out' : '0.04,0,0.5,1', 69 | 'sine:in:out' : '0.37,0.01,0.63,1', 70 | 'quad:in' : '0.14,0.01,0.49,0', 71 | 'quad:out' : '0.01,0,0.43,1', 72 | 'quad:in:out' : '0.47,0.04,0.53,0.96', 73 | 'cubic:in' : '0.35,0,0.65,0', 74 | 'cubic:out' : '0.09,0.25,0.24,1', 75 | 'cubic:in:out' : '0.66,0,0.34,1', 76 | 'quart:in' : '0.69,0,0.76,0.17', 77 | 'quart:out' : '0.26,0.96,0.44,1', 78 | 'quart:in:out' : '0.76,0,0.24,1', 79 | 'quint:in' : '0.64,0,0.78,0', 80 | 'quint:out' : '0.22,1,0.35,1', 81 | 'quint:in:out' : '0.9,0,0.1,1' 82 | }, 83 | 84 | initialize: function(element, options){ 85 | options.transition = options.transition || 'sine:in:out'; 86 | this.parent(element, options); 87 | if (typeof this.options.transition != 'string') alert('Only short notated transitions (like \'sine:in\') are supported by Fx.Tween.CSS3'); 88 | this.options.transition = this.options.transition.toLowerCase(); 89 | this.transition = this.element.supportVendorStyle('transition'); 90 | this.css3Supported = !!this.transition && !!this.transitionTimings[this.options.transition]; 91 | }, 92 | 93 | check: function(){ 94 | if (!this.boundComplete) return true; 95 | return this.parent(); 96 | }, 97 | 98 | start: function(property, from, to){ 99 | if (this.css3Supported){ 100 | if (!this.check(property, from, to)) return this; 101 | var args = Array.flatten(arguments); 102 | this.property = this.options.property || args.shift(); 103 | var parsed = this.prepare(this.element, this.property, args); 104 | this.from = parsed.from; 105 | this.to = parsed.to; 106 | this.boundComplete = function(event){ 107 | if (event.getPropertyName() == this.property /* && event.getElapsedTime() == this.options.duration */ ){ 108 | this.element.removeEvent('transitionend', this.boundComplete); 109 | this.boundComplete = null; 110 | this.onComplete(); 111 | } 112 | }.bind(this); 113 | this.element.addEvent('transitionend', this.boundComplete); 114 | var trans = function(){ 115 | this.element.setStyle(this.transition, this.property + ' ' + this.options.duration + 'ms cubic-bezier(' + this.transitionTimings[this.options.transition] + ')'); 116 | this.element.setStyle(this.property, this.to[0].value); 117 | }.bind(this); 118 | if (args[1]){ 119 | this.element.setStyle(this.transition, 'none'); 120 | this.element.setStyle(this.property, this.from[0].value); 121 | trans.delay(0.1); 122 | } else 123 | trans(); 124 | this.onStart(); 125 | return this; 126 | } 127 | return this.parent(property, from, to); 128 | }, 129 | 130 | cancel: function(){ 131 | if (this.css3Supported){ 132 | this.element.setStyle(this.transition, 'none'); 133 | this.element.removeEvent('transitionend', this.boundComplete); 134 | this.boundComplete = null; 135 | } 136 | this.parent(); 137 | return this; 138 | } 139 | 140 | }); 141 | -------------------------------------------------------------------------------- /Source/Fx.CSS3.js: -------------------------------------------------------------------------------- 1 | /* 2 | --- 3 | name: Fx.CSS3 4 | script: Fx.CSS3.js 5 | license: MIT-style license. 6 | description: Provides the CSS3 implementations of Tween, Morph and Elements 7 | copyright: Copyright (c) 2010, Dipl.-Ing. (FH) André Fiedler , based on code by eskimoblood (mootools users group) 8 | copyright: Copyright (c) 2011 Fred Cox mcfedr@gmail.com 9 | authors: [Fred Cox, André Fiedler, eskimoblood] 10 | 11 | requires: [Core/Class.Extras, Core/Element.Event, Core/Element.Style, Core/Fx, Core/Fx.Tween, Core/Fx.Morph, More/Array.Extras, More/Fx.Elements] 12 | 13 | provides: [Fx.Tween.CSS3, Fx.Morph.CSS3, Fx.Elements.CSS3] 14 | ... 15 | */ 16 | 17 | (function() { 18 | 19 | Object.extend({ 20 | 21 | isEqual: function(a, b){ 22 | // Check object identity. 23 | if (a === b) return true; 24 | // Different types? 25 | var atype = typeOf(a), btype = typeOf(b); 26 | if (atype != btype) return false; 27 | // Basic equality test (watch out for coercions). 28 | if (a == b) return true; 29 | // One is falsy and the other truthy. 30 | if ((!a && b) || (a && !b)) return false; 31 | // One of them implements an isEqual()? 32 | if (a.isEqual) return a.isEqual(b); 33 | if (b.isEqual) return b.isEqual(a); 34 | // Both are NaN? 35 | if ((a !== a) && (b !== b)) return false; 36 | // Check dates' integer values. 37 | if (atype == 'date') return a.getTime() === b.getTime(); 38 | if (atype == 'function') return true; 39 | // Compare regular expressions. 40 | if (atype == 'regexp') 41 | return a.source === b.source && 42 | a.global === b.global && 43 | a.ignoreCase === b.ignoreCase && 44 | a.multiline === b.multiline; 45 | // If a is not an object by this point, we can't handle it. 46 | if (atype !== 'object' && atype !== 'array') return false; 47 | // Check for different array lengths before comparing contents. 48 | if (a.length && (a.length !== b.length)) return false; 49 | // Nothing else worked, deep compare the contents. 50 | var aKeys = Object.keys(a), bKeys = Object.keys(b); 51 | // Different object sizes? 52 | if (aKeys.length != bKeys.length) return false; 53 | // Recursive comparison of contents. 54 | for (var key in a) if (!(key in b) || !Object.isEqual(a[key], b[key])) return false; 55 | return true; 56 | } 57 | 58 | }); 59 | 60 | var css3Features = (function(){ 61 | 62 | var prefix = (function(){ 63 | var prefixes = ['ms', 'O', 'Moz', 'webkit'], 64 | style = document.documentElement.style; 65 | for (var l = prefixes.length; l--;){ 66 | var prefix = prefixes[l]; 67 | if (typeof style[prefix + 'Transition'] != 'undefined') return prefix; 68 | } 69 | return false; 70 | })(); 71 | 72 | if(prefix) { 73 | return { 74 | transition: prefix + 'Transition', 75 | transitionProperty: prefix + 'TransitionProperty', 76 | transitionDuration: prefix + 'TransitionDuration', 77 | transitionTimingFunction : prefix + 'TransitionTimingFunction', 78 | transitionend: prefix == 'Moz' ? 'transitionend' : (prefix == 'ms' ? 'MS' : prefix) + 'TransitionEnd' 79 | } 80 | } 81 | return false; 82 | })(); 83 | 84 | Element.NativeEvents[css3Features.transitionend] = 2; 85 | 86 | (window.DOMEvent||window.Event).implement({ 87 | getPropertyName: function(){ 88 | return this.event.propertyName; 89 | }, 90 | 91 | getElapsedTime: function(nativeTime){ 92 | return nativeTime ? this.event.elapsedTime : (this.event.elapsedTime * 1000).toInt(); 93 | } 94 | }); 95 | 96 | Array.implement({ 97 | containsArray: function(array) { 98 | return array.every(function(v) { 99 | return this.contains(v); 100 | }, this); 101 | } 102 | }); 103 | 104 | var transitionTimings = { 105 | 'linear' : '0,0,1,1', 106 | 'expo:in' : '0.71,0.01,0.83,0', 107 | 'expo:out' : '0.14,1,0.32,0.99', 108 | 'expo:in:out' : '0.85,0,0.15,1', 109 | 'circ:in' : '0.34,0,0.96,0.23', 110 | 'circ:out' : '0,0.5,0.37,0.98', 111 | 'circ:in:out' : '0.88,0.1,0.12,0.9', 112 | 'sine:in' : '0.22,0.04,0.36,0', 113 | 'sine:out' : '0.04,0,0.5,1', 114 | 'sine:in:out' : '0.37,0.01,0.63,1', 115 | 'quad:in' : '0.14,0.01,0.49,0', 116 | 'quad:out' : '0.01,0,0.43,1', 117 | 'quad:in:out' : '0.47,0.04,0.53,0.96', 118 | 'cubic:in' : '0.35,0,0.65,0', 119 | 'cubic:out' : '0.09,0.25,0.24,1', 120 | 'cubic:in:out' : '0.66,0,0.34,1', 121 | 'quart:in' : '0.69,0,0.76,0.17', 122 | 'quart:out' : '0.26,0.96,0.44,1', 123 | 'quart:in:out' : '0.76,0,0.24,1', 124 | 'quint:in' : '0.64,0,0.78,0', 125 | 'quint:out' : '0.22,1,0.35,1', 126 | 'quint:in:out' : '0.9,0,0.1,1' 127 | }; 128 | 129 | var animatable = ['background-color', 'border-bottom-width', 'border-left-width', 'border-right-width', 130 | 'border-spacing', 'border-top-width', 'border-width', 'bottom', 'color', 'font-size', 'font-weight', 131 | 'height', 'left', 'letter-spacing', 'line-height', 'margin-bottom', 'margin-left', 'margin-right', 132 | 'margin-top', 'max-height', 'max-width', 'min-height', 'min-width', 'opacity', 'outline-color', 'outline-offset', 133 | 'outline-width', 'padding-bottom', 'padding-left', 'padding-right', 'padding-top', 'right', 'text-indent', 134 | 'top', 'vertical-align', 'visibility', 'width', 'word-spacing', 'z-index']; 135 | 136 | /* 137 | This is a list of properties listed by w3c but that are currently largely unsupported 138 | http://www.w3.org/TR/css3-transitions/#animatable-properties- 139 | http://www.opera.com/docs/specs/presto29/css/transitions/ 140 | 141 | var unsupported = ['background-image', 'background-position', 'border-bottom-color', 'border-color', 'border-left-color', 142 | 'border-right-color', 'border-top-color', 'crop', 'grid-*', 'text-shadow', 'zoom'] 143 | */ 144 | 145 | Fx.CSS3Funcs = { 146 | initialize: function(element, options){ 147 | if(css3Features) { 148 | options = options || {}; 149 | if(!options.transition || !transitionTimings[options.transition]) { 150 | options.transition = 'sine:in:out'; 151 | } 152 | if(this.initializeCSS3) { 153 | this.initializeCSS3(element, options); 154 | } 155 | } 156 | this.parent(element, options); 157 | }, 158 | 159 | startCSS3: function(properties, from, to) { 160 | 161 | if(!Object.isEqual(from, to)) { 162 | this.preTransStyles = this.element.getStyles(Fx.CSS3Funcs.css3Features.transitionProperty, 163 | Fx.CSS3Funcs.css3Features.transitionDuration, 164 | Fx.CSS3Funcs.css3Features.transitionTimingFunction); 165 | 166 | var incomplete = {}; 167 | properties.each(function(p) { 168 | incomplete[p] = false; 169 | }); 170 | 171 | this.animatingProperties = properties; 172 | 173 | this.boundComplete = function(e) { 174 | incomplete[e.getPropertyName()] = true; 175 | if(Object.every(incomplete, function(v) { return v; })) { 176 | this.element.removeEvent(Fx.CSS3Funcs.css3Features.transitionend, this.boundComplete); 177 | this.element.setStyles(this.preTransStyles); 178 | this.boundComplete = null; 179 | this.fireEvent('complete', this.subject); 180 | if (!this.callChain()) this.fireEvent('chainComplete', this.subject); 181 | } 182 | }.bind(this); 183 | 184 | this.element.addEvent(Fx.CSS3Funcs.css3Features.transitionend, this.boundComplete); 185 | var trans = function(){ 186 | var transStyles = {}; 187 | transStyles[Fx.CSS3Funcs.css3Features.transitionProperty] = 188 | properties.reduce(function(a, b) { return a + ', ' + b; }); 189 | // check if duration is a valid string or number 190 | transStyles[Fx.CSS3Funcs.css3Features.transitionDuration] = (Fx.Durations[this.options.duration] || this.options.duration.toInt() || 500) + 'ms'; 191 | transStyles[Fx.CSS3Funcs.css3Features.transitionTimingFunction] = 192 | 'cubic-bezier(' + Fx.CSS3Funcs.transitionTimings[this.options.transition] + ')'; 193 | this.element.setStyles(transStyles); 194 | this.set(this.compute(from, to, 1)); 195 | }.bind(this); 196 | 197 | this.element.setStyle(Fx.CSS3Funcs.css3Features.transitionProperty, 'none'); 198 | this.set(this.compute(from, to, 0)); 199 | trans.delay(0.1); 200 | this.fireEvent('start', this.subject); 201 | } 202 | else { 203 | this.fireEvent('start', this.subject); 204 | this.fireEvent('complete', this.subject); 205 | } 206 | return this; 207 | }, 208 | 209 | pause: function() { 210 | if (this.css3Supported){ 211 | return this; 212 | } 213 | return this.parent(); 214 | }, 215 | 216 | resume: function() { 217 | if (this.css3Supported){ 218 | return this; 219 | } 220 | return this.parent(); 221 | }, 222 | 223 | isRunning: function() { 224 | if (this.css3Supported){ 225 | return !!this.boundComplete; 226 | } 227 | return this.parent(); 228 | } 229 | }; 230 | 231 | Fx.CSS3Funcs.css3Features = css3Features; 232 | Fx.CSS3Funcs.transitionTimings = transitionTimings; 233 | Fx.CSS3Funcs.animatable = animatable; 234 | 235 | Fx.CSS3Stop = { 236 | cancel: function(){ 237 | if (this.css3Supported){ 238 | if(this.isRunning()) { 239 | this.element.removeEvent(Fx.CSS3Funcs.css3Features.transitionend, this.boundComplete); 240 | this.element.setStyles(this.preTransStyles); 241 | this.boundComplete = null; 242 | this.fireEvent('cancel', this.subject); 243 | this.clearChain(); 244 | } 245 | return this; 246 | } 247 | return this.parent(); 248 | }, 249 | 250 | stop: function() { 251 | if (this.css3Supported){ 252 | if(this.isRunning()) { 253 | this.element.removeEvent(Fx.CSS3Funcs.css3Features.transitionend, this.boundComplete); 254 | this.element.setStyles(this.preTransStyles); 255 | this.boundComplete = null; 256 | this.fireEvent('complete', this.subject); 257 | if (!this.callChain()) this.fireEvent('chainComplete', this.subject); 258 | } 259 | return this; 260 | } 261 | return this.parent(); 262 | } 263 | }; 264 | 265 | })(); 266 | 267 | (function() { 268 | 269 | var tweenCSS2 = Fx.Tween; 270 | var tweenCSS3; 271 | 272 | tweenCSS3 = new Class({ 273 | 274 | Extends: tweenCSS2, 275 | 276 | checkCSS3: function(property){ 277 | return (Fx.CSS3Funcs.css3Features && Fx.CSS3Funcs.animatable.contains(property)); 278 | }, 279 | 280 | start: function(property, from, to){ 281 | var args = Array.flatten(arguments); 282 | this.property = this.options.property || args.shift(); 283 | if ((this.css3Supported = this.checkCSS3(this.property))) { 284 | if(!this.check(property, from, to)) return this; 285 | 286 | var parsed = this.prepare(this.element, this.property, args); 287 | return this.startCSS3([this.property], parsed.from, parsed.to); 288 | } 289 | return this.parent(property, from, to); 290 | } 291 | }); 292 | 293 | tweenCSS3.implement(Fx.CSS3Funcs); 294 | tweenCSS3.implement(Fx.CSS3Stop); 295 | 296 | Fx.Tween.CSS2 = tweenCSS2; 297 | Fx.Tween.CSS3 = tweenCSS3; 298 | 299 | })(); 300 | 301 | 302 | (function() { 303 | 304 | var morphCSS2 = Fx.Morph; 305 | var morphCSS3; 306 | 307 | morphCSS3 = new Class({ 308 | 309 | Extends: morphCSS2, 310 | 311 | checkCSS3: function(properties){ 312 | return (Fx.CSS3Funcs.css3Features && Fx.CSS3Funcs.animatable.containsArray(Object.keys(properties))); 313 | }, 314 | 315 | start: function(properties){ 316 | if ((this.css3Supported = this.checkCSS3(properties))) { 317 | if(!this.check(properties)) return this; 318 | 319 | if (typeof properties == 'string') properties = this.search(properties); 320 | var from = {}, to = {}, usedProps = []; 321 | for (var p in properties){ 322 | var parsed = this.prepare(this.element, p, properties[p]); 323 | if(!Object.isEqual(parsed.from, parsed.to)) { 324 | from[p] = parsed.from; 325 | to[p] = parsed.to; 326 | usedProps.push(p); 327 | } 328 | } 329 | return this.startCSS3(usedProps, from, to); 330 | } 331 | return this.parent(properties); 332 | } 333 | }); 334 | 335 | morphCSS3.implement(Fx.CSS3Funcs); 336 | morphCSS3.implement(Fx.CSS3Stop); 337 | 338 | Fx.Morph.CSS2 = morphCSS2; 339 | Fx.Morph.CSS3 = morphCSS3; 340 | })(); 341 | 342 | (function() { 343 | 344 | if(Fx.Elements) { 345 | 346 | var elementsCSS2 = Fx.Elements; 347 | var elementsCSS3; 348 | 349 | elementsCSS3 = new Class({ 350 | Extends: elementsCSS2, 351 | 352 | initializeCSS3: function(elements, options){ 353 | this.morphers = elements.map(function(element) { 354 | return new Fx.Morph(element, Object.merge({}, options, { 355 | onComplete: this._complete.bind(this), 356 | onCancel: this._cancel.bind(this) 357 | })); 358 | }.bind(this)); 359 | }, 360 | 361 | _complete: function() { 362 | if(--this.count == 0) { 363 | this.fireEvent('complete', this.subject); 364 | if (!this.callChain()) this.fireEvent('chainComplete', this.subject); 365 | } 366 | }, 367 | 368 | _cancel: function() { 369 | if(--this.count == 0) { 370 | this.fireEvent('cancel', this.subject); 371 | this.clearChain(); 372 | } 373 | }, 374 | 375 | checkCSS3: function(obj){ 376 | return (Fx.CSS3Funcs.css3Features && Object.every(obj, function(properties, key) { 377 | if(properties && this.elements[key]) { 378 | return Fx.CSS3Funcs.animatable.containsArray(Object.keys(properties)); 379 | } 380 | return true; 381 | }, this)); 382 | }, 383 | 384 | count: 0, 385 | 386 | start: function(obj){ 387 | if ((this.css3Supported = this.checkCSS3(obj))) { 388 | if(!this.check(obj)) return this; 389 | this.count = 0; 390 | 391 | Object.each(obj, function(properties, key) { 392 | if(properties && this.elements[key]) { 393 | this.count++; 394 | this.morphers[key].start(properties); 395 | } 396 | }, this); 397 | 398 | this.fireEvent('start', this); 399 | return this; 400 | } 401 | return this.parent(obj); 402 | }, 403 | 404 | stop: function() { 405 | if(this.css3Supported) { 406 | Object.each(this.morphers, function(morph) { 407 | morph.stop(); 408 | }); 409 | return this; 410 | } 411 | return this.parent(); 412 | }, 413 | 414 | cancel: function() { 415 | if(this.css3Supported) { 416 | Object.each(this.morphers, function(morph) { 417 | morph.cancel(); 418 | }); 419 | return this; 420 | } 421 | return this.parent(); 422 | }, 423 | 424 | isRunning: function() { 425 | if(this.css3Supported) { 426 | return this.count != 0; 427 | } 428 | return this.parent(); 429 | } 430 | }); 431 | 432 | elementsCSS3.implement(Fx.CSS3Funcs); 433 | 434 | Fx.Elements.CSS2 = elementsCSS2; 435 | Fx.Elements.CSS3 = elementsCSS3; 436 | 437 | } 438 | 439 | })(); 440 | 441 | /** 442 | * 'tweenCSS3' and 'morphCSS3' properties 443 | */ 444 | (function() { 445 | Element.Properties.tweenCSS3 = { 446 | set: function(options){ 447 | this.get('tweenCSS3').cancel().setOptions(options); 448 | return this; 449 | }, 450 | get: function(){ 451 | var tween = this.retrieve('tweenCSS3'); 452 | if (!tween){ 453 | tween = new Fx.Tween.CSS3(this, {link: 'cancel'}); 454 | this.store('tweenCSS3', tween); 455 | } 456 | return tween; 457 | } 458 | }; 459 | 460 | Element.Properties.morphCSS3 = { 461 | set: function(options){ 462 | this.get('morphCSS3').cancel().setOptions(options); 463 | return this; 464 | }, 465 | get: function(){ 466 | var morph = this.retrieve('morphCSS3'); 467 | if (!morph){ 468 | morph = new Fx.Morph.CSS3(this, {link: 'cancel'}); 469 | this.store('morphCSS3', morph); 470 | } 471 | return morph; 472 | } 473 | 474 | }; 475 | Element.implement({ 476 | tweenCSS3: function(property, from, to){ 477 | this.get('tweenCSS3').start(property, from, to); 478 | return this; 479 | }, 480 | morphCSS3: function(props){ 481 | this.get('morphCSS3').start(props); 482 | return this; 483 | } 484 | }); 485 | })(); 486 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2011 Fred Cox mcfedr@gmail.com 4 | Copyright (c) 2010 Dipl.-Ing. (FH) André Fiedler 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. -------------------------------------------------------------------------------- /package.yml: -------------------------------------------------------------------------------- 1 | name: Fx.CSS3 2 | 3 | current: 2.2.0 4 | 5 | web: "[github.com/mcfedr/mootools-fx-css3](http://github.com/mcfedr/mootools-fx-css3)" 6 | 7 | description: "Native CSS3 transition for Fx (if available)" 8 | 9 | authors: "[Fred Cox](http://fedr.co), [André Fiedler](http://visualdrugs.net)" 10 | 11 | license: "MIT License" 12 | 13 | copyright: "Copyright (c) 2011 Fred Cox mcfedr@gmail.com" 14 | copyright: "Copyright (c) 2010, Dipl.-Ing. (FH) André Fiedler , based on code by eskimoblood (mootools users group)" 15 | 16 | sources: 17 | - "Source/Fx.CSS3.js" 18 | 19 | # Values for MooTools forge 20 | 21 | author: mcfedr 22 | 23 | demo: http://jsfiddle.net/mcfedr/6tX7A/ 24 | 25 | category: Effects 26 | 27 | tags: [Effects, CSS3, transition, animation, element, behavioral] 28 | -------------------------------------------------------------------------------- /screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunboX/mootools-fx-tween-css3/87ff7a71b512ebeb78de4dd46744a18de9720add/screen.png --------------------------------------------------------------------------------