Your IP : 18.219.40.177


Current Path : /usr/local/mgr5/skins/orion/src/
Upload File :
Current File : //usr/local/mgr5/skins/orion/src/App.PreLoader.js

/**
 * loader module
 *  @param {object} window  global object
 *  @param {function} $ jQuery library
 *  @param {object} EventMgr EventMgr library
 *  @param {object} App Application
 */
App.PreLoader = function(window, $, EventMgr, App) {
  'use strict';
  var init = function() {
    EventMgr.bind('getAjaxRequest', showLoader);
    EventMgr.bind('ajaxError', hideLoader);
    EventMgr.bind('giveAjaxRequest', hideLoader);
    EventMgr.bind('showLoader', showLoader);
    EventMgr.bind('hideLoader', hideLoader);
  },

      favicon = 'progress_favicon.gif',

      loader = function() {
        return App.Dom.byId('favicon');
      },

      changeFavicon = function(src, type) {
        var link = document.createElement('link'),
            oldLink = document.getElementById('favicon');
        if (oldLink === null) { return; }
        link.id = 'favicon';
        link.rel = 'shortcut icon';
        link.href = src;
        link.setAttribute('type', type);
        if (oldLink) {
          if (document.head) {
            document.head.removeChild(oldLink);
          } else {
            document.getElementsByTagName('head')[0].removeChild(oldLink);
          }
        }
        if (document.head) {
          document.head.appendChild(link);
        } else {
          document.getElementsByTagName('head')[0].appendChild(link);
        }
        link = null;
        oldLink = null;
      },

      showLoader = function() {
        changeFavicon(pageInfo.theme +
            pageInfo.localDir + favicon, 'image/gif');
      },

      hideLoader = function() {
        changeFavicon(pageInfo.theme +
            pageInfo.localDir + pageInfo.favicon, 'x-icon');
      };

  return {
    init: init
  };

}(window, $, EventMgr, App);