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
$.fn.transferClass = function (className) { | |
this.siblings().removeClass(className) | |
this.addClass(className) | |
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
(function () { | |
var abbrs = [] | |
var abbr = function (full) { | |
full = full | |
.replace(/^[^\w\d]+/, "") | |
.replace(/\s+/g, "_") | |
.replace(/[^\w\d]/g, "") | |
// Some's class => Somes_class | |
var abbr = full[0] | |
var testMatch; |
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
$.extend({ | |
replaceTag: function (element, tagName, withDataAndEvents, deepWithDataAndEvents) { | |
var newTag = $("<" + tagName + ">")[0] | |
// From [Stackoverflow: Copy all Attributes](http://stackoverflow.com/a/6753486/2096729) | |
$.each(element.attributes, function() { | |
newTag.setAttribute(this.name, this.value); | |
}); | |
$(element).children().clone(withDataAndEvents, deepWithDataAndEvents).appendTo(newTag) | |
return newTag | |
} |
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
@img = null | |
# Using an Image Object | |
getAspectRatio = (url, callback) -> | |
@img = img = new Image() | |
img.onload = -> | |
callback null, @width/@height, @width, @height | |
img.onerror = -> | |
callback "Failed loading #{url}" | |
img.src = url |
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
do renderBouncer = -> | |
if inlineImgEl.offsetWidth isnt 0 | |
inlineImgEl.style.height = (inlineImgEl.offsetWidth / ratio) + "px" | |
else if inlineImgEl.renderOffsetWidthTries++ > 20 | |
inlineImgEl.style.height = (width / ratio) + "px" | |
else | |
setTimeout(renderBouncer, 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
$(window).keyup(function(e) { | |
// esc - reduce selections | |
if(e.which === 27) { | |
var cmSel = $(".active-container.last-active .active-sub-container .CodeMirror") | |
if (cmSel.length === 0) | |
cmSel = $(".active-container.last-active .CodeMirror") | |
if (cmSel.length) { | |
var cm = cmSel[0].CodeMirror | |
cm.execCommand("singleSelectionTop") | |
cm.focus() |
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
process = (str, obj) -> | |
res = {} | |
bl = (cont_str, cobj) -> | |
if typeof cobj is 'object' | |
for k, v of cobj | |
bl cont_str + "[#{ k }]", v | |
else | |
res[cont_str] = cobj | |
bl str, obj | |
return res |
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
{Deferred} = require 'promise.coffee' | |
# Declare .then((value)->) | |
log = (value) -> | |
def = new Deferred | |
def.resolve console.log value | |
# return deferred | |
def.promise | |
# Declare time to delay |
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
{Deferred} = require 'promise.coffee' | |
fs = require 'fs' | |
nodeDef = (def) -> | |
(err, res) -> | |
if err? | |
def.reject err | |
else | |
def.resolve(res) |