123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- // Licensed Materials - Property of IBM
- //
- // IBM Cognos Products: cogadmin
- //
- // (C) Copyright IBM Corp. 2005, 2010
- //
- // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- //
- //
- // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- //----------------------------------------------------------
- com.cognos.admin.ObjectFactory("com.cognos.admin.widget");
- /**
- * J2HTML Builder class is to prepare the recipes for event class,
- * and traverse the DOM of the input element and attach event handlers
- * according to the recipes.
- *
- * @param elt: target container element will be attached with J2HTML events.
- * @param frg: fragment container
- *
- */
-
- com.cognos.admin.widget.Builder = function (elt,frg){
- if (!elt) throw new Error("You cannot create a J2HTML Table widget without input element");
-
- this.fragment = frg;
- this.table = elt;
- this.publicVariables = {}; //TODO
- this.recipe = new com.cognos.admin.util.Tools.Recipe();
- this.fragmentRecipe = new com.cognos.admin.util.Tools.Recipe();
- this._initDefaultFunc();
- this.event = new com.cognos.admin.widget.Event(this);
- };
- com.cognos.admin.widget.Builder.VERSION = "0.1.0";
- com.cognos.admin.widget.Builder.prototype = {
-
- /*
- *
- */
- _initDefaultFunc : function (){
- //init recipe for cogTable
- this.recipe.add("table_init","initTable","init");
- this.recipe.add("table_unload","unloadTable","unload");
- this.recipe.add("tooltip","showTooltip","mouseover");
- this.recipe.add("tooltip","showTooltip","focus");
- this.recipe.add("tooltip","hideTooltip","mouseout");
- this.recipe.add("tooltip","hideTooltip","blur");
- this.recipe.add("toggler","toggle","click");
- this.recipe.add("toggler","defaultCursor","init");
- this.recipe.add("checkbox_toggler","toggleCheckbox","click");
- this.recipe.add("all_toggler","toggleAll","click");
- this.recipe.add("all_toggler","defaultCursor","init");
- this.recipe.add("sort_column","sortColumn","keypress");
- this.recipe.add("sort_column","sortColumn","click");
- this.recipe.add("sort_column","mouseOverLink","init");
- this.recipe.add("mask","maskElement","init");
- this.recipe.add("sort_test","sortTest","click");
- this.recipe.add("filter_column","filterColumn","click");
- this.recipe.add("filter_column","initFilter","init");
- this.recipe.enableAction("action");
- //for client side silter summary widget only
- //r.add("filter_summary","filterSummary","init");
-
- //init recipe for fragment event
- this.fragmentRecipe.add("fragment","fgmtCreate","fragment.create");
- this.fragmentRecipe.add("fragment","fgmtDestroy","fragment.destroy");
- this.fragmentRecipe.add("fragment","fgmtError","fragment.error");
- this.fragmentRecipe.add("fragment","fgmtRefresh","fragment.refresh");
- this.fragmentRecipe.add("fragment","fgmtResize","fragment.resize");
- this.fragmentRecipe.add("fragment","fgmtLoad","fragment.load");
- this.fragmentRecipe.add("fragment","fgmtUnload","fragment.unload");
- this.fragmentRecipe.add("fragment","fgmtRetrieveBefore","fragment.retrieve.before");
- this.fragmentRecipe.add("fragment","fgmtRetrieveAfter","fragment.retrieve.after");
- this.fragmentRecipe.add("fragment","fgmtTitleChange","fragment.title.change");
- this.fragmentRecipe.add("fragment","fgmtWindowstateChange","fragment.windowstate.change");
- this.fragmentRecipe.add("fragment","fgmtModeChange","fragment.mode.change");
- this.fragmentRecipe.add("fragment","menuSelect","cognos.ui.menu.select");
-
- //init recipe for j2html customized event
- this.fragmentRecipe.add("fragment","cadminFragRefresh","com.cognos.cogadmin.load");
- this.fragmentRecipe.add("fragment","distCadminFragWschange","cogadmin.fragment.windowstate.change");
- this.fragmentRecipe.add("fragment","doAction","cogadmin.fragment.action.execute");
-
- },
-
- /* walk through the element and hook the behavior for the element accordingly
- *
- */
- populateTable : function(){
-
- //protect the event handler from dup loaded.
- if((!_F_getFragmentByID(this.fragment.id)) || com.cognos.admin.publicParam.evtLoaded[this.fragment.id]) return;
- com.cognos.admin.publicParam.evtLoaded[this.fragment.id] = true;
- var ce = this.event;
- function walk (elt) {
- if (elt){
- if (elt.nodeType == 1) {
- if (elt.getAttribute("cogType")) {
- ce.mountEvent(elt);
- }
-
- if (elt.childNodes){
- var children = elt.childNodes;
- for (var i = 0; i < children.length; i++){
- walk (children[i]);
- }
- }
- }
- }
- };
- //walk through
- walk (this.table);
-
- //load any extension handlers
- for (var obj in com.cognos.admin.extension) {
- this.event.extensionFuncs[obj] = new com.cognos.admin.extension[obj](this.event);
- }
-
- //unregister event handler when window/frament unload, fix IE leaking
- ce.unregisterEvent();
- },
- /*
- * add a customized function to the event class as an event handler
- */
- addFunction : function (cogType,func,evt,cap){
- var capturing = cap || false;
- var funcName = "function"+com.cognos.admin.util.Tools.uniqueID();
-
- this.add(cogType,funcName,evt,capturing);
-
- if (typeof func == "function")
- this.event.addCogEvent(funcName,func);
- },
-
- /*
- *
- */
- setPublicVariables : function (vName,vValue){
- if (vName in this.publicVariables)
- throw new Error("Variable "+vName+" has already existed.");
-
- this.publicVariables[vName] = vValue;
- },
-
- /*
- *
- */
- getPublicVariables : function (vName){
- if (this.publicVariables[vName] != undefined)
- return this.publicVariables[vName];
- else
- return;
- }
- };
|