diff --git a/app/index.html b/app/index.html index e068040..6e9d983 100644 --- a/app/index.html +++ b/app/index.html @@ -10,12 +10,12 @@ - - + + - - + + @@ -26,48 +26,40 @@
- - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + diff --git a/app/scripts/controllers/logo.js b/app/scripts/controllers/logo.js index a6c18da..290f360 100644 --- a/app/scripts/controllers/logo.js +++ b/app/scripts/controllers/logo.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('loremImageLogoApp') - .controller('LogoCtrl', function ($scope, $timeout, $safeApply) { + .controller('LogoCtrl', ['$scope', '$timeout', '$safeApply', '_', function ($scope, $timeout, $safeApply, _) { // $scope.loadingState = true; @@ -10,10 +10,10 @@ angular.module('loremImageLogoApp') // }, 1000); $scope.sections = ['No Section'].concat('abstract animals business cats city food nightlife fashion people nature sports technics transport'.split(' ').sort()) - .map(function(section, i) { + .map(function(section) { return { label: section, - value: section == 'No Section' ? null : section + value: section === 'No Section' ? null : section }; }); @@ -48,10 +48,10 @@ angular.module('loremImageLogoApp') $scope.getUncachedImageUrl = function(cacheToken) { return $scope.imageUrl + '?no-cache=' + cacheToken;//(cacheToken || ((+ new Date) + '_' + Math.random())); - } + }; $scope.$watch('imageParams', _.throttle(function() { $scope.paramsToUrl(); $safeApply(); }, 100, true) , true); - }); + }]); diff --git a/app/scripts/services/dependencies.js b/app/scripts/services/dependencies.js new file mode 100644 index 0000000..3214e68 --- /dev/null +++ b/app/scripts/services/dependencies.js @@ -0,0 +1,35 @@ +// create factory aliases for any 3rd party component +// in order to make them testable and to use them through angular's DI mechanism +// this also prevents accessing unsafe global variables and please jshint +// @usage: +// angular.module('loremImageLogoApp').controller('someController', function(jQuery) { +// // use jQuery here, as it's not a global var pinned on the window object +// // later on, if you want to use jqueryLite instead of jQuery, you could easily modify +// }) + +(function() { + 'use strict'; + + var module = angular.module('loremImageLogoApp'), + + // function that creates a factory returning the actual global variable + createFactory = function (dependency) { + module.factory(dependency, ['$window', function ($window) { + return $window[dependency]; + }]); + }, + + // this is the list of the used js dependencies + jsDependencies = ['jQuery', '_']; + + // store them as avalue in angular + // so we can test all th dependencies + module.value('jsDependencies', jsDependencies); + + // special case for $ jQuery + module.factory('$', ['$window', function($window) { + return $window.jQuery; + }]); + + angular.forEach(jsDependencies, createFactory); +})();