Skip to content

Commit fbfa444

Browse files
authored
Merge pull request #83 from ahabeb/master
fix background issue
2 parents e4ba78f + 8a5debe commit fbfa444

File tree

1 file changed

+56
-56
lines changed

1 file changed

+56
-56
lines changed

widget/directives.js

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,135 @@
11
(function (angular, buildfire) {
2-
"use strict";
3-
angular
4-
.module('folderPluginWidget')
5-
2+
"use strict";
3+
angular
4+
.module('folderPluginWidget')
5+
66
.directive("loadImage", function () {
77
return {
8-
restrict: 'A',
8+
restrict: 'A',
99
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+
1212
attrs.$observe('finalSrc', function () {
13-
var _img = attrs.finalSrc;
14-
13+
var _img = attrs.finalSrc;
14+
1515
if (attrs.cropType == 'resize') {
1616
buildfire.imageLib.local.resizeImage(_img, {
17-
width: attrs.cropWidth,
17+
width: attrs.cropWidth,
1818
height: attrs.cropHeight
1919
}, function (err, imgUrl) {
20-
_img = imgUrl;
20+
_img = imgUrl;
2121
replaceImg(_img);
2222
});
2323
} else {
2424
buildfire.imageLib.local.cropImage(_img, {
25-
width: attrs.cropWidth,
25+
width: attrs.cropWidth,
2626
height: attrs.cropHeight
2727
}, function (err, imgUrl) {
28-
_img = imgUrl;
28+
_img = imgUrl;
2929
replaceImg(_img);
3030
});
3131
}
32-
});
33-
32+
});
33+
3434
function replaceImg(finalSrc) {
35-
var elem = $("<img>");
35+
var elem = $("<img>");
3636
elem[0].onload = function () {
37-
element.attr("src", finalSrc);
37+
element.attr("src", finalSrc);
3838
elem.remove();
39-
};
39+
};
4040
elem.attr("src", finalSrc);
4141
}
4242
}
4343
};
44-
})
45-
44+
})
45+
4646
.directive('backImg', ["$rootScope", function ($rootScope) {
4747
return function (scope, element, attrs) {
4848
attrs.$observe('backImg', function (value) {
49-
var img = '';
49+
var img = '';
5050
if (value) {
5151
buildfire.imageLib.local.cropImage(value, {
52-
width: window.innerWidth,
52+
width: window.innerWidth,
5353
height: window.innerHeight
5454
}, function (err, imgUrl) {
5555
if (imgUrl) {
56-
img = imgUrl;
56+
img = imgUrl;
5757
element.attr("style", 'background:url(' + img + ') !important ; background-size: cover !important;');
5858
} else {
59-
img = '';
59+
img = '';
6060
element.attr("style", 'background-color:white');
61-
}
61+
}
6262
element.css({
63-
'background-size': 'cover'
63+
'background-size': 'cover !important'
6464
});
6565
});
66-
}
66+
}
6767
else {
68-
img = "";
69-
element.attr("style", 'background-color:white');
68+
img = "";
69+
element.attr("style", 'background-color:white');
7070
element.css({
71-
'background-size': 'cover'
71+
'background-size': 'cover !important'
7272
});
7373
}
7474
});
7575
};
76-
}])
77-
76+
}])
77+
7878
.directive('imgPreload', ['$rootScope', function ($rootScope) {
7979
return {
80-
restrict: 'A',
80+
restrict: 'A',
8181
scope: {
8282
ngSrc: '@'
83-
},
83+
},
8484
link: function (scope, element, attrs) {
8585
element.on('load', function () {
8686
element.addClass('in');
87-
}).on('error', function () {
88-
//
89-
});
90-
87+
}).on('error', function () {
88+
//
89+
});
90+
9191
scope.$watch('ngSrc', function (newVal) {
9292
element.removeClass('in');
9393
});
9494
}
9595
};
96-
}])
97-
96+
}])
97+
9898
.directive('emitLastRepeaterElement', function () {
9999
return function (scope) {
100100
if (scope.$last) {
101101
scope.$emit('LastRepeaterElement');
102102
}
103103
};
104-
})
105-
104+
})
105+
106106
.directive('imageCarousel', function ($timeout) {
107107
return {
108-
restrict: 'A',
109-
scope: {},
108+
restrict: 'A',
109+
scope: {},
110110
link: function (scope, elem, attrs) {
111-
scope.carousel = null;
112-
scope.timeout = null;
111+
scope.carousel = null;
112+
scope.timeout = null;
113113
function initCarousel() {
114114
if (scope.timeout) {
115115
$timeout.cancel(scope.timeout);
116-
}
116+
}
117117
if (scope.carousel) {
118-
scope.carousel.trigger("destroy.owl.carousel");
118+
scope.carousel.trigger("destroy.owl.carousel");
119119
$(elem).find(".owl-stage-outer").remove();
120-
}
121-
scope.carousel = null;
120+
}
121+
scope.carousel = null;
122122
scope.timeout = $timeout(function () {
123123
var obj = {
124-
loop: false,
125-
nav: false,
124+
loop: false,
125+
nav: false,
126126
items: 1
127-
};
127+
};
128128
scope.carousel = $(elem).owlCarousel(obj);
129129
}, 100);
130-
}
131-
132-
initCarousel();
130+
}
131+
132+
initCarousel();
133133
attrs.$observe("imageCarousel", function (newVal, oldVal) {
134134
if (newVal) {
135135
if (scope.carousel) {

0 commit comments

Comments
 (0)