This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Person = Class.create({ | |
| initialize: function(name) { | |
| this.name = name; | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Element.Methods.descendantOf = (function() { | |
| var doc = document.documentElement; | |
| // DOM Level 3 approach (Gecko, Opera) | |
| if ('compareDocumentPosition' in doc) { | |
| return function(element, ancestor) { | |
| return (element.compareDocumentPosition(ancestor) & 8) === 8 | |
| }; | |
| } | |
| // IE, Safari |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function cmpVersion(a,b) { | |
| var ai, bi; | |
| if (a.startsWith('.')) a = '0' + a; | |
| if (b.startsWith('.')) b = '0' + b; | |
| a = a.split('.'); | |
| b = b.split('.'); | |
| console.log(a,b) | |
| for (var i=0, l=Math.max(a.length, b.length); i<l; i++) { | |
| ai = typeof a[i] == 'undefined' ? 0 : parseInt(a[i]); | |
| bi = typeof b[i] == 'undefined' ? 0 : parseInt(b[i]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function() { | |
| var getText, setText; | |
| if ('innerText' in document.documentElement) { | |
| getText = function(element, shallow) { | |
| return (!shallow) ? $(element).innerText : getText(element); | |
| } | |
| setText = function(element, text) { | |
| (element = $(element)).innerText = text; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| var p = CObject.init().setLeft(100); | |
| p.left; // undefined | |
| p.getLeft(); 100 | |
| */ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var serializeElements = (function(){ | |
| function isSuccessful(element) { | |
| // http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2 | |
| return ( | |
| !element.disabled && // should not be disabled | |
| element.name && // should have a name | |
| !'^file|reset$'.test(element.type) && // should not be of `file` or `reset` types | |
| Element.getValue(element) != null // should have a non-null value | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Class.Methods.createAccessors = function() { | |
| var accessors = $A(arguments), proto = this.prototype; | |
| if (!accessors.length) { | |
| accessors = Object.keys(proto).reject(function(prop) { | |
| return Object.isFunction(proto[prop]); | |
| }); | |
| }; | |
| accessors.each(function(prop){ | |
| proto['get' + prop.capitalize()] = function(){ | |
| return this[prop]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;jQuery.fn.extend({ | |
| // Andrea Giammarchi - Mit Style Licence - V0.2 | |
| If: (jQuery.fn.ElseIf = function(fn){ | |
| var __If__ = this.__If__ || this, | |
| $ = __If__.filter(fn); | |
| $.__If__ = __If__.filter(function(){return !~$.index(this)}); | |
| return $; | |
| }), | |
| Else:function(){ | |
| return this.__If__; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var sourceIndex = (function(){ | |
| var root = document.documentElement, | |
| indexOf = Array.prototype.indexOf; | |
| if ('sourceIndex' in root) { | |
| if (root.sourceIndex === 0) { // Opera | |
| return function(e) { | |
| return e.sourceIndex + 1; | |
| } | |
| } | |
| else if (root.sourceIndex === 1) { // IE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Only one closure is created here - i.e. when one of these functions is returned from within anonymous-outer one. | |
| // That returned function will be part of the closure and have access to [[Scope]] of anonymous-outer one. | |
| // The returned function is the only Function object that's being created. | |
| // Function expressions from other blocks are never reached and so are never created | |
| var globalEval = (function(){ | |
| if (window.eval) { | |
| return function(s){ window.eval(s) } | |
| } | |
| else if (window.execScript) { |
OlderNewer