Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- require_once './illi.class.hlp.php';
- $JS = new JS();
- $JS->load(array(
- 'javascript/jquery/jquery-1.5.1.min.js',
- 'javascript/jquery/jquery-ui-1.8.11.custom.min.js',
- 'javascript/jquery/jquery-1.5.1.ext.js',
- //'javascript/thickbox.js'
- ));
- print $JS->render();?>
- (function( $ ){
- $.xtcmApp = {version: '0.0.2', vision: 'idle in roflcopter', jquery: '1.5.1', author: '~lvm', web: 'http://illi.be'};
- $.xtcmApp.global =
- {
- /**
- * not in use
- * @see $.xtcmApp.initProto()
- */
- __SUPER__ :
- {
- __METHOD__ :
- {
- __QUEUE__ : { initialize : function(){} },
- __REGISTRY__ : { initialize : function(){} }
- },
- __VARIABLE__ :
- {
- __VALUE__ : { initialize : function(){} },
- __REGISTRY__ : { initialize : function(){} }
- }
- },
- /**
- * CLASS LIB
- *
- * @see $.xtcmApp.initProto()
- */
- __CLASS__ :
- {
- __METHOD__ :
- {
- /**
- * method queue
- *
- * @param runonce bool true: terminate queue on exec
- *
- * // some stuff
- * var test11 = function(){alert('test1.1')};
- * var test12 = function(){alert('test1.2')};
- *
- * // default queue
- * var bar = new $.xtcmApp.global.__CLASS__.__METHOD__.__QUEUE__();
- * bar.push(test11).push(test12)
- * .execute() // test1.1 test1.2
- * .execute(); // test1.1 test1.2
- *
- * // run-once queue
- * var baz = new $.xtcmApp.global.__CLASS__.__METHOD__.__QUEUE__(true);
- * baz.push(test11).push(test12)
- * .execute() // test1.1 test1.2
- * .execute(); // nothing
- */
- __QUEUE__ : function(runonce)
- {
- var __queue = new Array();
- var __runonce = (runonce !== true) ? false : true;
- /**
- * add function to queue
- *
- * @param fn function
- * @return $.xtcmApp.global.__CLASS__.__METHOD__.__QUEUE__();
- */
- this.push = function(fn)
- {
- __queue.push(fn);
- return this;
- }
- /**
- * execute queue
- *
- * @return $.xtcmApp.global.__CLASS__.__METHOD__.__QUEUE__();
- */
- this.execute = function()
- {
- if(__queue.length === 0)
- return this;
- if(__runonce === false)
- for(i in __queue) __queue[i]();
- else
- while(__queue.length > 0) (__queue.shift())();
- return this;
- }
- /**
- * terminate queue
- *
- * @return $.xtcmApp.global.__CLASS__.__METHOD__.__QUEUE__();
- */
- this.reset = function()
- {
- __queue = new Array();
- return this;
- }
- },
- /**
- * method queue registry
- *
- * // some stuff
- * var test11 = function(){alert('test1.1')};
- * var test12 = function(){alert('test1.2')};
- * var test21 = function(){alert('test2.1')};
- * var test22 = function(){alert('test2.2')};
- *
- * // create registry queue
- * var foo = new $.xtcmApp.global.__CLASS__.__METHOD__.__REGISTRY__();
- *
- * // default queue
- * foo.register('test1').push('test1', test11).push('test1', test12)
- * .execute('test1') // test1.1 test1.2
- * .execute('test1'); // test1.1 test1.2
- *
- * // run-once queue
- * foo.register('test2', true).push('test2', test11).push('test2', test12)
- * .execute('test2') // test1.1 test1.2
- * .execute('test2'); // nothing
- *
- *
- * // shorthand:
- * // default queue
- * foo.get('test3').push(test21).push(test22)
- * .execute() // test2.1 test2.2
- * .execute(); // test2.1 test2.2
- *
- * // run-once queue
- * foo.get('test4', true).push(test21).push(test22)
- * .execute() // test2.1 test2.2
- * .execute(); // nothing
- *
- */
- __REGISTRY__ : function()
- {
- var __queue = new $.xtcmApp.global.__CLASS__.__VARIABLE__.__REGISTRY__();
- /**
- * register queue instance
- *
- * @param name string instance-name
- * @param runonce bool
- * @see $.xtcmApp.global.__CLASS__.__METHOD__.__QUEUE__()
- * @see $.xtcmApp.global.__CLASS__.__VARIABLE__.__REGISTRY__.register()
- * @return $.xtcmApp.global.__CLASS__.__METHOD__.__REGISTRY__()
- */
- this.register = function(name, runonce)
- {
- __queue.register(name, new $.xtcmApp.global.__CLASS__.__METHOD__.__QUEUE__(runonce), true);
- return this;
- }
- /**
- * isset instance
- *
- * @param name string instance-name
- * @see $.xtcmApp.global.__CLASS__.__VARIABLE__.__REGISTRY__.isset()
- * @return bool $.xtcmApp.global.__CLASS__.__VARIABLE__.__REGISTRY__.isset()
- */
- this.isset = function(name)
- {
- return __queue.isset(name);
- }
- /**
- * get/create queue instance
- *
- * @param name string instance-name
- * @param runonce bool
- * @see $.xtcmApp.global.__CLASS__.__VARIABLE__.__REGISTRY__.get()
- * @return mixed $.xtcmApp.global.__CLASS__.__VARIABLE__.__REGISTRY__.get()
- */
- this.get = function(name, runonce)
- {
- if(this.isset(name) === false)
- this.register(name, runonce);
- return __queue.get(name);
- }
- /**
- * execute queue of instance
- *
- * @param name string instance-name
- * @see $.xtcmApp.global.__CLASS__.__METHOD__.__QUEUE__.execute()
- * @return $.xtcmApp.global.__CLASS__.__METHOD__.__REGISTRY__();
- */
- this.execute = function(name)
- {
- if(this.isset(name) === true)
- this.get(name).execute();
- return this;
- }
- /**
- * terminate queue
- *
- * @see $.xtcmApp.global.__CLASS__.__METHOD__.__QUEUE__.reset()
- * @return $.xtcmApp.global.__CLASS__.__METHOD__.__REGISTRY__();
- */
- this.reset = function(name)
- {
- if(this.isset(name) === true)
- this.get(name).reset();
- return this;
- }
- /**
- * add function to queue of instance
- *
- * @param name string instance-name
- * @param fn function
- * @see $.xtcmApp.global.__CLASS__.__METHOD__.__QUEUE__.push()
- * @return $.xtcmApp.global.__CLASS__.__METHOD__.__REGISTRY__();
- */
- this.push = function(name, fn)
- {
- if(this.isset(name) === true)
- this.get(name).push(fn);
- return this;
- }
- }
- },
- __VARIABLE__ :
- {
- /**
- * value for value-queue
- *
- * overwrite is allowed or not
- *
- * @param value mixed
- * @param protect bool true: can not overwrite existing value
- */
- __VALUE__ : function(value, protect)
- {
- var __value = value || null;
- var __protect = (protect === true) ? true : false;
- /**
- * get value
- * @return mixed
- */
- this.get = function(){ return __value; }
- /**
- * set value
- *
- * this has no effect, if __protect is true
- * @return $.xtcmApp.global.__CLASS__.__VARIABLE__.__VALUE__();
- */
- this.set = function(value){ if(__protect === true) return this; __value = value; return this; }
- },
- /**
- * value-queue
- *
- * store vars with values
- *
- * // new value-queue
- * var foo = new $.xtcmApp.global.__CLASS__.__VARIABLE__.__REGISTRY__();
- *
- * // var "baz"
- * foo.register('baz', 'baz: bar'); alert(foo.get('baz')); // baz: bar
- * foo.set('baz', 'baz: bar -> foo'); alert(foo.get('baz')); // baz: foo
- *
- * // protected var "foo"
- * foo.register('foo', 'foo: lol', true); alert(foo.get('foo')); // foo: lol
- * foo.set('foo', 'foo: lol -> rofl'); alert(foo.get('foo')); // foo: lol
- */
- __REGISTRY__ : function()
- {
- var __queue = new Object();
- /**
- * register value-instance
- *
- * @param name string instance-name
- * @param value mixed
- * @param protect bool true: can not overwrite existing value
- * @see $.xtcmApp.global.__CLASS__.__VARIABLE__.__VALUE__();
- * @return $.xtcmApp.global.__CLASS__.__VARIABLE__.__REGISTRY__();
- */
- this.register = function(name, value, protect)
- {
- if(this.isset(name) === false)
- __queue[name] = new $.xtcmApp.global.__CLASS__.__VARIABLE__.__VALUE__(value, protect);
- return this;
- }
- /**
- * isset instance
- *
- * @param name string instance-name
- * @return bool
- */
- this.isset = function(name)
- {
- return (!__queue[name]) ? false : true;
- }
- /**
- * get value of instance
- *
- * @param name string instance-name
- * @see $.xtcmApp.global.__CLASS__.__VARIABLE__.__VALUE__.get()
- * @return $.xtcmApp.global.__CLASS__.__VARIABLE__.__VALUE__.get() || NULL
- */
- this.get = function(name)
- {
- return ((this.isset(name) === true) ? __queue[name].get() : null);
- }
- /**
- * set value of instance
- *
- * @param name string instance-name
- * @param value mixed
- * @see $.xtcmApp.global.__CLASS__.__VARIABLE__.__VALUE__.set()
- * @return $.xtcmApp.global.__CLASS__.__VARIABLE__.__REGISTRY__()
- */
- this.set = function(name, value)
- {
- if(this.isset(name) === true)
- this.set(value);
- return this;
- }
- }
- }
- }
- }
- $.fn.xtcmApp = function(SETTINGS)
- {
- var initProto = function()
- {
- $.extend($.xtcmApp.global.__CLASS__.__METHOD__.__QUEUE__.prototype, $.xtcmApp.global.__SUPER__.__METHOD__.__QUEUE__);
- $.extend($.xtcmApp.global.__CLASS__.__METHOD__.__REGISTRY__.prototype, $.xtcmApp.global.__SUPER__.__METHOD__.__REGISTRY__);
- $.extend($.xtcmApp.global.__CLASS__.__VARIABLE__.__VALUE__.prototype, $.xtcmApp.global.__SUPER__.__VARIABLE__.__VALUE__);
- $.extend($.xtcmApp.global.__CLASS__.__VARIABLE__.__REGISTRY__.prototype, $.xtcmApp.global.__SUPER__.__VARIABLE__.__REGISTRY__);
- };
- var test =
- {
- methodqueue : function()
- {
- var test11 = function(){alert('test1.1')};
- var test12 = function(){alert('test1.2')};
- var test21 = function(){alert('test2.1')};
- var test22 = function(){alert('test2.2')};
- var foo = new $.xtcmApp.global.__CLASS__.__METHOD__.__REGISTRY__();
- foo.get('test3').push(test11).push(test12)
- .execute() // test2.1 test2.2
- .execute(); // test2.1 test2.2
- foo.get('test4', true).push(test21).push(test22)
- .execute() // test2.1 test2.2
- .execute(); // nothing
- }
- };
- $.xtcmApp.initialize = function()
- {
- test.methodqueue();
- };
- $.xtcmApp.initialize();
- };
- })( jQuery );
- jQuery(document).ready(function($)
- {
- $('body').xtcmApp();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement