Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ A simple AngularJS directive to use jQuery backstretch plugin (http://srobbin.co

## Installation

Get the last `angular-backstretch.js` from here OR install it via Twitter bower: `bower install angular-backstretch`
Get the last `angular-backstretch.js` from here OR install it via bower: `bower install angular-backstretch`

## Setup

1. Include `angular-backstretch.js` in your project
2. Add it as a dependency of your main module: `angular.module('app', ['backstretch'])`
3. Declare an HTML element using the directive: `<body backstretch background-url="..."></body>`
2. Add it as a dependency of your main module: `angular.module('app', ['ngBackstretch'])`
3. Declare an HTML element using the directive: `<div ng-backstretch="..."></div>`

Version 1.0.1
51 changes: 42 additions & 9 deletions angular-backstretch.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,42 @@
angular.module('backstretch')
.directive('backstretch', function () {
return {
restrict: 'A'
link: function (scope, element, attr) {
$(element).backstretch(attr.backgroundUrl);
}
}
});
/*
* 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);
4 changes: 2 additions & 2 deletions component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-backstrech",
"version": "0.0.1",
"version": "1.0.1",
"main": "angular-backstretch.js",
"ignore": [
"**/.*",
Expand All @@ -11,4 +11,4 @@
"jquery": ">1.9.1",
"jquery-backstretch": "https://raw.github.com/srobbin/jquery-backstretch/master/jquery.backstretch.min.js"
}
}
}