From 8ddbe69ec07df2dcd971a6023839e7942fc9c41c Mon Sep 17 00:00:00 2001 From: Erik Zettersten Date: Sun, 6 Apr 2014 15:15:20 -0400 Subject: [PATCH 1/6] Updated to version 1.0.0 - Fixes an issue with a missing comma - Throws errors when dependencies are missing - Uses correct API when the body element is the context element - Changes API to use the directive attr as opposed to its own attr (no more background-url) - Added "ng" in front of directive. This is a design trend most devs are following. --- angular-backstretch.js | 51 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/angular-backstretch.js b/angular-backstretch.js index 34f9570..4082265 100644 --- a/angular-backstretch.js +++ b/angular-backstretch.js @@ -1,9 +1,42 @@ -angular.module('backstretch') - .directive('backstretch', function () { - return { - restrict: 'A' - link: function (scope, element, attr) { - $(element).backstretch(attr.backgroundUrl); - } - } - }); \ No newline at end of file +/* + * 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).length) + return $.backstretch(attr.ngBackstretch); + + $(element).backstretch(attr.ngBackstretch); + + } + } + + } + + ]); + +}).call(this); From 477a4aa687a8e665d4530a857bc32063c504c141 Mon Sep 17 00:00:00 2001 From: Erik Zettersten Date: Sun, 6 Apr 2014 15:15:46 -0400 Subject: [PATCH 2/6] Updated to version 1.0.0 --- component.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/component.json b/component.json index cf504e1..f40847d 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "angular-backstrech", - "version": "0.0.1", + "version": "1.0.0", "main": "angular-backstretch.js", "ignore": [ "**/.*", @@ -11,4 +11,4 @@ "jquery": ">1.9.1", "jquery-backstretch": "https://raw.github.com/srobbin/jquery-backstretch/master/jquery.backstretch.min.js" } -} \ No newline at end of file +} From 9e4c50e044571d891f67e635ccde5d7106ab5b0a Mon Sep 17 00:00:00 2001 From: Erik Zettersten Date: Sun, 6 Apr 2014 15:16:57 -0400 Subject: [PATCH 3/6] Updated to version 1.0.0 --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f897cf6..e45ab27 100644 --- a/README.md +++ b/README.md @@ -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: `` \ No newline at end of file +2. Add it as a dependency of your main module: `angular.module('app', ['ngBackstretch'])` +3. Declare an HTML element using the directive: `
` + +Version 1.0.0 From 1904e73607e7081ba2e5b21f07a0357a7cb129b2 Mon Sep 17 00:00:00 2001 From: Erik Zettersten Date: Sun, 6 Apr 2014 15:24:08 -0400 Subject: [PATCH 4/6] Fixes minor issue with length of a null match result - Version bump to 1.0.1 --- angular-backstretch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-backstretch.js b/angular-backstretch.js index 4082265..bb05f5c 100644 --- a/angular-backstretch.js +++ b/angular-backstretch.js @@ -27,7 +27,7 @@ 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).length) + if (element.context.toString().match(/HTMLBodyElement/gi)) return $.backstretch(attr.ngBackstretch); $(element).backstretch(attr.ngBackstretch); From f0df075731eb1dc173d452f2bc717ba0180efff6 Mon Sep 17 00:00:00 2001 From: Erik Zettersten Date: Sun, 6 Apr 2014 15:24:27 -0400 Subject: [PATCH 5/6] Updated to version 1.0.1 --- component.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component.json b/component.json index f40847d..e1fac85 100644 --- a/component.json +++ b/component.json @@ -1,6 +1,6 @@ { "name": "angular-backstrech", - "version": "1.0.0", + "version": "1.0.1", "main": "angular-backstretch.js", "ignore": [ "**/.*", From bccdff3ab179837800e2870c8725ffba1e57b9b6 Mon Sep 17 00:00:00 2001 From: Erik Zettersten Date: Sun, 6 Apr 2014 15:24:40 -0400 Subject: [PATCH 6/6] Updated to version 1.0.1 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e45ab27..f46e0ab 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,4 @@ Get the last `angular-backstretch.js` from here OR install it via bower: `bower 2. Add it as a dependency of your main module: `angular.module('app', ['ngBackstretch'])` 3. Declare an HTML element using the directive: `
` -Version 1.0.0 +Version 1.0.1