How to use alphaChar method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

homePageTool.ts

Source:homePageTool.ts Github

copy

Full Screen

1//TODO need to add addImagePath function to all modules2var mappingOrder = {};3var initViewModels = [];4var load = false;5var counter = 0;6class Dependents {7 constructor(params) {8 this.loadingModelData = ko.observableArray().extend({ deferred: true });9 this.itemNumber = ko.observable("");10 this.itemUrl = ko.observable("");11 this.imageSmallUrl = ko.observable("");12 this.imageLargeUrl = ko.observable("");13 this.imageDescription = ko.observable("");14 this.headline = ko.observable("");15 this.headlineUrl = ko.observable("");16 this.headlineDescription = ko.observable("");17 this.copy = ko.observable("");18 this.copyUrl = ko.observable("");19 this.copyDescription = ko.observable("");20 this.cta = ko.observable("");21 this.ctaUrl = ko.observable("");22 this.ctaDescription = ko.observable("");23 this.section = ko.observable("");24 this.sectionUrl = ko.observable("");25 this.sectionDescription = ko.observable("");26 this.seo1Section = ko.observable("");27 this.seo1SectionUrl = ko.observable("");28 this.seo1SectionDescription = ko.observable("");29 this.seo1cta = ko.observable("");30 this.seo1ctaUrl = ko.observable("");31 this.seo1ctaDescription = ko.observable("");32 this.seo2Section = ko.observable("");33 this.seo2SectionUrl = ko.observable("");34 this.seo2SectionDescription = ko.observable("");35 this.seo2cta = ko.observable("");36 this.seo2ctaUrl = ko.observable("");37 this.seo2ctaDescription = ko.observable("");38 this.seo2ItemNumber = ko.observable("");39 this.seo2ItemUrl = ko.observable("");40 this.seo2ImageSmallUrl = ko.observable("");41 this.seo2ImageLargeUrl = ko.observable("");42 this.seo2ImageDescription = ko.observable("");43 this.seo2cta = ko.observable("");44 this.seo2ctaUrl = ko.observable("");45 this.seo2ctaDescription = ko.observable("");46 this.moduleType = ko.observable("");47 this.displayModuleOn = ko.observable("");48 this.screenSizes = ko.observableArray(['small', 'medium', 'large', 'xlarge']);49 this.selectedModuleScreenSize = ko.observable('small');50 this.alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';51 this.mappingOrder = {};52 this.uniqueIdModified = ko.observable("");53 this.uniqueId = new Date().getTime();54 this.addImagePath = function(image){55 image = image.replace(/http:\/\/www.uncommongoods.com/g, "\/\/www.uncommongoods.com").replace(/\s+/g,"").replace(/é/g, "e");56 if (image.indexOf("www.uncommongoods.com/images/items") > -1) {57 return image;58 } else if(image.indexOf("/images/items") > -1 && image != '') {59 return '//www.uncommongoods.com'+image;60 } else if( image != '' ) {61 return '//www.uncommongoods.com/images/hp/B/'+image;62 } else {63 return '';64 }65 }66 this.removeImagePath = function(image){67 if (image.indexOf("//www.uncommongoods.com/images/hp/B/") > -1) {68 return image.split('//www.uncommongoods.com/images/hp/B/')[1];69 } else {70 return image;71 }72 }73 this.sortMappingOrder = function() {74 var uniqueIdReordered = this.uniqueIdModified();75 uniqueIdReordered.forEach((el,index) => {76 var alphaChar = this.alpha.charAt(index);77 if (Object.keys(this.mappingOrder[el])[0] != index) {78 var jsonString = JSON.stringify(this.mappingOrder[el]);79 var replaceVal = Object.keys(this.mappingOrder[el])[0];80 jsonString = jsonString.replace(RegExp(replaceVal), index);81 this.mappingOrder[el] = JSON.parse(jsonString);82 }83 });84 var mappingOrderCopy = this.mappingOrder;85 var removedUniqueIdJson = {};86 var tempArry = [];87 Object.keys(mappingOrderCopy).forEach(function(key) {88 Object.assign(removedUniqueIdJson, mappingOrderCopy[key]);89 })90 Object.keys(removedUniqueIdJson).forEach(function(key,index) {91 tempArry.push(Object.keys(removedUniqueIdJson[key])[0])92 });93 }94 this.removeModule = function(e) {95 var container = document.getElementById('uniqueId-'+e.uniqueId);96 var removeIndex = this.params.data.selectedModules().indexOf(ko.contextFor(container).$parent);97 this.params.data.selectedModules().splice(removeIndex, 1)98 ko.removeNode(container);99 delete this.params.data.mappingOrder[e.uniqueId];100 }101 this.bindingHandlers = {102 init: $(function () {103 $(document).foundation({104 accordion: {105 content_class: 'content', // specify the class used for active (or open) accordion panels106 active_class: 'active', // allow multiple accordion panels to be active at the same time107 multi_expand: false, // allow accordion panels to be closed by clicking on their headers108 toggleable: true109 }110 });111 })112 };113 ko.bindingHandlers.componentData = {114 init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {115 if (Object.keys(mappingOrder).length != 0 && load === true) {116 viewModel.params.data.loadingModelData.push(bindingContext);117 if (counter === viewModel.params.data.selectedModules().length) {118 var alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';119 //groups modules that are the same and next to each other into array120 var result = viewModel.params.data.loadingModelData().reduce(function(prev, curr) {121 if (prev.length && curr.$parent === prev[prev.length - 1][0].$parent) {122 if (curr.$parent === 'collection-grid-module' || curr.$parent === 'carousel-module' || curr.$parent === 'seo-link-module') {123 prev.push([curr]);124 } else {125 prev[prev.length - 1].push(curr);126 }127 }128 else {129 prev.push([curr]);130 }131 return prev;132 }, []);133 result.forEach((section, index) => {134 var alphaChar = alpha.charAt(index);135 var moduleType = section[0].$parent;136 section.forEach((binding,i) => {137 switch (binding.$parent) {138 case 'text-link-module':139 binding.$data.section(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.text : '');140 binding.$data.sectionUrl(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.link : '');141 binding.$data.sectionDescription(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.description : '');142 binding.$data.itemNumber(!!mappingOrder[alphaChar][moduleType]['sections'][i].item ? mappingOrder[alphaChar][moduleType]['sections'][i].item : '');143 binding.$data.itemUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.link : '');144 binding.$data.selectedModuleScreenSize(!!mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn ? mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn : '');145 binding.$data.imageSmallUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? viewModel.params.data.removeImagePath(mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.small) : '');146 binding.$data.imageLargeUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? viewModel.params.data.removeImagePath(mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.large) : '');147 binding.$data.imageDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.description : '');148 binding.$data.cta(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.text : '');149 binding.$data.ctaUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.link : '');150 binding.$data.ctaDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.description : '');151 break;152 case 'image-link-double-module':153 binding.$data.section(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.text : '');154 binding.$data.sectionUrl(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.link : '');155 binding.$data.sectionDescription(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.description : '');156 binding.$data.itemNumber(!!mappingOrder[alphaChar][moduleType]['sections'][i].item ? mappingOrder[alphaChar][moduleType]['sections'][i].item : '');157 binding.$data.itemUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.link : '');158 binding.$data.selectedModuleScreenSize(!!mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn ? mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn : '');159 binding.$data.imageSmallUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? viewModel.params.data.removeImagePath(mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.small) : '');160 binding.$data.imageLargeUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? viewModel.params.data.removeImagePath(mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.large) : '');161 binding.$data.imageDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.description : '');162 binding.$data.cta(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.text : '');163 binding.$data.ctaUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.link : '');164 binding.$data.ctaDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.description : '');165 break;166 case 'button-link-double-module':167 binding.$data.section(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.text : '');168 binding.$data.sectionUrl(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.link : '');169 binding.$data.sectionDescription(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.description : '');170 binding.$data.itemNumber(!!mappingOrder[alphaChar][moduleType]['sections'][i].item ? mappingOrder[alphaChar][moduleType]['sections'][i].item : '');171 binding.$data.itemUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.link : '');172 binding.$data.selectedModuleScreenSize(!!mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn ? mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn : '');173 binding.$data.imageSmallUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? viewModel.params.data.removeImagePath(mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.small) : '');174 binding.$data.imageLargeUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? viewModel.params.data.removeImagePath(mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.large) : '');175 binding.$data.imageDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.description : '');176 binding.$data.cta(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.text : '');177 binding.$data.ctaUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.link : '');178 binding.$data.ctaDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.description : '');179 break;180 case 'collection-grid-module':181 binding.$data.selectedModuleScreenSize(!!mappingOrder[alphaChar][moduleType].displayModuleOn ? mappingOrder[alphaChar][moduleType].displayModuleOn : '');182 binding.$data.section(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.text : '');183 binding.$data.sectionUrl(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.link : '');184 binding.$data.sectionDescription(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.description : '');185 binding.$data.headline(!!mappingOrder[alphaChar][moduleType].headline ? mappingOrder[alphaChar][moduleType].headline.text : '');186 binding.$data.headlineUrl(!!mappingOrder[alphaChar][moduleType].headline ? mappingOrder[alphaChar][moduleType].headline.link : '');187 binding.$data.headlineDescription(!!mappingOrder[alphaChar][moduleType].headline ? mappingOrder[alphaChar][moduleType].headline.description : '');188 binding.$data.cta(!!mappingOrder[alphaChar][moduleType].cta ? mappingOrder[alphaChar][moduleType].cta.text : '');189 binding.$data.ctaUrl(!!mappingOrder[alphaChar][moduleType].cta ? mappingOrder[alphaChar][moduleType].cta.link : '');190 binding.$data.ctaDescription(!!mappingOrder[alphaChar][moduleType].cta ? mappingOrder[alphaChar][moduleType].cta.description : '');191 var itemNumbers = [];192 var itemUrls = [];193 var smallImageUrls = [];194 var largeImageUrls = [];195 var imageDescriptions = [];196 if (mappingOrder[alphaChar][moduleType]['sections'] != undefined) {197 mappingOrder[alphaChar][moduleType]['sections'].forEach((item, index) => {198 itemNumbers.push(item.item);199 itemUrls.push(item.image.link);200 smallImageUrls.push(item.image.customImage.small);201 largeImageUrls.push(item.image.customImage.large);202 imageDescriptions.push(item.image.description);203 })204 itemNumbers = itemNumbers.join("\n");205 itemUrls = itemUrls.join("\n");206 smallImageUrls = smallImageUrls.join("\n");207 largeImageUrls = largeImageUrls.join("\n");208 imageDescriptions = imageDescriptions.join("\n");209 binding.$data.itemNumber(itemNumbers ? itemNumbers : '');210 binding.$data.itemUrl(itemUrls ? itemUrls : '');211 binding.$data.imageSmallUrl(smallImageUrls ? viewModel.params.data.removeImagePath(smallImageUrls) : '');212 binding.$data.imageLargeUrl(largeImageUrls ? viewModel.params.data.removeImagePath(largeImageUrls) : '');213 binding.$data.imageDescription(imageDescriptions ? imageDescriptions : '');214 }215 break;216 case 'carousel-module':217 binding.$data.selectedModuleScreenSize(!!mappingOrder[alphaChar][moduleType].displayModuleOn ? mappingOrder[alphaChar][moduleType].displayModuleOn : '');218 binding.$data.section(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.text : '');219 binding.$data.sectionUrl(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.link : '');220 binding.$data.sectionDescription(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.description : '');221 binding.$data.headline(!!mappingOrder[alphaChar][moduleType].headline ? mappingOrder[alphaChar][moduleType].headline.text : '');222 binding.$data.headlineUrl(!!mappingOrder[alphaChar][moduleType].headline ? mappingOrder[alphaChar][moduleType].headline.link : '');223 binding.$data.headlineDescription(!!mappingOrder[alphaChar][moduleType].headline ? mappingOrder[alphaChar][moduleType].headline.description : '');224 binding.$data.cta(!!mappingOrder[alphaChar][moduleType].cta ? mappingOrder[alphaChar][moduleType].cta.text : '');225 binding.$data.ctaUrl(!!mappingOrder[alphaChar][moduleType].cta ? mappingOrder[alphaChar][moduleType].cta.link : '');226 binding.$data.ctaDescription(!!mappingOrder[alphaChar][moduleType].cta ? mappingOrder[alphaChar][moduleType].cta.description : '');227 var itemNumbers = [];228 var itemUrls = [];229 var smallImageUrls = [];230 var largeImageUrls = [];231 var imageDescriptions = [];232 if (mappingOrder[alphaChar][moduleType]['sections'] != undefined) {233 mappingOrder[alphaChar][moduleType]['sections'].forEach((item, index) => {234 itemNumbers.push(item.item);235 itemUrls.push(item.image.link);236 smallImageUrls.push(item.image.customImage.small);237 largeImageUrls.push(item.image.customImage.large);238 imageDescriptions.push(item.image.description);239 })240 itemNumbers = itemNumbers.join("\n");241 itemUrls = itemUrls.join("\n");242 smallImageUrls = smallImageUrls.join("\n");243 largeImageUrls = largeImageUrls.join("\n");244 imageDescriptions = imageDescriptions.join("\n");245 binding.$data.itemNumber(itemNumbers ? itemNumbers : '');246 binding.$data.itemUrl(itemUrls ? itemUrls : '');247 binding.$data.imageSmallUrl(smallImageUrls ? viewModel.params.data.removeImagePath(smallImageUrls) : '');248 binding.$data.imageLargeUrl(largeImageUrls ? viewModel.params.data.removeImagePath(largeImageUrls) : '');249 binding.$data.imageDescription(imageDescriptions ? imageDescriptions : '');250 }251 break;252 case 'seo-link-module':253 binding.$data.seo1Section(!!mappingOrder[alphaChar][moduleType]['seo1'].section ? mappingOrder[alphaChar][moduleType]['seo1'].section.text : '');254 binding.$data.seo1SectionUrl(!!mappingOrder[alphaChar][moduleType]['seo1'].section ? mappingOrder[alphaChar][moduleType]['seo1'].section.link : '');255 binding.$data.seo1SectionDescription(!!mappingOrder[alphaChar][moduleType]['seo1'].section ? mappingOrder[alphaChar][moduleType]['seo1'].section.description : '');256 binding.$data.seo2Section(!!mappingOrder[alphaChar][moduleType]['seo2'].section ? mappingOrder[alphaChar][moduleType]['seo2'].section.text : '');257 binding.$data.seo2SectionUrl(!!mappingOrder[alphaChar][moduleType]['seo2'].section ? mappingOrder[alphaChar][moduleType]['seo2'].section.link : '');258 binding.$data.seo2SectionDescription(!!mappingOrder[alphaChar][moduleType]['seo2'].section ? mappingOrder[alphaChar][moduleType]['seo2'].section.description : '');259 var seo1_cta_text = [];260 var seo1_cta_link = [];261 var seo1_cta_description = [];262 var seo2_cta_text = [];263 var seo2_cta_link = [];264 var seo2_cta_description = [];265 var seo2_items = [];266 var seo2_items_urls = [];267 var seo2_small_images = [];268 var seo2_large_images = [];269 var seo2_image_descriptions = [];270 if (mappingOrder[alphaChar][moduleType]['seo1']['sections'] != undefined) {271 mappingOrder[alphaChar][moduleType]['seo1']['sections'].forEach((item, index) => {272 seo1_cta_text.push(item.cta.text);273 seo1_cta_link.push(item.cta.link);274 seo1_cta_description.push(item.cta.description);275 });276 }277 if (mappingOrder[alphaChar][moduleType]['seo2']['sections'] != undefined) {278 mappingOrder[alphaChar][moduleType]['seo2']['sections'].forEach((item, index) => {279 seo2_cta_text.push(item.cta.text);280 seo2_cta_link.push(item.cta.link);281 seo2_cta_description.push(item.cta.description);282 seo2_items.push(item.item);283 seo2_items_urls.push(item.image.link);284 seo2_small_images.push(item.image.customImage.small);285 seo2_large_images.push(item.image.customImage.large);286 seo2_image_descriptions.push(item.image.description);287 });288 }289 seo1_cta_text = seo1_cta_text.join("\n");290 seo1_cta_link = seo1_cta_link.join("\n");291 seo1_cta_description = seo1_cta_description.join("\n");292 seo2_cta_text = seo2_cta_text.join("\n");293 seo2_cta_link = seo2_cta_link.join("\n");294 seo2_cta_description = seo2_cta_description.join("\n");295 seo2_items = seo2_items.join("\n");296 seo2_items_urls = seo2_items_urls.join("\n");297 seo2_small_images = seo2_small_images.join("\n");298 seo2_large_images = seo2_large_images.join("\n");299 seo2_image_descriptions = seo2_image_descriptions.join("\n");300 binding.$data.seo1cta(seo1_cta_text ? seo1_cta_text : '');301 binding.$data.seo1ctaUrl(seo1_cta_link ? seo1_cta_link : '');302 binding.$data.seo1ctaDescription(seo1_cta_description ? seo1_cta_description : '');303 binding.$data.seo2cta(seo2_cta_text ? seo2_cta_text : '');304 binding.$data.seo2ctaUrl(seo2_cta_link ? seo2_cta_link : '');305 binding.$data.seo2ctaDescription(seo2_cta_description ? seo2_cta_description : '');306 binding.$data.seo2ItemNumber(seo2_items ? seo2_items : '');307 binding.$data.seo2ItemUrl(seo2_items_urls ? seo2_items_urls : '');308 binding.$data.seo2ImageSmallUrl(seo2_small_images ? viewModel.params.data.removeImagePath(seo2_small_images) : '');309 binding.$data.seo2ImageLargeUrl(seo2_large_images ? viewModel.params.data.removeImagePath(seo2_large_images) : '');310 binding.$data.seo2ImageDescription(seo2_image_descriptions ? seo2_image_descriptions : '');311 break;312 default:313 binding.$data.section(!!mappingOrder[alphaChar][moduleType]['sections'][i].section ? mappingOrder[alphaChar][moduleType]['sections'][i].section.text : '');314 binding.$data.sectionUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].section ? mappingOrder[alphaChar][moduleType]['sections'][i].section.link : '');315 binding.$data.sectionDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].section ? mappingOrder[alphaChar][moduleType]['sections'][i].section.description : '');316 binding.$data.itemNumber(!!mappingOrder[alphaChar][moduleType]['sections'][i].item ? mappingOrder[alphaChar][moduleType]['sections'][i].item : '');317 binding.$data.itemUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.link : '');318 binding.$data.selectedModuleScreenSize(!!mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn ? mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn : '');319 binding.$data.imageSmallUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? viewModel.params.data.removeImagePath(mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.small) : '');320 binding.$data.imageLargeUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? viewModel.params.data.removeImagePath(mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.large) : '');321 binding.$data.imageDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.description : '');322 binding.$data.headline(!!mappingOrder[alphaChar][moduleType]['sections'][i].headline ? mappingOrder[alphaChar][moduleType]['sections'][i].headline.text : '');323 binding.$data.headlineUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].headline ? mappingOrder[alphaChar][moduleType]['sections'][i].headline.link : '');324 binding.$data.headlineDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].headline ? mappingOrder[alphaChar][moduleType]['sections'][i].headline.description : '');325 binding.$data.copy(!!mappingOrder[alphaChar][moduleType]['sections'][i].copy ? mappingOrder[alphaChar][moduleType]['sections'][i].copy.text : '');326 binding.$data.copyUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].copy ? mappingOrder[alphaChar][moduleType]['sections'][i].copy.link : '');327 binding.$data.copyDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].copy ? mappingOrder[alphaChar][moduleType]['sections'][i].copy.description : '');328 binding.$data.cta(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.text : '');329 binding.$data.ctaUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.link : '');330 binding.$data.ctaDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.description : '');331 }332 })333 })334 }335 }336 },337 update: function(element, valueAccessor, allBindings, viewModel, bindingContext) {338 var uniqueId = viewModel.uniqueId;339 // var position = document.getElementById('sortableContainer').children.length;340 var moduleType = bindingContext.$parent;341 var uniqueIdArry = document.getElementById('sortableContainer').children;342 var myArray = Array.from(uniqueIdArry);343 var position;344 //console.log('myArray ',myArray);345 myArray.forEach((el, index) => {346 if ('uniqueId-'+uniqueId === el.id) {347 position = index;348 }349 })350 viewModel.params.data.mappingOrder[uniqueId] = {};351 viewModel.params.data.mappingOrder[uniqueId][position] = {};352 viewModel.params.data.mappingOrder[uniqueId][position][moduleType] = {};353 //console.log('mappingOrder ',viewModel.params.data.mappingOrder)354 switch (moduleType) {355 case 'large-feature-module':356 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['sections'] = [357 {358 'item': viewModel.itemNumber(),359 'displayModuleOn': viewModel.selectedModuleScreenSize(),360 'image': {361 'customImage': {362 "small": viewModel.addImagePath(viewModel.imageSmallUrl().trim()),363 "large": viewModel.addImagePath(viewModel.imageLargeUrl().trim())364 },365 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),366 'description': viewModel.imageDescription()367 },368 'headline': {369 'text': viewModel.headline().replace(/é/g, "&#233;"),370 'link': viewModel.headlineUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),371 'description': viewModel.headlineDescription()372 },373 'cta': {374 'text': viewModel.cta().replace(/é/g, "&#233;"),375 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),376 'description': viewModel.ctaDescription()377 }378 }379 ]380 break;381 case 'small-feature-module':382 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['sections'] = [383 {384 'item': viewModel.itemNumber(),385 'displayModuleOn': viewModel.selectedModuleScreenSize(),386 'section': {387 'text': viewModel.section().replace(/é/g, "&#233;"),388 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),389 'description': viewModel.sectionDescription()390 },391 'image': {392 'customImage': {393 "small": viewModel.addImagePath(viewModel.imageSmallUrl().trim()),394 "large": viewModel.addImagePath(viewModel.imageLargeUrl().trim())395 },396 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),397 'description': viewModel.imageDescription()398 },399 'headline': {400 'text': viewModel.headline().replace(/é/g, "&#233;"),401 'link': viewModel.headlineUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),402 'description': viewModel.headlineDescription()403 },404 'cta': {405 'text': viewModel.cta().replace(/é/g, "&#233;"),406 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),407 'description': viewModel.ctaDescription()408 }409 }410 ]411 break;412 case 'basic-story-module':413 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['sections'] = [414 {415 'item': viewModel.itemNumber(),416 'displayModuleOn': viewModel.selectedModuleScreenSize(),417 'section': {418 'text': viewModel.section().replace(/é/g, "&#233;"),419 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),420 'description': viewModel.sectionDescription()421 },422 'image': {423 'customImage': {424 "small": viewModel.addImagePath(viewModel.imageSmallUrl().trim()),425 "large": viewModel.addImagePath(viewModel.imageLargeUrl().trim())426 },427 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),428 'description': viewModel.imageDescription()429 },430 'headline': {431 'text': viewModel.headline().replace(/é/g, "&#233;"),432 'link': viewModel.headlineUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),433 'description': viewModel.headlineDescription()434 },435 'copy': {436 'text': viewModel.copy().replace(/é/g, "&#233;"),437 'link': viewModel.copyUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),438 'description': viewModel.copyDescription()439 },440 'cta': {441 'text': viewModel.cta().replace(/é/g, "&#233;"),442 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),443 'description': viewModel.ctaDescription()444 }445 }446 ]447 break;448 case 'extended-story-module':449 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['sections'] = [450 {451 'item': viewModel.itemNumber(),452 'displayModuleOn': viewModel.selectedModuleScreenSize(),453 'section': {454 'text': viewModel.section().replace(/é/g, "&#233;"),455 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),456 'description': viewModel.sectionDescription()457 },458 'image': {459 'customImage': {460 "small": viewModel.addImagePath(viewModel.imageSmallUrl().trim()),461 "large": viewModel.addImagePath(viewModel.imageLargeUrl().trim())462 },463 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),464 'description': viewModel.imageDescription()465 },466 'headline': {467 'text': viewModel.headline().replace(/é/g, "&#233;"),468 'link': viewModel.headlineUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),469 'description': viewModel.headlineDescription()470 },471 'copy': {472 'text': viewModel.copy().replace(/é/g, "&#233;"),473 'link': viewModel.copyUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),474 'description': viewModel.copyDescription()475 },476 'cta': {477 'text': viewModel.cta().replace(/é/g, "&#233;"),478 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),479 'description': viewModel.ctaDescription()480 }481 }482 ]483 break;484 case 'collection-grid-module':485 var itemsList = viewModel.itemNumber().replace(/\n/g, ',').split(',');486 var itemsUrlList = viewModel.itemUrl().replace(/\n/g, ',').split(',');487 var smallImageList = viewModel.imageSmallUrl().replace(/\n/g, ',').split(',');488 var largeImageList = viewModel.imageLargeUrl().replace(/\n/g, ',').split(',');489 var imageDescriptionList = viewModel.imageDescription().replace(/\n/g, ',').split(',');490 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['section'] = {491 'text': viewModel.section().replace(/é/g, "&#233;"),492 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),493 'description': viewModel.sectionDescription()494 },495 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['headline'] = {496 'text': viewModel.headline().replace(/é/g, "&#233;"),497 'link': viewModel.headlineUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),498 'description': viewModel.headlineDescription()499 },500 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['cta'] = {501 'text': viewModel.cta().replace(/é/g, "&#233;"),502 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),503 'description': viewModel.ctaDescription()504 },505 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['displayModuleOn'] = viewModel.selectedModuleScreenSize(),506 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['sections'] = []507 itemsList.forEach((item, index) => {508 if (item != '') {509 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['sections'].push(510 {511 'item': item.trim(),512 'image': {513 'customImage': {514 'small': smallImageList[index] === undefined ? '' : viewModel.addImagePath(smallImageList[index].trim()),515 'large': largeImageList[index] === undefined ? '' : viewModel.addImagePath(largeImageList[index].trim())516 },517 'link': itemsUrlList[index] === undefined ? '' : itemsUrlList[index].replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),518 'description': imageDescriptionList[index] === undefined ? '' : imageDescriptionList[index]519 }520 }521 )522 }523 })524 break;525 case 'carousel-module':526 var itemsList = viewModel.itemNumber().replace(/\n/g, ',').split(',');527 var itemsUrlList = viewModel.itemUrl().replace(/\n/g, ',').split(',');528 var smallImageList = viewModel.imageSmallUrl().replace(/\n/g, ',').split(',');529 var largeImageList = viewModel.imageLargeUrl().replace(/\n/g, ',').split(',');530 var imageDescriptionList = viewModel.imageDescription().replace(/\n/g, ',').split(',');531 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['section'] = {532 'text': viewModel.section().replace(/é/g, "&#233;"),533 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),534 'description': viewModel.sectionDescription()535 },536 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['headline'] = {537 'text': viewModel.headline().replace(/é/g, "&#233;"),538 'link': viewModel.headlineUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),539 'description': viewModel.headlineDescription()540 },541 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['cta'] = {542 'text': viewModel.cta().replace(/é/g, "&#233;"),543 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),544 'description': viewModel.ctaDescription()545 },546 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['displayModuleOn'] = viewModel.selectedModuleScreenSize(),547 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['sections'] = []548 itemsList.forEach((item, index) => {549 if (item != '') {550 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['sections'].push(551 {552 'item': item.trim(),553 'image': {554 'customImage': {555 'small': smallImageList[index] === undefined ? '' : viewModel.addImagePath(smallImageList[index].trim()),556 'large': largeImageList[index] === undefined ? '' : viewModel.addImagePath(largeImageList[index].trim())557 },558 'link': itemsUrlList[index] === undefined ? '' : itemsUrlList[index].replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),559 'description': imageDescriptionList[index] === undefined ? '' : imageDescriptionList[index]560 }561 }562 )563 }564 })565 break;566 case 'text-link-module':567 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['section'] = {568 'text': viewModel.section().replace(/é/g, "&#233;"),569 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),570 'description': viewModel.sectionDescription()571 },572 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['sections'] = [573 {574 'item': viewModel.itemNumber(),575 'displayModuleOn': viewModel.selectedModuleScreenSize(),576 'image': {577 'customImage': {578 "small": viewModel.addImagePath(viewModel.imageSmallUrl().trim()),579 "large": viewModel.addImagePath(viewModel.imageLargeUrl().trim())580 },581 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),582 'description': viewModel.imageDescription()583 },584 'cta': {585 'text': viewModel.cta().replace(/é/g, "&#233;"),586 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),587 'description': viewModel.ctaDescription()588 }589 }590 ]591 break;592 case 'image-link-double-module':593 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['section'] = {594 'text': viewModel.section().replace(/é/g, "&#233;"),595 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),596 'description': viewModel.sectionDescription()597 },598 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['sections'] = [599 {600 'item': viewModel.itemNumber(),601 'displayModuleOn': viewModel.selectedModuleScreenSize(),602 'image': {603 'customImage': {604 "small": viewModel.addImagePath(viewModel.imageSmallUrl().trim()),605 "large": viewModel.addImagePath(viewModel.imageLargeUrl().trim())606 },607 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),608 'description': viewModel.imageDescription()609 },610 'cta': {611 'text': viewModel.cta().replace(/é/g, "&#233;"),612 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),613 'description': viewModel.ctaDescription()614 }615 }616 ]617 break;618 case 'button-link-double-module':619 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['section'] = {620 'text': viewModel.section().replace(/é/g, "&#233;"),621 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),622 'description': viewModel.sectionDescription()623 },624 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['sections'] = [625 {626 'item': viewModel.itemNumber(),627 'displayModuleOn': viewModel.selectedModuleScreenSize(),628 'image': {629 'customImage': {630 "small": viewModel.addImagePath(viewModel.imageSmallUrl().trim()),631 "large": viewModel.addImagePath(viewModel.imageLargeUrl().trim())632 },633 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),634 'description': viewModel.imageDescription()635 },636 'cta': {637 'text': viewModel.cta().replace(/é/g, "&#233;"),638 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),639 'description': viewModel.ctaDescription()640 }641 }642 ]643 break;644 case 'seo-link-module':645 var seo1ctaList = viewModel.seo1cta().replace(/\n/g, ',').split(',');646 var seo1ctaUrlList = viewModel.seo1ctaUrl().replace(/\n/g, ',').split(',');647 var seo1ctaDescriptionList = viewModel.seo1ctaDescription().replace(/\n/g, ',').split(',');648 var seo2ItemsList = viewModel.seo2ItemNumber().replace(/\n/g, ',').split(',');649 var seo2ItemsUrlList = viewModel.seo2ItemUrl().replace(/\n/g, ',').split(',');650 var seo2SmallImageList = viewModel.seo2ImageSmallUrl().replace(/\n/g, ',').split(',');651 var seo2LargeImageList = viewModel.seo2ImageLargeUrl().replace(/\n/g, ',').split(',');652 var seo2ImageDescriptionList = viewModel.seo2ImageDescription().replace(/\n/g, ',').split(',');653 var seo2ctaList = viewModel.seo2cta().replace(/\n/g, ',').split(',');654 var seo2ctaUrlList = viewModel.seo2ctaUrl().replace(/\n/g, ',').split(',');655 var seo2ctaDescriptionList = viewModel.seo2ctaDescription().replace(/\n/g, ',').split(',');656 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['seo1'] = {}657 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['seo1']['section'] = {658 'text': viewModel.seo1Section().replace(/é/g, "&#233;"),659 'link': viewModel.seo1SectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),660 'description': viewModel.seo1SectionDescription()661 },662 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['seo1']['sections'] = []663 seo1ctaList.forEach((item, index) => {664 if (item != '') {665 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['seo1']['sections'].push(666 {667 'cta': {668 'text': item.trim(),669 'link': seo1ctaUrlList[index] === undefined ? '' : seo1ctaUrlList[index].replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),670 'description': seo1ctaDescriptionList[index] === undefined ? '' : seo1ctaDescriptionList[index]671 }672 }673 )674 }675 })676 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['seo2'] = {}677 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['seo2']['section'] = {678 'text': viewModel.seo2Section().replace(/é/g, "&#233;"),679 'link': viewModel.seo2SectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),680 'description': viewModel.seo2SectionDescription()681 },682 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['seo2']['sections'] = []683 seo2ItemsList.forEach((item, index) => {684 if (item != '') {685 viewModel.params.data.mappingOrder[uniqueId][position][moduleType]['seo2']['sections'].push(686 {687 'item': item.trim(),688 'image': {689 'customImage': {690 'small': seo2SmallImageList[index] === undefined ? '' : viewModel.addImagePath(seo2SmallImageList[index].trim()),691 'large': seo2LargeImageList[index] === undefined ? '' : viewModel.addImagePath(seo2LargeImageList[index].trim())692 },693 'link': seo2ItemsUrlList[index] === undefined ? '' : seo2ItemsUrlList[index].replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),694 'description': seo2ImageDescriptionList[index] === undefined ? '' : seo2ImageDescriptionList[index]695 },696 'cta': {697 'text': seo2ctaList[index] === undefined ? '' : seo2ctaList[index].replace(/é/g, "&#233;").trim(),698 'link': seo2ctaUrlList[index] === undefined ? '' : seo2ctaUrlList[index].replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),699 'description': seo2ctaDescriptionList[index] === undefined ? '' : seo2ctaDescriptionList[index]700 }701 }702 )703 }704 })705 break;706 }707 }708 };709 }710}711ko.components.register('large-feature-module', {712 viewModel: class LargeFeatureModuleComponentModel extends Dependents {713 constructor(params) {714 super(params);715 this.params = params;716 }717 },718 template: `719 <li class="row" data-bind="componentData, attr: {'id': 'uniqueId-'+uniqueId, 'data-type': 'large-feature-module' }">720 <div class="flexContainer">721 <div class="small-11 columns">722 <dl class="accordion" data-accordion="" role="tablist">723 <dd class="accordion-navigation">724 <a data-bind="text: 'Large Feature Module', attr: { href: '#accordion-'+uniqueId, id: 'accordion-heading-'+uniqueId, role: 'tab' }"></a>725 <div data-bind="attr: { id: 'accordion-'+uniqueId, 'aria-labelledby': 'accordion-heading-'+uniqueId, role: 'tabpanel' }" class="content">726 <div class="row">727 <div class="small-12 medium-4 columns">728 <label>Item #</label>729 <input data-bind="textInput: itemNumber" type="number" placeholder="Item #"></input>730 </div>731 <div class="small-12 medium-4 columns">732 <label>Item URL</label>733 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL"></input>734 </div>735 <div class="small-12 medium-4 columns">736 <label>Display Module On</label>737 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>738 </div>739 </div>740 <div class="row">741 <div class="small-12 medium-4 columns">742 <label>Small Image URL</label>743 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL"></input>744 </div>745 <div class="small-12 medium-4 columns">746 <label>Large Image URL</label>747 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL"></input>748 </div>749 <div class="small-12 medium-4 columns">750 <label>Image Description Tag</label>751 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag"></input>752 </div>753 </div>754 <div class="row">755 <div class="small-12 medium-4 columns">756 <label>Headline</label>757 <input data-bind="textInput: headline" type="text" placeholder="Headline">758 </div>759 <div class="small-12 medium-4 columns">760 <label>Headline URL</label>761 <input data-bind="textInput: headlineUrl" type="text" placeholder="Headline URL">762 </div>763 <div class="small-12 medium-4 columns">764 <label>Headline Description Tag</label>765 <input data-bind="textInput: headlineDescription" type="text" placeholder="Headline Description Tag"></input>766 </div>767 </div>768 <div class="row">769 <div class="small-12 medium-4 columns">770 <label>CTA</label>771 <input data-bind="textInput: cta" type="text" placeholder="CTA">772 </div>773 <div class="small-12 medium-4 columns">774 <label>CTA URL</label>775 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">776 </div>777 <div class="small-12 medium-4 columns">778 <label>CTA Description Tag</label>779 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag"></input>780 </div>781 </div>782 </div>783 </dd>784 </dl>785 </div>786 <div class="small-1 text-center columns removeModule">787 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>788 </div>789 </div790 </li>`, synchronous: true791});792ko.components.register('small-feature-module', {793 viewModel: class SmallFeatureModuleComponentModel extends Dependents {794 constructor(params) {795 super(params);796 this.params = params;797 }798 },799 template: `800 <li class="row" data-bind="componentData, attr: {'id': 'uniqueId-'+uniqueId, 'data-type': 'small-feature-module' }">801 <div class="flexContainer">802 <div class="small-11 columns">803 <dl class="accordion" data-accordion="" role="tablist">804 <dd class="accordion-navigation">805 <a data-bind="text: 'Small Feature Module', attr: { href: '#accordion-'+uniqueId, id: 'accordion-heading-'+uniqueId, role: 'tab' }"></a>806 <div data-bind="attr: { id: 'accordion-'+uniqueId, 'aria-labelledby': 'accordion-heading-'+uniqueId, role: 'tabpanel' }" class="content">807 <div class="row">808 <div class="small-12 medium-4 columns">809 <label>Item #</label>810 <input data-bind="textInput: itemNumber" type="text" placeholder="Item #">811 </div>812 <div class="small-12 medium-4 columns">813 <label>Item URL</label>814 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL">815 </div>816 <div class="small-12 medium-4 columns">817 <label>Display Module On</label>818 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>819 </div>820 </div>821 <div class="row">822 <div class="small-12 medium-4 columns">823 <label>Small Image URL</label>824 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL"></input>825 </div>826 <div class="small-12 medium-4 columns">827 <label>Large Image URL</label>828 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL"></input>829 </div>830 <div class="small-12 medium-4 columns">831 <label>Image Description Tag</label>832 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag"></input>833 </div>834 </div>835 <div class="row">836 <div class="small-12 medium-4 columns">837 <label>Section</label>838 <input data-bind="textInput: section" type="text" placeholder="Section">839 </div>840 <div class="small-12 medium-4 columns">841 <label>Section URL</label>842 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">843 </div>844 <div class="small-12 medium-4 columns">845 <label>Section Description Tag</label>846 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>847 </div>848 </div>849 <div class="row">850 <div class="small-12 medium-4 columns">851 <label>Headline</label>852 <input data-bind="textInput: headline" type="text" placeholder="Headline">853 </div>854 <div class="small-12 medium-4 columns">855 <label>Headline URL</label>856 <input data-bind="textInput: headlineUrl" type="text" placeholder="Headline URL">857 </div>858 <div class="small-12 medium-4 columns">859 <label>Headline Description Tag</label>860 <input data-bind="textInput: headlineDescription" type="text" placeholder="Headline Description Tag"></input>861 </div>862 </div>863 <div class="row">864 <div class="small-12 medium-4 columns">865 <label>CTA</label>866 <input data-bind="textInput: cta" type="text" placeholder="CTA">867 </div>868 <div class="small-12 medium-4 columns">869 <label>CTA URL</label>870 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">871 </div>872 <div class="small-12 medium-4 columns">873 <label>CTA Description Tag</label>874 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag"></input>875 </div>876 </div>877 </div>878 </dd>879 </dl>880 </div>881 <div class="small-1 text-center columns removeModule">882 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>883 </div>884 </div>885 </li>`, synchronous: true886});887ko.components.register('basic-story-module', {888 viewModel: class BasicStoryModuleComponentModel extends Dependents {889 constructor(params) {890 super(params);891 this.params = params;892 }893 },894 template: `895 <li class="row" data-bind="componentData, attr: {'id': 'uniqueId-'+uniqueId, 'data-type': 'basic-story-module' }">896 <div class="flexContainer">897 <div class="small-11 columns">898 <dl class="accordion" data-accordion="" role="tablist">899 <dd class="accordion-navigation">900 <a data-bind="text: 'Basic Story Module', attr: { href: '#accordion-'+uniqueId, id: 'accordion-heading-'+uniqueId, role: 'tab' }"></a>901 <div data-bind="attr: { id: 'accordion-'+uniqueId, 'aria-labelledby': 'accordion-heading-'+uniqueId, role: 'tabpanel' }" class="content">902 <div class="row">903 <div class="small-12 medium-4 columns">904 <label>Item #</label>905 <input data-bind="textInput: itemNumber" type="text" placeholder="Item #">906 </div>907 <div class="small-12 medium-4 columns">908 <label>Item URL</label>909 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL">910 </div>911 <div class="small-12 medium-4 columns">912 <label>Display Module On</label>913 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>914 </div>915 </div>916 <div class="row">917 <div class="small-12 medium-4 columns">918 <label>Small Image URL</label>919 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL"></input>920 </div>921 <div class="small-12 medium-4 columns">922 <label>Large Image URL</label>923 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL"></input>924 </div>925 <div class="small-12 medium-4 columns">926 <label>Image Description Tag</label>927 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag"></input>928 </div>929 </div>930 <div class="row">931 <div class="small-12 medium-4 columns">932 <label>Section</label>933 <input data-bind="textInput: section" type="text" placeholder="Section">934 </div>935 <div class="small-12 medium-4 columns">936 <label>Section URL</label>937 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">938 </div>939 <div class="small-12 medium-4 columns">940 <label>Section Description Tag</label>941 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>942 </div>943 </div>944 <div class="row">945 <div class="small-12 medium-4 columns">946 <label>Headline</label>947 <input data-bind="textInput: headline" type="text" placeholder="Headline">948 </div>949 <div class="small-12 medium-4 columns">950 <label>Headline URL</label>951 <input data-bind="textInput: headlineUrl" type="text" placeholder="Headline URL">952 </div>953 <div class="small-12 medium-4 columns">954 <label>Headline Description Tag</label>955 <input data-bind="textInput: headlineDescription" type="text" placeholder="Headline Description Tag"></input>956 </div>957 </div>958 <div class="row">959 <div class="small-12 medium-4 columns">960 <label>Copy</label>961 <textarea rows="6" type="text" placeholder="Copy" data-bind="textInput: copy"></textarea>962 </div>963 <div class="small-12 medium-4 columns">964 <label>Copy URL</label>965 <input data-bind="textInput: copyUrl" type="text" placeholder="Copy URL">966 </div>967 <div class="small-12 medium-4 columns">968 <label>Copy Description Tag</label>969 <input data-bind="textInput: copyDescription" type="text" placeholder="Copy Description Tag"></input>970 </div>971 </div>972 <div class="row">973 <div class="small-12 medium-4 columns">974 <label>CTA</label>975 <input data-bind="textInput: cta" type="text" placeholder="CTA">976 </div>977 <div class="small-12 medium-4 columns">978 <label>CTA URL</label>979 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">980 </div>981 <div class="small-12 medium-4 columns">982 <label>CTA Description Tag</label>983 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag"></input>984 </div>985 </div>986 </div>987 </dd>988 </dl>989 </div>990 <div class="small-1 text-center columns removeModule">991 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>992 </div>993 </div994 </li>`, synchronous: true995});996ko.components.register('extended-story-module', {997 viewModel: class ExtendedStoryModuleComponentModel extends Dependents {998 constructor(params) {999 super(params);1000 this.params = params;1001 }1002 },1003 template: `1004 <li class="row" data-bind="componentData, attr: {'id': 'uniqueId-'+uniqueId, 'data-type': 'extended-story-module' }">1005 <div class="flexContainer">1006 <div class="small-11 columns">1007 <dl class="accordion" data-accordion="" role="tablist">1008 <dd class="accordion-navigation">1009 <a data-bind="text: 'Extended Story Module', attr: { href: '#accordion-'+uniqueId, id: 'accordion-heading-'+uniqueId, role: 'tab' }"></a>1010 <div data-bind="attr: { id: 'accordion-'+uniqueId, 'aria-labelledby': 'accordion-heading-'+uniqueId, role: 'tabpanel' }" class="content">1011 <div class="row">1012 <div class="small-12 medium-4 columns">1013 <label>Item #</label>1014 <input data-bind="textInput: itemNumber" type="text" placeholder="Item #">1015 </div>1016 <div class="small-12 medium-4 columns">1017 <label>Item URL</label>1018 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL">1019 </div>1020 <div class="small-12 medium-4 columns">1021 <label>Display Module On</label>1022 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>1023 </div>1024 </div>1025 <div class="row">1026 <div class="small-12 medium-4 columns">1027 <label>Small Image URL</label>1028 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL"></input>1029 </div>1030 <div class="small-12 medium-4 columns">1031 <label>Large Image URL</label>1032 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL"></input>1033 </div>1034 <div class="small-12 medium-4 columns">1035 <label>Image Description Tag</label>1036 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag"></input>1037 </div>1038 </div>1039 <div class="row">1040 <div class="small-12 medium-4 columns">1041 <label>Section</label>1042 <input data-bind="textInput: section" type="text" placeholder="Section">1043 </div>1044 <div class="small-12 medium-4 columns">1045 <label>Section URL</label>1046 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">1047 </div>1048 <div class="small-12 medium-4 columns">1049 <label>Section Description Tag</label>1050 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>1051 </div>1052 </div>1053 <div class="row">1054 <div class="small-12 medium-4 columns">1055 <label>Headline</label>1056 <input data-bind="textInput: headline" type="text" placeholder="Headline">1057 </div>1058 <div class="small-12 medium-4 columns">1059 <label>Headline URL</label>1060 <input data-bind="textInput: headlineUrl" type="text" placeholder="Headline URL">1061 </div>1062 <div class="small-12 medium-4 columns">1063 <label>Headline Description Tag</label>1064 <input data-bind="textInput: headlineDescription" type="text" placeholder="Headline Description Tag"></input>1065 </div>1066 </div>1067 <div class="row">1068 <div class="small-12 medium-4 columns">1069 <label>Copy</label>1070 <textarea rows="6" type="text" placeholder="Copy" data-bind="textInput: copy"></textarea>1071 </div>1072 <div class="small-12 medium-4 columns">1073 <label>Copy URL</label>1074 <input data-bind="textInput: copyUrl" type="text" placeholder="Copy URL">1075 </div>1076 <div class="small-12 medium-4 columns">1077 <label>Copy Description Tag</label>1078 <input data-bind="textInput: copyDescription" type="text" placeholder="Copy Description Tag"></input>1079 </div>1080 </div>1081 <div class="row">1082 <div class="small-12 medium-4 columns">1083 <label>CTA</label>1084 <input data-bind="textInput: cta" type="text" placeholder="CTA">1085 </div>1086 <div class="small-12 medium-4 columns">1087 <label>CTA URL</label>1088 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1089 </div>1090 <div class="small-12 medium-4 columns">1091 <label>CTA Description Tag</label>1092 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag"></input>1093 </div>1094 </div>1095 </div>1096 </dd>1097 </dl>1098 </div>1099 <div class="small-1 text-center columns removeModule">1100 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1101 </div>1102 </div>1103 </li>`, synchronous: true1104});1105ko.components.register('collection-grid-module', {1106 viewModel: class CollectionGridModuleComponentModel extends Dependents {1107 constructor(params) {1108 super(params);1109 this.params = params;1110 }1111 },1112 template: `1113 <li class="row" data-bind="componentData, attr: {'id': 'uniqueId-'+uniqueId, 'data-type': 'collection-grid-module' }">1114 <div class="flexContainer">1115 <div class="small-11 columns">1116 <dl class="accordion" data-accordion="" role="tablist">1117 <dd class="accordion-navigation">1118 <a data-bind="text: 'Collection Grid Module', attr: { href: '#accordion-'+uniqueId, id: 'accordion-heading-'+uniqueId, role: 'tab' }"></a>1119 <div data-bind="attr: { id: 'accordion-'+uniqueId, 'aria-labelledby': 'accordion-heading-'+uniqueId, role: 'tabpanel' }" class="content">1120 <div class="row">1121 <div class="small-12 medium-4 columns">1122 <label>Item #</label>1123 <textarea rows="6" type="text" placeholder="Item #" data-bind="textInput: itemNumber"></textarea>1124 </div>1125 <div class="small-12 medium-4 columns">1126 <label>Item URL</label>1127 <textarea rows="6" type="text" placeholder="Item URL" data-bind="textInput: itemUrl"></textarea>1128 </div>1129 <div class="small-12 medium-4 columns">1130 <label>Display Module On</label>1131 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>1132 </div>1133 </div>1134 <div class="row">1135 <div class="small-12 medium-4 columns">1136 <label>Small Image URL</label>1137 <textarea rows="6" type="text" placeholder="Small Image URL" data-bind="textInput: imageSmallUrl"></textarea>1138 </div>1139 <div class="small-12 medium-4 columns">1140 <label>Large Image URL</label>1141 <textarea rows="6" type="text" placeholder="Large Image URL" data-bind="textInput: imageLargeUrl"></textarea>1142 </div>1143 <div class="small-12 medium-4 columns">1144 <label>Image Description Tag</label>1145 <textarea rows="6" type="text" placeholder="Image Description Tag" data-bind="textInput: imageDescription"></textarea>1146 </div>1147 </div>1148 <div class="row">1149 <div class="small-12 medium-4 columns">1150 <label>Section</label>1151 <input data-bind="textInput: section" type="text" placeholder="Section">1152 </div>1153 <div class="small-12 medium-4 columns">1154 <label>Section URL</label>1155 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">1156 </div>1157 <div class="small-12 medium-4 columns">1158 <label>Section Description Tag</label>1159 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>1160 </div>1161 </div>1162 <div class="row">1163 <div class="small-12 medium-4 columns">1164 <label>Headline</label>1165 <input data-bind="textInput: headline" type="text" placeholder="Headline">1166 </div>1167 <div class="small-12 medium-4 columns">1168 <label>Headline URL</label>1169 <input data-bind="textInput: headlineUrl" type="text" placeholder="Headline URL">1170 </div>1171 <div class="small-12 medium-4 columns">1172 <label>Headline Description Tag</label>1173 <input data-bind="textInput: headlineDescription" type="text" placeholder="Headline Description Tag"></input>1174 </div>1175 </div>1176 <div class="row">1177 <div class="small-12 medium-4 columns">1178 <label>CTA</label>1179 <input data-bind="textInput: cta" type="text" placeholder="CTA">1180 </div>1181 <div class="small-12 medium-4 columns">1182 <label>CTA URL</label>1183 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1184 </div>1185 <div class="small-12 medium-4 columns">1186 <label>CTA Description Tag</label>1187 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag"></input>1188 </div>1189 </div>1190 </div>1191 </dd>1192 </dl>1193 </div>1194 <div class="small-1 text-center columns removeModule">1195 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1196 </div>1197 </div>1198 </li>`, synchronous: true1199});1200ko.components.register('carousel-module', {1201 viewModel: class CarouselModuleComponentModel extends Dependents {1202 constructor(params) {1203 super(params);1204 this.params = params;1205 }1206 },1207 template: `1208 <li class="row" data-bind="componentData, attr: {'id': 'uniqueId-'+uniqueId, 'data-type': 'carousel-module' }">1209 <div class="flexContainer">1210 <div class="small-11 columns">1211 <dl class="accordion" data-accordion="" role="tablist">1212 <dd class="accordion-navigation">1213 <a data-bind="text: 'Carousel Module', attr: { href: '#accordion-'+uniqueId, id: 'accordion-heading-'+uniqueId, role: 'tab' }"></a>1214 <div data-bind="attr: { id: 'accordion-'+uniqueId, 'aria-labelledby': 'accordion-heading-'+uniqueId, role: 'tabpanel' }" class="content">1215 <div class="row">1216 <div class="small-12 medium-4 columns">1217 <label>Item #</label>1218 <textarea rows="6" type="text" placeholder="Item #" data-bind="textInput: itemNumber"></textarea>1219 </div>1220 <div class="small-12 medium-4 columns">1221 <label>Item URL</label>1222 <textarea rows="6" type="text" placeholder="Item URL" data-bind="textInput: itemUrl"></textarea>1223 </div>1224 <div class="small-12 medium-4 columns">1225 <label>Display Module On</label>1226 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>1227 </div>1228 </div>1229 <div class="row">1230 <div class="small-12 medium-4 columns">1231 <label>Small Image URL</label>1232 <textarea rows="6" type="text" placeholder="Small Image URL" data-bind="textInput: imageSmallUrl"></textarea>1233 </div>1234 <div class="small-12 medium-4 columns">1235 <label>Large Image URL</label>1236 <textarea rows="6" type="text" placeholder="Large Image URL" data-bind="textInput: imageLargeUrl"></textarea>1237 </div>1238 <div class="small-12 medium-4 columns">1239 <label>Image Description Tag</label>1240 <textarea rows="6" type="text" placeholder="Image Description Tag" data-bind="textInput: imageDescription"></textarea>1241 </div>1242 </div>1243 <div class="row">1244 <div class="small-12 medium-4 columns">1245 <label>Section</label>1246 <input data-bind="textInput: section" type="text" placeholder="Section">1247 </div>1248 <div class="small-12 medium-4 columns">1249 <label>Section URL</label>1250 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">1251 </div>1252 <div class="small-12 medium-4 columns">1253 <label>Section Description Tag</label>1254 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>1255 </div>1256 </div>1257 <div class="row">1258 <div class="small-12 medium-4 columns">1259 <label>Headline</label>1260 <input data-bind="textInput: headline" type="text" placeholder="Headline">1261 </div>1262 <div class="small-12 medium-4 columns">1263 <label>Headline URL</label>1264 <input data-bind="textInput: headlineUrl" type="text" placeholder="Headline URL">1265 </div>1266 <div class="small-12 medium-4 columns">1267 <label>Headline Description Tag</label>1268 <input data-bind="textInput: headlineDescription" type="text" placeholder="Headline Description Tag"></input>1269 </div>1270 </div>1271 <div class="row">1272 <div class="small-12 medium-4 columns">1273 <label>CTA</label>1274 <input data-bind="textInput: cta" type="text" placeholder="CTA">1275 </div>1276 <div class="small-12 medium-4 columns">1277 <label>CTA URL</label>1278 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1279 </div>1280 <div class="small-12 medium-4 columns">1281 <label>CTA Description Tag</label>1282 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag"></input>1283 </div>1284 </div>1285 </div>1286 </dd>1287 </dl>1288 </div>1289 <div class="small-1 text-center columns removeModule">1290 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1291 </div>1292 </div>1293 </li>`, synchronous: true1294});1295ko.components.register('text-link-module', {1296 viewModel: class TextLinkModuleComponentModel extends Dependents {1297 constructor(params) {1298 super(params);1299 this.params = params;1300 }1301 },1302 template: `1303 <li class="row" data-bind="componentData, attr: {'id': 'uniqueId-'+uniqueId, 'data-type': 'text-link-module' }">1304 <div class="flexContainer">1305 <div class="small-11 columns">1306 <dl class="accordion" data-accordion="" role="tablist">1307 <dd class="accordion-navigation">1308 <a data-bind="text: 'Text Link Module', attr: { href: '#accordion-'+uniqueId, id: 'accordion-heading-'+uniqueId, role: 'tab' }"></a>1309 <div data-bind="attr: { id: 'accordion-'+uniqueId, 'aria-labelledby': 'accordion-heading-'+uniqueId, role: 'tabpanel' }" class="content">1310 <div class="row">1311 <div class="small-12 medium-4 columns">1312 <label>Item #</label>1313 <input data-bind="textInput: itemNumber" type="text" placeholder="Item #">1314 </div>1315 <div class="small-12 medium-4 columns">1316 <label>Item URL</label>1317 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL">1318 </div>1319 <div class="small-12 medium-4 columns">1320 <label>Display Module On</label>1321 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>1322 </div>1323 </div>1324 <div class="row">1325 <div class="small-12 medium-4 columns">1326 <label>Small Image URL</label>1327 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL">1328 </div>1329 <div class="small-12 medium-4 columns">1330 <label>Large Image URL</label>1331 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL">1332 </div>1333 <div class="small-12 medium-4 columns">1334 <label>Image Description Tag</label>1335 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag">1336 </div>1337 </div>1338 <div class="row">1339 <div class="small-12 medium-4 columns">1340 <label>Section</label>1341 <input data-bind="textInput: section" type="text" placeholder="Section">1342 </div>1343 <div class="small-12 medium-4 columns">1344 <label>Section URL</label>1345 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">1346 </div>1347 <div class="small-12 medium-4 columns">1348 <label>Section Description Tag</label>1349 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>1350 </div>1351 </div>1352 <div class="row">1353 <div class="small-12 medium-4 columns">1354 <label>CTA</label>1355 <input data-bind="textInput: cta" type="text" placeholder="CTA">1356 </div>1357 <div class="small-12 medium-4 columns">1358 <label>CTA URL</label>1359 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1360 </div>1361 <div class="small-12 medium-4 columns">1362 <label>CTA Description Tag</label>1363 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag">1364 </div>1365 </div>1366 </div>1367 </dd>1368 </dl>1369 </div>1370 <div class="small-1 text-center columns removeModule">1371 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1372 </div>1373 </div>1374 </li>`, synchronous: true1375});1376ko.components.register('image-link-double-module', {1377 viewModel: class ImageLinkDoubleModuleComponentModel extends Dependents {1378 constructor(params) {1379 super(params);1380 this.params = params;1381 }1382 },1383 template: `1384 <li class="row" data-bind="componentData, attr: {'id': 'uniqueId-'+uniqueId, 'data-type': 'image-link-double-module' }">1385 <div class="flexContainer">1386 <div class="small-11 columns">1387 <dl class="accordion" data-accordion="" role="tablist">1388 <dd class="accordion-navigation">1389 <a data-bind="text: 'Image Link Double Module', attr: { href: '#accordion-'+uniqueId, id: 'accordion-heading-'+uniqueId, role: 'tab' }"></a>1390 <div data-bind="attr: { id: 'accordion-'+uniqueId, 'aria-labelledby': 'accordion-heading-'+uniqueId, role: 'tabpanel' }" class="content">1391 <div class="row">1392 <div class="small-12 medium-4 columns">1393 <label>Item #</label>1394 <input data-bind="textInput: itemNumber" type="text" placeholder="Item #">1395 </div>1396 <div class="small-12 medium-4 columns">1397 <label>Item URL</label>1398 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL">1399 </div>1400 <div class="small-12 medium-4 columns">1401 <label>Display Module On</label>1402 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>1403 </div>1404 </div>1405 <div class="row">1406 <div class="small-12 medium-4 columns">1407 <label>Small Image URL</label>1408 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL">1409 </div>1410 <div class="small-12 medium-4 columns">1411 <label>Large Image URL</label>1412 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL">1413 </div>1414 <div class="small-12 medium-4 columns">1415 <label>Image Description Tag</label>1416 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag">1417 </div>1418 </div>1419 <div class="row">1420 <div class="small-12 medium-4 columns">1421 <label>Section</label>1422 <input data-bind="textInput: section" type="text" placeholder="Section">1423 </div>1424 <div class="small-12 medium-4 columns">1425 <label>Section URL</label>1426 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">1427 </div>1428 <div class="small-12 medium-4 columns">1429 <label>Section Description Tag</label>1430 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>1431 </div>1432 </div>1433 <div class="row">1434 <div class="small-12 medium-4 columns">1435 <label>CTA</label>1436 <input data-bind="textInput: cta" type="text" placeholder="CTA">1437 </div>1438 <div class="small-12 medium-4 columns">1439 <label>CTA URL</label>1440 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1441 </div>1442 <div class="small-12 medium-4 columns">1443 <label>CTA Description Tag</label>1444 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag">1445 </div>1446 </div>1447 </div>1448 </dd>1449 </dl>1450 </div>1451 <div class="small-1 text-center columns removeModule">1452 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1453 </div>1454 </div>1455 </li>`, synchronous: true1456});1457ko.components.register('button-link-double-module', {1458 viewModel: class ButtonLinkDoubleModuleComponentModel extends Dependents {1459 constructor(params) {1460 super(params);1461 this.params = params;1462 }1463 },1464 template: `1465 <li class="row" data-bind="componentData, attr: {'id': 'uniqueId-'+uniqueId, 'data-type': 'button-link-double-module' }">1466 <div class="flexContainer">1467 <div class="small-11 columns">1468 <dl class="accordion" data-accordion="" role="tablist">1469 <dd class="accordion-navigation">1470 <a data-bind="text: 'Button Link Double Module', attr: { href: '#accordion-'+uniqueId, id: 'accordion-heading-'+uniqueId, role: 'tab' }"></a>1471 <div data-bind="attr: { id: 'accordion-'+uniqueId, 'aria-labelledby': 'accordion-heading-'+uniqueId, role: 'tabpanel' }" class="content">1472 <div class="row">1473 <div class="small-12 medium-4 columns">1474 <label>Item #</label>1475 <input data-bind="textInput: itemNumber" type="text" placeholder="Item #">1476 </div>1477 <div class="small-12 medium-4 columns">1478 <label>Item URL</label>1479 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL">1480 </div>1481 <div class="small-12 medium-4 columns">1482 <label>Display Module On</label>1483 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>1484 </div>1485 </div>1486 <div class="row">1487 <div class="small-12 medium-4 columns">1488 <label>Small Image URL</label>1489 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL">1490 </div>1491 <div class="small-12 medium-4 columns">1492 <label>Large Image URL</label>1493 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL">1494 </div>1495 <div class="small-12 medium-4 columns">1496 <label>Image Description Tag</label>1497 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag">1498 </div>1499 </div>1500 <div class="row">1501 <div class="small-12 medium-4 columns">1502 <label>Section</label>1503 <input data-bind="textInput: section" type="text" placeholder="Section">1504 </div>1505 <div class="small-12 medium-4 columns">1506 <label>Section URL</label>1507 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">1508 </div>1509 <div class="small-12 medium-4 columns">1510 <label>Section Description Tag</label>1511 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>1512 </div>1513 </div>1514 <div class="row">1515 <div class="small-12 medium-4 columns">1516 <label>CTA</label>1517 <input data-bind="textInput: cta" type="text" placeholder="CTA">1518 </div>1519 <div class="small-12 medium-4 columns">1520 <label>CTA URL</label>1521 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1522 </div>1523 <div class="small-12 medium-4 columns">1524 <label>CTA Description Tag</label>1525 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag">1526 </div>1527 </div>1528 </div>1529 </dd>1530 </dl>1531 </div>1532 <div class="small-1 text-center columns removeModule">1533 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1534 </div>1535 </div>1536 </li>`, synchronous: true1537});1538ko.components.register('seo-link-module', {1539 viewModel: class SeoLinkModuleComponentModel extends Dependents {1540 constructor(params) {1541 super(params);1542 this.params = params;1543 }1544 },1545 template: `1546 <li class="row" data-bind="componentData, attr: {'id': 'uniqueId-'+uniqueId, 'data-type': 'seo-link-module' }">1547 <div class="flexContainer">1548 <div class="small-11 columns">1549 <dl class="accordion" data-accordion="" role="tablist">1550 <dd class="accordion-navigation">1551 <a data-bind="text: 'SEO Links Module', attr: { href: '#accordion-'+uniqueId, id: 'accordion-heading-'+uniqueId, role: 'tab' }"></a>1552 <div data-bind="attr: { id: 'accordion-'+uniqueId, 'aria-labelledby': 'accordion-heading-'+uniqueId, role: 'tabpanel' }" class="content">1553 <div class="row">1554 <div class="small-12 columns">1555 <h3>TL SEO 1</h3>1556 </div>1557 </div>1558 <div class="row">1559 <div class="small-12 medium-4 columns">1560 <label>Section</label>1561 <input data-bind="textInput: seo1Section" type="text" placeholder="Section">1562 </div>1563 <div class="small-12 medium-4 columns">1564 <label>Section URL</label>1565 <input data-bind="textInput: seo1SectionUrl" type="text" placeholder="Section URL">1566 </div>1567 <div class="small-12 medium-4 columns">1568 <label>Section Description Tag</label>1569 <input data-bind="textInput: seo1SectionDescription" type="text" placeholder="Section Description Tag"></input>1570 </div>1571 </div>1572 <div class="row">1573 <div class="small-12 medium-4 columns">1574 <label>CTA</label>1575 <textarea rows="4" type="text" placeholder="CTA" data-bind="textInput: seo1cta"></textarea>1576 </div>1577 <div class="small-12 medium-4 columns">1578 <label>CTA URL</label>1579 <textarea rows="4" type="text" placeholder="CTA URL" data-bind="textInput: seo1ctaUrl"></textarea>1580 </div>1581 <div class="small-12 medium-4 columns">1582 <label>CTA Description Tag</label>1583 <textarea rows="4" type="text" placeholder="CTA Description Tag" data-bind="textInput: seo1ctaDescription"></textarea>1584 </div>1585 </div>1586 <div class="row">1587 <div class="small-12 columns">1588 <h3>LD SEO 2</h3>1589 </div>1590 </div>1591 <div class="row">1592 <div class="small-12 medium-6 columns">1593 <label>Item #</label>1594 <textarea rows="6" type="text" placeholder="Item #" data-bind="textInput: seo2ItemNumber"></textarea>1595 </div>1596 <div class="small-12 medium-6 columns">1597 <label>Item URL</label>1598 <textarea rows="6" type="text" placeholder="Item URL" data-bind="textInput: seo2ItemUrl"></textarea>1599 </div>1600 </div>1601 <div class="row">1602 <div class="small-12 medium-4 columns">1603 <label>Small Image URL</label>1604 <textarea rows="6" type="text" placeholder="Small Image URL" data-bind="textInput: seo2ImageSmallUrl"></textarea>1605 </div>1606 <div class="small-12 medium-4 columns">1607 <label>Large Image URL</label>1608 <textarea rows="6" type="text" placeholder="Large Image URL" data-bind="textInput: seo2ImageLargeUrl"></textarea>1609 </div>1610 <div class="small-12 medium-4 columns">1611 <label>Image Description Tag</label>1612 <textarea rows="6" type="text" placeholder="Image Description Tag" data-bind="textInput: seo2ImageDescription"></textarea>1613 </div>1614 </div>1615 <div class="row">1616 <div class="small-12 medium-4 columns">1617 <label>Section</label>1618 <input data-bind="textInput: seo2Section" type="text" placeholder="Section">1619 </div>1620 <div class="small-12 medium-4 columns">1621 <label>Section URL</label>1622 <input data-bind="textInput: seo2SectionUrl" type="text" placeholder="Section URL">1623 </div>1624 <div class="small-12 medium-4 columns">1625 <label>Section Description Tag</label>1626 <input data-bind="textInput: seo2SectionDescription" type="text" placeholder="Section Description Tag"></input>1627 </div>1628 </div>1629 <div class="row">1630 <div class="small-12 medium-4 columns">1631 <label>CTA</label>1632 <textarea rows="6" type="text" placeholder="CTA" data-bind="textInput: seo2cta"></textarea>1633 </div>1634 <div class="small-12 medium-4 columns">1635 <label>CTA URL</label>1636 <textarea rows="6" type="text" placeholder="CTA URLL" data-bind="textInput: seo2ctaUrl"></textarea>1637 </div>1638 <div class="small-12 medium-4 columns">1639 <label>CTA Description Tag</label>1640 <textarea rows="6" type="text" placeholder="CTA Description Tag" data-bind="textInput: seo2ctaDescription"></textarea>1641 </div>1642 </div>1643 </div>1644 </dd>1645 </dl>1646 </div>1647 <div class="small-1 text-center columns removeModule">1648 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1649 </div>1650 </div>1651 </li>`, synchronous: true1652});1653function reducerFilter(acc, xs) {1654 xs.map((item, index) => {1655 if (xs[index] === xs[index+1]) {1656 if (xs[index] === 'collection-grid-module' || xs[index] === 'carousel-module') {1657 acc.push(item);1658 } else {1659 acc.push('concat');1660 }1661 } else {1662 acc.push(item);1663 }1664 })1665 // console.log('acc ',acc);1666 return acc;1667}1668//TODO testing new way of rendering modules1669ko.components.register('homePageTool', {1670 viewModel: class HomePageToolComponentModel extends Dependents {1671 constructor(params) {1672 super(params);1673 this.selection = ko.observable();1674 this.selectedModules = ko.observableArray([]);1675 this.date = ko.observable();1676 this.moduleTypes = [1677 {name: 'Large Feature (LF)', value: 'large-feature-module'},1678 {name: 'Small Feature (SF)', value: 'small-feature-module'},1679 {name: 'Basic Story (BS)', value: 'basic-story-module'},1680 {name: 'Extended Story (ES)', value: 'extended-story-module'},1681 {name: 'Collection Grid (CG)', value: 'collection-grid-module'},1682 {name: 'Carousel (CL)', value: 'carousel-module'},1683 {name: 'Text Link (TL)', value: 'text-link-module'},1684 {name: 'Image Link Double (LD)', value: 'image-link-double-module'},1685 {name: 'Button Link Double (BD)', value: 'button-link-double-module'},1686 {name: 'SEO Links (SEO)', value: 'seo-link-module'}1687 ];1688 this.jsonOrder = function(arry, preview) {1689 var alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';1690 var hpJson = {};1691 var hpDate = this.date();1692 arry.forEach((obj, index) => {1693 hpJson[alpha.charAt(index)] = obj;1694 })1695 console.log('jsonOrder ',hpJson)1696 $.ajax({1697 type: "POST",1698 url: "http://localhost:5000/hp_config",1699 data: formToJSON(),1700 dataType: "json",1701 success: function() {1702 if (preview) {1703 window.open('http://localhost:9000/simulator/?date='+hpDate, '_blank');1704 }1705 }1706 }).done(function(msg) {1707 console.log("Data Saved: " + msg);1708 });1709 function formToJSON() {1710 return {1711 "json": hpJson,1712 "date": hpDate1713 };1714 }1715 }1716 this.createModule = function (e) {1717 load = false;1718 this.selectedModules.push(this.selection());1719 }1720 this.previewHomepage = function(e) {1721 //console.log('preview click ',this.mappingOrder);1722 var mappingOrderCopy = JSON.parse(JSON.stringify(this.mappingOrder));1723 var removedUniqueIdJson = {};1724 var duplicateModuleNames = [];1725 var duplicateObjects = [];1726 var concatArray = [];1727 var orderedJson = {};1728 //removes uniqueIds1729 Object.keys(mappingOrderCopy).forEach(function(key) {1730 Object.assign(removedUniqueIdJson, mappingOrderCopy[key]);1731 });1732 Object.keys(removedUniqueIdJson).sort().forEach(function(key,index) {1733 orderedJson[key] = removedUniqueIdJson[key];1734 });1735 Object.keys(orderedJson).forEach(function(key,index) {1736 duplicateModuleNames.push(Object.keys(orderedJson[key])[0]);1737 duplicateObjects.push(orderedJson[key]);1738 });1739 var adjecentCombine = reducerFilter([],duplicateModuleNames);1740 adjecentCombine.forEach((el,index) => {1741 var moduleType = Object.keys(duplicateObjects[index])[0];1742 if (el === 'concat') {1743 duplicateObjects[index+1][moduleType].sections = duplicateObjects[index][moduleType].sections.concat(duplicateObjects[index+1][moduleType].sections);1744 duplicateObjects.splice(index,1,'');1745 }1746 })1747 duplicateObjects = duplicateObjects.filter(function(n){ return n != '' });1748 //console.log('preview duplicateObjects ',duplicateObjects)1749 this.jsonOrder(duplicateObjects, true);1750 }1751 this.saveHomepage = function(e) {1752 var mappingOrderCopy = JSON.parse(JSON.stringify(this.mappingOrder));1753 var removedUniqueIdJson = {};1754 var duplicateModuleNames = [];1755 var duplicateObjects = [];1756 var concatArray = [];1757 var orderedJson = {};1758 //removes uniqueIds1759 Object.keys(mappingOrderCopy).forEach(function(key) {1760 Object.assign(removedUniqueIdJson, mappingOrderCopy[key]);1761 });1762 Object.keys(removedUniqueIdJson).sort().forEach(function(key,index) {1763 orderedJson[key] = removedUniqueIdJson[key];1764 });1765 Object.keys(orderedJson).forEach(function(key,index) {1766 duplicateModuleNames.push(Object.keys(orderedJson[key])[0]);1767 duplicateObjects.push(orderedJson[key]);1768 });1769 var adjecentCombine = reducerFilter([],duplicateModuleNames);1770 adjecentCombine.forEach((el,index) => {1771 var moduleType = Object.keys(duplicateObjects[index])[0];1772 if (el === 'concat') {1773 duplicateObjects[index+1][moduleType].sections = duplicateObjects[index][moduleType].sections.concat(duplicateObjects[index+1][moduleType].sections);1774 duplicateObjects.splice(index,1,'');1775 }1776 })1777 duplicateObjects = duplicateObjects.filter(function(n){ return n != '' });1778 //console.log('save duplicateObjects ',duplicateObjects)1779 this.jsonOrder(duplicateObjects, false);1780 }1781 this.reRender = function renderLoadedJson() {1782 this.selectedModules.removeAll();1783 counter = 0;1784 Object.keys(mappingOrder).forEach((letter, i) => {1785 Object.keys(mappingOrder[letter]).forEach((module, index) => {1786 if (module === 'collection-grid-module' || module === 'carousel-module' || module === 'seo-link-module') {1787 counter ++;1788 } else {1789 counter += mappingOrder[letter][module]['sections'].length;1790 }1791 })1792 })1793 Object.keys(mappingOrder).forEach((letter, i) => {1794 Object.keys(mappingOrder[letter]).forEach((module, index) => {1795 switch (module) {1796 case 'large-feature-module':1797 var sectionsArry = mappingOrder[letter][module].sections;1798 sectionsArry.forEach((el,index) => {1799 this.selectedModules.push(module);1800 })1801 break1802 case 'small-feature-module':1803 var sectionsArry = mappingOrder[letter][module].sections;1804 sectionsArry.forEach((el,index) => {1805 this.selectedModules.push(module);1806 })1807 break1808 case 'basic-story-module':1809 var sectionsArry = mappingOrder[letter][module].sections;1810 sectionsArry.forEach((el,index) => {1811 this.selectedModules.push(module);1812 })1813 break1814 case 'extended-story-module':1815 var sectionsArry = mappingOrder[letter][module].sections;1816 sectionsArry.forEach((el,index) => {1817 this.selectedModules.push(module);1818 })1819 break1820 case 'collection-grid-module':1821 this.selectedModules.push(module);1822 break1823 case 'carousel-module':1824 this.selectedModules.push(module);1825 break1826 case 'text-link-module':1827 var sectionsArry = mappingOrder[letter][module].sections;1828 sectionsArry.forEach((el,index) => {1829 this.selectedModules.push(module);1830 })1831 break1832 case 'image-link-double-module':1833 var sectionsArry = mappingOrder[letter][module].sections;1834 sectionsArry.forEach((el,index) => {1835 this.selectedModules.push(module);1836 })1837 break1838 case 'button-link-double-module':1839 var sectionsArry = mappingOrder[letter][module].sections;1840 sectionsArry.forEach((el,index) => {1841 this.selectedModules.push(module);1842 })1843 break1844 case 'seo-link-module':1845 this.selectedModules.push(module);1846 break1847 }1848 })1849 })1850 //console.log('mappingOrder ',mappingOrder)1851 };1852 this.loadHomePage = function(e) {1853 var loadDate = this.date();1854 var self = this;1855 load = true;1856 this.loadingModelData.removeAll();1857 $.ajax({1858 type: "GET",1859 url: "http://localhost:5000/hp_config/"+loadDate+".js",1860 success: function(data) {1861 var clearModules = [];1862 clearModules = Array.from(document.getElementById('sortableContainer').querySelectorAll('li'));1863 clearModules.forEach((el, index)=> {1864 ko.removeNode(el);1865 delete self.mappingOrder[el.getAttribute('id').split('-')[1]];1866 })1867 self.reRender();1868 },1869 error: function(jqXHR, status, error){1870 if (jqXHR.status === 404) {1871 alert('No data found for '+loadDate+'');1872 }1873 }1874 })1875 }1876 this.createNewHomePage = function(e) {1877 window.location.reload();1878 }1879 ko.bindingHandlers.datepicker = {1880 init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {1881 var d = new Date();1882 d.setHours(0, -d.getTimezoneOffset(), 0, 0); //removing the timezone offset.1883 viewModel.date(d.toISOString().slice(0,10));1884 $(function () {1885 $('#dp1').fdatepicker({1886 initialDate: 'yyyy-mm-dd',1887 format: 'yyyy-mm-dd',1888 disableDblClickSelection: true1889 }).on('changeDate', function (ev) {1890 viewModel.date(ev.date.toISOString().slice(0,10));1891 })1892 })1893 }1894 }1895 ko.bindingHandlers.sortable = {1896 init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {1897 $( function() {1898 $( "#sortableContainer" ).sortable({1899 axis: "y",1900 update: function(event, ui) {1901 var childElements = element.querySelectorAll("li");1902 var elementOrderArry = [];1903 var uniqueIdOrderArry = [];1904 childElements.forEach((item, index) => {1905 elementOrderArry.push(item.dataset.type);1906 uniqueIdOrderArry.push(ko.dataFor(item).uniqueId);1907 })1908 viewModel.uniqueIdModified(uniqueIdOrderArry);1909 viewModel.sortMappingOrder();1910 }1911 });1912 });1913 }1914 };1915 }1916 },1917 template: `1918 <div class='row'>1919 <div class='small-12 columns'>1920 <h2>Create Home Page Tool</h2>1921 </div>1922 </div>1923 <div class="row">1924 <div class="small-2 columns calIcon">1925 <span class="prefix"><i class="fa fa-calendar"></i></span>1926 </div>1927 <div class="small-2 end columns calInput">1928 <input type="text" class="span2" id="dp1" data-bind="datepicker">1929 </div>1930 </div>1931 <div class="row">1932 <div class="small-12 columns">1933 <button data-bind="event:{ click: createNewHomePage }">Create New Home Page</button>1934 <button data-bind="event:{ click: loadHomePage }">Load Home Page</button>1935 <button data-bind="event:{ click: previewHomepage }">Preview Home Page</button>1936 </div>1937 <div class="small-4 columns end">1938 <select data-bind="options: moduleTypes, value: selection ,optionsText: 'name', optionsValue: 'value', optionsCaption: 'Choose Module Type'"></select>1939 </div>1940 <div class="small-8 columns end">1941 <button data-bind="event:{ click: createModule }">Create Module</button>1942 <button data-bind="event:{ click: saveHomepage }">Save</button>1943 </div>1944 </div>1945 <ul data-bind="foreach: selectedModules(), sortable" id="sortableContainer">1946 <!-- ko component: {name: $data, params: { data: $parent }} --><!-- /ko -->1947 </ul>`, synchronous: true1948});...

Full Screen

Full Screen

backupHpTool.js

Source:backupHpTool.js Github

copy

Full Screen

1var mappingOrder = {};2var initViewModels = [];3var load = false;4var counter = 0;5class Dependents {6 constructor(params) {7 this.loadingModelData = ko.observableArray().extend({ deferred: true });8 this.itemNumber = ko.observable("");9 this.itemUrl = ko.observable("");10 this.imageSmallUrl = ko.observable("");11 this.imageLargeUrl = ko.observable("");12 this.imageDescription = ko.observable("");13 this.headline = ko.observable("");14 this.headlineUrl = ko.observable("");15 this.headlineDescription = ko.observable("");16 this.copy = ko.observable("");17 this.copyUrl = ko.observable("");18 this.copyDescription = ko.observable("");19 this.cta = ko.observable("");20 this.ctaUrl = ko.observable("");21 this.ctaDescription = ko.observable("");22 this.section = ko.observable("");23 this.sectionUrl = ko.observable("");24 this.sectionDescription = ko.observable("");25 this.seo1Section = ko.observable("");26 this.seo1SectionUrl = ko.observable("");27 this.seo1SectionDescription = ko.observable("");28 this.seo1cta = ko.observable("");29 this.seo1ctaUrl = ko.observable("");30 this.seo1ctaDescription = ko.observable("");31 this.seo2Section = ko.observable("");32 this.seo2SectionUrl = ko.observable("");33 this.seo2SectionDescription = ko.observable("");34 this.seo2cta = ko.observable("");35 this.seo2ctaUrl = ko.observable("");36 this.seo2ctaDescription = ko.observable("");37 this.seo2ItemNumber = ko.observable("");38 this.seo2ItemUrl = ko.observable("");39 this.seo2ImageSmallUrl = ko.observable("");40 this.seo2ImageLargeUrl = ko.observable("");41 this.seo2ImageDescription = ko.observable("");42 this.seo2cta = ko.observable("");43 this.seo2ctaUrl = ko.observable("");44 this.seo2ctaDescription = ko.observable("");45 this.moduleType = ko.observable("");46 this.displayModuleOn = ko.observable("");47 this.screenSizes = ko.observableArray(['small', 'medium', 'large', 'xlarge']);48 this.selectedGroupScreenSize = ko.observable('small');49 this.selectedModuleScreenSize = ko.observable('small');50 this.alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';51 this.mappingOrder = {};52 this.uniqueIdModified = ko.observable("");53 this.uniqueId = new Date().getTime();54 this.sortMappingOrder = function() {55 var uniqueIdReordered = this.uniqueIdModified();56 // console.log('uniqueIdReordered ',uniqueIdReordered)57 // console.log('selectedModules before ',this.selectedModules());58 // function reorderAlpha(obj, curr, updated) {59 // var jsonString = JSON.stringify(obj);60 // jsonString = jsonString.replace(curr, updated);61 // var jsonObj = JSON.parse(jsonString);62 // return jsonObj;63 // };64 uniqueIdReordered.forEach((el,index) => {65 var alphaChar = this.alpha.charAt(index);66 // if (Object.keys(this.mappingOrder[el]) != alphaChar) {67 // var curr = Object.keys(this.mappingOrder[el])[0];68 // this.mappingOrder[el] = reorderAlpha(this.mappingOrder[el],curr, alphaChar);69 // }70 if (Object.keys(this.mappingOrder[el])[0] != index) {71 var jsonString = JSON.stringify(this.mappingOrder[el]);72 var replaceVal = Object.keys(this.mappingOrder[el])[0];73 jsonString = jsonString.replace(RegExp(replaceVal), index);74 this.mappingOrder[el] = JSON.parse(jsonString);75 }76 });77 var mappingOrderCopy = this.mappingOrder;78 var removedUniqueIdJson = {};79 var tempArry = [];80 Object.keys(mappingOrderCopy).forEach(function(key) {81 Object.assign(removedUniqueIdJson, mappingOrderCopy[key]);82 })83 Object.keys(removedUniqueIdJson).forEach(function(key,index) {84 tempArry.push(Object.keys(removedUniqueIdJson[key])[0])85 });86 //this.selectedModules(tempArry);87 // tempArry.forEach((ordered, index) => {88 // if (this.selectedModules()[index] != ordered) {89 // this.selectedModules()[index] = ordered;90 // }91 // })92 //console.log('after selectedModules ',this.selectedModules());93 }94 this.removeModule = function(e) {95 var container = document.getElementById(e.uniqueId);96 var removeIndex = this.params.data.selectedModules().indexOf(ko.contextFor(container).$parent);97 this.params.data.selectedModules().splice(removeIndex, 1)98 ko.removeNode(container);99 delete this.params.data.mappingOrder[e.uniqueId];100 }101 this.bindingHandlers = {102 init: $(function () {103 $(document).foundation({104 accordion: {105 content_class: 'content', // specify the class used for active (or open) accordion panels106 active_class: 'active', // allow multiple accordion panels to be active at the same time107 multi_expand: false, // allow accordion panels to be closed by clicking on their headers108 toggleable: true109 }110 });111 })112 };113 ko.bindingHandlers.sortable = {114 init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {115 if (Object.keys(mappingOrder).length != 0 && load === true) {116 viewModel.params.data.loadingModelData.push(bindingContext);117 if (counter === viewModel.params.data.selectedModules().length) {118 var alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';119 //groups modules that are the same and next to each other into array120 var result = viewModel.params.data.loadingModelData().reduce(function(prev, curr) {121 if (prev.length && curr.$parent === prev[prev.length - 1][0].$parent) {122 if (curr.$parent === 'collection-grid-module' || curr.$parent === 'carousel-module' || curr.$parent === 'seo-link-module') {123 prev.push([curr]);124 } else {125 prev[prev.length - 1].push(curr);126 }127 }128 else {129 prev.push([curr]);130 }131 return prev;132 }, []);133 result.forEach((section, index) => {134 var alphaChar = alpha.charAt(index);135 var moduleType = section[0].$parent;136 section.forEach((binding,i) => {137 switch (binding.$parent) {138 case 'text-link-module':139 binding.$data.section(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.text : '');140 binding.$data.sectionUrl(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.link : '');141 binding.$data.sectionDescription(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.description : '');142 binding.$data.itemNumber(!!mappingOrder[alphaChar][moduleType]['sections'][i].item ? mappingOrder[alphaChar][moduleType]['sections'][i].item : '');143 binding.$data.itemUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.link : '');144 binding.$data.selectedModuleScreenSize(!!mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn ? mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn : '');145 binding.$data.imageSmallUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.small : '');146 binding.$data.imageLargeUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.large : '');147 binding.$data.imageDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.description : '');148 binding.$data.cta(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.text : '');149 binding.$data.ctaUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.link : '');150 binding.$data.ctaDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.description : '');151 break;152 case 'image-link-double-module':153 binding.$data.section(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.text : '');154 binding.$data.sectionUrl(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.link : '');155 binding.$data.sectionDescription(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.description : '');156 binding.$data.itemNumber(!!mappingOrder[alphaChar][moduleType]['sections'][i].item ? mappingOrder[alphaChar][moduleType]['sections'][i].item : '');157 binding.$data.itemUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.link : '');158 binding.$data.selectedModuleScreenSize(!!mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn ? mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn : '');159 binding.$data.imageSmallUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.small : '');160 binding.$data.imageLargeUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.large : '');161 binding.$data.imageDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.description : '');162 binding.$data.cta(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.text : '');163 binding.$data.ctaUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.link : '');164 binding.$data.ctaDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.description : '');165 break;166 case 'button-link-double-module':167 binding.$data.section(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.text : '');168 binding.$data.sectionUrl(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.link : '');169 binding.$data.sectionDescription(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.description : '');170 binding.$data.itemNumber(!!mappingOrder[alphaChar][moduleType]['sections'][i].item ? mappingOrder[alphaChar][moduleType]['sections'][i].item : '');171 binding.$data.itemUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.link : '');172 binding.$data.selectedModuleScreenSize(!!mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn ? mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn : '');173 binding.$data.imageSmallUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.small : '');174 binding.$data.imageLargeUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.large : '');175 binding.$data.imageDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.description : '');176 binding.$data.cta(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.text : '');177 binding.$data.ctaUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.link : '');178 binding.$data.ctaDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.description : '');179 break;180 case 'collection-grid-module':181 binding.$data.selectedModuleScreenSize(!!mappingOrder[alphaChar][moduleType].displayModuleOn ? mappingOrder[alphaChar][moduleType].displayModuleOn : '');182 binding.$data.section(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.text : '');183 binding.$data.sectionUrl(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.link : '');184 binding.$data.sectionDescription(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.description : '');185 binding.$data.headline(!!mappingOrder[alphaChar][moduleType].headline ? mappingOrder[alphaChar][moduleType].headline.text : '');186 binding.$data.headlineUrl(!!mappingOrder[alphaChar][moduleType].headline ? mappingOrder[alphaChar][moduleType].headline.link : '');187 binding.$data.headlineDescription(!!mappingOrder[alphaChar][moduleType].headline ? mappingOrder[alphaChar][moduleType].headline.description : '');188 binding.$data.cta(!!mappingOrder[alphaChar][moduleType].cta ? mappingOrder[alphaChar][moduleType].cta.text : '');189 binding.$data.ctaUrl(!!mappingOrder[alphaChar][moduleType].cta ? mappingOrder[alphaChar][moduleType].cta.link : '');190 binding.$data.ctaDescription(!!mappingOrder[alphaChar][moduleType].cta ? mappingOrder[alphaChar][moduleType].cta.description : '');191 var itemNumbers = [];192 var itemUrls = [];193 var smallImageUrls = [];194 var largeImageUrls = [];195 var imageDescriptions = [];196 if (mappingOrder[alphaChar][moduleType]['sections'] != undefined) {197 mappingOrder[alphaChar][moduleType]['sections'].forEach((item, index) => {198 itemNumbers.push(item.item);199 itemUrls.push(item.image.link);200 smallImageUrls.push(item.image.customImage.small);201 largeImageUrls.push(item.image.customImage.large);202 imageDescriptions.push(item.image.description);203 })204 itemNumbers = itemNumbers.join("\n");205 itemUrls = itemUrls.join("\n");206 smallImageUrls = smallImageUrls.join("\n");207 largeImageUrls = largeImageUrls.join("\n");208 imageDescriptions = imageDescriptions.join("\n");209 binding.$data.itemNumber(itemNumbers ? itemNumbers : '');210 binding.$data.itemUrl(itemUrls ? itemUrls : '');211 binding.$data.imageSmallUrl(smallImageUrls ? smallImageUrls : '');212 binding.$data.imageLargeUrl(largeImageUrls ? largeImageUrls : '');213 binding.$data.imageDescription(imageDescriptions ? imageDescriptions : '');214 }215 break;216 case 'carousel-module':217 binding.$data.selectedModuleScreenSize(!!mappingOrder[alphaChar][moduleType].displayModuleOn ? mappingOrder[alphaChar][moduleType].displayModuleOn : '');218 binding.$data.section(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.text : '');219 binding.$data.sectionUrl(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.link : '');220 binding.$data.sectionDescription(!!mappingOrder[alphaChar][moduleType].section ? mappingOrder[alphaChar][moduleType].section.description : '');221 binding.$data.headline(!!mappingOrder[alphaChar][moduleType].headline ? mappingOrder[alphaChar][moduleType].headline.text : '');222 binding.$data.headlineUrl(!!mappingOrder[alphaChar][moduleType].headline ? mappingOrder[alphaChar][moduleType].headline.link : '');223 binding.$data.headlineDescription(!!mappingOrder[alphaChar][moduleType].headline ? mappingOrder[alphaChar][moduleType].headline.description : '');224 binding.$data.cta(!!mappingOrder[alphaChar][moduleType].cta ? mappingOrder[alphaChar][moduleType].cta.text : '');225 binding.$data.ctaUrl(!!mappingOrder[alphaChar][moduleType].cta ? mappingOrder[alphaChar][moduleType].cta.link : '');226 binding.$data.ctaDescription(!!mappingOrder[alphaChar][moduleType].cta ? mappingOrder[alphaChar][moduleType].cta.description : '');227 var itemNumbers = [];228 var itemUrls = [];229 var smallImageUrls = [];230 var largeImageUrls = [];231 var imageDescriptions = [];232 if (mappingOrder[alphaChar][moduleType]['sections'] != undefined) {233 mappingOrder[alphaChar][moduleType]['sections'].forEach((item, index) => {234 itemNumbers.push(item.item);235 itemUrls.push(item.image.link);236 smallImageUrls.push(item.image.customImage.small);237 largeImageUrls.push(item.image.customImage.large);238 imageDescriptions.push(item.image.description);239 })240 itemNumbers = itemNumbers.join("\n");241 itemUrls = itemUrls.join("\n");242 smallImageUrls = smallImageUrls.join("\n");243 largeImageUrls = largeImageUrls.join("\n");244 imageDescriptions = imageDescriptions.join("\n");245 binding.$data.itemNumber(itemNumbers ? itemNumbers : '');246 binding.$data.itemUrl(itemUrls ? itemUrls : '');247 binding.$data.imageSmallUrl(smallImageUrls ? smallImageUrls : '');248 binding.$data.imageLargeUrl(largeImageUrls ? largeImageUrls : '');249 binding.$data.imageDescription(imageDescriptions ? imageDescriptions : '');250 }251 break;252 case 'seo-link-module':253 binding.$data.seo1Section(!!mappingOrder[alphaChar][moduleType]['seo1'].section ? mappingOrder[alphaChar][moduleType]['seo1'].section.text : '');254 binding.$data.seo1SectionUrl(!!mappingOrder[alphaChar][moduleType]['seo1'].section ? mappingOrder[alphaChar][moduleType]['seo1'].section.link : '');255 binding.$data.seo1SectionDescription(!!mappingOrder[alphaChar][moduleType]['seo1'].section ? mappingOrder[alphaChar][moduleType]['seo1'].section.description : '');256 binding.$data.seo2Section(!!mappingOrder[alphaChar][moduleType]['seo2'].section ? mappingOrder[alphaChar][moduleType]['seo2'].section.text : '');257 binding.$data.seo2SectionUrl(!!mappingOrder[alphaChar][moduleType]['seo2'].section ? mappingOrder[alphaChar][moduleType]['seo2'].section.link : '');258 binding.$data.seo2SectionDescription(!!mappingOrder[alphaChar][moduleType]['seo2'].section ? mappingOrder[alphaChar][moduleType]['seo2'].section.description : '');259 var seo1_cta_text = [];260 var seo1_cta_link = [];261 var seo1_cta_description = [];262 var seo2_cta_text = [];263 var seo2_cta_link = [];264 var seo2_cta_description = [];265 var seo2_items = [];266 var seo2_items_urls = [];267 var seo2_small_images = [];268 var seo2_large_images = [];269 var seo2_image_descriptions = [];270 if (mappingOrder[alphaChar][moduleType]['seo1']['sections'] != undefined) {271 mappingOrder[alphaChar][moduleType]['seo1']['sections'].forEach((item, index) => {272 seo1_cta_text.push(item.cta.text);273 seo1_cta_link.push(item.cta.link);274 seo1_cta_description.push(item.cta.description);275 });276 }277 if (mappingOrder[alphaChar][moduleType]['seo2']['sections'] != undefined) {278 mappingOrder[alphaChar][moduleType]['seo2']['sections'].forEach((item, index) => {279 seo2_cta_text.push(item.cta.text);280 seo2_cta_link.push(item.cta.link);281 seo2_cta_description.push(item.cta.description);282 seo2_items.push(item.item);283 seo2_items_urls.push(item.image.link);284 seo2_small_images.push(item.image.customImage.small);285 seo2_large_images.push(item.image.customImage.large);286 seo2_image_descriptions.push(item.image.description);287 });288 }289 seo1_cta_text = seo1_cta_text.join("\n");290 seo1_cta_link = seo1_cta_link.join("\n");291 seo1_cta_description = seo1_cta_description.join("\n");292 seo2_cta_text = seo2_cta_text.join("\n");293 seo2_cta_link = seo2_cta_link.join("\n");294 seo2_cta_description = seo2_cta_description.join("\n");295 seo2_items = seo2_items.join("\n");296 seo2_items_urls = seo2_items_urls.join("\n");297 seo2_small_images = seo2_small_images.join("\n");298 seo2_large_images = seo2_large_images.join("\n");299 seo2_image_descriptions = seo2_image_descriptions.join("\n");300 binding.$data.seo1cta(seo1_cta_text ? seo1_cta_text : '');301 binding.$data.seo1ctaUrl(seo1_cta_link ? seo1_cta_link : '');302 binding.$data.seo1ctaDescription(seo1_cta_description ? seo1_cta_description : '');303 binding.$data.seo2cta(seo2_cta_text ? seo2_cta_text : '');304 binding.$data.seo2ctaUrl(seo2_cta_link ? seo2_cta_link : '');305 binding.$data.seo2ctaDescription(seo2_cta_description ? seo2_cta_description : '');306 binding.$data.seo2ItemNumber(seo2_items ? seo2_items : '');307 binding.$data.seo2ItemUrl(seo2_items_urls ? seo2_items_urls : '');308 binding.$data.seo2ImageSmallUrl(seo2_small_images ? seo2_small_images : '');309 binding.$data.seo2ImageLargeUrl(seo2_large_images ? seo2_large_images : '');310 binding.$data.seo2ImageDescription(seo2_image_descriptions ? seo2_image_descriptions : '');311 break;312 default:313 binding.$data.section(!!mappingOrder[alphaChar][moduleType]['sections'][i].section ? mappingOrder[alphaChar][moduleType]['sections'][i].section.text : '');314 binding.$data.sectionUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].section ? mappingOrder[alphaChar][moduleType]['sections'][i].section.link : '');315 binding.$data.sectionDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].section ? mappingOrder[alphaChar][moduleType]['sections'][i].section.description : '');316 binding.$data.itemNumber(!!mappingOrder[alphaChar][moduleType]['sections'][i].item ? mappingOrder[alphaChar][moduleType]['sections'][i].item : '');317 binding.$data.itemUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.link : '');318 binding.$data.selectedModuleScreenSize(!!mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn ? mappingOrder[alphaChar][moduleType]['sections'][i].displayModuleOn : '');319 binding.$data.imageSmallUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.small : '');320 binding.$data.imageLargeUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.customImage.large : '');321 binding.$data.imageDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].image ? mappingOrder[alphaChar][moduleType]['sections'][i].image.description : '');322 binding.$data.headline(!!mappingOrder[alphaChar][moduleType]['sections'][i].headline ? mappingOrder[alphaChar][moduleType]['sections'][i].headline.text : '');323 binding.$data.headlineUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].headline ? mappingOrder[alphaChar][moduleType]['sections'][i].headline.link : '');324 binding.$data.headlineDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].headline ? mappingOrder[alphaChar][moduleType]['sections'][i].headline.description : '');325 binding.$data.copy(!!mappingOrder[alphaChar][moduleType]['sections'][i].copy ? mappingOrder[alphaChar][moduleType]['sections'][i].copy.text : '');326 binding.$data.copyUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].copy ? mappingOrder[alphaChar][moduleType]['sections'][i].copy.link : '');327 binding.$data.copyDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].copy ? mappingOrder[alphaChar][moduleType]['sections'][i].copy.description : '');328 binding.$data.cta(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.text : '');329 binding.$data.ctaUrl(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.link : '');330 binding.$data.ctaDescription(!!mappingOrder[alphaChar][moduleType]['sections'][i].cta ? mappingOrder[alphaChar][moduleType]['sections'][i].cta.description : '');331 }332 })333 })334 }335 }336 },337 update: function(element, valueAccessor, allBindings, viewModel, bindingContext) {338 var el = document.getElementById('sortableContainer');339 var sortable = new Sortable(el, {340 // group: "name", // or { name: "...", pull: [true, false, clone], put: [true, false, array] }341 disabled: false,342 sort: true, // sorting inside list343 delay: 0, // time in milliseconds to define when the sorting should start344 animation: 150, // ms, animation speed moving items when sorting, `0` — without animation345 handle: ".draggable", // Drag handle selector within list items346 filter: ".ignore-elements", // Selectors that do not lead to dragging (String or Function)347 ghostClass: "sortable-ghost", // Class name for the drop placeholder348 dataIdAttr: 'data-id',349 forceFallback: true,350 fallbackClass: 'fallback',351 // // dragging started352 onStart: function (evt) {353 var elements = document.querySelectorAll('.active');354 elements.forEach((el, index) => {355 el.className = el.className.replace("active", "");356 })357 },358 // // dragging ended359 onEnd: function (/**Event*/evt) {360 var order = sortable.toArray();361 ko.dataFor(evt.item).params.data.uniqueIdModified(order);362 ko.dataFor(evt.item).params.data.sortMappingOrder();363 var elements = el.querySelectorAll("li");364 elements.forEach((el, index) => {365 if (el.getAttribute("data-type") != viewModel.params.data.selectedModules()[index]) {366 // console.log('reordered ',el.getAttribute("data-type"));367 // console.log('viewModel ',viewModel.params.data.selectedModules()[index]);368 viewModel.params.data.selectedModules()[index] = el.getAttribute("data-type");369 }370 })371 console.log('viewModel ',viewModel.params.data.selectedModules());372 }373 });374 var uniqueId = viewModel.uniqueId;375 // var alphaChar = viewModel.alpha.charAt(viewModel.accordionIndex());376 var alphaChar = el.children.length;377 var accordionIndex = viewModel.accordionIndex;378 var moduleType = bindingContext.$parent;379 viewModel.params.data.mappingOrder[uniqueId] = {};380 viewModel.params.data.mappingOrder[uniqueId][accordionIndex] = {};381 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType] = {};382 switch (moduleType) {383 case 'large-feature-module':384 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['sections'] = [385 {386 'item': viewModel.itemNumber(),387 'displayModuleOn': viewModel.selectedModuleScreenSize(),388 'image': {389 'customImage': {390 "small": viewModel.imageSmallUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim(),391 "large": viewModel.imageLargeUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim()392 },393 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),394 'description': viewModel.imageDescription()395 },396 'headline': {397 'text': viewModel.headline().replace(/é/g, "&#233;"),398 'link': viewModel.headlineUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),399 'description': viewModel.headlineDescription()400 },401 'cta': {402 'text': viewModel.cta().replace(/é/g, "&#233;"),403 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),404 'description': viewModel.ctaDescription()405 }406 }407 ]408 break;409 case 'small-feature-module':410 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['sections'] = [411 {412 'item': viewModel.itemNumber(),413 'displayModuleOn': viewModel.selectedModuleScreenSize(),414 'section': {415 'text': viewModel.section().replace(/é/g, "&#233;"),416 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),417 'description': viewModel.sectionDescription()418 },419 'image': {420 'customImage': {421 "small": viewModel.imageSmallUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim(),422 "large": viewModel.imageLargeUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim()423 },424 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),425 'description': viewModel.imageDescription()426 },427 'headline': {428 'text': viewModel.headline().replace(/é/g, "&#233;"),429 'link': viewModel.headlineUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),430 'description': viewModel.headlineDescription()431 },432 'cta': {433 'text': viewModel.cta().replace(/é/g, "&#233;"),434 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),435 'description': viewModel.ctaDescription()436 }437 }438 ]439 break;440 case 'basic-story-module':441 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['sections'] = [442 {443 'item': viewModel.itemNumber(),444 'displayModuleOn': viewModel.selectedModuleScreenSize(),445 'section': {446 'text': viewModel.section().replace(/é/g, "&#233;"),447 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),448 'description': viewModel.sectionDescription()449 },450 'image': {451 'customImage': {452 "small": viewModel.imageSmallUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim(),453 "large": viewModel.imageLargeUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim()454 },455 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),456 'description': viewModel.imageDescription()457 },458 'headline': {459 'text': viewModel.headline().replace(/é/g, "&#233;"),460 'link': viewModel.headlineUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),461 'description': viewModel.headlineDescription()462 },463 'cta': {464 'text': viewModel.cta().replace(/é/g, "&#233;"),465 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),466 'description': viewModel.ctaDescription()467 }468 }469 ]470 break;471 case 'extended-story-module':472 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['sections'] = [473 {474 'item': viewModel.itemNumber(),475 'displayModuleOn': viewModel.selectedModuleScreenSize(),476 'section': {477 'text': viewModel.section().replace(/é/g, "&#233;"),478 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),479 'description': viewModel.sectionDescription()480 },481 'image': {482 'customImage': {483 "small": viewModel.imageSmallUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim(),484 "large": viewModel.imageLargeUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim()485 },486 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),487 'description': viewModel.imageDescription()488 },489 'headline': {490 'text': viewModel.headline().replace(/é/g, "&#233;"),491 'link': viewModel.headlineUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),492 'description': viewModel.headlineDescription()493 },494 'copy': {495 'text': viewModel.copy().replace(/é/g, "&#233;"),496 'link': viewModel.copyUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),497 'description': viewModel.copyDescription()498 },499 'cta': {500 'text': viewModel.cta().replace(/é/g, "&#233;"),501 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),502 'description': viewModel.ctaDescription()503 }504 }505 ]506 break;507 case 'collection-grid-module':508 var itemsList = viewModel.itemNumber().replace(/\n/g, ',').split(',');509 var itemsUrlList = viewModel.itemUrl().replace(/\n/g, ',').split(',');510 var smallImageList = viewModel.imageSmallUrl().replace(/\n/g, ',').split(',');511 var largeImageList = viewModel.imageLargeUrl().replace(/\n/g, ',').split(',');512 var imageDescriptionList = viewModel.imageDescription().replace(/\n/g, ',').split(',');513 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['section'] = {514 'text': viewModel.section().replace(/é/g, "&#233;"),515 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),516 'description': viewModel.sectionDescription()517 },518 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['headline'] = {519 'text': viewModel.headline().replace(/é/g, "&#233;"),520 'link': viewModel.headlineUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),521 'description': viewModel.headlineDescription()522 },523 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['cta'] = {524 'text': viewModel.cta().replace(/é/g, "&#233;"),525 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),526 'description': viewModel.ctaDescription()527 },528 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['displayModuleOn'] = viewModel.selectedModuleScreenSize(),529 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['sections'] = []530 itemsList.forEach((item, index) => {531 if (item != '') {532 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['sections'].push(533 {534 'item': item.trim(),535 'image': {536 'customImage': {537 'small': smallImageList[index] === undefined ? '' : smallImageList[index].replace(/http:\/\/www.uncommongoods.com/g, "").trim(),538 'large': largeImageList[index] === undefined ? '' : largeImageList[index].replace(/http:\/\/www.uncommongoods.com/g, "").trim()539 },540 'link': itemsUrlList[index] === undefined ? '' : itemsUrlList[index].replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),541 'description': imageDescriptionList[index] === undefined ? '' : imageDescriptionList[index]542 }543 }544 )545 }546 })547 break;548 case 'carousel-module':549 var itemsList = viewModel.itemNumber().replace(/\n/g, ',').split(',');550 var itemsUrlList = viewModel.itemUrl().replace(/\n/g, ',').split(',');551 var smallImageList = viewModel.imageSmallUrl().replace(/\n/g, ',').split(',');552 var largeImageList = viewModel.imageLargeUrl().replace(/\n/g, ',').split(',');553 var imageDescriptionList = viewModel.imageDescription().replace(/\n/g, ',').split(',');554 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['section'] = {555 'text': viewModel.section().replace(/é/g, "&#233;"),556 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),557 'description': viewModel.sectionDescription()558 },559 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['headline'] = {560 'text': viewModel.headline().replace(/é/g, "&#233;"),561 'link': viewModel.headlineUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),562 'description': viewModel.headlineDescription()563 },564 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['cta'] = {565 'text': viewModel.cta().replace(/é/g, "&#233;"),566 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),567 'description': viewModel.ctaDescription()568 },569 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['displayModuleOn'] = viewModel.selectedModuleScreenSize(),570 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['sections'] = []571 itemsList.forEach((item, index) => {572 if (item != '') {573 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['sections'].push(574 {575 'item': item.trim(),576 'image': {577 'customImage': {578 'small': smallImageList[index] === undefined ? '' : smallImageList[index].replace(/http:\/\/www.uncommongoods.com/g, "").trim(),579 'large': largeImageList[index] === undefined ? '' : largeImageList[index].replace(/http:\/\/www.uncommongoods.com/g, "").trim()580 },581 'link': itemsUrlList[index] === undefined ? '' : itemsUrlList[index].replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),582 'description': imageDescriptionList[index] === undefined ? '' : imageDescriptionList[index]583 }584 }585 )586 }587 })588 break;589 case 'text-link-module':590 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['section'] = {591 'text': viewModel.section().replace(/é/g, "&#233;"),592 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),593 'description': viewModel.sectionDescription()594 },595 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['sections'] = [596 {597 'item': viewModel.itemNumber(),598 'displayModuleOn': viewModel.selectedModuleScreenSize(),599 'image': {600 'customImage': {601 "small": viewModel.imageSmallUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim(),602 "large": viewModel.imageLargeUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim()603 },604 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),605 'description': viewModel.imageDescription()606 },607 'cta': {608 'text': viewModel.cta().replace(/é/g, "&#233;"),609 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),610 'description': viewModel.ctaDescription()611 }612 }613 ]614 break;615 case 'image-link-double-module':616 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['section'] = {617 'text': viewModel.section().replace(/é/g, "&#233;"),618 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),619 'description': viewModel.sectionDescription()620 },621 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['sections'] = [622 {623 'item': viewModel.itemNumber(),624 'displayModuleOn': viewModel.selectedModuleScreenSize(),625 'image': {626 'customImage': {627 "small": viewModel.imageSmallUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim(),628 "large": viewModel.imageLargeUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim()629 },630 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),631 'description': viewModel.imageDescription()632 },633 'cta': {634 'text': viewModel.cta().replace(/é/g, "&#233;"),635 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),636 'description': viewModel.ctaDescription()637 }638 }639 ]640 break;641 case 'button-link-double-module':642 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['section'] = {643 'text': viewModel.section().replace(/é/g, "&#233;"),644 'link': viewModel.sectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),645 'description': viewModel.sectionDescription()646 },647 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['sections'] = [648 {649 'item': viewModel.itemNumber(),650 'displayModuleOn': viewModel.selectedModuleScreenSize(),651 'image': {652 'customImage': {653 "small": viewModel.imageSmallUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim(),654 "large": viewModel.imageLargeUrl().replace(/http:\/\/www.uncommongoods.com/g, "").trim()655 },656 'link': viewModel.itemUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),657 'description': viewModel.imageDescription()658 },659 'cta': {660 'text': viewModel.cta().replace(/é/g, "&#233;"),661 'link': viewModel.ctaUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),662 'description': viewModel.ctaDescription()663 }664 }665 ]666 break;667 case 'seo-link-module':668 var seo1ctaList = viewModel.seo1cta().replace(/\n/g, ',').split(',');669 var seo1ctaUrlList = viewModel.seo1ctaUrl().replace(/\n/g, ',').split(',');670 var seo1ctaDescriptionList = viewModel.seo1ctaDescription().replace(/\n/g, ',').split(',');671 var seo2ItemsList = viewModel.seo2ItemNumber().replace(/\n/g, ',').split(',');672 var seo2ItemsUrlList = viewModel.seo2ItemUrl().replace(/\n/g, ',').split(',');673 var seo2SmallImageList = viewModel.seo2ImageSmallUrl().replace(/\n/g, ',').split(',');674 var seo2LargeImageList = viewModel.seo2ImageLargeUrl().replace(/\n/g, ',').split(',');675 var seo2ImageDescriptionList = viewModel.seo2ImageDescription().replace(/\n/g, ',').split(',');676 var seo2ctaList = viewModel.seo2cta().replace(/\n/g, ',').split(',');677 var seo2ctaUrlList = viewModel.seo2ctaUrl().replace(/\n/g, ',').split(',');678 var seo2ctaDescriptionList = viewModel.seo2ctaDescription().replace(/\n/g, ',').split(',');679 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['seo1'] = {}680 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['seo1']['section'] = {681 'text': viewModel.seo1Section().replace(/é/g, "&#233;"),682 'link': viewModel.seo1SectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),683 'description': viewModel.seo1SectionDescription()684 },685 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['seo1']['sections'] = []686 seo1ctaList.forEach((item, index) => {687 if (item != '') {688 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['seo1']['sections'].push(689 {690 'cta': {691 'text': item.trim(),692 'link': seo1ctaUrlList[index] === undefined ? '' : seo1ctaUrlList[index].replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),693 'description': seo1ctaDescriptionList[index] === undefined ? '' : seo1ctaDescriptionList[index]694 }695 }696 )697 }698 })699 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['seo2'] = {}700 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['seo2']['section'] = {701 'text': viewModel.seo2Section().replace(/é/g, "&#233;"),702 'link': viewModel.seo2SectionUrl().replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),703 'description': viewModel.seo2SectionDescription()704 },705 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['seo2']['sections'] = []706 seo2ItemsList.forEach((item, index) => {707 if (item != '') {708 viewModel.params.data.mappingOrder[uniqueId][accordionIndex][moduleType]['seo2']['sections'].push(709 {710 'item': item.trim(),711 'image': {712 'customImage': {713 'small': seo2SmallImageList[index] === undefined ? '' : seo2SmallImageList[index].replace(/http:\/\/www.uncommongoods.com/g, "").trim(),714 'large': seo2LargeImageList[index] === undefined ? '' : seo2LargeImageList[index].replace(/http:\/\/www.uncommongoods.com/g, "").trim()715 },716 'link': seo2ItemsUrlList[index] === undefined ? '' : seo2ItemsUrlList[index].replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),717 'description': seo2ImageDescriptionList[index] === undefined ? '' : seo2ImageDescriptionList[index]718 },719 'cta': {720 'text': seo2ctaList[index] === undefined ? '' : seo2ctaList[index].replace(/é/g, "&#233;").trim(),721 'link': seo2ctaUrlList[index] === undefined ? '' : seo2ctaUrlList[index].replace(/http:\/\/www.uncommongoods.com/g, "").replace(/http:\/\/blog.uncommongoods.com/g, "//blog.uncommongoods.com").replace(/é/g, "e").replace(/\s+/g,""),722 'description': seo2ctaDescriptionList[index] === undefined ? '' : seo2ctaDescriptionList[index]723 }724 }725 )726 }727 })728 break;729 }730 //console.log('mapping ',viewModel.params.data.mappingOrder);731 }732 };733 // ko.bindingHandlers.sortableList = {734 // init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {735 // //return { 'controlsDescendantBindings': true };736 // },737 // update: function(element, valueAccessor, allBindings, viewModel, bindingContext) {738 // // console.log('sortableList ',element);739 // // console.log('sortableList ',viewModel.selectedModules()[0]);740 // if (viewModel.selectedModules().length > 0) {741 // // console.log('sortableList ',viewModel.selectedModules()[viewModel.selectedModules().length - 1]);742 // //$(element).html('<hello></hello>');743 //744 // // var componentName = viewModel.selectedModules()[viewModel.selectedModules().length - 1];745 // // $(element).html('<ug-component></ug-component>');746 // //747 // //748 // // $(element).append($("<hello></hello>"));749 // // console.log($(element))750 // }751 //752 //753 //754 // }755 // }756 }757}758ko.components.register('large-feature-module', {759 viewModel: class LargeFeatureModuleComponentModel extends Dependents {760 constructor(params) {761 super(params);762 this.params = params;763 }764 },765 template: `766 <li class="row module" data-bind="sortable: uniqueId, attr: { 'data-id': uniqueId, id: uniqueId, 'data-type': 'large-feature-module' }">767 <div class="flexContainer">768 <div class="small-11 columns">769 <dl class="accordion" data-accordion="" role="tablist">770 <dd class="accordion-navigation">771 <a class="draggable" data-bind="text: 'Large Feature Module', attr: { href: '#accordion'+uniqueId, id: 'accordion-heading'+uniqueId, role: 'tab' }"></a>772 <div data-bind="attr: { id: 'accordion'+uniqueId, 'aria-labelledby': 'accordion-heading'+uniqueId, role: 'tabpanel' }" class="content">773 <div class="row">774 <div class="small-12 medium-4 columns">775 <label>Item #</label>776 <input data-bind="textInput: itemNumber" type="number" placeholder="Item #"></input>777 </div>778 <div class="small-12 medium-4 columns">779 <label>Item URL</label>780 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL"></input>781 </div>782 <div class="small-12 medium-4 columns">783 <label>Display Module On</label>784 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>785 </div>786 </div>787 <div class="row">788 <div class="small-12 medium-4 columns">789 <label>Small Image URL</label>790 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL"></input>791 </div>792 <div class="small-12 medium-4 columns">793 <label>Large Image URL</label>794 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL"></input>795 </div>796 <div class="small-12 medium-4 columns">797 <label>Image Description Tag</label>798 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag"></input>799 </div>800 </div>801 <div class="row">802 <div class="small-12 medium-4 columns">803 <label>Headline</label>804 <input data-bind="textInput: headline" type="text" placeholder="Headline">805 </div>806 <div class="small-12 medium-4 columns">807 <label>Headline URL</label>808 <input data-bind="textInput: headlineUrl" type="text" placeholder="Headline URL">809 </div>810 <div class="small-12 medium-4 columns">811 <label>Headline Description Tag</label>812 <input data-bind="textInput: headlineDescription" type="text" placeholder="Headline Description Tag"></input>813 </div>814 </div>815 <div class="row">816 <div class="small-12 medium-4 columns">817 <label>CTA</label>818 <input data-bind="textInput: cta" type="text" placeholder="CTA">819 </div>820 <div class="small-12 medium-4 columns">821 <label>CTA URL</label>822 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">823 </div>824 <div class="small-12 medium-4 columns">825 <label>CTA Description Tag</label>826 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag"></input>827 </div>828 </div>829 </div>830 </dd>831 </dl>832 </div>833 <div class="small-1 text-center columns removeModule">834 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>835 </div>836 </div837 </li>`, synchronous: true838});839ko.components.register('small-feature-module', {840 viewModel: class SmallFeatureModuleComponentModel extends Dependents {841 constructor(params) {842 super(params);843 this.params = params;844 }845 },846 template: `847 <li class="row module" data-bind="sortable: uniqueId, attr: { 'data-id': uniqueId, id: uniqueId, 'data-type': 'small-feature-module' }">848 <div class="flexContainer">849 <div class="small-11 columns">850 <dl class="accordion" data-accordion="" role="tablist">851 <dd class="accordion-navigation">852 <a class="draggable" data-bind="text: 'Small Feature Module', attr: { href: '#accordion'+uniqueId, id: 'accordion-heading'+uniqueId, role: 'tab' }"></a>853 <div data-bind="attr: { id: 'accordion'+uniqueId, 'aria-labelledby': 'accordion-heading'+uniqueId, role: 'tabpanel' }" class="content">854 <div class="row">855 <div class="small-12 medium-4 columns">856 <label>Item #</label>857 <input data-bind="textInput: itemNumber" type="text" placeholder="Item #">858 </div>859 <div class="small-12 medium-4 columns">860 <label>Item URL</label>861 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL">862 </div>863 <div class="small-12 medium-4 columns">864 <label>Display Module On</label>865 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>866 </div>867 </div>868 <div class="row">869 <div class="small-12 medium-4 columns">870 <label>Small Image URL</label>871 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL"></input>872 </div>873 <div class="small-12 medium-4 columns">874 <label>Large Image URL</label>875 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL"></input>876 </div>877 <div class="small-12 medium-4 columns">878 <label>Image Description Tag</label>879 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag"></input>880 </div>881 </div>882 <div class="row">883 <div class="small-12 medium-4 columns">884 <label>Section</label>885 <input data-bind="textInput: section" type="text" placeholder="Section">886 </div>887 <div class="small-12 medium-4 columns">888 <label>Section URL</label>889 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">890 </div>891 <div class="small-12 medium-4 columns">892 <label>Section Description Tag</label>893 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>894 </div>895 </div>896 <div class="row">897 <div class="small-12 medium-4 columns">898 <label>Headline</label>899 <input data-bind="textInput: headline" type="text" placeholder="Headline">900 </div>901 <div class="small-12 medium-4 columns">902 <label>Headline URL</label>903 <input data-bind="textInput: headlineUrl" type="text" placeholder="Headline URL">904 </div>905 <div class="small-12 medium-4 columns">906 <label>Headline Description Tag</label>907 <input data-bind="textInput: headlineDescription" type="text" placeholder="Headline Description Tag"></input>908 </div>909 </div>910 <div class="row">911 <div class="small-12 medium-4 columns">912 <label>CTA</label>913 <input data-bind="textInput: cta" type="text" placeholder="CTA">914 </div>915 <div class="small-12 medium-4 columns">916 <label>CTA URL</label>917 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">918 </div>919 <div class="small-12 medium-4 columns">920 <label>CTA Description Tag</label>921 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag"></input>922 </div>923 </div>924 </div>925 </dd>926 </dl>927 </div>928 <div class="small-1 text-center columns removeModule">929 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>930 </div>931 </div>932 </li>`, synchronous: true933});934ko.components.register('basic-story-module', {935 viewModel: class BasicStoryModuleComponentModel extends Dependents {936 constructor(params) {937 super(params);938 this.params = params;939 }940 },941 template: `942 <li class="row module" data-bind="sortable: uniqueId, attr: { 'data-id': uniqueId, id: uniqueId, 'data-type': 'basic-story-module' }">943 <div class="flexContainer">944 <div class="small-11 columns">945 <dl class="accordion" data-accordion="" role="tablist">946 <dd class="accordion-navigation">947 <a class="draggable" data-bind="text: 'Basic Story Module', attr: { href: '#accordion'+uniqueId, id: 'accordion-heading'+uniqueId, role: 'tab' }"></a>948 <div data-bind="attr: { id: 'accordion'+uniqueId, 'aria-labelledby': 'accordion-heading'+uniqueId, role: 'tabpanel' }" class="content">949 <div class="row">950 <div class="small-12 medium-4 columns">951 <label>Item #</label>952 <input data-bind="textInput: itemNumber" type="text" placeholder="Item #">953 </div>954 <div class="small-12 medium-4 columns">955 <label>Item URL</label>956 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL">957 </div>958 <div class="small-12 medium-4 columns">959 <label>Display Module On</label>960 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>961 </div>962 </div>963 <div class="row">964 <div class="small-12 medium-4 columns">965 <label>Small Image URL</label>966 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL"></input>967 </div>968 <div class="small-12 medium-4 columns">969 <label>Large Image URL</label>970 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL"></input>971 </div>972 <div class="small-12 medium-4 columns">973 <label>Image Description Tag</label>974 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag"></input>975 </div>976 </div>977 <div class="row">978 <div class="small-12 medium-4 columns">979 <label>Section</label>980 <input data-bind="textInput: section" type="text" placeholder="Section">981 </div>982 <div class="small-12 medium-4 columns">983 <label>Section URL</label>984 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">985 </div>986 <div class="small-12 medium-4 columns">987 <label>Section Description Tag</label>988 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>989 </div>990 </div>991 <div class="row">992 <div class="small-12 medium-4 columns">993 <label>Headline</label>994 <input data-bind="textInput: headline" type="text" placeholder="Headline">995 </div>996 <div class="small-12 medium-4 columns">997 <label>Headline URL</label>998 <input data-bind="textInput: headlineUrl" type="text" placeholder="Headline URL">999 </div>1000 <div class="small-12 medium-4 columns">1001 <label>Headline Description Tag</label>1002 <input data-bind="textInput: headlineDescription" type="text" placeholder="Headline Description Tag"></input>1003 </div>1004 </div>1005 <div class="row">1006 <div class="small-12 medium-4 columns">1007 <label>CTA</label>1008 <input data-bind="textInput: cta" type="text" placeholder="CTA">1009 </div>1010 <div class="small-12 medium-4 columns">1011 <label>CTA URL</label>1012 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1013 </div>1014 <div class="small-12 medium-4 columns">1015 <label>CTA Description Tag</label>1016 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag"></input>1017 </div>1018 </div>1019 </div>1020 </dd>1021 </dl>1022 </div>1023 <div class="small-1 text-center columns removeModule">1024 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1025 </div>1026 </div1027 </li>`, synchronous: true1028});1029ko.components.register('extended-story-module', {1030 viewModel: class ExtendedStoryModuleComponentModel extends Dependents {1031 constructor(params) {1032 super(params);1033 this.params = params;1034 }1035 },1036 template: `1037 <li class="row module" data-bind="sortable: uniqueId, attr: { 'data-id': uniqueId, id: uniqueId, 'data-type': 'extended-story-module' }">1038 <div class="flexContainer">1039 <div class="small-11 columns">1040 <dl class="accordion" data-accordion="" role="tablist">1041 <dd class="accordion-navigation">1042 <a class="draggable" data-bind="text: 'Extended Story Module', attr: { href: '#accordion'+uniqueId, id: 'accordion-heading'+uniqueId, role: 'tab' }"></a>1043 <div data-bind="attr: { id: 'accordion'+uniqueId, 'aria-labelledby': 'accordion-heading'+uniqueId, role: 'tabpanel' }" class="content">1044 <div class="row">1045 <div class="small-12 medium-4 columns">1046 <label>Item #</label>1047 <input data-bind="textInput: itemNumber" type="text" placeholder="Item #">1048 </div>1049 <div class="small-12 medium-4 columns">1050 <label>Item URL</label>1051 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL">1052 </div>1053 <div class="small-12 medium-4 columns">1054 <label>Display Module On</label>1055 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>1056 </div>1057 </div>1058 <div class="row">1059 <div class="small-12 medium-4 columns">1060 <label>Small Image URL</label>1061 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL"></input>1062 </div>1063 <div class="small-12 medium-4 columns">1064 <label>Large Image URL</label>1065 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL"></input>1066 </div>1067 <div class="small-12 medium-4 columns">1068 <label>Image Description Tag</label>1069 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag"></input>1070 </div>1071 </div>1072 <div class="row">1073 <div class="small-12 medium-4 columns">1074 <label>Section</label>1075 <input data-bind="textInput: section" type="text" placeholder="Section">1076 </div>1077 <div class="small-12 medium-4 columns">1078 <label>Section URL</label>1079 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">1080 </div>1081 <div class="small-12 medium-4 columns">1082 <label>Section Description Tag</label>1083 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>1084 </div>1085 </div>1086 <div class="row">1087 <div class="small-12 medium-4 columns">1088 <label>Headline</label>1089 <input data-bind="textInput: headline" type="text" placeholder="Headline">1090 </div>1091 <div class="small-12 medium-4 columns">1092 <label>Headline URL</label>1093 <input data-bind="textInput: headlineUrl" type="text" placeholder="Headline URL">1094 </div>1095 <div class="small-12 medium-4 columns">1096 <label>Headline Description Tag</label>1097 <input data-bind="textInput: headlineDescription" type="text" placeholder="Headline Description Tag"></input>1098 </div>1099 </div>1100 <div class="row">1101 <div class="small-12 medium-4 columns">1102 <label>Copy</label>1103 <textarea rows="6" type="text" placeholder="Copy" data-bind="textInput: copy"></textarea>1104 </div>1105 <div class="small-12 medium-4 columns">1106 <label>Copy URL</label>1107 <input data-bind="textInput: copyUrl" type="text" placeholder="Copy URL">1108 </div>1109 <div class="small-12 medium-4 columns">1110 <label>Copy Description Tag</label>1111 <input data-bind="textInput: copyDescription" type="text" placeholder="Copy Description Tag"></input>1112 </div>1113 </div>1114 <div class="row">1115 <div class="small-12 medium-4 columns">1116 <label>CTA</label>1117 <input data-bind="textInput: cta" type="text" placeholder="CTA">1118 </div>1119 <div class="small-12 medium-4 columns">1120 <label>CTA URL</label>1121 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1122 </div>1123 <div class="small-12 medium-4 columns">1124 <label>CTA Description Tag</label>1125 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag"></input>1126 </div>1127 </div>1128 </div>1129 </dd>1130 </dl>1131 </div>1132 <div class="small-1 text-center columns removeModule">1133 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1134 </div>1135 </div>1136 </li>`, synchronous: true1137});1138ko.components.register('collection-grid-module', {1139 viewModel: class CollectionGridModuleComponentModel extends Dependents {1140 constructor(params) {1141 super(params);1142 this.params = params;1143 }1144 },1145 template: `1146 <li class="row module" data-bind="sortable: uniqueId, attr: { 'data-id': uniqueId, id: uniqueId, 'data-type': 'collection-grid-module' }">1147 <div class="flexContainer">1148 <div class="small-11 columns">1149 <dl class="accordion" data-accordion="" role="tablist">1150 <dd class="accordion-navigation">1151 <a class="draggable" data-bind="text: 'Collection Grid Module', attr: { href: '#accordion'+uniqueId, id: 'accordion-heading'+uniqueId, role: 'tab' }"></a>1152 <div data-bind="attr: { id: 'accordion'+uniqueId, 'aria-labelledby': 'accordion-heading'+uniqueId, role: 'tabpanel' }" class="content">1153 <div class="row">1154 <div class="small-12 medium-4 columns">1155 <label>Item #</label>1156 <textarea rows="6" type="text" placeholder="Item #" data-bind="textInput: itemNumber"></textarea>1157 </div>1158 <div class="small-12 medium-4 columns">1159 <label>Item URL</label>1160 <textarea rows="6" type="text" placeholder="Item URL" data-bind="textInput: itemUrl"></textarea>1161 </div>1162 <div class="small-12 medium-4 columns">1163 <label>Display Module On</label>1164 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>1165 </div>1166 </div>1167 <div class="row">1168 <div class="small-12 medium-4 columns">1169 <label>Small Image URL</label>1170 <textarea rows="6" type="text" placeholder="Small Image URL" data-bind="textInput: imageSmallUrl"></textarea>1171 </div>1172 <div class="small-12 medium-4 columns">1173 <label>Large Image URL</label>1174 <textarea rows="6" type="text" placeholder="Large Image URL" data-bind="textInput: imageLargeUrl"></textarea>1175 </div>1176 <div class="small-12 medium-4 columns">1177 <label>Image Description Tag</label>1178 <textarea rows="6" type="text" placeholder="Image Description Tag" data-bind="textInput: imageDescription"></textarea>1179 </div>1180 </div>1181 <div class="row">1182 <div class="small-12 medium-4 columns">1183 <label>Section</label>1184 <input data-bind="textInput: section" type="text" placeholder="Section">1185 </div>1186 <div class="small-12 medium-4 columns">1187 <label>Section URL</label>1188 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">1189 </div>1190 <div class="small-12 medium-4 columns">1191 <label>Section Description Tag</label>1192 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>1193 </div>1194 </div>1195 <div class="row">1196 <div class="small-12 medium-4 columns">1197 <label>Headline</label>1198 <input data-bind="textInput: headline" type="text" placeholder="Headline">1199 </div>1200 <div class="small-12 medium-4 columns">1201 <label>Headline URL</label>1202 <input data-bind="textInput: headlineUrl" type="text" placeholder="Headline URL">1203 </div>1204 <div class="small-12 medium-4 columns">1205 <label>Headline Description Tag</label>1206 <input data-bind="textInput: headlineDescription" type="text" placeholder="Headline Description Tag"></input>1207 </div>1208 </div>1209 <div class="row">1210 <div class="small-12 medium-4 columns">1211 <label>CTA</label>1212 <input data-bind="textInput: cta" type="text" placeholder="CTA">1213 </div>1214 <div class="small-12 medium-4 columns">1215 <label>CTA URL</label>1216 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1217 </div>1218 <div class="small-12 medium-4 columns">1219 <label>CTA Description Tag</label>1220 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag"></input>1221 </div>1222 </div>1223 </div>1224 </dd>1225 </dl>1226 </div>1227 <div class="small-1 text-center columns removeModule">1228 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1229 </div>1230 </div>1231 </li>`, synchronous: true1232});1233ko.components.register('carousel-module', {1234 viewModel: class CarouselModuleComponentModel extends Dependents {1235 constructor(params) {1236 super(params);1237 this.params = params;1238 }1239 },1240 template: `1241 <li class="row module" data-bind="sortable: uniqueId, attr: { 'data-id': uniqueId, id: uniqueId, 'data-type': 'carousel-module' }">1242 <div class="flexContainer">1243 <div class="small-11 columns">1244 <dl class="accordion" data-accordion="" role="tablist">1245 <dd class="accordion-navigation">1246 <a class="draggable" data-bind="text: 'Carousel Module', attr: { href: '#accordion'+uniqueId, id: 'accordion-heading'+uniqueId, role: 'tab' }"></a>1247 <div data-bind="attr: { id: 'accordion'+uniqueId, 'aria-labelledby': 'accordion-heading'+uniqueId, role: 'tabpanel' }" class="content">1248 <div class="row">1249 <div class="small-12 medium-4 columns">1250 <label>Item #</label>1251 <textarea rows="6" type="text" placeholder="Item #" data-bind="textInput: itemNumber"></textarea>1252 </div>1253 <div class="small-12 medium-4 columns">1254 <label>Item URL</label>1255 <textarea rows="6" type="text" placeholder="Item URL" data-bind="textInput: itemUrl"></textarea>1256 </div>1257 <div class="small-12 medium-4 columns">1258 <label>Display Module On</label>1259 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>1260 </div>1261 </div>1262 <div class="row">1263 <div class="small-12 medium-4 columns">1264 <label>Small Image URL</label>1265 <textarea rows="6" type="text" placeholder="Small Image URL" data-bind="textInput: imageSmallUrl"></textarea>1266 </div>1267 <div class="small-12 medium-4 columns">1268 <label>Large Image URL</label>1269 <textarea rows="6" type="text" placeholder="Large Image URL" data-bind="textInput: imageLargeUrl"></textarea>1270 </div>1271 <div class="small-12 medium-4 columns">1272 <label>Image Description Tag</label>1273 <textarea rows="6" type="text" placeholder="Image Description Tag" data-bind="textInput: imageDescription"></textarea>1274 </div>1275 </div>1276 <div class="row">1277 <div class="small-12 medium-4 columns">1278 <label>Section</label>1279 <input data-bind="textInput: section" type="text" placeholder="Section">1280 </div>1281 <div class="small-12 medium-4 columns">1282 <label>Section URL</label>1283 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">1284 </div>1285 <div class="small-12 medium-4 columns">1286 <label>Section Description Tag</label>1287 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>1288 </div>1289 </div>1290 <div class="row">1291 <div class="small-12 medium-4 columns">1292 <label>Headline</label>1293 <input data-bind="textInput: headline" type="text" placeholder="Headline">1294 </div>1295 <div class="small-12 medium-4 columns">1296 <label>Headline URL</label>1297 <input data-bind="textInput: headlineUrl" type="text" placeholder="Headline URL">1298 </div>1299 <div class="small-12 medium-4 columns">1300 <label>Headline Description Tag</label>1301 <input data-bind="textInput: headlineDescription" type="text" placeholder="Headline Description Tag"></input>1302 </div>1303 </div>1304 <div class="row">1305 <div class="small-12 medium-4 columns">1306 <label>CTA</label>1307 <input data-bind="textInput: cta" type="text" placeholder="CTA">1308 </div>1309 <div class="small-12 medium-4 columns">1310 <label>CTA URL</label>1311 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1312 </div>1313 <div class="small-12 medium-4 columns">1314 <label>CTA Description Tag</label>1315 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag"></input>1316 </div>1317 </div>1318 </div>1319 </dd>1320 </dl>1321 </div>1322 <div class="small-1 text-center columns removeModule">1323 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1324 </div>1325 </div>1326 </li>`, synchronous: true1327});1328ko.components.register('text-link-module', {1329 viewModel: class TextLinkModuleComponentModel extends Dependents {1330 constructor(params) {1331 super(params);1332 this.params = params;1333 }1334 },1335 template: `1336 <li class="row module" data-bind="sortable: uniqueId, attr: { 'data-id': uniqueId, id: uniqueId, 'data-type': 'text-link-module' }">1337 <div class="flexContainer">1338 <div class="small-11 columns">1339 <dl class="accordion" data-accordion="" role="tablist">1340 <dd class="accordion-navigation">1341 <a class="draggable" data-bind="text: 'Text Link Module', attr: { href: '#accordion'+uniqueId, id: 'accordion-heading'+uniqueId, role: 'tab' }"></a>1342 <div data-bind="attr: { id: 'accordion'+uniqueId, 'aria-labelledby': 'accordion-heading'+uniqueId, role: 'tabpanel' }" class="content">1343 <div class="row">1344 <div class="small-12 medium-4 columns">1345 <label>Item #</label>1346 <input data-bind="textInput: itemNumber" type="text" placeholder="Item #">1347 </div>1348 <div class="small-12 medium-4 columns">1349 <label>Item URL</label>1350 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL">1351 </div>1352 <div class="small-12 medium-4 columns">1353 <label>Display Module On</label>1354 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>1355 </div>1356 </div>1357 <div class="row">1358 <div class="small-12 medium-4 columns">1359 <label>Small Image URL</label>1360 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL">1361 </div>1362 <div class="small-12 medium-4 columns">1363 <label>Large Image URL</label>1364 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL">1365 </div>1366 <div class="small-12 medium-4 columns">1367 <label>Image Description Tag</label>1368 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag">1369 </div>1370 </div>1371 <div class="row">1372 <div class="small-12 medium-4 columns">1373 <label>Section</label>1374 <input data-bind="textInput: section" type="text" placeholder="Section">1375 </div>1376 <div class="small-12 medium-4 columns">1377 <label>Section URL</label>1378 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">1379 </div>1380 <div class="small-12 medium-4 columns">1381 <label>Section Description Tag</label>1382 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>1383 </div>1384 </div>1385 <div class="row">1386 <div class="small-12 medium-4 columns">1387 <label>CTA</label>1388 <input data-bind="textInput: cta" type="text" placeholder="CTA">1389 </div>1390 <div class="small-12 medium-4 columns">1391 <label>CTA URL</label>1392 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1393 </div>1394 <div class="small-12 medium-4 columns">1395 <label>CTA Description Tag</label>1396 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag">1397 </div>1398 </div>1399 </div>1400 </dd>1401 </dl>1402 </div>1403 <div class="small-1 text-center columns removeModule">1404 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1405 </div>1406 </div>1407 </li>`, synchronous: true1408});1409ko.components.register('image-link-double-module', {1410 viewModel: class ImageLinkDoubleModuleComponentModel extends Dependents {1411 constructor(params) {1412 super(params);1413 this.params = params;1414 }1415 },1416 template: `1417 <li class="row module" data-bind="sortable: uniqueId, attr: { 'data-id': uniqueId, id: uniqueId, 'data-type': 'image-link-double-module' }">1418 <div class="flexContainer">1419 <div class="small-11 columns">1420 <dl class="accordion" data-accordion="" role="tablist">1421 <dd class="accordion-navigation">1422 <a class="draggable" data-bind="text: 'Image Link Double Module', attr: { href: '#accordion'+uniqueId, id: 'accordion-heading'+uniqueId, role: 'tab' }"></a>1423 <div data-bind="attr: { id: 'accordion'+uniqueId, 'aria-labelledby': 'accordion-heading'+uniqueId, role: 'tabpanel' }" class="content">1424 <div class="row">1425 <div class="small-12 medium-4 columns">1426 <label>Item #</label>1427 <input data-bind="textInput: itemNumber" type="text" placeholder="Item #">1428 </div>1429 <div class="small-12 medium-4 columns">1430 <label>Item URL</label>1431 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL">1432 </div>1433 <div class="small-12 medium-4 columns">1434 <label>Display Module On</label>1435 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>1436 </div>1437 </div>1438 <div class="row">1439 <div class="small-12 medium-4 columns">1440 <label>Small Image URL</label>1441 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL">1442 </div>1443 <div class="small-12 medium-4 columns">1444 <label>Large Image URL</label>1445 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL">1446 </div>1447 <div class="small-12 medium-4 columns">1448 <label>Image Description Tag</label>1449 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag">1450 </div>1451 </div>1452 <div class="row">1453 <div class="small-12 medium-4 columns">1454 <label>Section</label>1455 <input data-bind="textInput: section" type="text" placeholder="Section">1456 </div>1457 <div class="small-12 medium-4 columns">1458 <label>Section URL</label>1459 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">1460 </div>1461 <div class="small-12 medium-4 columns">1462 <label>Section Description Tag</label>1463 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>1464 </div>1465 </div>1466 <div class="row">1467 <div class="small-12 medium-4 columns">1468 <label>CTA</label>1469 <input data-bind="textInput: cta" type="text" placeholder="CTA">1470 </div>1471 <div class="small-12 medium-4 columns">1472 <label>CTA URL</label>1473 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1474 </div>1475 <div class="small-12 medium-4 columns">1476 <label>CTA Description Tag</label>1477 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag">1478 </div>1479 </div>1480 </div>1481 </dd>1482 </dl>1483 </div>1484 <div class="small-1 text-center columns removeModule">1485 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1486 </div>1487 </div>1488 </li>`, synchronous: true1489});1490ko.components.register('button-link-double-module', {1491 viewModel: class ButtonLinkDoubleModuleComponentModel extends Dependents {1492 constructor(params) {1493 super(params);1494 this.params = params;1495 }1496 },1497 template: `1498 <li class="row module" data-bind="sortable: uniqueId, attr: { 'data-id': uniqueId, id: uniqueId, 'data-type': 'button-link-double-module' }">1499 <div class="flexContainer">1500 <div class="small-11 columns">1501 <dl class="accordion" data-accordion="" role="tablist">1502 <dd class="accordion-navigation">1503 <a class="draggable" data-bind="text: 'Button Link Double Module', attr: { href: '#accordion'+uniqueId, id: 'accordion-heading'+uniqueId, role: 'tab' }"></a>1504 <div data-bind="attr: { id: 'accordion'+uniqueId, 'aria-labelledby': 'accordion-heading'+uniqueId, role: 'tabpanel' }" class="content">1505 <div class="row">1506 <div class="small-12 medium-4 columns">1507 <label>Item #</label>1508 <input data-bind="textInput: itemNumber" type="text" placeholder="Item #">1509 </div>1510 <div class="small-12 medium-4 columns">1511 <label>Item URL</label>1512 <input data-bind="textInput: itemUrl" type="text" placeholder="Item URL">1513 </div>1514 <div class="small-12 medium-4 columns">1515 <label>Display Module On</label>1516 <select data-bind="options: screenSizes, optionsCaption: 'Display On', value: selectedModuleScreenSize"></select>1517 </div>1518 </div>1519 <div class="row">1520 <div class="small-12 medium-4 columns">1521 <label>Small Image URL</label>1522 <input data-bind="textInput: imageSmallUrl" type="text" placeholder="Small Image URL">1523 </div>1524 <div class="small-12 medium-4 columns">1525 <label>Large Image URL</label>1526 <input data-bind="textInput: imageLargeUrl" type="text" placeholder="Large Image URL">1527 </div>1528 <div class="small-12 medium-4 columns">1529 <label>Image Description Tag</label>1530 <input data-bind="textInput: imageDescription" type="text" placeholder="Image Description Tag">1531 </div>1532 </div>1533 <div class="row">1534 <div class="small-12 medium-4 columns">1535 <label>Section</label>1536 <input data-bind="textInput: section" type="text" placeholder="Section">1537 </div>1538 <div class="small-12 medium-4 columns">1539 <label>Section URL</label>1540 <input data-bind="textInput: sectionUrl" type="text" placeholder="Section URL">1541 </div>1542 <div class="small-12 medium-4 columns">1543 <label>Section Description Tag</label>1544 <input data-bind="textInput: sectionDescription" type="text" placeholder="Section Description Tag"></input>1545 </div>1546 </div>1547 <div class="row">1548 <div class="small-12 medium-4 columns">1549 <label>CTA</label>1550 <input data-bind="textInput: cta" type="text" placeholder="CTA">1551 </div>1552 <div class="small-12 medium-4 columns">1553 <label>CTA URL</label>1554 <input data-bind="textInput: ctaUrl" type="text" placeholder="CTA URL">1555 </div>1556 <div class="small-12 medium-4 columns">1557 <label>CTA Description Tag</label>1558 <input data-bind="textInput: ctaDescription" type="text" placeholder="CTA Description Tag">1559 </div>1560 </div>1561 </div>1562 </dd>1563 </dl>1564 </div>1565 <div class="small-1 text-center columns removeModule">1566 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1567 </div>1568 </div>1569 </li>`, synchronous: true1570});1571ko.components.register('seo-link-module', {1572 viewModel: class SeoLinkModuleComponentModel extends Dependents {1573 constructor(params) {1574 super(params);1575 this.params = params;1576 }1577 },1578 template: `1579 <li class="row module" data-bind="sortable: uniqueId, attr: { 'data-id': uniqueId, id: uniqueId, 'data-type': 'seo-link-module' }">1580 <div class="flexContainer">1581 <div class="small-11 columns">1582 <dl class="accordion" data-accordion="" role="tablist">1583 <dd class="accordion-navigation">1584 <a class="draggable" data-bind="text: 'SEO Links Module', attr: { href: '#accordion'+uniqueId, id: 'accordion-heading'+uniqueId, role: 'tab' }"></a>1585 <div data-bind="attr: { id: 'accordion'+uniqueId, 'aria-labelledby': 'accordion-heading'+uniqueId, role: 'tabpanel' }" class="content">1586 <div class="row">1587 <div class="small-12 columns">1588 <h3>TL SEO 1</h3>1589 </div>1590 </div>1591 <div class="row">1592 <div class="small-12 medium-4 columns">1593 <label>Section</label>1594 <input data-bind="textInput: seo1Section" type="text" placeholder="Section">1595 </div>1596 <div class="small-12 medium-4 columns">1597 <label>Section URL</label>1598 <input data-bind="textInput: seo1SectionUrl" type="text" placeholder="Section URL">1599 </div>1600 <div class="small-12 medium-4 columns">1601 <label>Section Description Tag</label>1602 <input data-bind="textInput: seo1SectionDescription" type="text" placeholder="Section Description Tag"></input>1603 </div>1604 </div>1605 <div class="row">1606 <div class="small-12 medium-4 columns">1607 <label>CTA</label>1608 <textarea rows="4" type="text" placeholder="CTA" data-bind="textInput: seo1cta"></textarea>1609 </div>1610 <div class="small-12 medium-4 columns">1611 <label>CTA URL</label>1612 <textarea rows="4" type="text" placeholder="CTA URL" data-bind="textInput: seo1ctaUrl"></textarea>1613 </div>1614 <div class="small-12 medium-4 columns">1615 <label>CTA Description Tag</label>1616 <textarea rows="4" type="text" placeholder="CTA Description Tag" data-bind="textInput: seo1ctaDescription"></textarea>1617 </div>1618 </div>1619 <div class="row">1620 <div class="small-12 columns">1621 <h3>LD SEO 2</h3>1622 </div>1623 </div>1624 <div class="row">1625 <div class="small-12 medium-6 columns">1626 <label>Item #</label>1627 <textarea rows="6" type="text" placeholder="Item #" data-bind="textInput: seo2ItemNumber"></textarea>1628 </div>1629 <div class="small-12 medium-6 columns">1630 <label>Item URL</label>1631 <textarea rows="6" type="text" placeholder="Item URL" data-bind="textInput: seo2ItemUrl"></textarea>1632 </div>1633 </div>1634 <div class="row">1635 <div class="small-12 medium-4 columns">1636 <label>Small Image URL</label>1637 <textarea rows="6" type="text" placeholder="Small Image URL" data-bind="textInput: seo2ImageSmallUrl"></textarea>1638 </div>1639 <div class="small-12 medium-4 columns">1640 <label>Large Image URL</label>1641 <textarea rows="6" type="text" placeholder="Large Image URL" data-bind="textInput: seo2ImageLargeUrl"></textarea>1642 </div>1643 <div class="small-12 medium-4 columns">1644 <label>Image Description Tag</label>1645 <textarea rows="6" type="text" placeholder="Image Description Tag" data-bind="textInput: seo2ImageDescription"></textarea>1646 </div>1647 </div>1648 <div class="row">1649 <div class="small-12 medium-4 columns">1650 <label>Section</label>1651 <input data-bind="textInput: seo2Section" type="text" placeholder="Section">1652 </div>1653 <div class="small-12 medium-4 columns">1654 <label>Section URL</label>1655 <input data-bind="textInput: seo2SectionUrl" type="text" placeholder="Section URL">1656 </div>1657 <div class="small-12 medium-4 columns">1658 <label>Section Description Tag</label>1659 <input data-bind="textInput: seo2SectionDescription" type="text" placeholder="Section Description Tag"></input>1660 </div>1661 </div>1662 <div class="row">1663 <div class="small-12 medium-4 columns">1664 <label>CTA</label>1665 <textarea rows="6" type="text" placeholder="CTA" data-bind="textInput: seo2cta"></textarea>1666 </div>1667 <div class="small-12 medium-4 columns">1668 <label>CTA URL</label>1669 <textarea rows="6" type="text" placeholder="CTA URLL" data-bind="textInput: seo2ctaUrl"></textarea>1670 </div>1671 <div class="small-12 medium-4 columns">1672 <label>CTA Description Tag</label>1673 <textarea rows="6" type="text" placeholder="CTA Description Tag" data-bind="textInput: seo2ctaDescription"></textarea>1674 </div>1675 </div>1676 </div>1677 </dd>1678 </dl>1679 </div>1680 <div class="small-1 text-center columns removeModule">1681 <i class="fa fa-times fa-3" aria-hidden="true" data-bind="event:{ click: removeModule }"></i>1682 </div>1683 </div>1684 </li>`, synchronous: true1685});1686ko.components.register('ug-component', {1687 viewModel: function (params) {1688 this.params = params.params || {};1689 this.component = params.component || {};1690 console.log('this.params ',this.params);1691 console.log('this.component ',this.component);1692 },1693 template: `<!-- ko component: {name: component, params: { data: params }} --><!-- /ko -->`,synchronous: true1694});1695function reducerFilter(acc, xs) {1696 xs.map((item, index) => {1697 if (xs[index] === xs[index+1]) {1698 if (xs[index] === 'collection-grid-module' || xs[index] === 'carousel-module') {1699 acc.push(item);1700 } else {1701 acc.push('concat');1702 }1703 } else {1704 acc.push(item);1705 }1706 })1707 // console.log('acc ',acc);1708 return acc;1709}1710//TODO testing new way of rendering modules1711ko.components.register('homePageTool', {1712 viewModel: class HomePageToolComponentModel extends Dependents {1713 constructor(params) {1714 super(params);1715 this.selection = ko.observable();1716 this.selectedModules = ko.observableArray([]);1717 this.date = ko.observable();1718 this.moduleTypes = [1719 {name: 'Large Feature (LF)', value: 'large-feature-module'},1720 {name: 'Small Feature (SF)', value: 'small-feature-module'},1721 {name: 'Basic Story (BS)', value: 'basic-story-module'},1722 {name: 'Extended Story (ES)', value: 'extended-story-module'},1723 {name: 'Collection Grid (CG)', value: 'collection-grid-module'},1724 {name: 'Carousel (CL)', value: 'carousel-module'},1725 {name: 'Text Link (TL)', value: 'text-link-module'},1726 {name: 'Image Link Double (LD)', value: 'image-link-double-module'},1727 {name: 'Button Link Double (BD)', value: 'button-link-double-module'},1728 {name: 'SEO Links (SEO)', value: 'seo-link-module'}1729 ];1730 this.jsonOrder = function(arry) {1731 var alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';1732 var hpJson = {};1733 var hpDate = this.date();1734 arry.forEach((obj, index) => {1735 hpJson[alpha.charAt(index)] = obj;1736 })1737 $.ajax({1738 type: "POST",1739 url: "http://localhost:5000/hp_config",1740 data: formToJSON(),1741 dataType: "json",1742 success: function() {1743 window.open('http://localhost:9000/simulator/?date='+hpDate, '_blank');1744 }1745 }).done(function(msg) {1746 console.log("Data Saved: " + msg);1747 });1748 function formToJSON() {1749 return {1750 "json": hpJson,1751 "date": hpDate1752 };1753 }1754 }1755 this.createModule = function (e) {1756 load = false;1757 this.selectedModules.push(this.selection());1758 console.log('createModule ',this.selectedModules());1759 }1760 this.previewHomepage = function(e) {1761 //console.log('preview click ',this.mappingOrder);1762 var mappingOrderCopy = JSON.parse(JSON.stringify(this.mappingOrder));1763 var removedUniqueIdJson = {};1764 var duplicateModuleNames = [];1765 var duplicateObjects = [];1766 var concatArray = [];1767 var orderedJson = {};1768 //removes uniqueIds1769 Object.keys(mappingOrderCopy).forEach(function(key) {1770 Object.assign(removedUniqueIdJson, mappingOrderCopy[key]);1771 });1772 Object.keys(removedUniqueIdJson).sort().forEach(function(key,index) {1773 orderedJson[key] = removedUniqueIdJson[key];1774 });1775 Object.keys(orderedJson).forEach(function(key,index) {1776 duplicateModuleNames.push(Object.keys(orderedJson[key])[0]);1777 duplicateObjects.push(orderedJson[key]);1778 });1779 var adjecentCombine = reducerFilter([],duplicateModuleNames);1780 adjecentCombine.forEach((el,index) => {1781 var moduleType = Object.keys(duplicateObjects[index])[0];1782 if (el === 'concat') {1783 duplicateObjects[index+1][moduleType].sections = duplicateObjects[index][moduleType].sections.concat(duplicateObjects[index+1][moduleType].sections);1784 duplicateObjects.splice(index,1,'');1785 }1786 })1787 duplicateObjects = duplicateObjects.filter(function(n){ return n != '' });1788 this.jsonOrder(duplicateObjects);1789 }1790 this.reRender = function renderLoadedJson() {1791 this.selectedModules.removeAll();1792 counter = 0;1793 Object.keys(mappingOrder).forEach((letter, i) => {1794 Object.keys(mappingOrder[letter]).forEach((module, index) => {1795 if (module === 'collection-grid-module' || module === 'carousel-module' || module === 'seo-link-module') {1796 counter ++;1797 } else {1798 counter += mappingOrder[letter][module]['sections'].length;1799 }1800 })1801 })1802 Object.keys(mappingOrder).forEach((letter, i) => {1803 Object.keys(mappingOrder[letter]).forEach((module, index) => {1804 switch (module) {1805 case 'large-feature-module':1806 var sectionsArry = mappingOrder[letter][module].sections;1807 sectionsArry.forEach((el,index) => {1808 this.selectedModules.push(module);1809 })1810 break1811 case 'small-feature-module':1812 var sectionsArry = mappingOrder[letter][module].sections;1813 sectionsArry.forEach((el,index) => {1814 this.selectedModules.push(module);1815 })1816 break1817 case 'basic-story-module':1818 var sectionsArry = mappingOrder[letter][module].sections;1819 sectionsArry.forEach((el,index) => {1820 this.selectedModules.push(module);1821 })1822 break1823 case 'extended-story-module':1824 var sectionsArry = mappingOrder[letter][module].sections;1825 sectionsArry.forEach((el,index) => {1826 this.selectedModules.push(module);1827 })1828 break1829 case 'collection-grid-module':1830 this.selectedModules.push(module);1831 break1832 case 'carousel-module':1833 this.selectedModules.push(module);1834 break1835 case 'text-link-module':1836 var sectionsArry = mappingOrder[letter][module].sections;1837 sectionsArry.forEach((el,index) => {1838 this.selectedModules.push(module);1839 })1840 break1841 case 'image-link-double-module':1842 var sectionsArry = mappingOrder[letter][module].sections;1843 sectionsArry.forEach((el,index) => {1844 this.selectedModules.push(module);1845 })1846 break1847 case 'button-link-double-module':1848 var sectionsArry = mappingOrder[letter][module].sections;1849 sectionsArry.forEach((el,index) => {1850 this.selectedModules.push(module);1851 })1852 break1853 case 'seo-link-module':1854 this.selectedModules.push(module);1855 break1856 }1857 })1858 })1859 };1860 this.loadHomePage = function(e) {1861 var loadDate = this.date();1862 var self = this;1863 load = true;1864 this.loadingModelData.removeAll();1865 $.ajax({1866 type: "GET",1867 url: "http://localhost:5000/hp_config/"+loadDate+".js",1868 success: function(data) {1869 var clearModules = [];1870 clearModules = Array.from(document.getElementById('sortableContainer').querySelectorAll('.module'));1871 clearModules.forEach((el, index)=> {1872 ko.removeNode(el);1873 delete self.mappingOrder[el.getAttribute('id')];1874 })1875 self.reRender();1876 },1877 error: function(jqXHR, status, error){1878 if (jqXHR.status === 404) {1879 alert('No data found for '+loadDate+'');1880 }1881 }1882 })1883 }1884 this.createNewHomePage = function(e) {1885 window.location.reload();1886 }1887 ko.bindingHandlers.datepicker = {1888 init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {1889 var d = new Date();1890 d.setHours(0, -d.getTimezoneOffset(), 0, 0); //removing the timezone offset.1891 viewModel.date(d.toISOString().slice(0,10));1892 $(function () {1893 $('#dp1').fdatepicker({1894 initialDate: 'yyyy-mm-dd',1895 format: 'yyyy-mm-dd',1896 disableDblClickSelection: true1897 }).on('changeDate', function (ev) {1898 viewModel.date(ev.date.toISOString().slice(0,10));1899 })1900 })1901 }1902 }1903 }1904 },1905 template: `1906 <div class='row'>1907 <div class='small-12 columns'>1908 <h2>Create Home Page Tool</h2>1909 </div>1910 </div>1911 <div class="row" style="max-width:200px; margin: 0;">1912 <div class="small-2 columns" style="padding-right: 0;">1913 <span class="prefix"><i class="fa fa-calendar" style="line-height: inherit;"></i></span>1914 </div>1915 <div class="small-10 columns" style="padding-left: 0;">1916 <input type="text" class="span2" id="dp1" data-bind="datepicker">1917 </div>1918 </div>1919 <div class="row">1920 <div class="small-12 columns">1921 <button data-bind="event:{ click: createNewHomePage }">Create New Home Page</button>1922 <button data-bind="event:{ click: loadHomePage }">Load Home Page</button>1923 <button data-bind="event:{ click: previewHomepage }">Preview Home Page</button>1924 </div>1925 <div class="small-4 columns">1926 <select data-bind="options: moduleTypes, value: selection ,optionsText: 'name', optionsValue: 'value', optionsCaption: 'Choose Module Type'"></select>1927 </div>1928 <div class="small-8 columns end">1929 <button data-bind="event:{ click: createModule }">Create Module</button>1930 </div>1931 </div>1932 <ul data-bind="foreach: selectedModules()" id="sortableContainer">1933 <!-- ko component: {name: $data, params: { data: $parent }} --><!-- /ko -->1934 </ul>`, synchronous: true1935});...

Full Screen

Full Screen

script.js

Source:script.js Github

copy

Full Screen

1// Assignment code here2// ask for password legnth3var charSet = [];4var passwordLength; 5//upper or lower case letters6var letters = () => {7 var alphaChar = prompt(8 'would you like your letters to be lower case, upper case or both? type "1" for lower, type "2" for upper or type "3" for both.'9 );10 alphaChar = parseInt(alphaChar);11 if (!alphaChar) {12 alert("You must select an option. Please try again");13 } else if (alphaChar === 1) {14 charSet.push(15 "a",16 "b",17 "c",18 "d",19 "e",20 "f",21 "g",22 "h",23 "i",24 "j",25 "k",26 "l",27 "m",28 "n",29 "o",30 "p",31 "q",32 "r",33 "s",34 "t",35 "u",36 "v",37 "w",38 "x",39 "y",40 "z"41 );42 } else if (alphaChar === 2) {43 charSet.push(44 "A",45 "B",46 "C",47 "D",48 "E",49 "F",50 "G",51 "H",52 "I",53 "J",54 "K",55 "L",56 "M",57 "N",58 "O",59 "P",60 "Q",61 "R",62 "S",63 "T",64 "U",65 "V",66 "W",67 "X",68 "Y",69 "Z"70 );71 } else if (alphaChar === 3) {72 charSet.push(73 "A",74 "B",75 "C",76 "D",77 "E",78 "F",79 "G",80 "H",81 "I",82 "J",83 "K",84 "L",85 "M",86 "N",87 "O",88 "P",89 "Q",90 "R",91 "S",92 "T",93 "U",94 "V",95 "W",96 "X",97 "Y",98 "Z",99 "a",100 "b",101 "c",102 "d",103 "e",104 "f",105 "g",106 "h",107 "i",108 "j",109 "k",110 "l",111 "m",112 "n",113 "o",114 "p",115 "q",116 "r",117 "s",118 "t",119 "u",120 "v",121 "w",122 "x",123 "y",124 "z"125 );126 } else {127 alert("you have entered an invalid value. Please try again! .");128 letters();129 }130};131// should numbers be inlcuded132var numbers = () => {133 var numericChar = prompt(134 'Would you like to include numeric characters? Type "Y" for yes or "N" for no.'135 );136 numericChar = numericChar.toLowerCase();137 if (!numericChar) {138 alert("You did not choose a valid option. Please try again");139 numbers();140 } else if (numericChar === "y") {141 charSet.push(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);142 143 } else if (numericChar === "n") {144 alert(`You chose not to include numbers`);145 } else {146 alert("You did not choose a valid option, please try again!");147 numbers();148 }149};150var special = () => {151 var specialChar = prompt(152 'Would you like to include special characters? Type "Y" for yes or "N" for no.'153 );154 specialChar = specialChar.toLowerCase();155 if (!specialChar) {156 alert("You did not choose a valid option. Please try again");157 special();158 } else if (specialChar === "y") {159 charSet.push(160 "!",161 "#",162 "%",163 "$",164 "&",165 "*",166 "+",167 ">",168 "<",169 "@",170 "=",171 "^",172 "|",173 "()",174 "_"175 );176 } else if (specialChar === "n") {177 alert(`You chose not to include special characters`)178 } else {179 alert("You did not choose a valid option. Please try again!");180 special();181 }182};183var length = () => {184 passwordLength = prompt(185 "Welcome to Random Paswword Generater! How long would you like your password to be? Please provide a whole number between 8 and 128."186 );187 passwordLength = parseInt(passwordLength);188 if (!passwordLength) {189 alert(190 "You did not provide any information or did not enter a whole number. Please try again!"191 );192 length();193 } else if (passwordLength < 8 || passwordLength > 128) {194 alert(195 "You have chosen a number that does not meet the criteria. Please try again!"196 );197 length();198 }199};200var generatePassword = () => {201 length();202 letters();203 numbers();204 special();205 var pswd = [];206 var random;207 for (let i = 0; i < passwordLength; i++) {208 random = Math.floor(Math.random() * charSet.length);209 pswd.push(charSet[random]);210 var password = pswd.join("");211 }212 console.log(pswd);213 alert(`Your password is: ${password}`);214 return password;215};216// Get references to the #generate element217var generateBtn = document.querySelector("#generate");218// Write password to the #password input219function writePassword() {220 221 222 var password = generatePassword();223 var passwordText = document.querySelector("#password");224 passwordText.textContent = password;225}226// Add event listener to generate button...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import {alphaChar} from 'fast-check-monorepo';2console.log(alphaChar());3{4 "scripts": {5 },6 "dependencies": {7 }8}9{10 "scripts": {11 },12 "repository": {

Full Screen

Using AI Code Generation

copy

Full Screen

1import {alphaChar} from 'fast-check-monorepo';2console.log(alphaChar());3{4 "scripts": {5 },6 "dependencies": {7 }8}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { alphaChar } = require('fast-check');2console.log(alphaChar().generate());3{4 "dependencies": {5 }6}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { alphaChar } = require('fast-check-monorepo');2console.log(alphaChar());3const { alphaChar } = require('fast-check');4console.log(alphaChar());5const { alphaChar } = require('fast-check-1.0');6console.log(alphaChar());7const { alphaChar } = require('fast-check-1.1');8console.log(alphaChar());9const { alphaChar } = require('fast-check-1.2');10console.log(alphaChar());11const { alphaChar } = require('fast-check-1.3');12console.log(alphaChar());13const { alphaChar } = require('fast-check-1.4');14console.log(alphaChar());15const { alphaChar } = require('fast-check-1.5');16console.log(alphaChar());17const { alphaChar } = require('fast-check-1.6');18console.log(alphaChar());19const { alphaChar } = require('fast-check-1.7');20console.log(alphaChar());21const { alphaChar } = require('fast-check-1.8');22console.log(alphaChar());23const { alphaChar } = require('fast-check-1.9');24console.log(alphaChar());25const { alphaChar } = require('fast-check-1.10');26console.log(alphaChar());27const { alphaChar } = require('fast-check-1.11');28console.log(alphaChar());29const { alphaChar } = require('fast-check-1.12');

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const alphaChar = require('fast-check-monorepo').alphaChar;3fc.assert(4 fc.property(alphaChar(), (char) => {5 return char >= 'a' && char <= 'z';6 })7);8{9 "scripts": {10 },11 "dependencies": {12 }13}14{15 "dependencies": {16 }17}

Full Screen

Using AI Code Generation

copy

Full Screen

1var alphaChar = require('fast-check').alphaChar;2console.log(alphaChar());3{4 "dependencies": {5 }6}7var alphaChar = require('fast-check').alphaChar;8console.log(alphaChar());9{10 "dependencies": {11 }12}13var alphaChar = require('fast-check').alphaChar;14console.log(alphaChar());15{16 "dependencies": {17 }18}19var alphaChar = require('fast-check').alphaChar;20console.log(alphaChar());21{22 "dependencies": {23 }24}25var alphaChar = require('fast-check').alphaChar;26console.log(alphaChar());27{28 "dependencies": {29 }30}31var alphaChar = require('fast-check').alphaChar;32console.log(alphaChar());33{34 "dependencies": {35 }36}37var alphaChar = require('fast-check').alphaChar;38console.log(alphaChar());39{40 "dependencies": {41 }42}43var alphaChar = require('fast-check').alphaChar;44console.log(alpha

Full Screen

Using AI Code Generation

copy

Full Screen

1const { alphaChar } = require('fast-check-monorepo');2const { generate } = require('fast-check');3const { run } = require('fast-check/lib/check/runner/Runner.js');4const { check } = require('fast-check/lib/check/runner/Check.js');5const { buildProperty } = require('fast-check/lib/check/runner/Property.js');6const { buildSettings } = require('fast-check/lib/check/runner/Settings.js');7const { buildAsyncProperty } = require('fast-check/lib/check/runner/AsyncProperty.js');8const { buildAsyncSettings } = require('fast-check/lib/check/runner/AsyncSettings.js');9const { buildFullProperty } = require('fast-check/lib/check/runner/FullProperty.js');10const { buildFullSettings } = require('fast-check/lib/check/runner/FullSettings.js');11const settings = buildSettings({});12const property = buildProperty(() => alphaChar().generate(settings).value !== 'a');13const asyncProperty = buildAsyncProperty(() =>14 Promise.resolve(alphaChar().generate(settings).value !== 'a')15);16const fullProperty = buildFullProperty(() => alphaChar().generate(settings).value !== 'a');17const fullAsyncProperty = buildFullProperty(() =>18 Promise.resolve(alphaChar().generate(settings).value !== 'a')19);20const asyncSettings = buildAsyncSettings({});21const fullSettings = buildFullSettings({});22run(23 check(property, settings, 1000, 100),24 check(asyncProperty, asyncSettings, 1000, 100),25 check(fullProperty, fullSettings, 1000, 100),26 check(fullAsyncProperty, fullSettings, 1000, 100)27);28const { alphaChar } = require('fast-check-monorepo');29const { generate } = require('fast-check');30const { run } = require('fast-check/lib/check/runner/Runner.js');31const { check } = require('fast-check/lib/check/runner/Check.js');32const { buildProperty } = require('fast-check/lib/check/runner/Property.js');33const { buildSettings } = require('fast-check/lib/check/runner/Settings.js');34const { buildAsyncProperty } = require('fast-check/lib/check/runner/AsyncProperty.js');35const { buildAsyncSettings } = require('fast-check/lib/check/runner/AsyncSettings

Full Screen

Using AI Code Generation

copy

Full Screen

1const myChar = alphaChar();2console.log(myChar);3{4 "scripts": {5 },6 "dependencies": {7 }8}

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful