Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.17 KB | None | 0 0
  1. function setProdDetail(data, SelProduct, CurrentLine, rerenderButtons) {
  2.  
  3. _currentColour = data.PRD_COLOUR.replace('/', '_');
  4. var colorId = 'img' + _currentColour;
  5. oCarousel.setActivePage(colorId);
  6. var colorHId = 'box' + _currentColour;
  7.  
  8. PortraitCarousel.setActivePage(colorHId);
  9.  
  10. var imgIdA = 'imgPA' + _currentColour;
  11. var imgIdB = 'imgPB' + _currentColour;
  12. var imgId = 'img' + _currentColour;
  13.  
  14. if (typeof(Hammer) !== 'undefined' && typeof(hammerIt) === 'function') {
  15. if (document.getElementById(imgIdA) !== null && document.getElementById(imgIdA).src.indexOf('neptune') === -1) {
  16. hammerInitialize(document.getElementById(imgIdA));
  17. } else if (document.getElementById(imgIdA) !== null && document.getElementById(imgIdA).src.indexOf('neptune') !== -1) {
  18. hammerInitializeError(document.getElementById(imgIdA));
  19. }
  20. if (document.getElementById(imgIdB) !== null && document.getElementById(imgIdB).src.indexOf('neptune') === -1) {
  21. hammerInitialize(document.getElementById(imgIdB));
  22. } else if (document.getElementById(imgIdB) !== null && document.getElementById(imgIdB).src.indexOf('neptune') !== -1) {
  23. hammerInitializeError(document.getElementById(imgIdB));
  24. }
  25.  
  26. hammerIt(document.getElementById(imgId));
  27. }
  28. setTimeout(function() {
  29. $('#CustomBox' + _currentColour.replace('/', '_')).addClass('productSelected');
  30. }, 350);
  31.  
  32. if (data.LENS_PROPERTIES_TEXT !== '') {
  33. LensPropertiesInput.setValue(sap.n.Apps.ZNEPT_SFA_LAUNCHPAD_MENU_43.camelize(data.LENS_PROPERTIES_TEXT));
  34. } else {
  35. LensPropertiesInput.setValue('N/A');
  36. }
  37. if (data.LENS_MATERIAL_TEXT !== '') {
  38. LensMaterialInput.setValue(sap.n.Apps.ZNEPT_SFA_LAUNCHPAD_MENU_43.camelize(data.LENS_MATERIAL_TEXT));
  39. } else {
  40. LensMaterialInput.setValue('N/A');
  41. }
  42.  
  43. ProdNameInput.setValue(sap.n.Apps.ZNEPT_SFA_LAUNCHPAD_MENU_43.camelize(data.NAME));
  44. ProdIdInput.setValue(data.PRD_COLOUR);
  45.  
  46. //CHANGES WISHLIST
  47. var wish = modelWishlist.getData();
  48. $('#' + sap.n.currentView.sId + '--WishlistButton').addClass('wishlistClass').removeClass('wishlistClassSelected');
  49. WishlistButton.setIcon('sap-icon://unfavorite');
  50. for (var y = 0; y < wish.length; y++) {
  51. if (wish[y].PRODUCT === data.PRODUCT &&
  52. (wish[y].PRD_COLOUR === data.PRD_COLOUR.replace('/', '_') || wish[y].PRD_COLOUR === data.PRD_COLOUR)) {
  53. $('#' + sap.n.currentView.sId + '--WishlistButton').removeClass('wishlistClass').addClass('wishlistClassSelected');
  54. WishlistButton.setIcon('sap-icon://favorite');
  55. }
  56. }
  57. //EOC
  58.  
  59. //START CHANGES
  60. if (rerenderButtons === true) {
  61. ProductTechVBox.removeAllItems();
  62. var sizeLength = modeltabX.getData().length;
  63.  
  64. $.each(modeltabX.oData, function(i, data) {
  65. // var colMatrixX = new sap.m.Column({
  66. // hAlign: "Center",
  67. // width: "60px"
  68. // });
  69. // tabMatrix.addColumn(colMatrixX);
  70. var colorReplaced = _currentColour.replace('/', '_');
  71. var productReplaced = modeloPageMatrix.getData().PRODUCT.replace(' ', '_');
  72. var keyMinus = 'M' + productReplaced + colorReplaced + '_' + data;
  73. var keyPlus = 'P' + productReplaced + colorReplaced + '_' + data;
  74. var keyQty = 'Q' + productReplaced + colorReplaced + '_' + data;
  75. var keyModel = keyQty.replace('Q', 'K');
  76. var found = true;
  77. var recs = ModelData.Find(ProductMatrixFiltList, "KEY", keyModel);
  78.  
  79. var sizeBoxX = new sap.m.HBox("sizeBox" + i, {
  80. backgroundDesign: "Transparent",
  81. displayInline: false,
  82. fitContainer: false,
  83. height: "3.8em",
  84. justifyContent: "SpaceBetween",
  85. });
  86. if (recs.length === 0) {
  87. sizeBoxX.addStyleClass('opacityBoxSize');
  88. found = false;
  89. }
  90. if (i !== 0) {
  91. sizeBoxX.addStyleClass('negativeMargin');
  92. }
  93. ProductTechVBox.addItem(sizeBoxX);
  94.  
  95.  
  96.  
  97. var sizeButtonHBoxX = new sap.m.HBox({
  98. alignContent: "Stretch",
  99. backgroundDesign: "Transparent",
  100. displayInline: true,
  101. fitContainer: false,
  102. });
  103. sizeBoxX.addItem(sizeButtonHBoxX);
  104.  
  105.  
  106.  
  107. ////////
  108.  
  109. var sizeMinusButtonX = new sap.m.Button(keyMinus, {
  110. // text: "-"
  111. icon: 'sap-icon://less',
  112. type: "Default",
  113. press: function(event) {
  114. butMinus.firePress();
  115. var replace = this.sId.replace('M', 'K');
  116. if (typeof(sap.ui.getCore().byId(replace)) !== 'undefined') {
  117. sap.ui.getCore().byId(replace).firePress();
  118. }
  119.  
  120. }
  121. });
  122. sizeButtonHBoxX.addItem(sizeMinusButtonX);
  123.  
  124.  
  125.  
  126. //ES
  127. var allInBox = new sap.m.VBox({
  128. alignContent: "Stretch",
  129. backgroundDesign: "Transparent",
  130. displayInline: false,
  131. fitContainer: false,
  132. visible: true
  133. });
  134. sizeButtonHBoxX.addItem(allInBox);
  135.  
  136.  
  137.  
  138. // sizeBoxX.addItem(sizeTextX);
  139. if (found) {
  140. var sizeNumButtonX = new sap.m.Button(keyQty, {
  141. text: "0",
  142. type: "Transparent",
  143. });
  144. } else {
  145. var sizeNumButtonX = new sap.m.Button(keyQty, {
  146. text: '',
  147. type: "Transparent",
  148. });
  149.  
  150. sizeNumButtonX.addStyleClass('borderDisabledButton');
  151.  
  152. }
  153. allInBox.addItem(sizeNumButtonX);
  154. var replacedKey = keyQty.replace('Q', 'K');
  155.  
  156. if (typeof(sap.ui.getCore().byId(replacedKey)) !== 'undefined') {
  157. sizeNumButtonX.setText(sap.ui.getCore().byId(replacedKey).getText());
  158. }
  159. // sizeButtonHBoxX.addItem(sizeNumButtonX);
  160.  
  161. var sizeTextX = new sap.m.Text({
  162. text: 'Size ' + data,
  163. textAlign: 'Center',
  164. visible: true,
  165. });
  166. sizeTextX.addStyleClass("sizeFirstText");
  167. allInBox.addItem(sizeTextX);
  168.  
  169. var sizePlusButtonX = new sap.m.Button(keyPlus, {
  170. // text: "+",
  171. icon: 'sap-icon://add',
  172. type: "Emphasized",
  173. press: function(event) {
  174. butPlus.firePress();
  175. var replace = this.sId.replace('P', 'K');
  176. if (typeof(sap.ui.getCore().byId(replace)) !== 'undefined') {
  177. sap.ui.getCore().byId(replace).firePress();
  178. }
  179. }
  180. });
  181. sizeButtonHBoxX.addItem(sizePlusButtonX);
  182.  
  183. if (found && recs[0].IDEAL_ASSORT) {
  184. var idealIconSize = new sap.ui.core.Icon('idealIconSize' + i, {
  185. src: 'sap-icon://c-icon/handOK',
  186. });
  187. idealIconSize.addStyleClass('iconIdeal');
  188. sizeButtonHBoxX.addItem(idealIconSize);
  189. }
  190.  
  191. if (i !== sizeLength - 1) {
  192. var sizeDivideHBox = new sap.m.HBox({
  193. alignContent: "Stretch",
  194. backgroundDesign: "Transparent",
  195. displayInline: false,
  196. fitContainer: false,
  197. });
  198. sizeDivideHBox.addStyleClass('lineSizeHBox');
  199. ProductTechVBox.addItem(sizeDivideHBox);
  200. } else {
  201. sizeBoxX.addStyleClass('lastSizePopover');
  202. }
  203.  
  204. });
  205.  
  206. }
  207. }
  208.  
  209. function switchFromOpticalToGridView() {
  210. debugger;
  211. //Tracking Improvements
  212. var trkSWTStart = Date.now();
  213. var trkSWTEnd = '';
  214. var trkSWTElapsed = '';
  215. var trkDevInfo = 'Type:' + AppCache.deviceType + ' UID:' + device.uuid;
  216. var trkSeparator = '_';
  217. var trkPrevPage = App.getCurrentPage().sId;
  218. //Tracking Improvements end
  219. MatrixHeaderBar.setVisible(true);
  220. FooterMatrixBar.setVisible(true);
  221. oScrollContainer.setVisible(true);
  222.  
  223. if (typeof(_log) === 'undefined' || _log.length === 0 || _navigationToAcx) {
  224. MatrixUpButton.setVisible(false);
  225. MatrixDownButton.setVisible(false);
  226. GridRfidBtn.setVisible(false);
  227. if (_fromUpc) {
  228. OpticalViewButton.setVisible(true);
  229. if (typeof(cordova) !== 'undefined') {
  230. GridRfidBtn.setVisible(true);
  231. }
  232. } else {
  233. OpticalViewButton.setVisible(false);
  234. }
  235.  
  236. } else {
  237. MatrixUpButton.setVisible(true);
  238. MatrixDownButton.setVisible(true);
  239. if (typeof(cordova) !== 'undefined') {
  240. GridRfidBtn.setVisible(true);
  241. }
  242. OpticalViewButton.setVisible(true);
  243. }
  244. butClearAll.setVisible(true);
  245. POPbutClearAll.setVisible(false);
  246.  
  247. AvailLegendButton.setVisible(true);
  248. butMinus.setPressed(false);
  249. butPlus.setPressed(true);
  250. BusyAvlButton.setVisible(false);
  251. butCheck.setVisible(true);
  252. if (_isAccessory) {
  253. butInfo.setVisible(false);
  254. butInfoAcx.setVisible(true);
  255. } else {
  256. butInfo.setVisible(true);
  257. butInfoAcx.setVisible(false);
  258. }
  259.  
  260. ProductNameBox.setVisible(false);
  261. ProductHBox.setVisible(false);
  262. GridLine1HBox.setVisible(false);
  263.  
  264. var headerCont = sap.ui.getCore().byId("Header");
  265. if (typeof(headerCont) !== 'undefined') {
  266. headerCont.setVisible(false);
  267. }
  268. setTimeout(function() {
  269. rerenderWishlistGrid();
  270. sortByWishList();
  271. //Tracking Improvements & fix
  272. if (trkPrevPage.indexOf(sap.n.getObjectByID("oPageMatrix").sId) === 0) {
  273. trkSWTEnd = Date.now();
  274. trkSWTElapsed = (trkSWTEnd - trkSWTStart) / 1000;
  275. getOnlineChangeViewDToTradLogAjax(trkDevInfo + trkSeparator + trkSWTElapsed);
  276. }
  277. //Tracking Improvements end
  278. }, 200);
  279. }
  280.  
  281.  
  282. function switchFromGridToOpticalView() {
  283. //Tracking Improvements
  284. var trkSWTStart = Date.now();
  285. var trkSWTEnd = '';
  286. var trkSWTElapsed = '';
  287. var trkSeparator = '_';
  288. var trkDevInfo = 'Type:' + AppCache.deviceType + ' UID:' + device.uuid;
  289. var trkPrevPage = App.getCurrentPage().sId;
  290. //Tracking Improvements end
  291. MatrixHeaderBar.setVisible(false);
  292. FooterMatrixBar.setVisible(false);
  293. oScrollContainer.setVisible(false);
  294.  
  295. MatrixUpButton.setVisible(false);
  296. MatrixDownButton.setVisible(false);
  297. GridRfidBtn.setVisible(false);
  298. OpticalViewButton.setVisible(false);
  299.  
  300. ProductNameBox.setVisible(true);
  301.  
  302. GridLine1HBox.setVisible(true);
  303.  
  304. /////ES
  305. setTimeout(function() {
  306. var imgIdA = 'imgPA' + _currentColour;
  307. var imgIdB = 'imgPB' + _currentColour;
  308. var imgId = 'img' + _currentColour;
  309.  
  310. if (typeof(Hammer) !== 'undefined' && typeof(hammerIt) === 'function') {
  311. if (document.getElementById(imgIdA) !== null && document.getElementById(imgIdA).src.indexOf('neptune') === -1) {
  312. if (typeof(Hammer) !== 'undefined' && typeof(hammerInitialize) === 'function') {
  313. hammerInitialize(document.getElementById(imgIdA));
  314. }
  315. }
  316. if (document.getElementById(imgIdB) !== null && document.getElementById(imgIdB).src.indexOf('neptune') === -1) {
  317. if (typeof(Hammer) !== 'undefined' && typeof(hammerInitialize) === 'function') {
  318. hammerInitialize(document.getElementById(imgIdB));
  319. }
  320. }
  321.  
  322. hammerIt(document.getElementById(imgId));
  323. }
  324.  
  325. }, 0);
  326. /////ES
  327. var headerCont = sap.ui.getCore().byId("Header");
  328. if (typeof(headerCont) !== 'undefined') {
  329. headerCont.setVisible(true);
  330. ProductHBox.setVisible(true);
  331.  
  332. if (sap.ui.Device.orientation.landscape) {
  333. setTimeout(function() {
  334. setClassesOrientationDetailPage('landscape');
  335. rerenderWishlistCarousel();
  336. //Tracking Improvements & fix
  337. if (trkPrevPage.indexOf(sap.n.getObjectByID("oPageMatrix").sId) === 0 && _fromUpc === false) {
  338. trkSWTEnd = Date.now();
  339. trkSWTElapsed = (trkSWTEnd - trkSWTStart) / 1000;
  340. getOnlineChangeViewTradToDLogAjax(trkDevInfo + trkSeparator + trkSWTElapsed);
  341. }
  342. //Tracking Improvements & fix end
  343. }, 100);
  344. } else {
  345. setTimeout(function() {
  346. setClassesOrientationDetailPage('portrait');
  347. rerenderWishlistCarousel();
  348. //Tracking Improvements & fix
  349. if (App.getPreviousPage().sId.indexOf(sap.n.getObjectByID("oPageMatrix").sId) === 0 && _fromUpc === false) {
  350. trkSWTEnd = Date.now();
  351. trkSWTElapsed = (trkSWTEnd - trkSWTStart) / 1000;
  352. getOnlineChangeViewTradToDLogAjax(trkDevInfo + trkSeparator + trkSWTElapsed);
  353. }
  354. //Tracking Improvements & fix end
  355. }, 100);
  356. }
  357. }
  358. }
  359.  
  360. function rerenderWishlistCarousel() {
  361. var wish = modelWishlist.getData();
  362.  
  363. var colours = modelProductGridList.getData();
  364.  
  365. for (var n = 0; n < colours.length; n++) {
  366. $('#WishIconsHBox' + colours[n].PRD_COLOUR.replace('/', '_')).hide();
  367. for (var y = 0; y < wish.length; y++) {
  368. if (wish[y].PRODUCT === colours[n].PRODUCT && wish[y].PRD_COLOUR.replace('/', '_') === colours[n].PRD_COLOUR.replace('/', '_')) {
  369. $('#WishIconsHBox' + colours[n].PRD_COLOUR.replace('/', '_')).show();
  370. }
  371. }
  372. }
  373. }
  374.  
  375. function rerenderWishlistGrid() {
  376. var wish = modelWishlist.getData();
  377. var colours = modelProductGridList.getData();
  378. for (var n = 0; n < colours.length; n++) {
  379. $('#WishlistIconGrid' + colours[n].PRD_COLOUR.replace('/', '_')).hide();
  380. for (var y = 0; y < wish.length; y++) {
  381. if (wish[y].PRODUCT === colours[n].PRODUCT && wish[y].PRD_COLOUR.replace('/', '_') === colours[n].PRD_COLOUR.replace('/', '_')) {
  382. $('#WishlistIconGrid' + colours[n].PRD_COLOUR.replace('/', '_')).show();
  383. }
  384. }
  385. }
  386. }
  387.  
  388. function sortByWishList() {
  389. var wish = modelWishlist.getData();
  390. if (wish.length === 0 || wish.length === undefined) {
  391. return;
  392. }
  393. var coloursList = JSON.parse(JSON.stringify(modelProductGridList.getData()));
  394. //MARK WISHLIST PRODUCTS @coloursList
  395. for (var o = 0; o < wish.length; o++) {
  396. var found = false;
  397. for (var l = 0; l < coloursList.length && found === false; l++) {
  398. if (wish[o].PRODUCT === coloursList[l].PRODUCT &&
  399. wish[o].PRD_COLOUR.replace('/', '_') === coloursList[l].PRD_COLOUR.replace('/', '_')) {
  400. coloursList[l].WISHLIST = true;
  401. found = true;
  402. }
  403. }
  404. }
  405.  
  406. coloursList.sort(function(a, b) {
  407. if ((!(a.WISHLIST) && !(b.WISHLIST)) || (a.WISHLIST && b.WISHLIST)) {
  408. return a.PRD_COLOUR.localeCompare(b.PRD_COLOUR);
  409. } else {
  410. if (a.WISHLIST) {
  411. return -1;
  412. } else {
  413. return 1;
  414. }
  415. }
  416. });
  417.  
  418. //APPEND DOM IN ORDER
  419. var elements = $();
  420. elements = elements.add($('#MatrixButtonsRow_1').get());
  421. elements = elements.add($('#MatrixButtonsRow_2').get());
  422. for (var b = 0; b < coloursList.length; b++) {
  423. if (coloursList[b].WISHLIST) {
  424. elements = elements.add($('#itemMatrix' + coloursList[b].PRD_COLOUR.replace('/', '_')).get())
  425. // $('#tabMatrix-tblBody').prepend($('#itemMatrix' + coloursList[b].PRD_COLOUR.replace('/', '_')).get());
  426. }
  427. }
  428. $('#tabMatrix-tblBody').prepend(elements);
  429. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement