js content


var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
  return typeof obj;
} : function(obj) {
  return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var _createClass = function() {
  function defineProperties(target, props) {
    for (var i = 0; i < props.length; i++) {
      var descriptor = props[i];
      descriptor.enumerable = descriptor.enumerable || false;
      descriptor.configurable = true;
      if ("value" in descriptor) descriptor.writable = true;
      Object.defineProperty(target, descriptor.key, descriptor);
    }
  }
  return function(Constructor, protoProps, staticProps) {
    if (protoProps) defineProperties(Constructor.prototype, protoProps);
    if (staticProps) defineProperties(Constructor, staticProps);
    return Constructor;
  };
}();

function _classCallCheck(instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
}

var ProjectDashboard = function($) {

  var NAME = 'projectdashboard';
  var VERSION = '1.0.0';
  var DATA_KEY = 'bs.projectdashboard';
  var EVENT_KEY = '.' + DATA_KEY;
  var DATA_API_KEY = '.data-api';
  var JQUERY_NO_CONFLICT = $.fn[NAME];

  var Default = {
    searchBarTplId: "#search-bar-tpl",
    tabContainerTplId: "#tabs-container-tpl",
    tabPanesContainerTplId: "#tab-panes-container-tpl",
    phases: [],
    tabs: [],
    columns: [],
    gridData: []
  };

  var DefaultType = {
    searchBarTplId: 'string',
    tabContainerTplId: 'string',
    tabPanesContainerTplId: 'string',
    phases: 'array',
    tabs: 'array',
    columns: 'object',
    gridData: 'object'
  };

  /**
   * ------------------------------------------------------------------------
   * Class Definition
   * ------------------------------------------------------------------------
   */

  var ProjectDashboard = function() {
    function ProjectDashboard(element, config) {
      _classCallCheck(this, ProjectDashboard);

      this._config = _getConfig(config);
      this._element = $(element);
    }

    // getters

    // public

    ProjectDashboard.prototype.render = function render() {
      var _preRender = function _preRender() {
        // render spinbar here
      }();

      // render functions
      var _renderSearchBar = function _renderSearchBar(self) {
        var searchBarHtml = self._getTemplate("searchBar");
        $(searchBarHtml).appendTo(self._element);

        // initialize the phase collection
        var phaseOptions = "";
        var phases = self._config["phases"];
        for (var i = 0; i < phases.length; i++) {
          phaseOptions += "";
        }
        $("#currentPhase").append(phaseOptions);

      }(this);

      var _renderTabs = function _renderTabs(self) {
        var tabsHtml = self._getTemplate("tabContainer");
        $(tabsHtml).appendTo(self._element);

        // tabs
        var tabTemplate = "
  • " + "{{tab-id}}
  • "; // tab panes var tabPaneTemplate = "
    " + "
    " + "
    "; var tabsContainerHtml = $(self._config.tabContainerTplId).html(); var $tabsContainer = $(tabsContainerHtml); var tabPanesHtml = $(self._config.tabPanesContainerTplId).html(); var $tabPanesContainer = $(tabPanesHtml); var tabNames = self._config.tabs; for (var idx = 0; idx < tabNames.length; idx++) { var tabHtml = tabTemplate.replace(new RegExp("{{tab-id}}", 'g'), tabNames[idx]); $tabsContainer.append(tabHtml); var tabPaneHtml = tabPaneTemplate.replace(new RegExp("{{tab-pane-id}}", 'g'), tabNames[idx]); $tabPanesContainer.append(tabPaneHtml); if (idx === 0) { tabPaneTemplate = tabPaneTemplate.replace(" active", ""); tabTemplate = tabTemplate.replace(" class=\"active\"", ""); } } self._element.append($tabsContainer); self._element.append($tabPanesContainer); }(this); var _renderGrids = function _renderGrids(self) { var gridData = self._config.gridData; for (var projectType in gridData) { var tableSelector = "#" + projectType + "-tbl"; var _table = $(tableSelector).DataTable({ data: gridData[projectType], "columns": self._config.columns[projectType], "dom": "t", "deferRender": true, "paging": false, "info": false }); } $("#btnSearch").click(function (event) { event.preventDefault(); var _leader = $("#leaderPicker").eq(0).val(); var _gateReviewDate = $("#nextGateReviewDate>input").eq(0).val(); var _phase = $("#currentPhase").val(); _phase = _phase === "---" ? "" : _phase; var _trl = $("#TRL").val(); _trl = _trl === "0" ? "" : _trl; if (_leader === "" && _gateReviewDate === "" && _phase === "" && _trl === "") { $("[id$='-tbl']").DataTable() .columns().search( "" ) .draw(); return; } $("[id$='-tbl']").each(function () { // detect TRL idx var $trl = $(this).find("th:contains('TRL')"); var trlIdx = $("th", this).index($trl); $(this).DataTable() .columns( 1 ).search( _leader ) .columns( 2 ).search( _phase ) .columns( 4 ).search( _gateReviewDate ) .columns( trlIdx ).search( _trl ) .draw(); }); }); }(this); }; // static ProjectDashboard._jQueryInterface = function _jQueryInterface(config) { return this.each(function() { var data = $(this).data(DATA_KEY); var _config = $.extend({}, ProjectDashboard.Default, $(this).data(), (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config); if (!data) { data = new ProjectDashboard(this, _config); $(this).data(DATA_KEY, data); } if (config === 'render') { data[config](this); } }); }; // private var _getConfig = function _getConfig(config) { config = $.extend({}, Default, config); _typeCheckConfig(NAME, config, DefaultType); return config; }; var _typeCheckConfig = function typeCheckConfig(componentName, config, configTypes) { for (var property in configTypes) { if (configTypes.hasOwnProperty(property)) { var expectedTypes = configTypes[property]; var value = config[property]; var valueType = value && (value[0] || value).nodeType ? 'element' : _toType(value); if (!new RegExp(expectedTypes).test(valueType)) { throw new Error(componentName.toUpperCase() + ': ' + ('Option "' + property + '" provided type "' + valueType + '" ') + ('but expected type "' + expectedTypes + '".')); } } } }; var _toType = function toType(obj) { return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); }; _createClass(ProjectDashboard, null, [{ key: 'VERSION', get: function get() { return VERSION; } }, { key: 'Default', get: function get() { return Default; } }]); ProjectDashboard.prototype._getTemplate = function _getTemplate(name) { var _key = name + "TplId"; return document.querySelector(this._config[_key]).innerText; }; return ProjectDashboard; }(); /** * ------------------------------------------------------------------------ * jQuery * ------------------------------------------------------------------------ */ $.fn[NAME] = ProjectDashboard._jQueryInterface; $.fn[NAME].Constructor = ProjectDashboard; $.fn[NAME].noConflict = function() { $.fn[NAME] = JQUERY_NO_CONFLICT; return ProjectDashboard._jQueryInterface; }; return ProjectDashboard; }(jQuery);

    Comments

    Popular posts from this blog

    CREATE DATABASE (SMO)

    Enable JSON serialization in your Visual Studio 2010 project

    jQuery | remove inline style