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 isFunction = function(target){ | |
var getType = {}; | |
return !!target && | |
(getType.toString.call(target) === '[object Function]' || | |
typeof target === 'function'); | |
}; | |
var objectExtend = function(where) { | |
Array.prototype.slice.call(arguments, 1).forEach(function(source) { | |
var key; |
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
// Transform a date string into an object, e.g. | |
// "2014-04" -> {0:"2014", 1:"04"} | |
translateDate: function(format, date){ | |
var args = Array.prototype.slice.call(arguments); | |
var dates = date.split('-'); | |
if(dates.length === 2){ | |
args.splice(1, 1, dates[0], dates[1]); | |
}else if(dates.length === 3){ | |
args.splice(1, 1, dates[0], dates[1], dates[2]); | |
} |
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
/* | |
@param | |
date: '2014-01' | |
@return | |
'2014-02' | |
*/ | |
function getNextMonth(date){ | |
var current = moment(date).month(); | |
return moment(date).month(current + 1).format("YYYY-MM"); | |
} |
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
/* | |
* Extract from <JavaScript: The Good Parts> | |
* General routine with cache for recursive function invoking | |
*/ | |
var cacheCompute = function(cache, compute){ | |
var shell = function(n){ | |
var result = cache[n]; | |
if(typeof result !== 'number'){ | |
result = compute(shell, n); | |
cache[n] = result; |
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
<div class="overlay"> | |
<div class="loading"></div> | |
<div class="fool-tooltip" data-tooltip="Processing...">Processing...</div> | |
</div> |
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
<snippet> | |
<content><![CDATA[ | |
import React from 'react'; | |
let ${1:componentName} = React.createClass({ | |
propTypes: { | |
}, | |
getInitialState() { | |
return {}; |
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(userAgent, fileName) { | |
var suffix = '.zip'; | |
if(userAgent.indexOf('msie') >= 0 || userAgent.indexOf('chrome') >= 0) { | |
return 'attachment; filename=' + encodeURIComponent(fileName) + suffix; | |
} else if(userAgent.indexOf('firefox') >= 0) { | |
return 'attachment; filename*="utf8\'\'' + encodeURIComponent(fileName)+'"' + suffix; | |
} else { | |
return 'attachment; filename=' + new Buffer(fileName).toString('binary') + suffix; | |
} | |
} |
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
module.exports = { | |
hasClassName: function(element, name) { | |
return new RegExp('(?:^|\\s+)' + name + '(?:\\s+|$)').test(element.className); | |
}, | |
addClassName: function(element, name) { | |
if (!this.hasClassName(element, name)) { | |
element.className = element.className ? [element.className, name].join(' ') : 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
for(var func in module.exports) { | |
if (typeof module.exports[func] === 'function') { | |
module.exports[func].displayName = func; | |
} | |
} |
OlderNewer