|
|
|
priority 1000
|
|
|
|
snippet class "Adds a class"
|
|
|
|
class ${1:class_name}{
|
|
|
|
/**
|
|
|
|
* this function is run as soon as possible.
|
|
|
|
* the dom isn't neccessarily loaded / parsed
|
|
|
|
**/
|
|
|
|
constructor(){
|
|
|
|
//Bind this in the following functions to the class
|
|
|
|
this.domLoaded = this.domLoaded.bind(this);
|
|
|
|
|
|
|
|
//check to see if the dom has loaded yet
|
|
|
|
if(document.readyState == "loading"){
|
|
|
|
//if the dom hasn't loaded, wait until it is
|
|
|
|
document.addEventListener("readystatechange",this.domLoaded);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
//if it has, run the domloaded function
|
|
|
|
this.domLoaded();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* this function is run as soon as the dom is loaded
|
|
|
|
**/
|
|
|
|
domLoaded(){
|
|
|
|
//make sure we don't run this twice
|
|
|
|
document.removeEventListener("readystatechange",this.domLoaded);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
new $1();
|
|
|
|
$0
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet bind "creates a bind statement"
|
|
|
|
this.${1:functionName} = this.$1.bind(this);
|
|
|
|
endsnippet
|