/** @author Amol Salunkhe @version Date of Creation: 11/02/2016 */ (function(){ DashboardRpt = function (config){ //---------------------------------------------------------------// //----------------------Member Variables-------------------------// //---------------------------------------------------------------// //This variable will store the global reference for this class within its context var go_this = this; var config = config; var dashbordCont = $('#dashboardCont'); if(typeof dashbordCont.val() == "undefined"){ dashbordCont = $("
"); $("body").append(dashbordCont); } var dasbhoardBtnCont = $(''); var dasbhoardBodyCont = $(''); dashbordCont.append(dasbhoardBtnCont); dashbordCont.append(dasbhoardBodyCont); var dashboardBtnInstances; function init(){ //create the Tabs (headers) dashboardBtnInstances = $(".dashboardBtnCont").dxTabs({ dataSource: config.tabs, selectedIndex: 0 }).dxTabs("instance"); //create the respective Tab bodies var tabCnt =0, maxTabCnt = config.tabs.length; var currTabConfig; while(tabCnt < maxTabCnt){ currTabConfig = config.tabs[tabCnt]; currTabConfig.cont = $(''); dasbhoardBodyCont.append(currTabConfig.cont); currTabConfig["instance"] = new DashboardTab (currTabConfig); if(tabCnt == 0){ currTabConfig["instance"].show(); }else{ currTabConfig["instance"].hide(); } tabCnt++; }//while(tabCnt < maxTabCnt) subscribeToDesiredEvents(); }//function init //----------------------- Event Handlers -------------------------// function onDashboardTabClicked(e){ //hide the contents for the all the Tabs bodies var tabCnt =0, maxTabCnt = config.tabs.length; while(tabCnt < maxTabCnt){ config.tabs[tabCnt]["instance"].hide(); tabCnt++; }//while(tabCnt < maxTabCnt) //show the body/container of the clicked Tab Btn config.tabs[e.itemIndex]["instance"].show(); }//function onDashboardTabClicked //----------------------- Event Subscriptions -------------------------// function subscribeToDesiredEvents(){ dashboardBtnInstances.on("itemClick", onDashboardTabClicked); }//function subscribeToDesiredEvents init(); return this; };//DashboardRpt = function })();//anonym function -- IFFE