From 2c93783aa1d47bf3b2e40c0a5dd378c436131ab6 Mon Sep 17 00:00:00 2001 From: praneethkumarpidugu Date: Fri, 24 Jun 2016 23:33:26 -0400 Subject: [PATCH] Setting up inifinite Scroll --- libs/ladda/.bower.json | 2 +- libs/ngInfiniteScroll/.bower.json | 28 + libs/ngInfiniteScroll/LICENSE | 22 + libs/ngInfiniteScroll/README.md | 67 ++ libs/ngInfiniteScroll/bower.json | 16 + .../build/ng-infinite-scroll.js | 190 ++++ .../build/ng-infinite-scroll.min.js | 2 + libs/ngInfiniteScroll/package.json | 41 + .../src/infinite-scroll.coffee | 207 ++++ libs/spin.js/.bower.json | 4 +- section6/lesson1/index.html | 3 +- section6/lesson1/main.js | 931 +----------------- 12 files changed, 603 insertions(+), 910 deletions(-) create mode 100644 libs/ngInfiniteScroll/.bower.json create mode 100644 libs/ngInfiniteScroll/LICENSE create mode 100644 libs/ngInfiniteScroll/README.md create mode 100644 libs/ngInfiniteScroll/bower.json create mode 100644 libs/ngInfiniteScroll/build/ng-infinite-scroll.js create mode 100644 libs/ngInfiniteScroll/build/ng-infinite-scroll.min.js create mode 100644 libs/ngInfiniteScroll/package.json create mode 100644 libs/ngInfiniteScroll/src/infinite-scroll.coffee diff --git a/libs/ladda/.bower.json b/libs/ladda/.bower.json index 26a3835..d7b2579 100644 --- a/libs/ladda/.bower.json +++ b/libs/ladda/.bower.json @@ -19,6 +19,6 @@ "commit": "efbd6e0e4fec7e38eaacbcd0197a8b93e66252b7" }, "_source": "https://github.com/hakimel/Ladda.git", - "_target": "~0.9.8", + "_target": "~0.9.3", "_originalSource": "ladda" } \ No newline at end of file diff --git a/libs/ngInfiniteScroll/.bower.json b/libs/ngInfiniteScroll/.bower.json new file mode 100644 index 0000000..808ce89 --- /dev/null +++ b/libs/ngInfiniteScroll/.bower.json @@ -0,0 +1,28 @@ +{ + "name": "ngInfiniteScroll", + "main": "build/ng-infinite-scroll.js", + "ignore": [ + "**/.*", + "_*", + "node_modules", + "compile", + "test", + "Gruntfile.coffee", + ".*" + ], + "dependencies": { + "angular": ">=1.2.0" + }, + "homepage": "https://github.com/sroze/ngInfiniteScroll", + "version": "1.2.2", + "_release": "1.2.2", + "_resolution": { + "type": "version", + "tag": "1.2.2", + "commit": "f2fbba21726d5fd4889aeb087491d99f491e14e1" + }, + "_source": "https://github.com/sroze/ngInfiniteScroll.git", + "_target": "^1.2.2", + "_originalSource": "ngInfiniteScroll", + "_direct": true +} \ No newline at end of file diff --git a/libs/ngInfiniteScroll/LICENSE b/libs/ngInfiniteScroll/LICENSE new file mode 100644 index 0000000..949e708 --- /dev/null +++ b/libs/ngInfiniteScroll/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2012 Brandon Tilley + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/libs/ngInfiniteScroll/README.md b/libs/ngInfiniteScroll/README.md new file mode 100644 index 0000000..d04640f --- /dev/null +++ b/libs/ngInfiniteScroll/README.md @@ -0,0 +1,67 @@ +![logo](http://sroze.github.com/ngInfiniteScroll/images/logo-resized.png) + +[![Build Status](https://travis-ci.org/sroze/ngInfiniteScroll.png?branch=master)](https://travis-ci.org/sroze/ngInfiniteScroll) + +ngInfiniteScroll is a directive for [AngularJS](http://angularjs.org/) to evaluate an expression when the bottom of the directive's element approaches the bottom of the browser window, which can be used to implement infinite scrolling. + +Demos +----- + +Check out the running demos [at the ngInfiniteScroll web site](http://sroze.github.com/ngInfiniteScroll/demos.html). + +Version Numbers +--------------- + +ngInfinite Scroll follows [semantic versioning](http://semver.org/) and uses the following versioning scheme: + + * Versions starting with 0 (e.g. 0.1.0, 0.2.0, etc.) are for initial development, and the API is not stable + * Versions with an even minor version (1.0.0, 1.4.0, 2.2.0, etc.) are stable releases + * Versions with an odd minor version (1.1.0, 1.3.0, 2.1.0, etc.) are development releases + +The [download page](http://sroze.github.com/ngInfiniteScroll/#download) allows you to pick among various versions and specify which releases are stable (not including pre-release builds). + +Getting Started +--------------- + + * Download ngInfiniteScroll from [the download page on the ngInfiniteScroll web site](http://sroze.github.com/ngInfiniteScroll/#download) or install it with: + * [Bower](http://bower.io/) via `bower install ngInfiniteScroll` + * [Nuget](https://www.nuget.org) via `PM> Install-Package ng-infinite-scroll` + * Include the script tag on your page after the AngularJS and jQuery script tags (ngInfiniteScroll requires jQuery to run) + + + + + + * Ensure that your application module specifies `infinite-scroll` as a dependency: + + angular.module('myApplication', ['infinite-scroll']); + + * Use the directive by specifying an `infinite-scroll` attribute on an element. + +
+ +Note that neither the module nor the directive use the `ng` prefix, as that prefix is reserved for the core Angular module. + +Detailed Documentation +---------------------- + +ngInfiniteScroll accepts several attributes to customize the behavior of the directive; detailed instructions can be found [on the ngInfiniteScroll web site](http://sroze.github.com/ngInfiniteScroll/documentation.html). + +Ports +----- + +If you use [AngularDart](https://github.com/angular/angular.dart), Juha Komulainen has [a port of the project](http://pub.dartlang.org/packages/ng_infinite_scroll) you can use. + +License +------- + +ngInfiniteScroll is licensed under the MIT license. See the LICENSE file for more details. + +Testing +------- + +ngInfiniteScroll uses Protractor for testing. Note that you will need to have Chrome browser, and the `grunt-cli` npm package installed globally if you wish to use grunt (`npm install -g grunt-cli`). Then, install the dependencies with `npm install`. + +* `grunt test:protractor-local` - run tests + +Thank you very much @pomerantsev for your work on these Protractor tests. diff --git a/libs/ngInfiniteScroll/bower.json b/libs/ngInfiniteScroll/bower.json new file mode 100644 index 0000000..1171c45 --- /dev/null +++ b/libs/ngInfiniteScroll/bower.json @@ -0,0 +1,16 @@ +{ + "name": "ngInfiniteScroll", + "main": "build/ng-infinite-scroll.js", + "ignore": [ + "**/.*", + "_*", + "node_modules", + "compile", + "test", + "Gruntfile.coffee", + ".*" + ], + "dependencies": { + "angular": ">=1.2.0" + } +} diff --git a/libs/ngInfiniteScroll/build/ng-infinite-scroll.js b/libs/ngInfiniteScroll/build/ng-infinite-scroll.js new file mode 100644 index 0000000..5d89eee --- /dev/null +++ b/libs/ngInfiniteScroll/build/ng-infinite-scroll.js @@ -0,0 +1,190 @@ +/* ng-infinite-scroll - v1.2.0 - 2015-12-02 */ +var mod; + +mod = angular.module('infinite-scroll', []); + +mod.value('THROTTLE_MILLISECONDS', null); + +mod.directive('infiniteScroll', [ + '$rootScope', '$window', '$interval', 'THROTTLE_MILLISECONDS', function($rootScope, $window, $interval, THROTTLE_MILLISECONDS) { + return { + scope: { + infiniteScroll: '&', + infiniteScrollContainer: '=', + infiniteScrollDistance: '=', + infiniteScrollDisabled: '=', + infiniteScrollUseDocumentBottom: '=', + infiniteScrollListenForEvent: '@' + }, + link: function(scope, elem, attrs) { + var changeContainer, checkInterval, checkWhenEnabled, container, handleInfiniteScrollContainer, handleInfiniteScrollDisabled, handleInfiniteScrollDistance, handleInfiniteScrollUseDocumentBottom, handler, height, immediateCheck, offsetTop, pageYOffset, scrollDistance, scrollEnabled, throttle, unregisterEventListener, useDocumentBottom, windowElement; + windowElement = angular.element($window); + scrollDistance = null; + scrollEnabled = null; + checkWhenEnabled = null; + container = null; + immediateCheck = true; + useDocumentBottom = false; + unregisterEventListener = null; + checkInterval = false; + height = function(elem) { + elem = elem[0] || elem; + if (isNaN(elem.offsetHeight)) { + return elem.document.documentElement.clientHeight; + } else { + return elem.offsetHeight; + } + }; + offsetTop = function(elem) { + if (!elem[0].getBoundingClientRect || elem.css('none')) { + return; + } + return elem[0].getBoundingClientRect().top + pageYOffset(elem); + }; + pageYOffset = function(elem) { + elem = elem[0] || elem; + if (isNaN(window.pageYOffset)) { + return elem.document.documentElement.scrollTop; + } else { + return elem.ownerDocument.defaultView.pageYOffset; + } + }; + handler = function() { + var containerBottom, containerTopOffset, elementBottom, remaining, shouldScroll; + if (container === windowElement) { + containerBottom = height(container) + pageYOffset(container[0].document.documentElement); + elementBottom = offsetTop(elem) + height(elem); + } else { + containerBottom = height(container); + containerTopOffset = 0; + if (offsetTop(container) !== void 0) { + containerTopOffset = offsetTop(container); + } + elementBottom = offsetTop(elem) - containerTopOffset + height(elem); + } + if (useDocumentBottom) { + elementBottom = height((elem[0].ownerDocument || elem[0].document).documentElement); + } + remaining = elementBottom - containerBottom; + shouldScroll = remaining <= height(container) * scrollDistance + 1; + if (shouldScroll) { + checkWhenEnabled = true; + if (scrollEnabled) { + if (scope.$$phase || $rootScope.$$phase) { + return scope.infiniteScroll(); + } else { + return scope.$apply(scope.infiniteScroll); + } + } + } else { + if (checkInterval) { + $interval.cancel(checkInterval); + } + return checkWhenEnabled = false; + } + }; + throttle = function(func, wait) { + var later, previous, timeout; + timeout = null; + previous = 0; + later = function() { + var context; + previous = new Date().getTime(); + $interval.cancel(timeout); + timeout = null; + func.call(); + return context = null; + }; + return function() { + var now, remaining; + now = new Date().getTime(); + remaining = wait - (now - previous); + if (remaining <= 0) { + clearTimeout(timeout); + $interval.cancel(timeout); + timeout = null; + previous = now; + return func.call(); + } else { + if (!timeout) { + return timeout = $interval(later, remaining, 1); + } + } + }; + }; + if (THROTTLE_MILLISECONDS != null) { + handler = throttle(handler, THROTTLE_MILLISECONDS); + } + scope.$on('$destroy', function() { + container.unbind('scroll', handler); + if (unregisterEventListener != null) { + unregisterEventListener(); + return unregisterEventListener = null; + } + }); + handleInfiniteScrollDistance = function(v) { + return scrollDistance = parseFloat(v) || 0; + }; + scope.$watch('infiniteScrollDistance', handleInfiniteScrollDistance); + handleInfiniteScrollDistance(scope.infiniteScrollDistance); + handleInfiniteScrollDisabled = function(v) { + scrollEnabled = !v; + if (scrollEnabled && checkWhenEnabled) { + checkWhenEnabled = false; + return handler(); + } + }; + scope.$watch('infiniteScrollDisabled', handleInfiniteScrollDisabled); + handleInfiniteScrollDisabled(scope.infiniteScrollDisabled); + handleInfiniteScrollUseDocumentBottom = function(v) { + return useDocumentBottom = v; + }; + scope.$watch('infiniteScrollUseDocumentBottom', handleInfiniteScrollUseDocumentBottom); + handleInfiniteScrollUseDocumentBottom(scope.infiniteScrollUseDocumentBottom); + changeContainer = function(newContainer) { + if (container != null) { + container.unbind('scroll', handler); + } + container = newContainer; + if (newContainer != null) { + return container.bind('scroll', handler); + } + }; + changeContainer(windowElement); + if (scope.infiniteScrollListenForEvent) { + unregisterEventListener = $rootScope.$on(scope.infiniteScrollListenForEvent, handler); + } + handleInfiniteScrollContainer = function(newContainer) { + if ((newContainer == null) || newContainer.length === 0) { + return; + } + if (newContainer instanceof HTMLElement) { + newContainer = angular.element(newContainer); + } else if (typeof newContainer.append === 'function') { + newContainer = angular.element(newContainer[newContainer.length - 1]); + } else if (typeof newContainer === 'string') { + newContainer = angular.element(document.querySelector(newContainer)); + } + if (newContainer != null) { + return changeContainer(newContainer); + } else { + throw new Exception("invalid infinite-scroll-container attribute."); + } + }; + scope.$watch('infiniteScrollContainer', handleInfiniteScrollContainer); + handleInfiniteScrollContainer(scope.infiniteScrollContainer || []); + if (attrs.infiniteScrollParent != null) { + changeContainer(angular.element(elem.parent())); + } + if (attrs.infiniteScrollImmediateCheck != null) { + immediateCheck = scope.$eval(attrs.infiniteScrollImmediateCheck); + } + return checkInterval = $interval((function() { + if (immediateCheck) { + return handler(); + } + }), 0); + } + }; + } +]); diff --git a/libs/ngInfiniteScroll/build/ng-infinite-scroll.min.js b/libs/ngInfiniteScroll/build/ng-infinite-scroll.min.js new file mode 100644 index 0000000..ae931e5 --- /dev/null +++ b/libs/ngInfiniteScroll/build/ng-infinite-scroll.min.js @@ -0,0 +1,2 @@ +/* ng-infinite-scroll - v1.2.0 - 2015-12-02 */ +var mod;mod=angular.module("infinite-scroll",[]),mod.value("THROTTLE_MILLISECONDS",null),mod.directive("infiniteScroll",["$rootScope","$window","$interval","THROTTLE_MILLISECONDS",function(a,b,c,d){return{scope:{infiniteScroll:"&",infiniteScrollContainer:"=",infiniteScrollDistance:"=",infiniteScrollDisabled:"=",infiniteScrollUseDocumentBottom:"=",infiniteScrollListenForEvent:"@"},link:function(e,f,g){var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;return z=angular.element(b),u=null,v=null,j=null,k=null,r=!0,y=!1,x=null,i=!1,q=function(a){return a=a[0]||a,isNaN(a.offsetHeight)?a.document.documentElement.clientHeight:a.offsetHeight},s=function(a){return a[0].getBoundingClientRect&&!a.css("none")?a[0].getBoundingClientRect().top+t(a):void 0},t=function(a){return a=a[0]||a,isNaN(window.pageYOffset)?a.document.documentElement.scrollTop:a.ownerDocument.defaultView.pageYOffset},p=function(){var b,d,g,h,l;return k===z?(b=q(k)+t(k[0].document.documentElement),g=s(f)+q(f)):(b=q(k),d=0,void 0!==s(k)&&(d=s(k)),g=s(f)-d+q(f)),y&&(g=q((f[0].ownerDocument||f[0].document).documentElement)),h=g-b,l=h<=q(k)*u+1,l?(j=!0,v?e.$$phase||a.$$phase?e.infiniteScroll():e.$apply(e.infiniteScroll):void 0):(i&&c.cancel(i),j=!1)},w=function(a,b){var d,e,f;return f=null,e=0,d=function(){var b;return e=(new Date).getTime(),c.cancel(f),f=null,a.call(),b=null},function(){var g,h;return g=(new Date).getTime(),h=b-(g-e),0>=h?(clearTimeout(f),c.cancel(f),f=null,e=g,a.call()):f?void 0:f=c(d,h,1)}},null!=d&&(p=w(p,d)),e.$on("$destroy",function(){return k.unbind("scroll",p),null!=x?(x(),x=null):void 0}),n=function(a){return u=parseFloat(a)||0},e.$watch("infiniteScrollDistance",n),n(e.infiniteScrollDistance),m=function(a){return v=!a,v&&j?(j=!1,p()):void 0},e.$watch("infiniteScrollDisabled",m),m(e.infiniteScrollDisabled),o=function(a){return y=a},e.$watch("infiniteScrollUseDocumentBottom",o),o(e.infiniteScrollUseDocumentBottom),h=function(a){return null!=k&&k.unbind("scroll",p),k=a,null!=a?k.bind("scroll",p):void 0},h(z),e.infiniteScrollListenForEvent&&(x=a.$on(e.infiniteScrollListenForEvent,p)),l=function(a){if(null!=a&&0!==a.length){if(a instanceof HTMLElement?a=angular.element(a):"function"==typeof a.append?a=angular.element(a[a.length-1]):"string"==typeof a&&(a=angular.element(document.querySelector(a))),null!=a)return h(a);throw new Exception("invalid infinite-scroll-container attribute.")}},e.$watch("infiniteScrollContainer",l),l(e.infiniteScrollContainer||[]),null!=g.infiniteScrollParent&&h(angular.element(f.parent())),null!=g.infiniteScrollImmediateCheck&&(r=e.$eval(g.infiniteScrollImmediateCheck)),i=c(function(){return r?p():void 0},0)}}}]); \ No newline at end of file diff --git a/libs/ngInfiniteScroll/package.json b/libs/ngInfiniteScroll/package.json new file mode 100644 index 0000000..5754fa1 --- /dev/null +++ b/libs/ngInfiniteScroll/package.json @@ -0,0 +1,41 @@ +{ + "name": "ng-infinite-scroll", + "version": "1.2.0", + "description": "Infinite scrolling for AngularJS", + "repository": { + "type": "git", + "url": "git://github.com/sroze/ngInfiniteScroll.git" + }, + "browser": "build/ng-infinite-scroll.js", + "scripts": { + "test": "grunt test:protractor-local" + }, + "author": { + "name": "Brandon Tilley", + "email": "brandon@brandontilley.com", + "url": "http://brandontilley.com" + }, + "contributors": [ + { + "name": "Samuel ROZE", + "email": "samuel.roze@gmail.com", + "url": "http://sroze.io" + } + ], + "license": "MIT", + "readmeFilename": "README.md", + "devDependencies": { + "coffee-script": "~1.8.0", + "grunt": "~0.4.5", + "grunt-coffeelint": "~0.0.13", + "grunt-contrib-clean": "~0.6.0", + "grunt-contrib-coffee": "~0.12.0", + "grunt-contrib-concat": "~0.5.0", + "grunt-contrib-connect": "0.8.0", + "grunt-contrib-uglify": "~0.6.0", + "grunt-protractor-runner": "1.1.4", + "mkdirp": "0.5.0", + "protractor": "1.4.0", + "sauce-connect-launcher": "0.9.0" + } +} diff --git a/libs/ngInfiniteScroll/src/infinite-scroll.coffee b/libs/ngInfiniteScroll/src/infinite-scroll.coffee new file mode 100644 index 0000000..c9ddfae --- /dev/null +++ b/libs/ngInfiniteScroll/src/infinite-scroll.coffee @@ -0,0 +1,207 @@ +mod = angular.module('infinite-scroll', []) + +mod.value('THROTTLE_MILLISECONDS', null) + +mod.directive 'infiniteScroll', ['$rootScope', '$window', '$interval', 'THROTTLE_MILLISECONDS', \ + ($rootScope, $window, $interval, THROTTLE_MILLISECONDS) -> + scope: + infiniteScroll: '&' + infiniteScrollContainer: '=' + infiniteScrollDistance: '=' + infiniteScrollDisabled: '=' + infiniteScrollUseDocumentBottom: '=', + infiniteScrollListenForEvent: '@' + + link: (scope, elem, attrs) -> + windowElement = angular.element($window) + + scrollDistance = null + scrollEnabled = null + checkWhenEnabled = null + container = null + immediateCheck = true + useDocumentBottom = false + unregisterEventListener = null + checkInterval = false + + height = (elem) -> + elem = elem[0] or elem + + if isNaN(elem.offsetHeight) then elem.document.documentElement.clientHeight else elem.offsetHeight + + offsetTop = (elem) -> + if not elem[0].getBoundingClientRect or elem.css('none') + return + + elem[0].getBoundingClientRect().top + pageYOffset(elem) + + pageYOffset = (elem) -> + elem = elem[0] or elem + + if isNaN(window.pageYOffset) then elem.document.documentElement.scrollTop else elem.ownerDocument.defaultView.pageYOffset + + # infinite-scroll specifies a function to call when the window, + # or some other container specified by infinite-scroll-container, + # is scrolled within a certain range from the bottom of the + # document. It is recommended to use infinite-scroll-disabled + # with a boolean that is set to true when the function is + # called in order to throttle the function call. + handler = -> + if container == windowElement + containerBottom = height(container) + pageYOffset(container[0].document.documentElement) + elementBottom = offsetTop(elem) + height(elem) + else + containerBottom = height(container) + containerTopOffset = 0 + if offsetTop(container) != undefined + containerTopOffset = offsetTop(container) + elementBottom = offsetTop(elem) - containerTopOffset + height(elem) + + if(useDocumentBottom) + elementBottom = height((elem[0].ownerDocument || elem[0].document).documentElement) + + remaining = elementBottom - containerBottom + shouldScroll = remaining <= height(container) * scrollDistance + 1 + + if shouldScroll + checkWhenEnabled = true + + if scrollEnabled + if scope.$$phase || $rootScope.$$phase + scope.infiniteScroll() + else + scope.$apply(scope.infiniteScroll) + else + if checkInterval then $interval.cancel checkInterval + checkWhenEnabled = false + + # The optional THROTTLE_MILLISECONDS configuration value specifies + # a minimum time that should elapse between each call to the + # handler. N.b. the first call the handler will be run + # immediately, and the final call will always result in the + # handler being called after the `wait` period elapses. + # A slimmed down version of underscore's implementation. + throttle = (func, wait) -> + timeout = null + previous = 0 + later = -> + previous = new Date().getTime() + $interval.cancel(timeout) + timeout = null + func.call() + context = null + + return -> + now = new Date().getTime() + remaining = wait - (now - previous) + if remaining <= 0 + clearTimeout timeout + $interval.cancel(timeout) + timeout = null + previous = now + func.call() + else timeout = $interval(later, remaining, 1) unless timeout + + if THROTTLE_MILLISECONDS? + handler = throttle(handler, THROTTLE_MILLISECONDS) + + scope.$on '$destroy', -> + container.unbind 'scroll', handler + if unregisterEventListener? + unregisterEventListener() + unregisterEventListener = null + + # infinite-scroll-distance specifies how close to the bottom of the page + # the window is allowed to be before we trigger a new scroll. The value + # provided is multiplied by the container height; for example, to load + # more when the bottom of the page is less than 3 container heights away, + # specify a value of 3. Defaults to 0. + handleInfiniteScrollDistance = (v) -> + scrollDistance = parseFloat(v) or 0 + + scope.$watch 'infiniteScrollDistance', handleInfiniteScrollDistance + # If I don't explicitly call the handler here, tests fail. Don't know why yet. + handleInfiniteScrollDistance scope.infiniteScrollDistance + + # infinite-scroll-disabled specifies a boolean that will keep the + # infnite scroll function from being called; this is useful for + # debouncing or throttling the function call. If an infinite + # scroll is triggered but this value evaluates to true, then + # once it switches back to false the infinite scroll function + # will be triggered again. + handleInfiniteScrollDisabled = (v) -> + scrollEnabled = !v + if scrollEnabled && checkWhenEnabled + checkWhenEnabled = false + handler() + + scope.$watch 'infiniteScrollDisabled', handleInfiniteScrollDisabled + # If I don't explicitly call the handler here, tests fail. Don't know why yet. + handleInfiniteScrollDisabled scope.infiniteScrollDisabled + + # use the bottom of the document instead of the element's bottom. + # This useful when the element does not have a height due to its + # children being absolute positioned. + handleInfiniteScrollUseDocumentBottom = (v) -> + useDocumentBottom = v + + scope.$watch 'infiniteScrollUseDocumentBottom', handleInfiniteScrollUseDocumentBottom + handleInfiniteScrollUseDocumentBottom scope.infiniteScrollUseDocumentBottom + + # infinite-scroll-container sets the container which we want to be + # infinte scrolled, instead of the whole window. Must be an + # Angular or jQuery element, or, if jQuery is loaded, + # a jQuery selector as a string. + changeContainer = (newContainer) -> + if container? + container.unbind 'scroll', handler + + container = newContainer + if newContainer? + container.bind 'scroll', handler + + changeContainer windowElement + + if scope.infiniteScrollListenForEvent + unregisterEventListener = $rootScope.$on scope.infiniteScrollListenForEvent, handler + + handleInfiniteScrollContainer = (newContainer) -> + # TODO: For some reason newContainer is sometimes null instead + # of the empty array, which Angular is supposed to pass when the + # element is not defined + # (https://github.com/sroze/ngInfiniteScroll/pull/7#commitcomment-5748431). + # So I leave both checks. + if (not newContainer?) or newContainer.length == 0 + return + + if newContainer instanceof HTMLElement + newContainer = angular.element newContainer + else if typeof newContainer.append == 'function' + newContainer = angular.element newContainer[newContainer.length - 1] + else if typeof newContainer == 'string' + newContainer = angular.element document.querySelector newContainer + + if newContainer? + changeContainer newContainer + else + throw new Exception("invalid infinite-scroll-container attribute.") + + scope.$watch 'infiniteScrollContainer', handleInfiniteScrollContainer + handleInfiniteScrollContainer(scope.infiniteScrollContainer or []) + + # infinite-scroll-parent establishes this element's parent as the + # container infinitely scrolled instead of the whole window. + if attrs.infiniteScrollParent? + changeContainer angular.element elem.parent() + + # infinte-scoll-immediate-check sets whether or not run the + # expression passed on infinite-scroll for the first time when the + # directive first loads, before any actual scroll. + if attrs.infiniteScrollImmediateCheck? + immediateCheck = scope.$eval(attrs.infiniteScrollImmediateCheck) + + checkInterval = $interval (-> + if immediateCheck + handler() + ), 0 +] diff --git a/libs/spin.js/.bower.json b/libs/spin.js/.bower.json index 6634d3b..ea27b9d 100644 --- a/libs/spin.js/.bower.json +++ b/libs/spin.js/.bower.json @@ -22,7 +22,7 @@ "tag": "v2.0.2", "commit": "ad9aa9f0a2dc6773978baa8c3aac2b551e1da000" }, - "_source": "git://github.com/fgnass/spin.js.git", - "_target": "~2.0.1", + "_source": "https://github.com/fgnass/spin.js.git", + "_target": "~2.0.2", "_originalSource": "spin.js" } \ No newline at end of file diff --git a/section6/lesson1/index.html b/section6/lesson1/index.html index 247a471..96c6fb3 100644 --- a/section6/lesson1/index.html +++ b/section6/lesson1/index.html @@ -52,7 +52,7 @@ - +
@@ -128,6 +128,7 @@ + diff --git a/section6/lesson1/main.js b/section6/lesson1/main.js index b68d820..32bf4c3 100644 --- a/section6/lesson1/main.js +++ b/section6/lesson1/main.js @@ -1,5 +1,6 @@ var app = angular.module('codecraft', [ - 'ngResource' + 'ngResource', + 'infinite-scroll' ]); //we will add the factory $httpProvider @@ -8,7 +9,9 @@ app.config(function ($httpProvider, $resourceProvider) { //In the API we have, we normally have trailing slashes and to avoid we use below setting. $resourceProvider.defaults.stripTrailingSlashes = false; }); - +app.factory('Contact', function ($resource) { + return $resource("http://codecraftpro.com/api/samples/v1/contact/:id/"); +}); app.controller('PersonDetailController', function ($scope, ContactService) { $scope.contacts = ContactService; @@ -20,6 +23,10 @@ app.controller('PersonListController', function ($scope, ContactService) { $scope.order = "email"; $scope.contacts = ContactService; + $scope.loadMore = function () { + console.log("Load More!!!"); + }; + $scope.sensitiveSearch = function (person) { if ($scope.search) { return person.name.indexOf($scope.search) == 0 || @@ -30,916 +37,28 @@ app.controller('PersonListController', function ($scope, ContactService) { }); -app.service('ContactService', function () { +app.service('ContactService', function (Contact) { - return { + var self = { 'addPerson': function (person) { this.persons.push(person); }, + 'page': 1, + 'hasMore': true, + 'isLoading': false, 'selectedPerson': null, - 'persons': [ - { - "name": "Gregory Huffman", - "email": "Praesent@pedenec.net", - "birthdate": "2015-03-23T18:00:37-07:00", - "phonenumber": "07624 073918", - "address": "5880 Sed, Street", - "city": "Denderbelle", - "country": "Ethiopia" - }, - { - "name": "Tad Vazquez", - "email": "dapibus.gravida@necimperdietnec.co.uk", - "birthdate": "2015-12-28T06:02:56-08:00", - "phonenumber": "(016977) 1036", - "address": "830-6354 Cubilia Rd.", - "city": "Sulzbach", - "country": "Liechtenstein" - }, - { - "name": "William Abbott", - "email": "non.justo.Proin@mauris.net", - "birthdate": "2015-07-30T09:00:15-07:00", - "phonenumber": "(01984) 57054", - "address": "418-3595 Orci, St.", - "city": "Lint", - "country": "Sierra Leone" - }, - { - "name": "Amal Shaw", - "email": "ornare.sagittis@ipsumPhasellus.co.uk", - "birthdate": "2014-06-01T11:06:13-07:00", - "phonenumber": "076 4830 0002", - "address": "Ap #706-3890 Lobortis St.", - "city": "Baiso", - "country": "Faroe Islands" - }, - { - "name": "Avram Barrett", - "email": "Donec@lobortisultrices.co.uk", - "birthdate": "2014-07-17T19:31:30-07:00", - "phonenumber": "(01289) 68589", - "address": "560-5646 Ipsum Rd.", - "city": "Grand-Manil", - "country": "Trinidad and Tobago" - }, - { - "name": "Hamilton Webb", - "email": "Nam@noncursusnon.ca", - "birthdate": "2015-12-11T19:31:34-08:00", - "phonenumber": "(01913) 41035", - "address": "696-957 Morbi Street", - "city": "Grand-Halleux", - "country": "Montenegro" - }, - { - "name": "Emerson Osborn", - "email": "Sed.congue@auctor.co.uk", - "birthdate": "2015-04-07T12:13:00-07:00", - "phonenumber": "0800 090144", - "address": "295-673 Ac Ave", - "city": "Baracaldo", - "country": "South Georgia and The South Sandwich Islands" - }, - { - "name": "Rashad Johnson", - "email": "fringilla.Donec@Infaucibus.org", - "birthdate": "2014-09-22T18:20:45-07:00", - "phonenumber": "(022) 8324 6041", - "address": "P.O. Box 904, 7138 Metus Rd.", - "city": "Wichelen", - "country": "Niger" - }, - { - "name": "Brody Page", - "email": "nibh.Phasellus@eratvel.co.uk", - "birthdate": "2014-10-22T17:28:13-07:00", - "phonenumber": "(013459) 03264", - "address": "7456 Augue Rd.", - "city": "Pocatello", - "country": "Malta" - }, - { - "name": "Armando Bradford", - "email": "rutrum.eu@velpedeblandit.com", - "birthdate": "2016-02-04T23:16:13-08:00", - "phonenumber": "070 7348 5382", - "address": "P.O. Box 401, 8742 Sed St.", - "city": "Crewe", - "country": "Philippines" - }, - { - "name": "Malik Carpenter", - "email": "id.ante@pede.edu", - "birthdate": "2014-08-08T15:40:44-07:00", - "phonenumber": "(0115) 666 9816", - "address": "Ap #297-3670 Non, Rd.", - "city": "Harrisburg", - "country": "Vanuatu" - }, - { - "name": "Reece Figueroa", - "email": "tellus@primisin.net", - "birthdate": "2016-01-01T14:09:35-08:00", - "phonenumber": "(0118) 864 1600", - "address": "Ap #974-8842 Duis Ave", - "city": "Pagazzano", - "country": "Sao Tome and Principe" - }, - { - "name": "Orlando Morales", - "email": "magna.Ut@iaculis.net", - "birthdate": "2015-04-26T02:09:27-07:00", - "phonenumber": "0800 750400", - "address": "Ap #139-2923 Sem. Rd.", - "city": "Montgomery", - "country": "Uzbekistan" - }, - { - "name": "Clarke Guerrero", - "email": "placerat.Cras@et.net", - "birthdate": "2014-10-31T18:40:17-07:00", - "phonenumber": "070 6869 6797", - "address": "P.O. Box 151, 8680 Sit Rd.", - "city": "Gwalior", - "country": "Ecuador" - }, - { - "name": "Jasper Olson", - "email": "at.augue@utlacus.ca", - "birthdate": "2015-07-04T10:52:38-07:00", - "phonenumber": "056 8529 1645", - "address": "8544 Non, St.", - "city": "Oban", - "country": "Egypt" - }, - { - "name": "Xavier Spears", - "email": "mauris@nectempusscelerisque.net", - "birthdate": "2014-04-23T18:00:31-07:00", - "phonenumber": "055 7978 7806", - "address": "P.O. Box 864, 5387 Vulputate, Street", - "city": "Cuddapah", - "country": "Thailand" - }, - { - "name": "Lucian Gomez", - "email": "augue.id.ante@Cumsociis.edu", - "birthdate": "2015-12-30T04:41:45-08:00", - "phonenumber": "(028) 6676 3701", - "address": "P.O. Box 489, 5285 Proin Rd.", - "city": "Laino Castello", - "country": "Slovenia" - }, - { - "name": "Vladimir Calhoun", - "email": "diam@non.org", - "birthdate": "2014-06-09T14:58:33-07:00", - "phonenumber": "0500 911378", - "address": "623-3215 Magna. Avenue", - "city": "Leval-Chaudeville", - "country": "British Indian Ocean Territory" - }, - { - "name": "Armand Ryan", - "email": "placerat.augue.Sed@et.co.uk", - "birthdate": "2015-07-09T08:59:57-07:00", - "phonenumber": "(0110) 232 3739", - "address": "Ap #474-4393 Hendrerit Street", - "city": "Rosolini", - "country": "Bermuda" - }, - { - "name": "Aristotle Matthews", - "email": "eros.turpis@Integerurna.edu", - "birthdate": "2014-09-09T17:47:33-07:00", - "phonenumber": "0800 929617", - "address": "9971 Aliquam Avenue", - "city": "Gerpinnes", - "country": "Tajikistan" - }, - { - "name": "Valentine Cervantes", - "email": "Fusce.fermentum.fermentum@urnaNuncquis.co.uk", - "birthdate": "2015-05-16T18:38:12-07:00", - "phonenumber": "0800 088902", - "address": "P.O. Box 263, 5634 Facilisi. Ave", - "city": "Nandyal", - "country": "Norway" - }, - { - "name": "Cyrus Hartman", - "email": "dapibus.id.blandit@porttitor.edu", - "birthdate": "2014-06-12T07:30:12-07:00", - "phonenumber": "(01412) 250012", - "address": "Ap #543-4793 Eleifend St.", - "city": "Tuktoyaktuk", - "country": "Holy See (Vatican City State)" - }, - { - "name": "Keaton Floyd", - "email": "nibh.lacinia@vitaeorci.ca", - "birthdate": "2015-12-13T18:29:00-08:00", - "phonenumber": "(0118) 332 5673", - "address": "P.O. Box 587, 4696 Vitae Rd.", - "city": "Satriano di Lucania", - "country": "Tajikistan" - }, - { - "name": "Yasir Sosa", - "email": "bibendum.fermentum@CrasinterdumNunc.org", - "birthdate": "2014-07-19T10:24:35-07:00", - "phonenumber": "055 7799 2635", - "address": "P.O. Box 140, 7479 Ipsum. Rd.", - "city": "Governador Valadares", - "country": "Namibia" - }, - { - "name": "Cruz Jennings", - "email": "ipsum.Suspendisse@arcu.net", - "birthdate": "2015-07-03T04:26:30-07:00", - "phonenumber": "07750 484238", - "address": "129-6174 Massa. Road", - "city": "Pabianice", - "country": "Suriname" - }, - { - "name": "Blaze Keller", - "email": "neque.venenatis.lacus@acarcu.edu", - "birthdate": "2015-11-16T22:14:29-08:00", - "phonenumber": "(028) 4719 1558", - "address": "P.O. Box 511, 6059 Ut Ave", - "city": "Drachten", - "country": "Åland Islands" - }, - { - "name": "Dale Rodriguez", - "email": "molestie.in.tempus@Fusce.com", - "birthdate": "2014-12-15T09:49:29-08:00", - "phonenumber": "(01469) 96494", - "address": "249-3137 Nec, St.", - "city": "Acquasparta", - "country": "Comoros" - }, - { - "name": "Connor Dorsey", - "email": "non.sollicitudin@sitametrisus.ca", - "birthdate": "2014-11-10T13:24:04-08:00", - "phonenumber": "0800 582052", - "address": "6918 Vulputate, Road", - "city": "Ponti", - "country": "Lebanon" - }, - { - "name": "Ira Carroll", - "email": "interdum.Curabitur.dictum@augueidante.co.uk", - "birthdate": "2014-08-11T17:38:02-07:00", - "phonenumber": "(0111) 470 8010", - "address": "P.O. Box 284, 2166 Pharetra. Rd.", - "city": "College", - "country": "Sint Maarten" - }, - { - "name": "Clark Gilbert", - "email": "urna.et@nectempusmauris.ca", - "birthdate": "2015-04-11T19:09:42-07:00", - "phonenumber": "(016977) 6357", - "address": "Ap #603-6579 Vitae Av.", - "city": "Meer", - "country": "Haiti" - }, - { - "name": "Wayne Hughes", - "email": "vulputate.eu.odio@ipsumnuncid.com", - "birthdate": "2015-09-07T20:04:59-07:00", - "phonenumber": "(01165) 332450", - "address": "Ap #435-2695 Odio Av.", - "city": "Rhyl", - "country": "French Polynesia" - }, - { - "name": "Curran Pacheco", - "email": "dictum@tempuslorem.ca", - "birthdate": "2014-12-29T11:56:31-08:00", - "phonenumber": "0800 694417", - "address": "Ap #687-2400 Metus. Rd.", - "city": "Rockville", - "country": "Montenegro" - }, - { - "name": "Prescott Reed", - "email": "id@Aliquamvulputateullamcorper.net", - "birthdate": "2015-10-24T20:10:05-07:00", - "phonenumber": "0841 602 2483", - "address": "1957 Pellentesque Street", - "city": "Jhansi", - "country": "Saint Pierre and Miquelon" - }, - { - "name": "Tanner Chambers", - "email": "Aenean@risus.edu", - "birthdate": "2015-09-02T05:24:16-07:00", - "phonenumber": "0994 095 7796", - "address": "554 Sed Street", - "city": "Helena", - "country": "Zimbabwe" - }, - { - "name": "Arthur Carrillo", - "email": "sem.Nulla.interdum@Aliquamgravida.com", - "birthdate": "2015-12-26T15:33:35-08:00", - "phonenumber": "070 2132 9998", - "address": "821-3381 Nec St.", - "city": "Angoulême", - "country": "Puerto Rico" - }, - { - "name": "Nathaniel Mcclure", - "email": "hendrerit@netuset.org", - "birthdate": "2014-07-12T12:36:54-07:00", - "phonenumber": "07565 513520", - "address": "Ap #882-3496 Dictum Rd.", - "city": "Morro d'Alba", - "country": "Zimbabwe" - }, - { - "name": "Xenos Dyer", - "email": "velit@Phasellusliberomauris.com", - "birthdate": "2014-09-18T00:24:28-07:00", - "phonenumber": "07624 671388", - "address": "8507 Convallis St.", - "city": "Huntsville", - "country": "Timor-Leste" - }, - { - "name": "Thomas Nelson", - "email": "quis@ProinmiAliquam.co.uk", - "birthdate": "2015-07-05T09:32:22-07:00", - "phonenumber": "(018308) 20124", - "address": "Ap #338-144 Pede, St.", - "city": "Kapiti", - "country": "Pitcairn Islands" - }, - { - "name": "Dale Hart", - "email": "porta@dapibus.net", - "birthdate": "2015-09-26T19:08:04-07:00", - "phonenumber": "(01663) 25953", - "address": "4364 Sed Av.", - "city": "Glossop", - "country": "China" - }, - { - "name": "Kenneth Rodriguez", - "email": "Donec.tincidunt.Donec@pedeCumsociis.org", - "birthdate": "2015-02-10T04:02:27-08:00", - "phonenumber": "0800 1111", - "address": "Ap #415-1179 Risus. St.", - "city": "Baarle-Hertog", - "country": "Isle of Man" - }, - { - "name": "Bernard Tate", - "email": "arcu.Sed@quisdiamluctus.ca", - "birthdate": "2015-10-10T03:59:01-07:00", - "phonenumber": "(01594) 809167", - "address": "P.O. Box 621, 4148 Mauris Rd.", - "city": "Mandurah", - "country": "Central African Republic" - }, - { - "name": "Ralph Roberson", - "email": "metus.Vivamus.euismod@egestas.co.uk", - "birthdate": "2015-12-18T17:37:03-08:00", - "phonenumber": "07569 633721", - "address": "Ap #378-1939 Mauris Avenue", - "city": "Harbour Grace", - "country": "Svalbard and Jan Mayen Islands" - }, - { - "name": "Acton Pratt", - "email": "Fusce.feugiat@CuraeDonec.edu", - "birthdate": "2015-01-13T17:11:11-08:00", - "phonenumber": "055 1298 8099", - "address": "4545 Nunc Rd.", - "city": "Markkleeberg", - "country": "Tonga" - }, - { - "name": "Nash Graves", - "email": "Nunc.ac@aenimSuspendisse.co.uk", - "birthdate": "2015-03-11T22:00:56-07:00", - "phonenumber": "0369 744 8206", - "address": "2849 Donec Ave", - "city": "Trivigno", - "country": "Aruba" - }, - { - "name": "Rogan Chavez", - "email": "molestie@Proin.org", - "birthdate": "2015-08-13T13:43:36-07:00", - "phonenumber": "(0131) 398 2003", - "address": "1229 Tellus Street", - "city": "Rea", - "country": "Macao" - }, - { - "name": "Vincent Simpson", - "email": "Nunc.ullamcorper.velit@Suspendissecommodotincidunt.co.uk", - "birthdate": "2014-06-09T06:42:18-07:00", - "phonenumber": "0845 46 43", - "address": "P.O. Box 837, 9086 Odio St.", - "city": "Farrukhabad-cum-Fatehgarh", - "country": "Montenegro" - }, - { - "name": "Harlan Parks", - "email": "Integer@Aeneaneuismod.ca", - "birthdate": "2015-12-04T16:22:13-08:00", - "phonenumber": "0957 096 4637", - "address": "Ap #609-9943 Non Av.", - "city": "Elx", - "country": "Åland Islands" - }, - { - "name": "Axel Huffman", - "email": "dolor.Fusce.mi@in.com", - "birthdate": "2014-07-20T06:26:43-07:00", - "phonenumber": "0800 1111", - "address": "2031 Vulputate Rd.", - "city": "Champlain", - "country": "Greenland" - }, - { - "name": "Kamal Newton", - "email": "lorem.vitae@tinciduntorci.co.uk", - "birthdate": "2015-07-24T14:09:35-07:00", - "phonenumber": "(0111) 047 7450", - "address": "Ap #932-1588 Justo. Ave", - "city": "Ramillies", - "country": "Ireland" - }, - { - "name": "Clarke Francis", - "email": "felis.Nulla@sit.ca", - "birthdate": "2015-01-23T02:32:19-08:00", - "phonenumber": "0500 551664", - "address": "546-6895 Tempor, St.", - "city": "Dro", - "country": "Bonaire, Sint Eustatius and Saba" - }, - { - "name": "Octavius Mullins", - "email": "est.ac@montesnasceturridiculus.net", - "birthdate": "2014-06-08T06:10:16-07:00", - "phonenumber": "0367 056 4849", - "address": "4737 Rutrum Road", - "city": "Baie-d'Urf?", - "country": "Bahrain" - }, - { - "name": "Kirk Silva", - "email": "feugiat.non@ac.edu", - "birthdate": "2015-05-14T20:42:40-07:00", - "phonenumber": "070 3297 3915", - "address": "Ap #358-7477 Tellus Street", - "city": "Maisi�res", - "country": "Central African Republic" - }, - { - "name": "Laith Bass", - "email": "vehicula@enimcommodohendrerit.net", - "birthdate": "2015-05-06T01:08:43-07:00", - "phonenumber": "0500 078574", - "address": "9950 Odio Avenue", - "city": "Lachine", - "country": "Zambia" - }, - { - "name": "Silas Allison", - "email": "non.lacinia@semPellentesque.net", - "birthdate": "2015-05-15T09:14:56-07:00", - "phonenumber": "07664 138490", - "address": "426 Adipiscing Rd.", - "city": "Ruette", - "country": "Nigeria" - }, - { - "name": "Owen Rivers", - "email": "Nunc@quam.ca", - "birthdate": "2014-09-12T09:27:53-07:00", - "phonenumber": "(0110) 158 0190", - "address": "7553 Mauris. St.", - "city": "Township of Minden Hills", - "country": "Bahamas" - }, - { - "name": "Dustin Anthony", - "email": "Lorem@blanditat.ca", - "birthdate": "2014-12-25T05:21:31-08:00", - "phonenumber": "0919 428 6598", - "address": "P.O. Box 596, 8070 Magna Avenue", - "city": "Daiano", - "country": "Christmas Island" - }, - { - "name": "Brody Bonner", - "email": "Proin@Morbiaccumsan.ca", - "birthdate": "2015-02-23T18:21:30-08:00", - "phonenumber": "(01416) 53549", - "address": "395-8119 Urna. Road", - "city": "Westmeerbeek", - "country": "Croatia" - }, - { - "name": "Vaughan Cherry", - "email": "elementum@et.com", - "birthdate": "2015-10-02T18:29:58-07:00", - "phonenumber": "0800 1111", - "address": "P.O. Box 268, 1917 Volutpat Road", - "city": "Atlanta", - "country": "Curaçao" - }, - { - "name": "Jarrod Blackburn", - "email": "sit@vitaealiquameros.com", - "birthdate": "2014-12-05T16:26:27-08:00", - "phonenumber": "0800 1111", - "address": "985-9008 Orci Rd.", - "city": "Bala", - "country": "Philippines" - }, - { - "name": "Nash Valdez", - "email": "dictum.ultricies@risusquisdiam.edu", - "birthdate": "2014-09-20T00:38:24-07:00", - "phonenumber": "056 7769 7377", - "address": "P.O. Box 788, 1540 Aliquam Av.", - "city": "Saint-Denis-Bovesse", - "country": "Peru" - }, - { - "name": "Emery Fulton", - "email": "et.netus@feugiatnec.edu", - "birthdate": "2014-08-18T19:33:18-07:00", - "phonenumber": "076 6690 3350", - "address": "956 Ac St.", - "city": "Hénin-Beaumont", - "country": "Greece" - }, - { - "name": "Nissim Maynard", - "email": "Donec@Aliquamvulputate.ca", - "birthdate": "2015-09-16T08:04:51-07:00", - "phonenumber": "055 8490 4579", - "address": "P.O. Box 770, 6841 Ac Rd.", - "city": "Casoli", - "country": "Mali" - }, - { - "name": "Armando Francis", - "email": "orci@penatibus.com", - "birthdate": "2014-04-11T23:56:49-07:00", - "phonenumber": "(0113) 573 1265", - "address": "5264 Euismod Street", - "city": "Paradise", - "country": "Eritrea" - }, - { - "name": "Sebastian Hendricks", - "email": "sodales.elit@egetlaoreet.net", - "birthdate": "2014-10-15T04:15:44-07:00", - "phonenumber": "0800 1111", - "address": "500-6908 Eu, St.", - "city": "Etroubles", - "country": "Virgin Islands, British" - }, - { - "name": "Dexter Vargas", - "email": "magna.malesuada.vel@faucibusleo.net", - "birthdate": "2014-03-01T23:46:12-08:00", - "phonenumber": "(017077) 80013", - "address": "Ap #832-4082 Posuere Street", - "city": "Allerona", - "country": "Tonga" - }, - { - "name": "Alvin Justice", - "email": "dolor.sit.amet@elitelit.co.uk", - "birthdate": "2014-11-28T21:32:41-08:00", - "phonenumber": "0845 46 46", - "address": "P.O. Box 299, 6138 Massa Road", - "city": "Montebello sul Sangro", - "country": "Kyrgyzstan" - }, - { - "name": "Derek Matthews", - "email": "tempor@eutemporerat.edu", - "birthdate": "2014-05-19T13:00:21-07:00", - "phonenumber": "(012781) 48753", - "address": "8521 Est Rd.", - "city": "Pontevedra", - "country": "Bonaire, Sint Eustatius and Saba" - }, - { - "name": "Cadman Bradford", - "email": "Aenean@uterat.co.uk", - "birthdate": "2015-03-03T07:27:12-08:00", - "phonenumber": "0500 744796", - "address": "9684 Arcu. Avenue", - "city": "Auxerre", - "country": "Slovakia" - }, - { - "name": "Ryder Walters", - "email": "in@urnaet.co.uk", - "birthdate": "2015-01-04T21:26:57-08:00", - "phonenumber": "056 6242 3993", - "address": "3885 Nam Ave", - "city": "Sart-Dames-Avelines", - "country": "Ecuador" - }, - { - "name": "Thaddeus Hicks", - "email": "Duis.elementum.dui@lectusNullam.ca", - "birthdate": "2014-05-02T00:19:27-07:00", - "phonenumber": "0800 965759", - "address": "Ap #380-3557 Orci. Av.", - "city": "Frasnes-lez-Gosselies", - "country": "Kiribati" - }, - { - "name": "Lance Koch", - "email": "mauris@scelerisqueduiSuspendisse.edu", - "birthdate": "2014-08-16T05:23:58-07:00", - "phonenumber": "0936 692 6309", - "address": "7671 Sed St.", - "city": "Castletown", - "country": "Nauru" - }, - { - "name": "Julian Montgomery", - "email": "imperdiet@faucibusidlibero.org", - "birthdate": "2014-09-19T18:51:31-07:00", - "phonenumber": "0800 1111", - "address": "232-9783 Et, Av.", - "city": "Barrow-in-Furness", - "country": "Virgin Islands, United States" - }, - { - "name": "Amery Kline", - "email": "eu.nulla@nonbibendumsed.ca", - "birthdate": "2015-06-18T19:10:23-07:00", - "phonenumber": "(024) 7929 7746", - "address": "P.O. Box 789, 9593 Lectus Road", - "city": "Lithgow", - "country": "Croatia" - }, - { - "name": "Keefe Rollins", - "email": "tortor.dictum.eu@euelit.com", - "birthdate": "2015-01-09T20:52:08-08:00", - "phonenumber": "(0141) 314 7074", - "address": "Ap #381-2511 Et St.", - "city": "Castres", - "country": "Cape Verde" - }, - { - "name": "Craig Church", - "email": "Cras.sed.leo@MorbimetusVivamus.co.uk", - "birthdate": "2014-09-27T01:41:41-07:00", - "phonenumber": "0985 952 2089", - "address": "407-739 Eget, Rd.", - "city": "Laren", - "country": "Chile" - }, - { - "name": "Rooney Simmons", - "email": "erat@Proinnislsem.co.uk", - "birthdate": "2015-10-03T22:15:33-07:00", - "phonenumber": "(019038) 03318", - "address": "P.O. Box 169, 811 Erat. Avenue", - "city": "Nelson", - "country": "Grenada" - }, - { - "name": "Gray Goodwin", - "email": "in.consectetuer.ipsum@semperrutrum.co.uk", - "birthdate": "2015-08-13T20:09:08-07:00", - "phonenumber": "0386 123 5737", - "address": "Ap #710-1646 Eu, Road", - "city": "Thalassery", - "country": "Rwanda" - }, - { - "name": "Ivor Hays", - "email": "non@metus.co.uk", - "birthdate": "2015-02-04T21:31:35-08:00", - "phonenumber": "055 4475 0807", - "address": "P.O. Box 921, 477 Molestie Ave", - "city": "Alness", - "country": "Congo, the Democratic Republic of the" - }, - { - "name": "Garrison Fields", - "email": "malesuada@diamat.com", - "birthdate": "2014-10-31T08:01:26-07:00", - "phonenumber": "0840 264 2676", - "address": "Ap #950-7806 Nunc Road", - "city": "Sokoto", - "country": "Kyrgyzstan" - }, - { - "name": "Dylan Watson", - "email": "Etiam.laoreet.libero@vitae.ca", - "birthdate": "2015-09-08T12:33:38-07:00", - "phonenumber": "0845 46 47", - "address": "6184 Pede, Avenue", - "city": "Strasbourg", - "country": "Montserrat" - }, - { - "name": "Cooper Crawford", - "email": "lacus.Quisque.imperdiet@convallisconvallisdolor.edu", - "birthdate": "2014-11-04T21:33:36-08:00", - "phonenumber": "0899 624 8690", - "address": "584-7224 Vitae Rd.", - "city": "Charters Towers", - "country": "Puerto Rico" - }, - { - "name": "Zane Suarez", - "email": "fringilla.Donec@maurisSuspendissealiquet.ca", - "birthdate": "2015-04-19T15:31:30-07:00", - "phonenumber": "(013283) 55699", - "address": "P.O. Box 475, 1967 Blandit Rd.", - "city": "Barrhead", - "country": "Fiji" - }, - { - "name": "Cade Dean", - "email": "lacus.Etiam@semut.net", - "birthdate": "2014-11-28T12:03:15-08:00", - "phonenumber": "076 9669 0531", - "address": "P.O. Box 732, 678 Enim Avenue", - "city": "Bothey", - "country": "Svalbard and Jan Mayen Islands" - }, - { - "name": "Knox Mccarty", - "email": "iaculis.nec@nisisem.net", - "birthdate": "2014-12-18T01:48:31-08:00", - "phonenumber": "0800 1111", - "address": "711-2610 Nec, Avenue", - "city": "Arquata del Tronto", - "country": "Vanuatu" - }, - { - "name": "Callum May", - "email": "luctus@aliquetliberoInteger.com", - "birthdate": "2015-04-07T17:52:50-07:00", - "phonenumber": "(016977) 2374", - "address": "8291 Cursus Avenue", - "city": "Leamington", - "country": "Anguilla" - }, - { - "name": "Drew Chase", - "email": "Aliquam.nisl.Nulla@eutempor.co.uk", - "birthdate": "2014-05-08T10:11:43-07:00", - "phonenumber": "(01614) 432795", - "address": "P.O. Box 436, 4627 Est Street", - "city": "Wedel", - "country": "Mongolia" - }, - { - "name": "Holmes Hopper", - "email": "eu.tellus@volutpat.co.uk", - "birthdate": "2014-05-29T10:00:18-07:00", - "phonenumber": "0876 536 0219", - "address": "995-5667 Cras Road", - "city": "Chicago", - "country": "Myanmar" - }, - { - "name": "Fletcher Sherman", - "email": "eleifend.vitae@amet.com", - "birthdate": "2014-12-27T13:15:56-08:00", - "phonenumber": "0845 46 46", - "address": "439 Faucibus Rd.", - "city": "Provost", - "country": "Liberia" - }, - { - "name": "Ulysses Holden", - "email": "Proin.dolor@euplacerat.com", - "birthdate": "2015-11-14T14:21:52-08:00", - "phonenumber": "(01468) 13456", - "address": "Ap #684-6804 Sit Avenue", - "city": "Kanpur", - "country": "Brunei" - }, - { - "name": "Amery Gay", - "email": "ridiculus.mus@sitametante.co.uk", - "birthdate": "2015-05-31T08:09:41-07:00", - "phonenumber": "(0151) 911 7910", - "address": "8582 Dapibus Rd.", - "city": "Saint-Louis", - "country": "Tajikistan" - }, - { - "name": "Neville Ingram", - "email": "Donec.egestas@mi.edu", - "birthdate": "2014-06-11T17:59:18-07:00", - "phonenumber": "07624 209017", - "address": "9231 Accumsan Street", - "city": "Sluis", - "country": "Saint Martin" - }, - { - "name": "Xavier Chaney", - "email": "ridiculus.mus.Donec@tristiquealiquet.ca", - "birthdate": "2014-11-14T08:58:57-08:00", - "phonenumber": "(016977) 5030", - "address": "Ap #356-1949 Dictum St.", - "city": "Etterbeek", - "country": "Belize" - }, - { - "name": "Cedric Cash", - "email": "at.egestas@Sed.edu", - "birthdate": "2015-05-20T09:16:19-07:00", - "phonenumber": "(0131) 019 7953", - "address": "Ap #778-2204 Duis St.", - "city": "Barasat", - "country": "Barbados" - }, - { - "name": "Sylvester Whitehead", - "email": "risus@nisi.net", - "birthdate": "2015-07-18T00:38:09-07:00", - "phonenumber": "0800 613 5623", - "address": "673-3159 Sagittis. Av.", - "city": "Beaconsfield", - "country": "Burkina Faso" - }, - { - "name": "Ciaran Aguirre", - "email": "ornare.elit.elit@dolor.edu", - "birthdate": "2014-12-06T15:36:12-08:00", - "phonenumber": "(011878) 44101", - "address": "P.O. Box 249, 5058 Sem Rd.", - "city": "Lang", - "country": "Guinea-Bissau" - }, - { - "name": "Phelan Moreno", - "email": "Integer.sem.elit@Donecatarcu.com", - "birthdate": "2014-08-17T23:53:18-07:00", - "phonenumber": "07652 927237", - "address": "923-5619 Odio St.", - "city": "Breton", - "country": "Equatorial Guinea" - }, - { - "name": "Jackson Herman", - "email": "mauris@Suspendisse.co.uk", - "birthdate": "2015-04-18T06:44:33-07:00", - "phonenumber": "(022) 8101 2465", - "address": "Ap #530-8879 Montes, St.", - "city": "Cras-Avernas", - "country": "Monaco" - }, - { - "name": "Ethan Holder", - "email": "malesuada.fames@odio.edu", - "birthdate": "2015-09-20T19:26:43-07:00", - "phonenumber": "07119 643014", - "address": "Ap #473-6845 Non, Avenue", - "city": "Pescantina", - "country": "Taiwan" - }, - { - "name": "Kieran Kramer", - "email": "eu.erat@euultrices.com", - "birthdate": "2015-12-15T23:15:15-08:00", - "phonenumber": "(016977) 7389", - "address": "554-4139 Et, St.", - "city": "Morolo", - "country": "Namibia" - }, - { - "name": "Basil Phelps", - "email": "fringilla@velitCras.org", - "birthdate": "2015-08-03T10:13:39-07:00", - "phonenumber": "07624 625108", - "address": "Ap #384-5383 Montes, Av.", - "city": "Perchtoldsdorf", - "country": "Taiwan" - } - ] + 'persons': [], + 'loadContacts': function () { + Contact.get(function (data) { + console.log(data); + angular.forEach(data.results, function (person) { + self.persons.push(new Contact(person)); + }) + }); + } }; + self.loadContacts(); + return self; }); \ No newline at end of file
#