Skip to content

Instantly share code, notes, and snippets.

@wtfuii
Last active March 27, 2017 04:46
Show Gist options
  • Save wtfuii/10c42e6d4c815eaf4b0c4fc7564a80d0 to your computer and use it in GitHub Desktop.
Save wtfuii/10c42e6d4c815eaf4b0c4fc7564a80d0 to your computer and use it in GitHub Desktop.
Skeleton for an easesolutions codestyle JS file
// ensure that the namespace is created
if (typeof easesolutions !== 'object')
easesolutions = {};
if (typeof easesolutions.productname !== 'object')
easesolutions.productname = {};
// initialize instance variables
easesolutions.productname.fileName = function () {
this.url_get_stuff = '';
this.compiled_template_stuff = null;
};
//create object prototype
easesolutions.productname.fileName.prototype = {
//URL getters and setters
set_url_get_stuff: function(url) {
this.url_get_stuff = url;
},
get_url_get_stuff: function() {
return this.url_get_stuff;
},
//jQuery getters
get_jq_stuffcontainer: function() {
return jQuery('#easesolutions_productname_filename_stuffcontainer');
},
get_jq_stufftemplate: function() {
return jQuery('#easesolutions_productname_filename_stufftemplate');
},
// further methods
init: function (myArg) {
this.get_jq_stuffcontainer().html(this.compiled_template_list(myArg));
}
};
//add general purpose functions to prototype
Object.assign(easesolutions.productname.fileName.prototype, easesolutions.productname.base());
// create instance of our previously defined object
easesolutions.productname.theFileName = new easesolutions.productname.fileName();
// do necessary initializations
jQuery(document).ready(function () {
var that = easesolutions.productname.theFileName;
that.compiled_template_stuff = Handlebars.compile(that.get_jq_stufftemplate().html());
that.init({myArg: 1});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment