CjsBaseClass
DRY Javascript Class with inheritance, with embedded jQuery 2.2.3.
Install
bower install cjsbaseclass --save
Windows
goto root package folder
copy dist\*.sublime-snippet "%APPDATA%\Sublime Text 3\Packages\User\base_js_main_class.sublime-snippet"
Embedded libraries:
Command reference
waitReady('ClassName', callback)
self.waitReady('TOther', self.otherClassReady.apply());
waitStarted('ClassName', callback)
self.waitStarted('TOther', self.otherClassStarted.apply());
trigger(trigger_name, trigger_args)
self.trigger('fire-trigger', { 'name': 'The Name', 'id': 123456 });
waitTrigger(trigger_name, callback, miliseconds)
self.waitTrigger
(
'fire-trigger',
function(p_args)
{
console.log(p_args);
}
);
browser
self.log.info(self.browser);
pre defined variables
self.is.chrome;
self.is.firefox;
self.is.safari;
self.is.ie;
self.is.ie9;
is
var myvar = (self.is.ie9) ? 'IS IE9 :(' : 'IS NOT IE9 :D';
print(string)
self.log.print('my chinese variable :P');
alert(string)
self.log.alert('Class TOther is ready!');
info(string)
self.log.info(self.browser);
danger(string)
self.log.danger(self.browser);
lock(string)
self.lock('scroll');
self.lock('scroll,slide');
isLocked(string)
self.isLocked('scroll');
self.islocked('scroll,slide');
self.isLocked('another');
self.islocked('scroll,another');
unlock(string)
self.unlock('scroll');
self.unlock('scroll,slide');
setDebug(boolean)
self.setDebug(true);
self.setDebug(false);
setDebugMode(integer)
self.setDebugMode(0);
self.setDebugMode(1);
self.setDebugMode(2);
Usage
var MyApplication = MyApplication || {};
MyApplication.TMyClass = function($, objname, options)
{
'use strict';
var self = this;
this.init = function()
{
self.initVars();
self.processTriggers();
self.onElementsEvents();
};
this.initVars = function()
{
};
this.onReady = function()
{
self.start();
};
this.start = function()
{
self.triggerStarted();
};
this.processTriggers = function()
{
};
this.onElementsEvents = function()
{
};
CjsBaseClass.call(this, $, objname, options);
this.init();
};
MyApplication.MyClass = new MyApplication.TMyClass
(
window.cjsbaseclass_jquery,
'MyClass',
{
'debug': 1,
'highlighted': false
}
);