Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function setProdDetail(data, SelProduct, CurrentLine, rerenderButtons) {
- _currentColour = data.PRD_COLOUR.replace('/', '_');
- var colorId = 'img' + _currentColour;
- oCarousel.setActivePage(colorId);
- var colorHId = 'box' + _currentColour;
- PortraitCarousel.setActivePage(colorHId);
- var imgIdA = 'imgPA' + _currentColour;
- var imgIdB = 'imgPB' + _currentColour;
- var imgId = 'img' + _currentColour;
- if (typeof(Hammer) !== 'undefined' && typeof(hammerIt) === 'function') {
- if (document.getElementById(imgIdA) !== null && document.getElementById(imgIdA).src.indexOf('neptune') === -1) {
- hammerInitialize(document.getElementById(imgIdA));
- } else if (document.getElementById(imgIdA) !== null && document.getElementById(imgIdA).src.indexOf('neptune') !== -1) {
- hammerInitializeError(document.getElementById(imgIdA));
- }
- if (document.getElementById(imgIdB) !== null && document.getElementById(imgIdB).src.indexOf('neptune') === -1) {
- hammerInitialize(document.getElementById(imgIdB));
- } else if (document.getElementById(imgIdB) !== null && document.getElementById(imgIdB).src.indexOf('neptune') !== -1) {
- hammerInitializeError(document.getElementById(imgIdB));
- }
- hammerIt(document.getElementById(imgId));
- }
- setTimeout(function() {
- $('#CustomBox' + _currentColour.replace('/', '_')).addClass('productSelected');
- }, 350);
- if (data.LENS_PROPERTIES_TEXT !== '') {
- LensPropertiesInput.setValue(sap.n.Apps.ZNEPT_SFA_LAUNCHPAD_MENU_43.camelize(data.LENS_PROPERTIES_TEXT));
- } else {
- LensPropertiesInput.setValue('N/A');
- }
- if (data.LENS_MATERIAL_TEXT !== '') {
- LensMaterialInput.setValue(sap.n.Apps.ZNEPT_SFA_LAUNCHPAD_MENU_43.camelize(data.LENS_MATERIAL_TEXT));
- } else {
- LensMaterialInput.setValue('N/A');
- }
- ProdNameInput.setValue(sap.n.Apps.ZNEPT_SFA_LAUNCHPAD_MENU_43.camelize(data.NAME));
- ProdIdInput.setValue(data.PRD_COLOUR);
- //CHANGES WISHLIST
- var wish = modelWishlist.getData();
- $('#' + sap.n.currentView.sId + '--WishlistButton').addClass('wishlistClass').removeClass('wishlistClassSelected');
- WishlistButton.setIcon('sap-icon://unfavorite');
- for (var y = 0; y < wish.length; y++) {
- if (wish[y].PRODUCT === data.PRODUCT &&
- (wish[y].PRD_COLOUR === data.PRD_COLOUR.replace('/', '_') || wish[y].PRD_COLOUR === data.PRD_COLOUR)) {
- $('#' + sap.n.currentView.sId + '--WishlistButton').removeClass('wishlistClass').addClass('wishlistClassSelected');
- WishlistButton.setIcon('sap-icon://favorite');
- }
- }
- //EOC
- //START CHANGES
- if (rerenderButtons === true) {
- ProductTechVBox.removeAllItems();
- var sizeLength = modeltabX.getData().length;
- $.each(modeltabX.oData, function(i, data) {
- // var colMatrixX = new sap.m.Column({
- // hAlign: "Center",
- // width: "60px"
- // });
- // tabMatrix.addColumn(colMatrixX);
- var colorReplaced = _currentColour.replace('/', '_');
- var productReplaced = modeloPageMatrix.getData().PRODUCT.replace(' ', '_');
- var keyMinus = 'M' + productReplaced + colorReplaced + '_' + data;
- var keyPlus = 'P' + productReplaced + colorReplaced + '_' + data;
- var keyQty = 'Q' + productReplaced + colorReplaced + '_' + data;
- var keyModel = keyQty.replace('Q', 'K');
- var found = true;
- var recs = ModelData.Find(ProductMatrixFiltList, "KEY", keyModel);
- var sizeBoxX = new sap.m.HBox("sizeBox" + i, {
- backgroundDesign: "Transparent",
- displayInline: false,
- fitContainer: false,
- height: "3.8em",
- justifyContent: "SpaceBetween",
- });
- if (recs.length === 0) {
- sizeBoxX.addStyleClass('opacityBoxSize');
- found = false;
- }
- if (i !== 0) {
- sizeBoxX.addStyleClass('negativeMargin');
- }
- ProductTechVBox.addItem(sizeBoxX);
- var sizeButtonHBoxX = new sap.m.HBox({
- alignContent: "Stretch",
- backgroundDesign: "Transparent",
- displayInline: true,
- fitContainer: false,
- });
- sizeBoxX.addItem(sizeButtonHBoxX);
- ////////
- var sizeMinusButtonX = new sap.m.Button(keyMinus, {
- // text: "-"
- icon: 'sap-icon://less',
- type: "Default",
- press: function(event) {
- butMinus.firePress();
- var replace = this.sId.replace('M', 'K');
- if (typeof(sap.ui.getCore().byId(replace)) !== 'undefined') {
- sap.ui.getCore().byId(replace).firePress();
- }
- }
- });
- sizeButtonHBoxX.addItem(sizeMinusButtonX);
- //ES
- var allInBox = new sap.m.VBox({
- alignContent: "Stretch",
- backgroundDesign: "Transparent",
- displayInline: false,
- fitContainer: false,
- visible: true
- });
- sizeButtonHBoxX.addItem(allInBox);
- // sizeBoxX.addItem(sizeTextX);
- if (found) {
- var sizeNumButtonX = new sap.m.Button(keyQty, {
- text: "0",
- type: "Transparent",
- });
- } else {
- var sizeNumButtonX = new sap.m.Button(keyQty, {
- text: '',
- type: "Transparent",
- });
- sizeNumButtonX.addStyleClass('borderDisabledButton');
- }
- allInBox.addItem(sizeNumButtonX);
- var replacedKey = keyQty.replace('Q', 'K');
- if (typeof(sap.ui.getCore().byId(replacedKey)) !== 'undefined') {
- sizeNumButtonX.setText(sap.ui.getCore().byId(replacedKey).getText());
- }
- // sizeButtonHBoxX.addItem(sizeNumButtonX);
- var sizeTextX = new sap.m.Text({
- text: 'Size ' + data,
- textAlign: 'Center',
- visible: true,
- });
- sizeTextX.addStyleClass("sizeFirstText");
- allInBox.addItem(sizeTextX);
- var sizePlusButtonX = new sap.m.Button(keyPlus, {
- // text: "+",
- icon: 'sap-icon://add',
- type: "Emphasized",
- press: function(event) {
- butPlus.firePress();
- var replace = this.sId.replace('P', 'K');
- if (typeof(sap.ui.getCore().byId(replace)) !== 'undefined') {
- sap.ui.getCore().byId(replace).firePress();
- }
- }
- });
- sizeButtonHBoxX.addItem(sizePlusButtonX);
- if (found && recs[0].IDEAL_ASSORT) {
- var idealIconSize = new sap.ui.core.Icon('idealIconSize' + i, {
- src: 'sap-icon://c-icon/handOK',
- });
- idealIconSize.addStyleClass('iconIdeal');
- sizeButtonHBoxX.addItem(idealIconSize);
- }
- if (i !== sizeLength - 1) {
- var sizeDivideHBox = new sap.m.HBox({
- alignContent: "Stretch",
- backgroundDesign: "Transparent",
- displayInline: false,
- fitContainer: false,
- });
- sizeDivideHBox.addStyleClass('lineSizeHBox');
- ProductTechVBox.addItem(sizeDivideHBox);
- } else {
- sizeBoxX.addStyleClass('lastSizePopover');
- }
- });
- }
- }
- function switchFromOpticalToGridView() {
- debugger;
- //Tracking Improvements
- var trkSWTStart = Date.now();
- var trkSWTEnd = '';
- var trkSWTElapsed = '';
- var trkDevInfo = 'Type:' + AppCache.deviceType + ' UID:' + device.uuid;
- var trkSeparator = '_';
- var trkPrevPage = App.getCurrentPage().sId;
- //Tracking Improvements end
- MatrixHeaderBar.setVisible(true);
- FooterMatrixBar.setVisible(true);
- oScrollContainer.setVisible(true);
- if (typeof(_log) === 'undefined' || _log.length === 0 || _navigationToAcx) {
- MatrixUpButton.setVisible(false);
- MatrixDownButton.setVisible(false);
- GridRfidBtn.setVisible(false);
- if (_fromUpc) {
- OpticalViewButton.setVisible(true);
- if (typeof(cordova) !== 'undefined') {
- GridRfidBtn.setVisible(true);
- }
- } else {
- OpticalViewButton.setVisible(false);
- }
- } else {
- MatrixUpButton.setVisible(true);
- MatrixDownButton.setVisible(true);
- if (typeof(cordova) !== 'undefined') {
- GridRfidBtn.setVisible(true);
- }
- OpticalViewButton.setVisible(true);
- }
- butClearAll.setVisible(true);
- POPbutClearAll.setVisible(false);
- AvailLegendButton.setVisible(true);
- butMinus.setPressed(false);
- butPlus.setPressed(true);
- BusyAvlButton.setVisible(false);
- butCheck.setVisible(true);
- if (_isAccessory) {
- butInfo.setVisible(false);
- butInfoAcx.setVisible(true);
- } else {
- butInfo.setVisible(true);
- butInfoAcx.setVisible(false);
- }
- ProductNameBox.setVisible(false);
- ProductHBox.setVisible(false);
- GridLine1HBox.setVisible(false);
- var headerCont = sap.ui.getCore().byId("Header");
- if (typeof(headerCont) !== 'undefined') {
- headerCont.setVisible(false);
- }
- setTimeout(function() {
- rerenderWishlistGrid();
- sortByWishList();
- //Tracking Improvements & fix
- if (trkPrevPage.indexOf(sap.n.getObjectByID("oPageMatrix").sId) === 0) {
- trkSWTEnd = Date.now();
- trkSWTElapsed = (trkSWTEnd - trkSWTStart) / 1000;
- getOnlineChangeViewDToTradLogAjax(trkDevInfo + trkSeparator + trkSWTElapsed);
- }
- //Tracking Improvements end
- }, 200);
- }
- function switchFromGridToOpticalView() {
- //Tracking Improvements
- var trkSWTStart = Date.now();
- var trkSWTEnd = '';
- var trkSWTElapsed = '';
- var trkSeparator = '_';
- var trkDevInfo = 'Type:' + AppCache.deviceType + ' UID:' + device.uuid;
- var trkPrevPage = App.getCurrentPage().sId;
- //Tracking Improvements end
- MatrixHeaderBar.setVisible(false);
- FooterMatrixBar.setVisible(false);
- oScrollContainer.setVisible(false);
- MatrixUpButton.setVisible(false);
- MatrixDownButton.setVisible(false);
- GridRfidBtn.setVisible(false);
- OpticalViewButton.setVisible(false);
- ProductNameBox.setVisible(true);
- GridLine1HBox.setVisible(true);
- /////ES
- setTimeout(function() {
- var imgIdA = 'imgPA' + _currentColour;
- var imgIdB = 'imgPB' + _currentColour;
- var imgId = 'img' + _currentColour;
- if (typeof(Hammer) !== 'undefined' && typeof(hammerIt) === 'function') {
- if (document.getElementById(imgIdA) !== null && document.getElementById(imgIdA).src.indexOf('neptune') === -1) {
- if (typeof(Hammer) !== 'undefined' && typeof(hammerInitialize) === 'function') {
- hammerInitialize(document.getElementById(imgIdA));
- }
- }
- if (document.getElementById(imgIdB) !== null && document.getElementById(imgIdB).src.indexOf('neptune') === -1) {
- if (typeof(Hammer) !== 'undefined' && typeof(hammerInitialize) === 'function') {
- hammerInitialize(document.getElementById(imgIdB));
- }
- }
- hammerIt(document.getElementById(imgId));
- }
- }, 0);
- /////ES
- var headerCont = sap.ui.getCore().byId("Header");
- if (typeof(headerCont) !== 'undefined') {
- headerCont.setVisible(true);
- ProductHBox.setVisible(true);
- if (sap.ui.Device.orientation.landscape) {
- setTimeout(function() {
- setClassesOrientationDetailPage('landscape');
- rerenderWishlistCarousel();
- //Tracking Improvements & fix
- if (trkPrevPage.indexOf(sap.n.getObjectByID("oPageMatrix").sId) === 0 && _fromUpc === false) {
- trkSWTEnd = Date.now();
- trkSWTElapsed = (trkSWTEnd - trkSWTStart) / 1000;
- getOnlineChangeViewTradToDLogAjax(trkDevInfo + trkSeparator + trkSWTElapsed);
- }
- //Tracking Improvements & fix end
- }, 100);
- } else {
- setTimeout(function() {
- setClassesOrientationDetailPage('portrait');
- rerenderWishlistCarousel();
- //Tracking Improvements & fix
- if (App.getPreviousPage().sId.indexOf(sap.n.getObjectByID("oPageMatrix").sId) === 0 && _fromUpc === false) {
- trkSWTEnd = Date.now();
- trkSWTElapsed = (trkSWTEnd - trkSWTStart) / 1000;
- getOnlineChangeViewTradToDLogAjax(trkDevInfo + trkSeparator + trkSWTElapsed);
- }
- //Tracking Improvements & fix end
- }, 100);
- }
- }
- }
- function rerenderWishlistCarousel() {
- var wish = modelWishlist.getData();
- var colours = modelProductGridList.getData();
- for (var n = 0; n < colours.length; n++) {
- $('#WishIconsHBox' + colours[n].PRD_COLOUR.replace('/', '_')).hide();
- for (var y = 0; y < wish.length; y++) {
- if (wish[y].PRODUCT === colours[n].PRODUCT && wish[y].PRD_COLOUR.replace('/', '_') === colours[n].PRD_COLOUR.replace('/', '_')) {
- $('#WishIconsHBox' + colours[n].PRD_COLOUR.replace('/', '_')).show();
- }
- }
- }
- }
- function rerenderWishlistGrid() {
- var wish = modelWishlist.getData();
- var colours = modelProductGridList.getData();
- for (var n = 0; n < colours.length; n++) {
- $('#WishlistIconGrid' + colours[n].PRD_COLOUR.replace('/', '_')).hide();
- for (var y = 0; y < wish.length; y++) {
- if (wish[y].PRODUCT === colours[n].PRODUCT && wish[y].PRD_COLOUR.replace('/', '_') === colours[n].PRD_COLOUR.replace('/', '_')) {
- $('#WishlistIconGrid' + colours[n].PRD_COLOUR.replace('/', '_')).show();
- }
- }
- }
- }
- function sortByWishList() {
- var wish = modelWishlist.getData();
- if (wish.length === 0 || wish.length === undefined) {
- return;
- }
- var coloursList = JSON.parse(JSON.stringify(modelProductGridList.getData()));
- //MARK WISHLIST PRODUCTS @coloursList
- for (var o = 0; o < wish.length; o++) {
- var found = false;
- for (var l = 0; l < coloursList.length && found === false; l++) {
- if (wish[o].PRODUCT === coloursList[l].PRODUCT &&
- wish[o].PRD_COLOUR.replace('/', '_') === coloursList[l].PRD_COLOUR.replace('/', '_')) {
- coloursList[l].WISHLIST = true;
- found = true;
- }
- }
- }
- coloursList.sort(function(a, b) {
- if ((!(a.WISHLIST) && !(b.WISHLIST)) || (a.WISHLIST && b.WISHLIST)) {
- return a.PRD_COLOUR.localeCompare(b.PRD_COLOUR);
- } else {
- if (a.WISHLIST) {
- return -1;
- } else {
- return 1;
- }
- }
- });
- //APPEND DOM IN ORDER
- var elements = $();
- elements = elements.add($('#MatrixButtonsRow_1').get());
- elements = elements.add($('#MatrixButtonsRow_2').get());
- for (var b = 0; b < coloursList.length; b++) {
- if (coloursList[b].WISHLIST) {
- elements = elements.add($('#itemMatrix' + coloursList[b].PRD_COLOUR.replace('/', '_')).get())
- // $('#tabMatrix-tblBody').prepend($('#itemMatrix' + coloursList[b].PRD_COLOUR.replace('/', '_')).get());
- }
- }
- $('#tabMatrix-tblBody').prepend(elements);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement