|
1 | 1 | (function (angular, buildfire) { |
2 | | - "use strict"; |
3 | | - angular |
4 | | - .module('folderPluginWidget') |
5 | | - |
| 2 | + "use strict"; |
| 3 | + angular |
| 4 | + .module('folderPluginWidget') |
| 5 | + |
6 | 6 | .directive("loadImage", function () { |
7 | 7 | return { |
8 | | - restrict: 'A', |
| 8 | + restrict: 'A', |
9 | 9 | link: function (scope, element, attrs) { |
10 | | - element.attr("src", "../../../styles/media/holder-" + attrs.loadImage + ".gif"); |
11 | | - |
| 10 | + element.attr("src", "../../../styles/media/holder-" + attrs.loadImage + ".gif"); |
| 11 | + |
12 | 12 | attrs.$observe('finalSrc', function () { |
13 | | - var _img = attrs.finalSrc; |
14 | | - |
| 13 | + var _img = attrs.finalSrc; |
| 14 | + |
15 | 15 | if (attrs.cropType == 'resize') { |
16 | 16 | buildfire.imageLib.local.resizeImage(_img, { |
17 | | - width: attrs.cropWidth, |
| 17 | + width: attrs.cropWidth, |
18 | 18 | height: attrs.cropHeight |
19 | 19 | }, function (err, imgUrl) { |
20 | | - _img = imgUrl; |
| 20 | + _img = imgUrl; |
21 | 21 | replaceImg(_img); |
22 | 22 | }); |
23 | 23 | } else { |
24 | 24 | buildfire.imageLib.local.cropImage(_img, { |
25 | | - width: attrs.cropWidth, |
| 25 | + width: attrs.cropWidth, |
26 | 26 | height: attrs.cropHeight |
27 | 27 | }, function (err, imgUrl) { |
28 | | - _img = imgUrl; |
| 28 | + _img = imgUrl; |
29 | 29 | replaceImg(_img); |
30 | 30 | }); |
31 | 31 | } |
32 | | - }); |
33 | | - |
| 32 | + }); |
| 33 | + |
34 | 34 | function replaceImg(finalSrc) { |
35 | | - var elem = $("<img>"); |
| 35 | + var elem = $("<img>"); |
36 | 36 | elem[0].onload = function () { |
37 | | - element.attr("src", finalSrc); |
| 37 | + element.attr("src", finalSrc); |
38 | 38 | elem.remove(); |
39 | | - }; |
| 39 | + }; |
40 | 40 | elem.attr("src", finalSrc); |
41 | 41 | } |
42 | 42 | } |
43 | 43 | }; |
44 | | - }) |
45 | | - |
| 44 | + }) |
| 45 | + |
46 | 46 | .directive('backImg', ["$rootScope", function ($rootScope) { |
47 | 47 | return function (scope, element, attrs) { |
48 | 48 | attrs.$observe('backImg', function (value) { |
49 | | - var img = ''; |
| 49 | + var img = ''; |
50 | 50 | if (value) { |
51 | 51 | buildfire.imageLib.local.cropImage(value, { |
52 | | - width: window.innerWidth, |
| 52 | + width: window.innerWidth, |
53 | 53 | height: window.innerHeight |
54 | 54 | }, function (err, imgUrl) { |
55 | 55 | if (imgUrl) { |
56 | | - img = imgUrl; |
| 56 | + img = imgUrl; |
57 | 57 | element.attr("style", 'background:url(' + img + ') !important ; background-size: cover !important;'); |
58 | 58 | } else { |
59 | | - img = ''; |
| 59 | + img = ''; |
60 | 60 | element.attr("style", 'background-color:white'); |
61 | | - } |
| 61 | + } |
62 | 62 | element.css({ |
63 | | - 'background-size': 'cover' |
| 63 | + 'background-size': 'cover !important' |
64 | 64 | }); |
65 | 65 | }); |
66 | | - } |
| 66 | + } |
67 | 67 | else { |
68 | | - img = ""; |
69 | | - element.attr("style", 'background-color:white'); |
| 68 | + img = ""; |
| 69 | + element.attr("style", 'background-color:white'); |
70 | 70 | element.css({ |
71 | | - 'background-size': 'cover' |
| 71 | + 'background-size': 'cover !important' |
72 | 72 | }); |
73 | 73 | } |
74 | 74 | }); |
75 | 75 | }; |
76 | | - }]) |
77 | | - |
| 76 | + }]) |
| 77 | + |
78 | 78 | .directive('imgPreload', ['$rootScope', function ($rootScope) { |
79 | 79 | return { |
80 | | - restrict: 'A', |
| 80 | + restrict: 'A', |
81 | 81 | scope: { |
82 | 82 | ngSrc: '@' |
83 | | - }, |
| 83 | + }, |
84 | 84 | link: function (scope, element, attrs) { |
85 | 85 | element.on('load', function () { |
86 | 86 | element.addClass('in'); |
87 | | - }).on('error', function () { |
88 | | - // |
89 | | - }); |
90 | | - |
| 87 | + }).on('error', function () { |
| 88 | + // |
| 89 | + }); |
| 90 | + |
91 | 91 | scope.$watch('ngSrc', function (newVal) { |
92 | 92 | element.removeClass('in'); |
93 | 93 | }); |
94 | 94 | } |
95 | 95 | }; |
96 | | - }]) |
97 | | - |
| 96 | + }]) |
| 97 | + |
98 | 98 | .directive('emitLastRepeaterElement', function () { |
99 | 99 | return function (scope) { |
100 | 100 | if (scope.$last) { |
101 | 101 | scope.$emit('LastRepeaterElement'); |
102 | 102 | } |
103 | 103 | }; |
104 | | - }) |
105 | | - |
| 104 | + }) |
| 105 | + |
106 | 106 | .directive('imageCarousel', function ($timeout) { |
107 | 107 | return { |
108 | | - restrict: 'A', |
109 | | - scope: {}, |
| 108 | + restrict: 'A', |
| 109 | + scope: {}, |
110 | 110 | link: function (scope, elem, attrs) { |
111 | | - scope.carousel = null; |
112 | | - scope.timeout = null; |
| 111 | + scope.carousel = null; |
| 112 | + scope.timeout = null; |
113 | 113 | function initCarousel() { |
114 | 114 | if (scope.timeout) { |
115 | 115 | $timeout.cancel(scope.timeout); |
116 | | - } |
| 116 | + } |
117 | 117 | if (scope.carousel) { |
118 | | - scope.carousel.trigger("destroy.owl.carousel"); |
| 118 | + scope.carousel.trigger("destroy.owl.carousel"); |
119 | 119 | $(elem).find(".owl-stage-outer").remove(); |
120 | | - } |
121 | | - scope.carousel = null; |
| 120 | + } |
| 121 | + scope.carousel = null; |
122 | 122 | scope.timeout = $timeout(function () { |
123 | 123 | var obj = { |
124 | | - loop: false, |
125 | | - nav: false, |
| 124 | + loop: false, |
| 125 | + nav: false, |
126 | 126 | items: 1 |
127 | | - }; |
| 127 | + }; |
128 | 128 | scope.carousel = $(elem).owlCarousel(obj); |
129 | 129 | }, 100); |
130 | | - } |
131 | | - |
132 | | - initCarousel(); |
| 130 | + } |
| 131 | + |
| 132 | + initCarousel(); |
133 | 133 | attrs.$observe("imageCarousel", function (newVal, oldVal) { |
134 | 134 | if (newVal) { |
135 | 135 | if (scope.carousel) { |
|
0 commit comments