2010-08-15 08:35:14 -04:00
|
|
|
###########################################################################
|
|
|
|
# TextMate Snippets #
|
|
|
|
###########################################################################
|
2009-07-12 14:16:59 -04:00
|
|
|
snippet get "Get Elements"
|
|
|
|
getElement${1/(T)|.*/(?1:s)/}By${1:T}${1/(T)|(I)|.*/(?1:agName)(?2:d)/}('$2')
|
|
|
|
endsnippet
|
|
|
|
|
2010-08-15 08:35:14 -04:00
|
|
|
snippet '':f "object method string"
|
2013-03-21 06:54:20 -04:00
|
|
|
'${1:${2:#thing}:${3:click}}': function(element) {
|
|
|
|
${VISUAL}$0
|
2009-07-12 14:16:59 -04:00
|
|
|
}${10:,}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet :f "Object Method"
|
2013-03-21 06:54:20 -04:00
|
|
|
${1:method_name}: function(${3:attribute}) {
|
|
|
|
${VISUAL}$0
|
2009-07-12 14:16:59 -04:00
|
|
|
}${10:,}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet :, "Object Value JS"
|
2013-03-21 06:54:20 -04:00
|
|
|
${1:value_name}: ${0:value},
|
2009-07-12 14:16:59 -04:00
|
|
|
endsnippet
|
|
|
|
|
2010-08-15 08:35:14 -04:00
|
|
|
snippet : "Object key key: 'value'"
|
2009-07-12 14:16:59 -04:00
|
|
|
${1:key}: ${2:"${3:value}"}${4:, }
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet proto "Prototype (proto)"
|
2013-03-21 06:54:20 -04:00
|
|
|
${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {
|
|
|
|
${VISUAL}$0
|
2009-07-12 14:16:59 -04:00
|
|
|
};
|
2013-03-21 06:54:20 -04:00
|
|
|
|
2009-07-12 14:16:59 -04:00
|
|
|
endsnippet
|
|
|
|
|
2010-08-15 08:35:14 -04:00
|
|
|
snippet for "for (...) {...} (faster)"
|
2013-03-21 06:54:20 -04:00
|
|
|
for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2--) {
|
|
|
|
${3:$1[$2]}${VISUAL}$0
|
2013-09-10 09:57:56 -04:00
|
|
|
}
|
2009-07-12 14:16:59 -04:00
|
|
|
endsnippet
|
|
|
|
|
2010-08-15 08:35:14 -04:00
|
|
|
snippet for "for (...) {...}"
|
|
|
|
for (var ${2:i}=0; $2 < ${1:Things}.length; $2++) {
|
2013-03-21 06:54:20 -04:00
|
|
|
${3:$1[$2]}${VISUAL}$0
|
2013-09-10 09:57:56 -04:00
|
|
|
}
|
2009-07-12 14:16:59 -04:00
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet fun "function (fun)"
|
2013-08-29 12:20:38 -04:00
|
|
|
function ${1:function_name}(${2:argument}) {
|
2013-03-21 06:54:20 -04:00
|
|
|
${VISUAL}$0
|
2009-07-12 14:16:59 -04:00
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
2013-03-21 06:54:20 -04:00
|
|
|
snippet iife "Immediately-Invoked Function Expression (iife)"
|
|
|
|
(function (${1:argument}) {
|
|
|
|
${VISUAL}$0
|
|
|
|
}(${2:$1}));
|
|
|
|
endsnippet
|
|
|
|
|
2009-07-12 14:16:59 -04:00
|
|
|
snippet ife "if ___ else"
|
2013-01-24 11:24:55 -05:00
|
|
|
if (${1:condition}) {
|
2013-03-21 06:54:20 -04:00
|
|
|
${2://code}
|
2013-01-24 11:24:55 -05:00
|
|
|
}
|
|
|
|
else {
|
2013-03-21 06:54:20 -04:00
|
|
|
${3://code}
|
2013-01-24 11:24:55 -05:00
|
|
|
}
|
2009-07-12 14:16:59 -04:00
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet if "if"
|
2013-01-24 11:24:55 -05:00
|
|
|
if (${1:condition}) {
|
2013-03-21 06:54:20 -04:00
|
|
|
${VISUAL}$0
|
2013-01-24 11:24:55 -05:00
|
|
|
}
|
2009-07-12 14:16:59 -04:00
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet timeout "setTimeout function"
|
2013-03-21 06:54:20 -04:00
|
|
|
setTimeout(function() {
|
|
|
|
${VISUAL}$0
|
|
|
|
}${2:.bind(${3:this})}, ${1:10});
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
# Snippets for Console Debug Output
|
|
|
|
|
|
|
|
snippet cl "console.log"
|
|
|
|
console.log(${1:"${2:value}"});
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet cw "console.warn"
|
|
|
|
console.warn(${1:"${2:value}"});
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet ce "console.error"
|
|
|
|
console.error(${1:"${2:value}"});
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet ca "console.assert"
|
|
|
|
console.assert(${1:assertion}, ${2:"${3:message}"});
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet cgroup "console.group"
|
|
|
|
console.group("${1:label}");
|
|
|
|
${VISUAL}$0
|
|
|
|
console.groupEnd();
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet ctime "console.time"
|
|
|
|
console.time("${1:label}");
|
|
|
|
${VISUAL}$0
|
|
|
|
console.timeEnd("$1");
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet ctimestamp "console.timestamp"
|
|
|
|
console.timeStamp("${1:label}")
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet ctrace "console.trace"
|
|
|
|
console.trace();
|
2009-07-12 14:16:59 -04:00
|
|
|
endsnippet
|
|
|
|
|
2013-08-20 06:42:10 -04:00
|
|
|
# AMD (Asynchronous Module Definition) snippets
|
2013-08-15 11:38:09 -04:00
|
|
|
|
2013-08-20 06:42:10 -04:00
|
|
|
snippet def "define an AMD module"
|
2013-08-15 11:38:09 -04:00
|
|
|
define(${1:optional_name, }[${2:'jquery'}], ${3:callback});
|
|
|
|
endsnippet
|
|
|
|
|
2013-08-20 06:42:10 -04:00
|
|
|
snippet req "require an AMD module"
|
2013-08-15 11:38:09 -04:00
|
|
|
require([${1:'dependencies'}], ${2:callback});
|
|
|
|
endsnippet
|
|
|
|
|
2011-02-17 08:07:27 -05:00
|
|
|
# vim:ft=snippets:
|