forked from stevethecollier/angular-backstrech
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathangular-backstretch.js
48 lines (33 loc) · 1.39 KB
/
angular-backstretch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Title: ngBackstretch
* Description: An angular directive to assist the use of jQuery Backstretch.
* A plugin by Robbin & Co http://srobbin.com/jquery-plugins/backstretch/
* Version: 1.0.0
* Authors: Steven Collier, Erik Zettersten
*/
(function() {
/* Start ngBackstretch */
'use strict';
angular.module('ngBackstretch', [])
.directive('ngBackstretch', [
function() {
if (typeof $.fn.backstretch !== 'function')
throw new Error('ngBackstretch | Please make sure the jquery backstretch plugin is included before this directive is added.')
return {
restrict: 'E',
scope: {
configuration: '='
},
link: function(scope, element, attr) {
var images = scope.configuration.images || [];
var options = scope.configuration.options || {};
if (images.length == 0)
throw new Error('myBackstretch | You have not declared an image to be stretched.');
if (element.context.toString().match(/HTMLBodyElement/gi) || options.bodyBackground)
return $.backstretch(images, options);
$(element).backstretch(images, options);
}
}
}
]);
}).call(this);