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
| if(!Object.prototype.slice){ | |
| Object.prototype.slice = function(){ | |
| var returnObj = {}; | |
| for(var i = 0, j = arguments.length; i < j; i++){ | |
| if(this.hasOwnProperty(arguments[i])){ | |
| returnObj[arguments[i]] = this[arguments[i]]; | |
| } | |
| } | |
| return returnObj; | |
| } |
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
| if(typeof Object.prototype.except !== 'function'){ | |
| Object.prototype.except = function(){ | |
| for(var i = 0, j = arguments.length; i < j; i++){ | |
| if(this.hasOwnProperty(arguments[i])){ | |
| delete this[arguments[i]]; | |
| } | |
| } | |
| return this; | |
| } | |
| } |
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
| // Douglas Crockford's Supplant | |
| if(!String.prototype.supplant){ | |
| String.prototype.supplant = function(o){ | |
| return this.replace(/\{([^{}]*)\}/g, function(a, b){ | |
| var r = o[b]; | |
| return typeof r === 'string' || typeof r === 'number' ? r : a; | |
| }); | |
| }; | |
| } |
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
| Array.prototype.remove = function(obj){ | |
| // Copy the array, so we don't override it | |
| var array = this.slice(0); | |
| for(var i = 0; i < array.length; i++){ | |
| // Use while-loop to find adjacent equal objects | |
| while(array[i] === obj){ | |
| // Remove this[i] | |
| array.splice(i, 1)[0]; |
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
| # in app/helpers | |
| class DefaultFormBuilder < ActionView::Helpers::FormBuilder | |
| # Example of an added method that wraps custom textfields, where type can be | |
| # :email_field, :text_field, etc. | |
| def textfield(type, method, attributes = {}) | |
| @template.content_tag :div, class: 'textfield' do | |
| @template.send(type, @object_name, method, objectify_options(attributes)) | |
| end | |
| end | |
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
| if(!Array.prototype.includes){ | |
| Array.prototype.includes = function(value, detectSimilarObjects){ | |
| if(typeof detectSimilarObjects === 'undefined' || typeof value !== 'object'){ | |
| detectSimilarObjects = false; | |
| } | |
| if(detectSimilarObjects === true && typeof equalObjects !== 'function'){ | |
| throw Error("Array.includes() does not recognize equalObjects(). Get it here: https://gist.github.com/zykadelic/6020024"); | |
| } | |
| for(i = 0; i < this.length; i++){ | |
| if(detectSimilarObjects ? equalObjects(this[i], value) : this[i] === 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
| function equalObjects(object, otherObject){ | |
| var objects = [object, otherObject]; | |
| for(var i = 0; i < objects.length; i++){ | |
| for(key in objects[i]){ | |
| var isUnequalObject = typeof(object[key]) === 'object' && !equalObjects(object[key], otherObject[key]); | |
| if(!object || !otherObject || isUnequalObject || object[key] !== otherObject[key]){ | |
| return false; | |
| } | |
| } | |
| } |
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
| if(!Date.now){ | |
| Date.now = function now(){ | |
| return new Date().getTime(); | |
| } | |
| } |
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
| .ui-placeholder-wrap { | |
| position: relative; | |
| display: block; | |
| -moz-user-select: -moz-none; | |
| -khtml-user-select: none; | |
| -webkit-user-select: none; | |
| user-select: none; | |
| } | |
| .ui-placeholder { | |
| position: absolute; |
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
| Array.prototype.destroy = function(obj){ | |
| // Return null if no objects were found and removed | |
| var destroyed = null; | |
| for(var i = 0; i < this.length; i++){ | |
| // Use while-loop to find adjacent equal objects | |
| while(this[i] === obj){ | |
| // Remove this[i] and store it within destroyed |
NewerOlder