|
14 | 14 | var deviceHeight = window.innerHeight; |
15 | 15 | var detailedPluginInfoArray = []; |
16 | 16 | var deviceWidth = window.innerWidth; |
17 | | - var oldCarousalArray=[]; |
18 | | - var oldLayoutName=null; |
| 17 | + var oldCarousalArray = []; |
| 18 | + var oldLayoutName = null; |
19 | 19 | WidgetHome.firstTime = true; |
20 | | - $scope.layout12TotalItem=0; |
21 | | - $scope.layout12Height='300px'; |
| 20 | + $scope.layout12TotalItem = 0; |
| 21 | + $scope.layout12Height = '300px'; |
| 22 | + |
| 23 | + $scope.setWidth = function () { |
| 24 | + $rootScope.deviceWidth = window.innerWidth; |
| 25 | + }; |
22 | 26 |
|
23 | 27 | WidgetHome.view = null; |
24 | 28 | //Default initialise |
|
51 | 55 |
|
52 | 56 | /*declare the device width heights*/ |
53 | 57 | $rootScope.deviceHeight = window.innerHeight; |
54 | | - $rootScope.deviceWidth = window.innerWidth; |
| 58 | + //$rootScope.deviceWidth = window.innerWidth; |
55 | 59 |
|
56 | 60 | WidgetHome.advancedFolderInfo = new DB(COLLECTIONS.advancedFolderInfo); |
57 | 61 |
|
|
87 | 91 | console.log('>>result<<', result); |
88 | 92 | if (result && result.data && result.id) { |
89 | 93 | WidgetHome.info = result; |
90 | | - loadData(); |
| 94 | + $timeout(function () { |
| 95 | + loadData(); |
| 96 | + }, 1000); |
91 | 97 | if (WidgetHome.info.data && WidgetHome.info.data.design) { |
92 | 98 | setBackgroundImage(); |
93 | | - oldLayoutName=WidgetHome.info.data.design.itemListLayout; |
| 99 | + oldLayoutName = WidgetHome.info.data.design.itemListLayout; |
94 | 100 | } |
95 | 101 | $timeout(function () { |
96 | 102 | WidgetHome.initCarousel(); |
97 | | - oldCarousalArray=WidgetHome.info.data.content.images; |
98 | | - }, 1500); |
| 103 | + oldCarousalArray = WidgetHome.info.data.content.images; |
| 104 | + }, 1500); |
99 | 105 | } |
100 | 106 | else { |
101 | 107 | WidgetHome.info = DEFAULT_DATA.ADVANCED_FOLDER_INFO; |
|
162 | 168 |
|
163 | 169 | function preparePluginsData(plugins) { |
164 | 170 |
|
165 | | - var matrix = [], i, k; |
166 | | - var matrix = [] |
167 | | - for (i = 0, k = -1; i < plugins.length; i++) { |
168 | | - if (i % 8 === 0) { |
169 | | - k++; |
170 | | - matrix[k] = []; |
171 | | - } |
172 | | - matrix[k].push(plugins[i]); |
| 171 | + var matrix = [], i, k; |
| 172 | + var matrix = [] |
| 173 | + for (i = 0, k = -1; i < plugins.length; i++) { |
| 174 | + if (i % 8 === 0) { |
| 175 | + k++; |
| 176 | + matrix[k] = []; |
173 | 177 | } |
174 | | - $scope.layout12Plugins = matrix; |
| 178 | + matrix[k].push(plugins[i]); |
| 179 | + } |
| 180 | + $scope.layout12Plugins = matrix; |
175 | 181 |
|
176 | 182 | } |
177 | 183 |
|
|
303 | 309 | console.log('dynamic store fetching'); |
304 | 310 | buildfire.datastore.getWithDynamicData('advancedFolderInfo', function (err, result) { |
305 | 311 | if (err) { |
| 312 | + $('body').hide(); |
306 | 313 | console.log('eror in dynamic store fetching'); |
307 | 314 | console.error("Error: ", err); |
308 | 315 | return; |
|
323 | 330 | */ |
324 | 331 |
|
325 | 332 | WidgetHome.onUpdateCallback = function (event) { |
326 | | - |
327 | 333 | if (event.data) { |
328 | 334 | WidgetHome.info = event; |
329 | 335 | layout12Skeleton(); |
330 | 336 | ViewStack.popAllViews(); |
331 | 337 | if (WidgetHome.info.data && WidgetHome.info.data.design) |
332 | 338 | $rootScope.bgImage = WidgetHome.info.data.design.bgImage; |
333 | 339 | setBackgroundImage(); |
334 | | - var newCarousalArray=WidgetHome.info.data.content.images; |
335 | | - var newLayoutName=WidgetHome.info.data.design.itemListLayout; |
336 | | - |
337 | | - if(( (oldLayoutName != newLayoutName )|| !angular.equals(oldCarousalArray,newCarousalArray)) ){ |
338 | | - setTimeout(function(){ |
339 | | - WidgetHome.initCarousel(); |
340 | | - oldCarousalArray=newCarousalArray; |
341 | | - oldLayoutName=newLayoutName; |
342 | | - },500); |
| 340 | + var newCarousalArray = WidgetHome.info.data.content.images; |
| 341 | + var newLayoutName = WidgetHome.info.data.design.itemListLayout; |
| 342 | + |
| 343 | + if (( (oldLayoutName != newLayoutName ) || !angular.equals(oldCarousalArray, newCarousalArray))) { |
| 344 | + setTimeout(function () { |
| 345 | + WidgetHome.initCarousel(); |
| 346 | + oldCarousalArray = newCarousalArray; |
| 347 | + oldLayoutName = newLayoutName; |
| 348 | + }, 500); |
343 | 349 | } |
344 | 350 |
|
345 | 351 |
|
|
351 | 357 |
|
352 | 358 |
|
353 | 359 | function dataLoadedHandler(result) { |
354 | | - console.log('success in dynamic store fetching', result); |
| 360 | + console.log('success in dynamic store fetching', result.data._buildfire.plugins.result.length); |
355 | 361 | var pluginsList = null; |
356 | 362 | if (result && result.data && result.data._buildfire && result.data._buildfire.plugins && result.data._buildfire.plugins.result) { |
357 | 363 | pluginsList = result.data._buildfire.plugins; |
|
366 | 372 |
|
367 | 373 | }) |
368 | 374 | } |
369 | | - }else{ |
| 375 | + } else { |
370 | 376 | if (WidgetHome.info.data.content.entity.length) { |
371 | 377 | layout12Skeleton(); |
372 | 378 | } |
|
375 | 381 | console.log('success in dynamic store fetching post', WidgetHome.info); |
376 | 382 | } |
377 | 383 |
|
378 | | - function layout12Skeleton(){ |
379 | | - if(WidgetHome.info.data.design.itemListLayout=="list-layout12"){ |
380 | | - var currentCount =Number(WidgetHome.info.data.content.entity.length); |
| 384 | + function layout12Skeleton() { |
| 385 | + if (WidgetHome.info.data.design.itemListLayout == "list-layout12") { |
| 386 | + var currentCount = Number(WidgetHome.info.data.content.entity.length); |
381 | 387 | preparePluginsData(WidgetHome.info.data.content.entity); |
382 | | - if(currentCount){ |
383 | | - $scope.layout12TotalItem=currentCount; |
| 388 | + if (currentCount) { |
| 389 | + $scope.layout12TotalItem = currentCount; |
384 | 390 | } |
385 | 391 | } |
386 | 392 | } |
|
485 | 491 |
|
486 | 492 | }; |
487 | 493 |
|
488 | | - $rootScope.$on("CallHomeMethod", function (event,d) { |
| 494 | + $rootScope.$on("CallHomeMethod", function (event, d) { |
489 | 495 | if (d.data && d.method == 'navigateToPlugin') |
490 | 496 | WidgetHome.navigateToPlugin(d.data); |
491 | 497 | }); |
492 | 498 |
|
493 | | - $scope.$on('LastRepeaterElement', function(){ |
| 499 | + $scope.$on('LastRepeaterElement', function () { |
494 | 500 | // $('.plugin-slider.text-center.owl-carousel').trigger("destroy.owl.carousel"); |
495 | | - $scope.layout12Height= $('.plugin-slider .plugin-slide').first().height()+240+'px'; |
| 501 | + $scope.layout12Height = $('.plugin-slider .plugin-slide').first().height() + 240 + 'px'; |
496 | 502 | var slides = $('.plugin-slider .plugin-slide').length; |
497 | | - $scope.layout12TotalItem=$scope.layout12TotalItem+1; |
| 503 | + $scope.layout12TotalItem = $scope.layout12TotalItem + 1; |
498 | 504 | // Slider needs at least 2 slides or you'll get an error. |
499 | | - if(slides > 1){ |
| 505 | + if (slides > 1) { |
500 | 506 | $('.plugin-slider').owlCarousel({ |
501 | | - loop:false, |
502 | | - nav:false, |
503 | | - items:1 |
| 507 | + loop: false, |
| 508 | + nav: false, |
| 509 | + items: 1 |
504 | 510 | }); |
505 | 511 | } |
506 | 512 | }); |
|
0 commit comments