forked from arnaudbreton/angular-backstrech
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathangular-backstretch.js
42 lines (28 loc) · 1.18 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
/*
* 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: 'A',
link: function(scope, element, attr) {
if (attr.ngBackstretch === '' || typeof attr.ngBackstretch === 'undefined')
throw new Error('ngBackstretch | You have not declared an image to be stretched.')
if (element.context.toString().match(/HTMLBodyElement/gi))
return $.backstretch(attr.ngBackstretch);
$(element).backstretch(attr.ngBackstretch);
}
}
}
]);
}).call(this);