Your IP : 3.135.223.175


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

/**
 *  Showcaseform
 *  @param {object} window  global object
 *  @param {function} $ jQuery library
 *  @param {object} EventMgr EventMgr library
 *  @param {object} App Application
 *  @return {object} api
 */
/*global App:true*/
App.Showcase = function(window, $, EventMgr, App) {
  'use strict';

  var wizardStepSel = '.i-wizard__step-link',
      mainWrapperSel = '#main-wrapper';

  function $formContent() {
    return window.document.getElementById('wr-content');
  }
  //insert form in tab-content box
  function insertShowCaseForm(e, data) {
    var html = data;
    $formContent().innerHTML = html;
    EventMgr.trigger('appendForm', { tabId: 'tab0' });
  }
  //caught event & set type of content
  function preRespActions(e, data) {
    var obj = data;
    //caught fatal error
    if (obj.form) {
      obj.type = 'showcaseForm';
    }
    obj.showcase = true;
    EventMgr.trigger('ajaxResponse', obj);
  }
  //handler for wizard step link
  function defaultActionHandler(e) {
    if (e) { e.preventDefault(); }
    var href = this.getAttribute('href'),
        iType = 'replace',
        param = App.Common.parseParams(href),
        tabId = $(this).parents('.tab-content').attr('data-tabid'),
        formParam = $('#frm-' + tabId).serializeObject();
    if (formParam) {
      delete formParam.func;
      delete formParam.snext;
      delete formParam.sfrom;
      delete formParam.sok;
      $.extend(param, formParam);
    }
    EventMgr.trigger('ajaxRequest', {
      param: param,
      trfunc: 'showcaseFormResp',
      invar: { iType: iType },
      queue: 'noqueue',
      outtype: 'json',
      failfunc: 'failCommonAjaxResponse' });
    EventMgr.trigger('tabLoading', { tabId: tabId });
  }

  function preRequest(e, data) {
    var options = data;
    options.trfunc = 'showcaseFormResp';
    options.invar.showcase = true;
    delete options.invar.targetTabId;
    delete options.param.showcase;
    EventMgr.trigger('ajaxRequest', options);
  }

  function init() {
    EventMgr.bind('readyShowcaseFormHtml', insertShowCaseForm);
    EventMgr.bind('showcaseFormResp', preRespActions);
    EventMgr.on(mainWrapperSel, wizardStepSel, 'click', defaultActionHandler);
    EventMgr.bind('preRequestShowcase', preRequest);
  }

  var api = {
    init: init
  };

  return api;

} (window, $, EventMgr, App);