/** * Material HomePage and Cards * @author Prashik * @Date 2019-08-04T13:21:51+0530 */ ; (function ($, win) { //class axpertUI { $_this = this; function axpertUI() { options = { leftSideBar: { // scrollColor: 'rgba(255,255,255,0.7)', // scrollWidth: '4px', //scrollAlwaysVisible: false, // scrollAlwaysVisible: true, // scrollBorderRadius: '0', // scrollBorderRadius: '10px', // scrollRailBorderRadius: '0', // scrollRailBorderRadius: '10', // scrollActiveItemWhenPageLoad: true, // breakpointWidth: 1170, // enableExpandCollapse: true, menuConfiguration: { menuJson: {}, alignment: "vertical",//just for info staging: { div: "", divParent: "" }, menuTemplete: { menuUl: { opener: `` }, menuLi: { opener: ``, anchorGenerator: function (childObj) { let iconClass = ""; let iconText = ""; if (!childObj.icon) { return ` folder ${childObj.name} `; } else { if (typeof childObj.icon == "object") { iconClass = childObj.icon.addClass; iconText = childObj.icon.text; } else if (childObj.icon.indexOf("/") != -1) { return ` ${childObj.name} `; } else { iconClass = childObj.icon.addClass; iconText = childObj.icon.text; } return ` -1 ? `material-icons-style` : ``}"> ${iconText} ${childObj.name} `; } } }, functionalLi: { opener: ``, anchorGenerator: function (childObj) { let iconClass = ""; let iconText = ""; try { iconClass = AxCustomIcon(childObj) } catch (ex) { } if (iconClass === "") { if (!childObj.icon) { iconClass = "material-icons"; if (childObj.target != undefined && childObj.target != "") { if (childObj.target.indexOf("tstruct.aspx") > -1) { iconText = "assignment"; } else if (childObj.target.indexOf("iview.aspx") > -1 || childObj.target.indexOf("iviewInteractive.aspx") > -1) { iconText = "view_list"; } else { iconText = "insert_drive_file"; } } else if (childObj.target == "" && childObj.oname.indexOf("Head") > -1) { iconText = "folder"; } else { iconText = "insert_drive_file"; } return ` -1 ? `material-icons-style` : ``}"> ${iconText} ${childObj.name} `; } else { if (typeof childObj.icon == "object") { iconClass = childObj.icon.addClass; iconText = childObj.icon.text; } else if (childObj.icon.indexOf("/") != -1) { return ` ${childObj.name} `; } else { iconClass = "material-icons"; iconText = childObj.icon; } return ` -1 ? `material-icons-style` : ``}"> ${iconText} ${childObj.name} `; } } return ` ${iconClass} ${childObj.name} `; } } }, homePage: { url: "", icon: "home" } } }, dropdownMenu: { effectIn: 'fadeIn', effectOut: 'fadeOut' }, loader: { div: '.page-loader', subDiv: '.loader-box-wrapper', textDiv: '.page-loader-text', parent: '.page-loading', stayClass: 'stay-page-loading', inAnimationClass: 'animation animation-fade-in', outAnimationClass: 'animation animation-fade-out', radialGradientClass: 'bg-radial-gradient', loaderWrapClass: 'bg-white p-20 shadow rounded' }, navBarDiv: 'nav.navbar', search: { staging: { div: '#globalSearchinp', divParent: '.search-bar' } }, history: { staging: { div: "#historyData .setting-list", divParent: "" } }, frameDiv: '.splitter-wrapper', dirLeft: true, axpertUserSettings: {}, rightSideBar: {}, cardsPage: { setCards: false, cards: [], totalColumns: 12, designChanged: false, design: [], enableMasonry: false, html: { wrapper: `
`, loader: `
`, kpi: `
No Data Found
`, chart: `

more_vert
No Data Found
`, list: `

No Data Found
`, menu: ` `, "modern menu":`
`, modernMenuContent:`
`, "image card": `

No Data Found
`, calendar: `

more_vert
No Data Found
`, "html": `

No Data Found
`, masonryWidth: `
`, break: `
` } }, notificationbar:{}, navigation: { backButton: { div: ".appBackBtn" } }, isHybrid: false, isMobile: false, showMenu: true } /* Left Sidebar - Function ================================================================================================= * You can manage the left sidebar menu options * */ leftSideBar = { activate: function (options, isMobile) { var _this = this; _this.options = options; _this.isMobile = isMobile; _this.drawMenu(); }, setMenuHeight: function (isFirstTime) { }, checkStatusForResize: function (firstTime) { }, isOpen: function () { }, drawMenu: function () { var _this = this; var $body = $('body'); typeof createNewLeftMenu != "undefined" && createNewLeftMenu(_this.options.menuConfiguration); if (!$.axpertUI.options.showMenu) { $body.attr("data-kt-aside-minimize", "on").data("ktAsideMinimize", "on") } } }; // notificationbar notificationbar = { activate: function (options) { var _this = this; var $sidebar = $('#notificationbar'); var $panel = $("#notificationPanel"); _this.options = options; if (typeof _this.options.notificationTimeout != "undefined" && _this.options.notificationTimeout != "" && !isNaN(+(_this.options.notificationTimeout))) { var notifytimeoutms = +(_this.options.notificationTimeout) * 60000; setInterval(CheckNotificiationStringinRedis, notifytimeoutms); $(_this.options.divParent).attr("title", _this.options.staging.options.notification.title).find(_this.options.staging.options.notification.div).text(_this.options.staging.options.notification.title); $('.right-notificationbar').on('click', function () { setTimeout(() => { _this.notifyCount(); }, 0); }); $("#Clearnotify").on('click', function () { $sidebar.find(".demo-settings").empty(); setTimeout(() => { _this.notifyCount(); }, 0); try { $.ajax({ url: 'mainnew.aspx/delALLNotificiationKeyfromRedis', type: 'POST', cache: false, async: true, data: JSON.stringify({ key: true, }), dataType: 'json', contentType: "application/json", success: function (data) { }, error: function (error) { } }); } catch (exp) { } }); } else{ $panel.addClass("d-none"); } }, isOpen: function () { }, notifyCount: function () { var $panel = $("#notificationPanel"); var notifyCount = $("#notifycount .settingsGeneral").length; if (notifyCount > 0){ $panel?.find(".blinker")?.removeClass("d-none"); }else{ $panel?.find(".blinker")?.addClass("d-none"); } } }; //========================================================================================================================== /* Right Sidebar - Function ================================================================================================ * You can manage the right sidebar menu options * */ rightSideBar = { activate: function (options) { var _this = this; var $sidebar = $('#rightsidebar'); var $overlay = $('.overlay'); _this.options = options; }, isOpen: function () { }, switchLanguage(elm){ var _this = this; let newLanguage = $(elm).data("language"); if(gllangauge != newLanguage){ if (typeof (Storage) !== "undefined") { let appUrl = top.window.location.href.toLowerCase().substring("0", top.window.location.href.indexOf("/aspx/")); localStorage["langInfo-" + appUrl] = newLanguage; } _this.callSwitchLanguageWS(newLanguage); $j("#btnSetParams").click(); } }, callSwitchLanguageWS(newLanguage){ $.ajax({ type: "POST", url: "../WebService.asmx/switchLanguage", cache: false, async: false, contentType: "application/json;charset=utf-8", data: JSON.stringify({ lang: newLanguage }), dataType: "json", success: function (data) { if (data.d != "done"){ showAlertDialog("error", data.d); } }, }); } } //========================================================================================================================== /* cardsPage - Function ================================================================================================ * You can manage the cards page here * */ cardsPage = { activate(options) { let _this = this; if (options == "loadhomepage") { _this.options.cards = _this._refreshData() || _this.options.cards; _this.options = _this.options; } else if(options) { _this.options = options; } else { _this.options = _this.options; } _this.currentColumnWidth = 0; _this.firstTime = true; _this._checkSetCardsAndInit(); _this._showCardsFrame(_this.options.setCards); if (_this.options.setCards) { _this._sortCardsObject(); _this._drawCardsLayout(); } delete _this.currentColumnWidth; _this.firstTime = false; }, _refreshData(axp_cardsid, singleLoad = false) { let _this = this; let result = ""; $.ajax({ url: 'mainnew.aspx/refreshCards', type: 'POST', cache: false, async: false, data: JSON.stringify({ json: (axp_cardsid || _this.options.cards.map(card=>card["axp_cardsid"]).join(",") || ""), isJSON: false, singleLoad }), dataType: 'json', contentType: "application/json", success: function (data) { if (data && data.d) { try { result = JSON.parse(data.d !== "" ? data.d : "[]", function(k, v) { try { return (typeof v === "object" || isNaN(v) || v.toString().trim() === "") ? v : (typeof v == "string" && (v.startsWith("0") || v.startsWith("-")) ? parseFloat(v, 10) : JSON.parse(v)); } catch (ex) { return v; } } ); } catch (ex) {} } }, error: function (error) { } }); return result; }, _checkSetCardsAndInit() { let _this = this; let showEditButton = _this.options.cards.length > 0; if (!showEditButton) { $(_this.options.staging.cardsFrame.editSaveButton).addClass("d-none"); } }, _showCardsFrame(showCards) { let _this = this; setTimeout(() => { if (showCards && _this.options.setCards) { $(_this.options.staging.iframes).addClass("d-none"); $(_this.options.staging.cardsFrame.div).removeClass("d-none"); _this.editSaveCardDesignToggle(true); } else { $(_this.options.staging.iframes).removeClass("d-none"); $(_this.options.staging.cardsFrame.div).addClass("d-none"); } if(typeof closeFrame!="undefined") closeFrame(); }, 0); }, editSaveCardDesignToggle(reset = false) { let _this = this; let isEdit = $(_this.options.staging.cardsFrame.cardsDesigner).hasClass("d-none"); if (!reset && isEdit) { $(_this.options.staging.cardsFrame.cardsDiv).addClass("d-none"); $(_this.options.staging.cardsFrame.cardsDesigner).removeClass("d-none"); $(_this.options.staging.cardsFrame.editSaveButton).removeClass("btn-default").addClass("btn-primary"); $(_this.options.staging.cardsFrame.editSaveButton + " " + _this.options.staging.cardsFrame.icon).text("save"); } else { $(_this.options.staging.cardsFrame.cardsDiv).removeClass("d-none"); $(_this.options.staging.cardsFrame.cardsDesigner).addClass("d-none"); $(_this.options.staging.cardsFrame.editSaveButton).addClass("btn-default").removeClass("btn-primary"); $(_this.options.staging.cardsFrame.editSaveButton + " " + _this.options.staging.cardsFrame.icon).text("edit"); if (!reset && _this.options.designChanged) { _this.options.design = _this._generateCardsDesign(); if ((saveMsg = _this._saveCardDesign()) == "true") { _this.options.designChanged = false; showAlertDialog("success", "Cards Design Saved Successfully"); _this.activate(); } else { try { saveMsg = JSON.parse(saveMsg)["error"]["msg"]; } catch (ex) {} showAlertDialog("error", saveMsg); if (saveMsg == "Session Authentication failed...") { setTimeout(() => { parent.window.location.href = "../aspx/sess.aspx"; }, 1000); } } } else if(!_this.options.designChanged) { } } }, _generateCardsDesign() { let _this = this; return $(`${_this.options.staging.cardsFrame.cardsDesigner} li input:checkbox`).map((index, elem) => { return {axp_cardsid: $(elem).data("cardId"), visible: $(elem).prop("checked"), orderno: index+ 1 } }).toArray(); }, _saveCardDesign() { let _this = this; let result = ""; $.ajax({ url: 'mainnew.aspx/saveCardsDesign', type: 'POST', cache: false, async: false, data: JSON.stringify({ design: JSON.stringify(_this.options.design) }), dataType: 'json', contentType: "application/json", success: function (data) { if (data && data.d) { result = data.d; } }, error: function (error) { } }); return result; }, _sortCardsObject(cards) { let _this = this; if(_this.options.cards.length > 0){ _this.options.cards = _.values(_.merge(_.keyBy(_this.options.cards, 'axp_cardsid'), _.keyBy(_this.options.design, 'axp_cardsid'))).map((card => { if(card["cardtype"]){ typeof card["visible"] != "undefined" ? delete card.visible : ""; return card; }else{ return false; } })).filter((card=>card)); } _this.options.cards = _.sortBy(_this.options.cards, (card)=>parseInt(card.orderno)) }, _drawCardsLayout() { let _this = this; $(_this.options.staging.cardsFrame.div + " " + _this.options.staging.cardsFrame.cardsDiv).html(``); $(_this.options.staging.cardsFrame.div + " " + _this.options.staging.cardsFrame.cardsDesigner).html(``); if (_this.options.enableMasonry) { $(_this.options.staging.cardsFrame.div + " " + _this.options.staging.cardsFrame.cardsDiv).html(_this.options.html.masonryWidth); } try { callParentNew("updateAppLinkObj(loadhomepage)", "function"); } catch (ex) { } _this.options.cards.forEach((card, index) => { let cardType = card["cardtype"]; if (cardType) { if(["chart", "kpi", "list", "menu", "modern menu", "image card", "calendar", "html"].indexOf(cardType) == -1){ return; } let cardData = _this._getCardData(card); let cardId = card["axp_cardsid"]; let design = _this.options.design.filter((dsign) => dsign.axp_cardsid == cardId)[0]; let cardVisible = design && typeof design["visible"] != "undefined" ? JSON.parse(design["visible"]) : true; $(_this.options.staging.cardsFrame.cardsDesigner).append(`
  • drag_indicator
  • `); if (!cardVisible) { return cardVisible; } let cardFormattedData = []; cardFormattedData = _this._formatOutput(cardData); let cardElement = $(_this.options.html[cardType]).attr("card-index", index).data("card-index", index); $(_this.options.staging.cardsFrame.cardsDiv).append(cardElement); switch (cardType) { case "kpi": _this._addCardHeight(cardElement, card, ""); _this._addCardWidth(cardElement, card, "3"); _this._addCardIcon(cardElement, card); _this._addCardHeader(cardElement, card); if (typeof cardData != "string" && cardData.length > 0) { try { _this._setKpiInfo(cardElement, cardData, cardFormattedData); } catch (ex) {} } _this._addCardBackground(cardElement,card); break; case "image card": _this._addCardHeight(cardElement, card, ""); _this._addCardWidth(cardElement, card, "4"); _this._addCardIcon(cardElement, card); _this._addCardHeader(cardElement, card); try { _this._setImageCardInfo(cardElement, cardData, card); } catch (ex) {} _this._addCardBackground(cardElement,card); break; case "chart": _this._addCardHeight(cardElement, card, ""); _this._addCardWidth(cardElement, card, "4"); _this._addCardIcon(cardElement, card); _this._addCardHeader(cardElement, card); if (typeof cardData != "string" && cardData.length > 0) { setTimeout(() => { let body = cardElement.find("bodyContent").parent(); try { AxPlotHighChartWidgets(card["charttype"], body, cardFormattedData.rows, cardFormattedData.metaData, (_this._getChartJsonProps(card, "attributes") || {}), (_this._getChartJsonProps(card, "attributes.enableSlick") || false)); setTimeout(() => { body.find(".highcharts-button.highcharts-contextbutton, .highcharts-button.highcharts-contextbutton *").hide(); }, 0); } catch (ex) {} }, 0); } break; case "list": _this._addCardHeight(cardElement, card, ""); _this._addCardWidth(cardElement, card, "6"); _this._addCardIcon(cardElement, card); _this._addCardHeader(cardElement, card); if (typeof cardData != "string" && cardData.length > 0) { setTimeout(() => { try { _this._generateDatatable(cardElement.find("bodyContent").parent(), card, cardData, cardFormattedData); _this._addCardBackground(cardElement,card); } catch (ex) {} }, 0); } break; case "menu": _this._addCardHeight(cardElement, card, ""); _this._addCardWidth(cardElement, card, "6"); _this._addCardIcon(cardElement, card); _this._addCardHeader(cardElement, card); try{ _this._setMenuInfo(cardElement, cardData, card); } catch (ex) {} _this._addCardBackground(cardElement,card); break; case "modern menu": _this._addCardWidth(cardElement, {...card, width: "col-md-12"}, "12"); // _this.currentColumnWidth = 0; try { _this._setModernMenuInfo(cardElement, cardData, card); } catch (ex) {} break; case "calendar": _this._addCardWidth(cardElement, card, "12"); _this._addCardHeight(cardElement, card, ""); _this._addCardIcon(cardElement, card); _this._addCardHeader(cardElement, card); try { _this._setCalendar(cardElement, cardData, card); } catch (ex) {} break; case "html": _this._addCardHeight(cardElement, card, ""); _this._addCardWidth(cardElement, card, "4"); _this._addCardIcon(cardElement, card); _this._addCardHeader(cardElement, card); try { _this._setHtmlData(cardElement, card); } catch (ex) {} _this._addCardBackground(cardElement,card); break; case "break": break; } } }); _this._cardsWidthPostProcessor($(_this.options.staging.cardsFrame.cardsDiv)); _this._registerPlugins(); }, _getCardData(card){ let cardData = card.cardsql.row || card.cardsql["@value"] || ""; if (typeof cardData.length == "undefined") { cardData = [cardData]; } return cardData; }, _addCardIcon(cardElement, card) { let iconDiv = cardElement.find("iconContent").parents(".mainIcon"); let icon = card["cardicon"] ? (card["cardicon"] != "*" ? card["cardicon"].toString() : "") : ""; cardElement.find("iconContent").replaceWith(icon); if (icon) { iconDiv.addClass("iconAdded"); } else { iconDiv.addClass("d-none"); } }, _addCardHeader(cardElement, card) { cardElement.find(".mainHeading").attr("title", (card["cardname"] || "")).find("headerContent").replaceWith(card["cardname"] || ""); }, _addCardBackground(cardElement, card){ cardElement.find(".card-body a:not(.dropdown a)").addClass("border-bottom"); if(card["axpfile_imgcard"] && card["cardtype"] == "image card") { cardElement.find("imageContent").replaceWith($(``).attr("src", `../${thmProj}/ImageCard/${card["axpfile_imgcard"].split(",")[0]}`)); } if(card["cardbgclr"]) { cardElement.find(".card, table, a:not(.dropdown a)").addClass("cardbg-" + card["cardbgclr"]); cardElement.find(".symbol .symbol-label, button").addClass("cardbg-inverse-" + card["cardbgclr"]); } }, _addCardWidth(cardElement, card, defaultWidth) { let _this = this; if (_this._getSetCardWidth(cardElement, card, defaultWidth)) { if(_this.options.enableMasonry){ $(_this._getClearFix()).insertBefore(cardElement); }else{ $(cardElement.prevAll(":not(.row)").toArray().reverse()).wrapAll(`
    `); } } }, _addCardHeight(cardElement, card, defaultHeight) { let _this = this; if(cardElement.find(".heightControl").length > 0){ _this._getSetCardHeight(cardElement.find(".heightControl"), card, defaultHeight); } }, _formatOutput(result){ let mt = [], row = [], rowset = []; for(i=0;i 0) { let tableHTML = ` ${Object.keys(cardData[0]).map((col, ind) => { if (col.toLowerCase() == "link" || col.toLowerCase().endsWith("_ui") || col.toLowerCase().startsWith("axphide_")) { hiddenColumns.push(ind); } return ``; }).join('')}
    ${col}
    `; elem.html(tableHTML); elem.find("table").DataTable({ data: cardData, columns: Object.keys(cardData[0]).map((col) => { return {data: col} }), dom: "t", // order: [], columnDefs: [ { targets: hiddenColumns, visible: false }, { targets: "_all", createdCell(elem, cellData, rowData, row, col) { if (Object.keys(rowData)[col].toLowerCase().startsWith("axphidec_")) { $(elem).html(""); return; } var hyperLinkCol = parsedHyperLink ? parsedHyperLink.i : false; if (hyperLinkCol !== false) { cellData = getTheHyperLink(cardFormattedData.rows[row][hyperLinkCol], parsedHyperLink, customizeData(cardFormattedData.rows[row][col]), col); $(elem).html(cellData); } if (styleString = rowData[`${Object.keys(rowData)[col]}_ui`]) { $(elem).html(_this._SetAxFontCondition($(`
    ${cellData}
    `).find("div"), styleString).css({"border-radius": "10px"}).parent().html()); } } } ], "bLengthChange": false, "bPaginate": false, "pageLength": 20, initComplete(settings, json) { $(this).css({ "height": (elem.height()) + "px", "overflow": "auto", "display": "block" }); } }); } }, _setKpiInfo(cardElement, cardData, cardFormattedData) { if (cardData && cardData[0] && cardData[0]["status"]) { let statusContent = cardElement.find("statusContent"); statusContent.parents("card-toolbar").removeClass("d-none"); statusContent.replaceWith($("
    " + cardData[0]["status"] + "
    ").attr("title", `${(cardData[0]["status"]) || ""}`) || ""); } if (cardData && cardData[0] && cardData[0]["footer"]) { cardElement.find("footerContent").replaceWith($("
    " + cardData[0]["footer"] + "
    ").attr("title", `${(cardData[0]["footer"]) || ""}`) || ""); }else{ cardElement.find("footerContent").parents(".card-footer").addClass("d-none"); } var plotName = ((thisdata = cardData[0][Object.keys(cardData[0])[0]]) || (typeof thisdata != "undefined" ? thisdata : "")); var data = ""; try { var parsedHyperLink = parseHyperLink(cardFormattedData.metaData, cardFormattedData.rows[0]); var hyperLinkCol = parsedHyperLink ? parsedHyperLink.i : false; if (hyperLinkCol !== false) { data = getTheHyperLink(cardFormattedData.rows[0][hyperLinkCol], parsedHyperLink, customizeData(plotName), parseInt(Object.keys(parsedHyperLink.data)[0].replace("col", "")) - 1); }else{ data = customizeData(plotName); } } catch (ex) { data = customizeData(plotName); } cardElement.find("bodyContent").replaceWith($(`
    ${data}
    `).attr("title", `${(cardData[0][Object.keys(cardData[0])[0]]) || ""}`) || ""); }, _setImageCardInfo(cardElement, cardData, card) { var data = ""; data = card.pagedesc || ""; if(data){ cardElement.find("bodyContent").replaceWith($(`
    ${data}
    `).attr("title", `${(data) || ""}`) || ""); } if (card.htransid && card.htype) { let linkStr = ""; if (card["htype"].toLowerCase() === "iview") { linkStr = "ivtoivload.aspx?ivname=" + card.htransid; } else if (card["htype"].toLowerCase() === "tstruct") { linkStr = "tstruct.aspx?transid=" + card.htransid; } let footerHyperLink = `AxLoadUrl('${linkStr}');`; cardElement.find("footerContent").replaceWith($("" + (card.hcaption || "Link") + "").attr("onclick", `${footerHyperLink || ""}`) || ""); }else{ cardElement.find("footerContent").parents(".card-footer").addClass("d-none"); } }, _setMenuInfo(cardElement, cardData, card) { var data = ""; data = card["pagedesc"] || card["cardname"] || ""; cardElement.find("descriptionContent").replaceWith($(`
    ${data}
    `).attr("title", `${data}`) || ""); var pageName = ""; pageName = card["pagename"] || ""; let menuArray = []; if (pageName) { var pageObj = _.findDeep( menuJson, (value, key, parent) => { if (key == 'oname' && value == pageName) return true; } )?.parent; if (pageObj) { if (!pageObj.target) { menuArray = pageObj.child || []; } else { menuArray = pageObj; } if (typeof menuArray.length == "undefined") { menuArray = [menuArray]; } } } if (menuArray.length > 0) { let menuOptions = menuArray.map(menu => { if (!menu.target) { return ``; } let iconString = ``; if (typeof menu.icon == "object") { iconString = `${menu.icon.text}`; } else if (menu.icon && menu.icon.indexOf("/") != -1) { iconString = ``; } else if (menu.target != undefined && menu.target != "") { if (menu.target.indexOf("tstruct.aspx") > -1) { iconString = `assignment`; } else if (menu.target.indexOf("iview.aspx") > -1 || menu.target.indexOf("iviewInteractive.aspx") > -1) { iconString = `view_list`; } else { iconString = `insert_drive_file`; } } else if (menu.target == "" && menu.oname.indexOf("Head") > -1) { iconString = `folder`; } else { iconString = `insert_drive_file`; } return ` `; }).join(""); let menuHTML = ` `; if (menuHTML && menuOptions) { cardElement.find("bodyContent").replaceWith($(`
    ${menuHTML}
    `) || ""); } } }, _setModernMenuInfo(cardElement, cardData, card) { let _this = this; var pageName = ""; pageName = card["pagename"] || ""; let menuArray = []; if (pageName) { var pageObj = _.findDeep( menuJson, (value, key, parent) => { if (key == 'oname' && value == pageName) return true; } )?.parent; if (pageObj) { if (!pageObj.target) { menuArray = pageObj.child || []; } else { menuArray = pageObj; } if (typeof menuArray.length == "undefined") { menuArray = [menuArray]; } } } if (menuArray.length > 0) { let menuOptions = menuArray.map(menu => { if (!menu.target) { return ``; } let iconString = ``; if (typeof menu.icon == "object") { iconString = `${menu.icon.text}`; } else if (menu.icon && menu.icon.indexOf("/") != -1) { iconString = ``; } else if (menu.target != undefined && menu.target != "") { if (menu.target.indexOf("tstruct.aspx") > -1) { iconString = `assignment`; } else if (menu.target.indexOf("iview.aspx") > -1 || menu.target.indexOf("iviewInteractive.aspx") > -1) { iconString = `view_list`; } else { iconString = `insert_drive_file`; } } else if (menu.target == "" && menu.oname.indexOf("Head") > -1) { iconString = `folder`; } else { iconString = `insert_drive_file`; } let tempMenu = $(_this.options.html["modernMenuContent"]); tempMenu.find("bodyContent").replaceWith($(`
    ${menu.name}
    `) || ""); tempMenu.find("iconContent").replaceWith($(`
    ${iconString}
    `) || ""); tempMenu.attr("onclick", `AxLoadUrl('${menu.target}')`); return tempMenu.get(0).outerHTML; }).join(""); if (menuOptions) { cardElement.find("modernMenuContent").replaceWith($(`
    ${menuOptions}
    `) || ""); } } }, _setCalendar(cardElement, cardData, card){ let _this = this; let body = cardElement.find("bodyContent").parent(); body.find("bodyContent").hide(); if(!body.data("height")){ body.data("height", body.css("height")); } body.css("height", body.data("height")); let bodyHeight = $(body).height(); try { if(card["obj"]){ let ind = cardElement.data("cardIndex"); _this.options.cards[ind] = card; cardData = _this._getCardData(card); card["obj"].destroy(); } } catch (ex) {} let headerOptions = [ { icon: "calendar_view_month", href: "javascript:void(0);", caption: "Month View", onclick: `$.axpertUI.cardsPage.options.cards[${cardElement.data("cardIndex")}].obj.changeView('dayGridMonth');` }, { icon: "calendar_view_week", href: "javascript:void(0);", caption: "Week View", onclick: `$.axpertUI.cardsPage.options.cards[${cardElement.data("cardIndex")}].obj.changeView('dayGridWeek');` }, { icon: "calendar_view_day", href: "javascript:void(0);", caption: "Day View", onclick: `$.axpertUI.cardsPage.options.cards[${cardElement.data("cardIndex")}].obj.changeView('timeGridDay');` }, { icon: "add", href: "javascript:void(0);", caption: "Add Event", onclick: `$.axpertUI.cardsPage._calendarEventClick('', ${cardElement.data("cardIndex")});` } ]; cardElement.find(".card-toolbar").removeClass("d-none"); cardElement.find(".card-toolbar .menu.menu-sub.menu-sub-dropdown .separator + .menu-item").remove(); headerOptions.forEach((opt)=>{ cardElement.find(".card-toolbar .menu.menu-sub.menu-sub-dropdown").append(` `); }); var calendar = new FullCalendar.Calendar($(body)[0], { initialView: 'dayGridMonth', dayMaxEventRows: true, views: { timeGrid: { dayMaxEventRows: true } }, height: bodyHeight, headerToolbar: { start: 'title', center: '', end: 'today,prev,next' }, buttonText:{ today: "today", dayGridMonth: "calendar_view_month", timeGridDay: "calendar_view_day", prev: "navigate_before", next: "navigate_next" }, customButtons: { addEvent: { text: 'add', click(e){ _this._calendarEventClick(e); } } }, events: _this._calendarEventData(cardElement, cardData, card), eventClick(info) { $(".popover.in, .fc-popover").remove(); _this._calendarEventClick(info?.event?._def?.publicId, cardElement.data("cardIndex")); }, dateClick: function(info) { $(".popover.in, .fc-popover").remove(); _this._calendarEventClick(``, cardElement.data("cardIndex"), (info.dateStr ? `${moment(info.dateStr).format("DD/MM/YYYY")}`: ``)); }, eventDidMount(info) { $(info.el).popover({ get title(){ let {title} = info?.event?._def; let {type} = info?.event?._def?.extendedProps; return `${title ? (`${title} (${type || ""})`) : ""}` }, get content(){ let finalContent = ""; let {description, status, location} = info?.event?._def?.extendedProps; typeof description != "undefined" && description != "" && (finalContent += ((finalContent ? "
    " : "") + ``)); typeof status != "undefined" && status != "" && (finalContent += ((finalContent ? "" : "") + ``)); typeof location != "undefined" && location != "" && (finalContent += ((finalContent ? "" : "") + ``)); return finalContent || ""; }, trigger: 'hover', placement: 'top', container: 'body', html: true, animation: false, delay: { show: 0, hide: 0 } }); } }); setTimeout(() => { calendar.render(); card["obj"] = calendar; }, 0); }, _calendarEventClick(recordObj = "", ind = "", date = "") { let _this = $.axpertUI.cardsPage; let recordid = ""; let cardElement; let card; let cardData; if(typeof recordObj == "object"){ cardElement = $(recordObj.currentTarget).parents(".widgetWrapper"); ind = cardElement.data("cardIndex"); card = _this.options.cards[ind]; cardData = _this._getCardData(card); recordid = card["axp_cardsid"]; }else{ cardElement = $(`.widgetWrapper[card-index=${ind}]`); card = _this.options.cards[ind] cardData = _this._getCardData(card); recordid = recordObj; } let popTitle = "Calendar Events"; displayBootstrapModalDialog(popTitle, 'xxl', 'calc(100vh - 50px)', true, `tstruct.aspx?transid=axcal${typeof recordid == "string" && recordid != "" ? `&recordid=${recordid}` : ``}${typeof date == "string" && date != "" ? `&startdate=${date}` : ``}&AxPop=true&act=open`, false, ()=>{ try { removePageHeaders(); } catch (ex) {} let iFrameId = "iFrame" + popTitle.split(" ").join(""); let dialogWindow = $(`#${iFrameId}`); try { iframePopupLoadOpts(dialogWindow); } catch (ex) {} }, ()=>{ try { if(callParentNew('isSuccessAlertInPopUp')){ callParentNew('isSuccessAlertInPopUp=', false); let obj = card["obj"]; card = _this._refreshData(card["axp_cardsid"], true).filter(c=>c["axp_cardsid"] == card["axp_cardsid"])[0]; cardData = _this._getCardData(card); card["obj"] = obj; _this._setCalendar(cardElement, cardData, card); } } catch (ex) {} }); }, _calendarEventData(cardElement, cardData, card){ let _this = this; let returnData = []; cardData = cardData || []; try { if(cardData){ returnData = cardData.map(d=>{ return { id: d.axcalendarid || "", title: d.eventname || "", get start(){ let returnString = ""; if(d.startdate){ let {date, format} =_this._getDateAndFormatBasedOnCulture(d.startdate); if(date && format){ d.axptm_starttime = d.axptm_starttime || "00:00"; date = `${date} ${d.axptm_starttime}`; format = `${format} hh:mm`; try { returnString = moment(date, format).toISOString(); } catch (ex) {} } } return returnString; }, get end(){ let returnString = ""; d.enddate = d.enddate || d.startdate; if(d.enddate){ let {date, format} =_this._getDateAndFormatBasedOnCulture(d.enddate); if(date && format){ d.axptm_endtime = d.axptm_endtime || "23:59"; date = `${date} ${d.axptm_endtime}`; format = `${format} hh:mm`; try { returnString = moment(date, format).toISOString(); } catch (ex) {} } } return returnString; }, get allDay(){ return (d.startdate == d.enddate && d.axptm_starttime == "00:00" && d.axptm_endtime == "23:59") || (moment(this.end).diff(moment(this.start), 'days') == 1 && d.axptm_starttime == "00:00" && d.axptm_endtime == "00:00"); }, type: d.eventtype || "", description: d.messagetext || "", get status(){ switch(d.status){ case 0: return "New event"; case 1: return "Accepted"; case 2: return "Rejected"; case 3: return "Reschedule request"; case 4: return "Cancel"; default: return ""; } }, location: d.location || "", get classNames(){ switch(this.type.toLowerCase()){ case "personal": return "cardbg-cyan"; case "meeting": return "cardbg-pink"; case "online meet": return "cardbg-purple"; case "leave": return "cardbg-red"; default: return ""; } }, url: `javascript:void(0);` }; }) || []; } } catch (ex) {} return returnData; }, _setHtmlData(cardElement, card){ cardElement.find("bodyContent").replaceWith(`
    `); var shadowDomEle = $(cardElement.find(".body-content"))[0]; var shadowAtt = shadowDomEle.attachShadow({mode: 'open'}); card.shadow = shadowAtt; if (card["html_editor_card"]) { let cardHTML = card["html_editor_card"]; // cardHTML = ` // `; let objCardHTML = $(cardHTML); if(objCardHTML.data("theme")){ cardHTML = `` + cardHTML; } if(objCardHTML.data("handlebars")){ let sourceApiName = objCardHTML.data("sourceApiName"); let sourceApiType = objCardHTML.data("sourceApiType"); if(sourceApiName && sourceApiType == "menu"){ let menuData = AxGetMenus(sourceApiName); // menuData = menuData.length == 1 ? [...menuData[0]] : menuData; menuData = Object.keys(menuData).length == 1 ? menuData[Object.keys(menuData)] : menuData; card.axRenderProject = thmProj; card.apiData = menuData; try { cardHTML = Handlebars.compile(cardHTML)(card); } catch (error) { console.error("Card HTML Templete", "menu", error); } shadowAtt.innerHTML = cardHTML; }else if(sourceApiName && (sourceApiType == "sql" || sourceApiType == "axpert")){ AxAsyncGetApiData(sourceApiName, sourceApiType, [{ "id": card.axp_cardsid, "cachedata": card.cachedata, "cachedTime": String(card.cachedTime).padStart(12, '0'), "autorefresh": card.autorefresh }], (succ) => { var apiData = JSON.parse(succ); apiData = Object.keys(apiData).length == 1 ? apiData[Object.keys(apiData)] : apiData; card.axRenderProject = thmProj; card.apiData = apiData; try { cardHTML = Handlebars.compile(cardHTML)(card); } catch (error) { console.error("Card HTML Templete", sourceApiType, error); } shadowAtt.innerHTML = cardHTML; }, (err) => { } ); } } else { shadowAtt.innerHTML = cardHTML; } // shadowAtt.innerHTML = card["html_editor_card"]; // shadowAtt.appendChild($(``)[0].content ) // for executing javascript // $(card["html_editor_card"]).toArray().filter((domElm) => { // return domElm.tagName?.toLowerCase() == "script" // }).forEach((domElm) => { // var scriptWrapper = document.createElement( 'script-wrapper' ) // var script = document.createElement( 'script' ) // script.textContent = domElm?.text || ""; // scriptWrapper.appendChild(script); // shadowAtt.appendChild(scriptWrapper); // }); } }, _getDateAndFormatBasedOnCulture(dateStr) { if (dateStr != "") { dateStr = dateStr.split(" ")[0]; if (glCulture == "en-us") { var splittedDate = dateStr.split("/"); if (splittedDate.length > 2) { dateStr = splittedDate[1] + "/" + splittedDate[0] + "/" + splittedDate[2]; } } } return {date: dateStr, format: (glCulture == "en-us" ? "MM/DD/YYYY" : "DD/MM/YYYY")}; }, _SetAxFontCondition(thisFld, applyStyle) { let _this = this; if (applyStyle != "") { _this._ResetAxFont(thisFld); applyStyle = applyStyle.split(','); for (var y = 0; y < applyStyle.length; y++) { var currentStyle = applyStyle[y].split('='); switch (currentStyle[0].toLowerCase()) { case "fontname": thisFld.css("font-family", currentStyle[1]); break; case "fontsize": thisFld.css("font-size", currentStyle[1] + "pt"); break; case "fontstyle": for (var z = 0; z < currentStyle[1].toLowerCase().length; z++) { switch (currentStyle[1].toLowerCase()[z]) { case "b": thisFld.css('font-weight', 'bold'); break; case "i": thisFld.css('font-style', 'italic'); break; case "u": if (thisFld.css("text-decoration") == "line-through") { thisFld.css("text-decoration", "line-through underline"); } else { thisFld.css("text-decoration", "underline"); } break; case "s": if (thisFld.css("text-decoration") == "underline") { thisFld.css("text-decoration", "underline line-through"); } else { thisFld.css("text-decoration", "line-through"); } break; } } break; case "fontcolor": if (AxClColors[currentStyle[1]]) { thisFld.css("color", AxClColors[currentStyle[1]]); } else if (currentStyle[1].indexOf("#") == 0) { thisFld.css("color", currentStyle[1]); } else { thisFld.css("color", currentStyle[1]); } break; case "backcolor": if (AxClColors[currentStyle[1]]) { thisFld.css("background", AxClColors[currentStyle[1]]); } else if (currentStyle[1].indexOf("#") == 0) { thisFld.css("background", currentStyle[1]); } else { thisFld.css("background", currentStyle[1]); } break; default: thisFld.css(currentStyle[0], currentStyle[1]); break; } } } else { _this._ResetAxFont(thisFld); } return thisFld; }, _ResetAxFont(thisFld) { let _this = this; thisFld.css("font-family", ""); thisFld.css('font-weight', ""); thisFld.css('font-style', ""); thisFld.css("text-decoration", ""); thisFld.css("color", ""); thisFld.css("background", ""); }, _getSetCardWidth(elem, card, defaultVal, returnValue = false) { let _this = this; let cardWidth = ""; //cardWidth = _this._getChartJsonProps(card, "width").toString(); cardWidth = card["width"] || $(elem)[0].className; if (!cardWidth) { if (defaultVal) { cardWidth = defaultVal.toString(); } } if (cardWidth) { cardWidth = cardWidth.split(" ").filter(col => col.indexOf("col-") == 0).reverse().join(" ").toString(); if (cardWidth.indexOf("col-") == 0 || !isNaN(+cardWidth)) { if (cardWidth.indexOf("col-") == 0) { cardWidth = cardWidth.split("-")[cardWidth.split("-").length - 1]; } if (!cardWidth) { if (defaultVal) { cardWidth = defaultVal.toString(); } } if (cardWidth) { if(returnValue){ return +cardWidth; } elem.removeClass(function (index, className) { return (className.match (/(^|\s)col-\S+/g) || []).join(' '); }); elem.addClass(`col-lg-${cardWidth} col-md-${cardWidth} col-sm-12 col-xs-12`); if(cardWidth == "12" && (heightControl = elem.find(".heightControl")) && heightControl.length > 0 && (setHeight = heightControl.data("height"))){ heightControl.css({ "height": `${setHeight}` }); heightControl.removeClass(heightControl.attr("class").split(" ").filter(className => className.startsWith("h-") || className.startsWith("mh-") || className.startsWith("min-h-")).join(" ")); } }else if(returnValue){ return +cardWidth; } } else { cardWidth = ""; if(returnValue){ return +cardWidth; } } }else if(returnValue){ return +cardWidth; } // return cardWidth; if (cardWidth !== "") { cardWidth = +cardWidth; if (_this.currentColumnWidth + cardWidth > _this.options.totalColumns || cardWidth >= _this.options.totalColumns) { if (_this.currentColumnWidth + cardWidth > _this.options.totalColumns) { _this.currentColumnWidth = cardWidth; } else { _this.currentColumnWidth = 0; } return true; } else { _this.currentColumnWidth += cardWidth; return false; } } }, _getSetCardHeight(elem, card, defaultVal) { let _this = this; let cardHeight = ""; //cardHeight = _this._getChartJsonProps(card, "height"); cardHeight = card["height"]; if (!cardHeight) { if (defaultVal) { cardHeight = defaultVal; } } if (cardHeight) { cardHeight = cardHeight.toString(); if (cardHeight.indexOf("px") == cardHeight.length - 2) { // elem.removeClass(function (index, className) { // return (className.match (/(^|\s)col-\S+/g) || []).join(' '); // }); let cardHeightRaw = cardHeight.substring(0, cardHeight.length - 2); cardHeight = cardHeightRaw + "px"; if (cardHeight != "0px" && +cardHeightRaw > -1) { elem.data("height", cardHeight); } //elem.addClass(`col-lg-${cardHeight} col-md-${cardHeight} col-sm-${cardHeight} col-xs-${cardHeight}`); } else { cardHeight = ""; } } else { cardHeight = ""; } // return cardWidth; }, _getChartJsonProps(card, prop) { if (card["chartjson"] && card["chartjson"] != "*") { let chartJsonProps = {}; if (typeof card["chartjson"] == "string") { try { chartJsonProps = JSON.parse(card["chartjson"]); } catch (ex) {} } else { chartJsonProps = card["chartjson"]; } if (typeof prop != "undefined") { if (typeof _.get(chartJsonProps, prop) != "undefined") { return _.get(chartJsonProps, prop); } else { return ""; } } else { return chartJsonProps; } } else { return ""; } }, _cardsWidthPostProcessor(cardsStage){ let _this = this; if(!_this.options.enableMasonry){ cardsStage.children(":not(.row)").wrapAll(`
    `); cardsStage.children().toArray().forEach(row => { const totalChildWidth = $(row).children().toArray().reduce((totalWidth, card) => { return _this._getSetCardWidth($(card), "", "", true) + totalWidth; }, 0) || 0; if(totalChildWidth < 12){ const lastCard = $(row).children(":last")[0]; const newLastColumnWidth = _this._getSetCardWidth($(lastCard), "", "", true) + (12 - totalChildWidth); _this._getSetCardWidth($(lastCard), {"width": `col-${newLastColumnWidth}`}); } }); } }, _registerPlugins() { let _this = this; KTMenu && KTMenu.init(); $(_this.options.staging.cardsFrame.cardsDesigner).sortable({ cursor: "move", update: function (event, ui) { _this.options.designChanged = true; }, }); $(`${_this.options.staging.cardsFrame.cardsDesigner} li input:checkbox`).off("change.design").on("change.design", () => { _this.options.designChanged = true; }); $(window).off("resize.cards").on("resize.cards", (e) => { // debugger; $(".widgetWrapper.chartWrapper .highcharts-container").each((ind, elem) => { try { let chartObj = Highcharts.charts[$(elem).parent(".card-body").data("highchartsChart")]; setTimeout(() => { chartObj.reflow(); }, 1000); } catch (ex) { } }); $(".widgetWrapper.listWrapper table.dataTable").each((ind, elem) => { try { setTimeout(() => { $(elem).css("display", ""); $(elem).css({ "height": ($(elem).parents(".card-body").height()) + "px", "overflow": "auto", "display": "block" }); }, 0); } catch (ex) { } }); $(".widgetWrapper.calendarWrapper").each((ind, elem) => { try { let calendarObj = _this.options.cards[$(elem).data("cardIndex")].obj; setTimeout(() => { calendarObj.render(); }, 1000); } catch (ex) { } }); }); //ppn $(".cardsPageWrapper").on("resize", function(e) { // e; // this; // debugger; // }); if (_this.options.enableMasonry) { setTimeout(() => { if ($(_this.options.staging.cardsFrame.cardsDiv).data("masonry")) { $(_this.options.staging.cardsFrame.cardsDiv).masonry('destroy'); } $(_this.options.staging.cardsFrame.div + " " + _this.options.staging.cardsFrame.cardsDiv) .masonry({ itemSelector: '.widgetWrapper', columnWidth: '.grid-sizer', percentPosition: true }); }, 0); } }, _getClearFix() { return `
    `; } } /* Searchbar - Function ================================================================================================ * You can manage the search bar * */ search = { activate: function (options) { var _this = this; _this.options = options; KTLayoutSearch.getData = _this.getAjaxData; $(_this.options.staging.divParent).find(_this.options.staging.options.startsWith.div).attr("title", _this.options.staging.options.startsWith.title).text(_this.options.staging.options.startsWith.title); $(_this.options.staging.divParent).find(_this.options.staging.div).attr("placeholder", this.options.staging.placeholder); }, searchModeContains: function (contains = true) { var _this = this; if (contains) { GlobalSrchCondition = 'Contains'; } else { GlobalSrchCondition = 'StartsWith'; } var searchElem = $(_this.options.staging.div) searchElem.val() && searchElem.val().length > 1 && searchElem.focus().autocomplete("search", searchElem.val()); }, hideKTSearch(){ var _this = this; _this.searchObj.hide(); }, getAjaxData(searchObj){ var _this = $.axpertUI.search; _this.searchObj = searchObj; var txtInput = searchObj.getQuery() || ""; var gbSearch = []; var srchResult = ""; $.ajax({ url: 'mainnew.aspx/getGlobalSearchData', type: 'POST', cache: false, async: true, data: JSON.stringify({ keyword: txtInput, cond: GlobalSrchCondition }), dataType: 'json', contentType: "application/json", success: function (data) { gloSrchPageNo = 0; if (data.d.indexOf("*♦*") != -1) { var srchData = data.d.split("*♦*"); gloSrchLimit = srchData[0]; console.log("GlobalSearch RowCount-" + srchData[0]); if (srchData.length > 1) srchResult = srchData[1]; } else srchResult = data.d; if (srchResult == "Session Expired") window.location = "../aspx/sess.aspx"; if (srchResult != "getting exception in code" && srchResult != "") tblSearchData = $.parseJSON(srchResult); else { tblSearchData = []; } gbSearch = GetGLoSrchItems(tblSearchData) || []; if (gbSearch.length != 0) { _this.processAjaxData($.map(gbSearch.slice(0, 100), function (item) { var itemDts = item.split('♣'); return { label: itemDts[0], link: itemDts[1] } }) || [], searchObj) } else { _this.processAjaxData([], searchObj); } }, error: function (xhr, ajaxOptions, thrownError) { _this.processAjaxData([], searchObj); } }); }, processAjaxData(datas, searchObj){ var _this = this; $(searchObj.resultsElement).find("div:first").empty(); if(datas.length > 0){ datas.forEach(data=>{ var searchType = data.link.split('♦')[0]; var toolTip = data.label; itemText = toolTip; if (itemText.length > 100) itemText = itemText.substr(0, 100) + "..."; itemText = CheckSpCharsForXml(itemText); searchType = searchType.toLowerCase(); var icon = ""; if (searchType == "iview" || searchType == "iviewinteractive") { icon = "view_list"; } else if (searchType == "tstruct") { icon = "assignment"; } else if (searchType == "page" || searchType == "htmlpages") { icon = "insert_drive_file"; } else if (searchType == "help") { icon = "live_help"; } else { icon = "search"; } var loadurl = searchLoadIframe(searchType, data.link.split('♦')[1], true); if (loadurl != "") { if(loadurl.startsWith("help.aspx")){ loadurl = `javascript:window.open(\"${loadurl}\", \"_blank\");`; } else { loadurl = `javascript:LoadIframe(\"${loadurl}\");`; } } $(searchObj.resultsElement).find("div:first").append(`
    ${icon}
    ${itemText} ${function(searchType){ switch(searchType){ case "iview": return "Report"; case "tstruct": return "Form"; default: return searchType; } }(searchType)}
    `); }); } else{ KTEventHandler.trigger(searchObj.element, 'kt.search.clear', searchObj); } } } //========================================================================================================================== /* Navbar - Function ======================================================================================================= * You can manage the navbar * */ navbar = { activate: function () { var $body = $('body'); var $overlay = $('.overlay'); var $navbarCollapse = $('.navbar-collapse'); //Open left sidebar panel $('.bars').on('click', function () { if ($.axpertUI.options.cardsPage.setCards && $($.axpertUI.options.cardsPage.staging.cardsFrame.div).is(":visible")) { setTimeout(() => { $(window).trigger("resize.cards"); }, 0); } }); //Close collapse bar on click event $('.nav [data-close="true"]').on('click', function () { if ($('.navbar-toggle').is(':visible')) { $navbarCollapse.slideUp(function () { $navbarCollapse.removeClass('in').removeAttr('style'); }); } }); } } //========================================================================================================================== /* Input - Function ======================================================================================================== * You can manage the inputs(also textareas) with name of class 'form-control' * */ input = { activate: function ($parentSelector) { $parentSelector = $parentSelector || $('body'); //On focus event $parentSelector.find('.form-control').focus(function () { $(this).closest('.form-line').addClass('focused'); }); //On focusout event $parentSelector.find('.form-control').focusout(function () { var $this = $(this); if ($this.parents('.form-group').hasClass('form-float')) { if ($this.val() == '') { $this.parents('.form-line').removeClass('focused'); } } else { $this.parents('.form-line').removeClass('focused'); } }); //On label click $parentSelector.on('click', '.form-float .form-line .form-label', function () { $(this).parent().find('input').focus(); }); //Not blank form $parentSelector.find('.form-control').each(function () { if ($(this).val() !== '') { $(this).parents('.form-line').addClass('focused'); } }); } } //========================================================================================================================== /* Form - Select - Function ================================================================================================ * You can manage the 'select' of form elements * */ select = { activate: function () { if ($.fn.selectpicker) { $('select:not(.ms)').selectpicker(); } } } //========================================================================================================================== /* DropdownMenu - Function ================================================================================================= * You can manage the dropdown menu * */ dropdownMenu = { activate: function () { var _this = this; }, dropdownEffect: function (target) { var effectIn = $.axpertUI.options.dropdownMenu.effectIn, effectOut = $.axpertUI.options.dropdownMenu.effectOut; var dropdown = $(target), dropdownMenu = $('.dropdown-menu', target); if (dropdown.length > 0) { var udEffectIn = dropdown.data('effect-in'); var udEffectOut = dropdown.data('effect-out'); if (udEffectIn !== undefined) { effectIn = udEffectIn; } if (udEffectOut !== undefined) { effectOut = udEffectOut; } } return { target: target, dropdown: dropdown, dropdownMenu: dropdownMenu, effectIn: effectIn, effectOut: effectOut }; }, dropdownEffectStart: function (data, effectToStart) { if (effectToStart) { data.dropdown.addClass('dropdown-animating'); data.dropdownMenu.addClass('animated dropdown-animated'); data.dropdownMenu.addClass(effectToStart); } }, dropdownEffectEnd: function (data, callback) { var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend'; data.dropdown.one(animationEnd, function () { data.dropdown.removeClass('dropdown-animating'); data.dropdownMenu.removeClass('animated dropdown-animated'); data.dropdownMenu.removeClass(data.effectIn); data.dropdownMenu.removeClass(data.effectOut); if (typeof callback == 'function') { callback(); } }); } } tooltipsPopovers = { activate: function () { //Tooltip $('[data-toggle="tooltip"]').tooltip({ container: 'body' }); //Popover $('[data-toggle="popover"]').popover(); } } //========================================================================================================================== /* Browser - Function ====================================================================================================== * You can manage browser * */ browser = { activate: function (isHybrid) { var _this = this; _this.isHybrid = isHybrid; _this.browsers = { edge: 'Microsoft Edge', edgeLegacy: 'Microsoft Edge Legacy', ie10: 'Internet Explorer 10', ie11: 'Internet Explorer 11', opera: 'Opera', firefox: 'Mozilla Firefox', chrome: 'Google Chrome', safari: 'Safari', } var className = _this.getClassName(); if (className !== '') $('html').addClass(className); typeof isiOS && isiOS ? $("body").addClass("iOS") : ""; _this.isHybrid ? $("body").addClass("isHybrid") : ""; }, getBrowser: function () { var _this = this; var userAgent = navigator.userAgent.toLowerCase(); if (/edge/i.test(userAgent)) { return _this.browsers.edgeLegacy; } else if (/edg/i.test(userAgent)) { return _this.browsers.edge; } else if (/rv:11/i.test(userAgent)) { return _this.browsers.ie11; } else if (/msie 10/i.test(userAgent)) { return _this.browsers.ie10; } else if (/opr/i.test(userAgent)) { return _this.browsers.opera; } else if (/chrome/i.test(userAgent)) { return _this.browsers.chrome; } else if (/firefox/i.test(userAgent)) { return _this.browsers.firefox; } else if (!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)) { return _this.browsers.safari; } return undefined; }, getClassName: function () { var _this = this; var browser = this.getBrowser(); if (browser === _this.browsers.edge) { return 'edge'; } else if (browser === _this.browsers.edgeLegacy) { return 'edgeLegacy'; } else if (browser === _this.browsers.ie11) { return 'ie11'; } else if (browser === _this.browsers.ie10) { return 'ie10'; } else if (browser === _this.browsers.opera) { return 'opera'; } else if (browser === _this.browsers.chrome) { return 'chrome'; } else if (browser === _this.browsers.firefox) { return 'firefox'; } else if (browser === _this.browsers.safari) { return 'safari'; } else { return ''; } } } setUserOptions = { activate: function (options,compressedMode) { var _this = this; _this.options = options; _this.compressedMode=compressedMode; _this.initHeader(); _this.initProfile(); _this.initSettings(); _this.initUtilities(); }, initHeader: function () { var _this = this.options.settings.axUserOptions; var _thisStag = this.options.staging; if (_this.splitIcon) { $(_thisStag.splitIcon.div).attr("style", "display:" + _this.splitIcon.display); $(_thisStag.splitIcon.div).find("i:first").attr("title", _thisStag.splitIcon.title); $(_thisStag.splitIcon.div).find(_thisStag.splitIcon.options.horizontalSplit.div).attr("title", _thisStag.splitIcon.options.horizontalSplit.title).find("span").attr("title", _thisStag.splitIcon.options.horizontalSplit.title).text(_thisStag.splitIcon.options.horizontalSplit.title); $(_thisStag.splitIcon.div).find(_thisStag.splitIcon.options.verticalSplit.div).attr("title", _thisStag.splitIcon.options.verticalSplit.title).find("span").attr("title", _thisStag.splitIcon.options.verticalSplit.title).text(_thisStag.splitIcon.options.verticalSplit.title) $(_thisStag.splitIcon.div).find(_thisStag.splitIcon.options.clearSplit.div).attr("title", _thisStag.splitIcon.options.clearSplit.title).find("span").attr("title", _thisStag.splitIcon.options.clearSplit.title).text(_thisStag.splitIcon.options.clearSplit.title); } if (_this.compressedMode) { $(_thisStag.uiSelector.div).attr("style", "display:" + _this.compressedMode.display); $(_thisStag.uiSelector.div).find("i:first").attr("title", _thisStag.uiSelector.title); } $(_thisStag.optionsPanel.div).find("i:first").attr("title", _thisStag.optionsPanel.title); if (_this.LicInfo) { if(_this.LicInfo.display == "none"){ $(_thisStag.LicInfo.div).addClass("d-none"); }else{ $(_thisStag.LicInfo.div).removeClass("d-none"); } $(_thisStag.LicInfo.div).find(_thisStag.LicInfo.divClick).attr("onclick", _this.LicInfo.onclick); $(_thisStag.LicInfo.div).find(_thisStag.LicInfo.divTitle).attr("title", _this.LicInfo.title); } }, initProfile: function () { var _this = this.options.settings.axUserOptions; var _thisStag = this.options.staging; if (_this.AxNickName) { $(_thisStag.AxNickName.div).append("" + _this.AxNickName.NickName + ""); $(_thisStag.userProfile.div).find(_thisStag.userProfile.options.userName.icon).text(_this.AxNickName.NickName.trim().charAt(0).toUpperCase()); } if (_this.axAppName) { $(_thisStag.AxAppLogo.web.divParent).attr("onclick", _this.axAppName.onclick).attr("title",_this.axAppName.appName); $(_thisStag.AxAppLogo.mobile.divParent).attr("onclick", _this.axAppName.onclick).attr("title",_this.axAppName.appName); $(_thisStag.AxAppLogo.web.divParent).find(_thisStag.AxAppLogo.web.divTitle).text(_this.axAppName.appName).addClass(_thisStag.AxAppLogo.web.showTitle ? "" : "d-none"); $(_thisStag.AxAppLogo.mobile.divParent).find(_thisStag.AxAppLogo.mobile.divTitle).text(_this.axAppName.appName).addClass(_thisStag.AxAppLogo.mobile.showTitle ? "" : "d-none"); } if (_this.AxAppLogo){ $(_thisStag.AxAppLogo.web.divParent).find(_thisStag.AxAppLogo.web.div).attr("src", _this.AxAppLogo.imgSrc); $(_thisStag.AxAppLogo.mobile.divParent).find(_thisStag.AxAppLogo.mobile.div).attr("src", _this.AxAppLogo.imgSrc); } if (_this.AxUserEmail) { $(_thisStag.AxUserEmail.div).attr("style", "display:" + _this.AxUserEmail.display); $(_thisStag.AxUserEmail.div).append("" + _this.AxUserEmail.email + ""); } if (_thisStag.GlobalParams) { $(_thisStag.GlobalParams.div).attr("style", "display:" + _thisStag.GlobalParams.display); $(_thisStag.GlobalParams.div).find(_thisStag.GlobalParams.divClick).attr("title", _thisStag.GlobalParams.title); let gloParamsHTML = $(_thisStag.GlobalParams.divData).html().trim(); if(!gloParamsHTML){ gloParamsHTML = `edit`; } $(_thisStag.GlobalParams.div).find(_thisStag.GlobalParams.divTitle).html(gloParamsHTML); } if (_this.GlobalParamsonclick) $(_thisStag.GlobalParams.div).find(_thisStag.GlobalParams.divTitle).attr("onclick", _this.GlobalParamsonclick.onclick); if(_this.Refresh){ $(_thisStag.refreshMenu.div).attr("onclick", _this.Refresh.onclick); $(_thisStag.refreshMenu.div).find("a").attr("title", _thisStag.refreshMenu.title).text(_thisStag.refreshMenu.title); } if(_this.RefreshParams){ $(_thisStag.refreshVarParam.div).attr("onclick", _this.RefreshParams.onclick); $(_thisStag.refreshVarParam.div).find("a").attr("title", _thisStag.refreshVarParam.title).text(_thisStag.refreshVarParam.title); } if (_this.Logout){ $(_thisStag.Logout.div).find(_thisStag.Logout.divTitle).attr("onclick", _this.Logout.onclick).attr("title", _thisStag.Logout.title).text(_thisStag.Logout.title); } }, initSettings: function () { var _this = this.options.settings.axUserOptions; var _thisStag = this.options.staging; if (_this.About) { $(_thisStag.About.div).attr("onclick", _this.About.onclick); $(_thisStag.About.div).attr("title", _thisStag.About.title).find("a").text(_thisStag.About.title); } if(_this.Language){ if(_this.Language.options.split(",").length > 1){ let currentLoginLanguage = gllangauge; $(_thisStag.Language.div).attr("title", _thisStag.Language.title).find(_thisStag.Language.divTitle).text(_thisStag.Language.title); $(_thisStag.Language.div).find(_thisStag.Language.divOptions).html(` ${_this.Language.options.split(",").map(opt=>{ opt = opt.match(/[a-z]+/gi).map(function (word) { return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase() }).join(''); let isActive = opt.toLowerCase() == currentLoginLanguage.toLowerCase(); if(isActive){ $(_thisStag.Language.div).find(_thisStag.Language.badge).text(opt); } return ` ` }).join("")} `); }else{ $(_thisStag.Language.div).addClass("d-none"); } } if (_this.showLog) { $(_thisStag.showLog.div).attr("style", "display:" + _this.showLog.display); $(_thisStag.showLog.div).find(_thisStag.showLog.divClick).attr("onclick", _this.showLog.onclick); $(_thisStag.showLog.div).attr("title", _thisStag.showLog.title).find("span:first").text(_thisStag.showLog.title); } if (_this.traceValue) { if (_this.traceValue.traceVal == "True") { $(_thisStag.traceValue.div).find(_thisStag.traceValue.divControl).attr("checked", "checked"); $(_thisStag.traceValue.div).find(_thisStag.traceValue.divspan).attr("title", _thisStag.traceValue.title.on); } else { $(_thisStag.traceValue.div).find(_thisStag.traceValue.divControl).removeAttr("checked"); $(_thisStag.traceValue.div).find(_thisStag.traceValue.divspan).attr("title", _thisStag.traceValue.title.off); } $(_thisStag.traceValue.div).find(_thisStag.traceValue.divClick).attr("onclick", _this.traceValue.onclick); } if (_this.executionLog) { $(_thisStag.executionLog.div).attr("style", "display:" + _this.executionLog.display); $(_thisStag.executionLog.div).find(_thisStag.executionLog.divClick).attr("onclick", _this.executionLog.onclick); $(_thisStag.executionLog.div).find(_thisStag.showLog.divClick).attr("title", _thisStag.executionLog.title).text(_thisStag.executionLog.title); } if(_this.uiSelector){ $(_thisStag.uiSelector.div).attr("style", "display:" + _this.uiSelector.display); $(_thisStag.uiSelector.div).find(_thisStag.uiSelector.divClick).attr("onclick", _this.uiSelector.onclick); $(_thisStag.uiSelector.div).attr("title", _thisStag.uiSelector.title).find("span:first").text(_thisStag.uiSelector.title); } if (_this.modernUiValue) { if (this.compressedMode) { $(_thisStag.modernUiValue.div).find('input').prop("checked", true); $(_thisStag.modernUiValue.div).find(_thisStag.modernUiValue.divSpan).attr("title", _thisStag.modernUiValue.title.on); } else { $(_thisStag.modernUiValue.div).find('input').prop("checked", false); $(_thisStag.modernUiValue.div).find(_thisStag.modernUiValue.divSpan).attr("title", _thisStag.modernUiValue.title.off); } $(".setting-panel").css({ "height": "calc(100vh - " + Math.round($(".tab-content").offset().top) + "px", "overflow": "auto" }); $($(_thisStag.modernUiValue.div).find('input')).click(function(e){ if(!$(_thisStag.modernUiValue.div).find('input').is(":checked")) { $(_thisStag.modernUiValue.div).find(_thisStag.modernUiValue.divSpan).attr("title", _thisStag.modernUiValue.title.on); window[_this.modernUiValue.onclick](false); } else{ $(_thisStag.modernUiValue.div).find(_thisStag.modernUiValue.divSpan).attr("title", _thisStag.modernUiValue.title.off); window[_this.modernUiValue.onclick](true); } setTimeout(function(){ $(".setting-panel").css({ "height": "calc(100vh - " + Math.round($(".tab-content").offset().top) + "px", "overflow": "auto" }); }, 500); }) } if (_this.globalsettings) { $(_thisStag.globalsettings.div).attr("style", "display:" + _this.globalsettings.display); $(_thisStag.globalsettings.div).attr("onclick", _this.globalsettings.onclick); $(_thisStag.globalsettings.div).attr("title", _thisStag.globalsettings.title).find("span").text(_thisStag.globalsettings.title); } if(_thisStag.Adminconsole) { $(_thisStag.Adminconsole.div).attr("style", "display:" +_this.Adminconsole.display); $(_thisStag.Adminconsole.div).attr("onclick", _this.Adminconsole.onclick); $(_thisStag.Adminconsole.div).find(_thisStag.Adminconsole.title.div).attr("title", _thisStag.Adminconsole.title.title).text(_thisStag.Adminconsole.title.title); $(_thisStag.Adminconsole.div).find(_thisStag.Adminconsole.subTitle.div).attr("title", _thisStag.Adminconsole.subTitle.title).text(_thisStag.Adminconsole.subTitle.title); } if(_thisStag.developerworkbench) { $(_thisStag.developerworkbench.div).attr("style", "display:" +_this.developerworkbench.display); $(_thisStag.developerworkbench.div).attr("onclick", _this.developerworkbench.onclick); $(_thisStag.developerworkbench.div).find(_thisStag.developerworkbench.title.div).attr("title", _thisStag.developerworkbench.title.title).text(_thisStag.developerworkbench.title.title); $(_thisStag.developerworkbench.div).find(_thisStag.developerworkbench.subTitle.div).attr("title", _thisStag.developerworkbench.subTitle.title).text(_thisStag.developerworkbench.subTitle.title); } if (_this.AppConfig) { $(_thisStag.AppConfig.div).attr("style", "display:" + _this.AppConfig.display); $(_thisStag.AppConfig.div).attr("onclick", _this.AppConfig.onclick); $(_thisStag.AppConfig.div).attr("title", _thisStag.AppConfig.title).find("span").text(_thisStag.AppConfig.title); } if (_this.ChangePassword) { $(_thisStag.ChangePassword.div).attr("style", "display:" + _this.ChangePassword.display); $(_thisStag.ChangePassword.div).find(_thisStag.ChangePassword.divTitle).attr("onclick", _this.ChangePassword.onclick).attr("title", _thisStag.ChangePassword.title).text(_thisStag.ChangePassword.title); } if (_this.userManual) { $(_thisStag.userManual.div).attr("style", "display:" + _this.userManual.display); $(_thisStag.userManual.div).attr("onclick", _this.userManual.onclick); $(_thisStag.userManual.div).attr("title", _thisStag.userManual.title).find("span").text(_thisStag.userManual.title); } $(".setting-panel").css({ "height": "calc(100vh - " + Math.round($(".tab-content").offset().top) + "px", "overflow": "auto" }); }, initUtilities: function () { var _this = this.options.settings.axUserOptions; var _thisStag = this.options.staging; if (_this.qrCodeBtnWrapper) { $(_thisStag.qrCodeBtnWrapper.div).attr("style", "display:" + _this.qrCodeBtnWrapper.display); $(_thisStag.qrCodeBtnWrapper.div).find(_thisStag.qrCodeBtnWrapper.divTitle).attr("title", _thisStag.qrCodeBtnWrapper.title).text(_thisStag.qrCodeBtnWrapper.title); let qrDiv = $(_thisStag.qrCodeBtnWrapper.div).find(_thisStag.qrCodeBtnWrapper.divPlaceholder); try { if(qrDiv.length > 0){ var qrcode = new QRCode(qrDiv[0], { text: `{"spath":"${encodeURI(mainRestDllPath.slice(0, -1))}","pname":"${mainProject}","notify_URI":"${encodeURI(nodeApi.substr(0, nodeApi.length - 5))}","p_url":"${encodeURI(mainPageUrl = window.location.href.toLowerCase()) && (webUrl = mainPageUrl.substr(0, mainPageUrl.indexOf("/aspx")))}"}`, width: 250, height: 250, colorDark: "#000000", colorLight: "#ffffff", correctLevel: QRCode.CorrectLevel.H }); } } catch (ex) { } } if (_this.WidgetBuilder) { $(_thisStag.WidgetBuilder.div).attr("style", "display:" + _this.WidgetBuilder.display); $(_thisStag.WidgetBuilder.div).attr("onclick", _this.WidgetBuilder.onclick); $(_thisStag.WidgetBuilder.div).attr("title", _thisStag.WidgetBuilder.title).find("span").text(_thisStag.WidgetBuilder.title); } if (_this.pageBuilderBtn) { $(_thisStag.pageBuilderBtn.div).attr("style", "display:" + _this.pageBuilderBtn.display); $(_thisStag.pageBuilderBtn.div).attr("onclick", _this.pageBuilderBtn.onclick); $(_thisStag.pageBuilderBtn.div).attr("title", _thisStag.pageBuilderBtn.title).find("span").text(_thisStag.pageBuilderBtn.title); } if (_this.Dashboard) { $(_thisStag.Dashboard.div).attr("style", "display:" + _this.Dashboard.display); $(_thisStag.Dashboard.div).attr("onclick", _this.Dashboard.onclick); $(_thisStag.Dashboard.div).attr("title", _thisStag.Dashboard.title).find("span").text(_thisStag.Dashboard.title); } if (_this.Responsibilities) { $(_thisStag.Responsibilities.div).attr("style", "display:" + _this.Responsibilities.display); $(_thisStag.Responsibilities.div).attr("onclick", _this.Responsibilities.onclick); $(_thisStag.Responsibilities.div).attr("title", _thisStag.Responsibilities.title).find("span").text(_thisStag.Responsibilities.title); } if (_this.ExportData) { $(_thisStag.ExportData.div).attr("style", "display:" + _this.ExportData.display); $(_thisStag.ExportData.div).attr("onclick", _this.ExportData.onclick); $(_thisStag.ExportData.div).find(_thisStag.ExportData.title.div).attr("title", _thisStag.ExportData.title.title).text(_thisStag.ExportData.title.title); $(_thisStag.ExportData.div).find(_thisStag.ExportData.subTitle.div).attr("title", _thisStag.ExportData.subTitle.title).text(_thisStag.ExportData.subTitle.title); } if (_this.ImportData) { $(_thisStag.ImportData.div).attr("style", "display:" + _this.ImportData.display); $(_thisStag.ImportData.div).attr("onclick", _this.ImportData.onclick); $(_thisStag.ImportData.div).find(_thisStag.ImportData.title.div).attr("title", _thisStag.ImportData.title.title).text(_thisStag.ImportData.title.title); $(_thisStag.ImportData.div).find(_thisStag.ImportData.subTitle.div).attr("title", _thisStag.ImportData.subTitle.title).text(_thisStag.ImportData.subTitle.title); } if (_this.ImportHistory) { $(_thisStag.ImportHistory.div).attr("style", "display:" + _this.ImportHistory.display); $(_thisStag.ImportHistory.div).attr("onclick", _this.ImportHistory.onclick); $(_thisStag.ImportHistory.div).attr("title", _thisStag.ImportHistory.title).find("span").text(_thisStag.ImportHistory.title); } if (_this.WorkFlow) { $(_thisStag.WorkFlow.div).attr("style", "display:" + _this.WorkFlow.display); $(_thisStag.WorkFlow.div).attr("onclick", _this.WorkFlow.onclick); $(_thisStag.WorkFlow.div).attr("title", _thisStag.WorkFlow.title).find("span").text(_thisStag.WorkFlow.title); } } } init = function (initOptions) { this.options = $.extend(true, {}, this.options, initOptions); if (!this.options.dirLeft) { $(".navbar-right").removeClass("navbar-right").addClass("navbar-left"); $(".pull-right:not(.dropdown-menu)").removeClass("pull-right").addClass("pull-left"); $("[data-placement=right").attr("data-placement", "left"); } browser.activate(this.options.isHybrid); setUserOptions.activate(this.options.axpertUserSettings,this.options.compressedMode); leftSideBar.activate(this.options.leftSideBar, this.options.isMobile); rightSideBar.activate(this.options.rightSideBar); cardsPage.activate(this.options.cardsPage); notificationbar.activate(this.options.notificationbar); navbar.activate(); dropdownMenu.activate(); input.activate(); select.activate(); search.activate(this.options.search); tooltipsPopovers.activate(); $(this.options.navigation.backButton.div).hide(); setTimeout(() => { $(this.options.loader.div).addClass(this.options.loader.outAnimationClass); setTimeout(() => { $(this.options.loader.textDiv).addClass("d-none"); $(this.options.loader.parent).removeClass(this.options.loader.parent.substr(1)).removeClass(this.options.loader.stayClass); $(this.options.loader.div).removeClass(this.options.loader.outAnimationClass).addClass(this.options.loader.radialGradientClass); $(this.options.loader.subDiv).addClass(this.options.loader.loaderWrapClass); }, 0); }, 50); return this.options; } //========================================================================================================================== return { options, leftSideBar, rightSideBar, cardsPage, notificationbar, search, navbar, input, select, dropdownMenu, browser, init } } $.axpertUI = new axpertUI(); })(jQuery, window); $(function () { if (window.location.href.indexOf(".html") > -1) { $.axpertUI.init({ leftSideBar: { menuConfiguration: { menuJson: menuJsonData, staging: { div: "#leftsidebar .menu ul.list" }, menuTemplete: { } } } }); } });