Revision: 43897
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 2, 2011 07:11 by jvandemerwe
Initial Code
/** * @class App.Quick * Special Class (Singleton) * This small singleton works like a kind of application telephone book. * A quick register to find critical and often used objects in the application. * This object is in NO WAY generic and always application DEPENDENT !!! * * What makes this small class useful is that it dynamically generates the functions for how the * values can be retrieved * * f.e. * * App.Quick.set('abba', this); * * Means that in the register entry abba the reference is set to "this", but in such a way that it * will be set by reference, not by value!. * * You can retrieve this value simply by using: * App.Quick.abba(); * * App.Quick.check('abba'); * looks for the existance of a function called 'abba', used for validating if object functions already * exist, before calling them. * * You can also create the entries directly (hard coded) in this class (sometimes good for overview) * * @namespace App * * @singleton * @author J.J. van de Merwe, Enovision GmbH * @version 1.0 */ Ext.ns('App'); App.Quick = function(){ return { settings : {}, /** * function that checks if an entry already been created for this class (dynamically that is) * @params {string} set, which contains the label of the set item to be checked * * @return {boolean} exists?, true if exists, false if not exists */ check : function(set) { return ((App.Quick[set] && typeof(App.Quick[set]) === 'function') === true) ? true : false; }, /** * function that adds new entries to the App.Quick set in realtime * @params {string} set, which contains the label of the set item to be added * @params {mixed objec} Value, the reference value to be connected with the set * @params (boolean) forced, when set to true, it will override any existing one with the same label, * this is also the default value (false, will not override) * * @return {boolean} execution state (true is oké, false is no good) */ set : function(set, Value, forced) { if (typeof(set) === 'undefined' || typeof(Value) === 'undefined') { return false; } var is_forced = (typeof(forced) === 'undefined') ? true : forced; if (typeof(App.Quick[set]) !== 'undefined' && is_forced === false) return false; if (typeof(set) !== 'string') return false; App.Quick.settings[set] = Value; App.Quick[set] = function() { return App.Quick.settings[set]; } return true; }, /** * hardcoded sample (please this sample assumes that App.Quick.StructureManager has * been set somewhere in the software) * THIS IS NOT VERY PRACTICAL, BUT FOR THE DEMO ITS OKÉ */ TreeNodeSelectedSemester : function() { return App.Quick.StructureManager()._selectedSemester; } } }();
Initial URL
Initial Description
Initial Title
Extjs - A smart registry to find objects easy
Initial Tags
object
Initial Language
JavaScript