header.js 2.11 KB
Newer Older
1 2 3 4 5 6 7
/**
 * header js for index.
 * ※Code is written mainly for dashboard and operationList.
 *
 * @since cms:1.4.3.2&1.4.3.3 web:1.0
 */

NGO THI HONG committed
8
 var HEADER = {};
9

NGO THI HONG committed
10 11 12 13 14
 /** Direct home page setting */
 HEADER.goToHomePage = function (pageId) {
     DashboardSetting.getSettingData(function (settings) {
         if(settings.dashboardHome == 1)
         {
15 16
            sessionStorage.activeHomePage = CONSTANT.PAGE_NAME.DASHBOARD;
            HEADER.goDashboard();
NGO THI HONG committed
17 18 19
         }
         else
         {
20 21 22
            sessionStorage.activeHomePage = CONSTANT.PAGE_TAB.OPERATION_LIST;
            HEADER.goOperationList();
        }
NGO THI HONG committed
23 24
     });
 }
25

NGO THI HONG committed
26 27 28 29 30
 
 /**
  * Go page of operationList
  */
  HEADER.goOperationList = function () {
31
    OL.init();
NGO THI HONG committed
32 33 34 35 36 37
 };
 
 /**
  * Go page of dashboard
  */
  HEADER.goDashboard = function () {
38
    sessionStorage.activeHomePage = CONSTANT.PAGE_NAME.DASHBOARD;
NGO THI HONG committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
     COMMON.avwScreenMove("dashboard.html");
 };
 
 
 /**
  * Initialize with any navigation
  *
  * @param {String} bottomNav
  */
  HEADER.activeInitBottomNav = function (bottomNav) {
     HEADER.inactiveAllBottomNav();
     HEADER.activeBottomNav(bottomNav);
 };
 
 /**
  * change inactive all footer bottom
  */
  HEADER.inactiveAllBottomNav = function () {
     let navs = document.getElementsByClassName('bottom-nav');
     for (i = 0; i < navs.length; i++) {
         navs[i].className = navs[i].className.replace('text-primary', 'text-secondary');
         let img = navs[i].querySelector('img');
         if (img && img.getAttribute('data-inactive-src')) {
             img.src = img.getAttribute('data-inactive-src');
         }
     }
 };
 
 
 /**
  * Change specific footer bottom to active.
  *
  * @param {String} bottomNavId
  */
  HEADER.activeBottomNav = function (bottomNavId) {
     let elm = $('#' + bottomNavId);
     if (typeof elm !== 'object') {
         console.log('HEADER.activeBottomNav:elm !== object:' + bottomNavId);
         return;
     }
     elm.removeClass('text-secondary');
     elm.addClass('text-primary');
     let img = elm.find('img')[0];
     if (img && img.getAttribute('data-src')) {
         img.src = img.getAttribute('data-src');
     }
85
 };