Skip to content

Instantly share code, notes, and snippets.

@teaholiday89
teaholiday89 / jq.detect.if.event.happened
Created April 19, 2013 21:21
jquery detect if event happened
var eventClick = null;
$("a").click(function() {
if (this === eventClick) {
alert("You've clicked this element twice.");
}
eventClick = this;
return false;
});
@teaholiday89
teaholiday89 / jqWidget
Created April 19, 2013 21:11
jquery widget example
$.widget("ui.MyWidget", $.ui.mouse, {
options: {
txtLabel: 'custom label text: ',
initValue: 50
},
_create: function () {
var
opts = this.options,
$this = this.element;
<snippet>
<content><![CDATA[
\$.get(${1:url}, ${2:\{property: value\}, }function(data, textStatus, xhr) \{
${0://do stuff}
});
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>jqget</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
<snippet>
<content><![CDATA[
<% if (${1:condition}) { %>
${2}
<% } else { %>
${3}
<% } %>
${0}
]]></content>
<snippet>
<content><![CDATA[
<%=${0}%>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>jspt</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
<snippet>
<content><![CDATA[
<% ${0} %>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>jspt</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
@teaholiday89
teaholiday89 / fetch.stuff
Created April 2, 2013 07:48
Fetch Libs
{
"files":
{
"angular.js": "https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js",
"dropdown.js": "https://raw.github.com/enyo/dropzone/master/downloads/dropzone.js",
"holder.js": "https://raw.github.com/imsky/holder/master/holder.js",
"howler.js": "https://raw.github.com/goldfire/howler.js/master/howler.min.js",
"jKit.js": "https://raw.github.com/FrediBach/jQuery-jKit/master/jquery-1.9.1.min.js",
"jq++": "http://jquerypp.com/downloads/jquerypp-1.0.1.zip",
"jquery.js": "http://code.jquery.com/jquery.min.js",
@teaholiday89
teaholiday89 / jqplugin.sublime-snippet
Created April 2, 2013 06:45
jQuery Plugin Boilerplate
<snippet>
<content><![CDATA[
/*
* jQuery ${1:plugin} Plugin
*
* ${2:Description}
*
*/
;(function(\$, window, undefined) {
@teaholiday89
teaholiday89 / jqajax.sublime-snippet
Created April 1, 2013 23:42
jQuery ajax with promises
<snippet>
<content><![CDATA[
\$.ajax({
type: "${1:POST}",
url: ${2:url},
dataType: "json",
data: ${3:json}
}).done(function (data, xhr, textStatus) {
${0}
})${4:.fail(function (xhr, textStatus, error) \{
<snippet>
<content><![CDATA[
function() {
${0}
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>lmd</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->