├── .gitignore ├── README.md ├── app ├── css │ └── style.css ├── home.html ├── img │ ├── demo1.jpg │ └── demo2.jpg ├── index.html ├── js │ └── app.js └── login.html ├── exercises ├── 1-your-first-app │ ├── app.js │ ├── index.html │ ├── solution.js │ └── tests.js ├── 2-controllers-and-scopes │ ├── app.js │ ├── index.html │ ├── solution.js │ └── tests.js ├── 3-routing-and-repeaters │ ├── app.js │ ├── index.html │ ├── solution.js │ ├── stooges.html │ └── tests.js ├── 4-services-models-and-interaction │ ├── app.js │ ├── index.html │ ├── logged-in.html │ ├── logged-out.html │ ├── solution.js │ └── tests.js ├── 5-directives │ ├── app.js │ ├── index.html │ ├── solution.js │ └── tests.js └── assert.js ├── index.html ├── package.json ├── scratchpad └── vendor ├── css ├── foundation.min.css └── normalize.css └── js ├── angular-route.js ├── angular.js └── underscore.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | intro-to-angularjs 2 | ================== 3 | 4 | [Screencast published May 3, 2013](http://www.youtube.com/watch?v=8ILQOFAgaXE) 5 | 6 | Walk through building a sample application with AngularJS to learn some of the basics along with some commentary that contrasts it with jQuery / Backbone.JS; this was produced for a talk I gave at [Prairie DevCon](http://prairiedevcon.com/) in Winnipeg, MB, May 6-7, 2013. Some things you can expect to learn the basics on: 7 | 8 | * angular.module 9 | * angular.controller 10 | * angular.directive 11 | * angular.$routeProvider 12 | * angular.factory 13 | * ng-app, ng-model, ng-submit, ng-click 14 | * $scope, inheritance, and its relationship with the DOM 15 | * contrasting some of angular w/ jQuery/Backbone 16 | 17 | # Getting Started 18 | 19 | * Install NodeJS: https://nodejs.org/ 20 | * Google Chrome, Firefox, or IE 21 | * `git clone https://github.com/davemo/intro-to-angularjs.git` 22 | * `npm install` 23 | * `npm start` 24 | 25 | Then visit http://localhost:3000 26 | 27 | # Changelog 28 | 29 | - May 20, 2015: upgrade: angular and angular-route to 1.4.0-rc.2, add exercises for workshop 30 | - April 11, 2014: upgrade: angular to 1.2.16, add: angular-route 31 | 32 | -------------------------------------------------------------------------------- /app/css/style.css: -------------------------------------------------------------------------------- 1 | h1,h2,h3,h4,h5 { 2 | text-align: center; 3 | } 4 | 5 | button { 6 | margin-bottom: 0px !important; 7 | } 8 | -------------------------------------------------------------------------------- /app/home.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Welcome to the {{ title }} page!

4 | 5 |
{{ message }}
6 | 7 | 15 | 16 |
17 |
18 | 19 |
20 |
21 |
22 |
23 | -------------------------------------------------------------------------------- /app/img/demo1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davemo/intro-to-angularjs/6595d539f9c71f00e04d3377c9b767ac13718343/app/img/demo1.jpg -------------------------------------------------------------------------------- /app/img/demo2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davemo/intro-to-angularjs/6595d539f9c71f00e04d3377c9b767ac13718343/app/img/demo2.jpg -------------------------------------------------------------------------------- /app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | An Introduction to Angular.JS 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |

Introduction to Angular.JS

17 |
18 |
19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/js/app.js: -------------------------------------------------------------------------------- 1 | var app = angular.module("app", ['ngRoute']) 2 | 3 | app.config(function($routeProvider) { 4 | 5 | $routeProvider.when('/login', { 6 | templateUrl: 'login.html', 7 | controller: 'LoginController' 8 | }); 9 | 10 | $routeProvider.when('/home', { 11 | templateUrl: 'home.html', 12 | controller: 'HomeController' 13 | }); 14 | 15 | $routeProvider.otherwise({ redirectTo: '/login' }); 16 | 17 | }); 18 | 19 | app.factory("AuthenticationService", function($location) { 20 | return { 21 | login: function(credentials) { 22 | if (credentials.username !== "ralph" || credentials.password !== "wiggum") { 23 | alert("Username must be 'ralph', password must be 'wiggum'"); 24 | } else { 25 | $location.path('/home'); 26 | } 27 | }, 28 | logout: function() { 29 | $location.path('/login'); 30 | } 31 | }; 32 | }); 33 | 34 | app.controller("LoginController", function($scope, $location, AuthenticationService) { 35 | $scope.credentials = { username: "", password: "" }; 36 | 37 | $scope.login = function() { 38 | AuthenticationService.login($scope.credentials); 39 | } 40 | }); 41 | 42 | app.controller("HomeController", function($scope, AuthenticationService) { 43 | $scope.title = "Awesome Home"; 44 | $scope.message = "Mouse Over these images to see a directive at work!"; 45 | 46 | $scope.logout = function() { 47 | AuthenticationService.logout(); 48 | }; 49 | }); 50 | 51 | app.directive("showsMessageWhenHovered", function() { 52 | return { 53 | restrict: "A", // A = Attribute, C = CSS Class, E = HTML Element, M = HTML Comment 54 | link: function(scope, element, attributes) { 55 | var originalMessage = scope.message; 56 | element.bind("mouseenter", function() { 57 | scope.message = attributes.message; 58 | scope.$apply(); 59 | }); 60 | element.bind("mouseleave", function() { 61 | scope.message = originalMessage; 62 | scope.$apply(); 63 | }); 64 | } 65 | }; 66 | }); 67 | -------------------------------------------------------------------------------- /app/login.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
6 |
7 | 8 |
9 |
10 | 11 |
12 |
13 | 14 |
15 |
16 | 17 |
18 |
19 |
20 |
21 |
22 |
23 | -------------------------------------------------------------------------------- /exercises/1-your-first-app/app.js: -------------------------------------------------------------------------------- 1 | // module here 2 | -------------------------------------------------------------------------------- /exercises/1-your-first-app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | An Introduction to Angular.JS 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Your First App

19 |
    20 |
  1. Create An Angular Module called app in app.js
  2. 21 |
  3. Bootstrap the angular app called app you created in step one using ng-app
  4. 22 |
23 |

Note: Open your browsers developer tools console and make sure the tests are passing.

24 |
25 |
26 |

Useful Resources

27 | 30 |
31 |
32 |
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /exercises/1-your-first-app/solution.js: -------------------------------------------------------------------------------- 1 | // app.js 2 | angular.module('app', []); 3 | 4 | // index.html 5 | 6 | -------------------------------------------------------------------------------- /exercises/1-your-first-app/tests.js: -------------------------------------------------------------------------------- 1 | assert(angular.module('app') !== undefined, 'an angular module named `app` exists'); 2 | var appDirective = document.querySelector('html').attributes['ng-app']; 3 | assert(appDirective !== undefined, 'an `ng-app` directive exists in index.html'); 4 | assert(appDirective && appDirective.value === 'app', 'the `ng-app` directive value is `app`.'); 5 | -------------------------------------------------------------------------------- /exercises/2-controllers-and-scopes/app.js: -------------------------------------------------------------------------------- 1 | var app = angular.module('app', []); 2 | 3 | // controller here 4 | -------------------------------------------------------------------------------- /exercises/2-controllers-and-scopes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | An Introduction to Angular.JS 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Controllers & Scopes

19 |
    20 |
  1. Within your `app` module, create a controller called FirstController
  2. 21 |
  3. Assign your controller to div#put-a-controller-on-me in this page
  4. 22 |
  5. Add a key 'dynamic' with the value 'yes' to the $scope that is injected into your FirstController
  6. 23 |
  7. Add a two way binding to render $scope.dynamic inside of em#dynamic
  8. 24 |
25 | 26 |
27 | I should be a controller with a value on the $scope: 28 |
29 |
30 |

Note: Open your browsers developer tools console and make sure the tests are passing.

31 |
32 |
33 |

Useful Resources

34 | 38 |
39 |
40 |
41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /exercises/2-controllers-and-scopes/solution.js: -------------------------------------------------------------------------------- 1 | // app.js 2 | var app = angular.module('app', []); 3 | 4 | app.controller('FirstController', function($scope) { 5 | $scope.dynamic = 'yes'; 6 | }); 7 | 8 | // index.html 9 |
10 | I should be a controller with a value on the $scope: {{dynamic}} 11 |
12 | -------------------------------------------------------------------------------- /exercises/2-controllers-and-scopes/tests.js: -------------------------------------------------------------------------------- 1 | var module = angular.module('app'); 2 | var controllerDirective = document.querySelector('#put-a-controller-on-me').attributes['ng-controller']; 3 | 4 | assert( 5 | module._invokeQueue && 6 | module._invokeQueue[0] && 7 | module._invokeQueue[0][2] && 8 | module._invokeQueue[0][2][0] === 'FirstController', 'a controller named `FirstController` exists on the `app` module'); 9 | assert(controllerDirective !== undefined, 'an `ng-controller` directive exists on div#put-a-controller-on-me'); 10 | assert(controllerDirective && controllerDirective.value === 'FirstController', 'the `ng-controller` directive value is `FirstController`'); 11 | assert(document.querySelector('#dynamic').innerText === '{{dynamic}}', 'the text value of em#dynamic is `{{dynamic}}`'); 12 | -------------------------------------------------------------------------------- /exercises/3-routing-and-repeaters/app.js: -------------------------------------------------------------------------------- 1 | var app = angular.module('app', []); 2 | 3 | // controller here 4 | 5 | // routes here 6 | -------------------------------------------------------------------------------- /exercises/3-routing-and-repeaters/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | An Introduction to Angular.JS 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Routing & Repeaters

19 |
    20 |
  1. Add `ngRoute` as a dependency to your `app` module and inject $routeProvider during the `config` phase.
  2. 21 |
  3. Add an `ng-view` directive to div#view
  4. 22 |
  5. Configure `$routeProvider` with a route to /stooges that loads a template, stooges.html and assigns the controller FirstController
  6. 23 |
  7. Add an array of the 3 stooges (larry, curly, and moe) to the `$scope` for `FirstController`
  8. 24 |
  9. Use `ng-repeat` on a table#stooges element in stooges.html to display the list of stooges
  10. 25 |
26 | 27 |
28 | 29 |
30 |

Note: Open your browsers developer tools console and make sure the tests are passing.

31 |
32 |
33 |

Useful Resources

34 | 39 |
40 |
41 |
42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /exercises/3-routing-and-repeaters/solution.js: -------------------------------------------------------------------------------- 1 | // app.js 2 | 3 | var app = angular.module('app', ['ngRoute']); 4 | 5 | app.controller('FirstController', function($scope) { 6 | $scope.stooges = ['larry', 'curly', 'moe']; 7 | }); 8 | 9 | app.config(function($routeProvider) { 10 | $routeProvider.when('/stooges', { 11 | templateUrl: 'stooges.html', 12 | controller: 'FirstController' 13 | }); 14 | 15 | $routeProvider.otherwise({ redirectTo: '/stooges' }); 16 | }); 17 | 18 | // index.html 19 |
20 | 21 | // stooges.html 22 | 23 | 24 | 25 | 26 |
{{stooge}}
27 | 28 | 29 | -------------------------------------------------------------------------------- /exercises/3-routing-and-repeaters/stooges.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
{{stooge}}
6 | -------------------------------------------------------------------------------- /exercises/3-routing-and-repeaters/tests.js: -------------------------------------------------------------------------------- 1 | setTimeout(function() { 2 | var app = angular.module('app'); 3 | var stoogesTable = document.querySelector('#stooges'); 4 | var view = document.querySelector('#view'); 5 | 6 | assert(app.requires[0] === 'ngRoute', 'the `ngRoute` dependency is included in the `app` module') 7 | assert(view && view.attributes['ng-view'] !== undefined, 'the `ng-view` attribute exists on div#view'); 8 | 9 | assert( 10 | app._configBlocks && 11 | app._configBlocks[0] && 12 | app._configBlocks[0][2] && 13 | !!app._configBlocks[0][2][0].toString().match(/\$routeProvider.when\(\'\/stooges/), 'a route `/stooges` is defined with `$routeProvider`'); 14 | 15 | assert(stoogesTable !== null, 'there is a table#stooges element that was loaded via ngRoute'); 16 | assert(stoogesTable && !!stoogesTable.innerHTML.match(/(?:.*larry)(?:.*curly)(?:.*moe)/), 'larry, curly, and moe exist in the table, rendered from the `FirstController.$scope`'); 17 | }, 1000); 18 | 19 | -------------------------------------------------------------------------------- /exercises/4-services-models-and-interaction/app.js: -------------------------------------------------------------------------------- 1 | var app = angular.module('app', ['ngRoute']); 2 | 3 | // routes here 4 | 5 | // LoginController here 6 | 7 | // LogoutController here 8 | 9 | app.service("AuthenticationService", function($location) { 10 | return { 11 | login: function(credentials) { 12 | if (credentials.username !== "ralph" || credentials.password !== "wiggum") { 13 | alert("Username must be 'ralph', password must be 'wiggum'"); 14 | } else { 15 | $location.path('/logged-in'); 16 | } 17 | }, 18 | logout: function() { 19 | $location.path('/logged-out'); 20 | } 21 | }; 22 | }); 23 | -------------------------------------------------------------------------------- /exercises/4-services-models-and-interaction/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | An Introduction to Angular.JS 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Services & Interaction

19 |
    20 |
  1. Create routes for `/logged-out` and `/logged-in` using $routeProvider, they should each configure a templateUrl of the same name (logged-in.html, and logged-out.html are provided for you in this excercise folder); make the default route `/logged-out
  2. 21 |
  3. Create controllers `LoginController` and `LogoutController` and assign them to their corresponding routes using the $routeProvider config objects `controller` property. Inject the provided `AuthenticationService` into both controllers.
  4. 22 |
  5. Add `$scope.credentials` within LoginController, which is an object literal containing a `username` and `password` key with empty strings as values.
  6. 23 |
  7. On LoginController, create $scope.login which is a function that calls `AuthenticationService.Login` and passes in `$scope.credentials`; bind this function using `ng-submit` within `logged-out.html`
  8. 24 |
  9. On LogoutController, create $scope.logout which calls `AuthenticationService.Logout`; bind this function using `ng-click` within `logged-in.html`
  10. 25 |
  11. Within `logged-out.html`, bind the form input elements for `username` and `password` using `ng-model` pointing to `credentials.username` and `credentials.password`
  12. 26 |
27 | 28 |
29 | 30 |
31 |

Note: Open your browsers developer tools console and make sure the tests are passing.

32 |
33 |
34 |

Useful Resources

35 | 42 |
43 |
44 |
45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /exercises/4-services-models-and-interaction/logged-in.html: -------------------------------------------------------------------------------- 1 |

YOU ARE LOGGED IN!!!

2 | 3 | -------------------------------------------------------------------------------- /exercises/4-services-models-and-interaction/logged-out.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 6 |
7 |
8 | 9 |
10 |
11 | 12 |
13 |
14 | 15 |
16 |
17 |
18 |
19 | -------------------------------------------------------------------------------- /exercises/4-services-models-and-interaction/solution.js: -------------------------------------------------------------------------------- 1 | // app.js 2 | 3 | var app = angular.module('app', ['ngRoute']); 4 | 5 | app.config(function($routeProvider) { 6 | $routeProvider.when('/logged-out', { 7 | templateUrl: 'logged-out.html', 8 | controller: 'LoginController' 9 | }); 10 | 11 | $routeProvider.when('/logged-in', { 12 | templateUrl: 'logged-in.html', 13 | controller: 'LogoutController' 14 | }); 15 | 16 | $routeProvider.otherwise({ redirectTo: '/logged-out' }); 17 | }); 18 | 19 | app.controller('LoginController', function($scope, AuthenticationService) { 20 | $scope.credentials = {username: '', password: ''}; 21 | $scope.login = function() { 22 | AuthenticationService.login($scope.credentials); 23 | }; 24 | }); 25 | 26 | app.controller('LogoutController', function($scope, AuthenticationService) { 27 | $scope.logout = AuthenticationService.logout; 28 | }); 29 | 30 | app.service("AuthenticationService", function($location) { 31 | return { 32 | login: function(credentials) { 33 | if (credentials.username !== "ralph" || credentials.password !== "wiggum") { 34 | alert("Username must be 'ralph', password must be 'wiggum'"); 35 | } else { 36 | $location.path('/logged-in'); 37 | } 38 | }, 39 | logout: function() { 40 | $location.path('/logged-out'); 41 | } 42 | }; 43 | }); 44 | 45 | // logged-out.html 46 |
47 |
48 |
49 |
50 | 51 |
52 |
53 | 54 |
55 |
56 | 57 |
58 |
59 | 60 |
61 |
62 |
63 |
64 | 65 | // logged-in.html 66 |

YOU ARE LOGGED IN!!!

67 | 68 | -------------------------------------------------------------------------------- /exercises/4-services-models-and-interaction/tests.js: -------------------------------------------------------------------------------- 1 | setTimeout(function() { 2 | 3 | var module = angular.module('app'); 4 | var usernameInput = document.querySelector('input[name=username]'); 5 | var passwordInput = document.querySelector('input[name=password]'); 6 | var form = document.querySelector('form#logged-out'); 7 | 8 | assert( 9 | module._configBlocks && 10 | module._configBlocks[0] && 11 | module._configBlocks[0][2] && 12 | !!module._configBlocks[0][2][0].toString().match(/\$routeProvider.when\(\'\/logged-out/), 'a route `/logged-out` is defined with `$routeProvider`'); 13 | 14 | assert( 15 | module._configBlocks && 16 | module._configBlocks[0] && 17 | module._configBlocks[0][2] && 18 | !!module._configBlocks[0][2][0].toString().match(/\$routeProvider.when\(\'\/logged-in/), 'a route `/logged-in` is defined with `$routeProvider`'); 19 | 20 | assert( 21 | module._invokeQueue && 22 | module._invokeQueue[0] && 23 | module._invokeQueue[0][2] && 24 | module._invokeQueue[0][2][0] === 'LoginController', 'a controller named `LoginController` exists on the `app` module'); 25 | 26 | assert( 27 | module._invokeQueue && 28 | module._invokeQueue[1] && 29 | module._invokeQueue[1][2] && 30 | module._invokeQueue[1][2][0] === 'LogoutController', 'a controller named `LogoutController` exists on the `app` module'); 31 | 32 | assert( 33 | form && 34 | form.attributes['ng-submit'] && 35 | form.attributes['ng-submit'].value === 'login()', 'logged-out.html form#logged-out is bound using `ng-submit` to `logout()`'); 36 | 37 | assert( 38 | usernameInput && 39 | usernameInput.attributes['ng-model'] && 40 | usernameInput.attributes['ng-model'].value === 'credentials.username', 'logged-out.html input[name=username] is bound to `credentials.username` using ng-model'); 41 | 42 | assert( 43 | passwordInput && 44 | passwordInput.attributes['ng-model'] && 45 | passwordInput.attributes['ng-model'].value === 'credentials.password', 'logged-out.html input[name=password] is bound to `credentials.password` using ng-model'); 46 | 47 | 48 | }, 1000); 49 | -------------------------------------------------------------------------------- /exercises/5-directives/app.js: -------------------------------------------------------------------------------- 1 | var app = angular.module('app', []); 2 | 3 | // controller here 4 | 5 | // directive here 6 | -------------------------------------------------------------------------------- /exercises/5-directives/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | An Introduction to Angular.JS 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Directives

19 |
    20 |
  1. Create a controller on the `app` module called `HoverController`, that has a message property assigned to the `$scope`. Let the message read: "Mouse Over these images to see a directive at work!"
  2. 21 |
  3. Assign the controller to div#hover-interaction using `ng-controller`
  4. 22 |
  5. On each house image element in the page, add a `shows-message-when-hovered` attribute and a `message` attribute. Make the `message` attribute value a string: "Im the nth house", where nth is `first`, `second`, etc..
  6. 23 |
  7. Create an `attribute` directive within the `app` module called `showsMessageWhenHovered` and add a `link` function that uses `angular.element.bind` to toggle the `scope.message` on 2 events: `mouseenter` and `mouseleave`.
  8. 24 |
  9. Create a binding for the message on the div.alert-box element using `ng-bind` to see the message changing when you mouseover the images on the page.
  10. 25 |
26 | 27 |
28 |
29 | 30 |
    31 |
  • 32 | 33 |
  • 34 |
  • 35 | 36 |
  • 37 |
38 |
39 | 40 |
41 |

Note: Open your browsers developer tools console and make sure the tests are passing.

42 |
43 |
44 |

Useful Resources

45 | 51 |
52 |
53 |
54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /exercises/5-directives/solution.js: -------------------------------------------------------------------------------- 1 | // app.js 2 | var app = angular.module('app', []); 3 | 4 | app.controller("HoverController", function($scope) { 5 | $scope.message = "Mouse Over these images to see a directive at work!"; 6 | }); 7 | 8 | app.directive("showsMessageWhenHovered", function() { 9 | return { 10 | restrict: "A", // A = Attribute, C = CSS Class, E = HTML Element, M = HTML Comment 11 | link: function(scope, element, attributes) { 12 | var originalMessage = scope.message; 13 | element.bind("mouseenter", function() { 14 | scope.message = attributes.message; 15 | scope.$apply(); 16 | }); 17 | element.bind("mouseleave", function() { 18 | scope.message = originalMessage; 19 | scope.$apply(); 20 | }); 21 | } 22 | }; 23 | }); 24 | 25 | // index.html 26 |
27 |
28 | 29 | 37 |
38 | -------------------------------------------------------------------------------- /exercises/5-directives/tests.js: -------------------------------------------------------------------------------- 1 | setTimeout(function() { 2 | 3 | var module = angular.module('app'); 4 | assert( 5 | module._invokeQueue && 6 | module._invokeQueue[0] && 7 | module._invokeQueue[0][2] && 8 | module._invokeQueue[0][2][0] === 'HoverController', 'a controller named `HoverController` exists on the `app` module'); 9 | 10 | var controllerDirective = document.querySelector('#hover-interaction').attributes['ng-controller']; 11 | assert(controllerDirective !== undefined, 'an `ng-controller` directive exists on div#hover-interaction'); 12 | assert(controllerDirective && controllerDirective.value === 'HoverController', 'the `ng-controller` directive value is `HoverController`'); 13 | 14 | var images = document.querySelectorAll('img.th'); 15 | var ordinalMap = { 16 | 0: 'first', 17 | 1: 'second' 18 | }; 19 | _.each(images, function(image, i) { 20 | var imageDirective = image.attributes['shows-message-when-hovered']; 21 | var messageDirective = image.attributes['message']; 22 | var expectedValue = "Im the " + ordinalMap[i] + " house"; 23 | assert(imageDirective && imageDirective.name === 'shows-message-when-hovered', 'image ' + (i+1) + ' has a `shows-message-when-hovered` attribute'); 24 | assert(messageDirective && messageDirective.value === expectedValue, 'image ' + (i+1) + ' has a `message` attribute with the value `' + expectedValue + '`'); 25 | }); 26 | 27 | var binding = document.querySelector('.alert-box').attributes['ng-bind']; 28 | assert(binding !== undefined, 'an `ng-bind` directive exists on div.alert-box'); 29 | assert(binding && binding.value === 'message', 'the `ng-bind` directive value is `message`'); 30 | 31 | assert( 32 | module._invokeQueue && 33 | module._invokeQueue[1] && 34 | module._invokeQueue[1][2] && 35 | module._invokeQueue[1][2][0] === 'showsMessageWhenHovered', 'a directive named `showsMessageWhenHovered` exists on the `app` module'); 36 | 37 | }, 1000); 38 | -------------------------------------------------------------------------------- /exercises/assert.js: -------------------------------------------------------------------------------- 1 | window.assert = function(pass, description) { 2 | if (pass === true) { 3 | console.log('%c✔︎ ok', 'color: green', description); 4 | } 5 | else { 6 | console.assert(pass, description); 7 | } 8 | }; 9 | 10 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Intro to Angular JS 6 | 7 | 8 | 9 |

Introduction to Angular JS

10 |
11 | 12 |

Exercises

13 | 20 |
21 | 22 |

Completed App

23 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "intro-to-angularjs", 3 | "version": "1.0.0", 4 | "description": "", 5 | "scripts": { 6 | "start": "./node_modules/.bin/serve" 7 | }, 8 | "author": "David mosher ", 9 | "license": "ISC", 10 | "dependencies": { 11 | "serve": "^1.4.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /scratchpad: -------------------------------------------------------------------------------- 1 | AngularJS Intro: 2 | 3 | - extension to html 4 | - what googles vision for "web components" are 5 | - isolated pieces of html, css, js working to create a rich experience 6 | - can do what other client-side frameworks like backbone/ember can, but offers a lot more 7 | - "data-binding" baked in 8 | - write less, do more 9 | 10 | 1. Module system 11 | 12 | app/js/app.js 13 | 14 | angular.module("app", []) 15 | 16 | - defines a spot to stick the stuff that belogns in this "application" 17 | - could be scoped smaller 18 | - the [] are intended to list any dependencies that this module might need, more later 19 | 20 | 2. How do we make our app aware of the app and "wire it up" ? 21 | 22 | index.html 23 | 24 | html ng-app="app" 25 | 26 | - this is a built in "directive" that tells angular to "bootstrap" this HTML element so that it knows about our app module 27 | - the wiring happens automatically 28 | 29 | 3. Routing / "Pages", How do we handle transitions? 30 | 31 | app/js/app.js 32 | 33 | .config(['$routeProvider', function($routeProvider) { 34 | 35 | $routeProvider.when('/login', { 36 | templateUrl: 'login.html', 37 | controller: 'LoginController' 38 | }); 39 | 40 | $routeProvider.otherwise({ redirectTo: '/login' }); 41 | 42 | }]); 43 | 44 | - dependency injection, more on that later 45 | - default route 46 | - a controller to handle the "context" for that "page" 47 | - where does it get injected? 48 | 49 | index.html 50 | 51 |
52 | 53 | - ng-view is an angular directive that tells angular, "this is where you should inject the templates that come from this scopes routeProvider when a route is matched" 54 | 55 | - the default behaviour is that angular will fetch the template provided at templateUrl, and cache it internally so it doesn't have to fetch it again 56 | 57 | - we need a controller, so things don't blow up 58 | 59 | app/js/app.js 60 | 61 | angular.module("app").controller("LoginController", function($scope) { 62 | 63 | }); 64 | 65 | 4. Right, so now we have a way to load templates and know how to load routes, so let's add a second route which has our homepage after login happens. 66 | 67 | home.html 68 | 69 | - now we can see the template cache at work, no more XHR's after the first two 70 | 71 | 5. Let's add some dynamic behaviour, and wire up the login form so it will redirect to the home page once the user submits the form. 72 | 73 | - first, we'll set angular up so it handles the form submit for us using the ng-submit attribute 74 | - this attribute defines an expression, and the spot angular looks for that expression is on the scope that is passed in to the controller 75 | 76 | - we'll write the logic for our controller to handle a basic login scheme, and if the username and password are correct redirect the user to our home page using angulars $location service 77 | 78 | - however, we also need to figure out how to get the HTML form elements to pass the username and password to the $scope so our login function knows about them; in jQuery you might handle this manually be using $("input").val(), but in angular we try to avoid doing any manual DOM querying and instead rely on directives, like ng-model. 79 | 80 | 6. Now that our login is working pretty well, we should add some love to the Homepage, cause it's kind of boring right now. So, we will make a custom directive to show a special message when the user hovers their mouse over each of the images _and_ set an initial value for a title and message when the page renders, remember we have 2 way binding! 81 | 82 | {{ title }} 83 | {{ message }} 84 | shows-message-when-hovered message="Im the first house." 85 | shows-message-when-hovered message="Im the second house." 86 | 87 | app.controller("HomeController", function($scope) { 88 | $scope.title = "Awesome Home"; 89 | $scope.message = "Mouse Over these images to see a directive at work!"; 90 | }); 91 | 92 | app.directive("showsMessageWhenHovered", function() { 93 | return { 94 | restrict: "A", // A = Attribute, C = CSS Class, E = HTML Element, M = HTML Comment 95 | link: function(scope, element, attributes) { 96 | var originalMessage = scope.message; 97 | element.bind("mouseenter", function() { 98 | scope.message = attributes.message; 99 | scope.$apply(); 100 | }); 101 | element.bind("mouseleave", function() { 102 | scope.message = originalMessage; 103 | scope.$apply(); 104 | }); 105 | } 106 | }; 107 | }); 108 | 109 | 7. Services - it seems silly that our HomePage controller has to know about how to handle logging in, and it kind of flies against the "angular way" of having pieces of code be responsible for only 1 thing (Single Responsibility Principle). So let's extract our authentication logic into a service called the AuthenticationService. 110 | 111 | - we also added a logout function, and wired it up in the home.html to complete the cycle in our simple app. 112 | - many more things we could explore, like $http 113 | 114 | 115 | -------------------------------------------------------------------------------- /vendor/css/foundation.min.css: -------------------------------------------------------------------------------- 1 | *,*:before,*:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}html,body{font-size:100%}body{background:#fff;color:#222;padding:0;margin:0;font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-weight:normal;font-style:normal;line-height:1;position:relative}a:focus{outline:none}img,object,embed{max-width:100%;height:auto}object,embed{height:100%}img{-ms-interpolation-mode:bicubic}#map_canvas img,#map_canvas embed,#map_canvas object,.map_canvas img,.map_canvas embed,.map_canvas object{max-width:none !important}.left{float:left !important}.right{float:right !important}.text-left{text-align:left !important}.text-right{text-align:right !important}.text-center{text-align:center !important}.text-justify{text-align:justify !important}.hide{display:none}.antialiased{-webkit-font-smoothing:antialiased}img{display:inline-block}textarea{height:auto;min-height:50px}select{width:100%}.row{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1}.row:before,.row:after{content:" ";display:table}.row:after{clear:both}.row .column,.row .columns{position:relative;padding-left:0.9375em;padding-right:0.9375em;width:100%;float:left}.row.collapse .column,.row.collapse .columns{position:relative;padding-left:0;padding-right:0;float:left}.row .row{width:auto;margin-left:-0.9375em;margin-right:-0.9375em;margin-top:0;margin-bottom:0;max-width:none;*zoom:1}.row .row:before,.row .row:after{content:" ";display:table}.row .row:after{clear:both}.row .row.collapse{width:auto;margin:0;max-width:none;*zoom:1}.row .row.collapse:before,.row .row.collapse:after{content:" ";display:table}.row .row.collapse:after{clear:both}@media only screen{.row .column,.row .columns{position:relative;padding-left:0.9375em;padding-right:0.9375em;float:left}.row .small-1{position:relative;width:8.33333%}.row .small-2{position:relative;width:16.66667%}.row .small-3{position:relative;width:25%}.row .small-4{position:relative;width:33.33333%}.row .small-5{position:relative;width:41.66667%}.row .small-6{position:relative;width:50%}.row .small-7{position:relative;width:58.33333%}.row .small-8{position:relative;width:66.66667%}.row .small-9{position:relative;width:75%}.row .small-10{position:relative;width:83.33333%}.row .small-11{position:relative;width:91.66667%}.row .small-12{position:relative;width:100%}.row .small-offset-1{position:relative;margin-left:8.33333%}.row .small-offset-2{position:relative;margin-left:16.66667%}.row .small-offset-3{position:relative;margin-left:25%}.row .small-offset-4{position:relative;margin-left:33.33333%}.row .small-offset-5{position:relative;margin-left:41.66667%}.row .small-offset-6{position:relative;margin-left:50%}.row .small-offset-7{position:relative;margin-left:58.33333%}.row .small-offset-8{position:relative;margin-left:66.66667%}.row .small-offset-9{position:relative;margin-left:75%}.row .small-offset-10{position:relative;margin-left:83.33333%}[class*="column"]+[class*="column"]:last-child{float:right}[class*="column"]+[class*="column"].end{float:left}.column.small-centered,.columns.small-centered{position:relative;margin-left:auto;margin-right:auto;float:none !important}}@media only screen and (min-width: 48em){.row .large-1{position:relative;width:8.33333%}.row .large-2{position:relative;width:16.66667%}.row .large-3{position:relative;width:25%}.row .large-4{position:relative;width:33.33333%}.row .large-5{position:relative;width:41.66667%}.row .large-6{position:relative;width:50%}.row .large-7{position:relative;width:58.33333%}.row .large-8{position:relative;width:66.66667%}.row .large-9{position:relative;width:75%}.row .large-10{position:relative;width:83.33333%}.row .large-11{position:relative;width:91.66667%}.row .large-12{position:relative;width:100%}.row .large-offset-1{position:relative;margin-left:8.33333%}.row .large-offset-2{position:relative;margin-left:16.66667%}.row .large-offset-3{position:relative;margin-left:25%}.row .large-offset-4{position:relative;margin-left:33.33333%}.row .large-offset-5{position:relative;margin-left:41.66667%}.row .large-offset-6{position:relative;margin-left:50%}.row .large-offset-7{position:relative;margin-left:58.33333%}.row .large-offset-8{position:relative;margin-left:66.66667%}.row .large-offset-9{position:relative;margin-left:75%}.row .large-offset-10{position:relative;margin-left:83.33333%}.push-2{position:relative;left:16.66667%;right:auto}.pull-2{position:relative;right:16.66667%;left:auto}.push-3{position:relative;left:25%;right:auto}.pull-3{position:relative;right:25%;left:auto}.push-4{position:relative;left:33.33333%;right:auto}.pull-4{position:relative;right:33.33333%;left:auto}.push-5{position:relative;left:41.66667%;right:auto}.pull-5{position:relative;right:41.66667%;left:auto}.push-6{position:relative;left:50%;right:auto}.pull-6{position:relative;right:50%;left:auto}.push-7{position:relative;left:58.33333%;right:auto}.pull-7{position:relative;right:58.33333%;left:auto}.push-8{position:relative;left:66.66667%;right:auto}.pull-8{position:relative;right:66.66667%;left:auto}.push-9{position:relative;left:75%;right:auto}.pull-9{position:relative;right:75%;left:auto}.push-10{position:relative;left:83.33333%;right:auto}.pull-10{position:relative;right:83.33333%;left:auto}.small-push-2{left:inherit}.small-pull-2{right:inherit}.small-push-3{left:inherit}.small-pull-3{right:inherit}.small-push-4{left:inherit}.small-pull-4{right:inherit}.small-push-5{left:inherit}.small-pull-5{right:inherit}.small-push-6{left:inherit}.small-pull-6{right:inherit}.small-push-7{left:inherit}.small-pull-7{right:inherit}.small-push-8{left:inherit}.small-pull-8{right:inherit}.small-push-9{left:inherit}.small-pull-9{right:inherit}.small-push-10{left:inherit}.small-pull-10{right:inherit}.column.large-centered,.columns.large-centered{position:relative;margin-left:auto;margin-right:auto;float:none !important}}.show-for-small,.show-for-medium-down,.show-for-large-down{display:inherit !important}.show-for-medium,.show-for-medium-up,.show-for-large,.show-for-large-up,.show-for-xlarge{display:none !important}.hide-for-medium,.hide-for-medium-up,.hide-for-large,.hide-for-large-up,.hide-for-xlarge{display:inherit !important}.hide-for-small,.hide-for-medium-down,.hide-for-large-down{display:none !important}table.show-for-small,table.show-for-medium-down,table.show-for-large-down,table.hide-for-medium,table.hide-for-medium-up,table.hide-for-large,table.hide-for-large-up,table.hide-for-xlarge{display:table}thead.show-for-small,thead.show-for-medium-down,thead.show-for-large-down,thead.hide-for-medium,thead.hide-for-medium-up,thead.hide-for-large,thead.hide-for-large-up,thead.hide-for-xlarge{display:table-header-group !important}tbody.show-for-small,tbody.show-for-medium-down,tbody.show-for-large-down,tbody.hide-for-medium,tbody.hide-for-medium-up,tbody.hide-for-large,tbody.hide-for-large-up,tbody.hide-for-xlarge{display:table-row-group !important}tr.show-for-small,tr.show-for-medium-down,tr.show-for-large-down,tr.hide-for-medium,tr.hide-for-medium-up,tr.hide-for-large,tr.hide-for-large-up,tr.hide-for-xlarge{display:table-row !important}td.show-for-small,td.show-for-medium-down,td.show-for-large-down,td.hide-for-medium,td.hide-for-medium-up,td.hide-for-large,td.hide-for-large-up,td.hide-for-xlarge,th.show-for-small,th.show-for-medium-down,th.show-for-large-down,th.hide-for-medium,th.hide-for-medium-up,th.hide-for-large,th.hide-for-large-up,th.hide-for-xlarge{display:table-cell !important}@media only screen and (min-width: 48em){.show-for-medium,.show-for-medium-up{display:inherit !important}.show-for-small{display:none !important}.hide-for-small{display:inherit !important}.hide-for-medium,.hide-for-medium-up{display:none !important}table.show-for-medium,table.show-for-medium-up,table.hide-for-small{display:table}thead.show-for-medium,thead.show-for-medium-up,thead.hide-for-small{display:table-header-group !important}tbody.show-for-medium,tbody.show-for-medium-up,tbody.hide-for-small{display:table-row-group !important}tr.show-for-medium,tr.show-for-medium-up,tr.hide-for-small{display:table-row !important}td.show-for-medium,td.show-for-medium-up,td.hide-for-small,th.show-for-medium,th.show-for-medium-up,th.hide-for-small{display:table-cell !important}}@media only screen and (min-width: 80em){.show-for-large,.show-for-large-up{display:inherit !important}.show-for-medium,.show-for-medium-down{display:none !important}.hide-for-medium,.hide-for-medium-down{display:inherit !important}.hide-for-large,.hide-for-large-up{display:none !important}table.show-for-large,table.show-for-large-up,table.hide-for-medium,table.hide-for-medium-down{display:table}thead.show-for-large,thead.show-for-large-up,thead.hide-for-medium,thead.hide-for-medium-down{display:table-header-group !important}tbody.show-for-large,tbody.show-for-large-up,tbody.hide-for-medium,tbody.hide-for-medium-down{display:table-row-group !important}tr.show-for-large,tr.show-for-large-up,tr.hide-for-medium,tr.hide-for-medium-down{display:table-row !important}td.show-for-large,td.show-for-large-up,td.hide-for-medium,td.hide-for-medium-down,th.show-for-large,th.show-for-large-up,th.hide-for-medium,th.hide-for-medium-down{display:table-cell !important}}@media only screen and (min-width: 90em){.show-for-xlarge{display:inherit !important}.show-for-large,.show-for-large-down{display:none !important}.hide-for-large,.hide-for-large-down{display:inherit !important}.hide-for-xlarge{display:none !important}table.show-for-xlarge,table.hide-for-large,table.hide-for-large-down{display:table}thead.show-for-xlarge,thead.hide-for-large,thead.hide-for-large-down{display:table-header-group !important}tbody.show-for-xlarge,tbody.hide-for-large,tbody.hide-for-large-down{display:table-row-group !important}tr.show-for-xlarge,tr.hide-for-large,tr.hide-for-large-down{display:table-row !important}td.show-for-xlarge,td.hide-for-large,td.hide-for-large-down,th.show-for-xlarge,th.hide-for-large,th.hide-for-large-down{display:table-cell !important}}.show-for-landscape,.hide-for-portrait{display:inherit !important}.hide-for-landscape,.show-for-portrait{display:none !important}table.hide-for-landscape,table.show-for-portrait{display:table}thead.hide-for-landscape,thead.show-for-portrait{display:table-header-group !important}tbody.hide-for-landscape,tbody.show-for-portrait{display:table-row-group !important}tr.hide-for-landscape,tr.show-for-portrait{display:table-row !important}td.hide-for-landscape,td.show-for-portrait,th.hide-for-landscape,th.show-for-portrait{display:table-cell !important}@media only screen and (orientation: landscape){.show-for-landscape,.hide-for-portrait{display:inherit !important}.hide-for-landscape,.show-for-portrait{display:none !important}table.show-for-landscape,table.hide-for-portrait{display:table}thead.show-for-landscape,thead.hide-for-portrait{display:table-header-group !important}tbody.show-for-landscape,tbody.hide-for-portrait{display:table-row-group !important}tr.show-for-landscape,tr.hide-for-portrait{display:table-row !important}td.show-for-landscape,td.hide-for-portrait,th.show-for-landscape,th.hide-for-portrait{display:table-cell !important}}@media only screen and (orientation: portrait){.show-for-portrait,.hide-for-landscape{display:inherit !important}.hide-for-portrait,.show-for-landscape{display:none !important}table.show-for-portrait,table.hide-for-landscape{display:table}thead.show-for-portrait,thead.hide-for-landscape{display:table-header-group !important}tbody.show-for-portrait,tbody.hide-for-landscape{display:table-row-group !important}tr.show-for-portrait,tr.hide-for-landscape{display:table-row !important}td.show-for-portrait,td.hide-for-landscape,th.show-for-portrait,th.hide-for-landscape{display:table-cell !important}}.show-for-touch{display:none !important}.hide-for-touch{display:inherit !important}.touch .show-for-touch{display:inherit !important}.touch .hide-for-touch{display:none !important}table.hide-for-touch{display:table}.touch table.show-for-touch{display:table}thead.hide-for-touch{display:table-header-group !important}.touch thead.show-for-touch{display:table-header-group !important}tbody.hide-for-touch{display:table-row-group !important}.touch tbody.show-for-touch{display:table-row-group !important}tr.hide-for-touch{display:table-row !important}.touch tr.show-for-touch{display:table-row !important}td.hide-for-touch{display:table-cell !important}.touch td.show-for-touch{display:table-cell !important}th.hide-for-touch{display:table-cell !important}.touch th.show-for-touch{display:table-cell !important}@media only screen{[class*="block-grid-"]{display:block;padding:0;margin:0 -10px;*zoom:1}[class*="block-grid-"]:before,[class*="block-grid-"]:after{content:" ";display:table}[class*="block-grid-"]:after{clear:both}[class*="block-grid-"]>li{display:block;height:auto;float:left;padding:0 10px 10px}.small-block-grid-1>li{width:100%;padding:0 10px 10px}.small-block-grid-1>li:nth-of-type(1n+1){clear:both}.small-block-grid-2>li{width:50%;padding:0 10px 10px}.small-block-grid-2>li:nth-of-type(2n+1){clear:both}.small-block-grid-3>li{width:33.33333%;padding:0 10px 10px}.small-block-grid-3>li:nth-of-type(3n+1){clear:both}.small-block-grid-4>li{width:25%;padding:0 10px 10px}.small-block-grid-4>li:nth-of-type(4n+1){clear:both}.small-block-grid-5>li{width:20%;padding:0 10px 10px}.small-block-grid-5>li:nth-of-type(5n+1){clear:both}.small-block-grid-6>li{width:16.66667%;padding:0 10px 10px}.small-block-grid-6>li:nth-of-type(6n+1){clear:both}.small-block-grid-7>li{width:14.28571%;padding:0 10px 10px}.small-block-grid-7>li:nth-of-type(7n+1){clear:both}.small-block-grid-8>li{width:12.5%;padding:0 10px 10px}.small-block-grid-8>li:nth-of-type(8n+1){clear:both}.small-block-grid-9>li{width:11.11111%;padding:0 10px 10px}.small-block-grid-9>li:nth-of-type(9n+1){clear:both}.small-block-grid-10>li{width:10%;padding:0 10px 10px}.small-block-grid-10>li:nth-of-type(10n+1){clear:both}.small-block-grid-11>li{width:9.09091%;padding:0 10px 10px}.small-block-grid-11>li:nth-of-type(11n+1){clear:both}.small-block-grid-12>li{width:8.33333%;padding:0 10px 10px}.small-block-grid-12>li:nth-of-type(12n+1){clear:both}}@media only screen and (min-width: 48em){.large-block-grid-1>li{width:100%;padding:0 10px 10px}.large-block-grid-1>li:nth-of-type(1n+1){clear:both}.large-block-grid-2>li{width:50%;padding:0 10px 10px}.large-block-grid-2>li:nth-of-type(2n+1){clear:both}.large-block-grid-3>li{width:33.33333%;padding:0 10px 10px}.large-block-grid-3>li:nth-of-type(3n+1){clear:both}.large-block-grid-4>li{width:25%;padding:0 10px 10px}.large-block-grid-4>li:nth-of-type(4n+1){clear:both}.large-block-grid-5>li{width:20%;padding:0 10px 10px}.large-block-grid-5>li:nth-of-type(5n+1){clear:both}.large-block-grid-6>li{width:16.66667%;padding:0 10px 10px}.large-block-grid-6>li:nth-of-type(6n+1){clear:both}.large-block-grid-7>li{width:14.28571%;padding:0 10px 10px}.large-block-grid-7>li:nth-of-type(7n+1){clear:both}.large-block-grid-8>li{width:12.5%;padding:0 10px 10px}.large-block-grid-8>li:nth-of-type(8n+1){clear:both}.large-block-grid-9>li{width:11.11111%;padding:0 10px 10px}.large-block-grid-9>li:nth-of-type(9n+1){clear:both}.large-block-grid-10>li{width:10%;padding:0 10px 10px}.large-block-grid-10>li:nth-of-type(10n+1){clear:both}.large-block-grid-11>li{width:9.09091%;padding:0 10px 10px}.large-block-grid-11>li:nth-of-type(11n+1){clear:both}.large-block-grid-12>li{width:8.33333%;padding:0 10px 10px}.large-block-grid-12>li:nth-of-type(12n+1){clear:both}[class*="small-block-grid-"]>li{clear:none !important}}p.lead{font-size:1.21875em;line-height:1.6}.subheader{line-height:1.4;color:#6f6f6f;font-weight:300;margin-top:0.2em;margin-bottom:0.5em}div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr}a{color:#2ba6cb;text-decoration:none;line-height:inherit}a:hover,a:focus{color:#2795b6}a img{border:none}p{font-family:inherit;font-weight:normal;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}p aside{font-size:0.875em;line-height:1.35;font-style:italic}h1,h2,h3,h4,h5,h6{font-family:"Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif;font-weight:bold;font-style:normal;color:#222;text-rendering:optimizeLegibility;margin-top:0.2em;margin-bottom:0.5em;line-height:1.2125em}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-size:60%;color:#6f6f6f;line-height:0}h1{font-size:2.125em}h2{font-size:1.6875em}h3{font-size:1.375em}h4{font-size:1.125em}h5{font-size:1.125em}h6{font-size:1em}hr{border:solid #ddd;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0}em,i{font-style:italic;line-height:inherit}strong,b{font-weight:bold;line-height:inherit}small{font-size:60%;line-height:inherit}code{font-family:Consolas,"Liberation Mono",Courier,monospace;font-weight:bold;color:#7f0a0c}ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em}ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}ul.square{list-style-type:square}ul.circle{list-style-type:circle}ul.disc{list-style-type:disc}ul.no-bullet{list-style:none}ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}dl dt{margin-bottom:0.3em;font-weight:bold}dl dd{margin-bottom:0.75em}abbr,acronym{text-transform:uppercase;font-size:90%;color:#222;border-bottom:1px dotted #ddd;cursor:help}abbr{text-transform:none}blockquote{margin:0 0 1.25em;padding:0.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}blockquote cite{display:block;font-size:0.8125em;color:#555}blockquote cite:before{content:"\2014 \0020"}blockquote cite a,blockquote cite a:visited{color:#555}blockquote,blockquote p{line-height:1.6;color:#6f6f6f}.vcard{display:inline-block;margin:0 0 1.25em 0;border:1px solid #ddd;padding:0.625em 0.75em}.vcard li{margin:0;display:block}.vcard .fn{font-weight:bold;font-size:0.9375em}.vevent .summary{font-weight:bold}.vevent abbr{cursor:default;text-decoration:none;font-weight:bold;border:none;padding:0 0.0625em}@media only screen and (min-width: 48em){h1,h2,h3,h4,h5,h6{line-height:1.4}h1{font-size:2.75em}h2{font-size:2.3125em}h3{font-size:1.6875em}h4{font-size:1.4375em}}.print-only{display:none !important}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}.hide-on-print{display:none !important}.print-only{display:block !important}.hide-for-print{display:none !important}.show-for-print{display:inherit !important}}button,.button{border-style:solid;border-width:1px;cursor:pointer;font-family:inherit;font-weight:bold;line-height:1;margin:0 0 1.25em;position:relative;text-decoration:none;text-align:center;display:inline-block;padding-top:0.75em;padding-right:1.5em;padding-bottom:0.8125em;padding-left:1.5em;font-size:1em;background-color:#2ba6cb;border-color:#2284a1;color:#fff}button:hover,button:focus,.button:hover,.button:focus{background-color:#2284a1}button:hover,button:focus,.button:hover,.button:focus{color:#fff}button.secondary,.button.secondary{background-color:#e9e9e9;border-color:#d0d0d0;color:#333}button.secondary:hover,button.secondary:focus,.button.secondary:hover,.button.secondary:focus{background-color:#d0d0d0}button.secondary:hover,button.secondary:focus,.button.secondary:hover,.button.secondary:focus{color:#333}button.success,.button.success{background-color:#5da423;border-color:#457a1a;color:#fff}button.success:hover,button.success:focus,.button.success:hover,.button.success:focus{background-color:#457a1a}button.success:hover,button.success:focus,.button.success:hover,.button.success:focus{color:#fff}button.alert,.button.alert{background-color:#c60f13;border-color:#970b0e;color:#fff}button.alert:hover,button.alert:focus,.button.alert:hover,.button.alert:focus{background-color:#970b0e}button.alert:hover,button.alert:focus,.button.alert:hover,.button.alert:focus{color:#fff}button.large,.button.large{padding-top:1em;padding-right:2em;padding-bottom:1.0625em;padding-left:2em;font-size:1.25em}button.small,.button.small{padding-top:0.5625em;padding-right:1.125em;padding-bottom:0.625em;padding-left:1.125em;font-size:0.8125em}button.tiny,.button.tiny{padding-top:0.4375em;padding-right:0.875em;padding-bottom:0.5em;padding-left:0.875em;font-size:0.6875em}button.expand,.button.expand{padding-top:false;padding-right:0px;padding-bottom:false0.0625em;padding-left:0px;width:100%}button.left-align,.button.left-align{text-align:left;text-indent:0.75em}button.right-align,.button.right-align{text-align:right;padding-right:0.75em}button.disabled,button[disabled],.button.disabled,.button[disabled]{background-color:#2ba6cb;border-color:#2284a1;color:#fff;cursor:default;opacity:0.6;-webkit-box-shadow:none;box-shadow:none}button.disabled:hover,button.disabled:focus,button[disabled]:hover,button[disabled]:focus,.button.disabled:hover,.button.disabled:focus,.button[disabled]:hover,.button[disabled]:focus{background-color:#2284a1}button.disabled:hover,button.disabled:focus,button[disabled]:hover,button[disabled]:focus,.button.disabled:hover,.button.disabled:focus,.button[disabled]:hover,.button[disabled]:focus{color:#fff}button.disabled:hover,button.disabled:focus,button[disabled]:hover,button[disabled]:focus,.button.disabled:hover,.button.disabled:focus,.button[disabled]:hover,.button[disabled]:focus{background-color:#2ba6cb}button.disabled.secondary,button[disabled].secondary,.button.disabled.secondary,.button[disabled].secondary{background-color:#e9e9e9;border-color:#d0d0d0;color:#333;cursor:default;opacity:0.6;-webkit-box-shadow:none;box-shadow:none}button.disabled.secondary:hover,button.disabled.secondary:focus,button[disabled].secondary:hover,button[disabled].secondary:focus,.button.disabled.secondary:hover,.button.disabled.secondary:focus,.button[disabled].secondary:hover,.button[disabled].secondary:focus{background-color:#d0d0d0}button.disabled.secondary:hover,button.disabled.secondary:focus,button[disabled].secondary:hover,button[disabled].secondary:focus,.button.disabled.secondary:hover,.button.disabled.secondary:focus,.button[disabled].secondary:hover,.button[disabled].secondary:focus{color:#333}button.disabled.secondary:hover,button.disabled.secondary:focus,button[disabled].secondary:hover,button[disabled].secondary:focus,.button.disabled.secondary:hover,.button.disabled.secondary:focus,.button[disabled].secondary:hover,.button[disabled].secondary:focus{background-color:#e9e9e9}button.disabled.success,button[disabled].success,.button.disabled.success,.button[disabled].success{background-color:#5da423;border-color:#457a1a;color:#fff;cursor:default;opacity:0.6;-webkit-box-shadow:none;box-shadow:none}button.disabled.success:hover,button.disabled.success:focus,button[disabled].success:hover,button[disabled].success:focus,.button.disabled.success:hover,.button.disabled.success:focus,.button[disabled].success:hover,.button[disabled].success:focus{background-color:#457a1a}button.disabled.success:hover,button.disabled.success:focus,button[disabled].success:hover,button[disabled].success:focus,.button.disabled.success:hover,.button.disabled.success:focus,.button[disabled].success:hover,.button[disabled].success:focus{color:#fff}button.disabled.success:hover,button.disabled.success:focus,button[disabled].success:hover,button[disabled].success:focus,.button.disabled.success:hover,.button.disabled.success:focus,.button[disabled].success:hover,.button[disabled].success:focus{background-color:#5da423}button.disabled.alert,button[disabled].alert,.button.disabled.alert,.button[disabled].alert{background-color:#c60f13;border-color:#970b0e;color:#fff;cursor:default;opacity:0.6;-webkit-box-shadow:none;box-shadow:none}button.disabled.alert:hover,button.disabled.alert:focus,button[disabled].alert:hover,button[disabled].alert:focus,.button.disabled.alert:hover,.button.disabled.alert:focus,.button[disabled].alert:hover,.button[disabled].alert:focus{background-color:#970b0e}button.disabled.alert:hover,button.disabled.alert:focus,button[disabled].alert:hover,button[disabled].alert:focus,.button.disabled.alert:hover,.button.disabled.alert:focus,.button[disabled].alert:hover,.button[disabled].alert:focus{color:#fff}button.disabled.alert:hover,button.disabled.alert:focus,button[disabled].alert:hover,button[disabled].alert:focus,.button.disabled.alert:hover,.button.disabled.alert:focus,.button[disabled].alert:hover,.button[disabled].alert:focus{background-color:#c60f13}input.button,button.button{padding-top:0.8125em;padding-bottom:0.75em}input.button.tiny,button.button.tiny{padding-top:0.5em;padding-bottom:0.4375em}input.button.small,button.button.small{padding-top:0.625em;padding-bottom:0.5625em}input.button.large,button.button.large{padding-top:1.03125em;padding-bottom:1.03125em}@media only screen{.button{-webkit-box-shadow:0 1px 0 rgba(255,255,255,0.5) inset;box-shadow:0 1px 0 rgba(255,255,255,0.5) inset;-webkit-transition:background-color 300ms ease-out;-moz-transition:background-color 300ms ease-out;transition:background-color 300ms ease-out}.button:active{-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.2) inset;box-shadow:0 1px 0 rgba(0,0,0,0.2) inset}.button.radius{-webkit-border-radius:3px;border-radius:3px}.button.round{-webkit-border-radius:1000px;border-radius:1000px}}@media only screen and (min-width: 48em){.button{display:inline-block}}form{margin:0 0 1em}form .row .row{margin:-0.5em}form .row .row .column,form .row .row .columns{padding:0 0.5em}form .row .row.collapse{margin:0}form .row .row.collapse .column,form .row .row.collapse .columns{padding:0}form .row input.column,form .row input.columns{padding-left:0.5em}label{font-size:0.875em;color:#4d4d4d;cursor:pointer;display:block;font-weight:500;margin-bottom:0.1875em}label.right{float:none;text-align:right}label.inline{margin:0 0 1em 0;padding:0.625em 0}.prefix,.postfix{display:block;position:relative;z-index:2;text-align:center;width:100%;padding-top:0;padding-bottom:0;border-style:solid;border-width:1px;overflow:hidden;font-size:0.875em;height:2.3125em;line-height:2.3125em}.postfix.button{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;text-align:center;line-height:2.125em}.prefix.button{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;text-align:center;line-height:2.125em}.prefix.button.radius{-webkit-border-radius:0;border-radius:0;-moz-border-radius-bottomleft:3px;-moz-border-radius-topleft:3px;-webkit-border-bottom-left-radius:3px;-webkit-border-top-left-radius:3px;border-bottom-left-radius:3px;border-top-left-radius:3px}.postfix.button.radius{-webkit-border-radius:0;border-radius:0;-moz-border-radius-topright:3px;-moz-border-radius-bottomright:3px;-webkit-border-top-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px}.prefix.button.round{-webkit-border-radius:0;border-radius:0;-moz-border-radius-bottomleft:1000px;-moz-border-radius-topleft:1000px;-webkit-border-bottom-left-radius:1000px;-webkit-border-top-left-radius:1000px;border-bottom-left-radius:1000px;border-top-left-radius:1000px}.postfix.button.round{-webkit-border-radius:0;border-radius:0;-moz-border-radius-topright:1000px;-moz-border-radius-bottomright:1000px;-webkit-border-top-right-radius:1000px;-webkit-border-bottom-right-radius:1000px;border-top-right-radius:1000px;border-bottom-right-radius:1000px}span.prefix{background:#f2f2f2;border-color:#d9d9d9;border-right:none;color:#333}span.prefix.radius{-webkit-border-radius:0;border-radius:0;-moz-border-radius-bottomleft:3px;-moz-border-radius-topleft:3px;-webkit-border-bottom-left-radius:3px;-webkit-border-top-left-radius:3px;border-bottom-left-radius:3px;border-top-left-radius:3px}span.postfix{background:#f2f2f2;border-color:#ccc;border-left:none;color:#333}span.postfix.radius{-webkit-border-radius:0;border-radius:0;-moz-border-radius-topright:3px;-moz-border-radius-bottomright:3px;-webkit-border-top-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px}.input-group.radius>*:first-child,.input-group.radius>*:first-child *{-webkit-border-radius:0;border-radius:0;-moz-border-radius-bottomleft:3px;-moz-border-radius-topleft:3px;-webkit-border-bottom-left-radius:3px;-webkit-border-top-left-radius:3px;border-bottom-left-radius:3px;border-top-left-radius:3px}.input-group.radius>*:last-child,.input-group.radius>*:last-child *{-webkit-border-radius:0;border-radius:0;-moz-border-radius-topright:3px;-moz-border-radius-bottomright:3px;-webkit-border-top-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px}.input-group.round>*:first-child,.input-group.round>*:first-child *{-webkit-border-radius:0;border-radius:0;-moz-border-radius-bottomleft:1000px;-moz-border-radius-topleft:1000px;-webkit-border-bottom-left-radius:1000px;-webkit-border-top-left-radius:1000px;border-bottom-left-radius:1000px;border-top-left-radius:1000px}.input-group.round>*:last-child,.input-group.round>*:last-child *{-webkit-border-radius:0;border-radius:0;-moz-border-radius-topright:1000px;-moz-border-radius-bottomright:1000px;-webkit-border-top-right-radius:1000px;-webkit-border-bottom-right-radius:1000px;border-top-right-radius:1000px;border-bottom-right-radius:1000px}input[type="text"],input[type="password"],input[type="date"],input[type="datetime"],input[type="datetime-local"],input[type="month"],input[type="week"],input[type="email"],input[type="number"],input[type="search"],input[type="tel"],input[type="time"],input[type="url"],textarea{background-color:#fff;font-family:inherit;border:1px solid #ccc;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);color:rgba(0,0,0,0.75);display:block;font-size:0.875em;margin:0 0 1em 0;padding:0.5em;height:2.3125em;width:100%;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-transition:all 0.15s linear;-moz-transition:all 0.15s linear;transition:all 0.15s linear}input[type="text"]:focus,input[type="password"]:focus,input[type="date"]:focus,input[type="datetime"]:focus,input[type="datetime-local"]:focus,input[type="month"]:focus,input[type="week"]:focus,input[type="email"]:focus,input[type="number"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="time"]:focus,input[type="url"]:focus,textarea:focus{background:#fafafa;border-color:#999;outline:none}input[type="text"][disabled],input[type="password"][disabled],input[type="date"][disabled],input[type="datetime"][disabled],input[type="datetime-local"][disabled],input[type="month"][disabled],input[type="week"][disabled],input[type="email"][disabled],input[type="number"][disabled],input[type="search"][disabled],input[type="tel"][disabled],input[type="time"][disabled],input[type="url"][disabled],textarea[disabled]{background-color:#ddd}fieldset{border:solid 1px #ddd;padding:1.25em;margin:1.125em 0}fieldset legend{font-weight:bold;background:#fff;padding:0 0.1875em;margin:0;margin-left:-0.1875em}.error input,input.error,.error textarea,textarea.error{border-color:#c60f13;background-color:rgba(198,15,19,0.1)}.error input:focus,input.error:focus,.error textarea:focus,textarea.error:focus{background:#fafafa;border-color:#999}.error label,label.error{color:#c60f13}.error small,small.error{display:block;padding:0.375em 0.25em;margin-top:-1.3125em;margin-bottom:1em;font-size:0.75em;font-weight:bold;background:#c60f13;color:#fff}form.custom .custom{display:inline-block;width:16px;height:16px;position:relative;top:2px;border:solid 1px #ccc;background:#fff}form.custom .custom.radio{-webkit-border-radius:1000px;border-radius:1000px}form.custom .custom.checkbox:before{content:"";display:block;line-height:0.8;height:14px;width:14px;text-align:center;position:absolute;top:0;left:0;font-size:14px;color:#fff}form.custom .custom.radio.checked:before{content:"";display:block;width:8px;height:8px;-webkit-border-radius:1000px;border-radius:1000px;background:#222;position:relative;top:3px;left:3px}form.custom .custom.checkbox.checked:before{content:"\00d7";color:#222}form.custom .custom.dropdown{display:block;position:relative;top:0;height:2.3125em;margin-bottom:1.25em;margin-top:0px;padding:0px;width:100%;background:#fff;background:-moz-linear-gradient(top, #fff 0%, #f3f3f3 100%);background:-webkit-linear-gradient(top, #fff 0%, #f3f3f3 100%);background:linear-gradient(to bottom, #fff 0%, #f3f3f3 100%);-webkit-box-shadow:none;box-shadow:none;font-size:0.875em;vertical-align:top}form.custom .custom.dropdown ul{overflow-y:auto;max-height:200px}form.custom .custom.dropdown .current{cursor:default;white-space:nowrap;line-height:2.25em;color:rgba(0,0,0,0.75);text-decoration:none;overflow:hidden;display:block;margin-left:0.5em;margin-right:2.3125em}form.custom .custom.dropdown .selector{cursor:default;position:absolute;width:2.5em;height:2.3125em;display:block;right:0;top:0}form.custom .custom.dropdown .selector:after{content:"";display:block;content:"";display:block;width:0;height:0;border:solid 5px;border-color:#aaa transparent transparent transparent;position:absolute;left:0.9375em;top:50%;margin-top:-3px}form.custom .custom.dropdown:hover a.selector:after,form.custom .custom.dropdown.open a.selector:after{content:"";display:block;width:0;height:0;border:solid 5px;border-color:#222 transparent transparent transparent}form.custom .custom.dropdown .disabled{color:#888}form.custom .custom.dropdown .disabled:hover{background:transparent;color:#888}form.custom .custom.dropdown .disabled:hover:after{display:none}form.custom .custom.dropdown.open ul{display:block;z-index:10;min-width:100%;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}form.custom .custom.dropdown.small{max-width:134px}form.custom .custom.dropdown.medium{max-width:254px}form.custom .custom.dropdown.large{max-width:434px}form.custom .custom.dropdown.expand{width:100% !important}form.custom .custom.dropdown.open.small ul{min-width:134px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}form.custom .custom.dropdown.open.medium ul{min-width:254px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}form.custom .custom.dropdown.open.large ul{min-width:434px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}form.custom .custom.dropdown ul{position:absolute;width:auto;display:none;margin:0;left:-1px;top:auto;-webkit-box-shadow:0 2px 2px 0px rgba(0,0,0,0.1);box-shadow:0 2px 2px 0px rgba(0,0,0,0.1);margin:0;padding:0;background:#fff;border:solid 1px #ccc;font-size:16px}form.custom .custom.dropdown ul li{color:#555;font-size:0.875em;cursor:default;padding-top:0.25em;padding-bottom:0.25em;padding-left:0.375em;padding-right:2.375em;min-height:1.5em;line-height:1.5em;margin:0;white-space:nowrap;list-style:none}form.custom .custom.dropdown ul li.selected{background:#eee;color:#000}form.custom .custom.dropdown ul li:hover{background-color:#e4e4e4;color:#000}form.custom .custom.dropdown ul li.selected:hover{background:#eee;cursor:default;color:#000}form.custom .custom.dropdown ul.show{display:block}form.custom .custom.disabled{background-color:#ddd}.button-group{list-style:none;margin:0;*zoom:1}.button-group:before,.button-group:after{content:" ";display:table}.button-group:after{clear:both}.button-group>*{margin:0 0 0 -1px;float:left}.button-group>*:first-child{margin-left:0}.button-group.radius>*:first-child,.button-group.radius>*:first-child>a,.button-group.radius>*:first-child>button{-webkit-border-radius:0;border-radius:0;-moz-border-radius-bottomleft:3px;-moz-border-radius-topleft:3px;-webkit-border-bottom-left-radius:3px;-webkit-border-top-left-radius:3px;border-bottom-left-radius:3px;border-top-left-radius:3px}.button-group.radius>*:last-child,.button-group.radius>*:last-child>a,.button-group.radius>*:last-child>button{-webkit-border-radius:0;border-radius:0;-moz-border-radius-topright:3px;-moz-border-radius-bottomright:3px;-webkit-border-top-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px}.button-group.round>*:first-child,.button-group.round>*:first-child>a,.button-group.round>*:first-child>button{-webkit-border-radius:0;border-radius:0;-moz-border-radius-bottomleft:1000px;-moz-border-radius-topleft:1000px;-webkit-border-bottom-left-radius:1000px;-webkit-border-top-left-radius:1000px;border-bottom-left-radius:1000px;border-top-left-radius:1000px}.button-group.round>*:last-child,.button-group.round>*:last-child>a,.button-group.round>*:last-child>button{-webkit-border-radius:0;border-radius:0;-moz-border-radius-topright:1000px;-moz-border-radius-bottomright:1000px;-webkit-border-top-right-radius:1000px;-webkit-border-bottom-right-radius:1000px;border-top-right-radius:1000px;border-bottom-right-radius:1000px}.button-group.even-2 li{width:50%}.button-group.even-2 li .button{width:100%}.button-group.even-3 li{width:33.33333%}.button-group.even-3 li .button{width:100%}.button-group.even-4 li{width:25%}.button-group.even-4 li .button{width:100%}.button-group.even-5 li{width:20%}.button-group.even-5 li .button{width:100%}.button-group.even-6 li{width:16.66667%}.button-group.even-6 li .button{width:100%}.button-group.even-7 li{width:14.28571%}.button-group.even-7 li .button{width:100%}.button-group.even-8 li{width:12.5%}.button-group.even-8 li .button{width:100%}.button-bar{*zoom:1}.button-bar:before,.button-bar:after{content:" ";display:table}.button-bar:after{clear:both}.button-bar .button-group{float:left;margin-right:0.625em}.button-bar .button-group div{overflow:hidden}.dropdown.button{position:relative;padding-right:3.1875em}.dropdown.button:before{position:absolute;content:"";width:0;height:0;display:block;border-style:solid;border-color:#fff transparent transparent transparent;top:50%}.dropdown.button:before{border-width:0.5625em;right:1.5em;margin-top:-0.25em}.dropdown.button:before{border-color:#fff transparent transparent transparent}.dropdown.button.tiny{padding-right:2.1875em}.dropdown.button.tiny:before{border-width:0.4375em;right:0.875em;margin-top:-0.15625em}.dropdown.button.tiny:before{border-color:#fff transparent transparent transparent}.dropdown.button.small{padding-right:2.8125em}.dropdown.button.small:before{border-width:0.5625em;right:1.125em;margin-top:-0.21875em}.dropdown.button.small:before{border-color:#fff transparent transparent transparent}.dropdown.button.large{padding-right:4em}.dropdown.button.large:before{border-width:0.625em;right:1.75em;margin-top:-0.3125em}.dropdown.button.large:before{border-color:#fff transparent transparent transparent}.dropdown.button.secondary:before{border-color:#333 transparent transparent transparent}.split.button{position:relative;padding-right:4.8em}.split.button span{display:block;height:100%;position:absolute;right:0;top:0;border-left:solid 1px}.split.button span:before{position:absolute;content:"";width:0;height:0;display:block;border-style:solid;left:50%}.split.button span:active{background-color:rgba(0,0,0,0.1)}.split.button span{border-left-color:#1e728c}.split.button span{width:3em}.split.button span:before{border-width:0.5625em;top:1.125em;margin-left:-0.5625em}.split.button span:before{border-color:#fff transparent transparent transparent}.split.button.secondary span{border-left-color:#c3c3c3}.split.button.secondary span:before{border-color:#fff transparent transparent transparent}.split.button.alert span{border-left-color:#7f0a0c}.split.button.success span{border-left-color:#396516}.split.button.tiny{padding-right:3.9375em}.split.button.tiny span{width:2.84375em}.split.button.tiny span:before{border-width:0.4375em;top:0.875em;margin-left:-0.3125em}.split.button.small{padding-right:3.9375em}.split.button.small span{width:2.8125em}.split.button.small span:before{border-width:0.5625em;top:0.84375em;margin-left:-0.5625em}.split.button.large{padding-right:6em}.split.button.large span{width:3.75em}.split.button.large span:before{border-width:0.625em;top:1.3125em;margin-left:-0.5625em}.split.button.secondary span:before{border-color:#333 transparent transparent transparent}.split.button.radius span{-webkit-border-radius:0;border-radius:0;-moz-border-radius-topright:3px;-moz-border-radius-bottomright:3px;-webkit-border-top-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px}.split.button.round span{-webkit-border-radius:0;border-radius:0;-moz-border-radius-topright:1000px;-moz-border-radius-bottomright:1000px;-webkit-border-top-right-radius:1000px;-webkit-border-bottom-right-radius:1000px;border-top-right-radius:1000px;border-bottom-right-radius:1000px}.flex-video{position:relative;padding-top:1.5625em;padding-bottom:67.5%;height:0;margin-bottom:1em;overflow:hidden}.flex-video.widescreen{padding-bottom:57.25%}.flex-video.vimeo{padding-top:0}.flex-video iframe,.flex-video object,.flex-video embed,.flex-video video{position:absolute;top:0;left:0;width:100%;height:100%}.section-container,.section-container.auto{width:100%;display:block;margin-bottom:1.25em;border:1px solid #ccc;border-top:none}.section-container section,.section-container .section,.section-container.auto section,.section-container.auto .section{border-top:1px solid #ccc;position:relative}.section-container section .title,.section-container .section .title,.section-container.auto section .title,.section-container.auto .section .title{top:0;cursor:pointer;width:100%;margin:0;background-color:#efefef}.section-container section .title a,.section-container .section .title a,.section-container.auto section .title a,.section-container.auto .section .title a{padding:0.9375em;display:inline-block;color:#333;font-size:0.875em;white-space:nowrap;width:100%}.section-container section .title:hover,.section-container .section .title:hover,.section-container.auto section .title:hover,.section-container.auto .section .title:hover{background-color:#e2e2e2}.section-container section .content,.section-container .section .content,.section-container.auto section .content,.section-container.auto .section .content{display:none;padding:0.9375em;background-color:#fff}.section-container section .content>*:last-child,.section-container .section .content>*:last-child,.section-container.auto section .content>*:last-child,.section-container.auto .section .content>*:last-child{margin-bottom:0}.section-container section .content>*:first-child,.section-container .section .content>*:first-child,.section-container.auto section .content>*:first-child,.section-container.auto .section .content>*:first-child{padding-top:0}.section-container section .content>*:last-child,.section-container .section .content>*:last-child,.section-container.auto section .content>*:last-child,.section-container.auto .section .content>*:last-child{padding-bottom:0}.section-container section.active .content,.section-container .section.active .content,.section-container.auto section.active .content,.section-container.auto .section.active .content{display:block}.section-container section.active .title,.section-container .section.active .title,.section-container.auto section.active .title,.section-container.auto .section.active .title{background:#d5d5d5}.section-container.tabs{border:0;position:relative}.section-container.tabs section,.section-container.tabs .section{padding-top:0;border:0;position:static}.section-container.tabs section .title,.section-container.tabs .section .title{width:auto;border:1px solid #ccc;border-right:0;border-bottom:0;position:absolute;z-index:1}.section-container.tabs section .title a,.section-container.tabs .section .title a{width:100%}.section-container.tabs section:last-child .title,.section-container.tabs .section:last-child .title{border-right:1px solid #ccc}.section-container.tabs section .content,.section-container.tabs .section .content{border:1px solid #ccc;position:absolute;z-index:10;top:-1px}.section-container.tabs section.active .title,.section-container.tabs .section.active .title{background-color:#fff;z-index:11;border-bottom:0}.section-container.tabs section.active .content,.section-container.tabs .section.active .content{position:relative}@media only screen and (min-width: 48em){.section-container.auto{border:0;position:relative}.section-container.auto section,.section-container.auto .section{padding-top:0;border:0;position:static}.section-container.auto section .title,.section-container.auto .section .title{width:auto;border:1px solid #ccc;border-right:0;border-bottom:0;position:absolute;z-index:1}.section-container.auto section .title a,.section-container.auto .section .title a{width:100%}.section-container.auto section:last-child .title,.section-container.auto .section:last-child .title{border-right:1px solid #ccc}.section-container.auto section .content,.section-container.auto .section .content{border:1px solid #ccc;position:absolute;z-index:10;top:-1px}.section-container.auto section.active .title,.section-container.auto .section.active .title{background-color:#fff;z-index:11;border-bottom:0}.section-container.auto section.active .content,.section-container.auto .section.active .content{position:relative}.section-container.accordion .section{padding-top:0 !important}.section-container.vertical-nav{border:1px solid #ccc;border-top:none}.section-container.vertical-nav section,.section-container.vertical-nav .section{padding-top:0 !important}.section-container.vertical-nav section .title a,.section-container.vertical-nav .section .title a{display:block;width:100%}.section-container.vertical-nav section .content,.section-container.vertical-nav .section .content{display:none}.section-container.vertical-nav section.active .content,.section-container.vertical-nav .section.active .content{display:block;position:absolute;left:100%;top:-1px;z-index:999;min-width:12.5em;border:1px solid #ccc}.section-container.horizontal-nav{position:relative;background:#efefef;border:1px solid #ccc}.section-container.horizontal-nav section,.section-container.horizontal-nav .section{padding-top:0;border:0;position:static}.section-container.horizontal-nav section .title,.section-container.horizontal-nav .section .title{width:auto;border:1px solid #ccc;border-left:0;top:-1px;position:absolute;z-index:1}.section-container.horizontal-nav section .title a,.section-container.horizontal-nav .section .title a{width:100%}.section-container.horizontal-nav section .content,.section-container.horizontal-nav .section .content{display:none}.section-container.horizontal-nav section.active .content,.section-container.horizontal-nav .section.active .content{display:block;position:absolute;z-index:999;left:0;top:-2px;min-width:12.5em;border:1px solid #ccc}}.contain-to-grid{width:100%;background:#111}.fixed{width:100%;left:0;position:fixed;top:0;z-index:99}.top-bar{overflow:hidden;height:45px;line-height:45px;position:relative;background:#111;margin-bottom:1.875em}.top-bar ul{margin-bottom:0;list-style:none}.top-bar .row{max-width:none}.top-bar form,.top-bar input{margin-bottom:0}.top-bar input{height:2.45em}.top-bar .button{padding-top:.5em;padding-bottom:.5em;margin-bottom:0}.top-bar .title-area{position:relative}.top-bar .name{height:45px;margin:0;font-size:16px}.top-bar .name h1{line-height:45px;font-size:1.0625em;margin:0}.top-bar .name h1 a{font-weight:bold;color:#fff;width:50%;display:block;padding:0 15px}.top-bar .toggle-topbar{position:absolute;right:0;top:0}.top-bar .toggle-topbar a{color:#fff;text-transform:uppercase;font-size:0.8125em;font-weight:bold;position:relative;display:block;padding:0 15px;height:45px;line-height:45px}.top-bar .toggle-topbar.menu-icon{right:15px;top:50%;margin-top:-16px;padding-left:40px}.top-bar .toggle-topbar.menu-icon a{text-indent:-48px;width:34px;height:34px;line-height:33px;padding:0;color:#fff}.top-bar .toggle-topbar.menu-icon a span{position:absolute;right:0;display:block;width:16px;height:0;-webkit-box-shadow:0 10px 0 1px #fff,0 16px 0 1px #fff,0 22px 0 1px #fff;box-shadow:0 10px 0 1px #fff,0 16px 0 1px #fff,0 22px 0 1px #fff}.top-bar.expanded{height:auto;background:transparent}.top-bar.expanded .title-area{background:#111}.top-bar.expanded .toggle-topbar a{color:#888}.top-bar.expanded .toggle-topbar a span{-webkit-box-shadow:0 10px 0 1px #888,0 16px 0 1px #888,0 22px 0 1px #888;box-shadow:0 10px 0 1px #888,0 16px 0 1px #888,0 22px 0 1px #888}.top-bar-section{left:0;position:relative;width:auto;-webkit-transition:left 300ms ease-out;-moz-transition:left 300ms ease-out;transition:left 300ms ease-out}.top-bar-section ul{width:100%;height:auto;display:block;background:#333;font-size:16px;margin:0}.top-bar-section .divider{border-bottom:solid 1px #4d4d4d;border-top:solid 1px #1a1a1a;clear:both;height:1px;width:100%}.top-bar-section ul li>a{display:block;width:100%;color:#fff;padding:12px 0 12px 0;padding-left:15px;font-size:0.8125em;font-weight:bold;background:#333;height:45px}.top-bar-section ul li>a:hover{background:#2b2b2b}.top-bar-section ul li>a.button{background:#2ba6cb;font-size:0.8125em}.top-bar-section ul li>a.button:hover{background:#2284a1}.top-bar-section ul li>a.button.secondary{background:#e9e9e9}.top-bar-section ul li>a.button.secondary:hover{background:#d0d0d0}.top-bar-section ul li>a.button.success{background:#5da423}.top-bar-section ul li>a.button.success:hover{background:#457a1a}.top-bar-section ul li>a.button.alert{background:#c60f13}.top-bar-section ul li>a.button.alert:hover{background:#970b0e}.top-bar-section ul li.active>a{background:#2b2b2b}.top-bar-section .has-form{padding:15px}.top-bar-section .has-dropdown{position:relative}.top-bar-section .has-dropdown>a:after{content:"";display:block;width:0;height:0;border:solid 5px;border-color:transparent transparent transparent rgba(255,255,255,0.5);margin-right:15px;margin-top:-4.5px;position:absolute;top:22px;right:0}.top-bar-section .has-dropdown.moved{position:static}.top-bar-section .has-dropdown.moved>.dropdown{visibility:visible}.top-bar-section .dropdown{position:absolute;left:100%;top:0;visibility:hidden;z-index:99}.top-bar-section .dropdown li{width:100%}.top-bar-section .dropdown li a{font-weight:normal;padding:8px 15px}.top-bar-section .dropdown li.title h5{margin-bottom:0}.top-bar-section .dropdown li.title h5 a{color:#fff;line-height:22.5px;display:block}.top-bar-section .dropdown label{padding:8px 15px 2px;margin-bottom:0;text-transform:uppercase;color:#555;font-weight:bold;font-size:0.625em}.top-bar-js-breakpoint{width:58.75em !important;visibility:hidden}.js-generated{display:block}@media only screen and (min-width: 58.75em){.top-bar{background:#111;*zoom:1;overflow:visible}.top-bar:before,.top-bar:after{content:" ";display:table}.top-bar:after{clear:both}.top-bar .toggle-topbar{display:none}.top-bar .title-area{float:left}.top-bar .name h1 a{width:auto}.top-bar input,.top-bar .button{line-height:2em;font-size:0.875em;height:2em;padding:0 10px;position:relative;top:8px}.top-bar.expanded{background:#111}.contain-to-grid .top-bar{max-width:62.5em;margin:0 auto}.top-bar-section{-webkit-transition:none 0 0;-moz-transition:none 0 0;transition:none 0 0;left:0 !important}.top-bar-section ul{width:auto;height:auto !important;display:inline}.top-bar-section ul li{float:left}.top-bar-section ul li .js-generated{display:none}.top-bar-section li a:not(.button){padding:0 15px;line-height:45px;background:#111}.top-bar-section li a:not(.button):hover{background:#000}.top-bar-section .has-dropdown>a{padding-right:35px !important}.top-bar-section .has-dropdown>a:after{content:"";display:block;width:0;height:0;border:solid 5px;border-color:rgba(255,255,255,0.5) transparent transparent transparent;margin-top:-2.5px}.top-bar-section .has-dropdown.moved{position:relative}.top-bar-section .has-dropdown.moved>.dropdown{visibility:hidden}.top-bar-section .has-dropdown:hover>.dropdown,.top-bar-section .has-dropdown:active>.dropdown{visibility:visible}.top-bar-section .has-dropdown .dropdown li.has-dropdown>a:after{border:none;content:"\00bb";margin-top:-7px;right:5px}.top-bar-section .dropdown{left:0;top:auto;background:transparent;min-width:100%}.top-bar-section .dropdown li a{color:#fff;line-height:1;white-space:nowrap;padding:7px 15px;background:#1e1e1e}.top-bar-section .dropdown li label{white-space:nowrap;background:#1e1e1e}.top-bar-section .dropdown li .dropdown{left:100%;top:0}.top-bar-section>ul>.divider{border-bottom:none;border-top:none;border-right:solid 1px #2b2b2b;border-left:solid 1px #000;clear:none;height:45px;width:0px}.top-bar-section .has-form{background:#111;padding:0 15px;height:45px}.top-bar-section ul.right li .dropdown{left:auto;right:0}.top-bar-section ul.right li .dropdown li .dropdown{right:100%}}.orbit-container{overflow:hidden;width:100%;position:relative;background:#f5f5f5}.orbit-container .orbit-slides-container{list-style:none;margin:0;padding:0;position:relative}.orbit-container .orbit-slides-container img{display:block}.orbit-container .orbit-slides-container>*{position:relative;float:left;height:100%}.orbit-container .orbit-slides-container>* .orbit-caption{position:absolute;bottom:0;background-color:#000;background-color:rgba(0,0,0,0.6);color:#fff;width:100%;padding:10px 14px;font-size:0.875em}.orbit-container .orbit-slides-container>* .orbit-caption *{color:#fff}.orbit-container .orbit-slide-number{position:absolute;top:10px;left:10px;font-size:12px}.orbit-container .orbit-slide-number span{font-weight:700}.orbit-container .orbit-timer{position:absolute;top:10px;right:10px;height:6px;width:100px}.orbit-container .orbit-timer .orbit-progress{height:100%;background-color:#000;background-color:rgba(0,0,0,0.6);display:block;width:0%}.orbit-container .orbit-timer>span{display:none;position:absolute;top:10px;right:0px;width:11px;height:14px;border:solid 4px #000;border-top:none;border-bottom:none}.orbit-container .orbit-timer.paused>span{right:-6px;top:9px;width:11px;height:14px;border:solid 8px;border-color:transparent transparent transparent #000}.orbit-container:hover .orbit-timer>span{display:block}.orbit-container .orbit-prev,.orbit-container .orbit-next{position:absolute;top:50%;margin-top:-25px;background-color:#000;background-color:rgba(0,0,0,0.6);width:50px;height:60px;line-height:50px;color:white;text-indent:-9999px !important}.orbit-container .orbit-prev>span,.orbit-container .orbit-next>span{position:absolute;top:50%;margin-top:-16px;display:block;width:0;height:0;border:solid 16px}.orbit-container .orbit-prev{left:0}.orbit-container .orbit-prev>span{border-color:transparent;border-right-color:#fff}.orbit-container .orbit-prev:hover>span{border-right-color:#ccc}.orbit-container .orbit-next{right:0}.orbit-container .orbit-next>span{border-color:transparent;border-left-color:#fff;left:50%;margin-left:-8px}.orbit-container .orbit-next:hover>span{border-left-color:#ccc}.orbit-bullets{margin:0 auto 30px auto;overflow:hidden;position:relative;top:10px}.orbit-bullets li{display:block;width:18px;height:18px;background:#fff;float:left;margin-right:6px;border:solid 2px #000;-webkit-border-radius:1000px;border-radius:1000px}.orbit-bullets li.active{background:#000}.orbit-bullets li:last-child{margin-right:0}.touch .orbit-container .orbit-prev,.touch .orbit-container .orbit-next{display:none}.touch .orbit-bullets{display:none}@media only screen and (min-width: 48em){.touch .orbit-container .orbit-prev,.touch .orbit-container .orbit-next{display:inherit}.touch .orbit-bullets{display:block}}.reveal-modal-bg{position:fixed;height:100%;width:100%;background:#000;background:rgba(0,0,0,0.45);z-index:98;display:none;top:0;left:0}.reveal-modal{visibility:hidden;display:none;position:absolute;left:50%;z-index:99;height:auto;background-color:#fff;margin-left:-40%;width:80%;background-color:#fff;padding:1.25em;border:solid 1px #666;-webkit-box-shadow:0 0 10px rgba(0,0,0,0.4);box-shadow:0 0 10px rgba(0,0,0,0.4);top:50px}.reveal-modal .column,.reveal-modal .columns{min-width:0}.reveal-modal>:first-child{margin-top:0}.reveal-modal>:last-child{margin-bottom:0}.reveal-modal .close-reveal-modal{font-size:1.375em;line-height:1;position:absolute;top:0.5em;right:0.6875em;color:#aaa;font-weight:bold;cursor:pointer}@media only screen and (min-width: 48em){.reveal-modal{padding:1.875em;top:6.25em}.reveal-modal.small{margin-left:-15%;width:30%}.reveal-modal.medium{margin-left:-20%;width:40%}.reveal-modal.large{margin-left:-30%;width:60%}.reveal-modal.xlarge{margin-left:-35%;width:70%}.reveal-modal.expand{margin-left:-47.5%;width:95%}}@media print{div:not(.reveal-modal){display:none}}.joyride-list{display:none}.joyride-tip-guide{display:none;position:absolute;background:#000;color:#fff;z-index:101;top:0;left:2.5%;font-family:inherit;font-weight:normal;width:95%}.lt-ie9 .joyride-tip-guide{max-width:800px;left:50%;margin-left:-400px}.joyride-content-wrapper{width:100%;padding:1.125em 1.25em 1.5em}.joyride-content-wrapper .button{margin-bottom:0 !important}.joyride-tip-guide .joyride-nub{display:block;position:absolute;left:22px;width:0;height:0;border:solid 14px}.joyride-tip-guide .joyride-nub.top{border-color:#000;border-top-color:transparent !important;border-left-color:transparent !important;border-right-color:transparent !important;top:-28px;bottom:none}.joyride-tip-guide .joyride-nub.bottom{border-color:#000 !important;border-bottom-color:transparent !important;border-left-color:transparent !important;border-right-color:transparent !important;bottom:-28px;bottom:none}.joyride-tip-guide .joyride-nub.right{right:-28px}.joyride-tip-guide .joyride-nub.left{left:-28px}.joyride-tip-guide h1,.joyride-tip-guide h2,.joyride-tip-guide h3,.joyride-tip-guide h4,.joyride-tip-guide h5,.joyride-tip-guide h6{line-height:1.25;margin:0;font-weight:bold;color:#fff}.joyride-tip-guide p{margin:0 0 1.125em 0;font-size:0.875em;line-height:1.3}.joyride-timer-indicator-wrap{width:50px;height:3px;border:solid 1px #555;position:absolute;right:1.0625em;bottom:1em}.joyride-timer-indicator{display:block;width:0;height:inherit;background:#666}.joyride-close-tip{position:absolute;right:12px;top:10px;color:#777 !important;text-decoration:none;font-size:30px;font-weight:normal;line-height:0.5 !important}.joyride-close-tip:hover,.joyride-close-tip:focus{color:#eee !important}.joyride-modal-bg{position:fixed;height:100%;width:100%;background:transparent;background:rgba(0,0,0,0.5);z-index:100;display:none;top:0;left:0;cursor:pointer}.joyride-expose-wrapper{background-color:#ffffff;position:absolute;border-radius:3px;z-index:102;-moz-box-shadow:0px 0px 30px #fff;-webkit-box-shadow:0px 0px 15px #fff;box-shadow:0px 0px 15px #fff}.joyride-expose-cover{background:transparent;border-radius:3px;position:absolute;z-index:9999;top:0px;left:0px}@media only screen and (min-width: 48em){.joyride-tip-guide{width:300px;left:inherit}.joyride-tip-guide .joyride-nub.bottom{border-color:#000 !important;border-bottom-color:transparent !important;border-left-color:transparent !important;border-right-color:transparent !important;bottom:-28px;bottom:none}.joyride-tip-guide .joyride-nub.right{border-color:#000 !important;border-top-color:transparent !important;border-right-color:transparent !important;border-bottom-color:transparent !important;top:22px;bottom:none;left:auto;right:-28px}.joyride-tip-guide .joyride-nub.left{border-color:#000 !important;border-top-color:transparent !important;border-left-color:transparent !important;border-bottom-color:transparent !important;top:22px;left:-28px;right:auto;bottom:none}}[data-clearing]{*zoom:1;margin-bottom:0}[data-clearing]:before,[data-clearing]:after{content:" ";display:table}[data-clearing]:after{clear:both}.clearing-blackout{background:#111;position:fixed;width:100%;height:100%;top:0;left:0;z-index:998}.clearing-blackout .clearing-close{display:block}.clearing-container{position:relative;z-index:998;height:100%;overflow:hidden;margin:0}.visible-img{height:95%;position:relative}.visible-img img{position:absolute;left:50%;top:50%;margin-left:-50%;max-height:100%;max-width:100%}.clearing-caption{color:#fff;line-height:1.3;margin-bottom:0;text-align:center;bottom:0;background:#111;width:100%;padding:10px 30px;position:absolute;left:0}.clearing-close{z-index:999;padding-left:20px;padding-top:10px;font-size:40px;line-height:1;color:#fff;display:none}.clearing-close:hover,.clearing-close:focus{color:#ccc}.clearing-assembled .clearing-container{height:100%}.clearing-assembled .clearing-container .carousel>ul{display:none}@media only screen and (min-width: 48em){.clearing-main-prev,.clearing-main-next{position:absolute;height:100%;width:40px;top:0}.clearing-main-prev>span,.clearing-main-next>span{position:absolute;top:50%;display:block;width:0;height:0;border:solid 16px}.clearing-main-prev{left:0}.clearing-main-prev>span{left:5px;border-color:transparent;border-right-color:#fff}.clearing-main-next{right:0}.clearing-main-next>span{border-color:transparent;border-left-color:#fff}.clearing-main-prev.disabled,.clearing-main-next.disabled{opacity:0.5}.clearing-feature ~ li{display:none}.clearing-assembled .clearing-container .carousel{background:#111;height:150px;margin-top:5px}.clearing-assembled .clearing-container .carousel>ul{display:block;z-index:999;width:200%;height:100%;margin-left:0;position:relative;left:0}.clearing-assembled .clearing-container .carousel>ul li{display:block;width:175px;height:inherit;padding:0;float:left;overflow:hidden;margin-right:1px;position:relative;cursor:pointer;opacity:0.4}.clearing-assembled .clearing-container .carousel>ul li.fix-height img{min-height:100%;height:100%;max-width:none}.clearing-assembled .clearing-container .carousel>ul li a.th{border:none;-webkit-box-shadow:none;box-shadow:none;display:block}.clearing-assembled .clearing-container .carousel>ul li img{cursor:pointer !important;min-width:100% !important}.clearing-assembled .clearing-container .carousel>ul li.visible{opacity:1}.clearing-assembled .clearing-container .visible-img{background:#111;overflow:hidden;height:75%}.clearing-close{position:absolute;top:10px;right:20px;padding-left:0;padding-top:0}}.alert-box{border-style:solid;border-width:1px;display:block;font-weight:bold;margin-bottom:1.25em;position:relative;padding:0.6875em 1.3125em 0.75em 0.6875em;font-size:0.875em;background-color:#2ba6cb;border-color:#2284a1;color:#fff}.alert-box .close{font-size:1.375em;padding:5px 4px 4px;line-height:0;position:absolute;top:0.4375em;right:0.3125em;color:#333;opacity:0.3}.alert-box .close:hover,.alert-box .close:focus{opacity:0.5}.alert-box.radius{-webkit-border-radius:3px;border-radius:3px}.alert-box.round{-webkit-border-radius:1000px;border-radius:1000px}.alert-box.success{background-color:#5da423;border-color:#457a1a;color:#fff}.alert-box.alert{background-color:#c60f13;border-color:#970b0e;color:#fff}.alert-box.secondary{background-color:#e9e9e9;border-color:#d0d0d0;color:#505050}.breadcrumbs{display:block;padding:0.375em 0.875em 0.5625em;overflow:hidden;margin-left:0;list-style:none;border-style:solid;border-width:1px;background-color:#f6f6f6;border-color:#dcdcdc;-webkit-border-radius:3px;border-radius:3px}.breadcrumbs li{margin:0;padding:0 0.75em 0 0;float:left}.breadcrumbs li:hover a,.breadcrumbs li:focus a{text-decoration:underline}.breadcrumbs li a,.breadcrumbs li span{font-size:0.6875em;padding-left:0.75em;text-transform:uppercase;color:#2ba6cb}.breadcrumbs li.current a{cursor:default;color:#333}.breadcrumbs li.current:hover a,.breadcrumbs li.current:focus a{text-decoration:none}.breadcrumbs li.unavailable a{color:#999}.breadcrumbs li.unavailable:hover a,.breadcrumbs li.unavailable a:focus{text-decoration:none;color:#999;cursor:default}.breadcrumbs li:before{content:"/";color:#aaa;position:relative;top:1px}.breadcrumbs li:first-child a,.breadcrumbs li:first-child span{padding-left:0}.breadcrumbs li:first-child:before{content:" "}.keystroke,kbd{background-color:#ededed;border-color:#dbdbdb;color:#222;border-style:solid;border-width:1px;margin:0;font-family:"Consolas","Menlo","Courier",monospace;font-size:0.9375em;padding:0.125em 0.25em 0em;-webkit-border-radius:3px;border-radius:3px}.label{font-weight:500;text-align:center;text-decoration:none;line-height:1;white-space:nowrap;display:inline-block;position:relative;padding:0.1875em 0.625em 0.25em;font-size:0.875em;background-color:#2ba6cb;color:#fff}.label.radius{-webkit-border-radius:3px;border-radius:3px}.label.round{-webkit-border-radius:1000px;border-radius:1000px}.label.alert{background-color:#c60f13;color:#fff}.label.success{background-color:#5da423;color:#fff}.label.secondary{background-color:#e9e9e9;color:#333}.inline-list{margin:0 auto 1.0625em auto;margin-left:-1.375em;margin-right:0;padding:0;list-style:none;overflow:hidden}.inline-list>li{list-style:none;float:left;margin-left:1.375em;display:block}.inline-list>li>*{display:block}.pagination{display:block;height:1.5em;margin-left:-0.3125em}.pagination li{display:block;float:left;height:1.5em;color:#222;font-size:0.875em;margin-left:0.3125em}.pagination li a{display:block;padding:0.0625em 0.4375em 0.0625em;color:#999}.pagination li:hover a,.pagination li a:focus{background:#e6e6e6}.pagination li.unavailable a{cursor:default;color:#999}.pagination li.unavailable:hover a,.pagination li.unavailable a:focus{background:transparent}.pagination li.current a{background:#2ba6cb;color:#fff;font-weight:bold;cursor:default}.pagination li.current a:hover,.pagination li.current a:focus{background:#2ba6cb}.pagination-centered{text-align:center}.pagination-centered ul>li{float:none;display:inline-block}.panel{border-style:solid;border-width:1px;border-color:#d9d9d9;margin-bottom:1.25em;padding:1.25em;background:#f2f2f2}.panel h1,.panel h2,.panel h3,.panel h4,.panel h5,.panel h6,.panel p{color:#333}.panel>:first-child{margin-top:0}.panel>:last-child{margin-bottom:0}.panel h1,.panel h2,.panel h3,.panel h4,.panel h5,.panel h6{line-height:1;margin-bottom:0.625em}.panel h1.subheader,.panel h2.subheader,.panel h3.subheader,.panel h4.subheader,.panel h5.subheader,.panel h6.subheader{line-height:1.4}.panel.callout{border-style:solid;border-width:1px;border-color:#2284a1;margin-bottom:1.25em;padding:1.25em;background:#2ba6cb;-webkit-box-shadow:0 1px 0 rgba(255,255,255,0.5) inset;box-shadow:0 1px 0 rgba(255,255,255,0.5) inset}.panel.callout h1,.panel.callout h2,.panel.callout h3,.panel.callout h4,.panel.callout h5,.panel.callout h6,.panel.callout p{color:#fff}.panel.callout>:first-child{margin-top:0}.panel.callout>:last-child{margin-bottom:0}.panel.callout h1,.panel.callout h2,.panel.callout h3,.panel.callout h4,.panel.callout h5,.panel.callout h6{line-height:1;margin-bottom:0.625em}.panel.callout h1.subheader,.panel.callout h2.subheader,.panel.callout h3.subheader,.panel.callout h4.subheader,.panel.callout h5.subheader,.panel.callout h6.subheader{line-height:1.4}.panel.radius{-webkit-border-radius:3px;border-radius:3px}.pricing-table{border:solid 1px #ddd;margin-left:0;margin-bottom:1.25em}.pricing-table *{list-style:none;line-height:1}.pricing-table .title{background-color:#ddd;padding:0.9375em 1.25em;text-align:center;color:#333;font-weight:bold;font-size:1em}.pricing-table .price{background-color:#eee;padding:0.9375em 1.25em;text-align:center;color:#333;font-weight:normal;font-size:1.25em}.pricing-table .description{background-color:#fff;padding:0.9375em;text-align:center;color:#777;font-size:0.75em;font-weight:normal;line-height:1.4;border-bottom:dotted 1px #ddd}.pricing-table .bullet-item{background-color:#fff;padding:0.9375em;text-align:center;color:#333;font-size:0.875em;font-weight:normal;border-bottom:dotted 1px #ddd}.pricing-table .cta-button{background-color:#f5f5f5;text-align:center;padding:1.25em 1.25em 0}.progress{background-color:transparent;height:1.5625em;border:1px solid #ccc;padding:0.125em;margin-bottom:0.625em}.progress .meter{background:#2ba6cb;height:100%;display:block}.progress.secondary .meter{background:#e9e9e9;height:100%;display:block}.progress.success .meter{background:#5da423;height:100%;display:block}.progress.alert .meter{background:#c60f13;height:100%;display:block}.progress.radius{-webkit-border-radius:3px;border-radius:3px}.progress.radius .meter{-webkit-border-radius:2px;border-radius:2px}.progress.round{-webkit-border-radius:1000px;border-radius:1000px}.progress.round .meter{-webkit-border-radius:999px;border-radius:999px}.side-nav{display:block;margin:0;padding:0.875em 0;list-style-type:none;list-style-position:inside}.side-nav li{margin:0 0 0.4375em 0;font-size:0.875em}.side-nav li a{display:block;color:#2ba6cb}.side-nav li.active a{color:#4d4d4d;font-weight:bold}.side-nav li.divider{border-top:1px solid;height:0;padding:0;list-style:none;border-top-color:#e6e6e6}.sub-nav{display:block;width:auto;overflow:hidden;margin:-0.25em 0 1.125em;padding-top:0.25em;margin-right:0;margin-left:-0.5625em}.sub-nav dt,.sub-nav dd{float:left;display:inline;margin-left:0.5625em;margin-bottom:0.625em;font-weight:normal;font-size:0.875em}.sub-nav dt a,.sub-nav dd a{color:#999;text-decoration:none}.sub-nav dt.active a,.sub-nav dd.active a{-webkit-border-radius:1000px;border-radius:1000px;font-weight:bold;background:#2ba6cb;padding:0.1875em 0.5625em;cursor:default;color:#fff}@media only screen{div.switch{position:relative;width:100%;padding:0;display:block;overflow:hidden;border-style:solid;border-width:1px;margin-bottom:1.25em;-webkit-animation:webkitSiblingBugfix infinite 1s;height:36px;background:#fff;border-color:#ccc}div.switch label{position:relative;left:0;z-index:2;float:left;width:50%;height:100%;margin:0;font-weight:bold;text-align:left;-webkit-transition:all 0.1s ease-out;-moz-transition:all 0.1s ease-out;transition:all 0.1s ease-out}div.switch input{position:absolute;z-index:3;opacity:0;width:100%;height:100%}div.switch input:hover,div.switch input:focus{cursor:pointer}div.switch>span{position:absolute;top:-1px;left:-1px;z-index:1;display:block;padding:0;border-width:1px;border-style:solid;-webkit-transition:all 0.1s ease-out;-moz-transition:all 0.1s ease-out;transition:all 0.1s ease-out}div.switch input:not(:checked)+label{opacity:0}div.switch input:checked{display:none !important}div.switch input{left:0;display:block !important}div.switch input:first-of-type+label,div.switch input:first-of-type+span+label{left:-50%}div.switch input:first-of-type:checked+label,div.switch input:first-of-type:checked+span+label{left:0%}div.switch input:last-of-type+label,div.switch input:last-of-type+span+label{right:-50%;left:auto;text-align:right}div.switch input:last-of-type:checked+label,div.switch input:last-of-type:checked+span+label{right:0%;left:auto}div.switch span.custom{display:none !important}div.switch label{padding:0 0.375em;line-height:2.3em;font-size:0.875em}div.switch input:first-of-type:checked ~ span{left:100%;margin-left:-2.1875em}div.switch>span{width:2.25em;height:2.25em}div.switch>span{border-color:#b3b3b3;background:#fff;background:-moz-linear-gradient(top, #fff 0%, #f2f2f2 100%);background:-webkit-linear-gradient(top, #fff 0%, #f2f2f2 100%);background:linear-gradient(to bottom, #fff 0%, #f2f2f2 100%);-webkit-box-shadow:2px 0 10px 0 rgba(0,0,0,0.07),1000px 0 0 1000px #e1f5d1,-2px 0 10px 0 rgba(0,0,0,0.07),-1000px 0 0 1000px #f5f5f5;box-shadow:2px 0 10px 0 rgba(0,0,0,0.07),1000px 0 0 980px #e1f5d1,-2px 0 10px 0 rgba(0,0,0,0.07),-1000px 0 0 1000px #f5f5f5}div.switch:hover>span,div.switch:focus>span{background:#fff;background:-moz-linear-gradient(top, #fff 0%, #e6e6e6 100%);background:-webkit-linear-gradient(top, #fff 0%, #e6e6e6 100%);background:linear-gradient(to bottom, #fff 0%, #e6e6e6 100%)}div.switch:active{background:transparent}div.switch.large{height:44px}div.switch.large label{padding:0 0.375em;line-height:2.3em;font-size:1.0625em}div.switch.large input:first-of-type:checked ~ span{left:100%;margin-left:-2.6875em}div.switch.large>span{width:2.75em;height:2.75em}div.switch.small{height:28px}div.switch.small label{padding:0 0.375em;line-height:2.1em;font-size:0.75em}div.switch.small input:first-of-type:checked ~ span{left:100%;margin-left:-1.6875em}div.switch.small>span{width:1.75em;height:1.75em}div.switch.tiny{height:22px}div.switch.tiny label{padding:0 0.375em;line-height:1.9em;font-size:0.6875em}div.switch.tiny input:first-of-type:checked ~ span{left:100%;margin-left:-1.3125em}div.switch.tiny>span{width:1.375em;height:1.375em}div.switch.radius{-webkit-border-radius:4px;border-radius:4px}div.switch.radius>span{-webkit-border-radius:3px;border-radius:3px}div.switch.round{-webkit-border-radius:1000px;border-radius:1000px}div.switch.round>span{-webkit-border-radius:999px;border-radius:999px}div.switch.round label{padding:0 0.5625em}@-webkit-keyframes webkitSiblingBugfix{from{position:relative}to{position:relative}}}[data-magellan-expedition]{background:#fff;z-index:50;min-width:100%;padding:10px}[data-magellan-expedition] .sub-nav{margin-bottom:0}[data-magellan-expedition] .sub-nav dd{margin-bottom:0}table{background:#fff;margin-bottom:1.25em;border:solid 1px #ddd}table thead,table tfoot{background:#f5f5f5;font-weight:bold}table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:0.5em 0.625em 0.625em;font-size:0.875em;color:#222;text-align:left}table tr th,table tr td{padding:0.5625em 0.625em;font-size:0.875em;color:#222}table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f9f9f9}table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.125em}.th{display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px rgba(0,0,0,0.2);box-shadow:0 0 0 1px rgba(0,0,0,0.2);-webkit-transition:all 200ms ease-out;-moz-transition:all 200ms ease-out;transition:all 200ms ease-out}.th:hover,.th:focus{-webkit-box-shadow:0 0 6px 1px rgba(43,166,203,0.5);box-shadow:0 0 6px 1px rgba(43,166,203,0.5)}.th.radius{-webkit-border-radius:3px;border-radius:3px}.has-tip{border-bottom:dotted 1px #ccc;cursor:help;font-weight:bold;color:#333}.has-tip:hover,.has-tip:focus{border-bottom:dotted 1px #196177;color:#2ba6cb}.has-tip.tip-left,.has-tip.tip-right{float:none !important}.tooltip{display:none;position:absolute;z-index:999;font-weight:bold;font-size:0.9375em;line-height:1.3;padding:0.5em;max-width:85%;left:50%;width:100%;color:#fff;background:#000;-webkit-border-radius:3px;border-radius:3px}.tooltip>.nub{display:block;left:5px;position:absolute;width:0;height:0;border:solid 5px;border-color:transparent transparent #000 transparent;top:-10px}.tooltip.opened{color:#2ba6cb !important;border-bottom:dotted 1px #196177 !important}.tap-to-close{display:block;font-size:0.625em;color:#888;font-weight:normal}@media only screen and (min-width: 48em){.tooltip>.nub{border-color:transparent transparent #000 transparent;top:-10px}.tooltip.tip-top>.nub{border-color:#000 transparent transparent transparent;top:auto;bottom:-10px}.tooltip.tip-left,.tooltip.tip-right{float:none !important}.tooltip.tip-left>.nub{border-color:transparent transparent transparent #000;right:-10px;left:auto;top:50%;margin-top:-5px}.tooltip.tip-right>.nub{border-color:transparent #000 transparent transparent;right:auto;left:-10px;top:50%;margin-top:-5px}}@media only screen and (max-width: 767px){.f-dropdown{max-width:100%;left:0}}.f-dropdown{position:absolute;top:-9999px;list-style:none;padding:1.25em;width:100%;height:auto;max-height:none;background:#fff;border:solid 1px #ccc;font-size:16px;z-index:99;margin-top:2px;max-width:200px}.f-dropdown *:first-child{margin-top:0}.f-dropdown *:last-child{margin-bottom:0}.f-dropdown:before{content:"";display:block;width:0;height:0;border:solid 6px;border-color:transparent transparent #fff transparent;position:absolute;top:-12px;left:10px;z-index:99}.f-dropdown:after{content:"";display:block;width:0;height:0;border:solid 7px;border-color:transparent transparent #ccc transparent;position:absolute;top:-14px;left:9px;z-index:98}.f-dropdown.right:before{left:auto;right:10px}.f-dropdown.right:after{left:auto;right:9px}.f-dropdown li{font-size:0.875em;cursor:pointer;padding:0.3125em 0.625em;line-height:1.125em;margin:0}.f-dropdown li:hover,.f-dropdown li:focus{background:#eee}.f-dropdown li a{color:#555}.f-dropdown.content{position:absolute;top:-9999px;list-style:none;padding:1.25em;width:100%;height:auto;max-height:none;background:#fff;border:solid 1px #ccc;font-size:16px;z-index:99;max-width:200px}.f-dropdown.content *:first-child{margin-top:0}.f-dropdown.content *:last-child{margin-bottom:0}.f-dropdown.tiny{max-width:200px}.f-dropdown.small{max-width:300px}.f-dropdown.medium{max-width:500px}.f-dropdown.large{max-width:800px} 2 | -------------------------------------------------------------------------------- /vendor/css/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v2.1.0 | MIT License | git.io/normalize */ 2 | 3 | /* ========================================================================== 4 | HTML5 display definitions 5 | ========================================================================== */ 6 | 7 | /** 8 | * Correct `block` display not defined in IE 8/9. 9 | */ 10 | 11 | article, 12 | aside, 13 | details, 14 | figcaption, 15 | figure, 16 | footer, 17 | header, 18 | hgroup, 19 | main, 20 | nav, 21 | section, 22 | summary { 23 | display: block; 24 | } 25 | 26 | /** 27 | * Correct `inline-block` display not defined in IE 8/9. 28 | */ 29 | 30 | audio, 31 | canvas, 32 | video { 33 | display: inline-block; 34 | } 35 | 36 | /** 37 | * Prevent modern browsers from displaying `audio` without controls. 38 | * Remove excess height in iOS 5 devices. 39 | */ 40 | 41 | audio:not([controls]) { 42 | display: none; 43 | height: 0; 44 | } 45 | 46 | /** 47 | * Address styling not present in IE 8/9. 48 | */ 49 | 50 | [hidden] { 51 | display: none; 52 | } 53 | 54 | /* ========================================================================== 55 | Base 56 | ========================================================================== */ 57 | 58 | /** 59 | * 1. Set default font family to sans-serif. 60 | * 2. Prevent iOS text size adjust after orientation change, without disabling 61 | * user zoom. 62 | */ 63 | 64 | html { 65 | font-family: sans-serif; /* 1 */ 66 | -webkit-text-size-adjust: 100%; /* 2 */ 67 | -ms-text-size-adjust: 100%; /* 2 */ 68 | } 69 | 70 | /** 71 | * Remove default margin. 72 | */ 73 | 74 | body { 75 | margin: 0; 76 | } 77 | 78 | /* ========================================================================== 79 | Links 80 | ========================================================================== */ 81 | 82 | /** 83 | * Address `outline` inconsistency between Chrome and other browsers. 84 | */ 85 | 86 | a:focus { 87 | outline: thin dotted; 88 | } 89 | 90 | /** 91 | * Improve readability when focused and also mouse hovered in all browsers. 92 | */ 93 | 94 | a:active, 95 | a:hover { 96 | outline: 0; 97 | } 98 | 99 | /* ========================================================================== 100 | Typography 101 | ========================================================================== */ 102 | 103 | /** 104 | * Address variable `h1` font-size and margin within `section` and `article` 105 | * contexts in Firefox 4+, Safari 5, and Chrome. 106 | */ 107 | 108 | h1 { 109 | font-size: 2em; 110 | margin: 0.67em 0; 111 | } 112 | 113 | /** 114 | * Address styling not present in IE 8/9, Safari 5, and Chrome. 115 | */ 116 | 117 | abbr[title] { 118 | border-bottom: 1px dotted; 119 | } 120 | 121 | /** 122 | * Address style set to `bolder` in Firefox 4+, Safari 5, and Chrome. 123 | */ 124 | 125 | b, 126 | strong { 127 | font-weight: bold; 128 | } 129 | 130 | /** 131 | * Address styling not present in Safari 5 and Chrome. 132 | */ 133 | 134 | dfn { 135 | font-style: italic; 136 | } 137 | 138 | /** 139 | * Address differences between Firefox and other browsers. 140 | */ 141 | 142 | hr { 143 | -moz-box-sizing: content-box; 144 | box-sizing: content-box; 145 | height: 0; 146 | } 147 | 148 | /** 149 | * Address styling not present in IE 8/9. 150 | */ 151 | 152 | mark { 153 | background: #ff0; 154 | color: #000; 155 | } 156 | 157 | /** 158 | * Correct font family set oddly in Safari 5 and Chrome. 159 | */ 160 | 161 | code, 162 | kbd, 163 | pre, 164 | samp { 165 | font-family: monospace, serif; 166 | font-size: 1em; 167 | } 168 | 169 | /** 170 | * Improve readability of pre-formatted text in all browsers. 171 | */ 172 | 173 | pre { 174 | white-space: pre-wrap; 175 | } 176 | 177 | /** 178 | * Set consistent quote types. 179 | */ 180 | 181 | q { 182 | quotes: "\201C" "\201D" "\2018" "\2019"; 183 | } 184 | 185 | /** 186 | * Address inconsistent and variable font size in all browsers. 187 | */ 188 | 189 | small { 190 | font-size: 80%; 191 | } 192 | 193 | /** 194 | * Prevent `sub` and `sup` affecting `line-height` in all browsers. 195 | */ 196 | 197 | sub, 198 | sup { 199 | font-size: 75%; 200 | line-height: 0; 201 | position: relative; 202 | vertical-align: baseline; 203 | } 204 | 205 | sup { 206 | top: -0.5em; 207 | } 208 | 209 | sub { 210 | bottom: -0.25em; 211 | } 212 | 213 | /* ========================================================================== 214 | Embedded content 215 | ========================================================================== */ 216 | 217 | /** 218 | * Remove border when inside `a` element in IE 8/9. 219 | */ 220 | 221 | img { 222 | border: 0; 223 | } 224 | 225 | /** 226 | * Correct overflow displayed oddly in IE 9. 227 | */ 228 | 229 | svg:not(:root) { 230 | overflow: hidden; 231 | } 232 | 233 | /* ========================================================================== 234 | Figures 235 | ========================================================================== */ 236 | 237 | /** 238 | * Address margin not present in IE 8/9 and Safari 5. 239 | */ 240 | 241 | figure { 242 | margin: 0; 243 | } 244 | 245 | /* ========================================================================== 246 | Forms 247 | ========================================================================== */ 248 | 249 | /** 250 | * Define consistent border, margin, and padding. 251 | */ 252 | 253 | fieldset { 254 | border: 1px solid #c0c0c0; 255 | margin: 0 2px; 256 | padding: 0.35em 0.625em 0.75em; 257 | } 258 | 259 | /** 260 | * 1. Correct `color` not being inherited in IE 8/9. 261 | * 2. Remove padding so people aren't caught out if they zero out fieldsets. 262 | */ 263 | 264 | legend { 265 | border: 0; /* 1 */ 266 | padding: 0; /* 2 */ 267 | } 268 | 269 | /** 270 | * 1. Correct font family not being inherited in all browsers. 271 | * 2. Correct font size not being inherited in all browsers. 272 | * 3. Address margins set differently in Firefox 4+, Safari 5, and Chrome. 273 | */ 274 | 275 | button, 276 | input, 277 | select, 278 | textarea { 279 | font-family: inherit; /* 1 */ 280 | font-size: 100%; /* 2 */ 281 | margin: 0; /* 3 */ 282 | } 283 | 284 | /** 285 | * Address Firefox 4+ setting `line-height` on `input` using `!important` in 286 | * the UA stylesheet. 287 | */ 288 | 289 | button, 290 | input { 291 | line-height: normal; 292 | } 293 | 294 | /** 295 | * Address inconsistent `text-transform` inheritance for `button` and `select`. 296 | * All other form control elements do not inherit `text-transform` values. 297 | * Correct `button` style inheritance in Chrome, Safari 5+, and IE 8+. 298 | * Correct `select` style inheritance in Firefox 4+ and Opera. 299 | */ 300 | 301 | button, 302 | select { 303 | text-transform: none; 304 | } 305 | 306 | /** 307 | * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` 308 | * and `video` controls. 309 | * 2. Correct inability to style clickable `input` types in iOS. 310 | * 3. Improve usability and consistency of cursor style between image-type 311 | * `input` and others. 312 | */ 313 | 314 | button, 315 | html input[type="button"], /* 1 */ 316 | input[type="reset"], 317 | input[type="submit"] { 318 | -webkit-appearance: button; /* 2 */ 319 | cursor: pointer; /* 3 */ 320 | } 321 | 322 | /** 323 | * Re-set default cursor for disabled elements. 324 | */ 325 | 326 | button[disabled], 327 | html input[disabled] { 328 | cursor: default; 329 | } 330 | 331 | /** 332 | * 1. Address box sizing set to `content-box` in IE 8/9. 333 | * 2. Remove excess padding in IE 8/9. 334 | */ 335 | 336 | input[type="checkbox"], 337 | input[type="radio"] { 338 | box-sizing: border-box; /* 1 */ 339 | padding: 0; /* 2 */ 340 | } 341 | 342 | /** 343 | * 1. Address `appearance` set to `searchfield` in Safari 5 and Chrome. 344 | * 2. Address `box-sizing` set to `border-box` in Safari 5 and Chrome 345 | * (include `-moz` to future-proof). 346 | */ 347 | 348 | input[type="search"] { 349 | -webkit-appearance: textfield; /* 1 */ 350 | -moz-box-sizing: content-box; 351 | -webkit-box-sizing: content-box; /* 2 */ 352 | box-sizing: content-box; 353 | } 354 | 355 | /** 356 | * Remove inner padding and search cancel button in Safari 5 and Chrome 357 | * on OS X. 358 | */ 359 | 360 | input[type="search"]::-webkit-search-cancel-button, 361 | input[type="search"]::-webkit-search-decoration { 362 | -webkit-appearance: none; 363 | } 364 | 365 | /** 366 | * Remove inner padding and border in Firefox 4+. 367 | */ 368 | 369 | button::-moz-focus-inner, 370 | input::-moz-focus-inner { 371 | border: 0; 372 | padding: 0; 373 | } 374 | 375 | /** 376 | * 1. Remove default vertical scrollbar in IE 8/9. 377 | * 2. Improve readability and alignment in all browsers. 378 | */ 379 | 380 | textarea { 381 | overflow: auto; /* 1 */ 382 | vertical-align: top; /* 2 */ 383 | } 384 | 385 | /* ========================================================================== 386 | Tables 387 | ========================================================================== */ 388 | 389 | /** 390 | * Remove most spacing between table cells. 391 | */ 392 | 393 | table { 394 | border-collapse: collapse; 395 | border-spacing: 0; 396 | } 397 | -------------------------------------------------------------------------------- /vendor/js/angular-route.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license AngularJS v1.4.0-rc.2 3 | * (c) 2010-2015 Google, Inc. http://angularjs.org 4 | * License: MIT 5 | */ 6 | (function(window, angular, undefined) {'use strict'; 7 | 8 | /** 9 | * @ngdoc module 10 | * @name ngRoute 11 | * @description 12 | * 13 | * # ngRoute 14 | * 15 | * The `ngRoute` module provides routing and deeplinking services and directives for angular apps. 16 | * 17 | * ## Example 18 | * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`. 19 | * 20 | * 21 | *
22 | */ 23 | /* global -ngRouteModule */ 24 | var ngRouteModule = angular.module('ngRoute', ['ng']). 25 | provider('$route', $RouteProvider), 26 | $routeMinErr = angular.$$minErr('ngRoute'); 27 | 28 | /** 29 | * @ngdoc provider 30 | * @name $routeProvider 31 | * 32 | * @description 33 | * 34 | * Used for configuring routes. 35 | * 36 | * ## Example 37 | * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`. 38 | * 39 | * ## Dependencies 40 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 41 | */ 42 | function $RouteProvider() { 43 | function inherit(parent, extra) { 44 | return angular.extend(Object.create(parent), extra); 45 | } 46 | 47 | var routes = {}; 48 | 49 | /** 50 | * @ngdoc method 51 | * @name $routeProvider#when 52 | * 53 | * @param {string} path Route path (matched against `$location.path`). If `$location.path` 54 | * contains redundant trailing slash or is missing one, the route will still match and the 55 | * `$location.path` will be updated to add or drop the trailing slash to exactly match the 56 | * route definition. 57 | * 58 | * * `path` can contain named groups starting with a colon: e.g. `:name`. All characters up 59 | * to the next slash are matched and stored in `$routeParams` under the given `name` 60 | * when the route matches. 61 | * * `path` can contain named groups starting with a colon and ending with a star: 62 | * e.g.`:name*`. All characters are eagerly stored in `$routeParams` under the given `name` 63 | * when the route matches. 64 | * * `path` can contain optional named groups with a question mark: e.g.`:name?`. 65 | * 66 | * For example, routes like `/color/:color/largecode/:largecode*\/edit` will match 67 | * `/color/brown/largecode/code/with/slashes/edit` and extract: 68 | * 69 | * * `color: brown` 70 | * * `largecode: code/with/slashes`. 71 | * 72 | * 73 | * @param {Object} route Mapping information to be assigned to `$route.current` on route 74 | * match. 75 | * 76 | * Object properties: 77 | * 78 | * - `controller` – `{(string|function()=}` – Controller fn that should be associated with 79 | * newly created scope or the name of a {@link angular.Module#controller registered 80 | * controller} if passed as a string. 81 | * - `controllerAs` – `{string=}` – An identifier name for a reference to the controller. 82 | * If present, the controller will be published to scope under the `controllerAs` name. 83 | * - `template` – `{string=|function()=}` – html template as a string or a function that 84 | * returns an html template as a string which should be used by {@link 85 | * ngRoute.directive:ngView ngView} or {@link ng.directive:ngInclude ngInclude} directives. 86 | * This property takes precedence over `templateUrl`. 87 | * 88 | * If `template` is a function, it will be called with the following parameters: 89 | * 90 | * - `{Array.}` - route parameters extracted from the current 91 | * `$location.path()` by applying the current route 92 | * 93 | * - `templateUrl` – `{string=|function()=}` – path or function that returns a path to an html 94 | * template that should be used by {@link ngRoute.directive:ngView ngView}. 95 | * 96 | * If `templateUrl` is a function, it will be called with the following parameters: 97 | * 98 | * - `{Array.}` - route parameters extracted from the current 99 | * `$location.path()` by applying the current route 100 | * 101 | * - `resolve` - `{Object.=}` - An optional map of dependencies which should 102 | * be injected into the controller. If any of these dependencies are promises, the router 103 | * will wait for them all to be resolved or one to be rejected before the controller is 104 | * instantiated. 105 | * If all the promises are resolved successfully, the values of the resolved promises are 106 | * injected and {@link ngRoute.$route#$routeChangeSuccess $routeChangeSuccess} event is 107 | * fired. If any of the promises are rejected the 108 | * {@link ngRoute.$route#$routeChangeError $routeChangeError} event is fired. The map object 109 | * is: 110 | * 111 | * - `key` – `{string}`: a name of a dependency to be injected into the controller. 112 | * - `factory` - `{string|function}`: If `string` then it is an alias for a service. 113 | * Otherwise if function, then it is {@link auto.$injector#invoke injected} 114 | * and the return value is treated as the dependency. If the result is a promise, it is 115 | * resolved before its value is injected into the controller. Be aware that 116 | * `ngRoute.$routeParams` will still refer to the previous route within these resolve 117 | * functions. Use `$route.current.params` to access the new route parameters, instead. 118 | * 119 | * - `redirectTo` – {(string|function())=} – value to update 120 | * {@link ng.$location $location} path with and trigger route redirection. 121 | * 122 | * If `redirectTo` is a function, it will be called with the following parameters: 123 | * 124 | * - `{Object.}` - route parameters extracted from the current 125 | * `$location.path()` by applying the current route templateUrl. 126 | * - `{string}` - current `$location.path()` 127 | * - `{Object}` - current `$location.search()` 128 | * 129 | * The custom `redirectTo` function is expected to return a string which will be used 130 | * to update `$location.path()` and `$location.search()`. 131 | * 132 | * - `[reloadOnSearch=true]` - {boolean=} - reload route when only `$location.search()` 133 | * or `$location.hash()` changes. 134 | * 135 | * If the option is set to `false` and url in the browser changes, then 136 | * `$routeUpdate` event is broadcasted on the root scope. 137 | * 138 | * - `[caseInsensitiveMatch=false]` - {boolean=} - match routes without being case sensitive 139 | * 140 | * If the option is set to `true`, then the particular route can be matched without being 141 | * case sensitive 142 | * 143 | * @returns {Object} self 144 | * 145 | * @description 146 | * Adds a new route definition to the `$route` service. 147 | */ 148 | this.when = function(path, route) { 149 | //copy original route object to preserve params inherited from proto chain 150 | var routeCopy = angular.copy(route); 151 | if (angular.isUndefined(routeCopy.reloadOnSearch)) { 152 | routeCopy.reloadOnSearch = true; 153 | } 154 | if (angular.isUndefined(routeCopy.caseInsensitiveMatch)) { 155 | routeCopy.caseInsensitiveMatch = this.caseInsensitiveMatch; 156 | } 157 | routes[path] = angular.extend( 158 | routeCopy, 159 | path && pathRegExp(path, routeCopy) 160 | ); 161 | 162 | // create redirection for trailing slashes 163 | if (path) { 164 | var redirectPath = (path[path.length - 1] == '/') 165 | ? path.substr(0, path.length - 1) 166 | : path + '/'; 167 | 168 | routes[redirectPath] = angular.extend( 169 | {redirectTo: path}, 170 | pathRegExp(redirectPath, routeCopy) 171 | ); 172 | } 173 | 174 | return this; 175 | }; 176 | 177 | /** 178 | * @ngdoc property 179 | * @name $routeProvider#caseInsensitiveMatch 180 | * @description 181 | * 182 | * A boolean property indicating if routes defined 183 | * using this provider should be matched using a case insensitive 184 | * algorithm. Defaults to `false`. 185 | */ 186 | this.caseInsensitiveMatch = false; 187 | 188 | /** 189 | * @param path {string} path 190 | * @param opts {Object} options 191 | * @return {?Object} 192 | * 193 | * @description 194 | * Normalizes the given path, returning a regular expression 195 | * and the original path. 196 | * 197 | * Inspired by pathRexp in visionmedia/express/lib/utils.js. 198 | */ 199 | function pathRegExp(path, opts) { 200 | var insensitive = opts.caseInsensitiveMatch, 201 | ret = { 202 | originalPath: path, 203 | regexp: path 204 | }, 205 | keys = ret.keys = []; 206 | 207 | path = path 208 | .replace(/([().])/g, '\\$1') 209 | .replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option) { 210 | var optional = option === '?' ? option : null; 211 | var star = option === '*' ? option : null; 212 | keys.push({ name: key, optional: !!optional }); 213 | slash = slash || ''; 214 | return '' 215 | + (optional ? '' : slash) 216 | + '(?:' 217 | + (optional ? slash : '') 218 | + (star && '(.+?)' || '([^/]+)') 219 | + (optional || '') 220 | + ')' 221 | + (optional || ''); 222 | }) 223 | .replace(/([\/$\*])/g, '\\$1'); 224 | 225 | ret.regexp = new RegExp('^' + path + '$', insensitive ? 'i' : ''); 226 | return ret; 227 | } 228 | 229 | /** 230 | * @ngdoc method 231 | * @name $routeProvider#otherwise 232 | * 233 | * @description 234 | * Sets route definition that will be used on route change when no other route definition 235 | * is matched. 236 | * 237 | * @param {Object|string} params Mapping information to be assigned to `$route.current`. 238 | * If called with a string, the value maps to `redirectTo`. 239 | * @returns {Object} self 240 | */ 241 | this.otherwise = function(params) { 242 | if (typeof params === 'string') { 243 | params = {redirectTo: params}; 244 | } 245 | this.when(null, params); 246 | return this; 247 | }; 248 | 249 | 250 | this.$get = ['$rootScope', 251 | '$location', 252 | '$routeParams', 253 | '$q', 254 | '$injector', 255 | '$templateRequest', 256 | '$sce', 257 | function($rootScope, $location, $routeParams, $q, $injector, $templateRequest, $sce) { 258 | 259 | /** 260 | * @ngdoc service 261 | * @name $route 262 | * @requires $location 263 | * @requires $routeParams 264 | * 265 | * @property {Object} current Reference to the current route definition. 266 | * The route definition contains: 267 | * 268 | * - `controller`: The controller constructor as define in route definition. 269 | * - `locals`: A map of locals which is used by {@link ng.$controller $controller} service for 270 | * controller instantiation. The `locals` contain 271 | * the resolved values of the `resolve` map. Additionally the `locals` also contain: 272 | * 273 | * - `$scope` - The current route scope. 274 | * - `$template` - The current route template HTML. 275 | * 276 | * @property {Object} routes Object with all route configuration Objects as its properties. 277 | * 278 | * @description 279 | * `$route` is used for deep-linking URLs to controllers and views (HTML partials). 280 | * It watches `$location.url()` and tries to map the path to an existing route definition. 281 | * 282 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 283 | * 284 | * You can define routes through {@link ngRoute.$routeProvider $routeProvider}'s API. 285 | * 286 | * The `$route` service is typically used in conjunction with the 287 | * {@link ngRoute.directive:ngView `ngView`} directive and the 288 | * {@link ngRoute.$routeParams `$routeParams`} service. 289 | * 290 | * @example 291 | * This example shows how changing the URL hash causes the `$route` to match a route against the 292 | * URL, and the `ngView` pulls in the partial. 293 | * 294 | * 296 | * 297 | *
298 | * Choose: 299 | * Moby | 300 | * Moby: Ch1 | 301 | * Gatsby | 302 | * Gatsby: Ch4 | 303 | * Scarlet Letter
304 | * 305 | *
306 | * 307 | *
308 | * 309 | *
$location.path() = {{$location.path()}}
310 | *
$route.current.templateUrl = {{$route.current.templateUrl}}
311 | *
$route.current.params = {{$route.current.params}}
312 | *
$route.current.scope.name = {{$route.current.scope.name}}
313 | *
$routeParams = {{$routeParams}}
314 | *
315 | *
316 | * 317 | * 318 | * controller: {{name}}
319 | * Book Id: {{params.bookId}}
320 | *
321 | * 322 | * 323 | * controller: {{name}}
324 | * Book Id: {{params.bookId}}
325 | * Chapter Id: {{params.chapterId}} 326 | *
327 | * 328 | * 329 | * angular.module('ngRouteExample', ['ngRoute']) 330 | * 331 | * .controller('MainController', function($scope, $route, $routeParams, $location) { 332 | * $scope.$route = $route; 333 | * $scope.$location = $location; 334 | * $scope.$routeParams = $routeParams; 335 | * }) 336 | * 337 | * .controller('BookController', function($scope, $routeParams) { 338 | * $scope.name = "BookController"; 339 | * $scope.params = $routeParams; 340 | * }) 341 | * 342 | * .controller('ChapterController', function($scope, $routeParams) { 343 | * $scope.name = "ChapterController"; 344 | * $scope.params = $routeParams; 345 | * }) 346 | * 347 | * .config(function($routeProvider, $locationProvider) { 348 | * $routeProvider 349 | * .when('/Book/:bookId', { 350 | * templateUrl: 'book.html', 351 | * controller: 'BookController', 352 | * resolve: { 353 | * // I will cause a 1 second delay 354 | * delay: function($q, $timeout) { 355 | * var delay = $q.defer(); 356 | * $timeout(delay.resolve, 1000); 357 | * return delay.promise; 358 | * } 359 | * } 360 | * }) 361 | * .when('/Book/:bookId/ch/:chapterId', { 362 | * templateUrl: 'chapter.html', 363 | * controller: 'ChapterController' 364 | * }); 365 | * 366 | * // configure html5 to get links working on jsfiddle 367 | * $locationProvider.html5Mode(true); 368 | * }); 369 | * 370 | * 371 | * 372 | * 373 | * it('should load and compile correct template', function() { 374 | * element(by.linkText('Moby: Ch1')).click(); 375 | * var content = element(by.css('[ng-view]')).getText(); 376 | * expect(content).toMatch(/controller\: ChapterController/); 377 | * expect(content).toMatch(/Book Id\: Moby/); 378 | * expect(content).toMatch(/Chapter Id\: 1/); 379 | * 380 | * element(by.partialLinkText('Scarlet')).click(); 381 | * 382 | * content = element(by.css('[ng-view]')).getText(); 383 | * expect(content).toMatch(/controller\: BookController/); 384 | * expect(content).toMatch(/Book Id\: Scarlet/); 385 | * }); 386 | * 387 | *
388 | */ 389 | 390 | /** 391 | * @ngdoc event 392 | * @name $route#$routeChangeStart 393 | * @eventType broadcast on root scope 394 | * @description 395 | * Broadcasted before a route change. At this point the route services starts 396 | * resolving all of the dependencies needed for the route change to occur. 397 | * Typically this involves fetching the view template as well as any dependencies 398 | * defined in `resolve` route property. Once all of the dependencies are resolved 399 | * `$routeChangeSuccess` is fired. 400 | * 401 | * The route change (and the `$location` change that triggered it) can be prevented 402 | * by calling `preventDefault` method of the event. See {@link ng.$rootScope.Scope#$on} 403 | * for more details about event object. 404 | * 405 | * @param {Object} angularEvent Synthetic event object. 406 | * @param {Route} next Future route information. 407 | * @param {Route} current Current route information. 408 | */ 409 | 410 | /** 411 | * @ngdoc event 412 | * @name $route#$routeChangeSuccess 413 | * @eventType broadcast on root scope 414 | * @description 415 | * Broadcasted after a route dependencies are resolved. 416 | * {@link ngRoute.directive:ngView ngView} listens for the directive 417 | * to instantiate the controller and render the view. 418 | * 419 | * @param {Object} angularEvent Synthetic event object. 420 | * @param {Route} current Current route information. 421 | * @param {Route|Undefined} previous Previous route information, or undefined if current is 422 | * first route entered. 423 | */ 424 | 425 | /** 426 | * @ngdoc event 427 | * @name $route#$routeChangeError 428 | * @eventType broadcast on root scope 429 | * @description 430 | * Broadcasted if any of the resolve promises are rejected. 431 | * 432 | * @param {Object} angularEvent Synthetic event object 433 | * @param {Route} current Current route information. 434 | * @param {Route} previous Previous route information. 435 | * @param {Route} rejection Rejection of the promise. Usually the error of the failed promise. 436 | */ 437 | 438 | /** 439 | * @ngdoc event 440 | * @name $route#$routeUpdate 441 | * @eventType broadcast on root scope 442 | * @description 443 | * The `reloadOnSearch` property has been set to false, and we are reusing the same 444 | * instance of the Controller. 445 | * 446 | * @param {Object} angularEvent Synthetic event object 447 | * @param {Route} current Current/previous route information. 448 | */ 449 | 450 | var forceReload = false, 451 | preparedRoute, 452 | preparedRouteIsUpdateOnly, 453 | $route = { 454 | routes: routes, 455 | 456 | /** 457 | * @ngdoc method 458 | * @name $route#reload 459 | * 460 | * @description 461 | * Causes `$route` service to reload the current route even if 462 | * {@link ng.$location $location} hasn't changed. 463 | * 464 | * As a result of that, {@link ngRoute.directive:ngView ngView} 465 | * creates new scope and reinstantiates the controller. 466 | */ 467 | reload: function() { 468 | forceReload = true; 469 | $rootScope.$evalAsync(function() { 470 | // Don't support cancellation of a reload for now... 471 | prepareRoute(); 472 | commitRoute(); 473 | }); 474 | }, 475 | 476 | /** 477 | * @ngdoc method 478 | * @name $route#updateParams 479 | * 480 | * @description 481 | * Causes `$route` service to update the current URL, replacing 482 | * current route parameters with those specified in `newParams`. 483 | * Provided property names that match the route's path segment 484 | * definitions will be interpolated into the location's path, while 485 | * remaining properties will be treated as query params. 486 | * 487 | * @param {!Object} newParams mapping of URL parameter names to values 488 | */ 489 | updateParams: function(newParams) { 490 | if (this.current && this.current.$$route) { 491 | newParams = angular.extend({}, this.current.params, newParams); 492 | $location.path(interpolate(this.current.$$route.originalPath, newParams)); 493 | // interpolate modifies newParams, only query params are left 494 | $location.search(newParams); 495 | } else { 496 | throw $routeMinErr('norout', 'Tried updating route when with no current route'); 497 | } 498 | } 499 | }; 500 | 501 | $rootScope.$on('$locationChangeStart', prepareRoute); 502 | $rootScope.$on('$locationChangeSuccess', commitRoute); 503 | 504 | return $route; 505 | 506 | ///////////////////////////////////////////////////// 507 | 508 | /** 509 | * @param on {string} current url 510 | * @param route {Object} route regexp to match the url against 511 | * @return {?Object} 512 | * 513 | * @description 514 | * Check if the route matches the current url. 515 | * 516 | * Inspired by match in 517 | * visionmedia/express/lib/router/router.js. 518 | */ 519 | function switchRouteMatcher(on, route) { 520 | var keys = route.keys, 521 | params = {}; 522 | 523 | if (!route.regexp) return null; 524 | 525 | var m = route.regexp.exec(on); 526 | if (!m) return null; 527 | 528 | for (var i = 1, len = m.length; i < len; ++i) { 529 | var key = keys[i - 1]; 530 | 531 | var val = m[i]; 532 | 533 | if (key && val) { 534 | params[key.name] = val; 535 | } 536 | } 537 | return params; 538 | } 539 | 540 | function prepareRoute($locationEvent) { 541 | var lastRoute = $route.current; 542 | 543 | preparedRoute = parseRoute(); 544 | preparedRouteIsUpdateOnly = preparedRoute && lastRoute && preparedRoute.$$route === lastRoute.$$route 545 | && angular.equals(preparedRoute.pathParams, lastRoute.pathParams) 546 | && !preparedRoute.reloadOnSearch && !forceReload; 547 | 548 | if (!preparedRouteIsUpdateOnly && (lastRoute || preparedRoute)) { 549 | if ($rootScope.$broadcast('$routeChangeStart', preparedRoute, lastRoute).defaultPrevented) { 550 | if ($locationEvent) { 551 | $locationEvent.preventDefault(); 552 | } 553 | } 554 | } 555 | } 556 | 557 | function commitRoute() { 558 | var lastRoute = $route.current; 559 | var nextRoute = preparedRoute; 560 | 561 | if (preparedRouteIsUpdateOnly) { 562 | lastRoute.params = nextRoute.params; 563 | angular.copy(lastRoute.params, $routeParams); 564 | $rootScope.$broadcast('$routeUpdate', lastRoute); 565 | } else if (nextRoute || lastRoute) { 566 | forceReload = false; 567 | $route.current = nextRoute; 568 | if (nextRoute) { 569 | if (nextRoute.redirectTo) { 570 | if (angular.isString(nextRoute.redirectTo)) { 571 | $location.path(interpolate(nextRoute.redirectTo, nextRoute.params)).search(nextRoute.params) 572 | .replace(); 573 | } else { 574 | $location.url(nextRoute.redirectTo(nextRoute.pathParams, $location.path(), $location.search())) 575 | .replace(); 576 | } 577 | } 578 | } 579 | 580 | $q.when(nextRoute). 581 | then(function() { 582 | if (nextRoute) { 583 | var locals = angular.extend({}, nextRoute.resolve), 584 | template, templateUrl; 585 | 586 | angular.forEach(locals, function(value, key) { 587 | locals[key] = angular.isString(value) ? 588 | $injector.get(value) : $injector.invoke(value, null, null, key); 589 | }); 590 | 591 | if (angular.isDefined(template = nextRoute.template)) { 592 | if (angular.isFunction(template)) { 593 | template = template(nextRoute.params); 594 | } 595 | } else if (angular.isDefined(templateUrl = nextRoute.templateUrl)) { 596 | if (angular.isFunction(templateUrl)) { 597 | templateUrl = templateUrl(nextRoute.params); 598 | } 599 | templateUrl = $sce.getTrustedResourceUrl(templateUrl); 600 | if (angular.isDefined(templateUrl)) { 601 | nextRoute.loadedTemplateUrl = templateUrl; 602 | template = $templateRequest(templateUrl); 603 | } 604 | } 605 | if (angular.isDefined(template)) { 606 | locals['$template'] = template; 607 | } 608 | return $q.all(locals); 609 | } 610 | }). 611 | then(function(locals) { 612 | // after route change 613 | if (nextRoute == $route.current) { 614 | if (nextRoute) { 615 | nextRoute.locals = locals; 616 | angular.copy(nextRoute.params, $routeParams); 617 | } 618 | $rootScope.$broadcast('$routeChangeSuccess', nextRoute, lastRoute); 619 | } 620 | }, function(error) { 621 | if (nextRoute == $route.current) { 622 | $rootScope.$broadcast('$routeChangeError', nextRoute, lastRoute, error); 623 | } 624 | }); 625 | } 626 | } 627 | 628 | 629 | /** 630 | * @returns {Object} the current active route, by matching it against the URL 631 | */ 632 | function parseRoute() { 633 | // Match a route 634 | var params, match; 635 | angular.forEach(routes, function(route, path) { 636 | if (!match && (params = switchRouteMatcher($location.path(), route))) { 637 | match = inherit(route, { 638 | params: angular.extend({}, $location.search(), params), 639 | pathParams: params}); 640 | match.$$route = route; 641 | } 642 | }); 643 | // No route matched; fallback to "otherwise" route 644 | return match || routes[null] && inherit(routes[null], {params: {}, pathParams:{}}); 645 | } 646 | 647 | /** 648 | * @returns {string} interpolation of the redirect path with the parameters 649 | */ 650 | function interpolate(string, params) { 651 | var result = []; 652 | angular.forEach((string || '').split(':'), function(segment, i) { 653 | if (i === 0) { 654 | result.push(segment); 655 | } else { 656 | var segmentMatch = segment.match(/(\w+)(?:[?*])?(.*)/); 657 | var key = segmentMatch[1]; 658 | result.push(params[key]); 659 | result.push(segmentMatch[2] || ''); 660 | delete params[key]; 661 | } 662 | }); 663 | return result.join(''); 664 | } 665 | }]; 666 | } 667 | 668 | ngRouteModule.provider('$routeParams', $RouteParamsProvider); 669 | 670 | 671 | /** 672 | * @ngdoc service 673 | * @name $routeParams 674 | * @requires $route 675 | * 676 | * @description 677 | * The `$routeParams` service allows you to retrieve the current set of route parameters. 678 | * 679 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 680 | * 681 | * The route parameters are a combination of {@link ng.$location `$location`}'s 682 | * {@link ng.$location#search `search()`} and {@link ng.$location#path `path()`}. 683 | * The `path` parameters are extracted when the {@link ngRoute.$route `$route`} path is matched. 684 | * 685 | * In case of parameter name collision, `path` params take precedence over `search` params. 686 | * 687 | * The service guarantees that the identity of the `$routeParams` object will remain unchanged 688 | * (but its properties will likely change) even when a route change occurs. 689 | * 690 | * Note that the `$routeParams` are only updated *after* a route change completes successfully. 691 | * This means that you cannot rely on `$routeParams` being correct in route resolve functions. 692 | * Instead you can use `$route.current.params` to access the new route's parameters. 693 | * 694 | * @example 695 | * ```js 696 | * // Given: 697 | * // URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby 698 | * // Route: /Chapter/:chapterId/Section/:sectionId 699 | * // 700 | * // Then 701 | * $routeParams ==> {chapterId:'1', sectionId:'2', search:'moby'} 702 | * ``` 703 | */ 704 | function $RouteParamsProvider() { 705 | this.$get = function() { return {}; }; 706 | } 707 | 708 | ngRouteModule.directive('ngView', ngViewFactory); 709 | ngRouteModule.directive('ngView', ngViewFillContentFactory); 710 | 711 | 712 | /** 713 | * @ngdoc directive 714 | * @name ngView 715 | * @restrict ECA 716 | * 717 | * @description 718 | * # Overview 719 | * `ngView` is a directive that complements the {@link ngRoute.$route $route} service by 720 | * including the rendered template of the current route into the main layout (`index.html`) file. 721 | * Every time the current route changes, the included view changes with it according to the 722 | * configuration of the `$route` service. 723 | * 724 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 725 | * 726 | * @animations 727 | * enter - animation is used to bring new content into the browser. 728 | * leave - animation is used to animate existing content away. 729 | * 730 | * The enter and leave animation occur concurrently. 731 | * 732 | * @scope 733 | * @priority 400 734 | * @param {string=} onload Expression to evaluate whenever the view updates. 735 | * 736 | * @param {string=} autoscroll Whether `ngView` should call {@link ng.$anchorScroll 737 | * $anchorScroll} to scroll the viewport after the view is updated. 738 | * 739 | * - If the attribute is not set, disable scrolling. 740 | * - If the attribute is set without value, enable scrolling. 741 | * - Otherwise enable scrolling only if the `autoscroll` attribute value evaluated 742 | * as an expression yields a truthy value. 743 | * @example 744 | 747 | 748 |
749 | Choose: 750 | Moby | 751 | Moby: Ch1 | 752 | Gatsby | 753 | Gatsby: Ch4 | 754 | Scarlet Letter
755 | 756 |
757 |
758 |
759 |
760 | 761 |
$location.path() = {{main.$location.path()}}
762 |
$route.current.templateUrl = {{main.$route.current.templateUrl}}
763 |
$route.current.params = {{main.$route.current.params}}
764 |
$routeParams = {{main.$routeParams}}
765 |
766 |
767 | 768 | 769 |
770 | controller: {{book.name}}
771 | Book Id: {{book.params.bookId}}
772 |
773 |
774 | 775 | 776 |
777 | controller: {{chapter.name}}
778 | Book Id: {{chapter.params.bookId}}
779 | Chapter Id: {{chapter.params.chapterId}} 780 |
781 |
782 | 783 | 784 | .view-animate-container { 785 | position:relative; 786 | height:100px!important; 787 | background:white; 788 | border:1px solid black; 789 | height:40px; 790 | overflow:hidden; 791 | } 792 | 793 | .view-animate { 794 | padding:10px; 795 | } 796 | 797 | .view-animate.ng-enter, .view-animate.ng-leave { 798 | -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s; 799 | transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s; 800 | 801 | display:block; 802 | width:100%; 803 | border-left:1px solid black; 804 | 805 | position:absolute; 806 | top:0; 807 | left:0; 808 | right:0; 809 | bottom:0; 810 | padding:10px; 811 | } 812 | 813 | .view-animate.ng-enter { 814 | left:100%; 815 | } 816 | .view-animate.ng-enter.ng-enter-active { 817 | left:0; 818 | } 819 | .view-animate.ng-leave.ng-leave-active { 820 | left:-100%; 821 | } 822 | 823 | 824 | 825 | angular.module('ngViewExample', ['ngRoute', 'ngAnimate']) 826 | .config(['$routeProvider', '$locationProvider', 827 | function($routeProvider, $locationProvider) { 828 | $routeProvider 829 | .when('/Book/:bookId', { 830 | templateUrl: 'book.html', 831 | controller: 'BookCtrl', 832 | controllerAs: 'book' 833 | }) 834 | .when('/Book/:bookId/ch/:chapterId', { 835 | templateUrl: 'chapter.html', 836 | controller: 'ChapterCtrl', 837 | controllerAs: 'chapter' 838 | }); 839 | 840 | $locationProvider.html5Mode(true); 841 | }]) 842 | .controller('MainCtrl', ['$route', '$routeParams', '$location', 843 | function($route, $routeParams, $location) { 844 | this.$route = $route; 845 | this.$location = $location; 846 | this.$routeParams = $routeParams; 847 | }]) 848 | .controller('BookCtrl', ['$routeParams', function($routeParams) { 849 | this.name = "BookCtrl"; 850 | this.params = $routeParams; 851 | }]) 852 | .controller('ChapterCtrl', ['$routeParams', function($routeParams) { 853 | this.name = "ChapterCtrl"; 854 | this.params = $routeParams; 855 | }]); 856 | 857 | 858 | 859 | 860 | it('should load and compile correct template', function() { 861 | element(by.linkText('Moby: Ch1')).click(); 862 | var content = element(by.css('[ng-view]')).getText(); 863 | expect(content).toMatch(/controller\: ChapterCtrl/); 864 | expect(content).toMatch(/Book Id\: Moby/); 865 | expect(content).toMatch(/Chapter Id\: 1/); 866 | 867 | element(by.partialLinkText('Scarlet')).click(); 868 | 869 | content = element(by.css('[ng-view]')).getText(); 870 | expect(content).toMatch(/controller\: BookCtrl/); 871 | expect(content).toMatch(/Book Id\: Scarlet/); 872 | }); 873 | 874 |
875 | */ 876 | 877 | 878 | /** 879 | * @ngdoc event 880 | * @name ngView#$viewContentLoaded 881 | * @eventType emit on the current ngView scope 882 | * @description 883 | * Emitted every time the ngView content is reloaded. 884 | */ 885 | ngViewFactory.$inject = ['$route', '$anchorScroll', '$animate']; 886 | function ngViewFactory($route, $anchorScroll, $animate) { 887 | return { 888 | restrict: 'ECA', 889 | terminal: true, 890 | priority: 400, 891 | transclude: 'element', 892 | link: function(scope, $element, attr, ctrl, $transclude) { 893 | var currentScope, 894 | currentElement, 895 | previousLeaveAnimation, 896 | autoScrollExp = attr.autoscroll, 897 | onloadExp = attr.onload || ''; 898 | 899 | scope.$on('$routeChangeSuccess', update); 900 | update(); 901 | 902 | function cleanupLastView() { 903 | if (previousLeaveAnimation) { 904 | $animate.cancel(previousLeaveAnimation); 905 | previousLeaveAnimation = null; 906 | } 907 | 908 | if (currentScope) { 909 | currentScope.$destroy(); 910 | currentScope = null; 911 | } 912 | if (currentElement) { 913 | previousLeaveAnimation = $animate.leave(currentElement); 914 | previousLeaveAnimation.then(function() { 915 | previousLeaveAnimation = null; 916 | }); 917 | currentElement = null; 918 | } 919 | } 920 | 921 | function update() { 922 | var locals = $route.current && $route.current.locals, 923 | template = locals && locals.$template; 924 | 925 | if (angular.isDefined(template)) { 926 | var newScope = scope.$new(); 927 | var current = $route.current; 928 | 929 | // Note: This will also link all children of ng-view that were contained in the original 930 | // html. If that content contains controllers, ... they could pollute/change the scope. 931 | // However, using ng-view on an element with additional content does not make sense... 932 | // Note: We can't remove them in the cloneAttchFn of $transclude as that 933 | // function is called before linking the content, which would apply child 934 | // directives to non existing elements. 935 | var clone = $transclude(newScope, function(clone) { 936 | $animate.enter(clone, null, currentElement || $element).then(function onNgViewEnter() { 937 | if (angular.isDefined(autoScrollExp) 938 | && (!autoScrollExp || scope.$eval(autoScrollExp))) { 939 | $anchorScroll(); 940 | } 941 | }); 942 | cleanupLastView(); 943 | }); 944 | 945 | currentElement = clone; 946 | currentScope = current.scope = newScope; 947 | currentScope.$emit('$viewContentLoaded'); 948 | currentScope.$eval(onloadExp); 949 | } else { 950 | cleanupLastView(); 951 | } 952 | } 953 | } 954 | }; 955 | } 956 | 957 | // This directive is called during the $transclude call of the first `ngView` directive. 958 | // It will replace and compile the content of the element with the loaded template. 959 | // We need this directive so that the element content is already filled when 960 | // the link function of another directive on the same element as ngView 961 | // is called. 962 | ngViewFillContentFactory.$inject = ['$compile', '$controller', '$route']; 963 | function ngViewFillContentFactory($compile, $controller, $route) { 964 | return { 965 | restrict: 'ECA', 966 | priority: -400, 967 | link: function(scope, $element) { 968 | var current = $route.current, 969 | locals = current.locals; 970 | 971 | $element.html(locals.$template); 972 | 973 | var link = $compile($element.contents()); 974 | 975 | if (current.controller) { 976 | locals.$scope = scope; 977 | var controller = $controller(current.controller, locals); 978 | if (current.controllerAs) { 979 | scope[current.controllerAs] = controller; 980 | } 981 | $element.data('$ngControllerController', controller); 982 | $element.children().data('$ngControllerController', controller); 983 | } 984 | 985 | link(scope); 986 | } 987 | }; 988 | } 989 | 990 | 991 | })(window, window.angular); 992 | -------------------------------------------------------------------------------- /vendor/js/underscore.js: -------------------------------------------------------------------------------- 1 | // Underscore.js 1.8.3 2 | // http://underscorejs.org 3 | // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 4 | // Underscore may be freely distributed under the MIT license. 5 | 6 | (function() { 7 | 8 | // Baseline setup 9 | // -------------- 10 | 11 | // Establish the root object, `window` in the browser, or `exports` on the server. 12 | var root = this; 13 | 14 | // Save the previous value of the `_` variable. 15 | var previousUnderscore = root._; 16 | 17 | // Save bytes in the minified (but not gzipped) version: 18 | var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; 19 | 20 | // Create quick reference variables for speed access to core prototypes. 21 | var 22 | push = ArrayProto.push, 23 | slice = ArrayProto.slice, 24 | toString = ObjProto.toString, 25 | hasOwnProperty = ObjProto.hasOwnProperty; 26 | 27 | // All **ECMAScript 5** native function implementations that we hope to use 28 | // are declared here. 29 | var 30 | nativeIsArray = Array.isArray, 31 | nativeKeys = Object.keys, 32 | nativeBind = FuncProto.bind, 33 | nativeCreate = Object.create; 34 | 35 | // Naked function reference for surrogate-prototype-swapping. 36 | var Ctor = function(){}; 37 | 38 | // Create a safe reference to the Underscore object for use below. 39 | var _ = function(obj) { 40 | if (obj instanceof _) return obj; 41 | if (!(this instanceof _)) return new _(obj); 42 | this._wrapped = obj; 43 | }; 44 | 45 | // Export the Underscore object for **Node.js**, with 46 | // backwards-compatibility for the old `require()` API. If we're in 47 | // the browser, add `_` as a global object. 48 | if (typeof exports !== 'undefined') { 49 | if (typeof module !== 'undefined' && module.exports) { 50 | exports = module.exports = _; 51 | } 52 | exports._ = _; 53 | } else { 54 | root._ = _; 55 | } 56 | 57 | // Current version. 58 | _.VERSION = '1.8.3'; 59 | 60 | // Internal function that returns an efficient (for current engines) version 61 | // of the passed-in callback, to be repeatedly applied in other Underscore 62 | // functions. 63 | var optimizeCb = function(func, context, argCount) { 64 | if (context === void 0) return func; 65 | switch (argCount == null ? 3 : argCount) { 66 | case 1: return function(value) { 67 | return func.call(context, value); 68 | }; 69 | case 2: return function(value, other) { 70 | return func.call(context, value, other); 71 | }; 72 | case 3: return function(value, index, collection) { 73 | return func.call(context, value, index, collection); 74 | }; 75 | case 4: return function(accumulator, value, index, collection) { 76 | return func.call(context, accumulator, value, index, collection); 77 | }; 78 | } 79 | return function() { 80 | return func.apply(context, arguments); 81 | }; 82 | }; 83 | 84 | // A mostly-internal function to generate callbacks that can be applied 85 | // to each element in a collection, returning the desired result — either 86 | // identity, an arbitrary callback, a property matcher, or a property accessor. 87 | var cb = function(value, context, argCount) { 88 | if (value == null) return _.identity; 89 | if (_.isFunction(value)) return optimizeCb(value, context, argCount); 90 | if (_.isObject(value)) return _.matcher(value); 91 | return _.property(value); 92 | }; 93 | _.iteratee = function(value, context) { 94 | return cb(value, context, Infinity); 95 | }; 96 | 97 | // An internal function for creating assigner functions. 98 | var createAssigner = function(keysFunc, undefinedOnly) { 99 | return function(obj) { 100 | var length = arguments.length; 101 | if (length < 2 || obj == null) return obj; 102 | for (var index = 1; index < length; index++) { 103 | var source = arguments[index], 104 | keys = keysFunc(source), 105 | l = keys.length; 106 | for (var i = 0; i < l; i++) { 107 | var key = keys[i]; 108 | if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key]; 109 | } 110 | } 111 | return obj; 112 | }; 113 | }; 114 | 115 | // An internal function for creating a new object that inherits from another. 116 | var baseCreate = function(prototype) { 117 | if (!_.isObject(prototype)) return {}; 118 | if (nativeCreate) return nativeCreate(prototype); 119 | Ctor.prototype = prototype; 120 | var result = new Ctor; 121 | Ctor.prototype = null; 122 | return result; 123 | }; 124 | 125 | var property = function(key) { 126 | return function(obj) { 127 | return obj == null ? void 0 : obj[key]; 128 | }; 129 | }; 130 | 131 | // Helper for collection methods to determine whether a collection 132 | // should be iterated as an array or as an object 133 | // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength 134 | // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 135 | var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; 136 | var getLength = property('length'); 137 | var isArrayLike = function(collection) { 138 | var length = getLength(collection); 139 | return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX; 140 | }; 141 | 142 | // Collection Functions 143 | // -------------------- 144 | 145 | // The cornerstone, an `each` implementation, aka `forEach`. 146 | // Handles raw objects in addition to array-likes. Treats all 147 | // sparse array-likes as if they were dense. 148 | _.each = _.forEach = function(obj, iteratee, context) { 149 | iteratee = optimizeCb(iteratee, context); 150 | var i, length; 151 | if (isArrayLike(obj)) { 152 | for (i = 0, length = obj.length; i < length; i++) { 153 | iteratee(obj[i], i, obj); 154 | } 155 | } else { 156 | var keys = _.keys(obj); 157 | for (i = 0, length = keys.length; i < length; i++) { 158 | iteratee(obj[keys[i]], keys[i], obj); 159 | } 160 | } 161 | return obj; 162 | }; 163 | 164 | // Return the results of applying the iteratee to each element. 165 | _.map = _.collect = function(obj, iteratee, context) { 166 | iteratee = cb(iteratee, context); 167 | var keys = !isArrayLike(obj) && _.keys(obj), 168 | length = (keys || obj).length, 169 | results = Array(length); 170 | for (var index = 0; index < length; index++) { 171 | var currentKey = keys ? keys[index] : index; 172 | results[index] = iteratee(obj[currentKey], currentKey, obj); 173 | } 174 | return results; 175 | }; 176 | 177 | // Create a reducing function iterating left or right. 178 | function createReduce(dir) { 179 | // Optimized iterator function as using arguments.length 180 | // in the main function will deoptimize the, see #1991. 181 | function iterator(obj, iteratee, memo, keys, index, length) { 182 | for (; index >= 0 && index < length; index += dir) { 183 | var currentKey = keys ? keys[index] : index; 184 | memo = iteratee(memo, obj[currentKey], currentKey, obj); 185 | } 186 | return memo; 187 | } 188 | 189 | return function(obj, iteratee, memo, context) { 190 | iteratee = optimizeCb(iteratee, context, 4); 191 | var keys = !isArrayLike(obj) && _.keys(obj), 192 | length = (keys || obj).length, 193 | index = dir > 0 ? 0 : length - 1; 194 | // Determine the initial value if none is provided. 195 | if (arguments.length < 3) { 196 | memo = obj[keys ? keys[index] : index]; 197 | index += dir; 198 | } 199 | return iterator(obj, iteratee, memo, keys, index, length); 200 | }; 201 | } 202 | 203 | // **Reduce** builds up a single result from a list of values, aka `inject`, 204 | // or `foldl`. 205 | _.reduce = _.foldl = _.inject = createReduce(1); 206 | 207 | // The right-associative version of reduce, also known as `foldr`. 208 | _.reduceRight = _.foldr = createReduce(-1); 209 | 210 | // Return the first value which passes a truth test. Aliased as `detect`. 211 | _.find = _.detect = function(obj, predicate, context) { 212 | var key; 213 | if (isArrayLike(obj)) { 214 | key = _.findIndex(obj, predicate, context); 215 | } else { 216 | key = _.findKey(obj, predicate, context); 217 | } 218 | if (key !== void 0 && key !== -1) return obj[key]; 219 | }; 220 | 221 | // Return all the elements that pass a truth test. 222 | // Aliased as `select`. 223 | _.filter = _.select = function(obj, predicate, context) { 224 | var results = []; 225 | predicate = cb(predicate, context); 226 | _.each(obj, function(value, index, list) { 227 | if (predicate(value, index, list)) results.push(value); 228 | }); 229 | return results; 230 | }; 231 | 232 | // Return all the elements for which a truth test fails. 233 | _.reject = function(obj, predicate, context) { 234 | return _.filter(obj, _.negate(cb(predicate)), context); 235 | }; 236 | 237 | // Determine whether all of the elements match a truth test. 238 | // Aliased as `all`. 239 | _.every = _.all = function(obj, predicate, context) { 240 | predicate = cb(predicate, context); 241 | var keys = !isArrayLike(obj) && _.keys(obj), 242 | length = (keys || obj).length; 243 | for (var index = 0; index < length; index++) { 244 | var currentKey = keys ? keys[index] : index; 245 | if (!predicate(obj[currentKey], currentKey, obj)) return false; 246 | } 247 | return true; 248 | }; 249 | 250 | // Determine if at least one element in the object matches a truth test. 251 | // Aliased as `any`. 252 | _.some = _.any = function(obj, predicate, context) { 253 | predicate = cb(predicate, context); 254 | var keys = !isArrayLike(obj) && _.keys(obj), 255 | length = (keys || obj).length; 256 | for (var index = 0; index < length; index++) { 257 | var currentKey = keys ? keys[index] : index; 258 | if (predicate(obj[currentKey], currentKey, obj)) return true; 259 | } 260 | return false; 261 | }; 262 | 263 | // Determine if the array or object contains a given item (using `===`). 264 | // Aliased as `includes` and `include`. 265 | _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) { 266 | if (!isArrayLike(obj)) obj = _.values(obj); 267 | if (typeof fromIndex != 'number' || guard) fromIndex = 0; 268 | return _.indexOf(obj, item, fromIndex) >= 0; 269 | }; 270 | 271 | // Invoke a method (with arguments) on every item in a collection. 272 | _.invoke = function(obj, method) { 273 | var args = slice.call(arguments, 2); 274 | var isFunc = _.isFunction(method); 275 | return _.map(obj, function(value) { 276 | var func = isFunc ? method : value[method]; 277 | return func == null ? func : func.apply(value, args); 278 | }); 279 | }; 280 | 281 | // Convenience version of a common use case of `map`: fetching a property. 282 | _.pluck = function(obj, key) { 283 | return _.map(obj, _.property(key)); 284 | }; 285 | 286 | // Convenience version of a common use case of `filter`: selecting only objects 287 | // containing specific `key:value` pairs. 288 | _.where = function(obj, attrs) { 289 | return _.filter(obj, _.matcher(attrs)); 290 | }; 291 | 292 | // Convenience version of a common use case of `find`: getting the first object 293 | // containing specific `key:value` pairs. 294 | _.findWhere = function(obj, attrs) { 295 | return _.find(obj, _.matcher(attrs)); 296 | }; 297 | 298 | // Return the maximum element (or element-based computation). 299 | _.max = function(obj, iteratee, context) { 300 | var result = -Infinity, lastComputed = -Infinity, 301 | value, computed; 302 | if (iteratee == null && obj != null) { 303 | obj = isArrayLike(obj) ? obj : _.values(obj); 304 | for (var i = 0, length = obj.length; i < length; i++) { 305 | value = obj[i]; 306 | if (value > result) { 307 | result = value; 308 | } 309 | } 310 | } else { 311 | iteratee = cb(iteratee, context); 312 | _.each(obj, function(value, index, list) { 313 | computed = iteratee(value, index, list); 314 | if (computed > lastComputed || computed === -Infinity && result === -Infinity) { 315 | result = value; 316 | lastComputed = computed; 317 | } 318 | }); 319 | } 320 | return result; 321 | }; 322 | 323 | // Return the minimum element (or element-based computation). 324 | _.min = function(obj, iteratee, context) { 325 | var result = Infinity, lastComputed = Infinity, 326 | value, computed; 327 | if (iteratee == null && obj != null) { 328 | obj = isArrayLike(obj) ? obj : _.values(obj); 329 | for (var i = 0, length = obj.length; i < length; i++) { 330 | value = obj[i]; 331 | if (value < result) { 332 | result = value; 333 | } 334 | } 335 | } else { 336 | iteratee = cb(iteratee, context); 337 | _.each(obj, function(value, index, list) { 338 | computed = iteratee(value, index, list); 339 | if (computed < lastComputed || computed === Infinity && result === Infinity) { 340 | result = value; 341 | lastComputed = computed; 342 | } 343 | }); 344 | } 345 | return result; 346 | }; 347 | 348 | // Shuffle a collection, using the modern version of the 349 | // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). 350 | _.shuffle = function(obj) { 351 | var set = isArrayLike(obj) ? obj : _.values(obj); 352 | var length = set.length; 353 | var shuffled = Array(length); 354 | for (var index = 0, rand; index < length; index++) { 355 | rand = _.random(0, index); 356 | if (rand !== index) shuffled[index] = shuffled[rand]; 357 | shuffled[rand] = set[index]; 358 | } 359 | return shuffled; 360 | }; 361 | 362 | // Sample **n** random values from a collection. 363 | // If **n** is not specified, returns a single random element. 364 | // The internal `guard` argument allows it to work with `map`. 365 | _.sample = function(obj, n, guard) { 366 | if (n == null || guard) { 367 | if (!isArrayLike(obj)) obj = _.values(obj); 368 | return obj[_.random(obj.length - 1)]; 369 | } 370 | return _.shuffle(obj).slice(0, Math.max(0, n)); 371 | }; 372 | 373 | // Sort the object's values by a criterion produced by an iteratee. 374 | _.sortBy = function(obj, iteratee, context) { 375 | iteratee = cb(iteratee, context); 376 | return _.pluck(_.map(obj, function(value, index, list) { 377 | return { 378 | value: value, 379 | index: index, 380 | criteria: iteratee(value, index, list) 381 | }; 382 | }).sort(function(left, right) { 383 | var a = left.criteria; 384 | var b = right.criteria; 385 | if (a !== b) { 386 | if (a > b || a === void 0) return 1; 387 | if (a < b || b === void 0) return -1; 388 | } 389 | return left.index - right.index; 390 | }), 'value'); 391 | }; 392 | 393 | // An internal function used for aggregate "group by" operations. 394 | var group = function(behavior) { 395 | return function(obj, iteratee, context) { 396 | var result = {}; 397 | iteratee = cb(iteratee, context); 398 | _.each(obj, function(value, index) { 399 | var key = iteratee(value, index, obj); 400 | behavior(result, value, key); 401 | }); 402 | return result; 403 | }; 404 | }; 405 | 406 | // Groups the object's values by a criterion. Pass either a string attribute 407 | // to group by, or a function that returns the criterion. 408 | _.groupBy = group(function(result, value, key) { 409 | if (_.has(result, key)) result[key].push(value); else result[key] = [value]; 410 | }); 411 | 412 | // Indexes the object's values by a criterion, similar to `groupBy`, but for 413 | // when you know that your index values will be unique. 414 | _.indexBy = group(function(result, value, key) { 415 | result[key] = value; 416 | }); 417 | 418 | // Counts instances of an object that group by a certain criterion. Pass 419 | // either a string attribute to count by, or a function that returns the 420 | // criterion. 421 | _.countBy = group(function(result, value, key) { 422 | if (_.has(result, key)) result[key]++; else result[key] = 1; 423 | }); 424 | 425 | // Safely create a real, live array from anything iterable. 426 | _.toArray = function(obj) { 427 | if (!obj) return []; 428 | if (_.isArray(obj)) return slice.call(obj); 429 | if (isArrayLike(obj)) return _.map(obj, _.identity); 430 | return _.values(obj); 431 | }; 432 | 433 | // Return the number of elements in an object. 434 | _.size = function(obj) { 435 | if (obj == null) return 0; 436 | return isArrayLike(obj) ? obj.length : _.keys(obj).length; 437 | }; 438 | 439 | // Split a collection into two arrays: one whose elements all satisfy the given 440 | // predicate, and one whose elements all do not satisfy the predicate. 441 | _.partition = function(obj, predicate, context) { 442 | predicate = cb(predicate, context); 443 | var pass = [], fail = []; 444 | _.each(obj, function(value, key, obj) { 445 | (predicate(value, key, obj) ? pass : fail).push(value); 446 | }); 447 | return [pass, fail]; 448 | }; 449 | 450 | // Array Functions 451 | // --------------- 452 | 453 | // Get the first element of an array. Passing **n** will return the first N 454 | // values in the array. Aliased as `head` and `take`. The **guard** check 455 | // allows it to work with `_.map`. 456 | _.first = _.head = _.take = function(array, n, guard) { 457 | if (array == null) return void 0; 458 | if (n == null || guard) return array[0]; 459 | return _.initial(array, array.length - n); 460 | }; 461 | 462 | // Returns everything but the last entry of the array. Especially useful on 463 | // the arguments object. Passing **n** will return all the values in 464 | // the array, excluding the last N. 465 | _.initial = function(array, n, guard) { 466 | return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); 467 | }; 468 | 469 | // Get the last element of an array. Passing **n** will return the last N 470 | // values in the array. 471 | _.last = function(array, n, guard) { 472 | if (array == null) return void 0; 473 | if (n == null || guard) return array[array.length - 1]; 474 | return _.rest(array, Math.max(0, array.length - n)); 475 | }; 476 | 477 | // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. 478 | // Especially useful on the arguments object. Passing an **n** will return 479 | // the rest N values in the array. 480 | _.rest = _.tail = _.drop = function(array, n, guard) { 481 | return slice.call(array, n == null || guard ? 1 : n); 482 | }; 483 | 484 | // Trim out all falsy values from an array. 485 | _.compact = function(array) { 486 | return _.filter(array, _.identity); 487 | }; 488 | 489 | // Internal implementation of a recursive `flatten` function. 490 | var flatten = function(input, shallow, strict, startIndex) { 491 | var output = [], idx = 0; 492 | for (var i = startIndex || 0, length = getLength(input); i < length; i++) { 493 | var value = input[i]; 494 | if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { 495 | //flatten current level of array or arguments object 496 | if (!shallow) value = flatten(value, shallow, strict); 497 | var j = 0, len = value.length; 498 | output.length += len; 499 | while (j < len) { 500 | output[idx++] = value[j++]; 501 | } 502 | } else if (!strict) { 503 | output[idx++] = value; 504 | } 505 | } 506 | return output; 507 | }; 508 | 509 | // Flatten out an array, either recursively (by default), or just one level. 510 | _.flatten = function(array, shallow) { 511 | return flatten(array, shallow, false); 512 | }; 513 | 514 | // Return a version of the array that does not contain the specified value(s). 515 | _.without = function(array) { 516 | return _.difference(array, slice.call(arguments, 1)); 517 | }; 518 | 519 | // Produce a duplicate-free version of the array. If the array has already 520 | // been sorted, you have the option of using a faster algorithm. 521 | // Aliased as `unique`. 522 | _.uniq = _.unique = function(array, isSorted, iteratee, context) { 523 | if (!_.isBoolean(isSorted)) { 524 | context = iteratee; 525 | iteratee = isSorted; 526 | isSorted = false; 527 | } 528 | if (iteratee != null) iteratee = cb(iteratee, context); 529 | var result = []; 530 | var seen = []; 531 | for (var i = 0, length = getLength(array); i < length; i++) { 532 | var value = array[i], 533 | computed = iteratee ? iteratee(value, i, array) : value; 534 | if (isSorted) { 535 | if (!i || seen !== computed) result.push(value); 536 | seen = computed; 537 | } else if (iteratee) { 538 | if (!_.contains(seen, computed)) { 539 | seen.push(computed); 540 | result.push(value); 541 | } 542 | } else if (!_.contains(result, value)) { 543 | result.push(value); 544 | } 545 | } 546 | return result; 547 | }; 548 | 549 | // Produce an array that contains the union: each distinct element from all of 550 | // the passed-in arrays. 551 | _.union = function() { 552 | return _.uniq(flatten(arguments, true, true)); 553 | }; 554 | 555 | // Produce an array that contains every item shared between all the 556 | // passed-in arrays. 557 | _.intersection = function(array) { 558 | var result = []; 559 | var argsLength = arguments.length; 560 | for (var i = 0, length = getLength(array); i < length; i++) { 561 | var item = array[i]; 562 | if (_.contains(result, item)) continue; 563 | for (var j = 1; j < argsLength; j++) { 564 | if (!_.contains(arguments[j], item)) break; 565 | } 566 | if (j === argsLength) result.push(item); 567 | } 568 | return result; 569 | }; 570 | 571 | // Take the difference between one array and a number of other arrays. 572 | // Only the elements present in just the first array will remain. 573 | _.difference = function(array) { 574 | var rest = flatten(arguments, true, true, 1); 575 | return _.filter(array, function(value){ 576 | return !_.contains(rest, value); 577 | }); 578 | }; 579 | 580 | // Zip together multiple lists into a single array -- elements that share 581 | // an index go together. 582 | _.zip = function() { 583 | return _.unzip(arguments); 584 | }; 585 | 586 | // Complement of _.zip. Unzip accepts an array of arrays and groups 587 | // each array's elements on shared indices 588 | _.unzip = function(array) { 589 | var length = array && _.max(array, getLength).length || 0; 590 | var result = Array(length); 591 | 592 | for (var index = 0; index < length; index++) { 593 | result[index] = _.pluck(array, index); 594 | } 595 | return result; 596 | }; 597 | 598 | // Converts lists into objects. Pass either a single array of `[key, value]` 599 | // pairs, or two parallel arrays of the same length -- one of keys, and one of 600 | // the corresponding values. 601 | _.object = function(list, values) { 602 | var result = {}; 603 | for (var i = 0, length = getLength(list); i < length; i++) { 604 | if (values) { 605 | result[list[i]] = values[i]; 606 | } else { 607 | result[list[i][0]] = list[i][1]; 608 | } 609 | } 610 | return result; 611 | }; 612 | 613 | // Generator function to create the findIndex and findLastIndex functions 614 | function createPredicateIndexFinder(dir) { 615 | return function(array, predicate, context) { 616 | predicate = cb(predicate, context); 617 | var length = getLength(array); 618 | var index = dir > 0 ? 0 : length - 1; 619 | for (; index >= 0 && index < length; index += dir) { 620 | if (predicate(array[index], index, array)) return index; 621 | } 622 | return -1; 623 | }; 624 | } 625 | 626 | // Returns the first index on an array-like that passes a predicate test 627 | _.findIndex = createPredicateIndexFinder(1); 628 | _.findLastIndex = createPredicateIndexFinder(-1); 629 | 630 | // Use a comparator function to figure out the smallest index at which 631 | // an object should be inserted so as to maintain order. Uses binary search. 632 | _.sortedIndex = function(array, obj, iteratee, context) { 633 | iteratee = cb(iteratee, context, 1); 634 | var value = iteratee(obj); 635 | var low = 0, high = getLength(array); 636 | while (low < high) { 637 | var mid = Math.floor((low + high) / 2); 638 | if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; 639 | } 640 | return low; 641 | }; 642 | 643 | // Generator function to create the indexOf and lastIndexOf functions 644 | function createIndexFinder(dir, predicateFind, sortedIndex) { 645 | return function(array, item, idx) { 646 | var i = 0, length = getLength(array); 647 | if (typeof idx == 'number') { 648 | if (dir > 0) { 649 | i = idx >= 0 ? idx : Math.max(idx + length, i); 650 | } else { 651 | length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; 652 | } 653 | } else if (sortedIndex && idx && length) { 654 | idx = sortedIndex(array, item); 655 | return array[idx] === item ? idx : -1; 656 | } 657 | if (item !== item) { 658 | idx = predicateFind(slice.call(array, i, length), _.isNaN); 659 | return idx >= 0 ? idx + i : -1; 660 | } 661 | for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { 662 | if (array[idx] === item) return idx; 663 | } 664 | return -1; 665 | }; 666 | } 667 | 668 | // Return the position of the first occurrence of an item in an array, 669 | // or -1 if the item is not included in the array. 670 | // If the array is large and already in sort order, pass `true` 671 | // for **isSorted** to use binary search. 672 | _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex); 673 | _.lastIndexOf = createIndexFinder(-1, _.findLastIndex); 674 | 675 | // Generate an integer Array containing an arithmetic progression. A port of 676 | // the native Python `range()` function. See 677 | // [the Python documentation](http://docs.python.org/library/functions.html#range). 678 | _.range = function(start, stop, step) { 679 | if (stop == null) { 680 | stop = start || 0; 681 | start = 0; 682 | } 683 | step = step || 1; 684 | 685 | var length = Math.max(Math.ceil((stop - start) / step), 0); 686 | var range = Array(length); 687 | 688 | for (var idx = 0; idx < length; idx++, start += step) { 689 | range[idx] = start; 690 | } 691 | 692 | return range; 693 | }; 694 | 695 | // Function (ahem) Functions 696 | // ------------------ 697 | 698 | // Determines whether to execute a function as a constructor 699 | // or a normal function with the provided arguments 700 | var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) { 701 | if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); 702 | var self = baseCreate(sourceFunc.prototype); 703 | var result = sourceFunc.apply(self, args); 704 | if (_.isObject(result)) return result; 705 | return self; 706 | }; 707 | 708 | // Create a function bound to a given object (assigning `this`, and arguments, 709 | // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if 710 | // available. 711 | _.bind = function(func, context) { 712 | if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); 713 | if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function'); 714 | var args = slice.call(arguments, 2); 715 | var bound = function() { 716 | return executeBound(func, bound, context, this, args.concat(slice.call(arguments))); 717 | }; 718 | return bound; 719 | }; 720 | 721 | // Partially apply a function by creating a version that has had some of its 722 | // arguments pre-filled, without changing its dynamic `this` context. _ acts 723 | // as a placeholder, allowing any combination of arguments to be pre-filled. 724 | _.partial = function(func) { 725 | var boundArgs = slice.call(arguments, 1); 726 | var bound = function() { 727 | var position = 0, length = boundArgs.length; 728 | var args = Array(length); 729 | for (var i = 0; i < length; i++) { 730 | args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i]; 731 | } 732 | while (position < arguments.length) args.push(arguments[position++]); 733 | return executeBound(func, bound, this, this, args); 734 | }; 735 | return bound; 736 | }; 737 | 738 | // Bind a number of an object's methods to that object. Remaining arguments 739 | // are the method names to be bound. Useful for ensuring that all callbacks 740 | // defined on an object belong to it. 741 | _.bindAll = function(obj) { 742 | var i, length = arguments.length, key; 743 | if (length <= 1) throw new Error('bindAll must be passed function names'); 744 | for (i = 1; i < length; i++) { 745 | key = arguments[i]; 746 | obj[key] = _.bind(obj[key], obj); 747 | } 748 | return obj; 749 | }; 750 | 751 | // Memoize an expensive function by storing its results. 752 | _.memoize = function(func, hasher) { 753 | var memoize = function(key) { 754 | var cache = memoize.cache; 755 | var address = '' + (hasher ? hasher.apply(this, arguments) : key); 756 | if (!_.has(cache, address)) cache[address] = func.apply(this, arguments); 757 | return cache[address]; 758 | }; 759 | memoize.cache = {}; 760 | return memoize; 761 | }; 762 | 763 | // Delays a function for the given number of milliseconds, and then calls 764 | // it with the arguments supplied. 765 | _.delay = function(func, wait) { 766 | var args = slice.call(arguments, 2); 767 | return setTimeout(function(){ 768 | return func.apply(null, args); 769 | }, wait); 770 | }; 771 | 772 | // Defers a function, scheduling it to run after the current call stack has 773 | // cleared. 774 | _.defer = _.partial(_.delay, _, 1); 775 | 776 | // Returns a function, that, when invoked, will only be triggered at most once 777 | // during a given window of time. Normally, the throttled function will run 778 | // as much as it can, without ever going more than once per `wait` duration; 779 | // but if you'd like to disable the execution on the leading edge, pass 780 | // `{leading: false}`. To disable execution on the trailing edge, ditto. 781 | _.throttle = function(func, wait, options) { 782 | var context, args, result; 783 | var timeout = null; 784 | var previous = 0; 785 | if (!options) options = {}; 786 | var later = function() { 787 | previous = options.leading === false ? 0 : _.now(); 788 | timeout = null; 789 | result = func.apply(context, args); 790 | if (!timeout) context = args = null; 791 | }; 792 | return function() { 793 | var now = _.now(); 794 | if (!previous && options.leading === false) previous = now; 795 | var remaining = wait - (now - previous); 796 | context = this; 797 | args = arguments; 798 | if (remaining <= 0 || remaining > wait) { 799 | if (timeout) { 800 | clearTimeout(timeout); 801 | timeout = null; 802 | } 803 | previous = now; 804 | result = func.apply(context, args); 805 | if (!timeout) context = args = null; 806 | } else if (!timeout && options.trailing !== false) { 807 | timeout = setTimeout(later, remaining); 808 | } 809 | return result; 810 | }; 811 | }; 812 | 813 | // Returns a function, that, as long as it continues to be invoked, will not 814 | // be triggered. The function will be called after it stops being called for 815 | // N milliseconds. If `immediate` is passed, trigger the function on the 816 | // leading edge, instead of the trailing. 817 | _.debounce = function(func, wait, immediate) { 818 | var timeout, args, context, timestamp, result; 819 | 820 | var later = function() { 821 | var last = _.now() - timestamp; 822 | 823 | if (last < wait && last >= 0) { 824 | timeout = setTimeout(later, wait - last); 825 | } else { 826 | timeout = null; 827 | if (!immediate) { 828 | result = func.apply(context, args); 829 | if (!timeout) context = args = null; 830 | } 831 | } 832 | }; 833 | 834 | return function() { 835 | context = this; 836 | args = arguments; 837 | timestamp = _.now(); 838 | var callNow = immediate && !timeout; 839 | if (!timeout) timeout = setTimeout(later, wait); 840 | if (callNow) { 841 | result = func.apply(context, args); 842 | context = args = null; 843 | } 844 | 845 | return result; 846 | }; 847 | }; 848 | 849 | // Returns the first function passed as an argument to the second, 850 | // allowing you to adjust arguments, run code before and after, and 851 | // conditionally execute the original function. 852 | _.wrap = function(func, wrapper) { 853 | return _.partial(wrapper, func); 854 | }; 855 | 856 | // Returns a negated version of the passed-in predicate. 857 | _.negate = function(predicate) { 858 | return function() { 859 | return !predicate.apply(this, arguments); 860 | }; 861 | }; 862 | 863 | // Returns a function that is the composition of a list of functions, each 864 | // consuming the return value of the function that follows. 865 | _.compose = function() { 866 | var args = arguments; 867 | var start = args.length - 1; 868 | return function() { 869 | var i = start; 870 | var result = args[start].apply(this, arguments); 871 | while (i--) result = args[i].call(this, result); 872 | return result; 873 | }; 874 | }; 875 | 876 | // Returns a function that will only be executed on and after the Nth call. 877 | _.after = function(times, func) { 878 | return function() { 879 | if (--times < 1) { 880 | return func.apply(this, arguments); 881 | } 882 | }; 883 | }; 884 | 885 | // Returns a function that will only be executed up to (but not including) the Nth call. 886 | _.before = function(times, func) { 887 | var memo; 888 | return function() { 889 | if (--times > 0) { 890 | memo = func.apply(this, arguments); 891 | } 892 | if (times <= 1) func = null; 893 | return memo; 894 | }; 895 | }; 896 | 897 | // Returns a function that will be executed at most one time, no matter how 898 | // often you call it. Useful for lazy initialization. 899 | _.once = _.partial(_.before, 2); 900 | 901 | // Object Functions 902 | // ---------------- 903 | 904 | // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. 905 | var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); 906 | var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', 907 | 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; 908 | 909 | function collectNonEnumProps(obj, keys) { 910 | var nonEnumIdx = nonEnumerableProps.length; 911 | var constructor = obj.constructor; 912 | var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto; 913 | 914 | // Constructor is a special case. 915 | var prop = 'constructor'; 916 | if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop); 917 | 918 | while (nonEnumIdx--) { 919 | prop = nonEnumerableProps[nonEnumIdx]; 920 | if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) { 921 | keys.push(prop); 922 | } 923 | } 924 | } 925 | 926 | // Retrieve the names of an object's own properties. 927 | // Delegates to **ECMAScript 5**'s native `Object.keys` 928 | _.keys = function(obj) { 929 | if (!_.isObject(obj)) return []; 930 | if (nativeKeys) return nativeKeys(obj); 931 | var keys = []; 932 | for (var key in obj) if (_.has(obj, key)) keys.push(key); 933 | // Ahem, IE < 9. 934 | if (hasEnumBug) collectNonEnumProps(obj, keys); 935 | return keys; 936 | }; 937 | 938 | // Retrieve all the property names of an object. 939 | _.allKeys = function(obj) { 940 | if (!_.isObject(obj)) return []; 941 | var keys = []; 942 | for (var key in obj) keys.push(key); 943 | // Ahem, IE < 9. 944 | if (hasEnumBug) collectNonEnumProps(obj, keys); 945 | return keys; 946 | }; 947 | 948 | // Retrieve the values of an object's properties. 949 | _.values = function(obj) { 950 | var keys = _.keys(obj); 951 | var length = keys.length; 952 | var values = Array(length); 953 | for (var i = 0; i < length; i++) { 954 | values[i] = obj[keys[i]]; 955 | } 956 | return values; 957 | }; 958 | 959 | // Returns the results of applying the iteratee to each element of the object 960 | // In contrast to _.map it returns an object 961 | _.mapObject = function(obj, iteratee, context) { 962 | iteratee = cb(iteratee, context); 963 | var keys = _.keys(obj), 964 | length = keys.length, 965 | results = {}, 966 | currentKey; 967 | for (var index = 0; index < length; index++) { 968 | currentKey = keys[index]; 969 | results[currentKey] = iteratee(obj[currentKey], currentKey, obj); 970 | } 971 | return results; 972 | }; 973 | 974 | // Convert an object into a list of `[key, value]` pairs. 975 | _.pairs = function(obj) { 976 | var keys = _.keys(obj); 977 | var length = keys.length; 978 | var pairs = Array(length); 979 | for (var i = 0; i < length; i++) { 980 | pairs[i] = [keys[i], obj[keys[i]]]; 981 | } 982 | return pairs; 983 | }; 984 | 985 | // Invert the keys and values of an object. The values must be serializable. 986 | _.invert = function(obj) { 987 | var result = {}; 988 | var keys = _.keys(obj); 989 | for (var i = 0, length = keys.length; i < length; i++) { 990 | result[obj[keys[i]]] = keys[i]; 991 | } 992 | return result; 993 | }; 994 | 995 | // Return a sorted list of the function names available on the object. 996 | // Aliased as `methods` 997 | _.functions = _.methods = function(obj) { 998 | var names = []; 999 | for (var key in obj) { 1000 | if (_.isFunction(obj[key])) names.push(key); 1001 | } 1002 | return names.sort(); 1003 | }; 1004 | 1005 | // Extend a given object with all the properties in passed-in object(s). 1006 | _.extend = createAssigner(_.allKeys); 1007 | 1008 | // Assigns a given object with all the own properties in the passed-in object(s) 1009 | // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) 1010 | _.extendOwn = _.assign = createAssigner(_.keys); 1011 | 1012 | // Returns the first key on an object that passes a predicate test 1013 | _.findKey = function(obj, predicate, context) { 1014 | predicate = cb(predicate, context); 1015 | var keys = _.keys(obj), key; 1016 | for (var i = 0, length = keys.length; i < length; i++) { 1017 | key = keys[i]; 1018 | if (predicate(obj[key], key, obj)) return key; 1019 | } 1020 | }; 1021 | 1022 | // Return a copy of the object only containing the whitelisted properties. 1023 | _.pick = function(object, oiteratee, context) { 1024 | var result = {}, obj = object, iteratee, keys; 1025 | if (obj == null) return result; 1026 | if (_.isFunction(oiteratee)) { 1027 | keys = _.allKeys(obj); 1028 | iteratee = optimizeCb(oiteratee, context); 1029 | } else { 1030 | keys = flatten(arguments, false, false, 1); 1031 | iteratee = function(value, key, obj) { return key in obj; }; 1032 | obj = Object(obj); 1033 | } 1034 | for (var i = 0, length = keys.length; i < length; i++) { 1035 | var key = keys[i]; 1036 | var value = obj[key]; 1037 | if (iteratee(value, key, obj)) result[key] = value; 1038 | } 1039 | return result; 1040 | }; 1041 | 1042 | // Return a copy of the object without the blacklisted properties. 1043 | _.omit = function(obj, iteratee, context) { 1044 | if (_.isFunction(iteratee)) { 1045 | iteratee = _.negate(iteratee); 1046 | } else { 1047 | var keys = _.map(flatten(arguments, false, false, 1), String); 1048 | iteratee = function(value, key) { 1049 | return !_.contains(keys, key); 1050 | }; 1051 | } 1052 | return _.pick(obj, iteratee, context); 1053 | }; 1054 | 1055 | // Fill in a given object with default properties. 1056 | _.defaults = createAssigner(_.allKeys, true); 1057 | 1058 | // Creates an object that inherits from the given prototype object. 1059 | // If additional properties are provided then they will be added to the 1060 | // created object. 1061 | _.create = function(prototype, props) { 1062 | var result = baseCreate(prototype); 1063 | if (props) _.extendOwn(result, props); 1064 | return result; 1065 | }; 1066 | 1067 | // Create a (shallow-cloned) duplicate of an object. 1068 | _.clone = function(obj) { 1069 | if (!_.isObject(obj)) return obj; 1070 | return _.isArray(obj) ? obj.slice() : _.extend({}, obj); 1071 | }; 1072 | 1073 | // Invokes interceptor with the obj, and then returns obj. 1074 | // The primary purpose of this method is to "tap into" a method chain, in 1075 | // order to perform operations on intermediate results within the chain. 1076 | _.tap = function(obj, interceptor) { 1077 | interceptor(obj); 1078 | return obj; 1079 | }; 1080 | 1081 | // Returns whether an object has a given set of `key:value` pairs. 1082 | _.isMatch = function(object, attrs) { 1083 | var keys = _.keys(attrs), length = keys.length; 1084 | if (object == null) return !length; 1085 | var obj = Object(object); 1086 | for (var i = 0; i < length; i++) { 1087 | var key = keys[i]; 1088 | if (attrs[key] !== obj[key] || !(key in obj)) return false; 1089 | } 1090 | return true; 1091 | }; 1092 | 1093 | 1094 | // Internal recursive comparison function for `isEqual`. 1095 | var eq = function(a, b, aStack, bStack) { 1096 | // Identical objects are equal. `0 === -0`, but they aren't identical. 1097 | // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). 1098 | if (a === b) return a !== 0 || 1 / a === 1 / b; 1099 | // A strict comparison is necessary because `null == undefined`. 1100 | if (a == null || b == null) return a === b; 1101 | // Unwrap any wrapped objects. 1102 | if (a instanceof _) a = a._wrapped; 1103 | if (b instanceof _) b = b._wrapped; 1104 | // Compare `[[Class]]` names. 1105 | var className = toString.call(a); 1106 | if (className !== toString.call(b)) return false; 1107 | switch (className) { 1108 | // Strings, numbers, regular expressions, dates, and booleans are compared by value. 1109 | case '[object RegExp]': 1110 | // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i') 1111 | case '[object String]': 1112 | // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is 1113 | // equivalent to `new String("5")`. 1114 | return '' + a === '' + b; 1115 | case '[object Number]': 1116 | // `NaN`s are equivalent, but non-reflexive. 1117 | // Object(NaN) is equivalent to NaN 1118 | if (+a !== +a) return +b !== +b; 1119 | // An `egal` comparison is performed for other numeric values. 1120 | return +a === 0 ? 1 / +a === 1 / b : +a === +b; 1121 | case '[object Date]': 1122 | case '[object Boolean]': 1123 | // Coerce dates and booleans to numeric primitive values. Dates are compared by their 1124 | // millisecond representations. Note that invalid dates with millisecond representations 1125 | // of `NaN` are not equivalent. 1126 | return +a === +b; 1127 | } 1128 | 1129 | var areArrays = className === '[object Array]'; 1130 | if (!areArrays) { 1131 | if (typeof a != 'object' || typeof b != 'object') return false; 1132 | 1133 | // Objects with different constructors are not equivalent, but `Object`s or `Array`s 1134 | // from different frames are. 1135 | var aCtor = a.constructor, bCtor = b.constructor; 1136 | if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor && 1137 | _.isFunction(bCtor) && bCtor instanceof bCtor) 1138 | && ('constructor' in a && 'constructor' in b)) { 1139 | return false; 1140 | } 1141 | } 1142 | // Assume equality for cyclic structures. The algorithm for detecting cyclic 1143 | // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. 1144 | 1145 | // Initializing stack of traversed objects. 1146 | // It's done here since we only need them for objects and arrays comparison. 1147 | aStack = aStack || []; 1148 | bStack = bStack || []; 1149 | var length = aStack.length; 1150 | while (length--) { 1151 | // Linear search. Performance is inversely proportional to the number of 1152 | // unique nested structures. 1153 | if (aStack[length] === a) return bStack[length] === b; 1154 | } 1155 | 1156 | // Add the first object to the stack of traversed objects. 1157 | aStack.push(a); 1158 | bStack.push(b); 1159 | 1160 | // Recursively compare objects and arrays. 1161 | if (areArrays) { 1162 | // Compare array lengths to determine if a deep comparison is necessary. 1163 | length = a.length; 1164 | if (length !== b.length) return false; 1165 | // Deep compare the contents, ignoring non-numeric properties. 1166 | while (length--) { 1167 | if (!eq(a[length], b[length], aStack, bStack)) return false; 1168 | } 1169 | } else { 1170 | // Deep compare objects. 1171 | var keys = _.keys(a), key; 1172 | length = keys.length; 1173 | // Ensure that both objects contain the same number of properties before comparing deep equality. 1174 | if (_.keys(b).length !== length) return false; 1175 | while (length--) { 1176 | // Deep compare each member 1177 | key = keys[length]; 1178 | if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; 1179 | } 1180 | } 1181 | // Remove the first object from the stack of traversed objects. 1182 | aStack.pop(); 1183 | bStack.pop(); 1184 | return true; 1185 | }; 1186 | 1187 | // Perform a deep comparison to check if two objects are equal. 1188 | _.isEqual = function(a, b) { 1189 | return eq(a, b); 1190 | }; 1191 | 1192 | // Is a given array, string, or object empty? 1193 | // An "empty" object has no enumerable own-properties. 1194 | _.isEmpty = function(obj) { 1195 | if (obj == null) return true; 1196 | if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0; 1197 | return _.keys(obj).length === 0; 1198 | }; 1199 | 1200 | // Is a given value a DOM element? 1201 | _.isElement = function(obj) { 1202 | return !!(obj && obj.nodeType === 1); 1203 | }; 1204 | 1205 | // Is a given value an array? 1206 | // Delegates to ECMA5's native Array.isArray 1207 | _.isArray = nativeIsArray || function(obj) { 1208 | return toString.call(obj) === '[object Array]'; 1209 | }; 1210 | 1211 | // Is a given variable an object? 1212 | _.isObject = function(obj) { 1213 | var type = typeof obj; 1214 | return type === 'function' || type === 'object' && !!obj; 1215 | }; 1216 | 1217 | // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError. 1218 | _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) { 1219 | _['is' + name] = function(obj) { 1220 | return toString.call(obj) === '[object ' + name + ']'; 1221 | }; 1222 | }); 1223 | 1224 | // Define a fallback version of the method in browsers (ahem, IE < 9), where 1225 | // there isn't any inspectable "Arguments" type. 1226 | if (!_.isArguments(arguments)) { 1227 | _.isArguments = function(obj) { 1228 | return _.has(obj, 'callee'); 1229 | }; 1230 | } 1231 | 1232 | // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8, 1233 | // IE 11 (#1621), and in Safari 8 (#1929). 1234 | if (typeof /./ != 'function' && typeof Int8Array != 'object') { 1235 | _.isFunction = function(obj) { 1236 | return typeof obj == 'function' || false; 1237 | }; 1238 | } 1239 | 1240 | // Is a given object a finite number? 1241 | _.isFinite = function(obj) { 1242 | return isFinite(obj) && !isNaN(parseFloat(obj)); 1243 | }; 1244 | 1245 | // Is the given value `NaN`? (NaN is the only number which does not equal itself). 1246 | _.isNaN = function(obj) { 1247 | return _.isNumber(obj) && obj !== +obj; 1248 | }; 1249 | 1250 | // Is a given value a boolean? 1251 | _.isBoolean = function(obj) { 1252 | return obj === true || obj === false || toString.call(obj) === '[object Boolean]'; 1253 | }; 1254 | 1255 | // Is a given value equal to null? 1256 | _.isNull = function(obj) { 1257 | return obj === null; 1258 | }; 1259 | 1260 | // Is a given variable undefined? 1261 | _.isUndefined = function(obj) { 1262 | return obj === void 0; 1263 | }; 1264 | 1265 | // Shortcut function for checking if an object has a given property directly 1266 | // on itself (in other words, not on a prototype). 1267 | _.has = function(obj, key) { 1268 | return obj != null && hasOwnProperty.call(obj, key); 1269 | }; 1270 | 1271 | // Utility Functions 1272 | // ----------------- 1273 | 1274 | // Run Underscore.js in *noConflict* mode, returning the `_` variable to its 1275 | // previous owner. Returns a reference to the Underscore object. 1276 | _.noConflict = function() { 1277 | root._ = previousUnderscore; 1278 | return this; 1279 | }; 1280 | 1281 | // Keep the identity function around for default iteratees. 1282 | _.identity = function(value) { 1283 | return value; 1284 | }; 1285 | 1286 | // Predicate-generating functions. Often useful outside of Underscore. 1287 | _.constant = function(value) { 1288 | return function() { 1289 | return value; 1290 | }; 1291 | }; 1292 | 1293 | _.noop = function(){}; 1294 | 1295 | _.property = property; 1296 | 1297 | // Generates a function for a given object that returns a given property. 1298 | _.propertyOf = function(obj) { 1299 | return obj == null ? function(){} : function(key) { 1300 | return obj[key]; 1301 | }; 1302 | }; 1303 | 1304 | // Returns a predicate for checking whether an object has a given set of 1305 | // `key:value` pairs. 1306 | _.matcher = _.matches = function(attrs) { 1307 | attrs = _.extendOwn({}, attrs); 1308 | return function(obj) { 1309 | return _.isMatch(obj, attrs); 1310 | }; 1311 | }; 1312 | 1313 | // Run a function **n** times. 1314 | _.times = function(n, iteratee, context) { 1315 | var accum = Array(Math.max(0, n)); 1316 | iteratee = optimizeCb(iteratee, context, 1); 1317 | for (var i = 0; i < n; i++) accum[i] = iteratee(i); 1318 | return accum; 1319 | }; 1320 | 1321 | // Return a random integer between min and max (inclusive). 1322 | _.random = function(min, max) { 1323 | if (max == null) { 1324 | max = min; 1325 | min = 0; 1326 | } 1327 | return min + Math.floor(Math.random() * (max - min + 1)); 1328 | }; 1329 | 1330 | // A (possibly faster) way to get the current timestamp as an integer. 1331 | _.now = Date.now || function() { 1332 | return new Date().getTime(); 1333 | }; 1334 | 1335 | // List of HTML entities for escaping. 1336 | var escapeMap = { 1337 | '&': '&', 1338 | '<': '<', 1339 | '>': '>', 1340 | '"': '"', 1341 | "'": ''', 1342 | '`': '`' 1343 | }; 1344 | var unescapeMap = _.invert(escapeMap); 1345 | 1346 | // Functions for escaping and unescaping strings to/from HTML interpolation. 1347 | var createEscaper = function(map) { 1348 | var escaper = function(match) { 1349 | return map[match]; 1350 | }; 1351 | // Regexes for identifying a key that needs to be escaped 1352 | var source = '(?:' + _.keys(map).join('|') + ')'; 1353 | var testRegexp = RegExp(source); 1354 | var replaceRegexp = RegExp(source, 'g'); 1355 | return function(string) { 1356 | string = string == null ? '' : '' + string; 1357 | return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; 1358 | }; 1359 | }; 1360 | _.escape = createEscaper(escapeMap); 1361 | _.unescape = createEscaper(unescapeMap); 1362 | 1363 | // If the value of the named `property` is a function then invoke it with the 1364 | // `object` as context; otherwise, return it. 1365 | _.result = function(object, property, fallback) { 1366 | var value = object == null ? void 0 : object[property]; 1367 | if (value === void 0) { 1368 | value = fallback; 1369 | } 1370 | return _.isFunction(value) ? value.call(object) : value; 1371 | }; 1372 | 1373 | // Generate a unique integer id (unique within the entire client session). 1374 | // Useful for temporary DOM ids. 1375 | var idCounter = 0; 1376 | _.uniqueId = function(prefix) { 1377 | var id = ++idCounter + ''; 1378 | return prefix ? prefix + id : id; 1379 | }; 1380 | 1381 | // By default, Underscore uses ERB-style template delimiters, change the 1382 | // following template settings to use alternative delimiters. 1383 | _.templateSettings = { 1384 | evaluate : /<%([\s\S]+?)%>/g, 1385 | interpolate : /<%=([\s\S]+?)%>/g, 1386 | escape : /<%-([\s\S]+?)%>/g 1387 | }; 1388 | 1389 | // When customizing `templateSettings`, if you don't want to define an 1390 | // interpolation, evaluation or escaping regex, we need one that is 1391 | // guaranteed not to match. 1392 | var noMatch = /(.)^/; 1393 | 1394 | // Certain characters need to be escaped so that they can be put into a 1395 | // string literal. 1396 | var escapes = { 1397 | "'": "'", 1398 | '\\': '\\', 1399 | '\r': 'r', 1400 | '\n': 'n', 1401 | '\u2028': 'u2028', 1402 | '\u2029': 'u2029' 1403 | }; 1404 | 1405 | var escaper = /\\|'|\r|\n|\u2028|\u2029/g; 1406 | 1407 | var escapeChar = function(match) { 1408 | return '\\' + escapes[match]; 1409 | }; 1410 | 1411 | // JavaScript micro-templating, similar to John Resig's implementation. 1412 | // Underscore templating handles arbitrary delimiters, preserves whitespace, 1413 | // and correctly escapes quotes within interpolated code. 1414 | // NB: `oldSettings` only exists for backwards compatibility. 1415 | _.template = function(text, settings, oldSettings) { 1416 | if (!settings && oldSettings) settings = oldSettings; 1417 | settings = _.defaults({}, settings, _.templateSettings); 1418 | 1419 | // Combine delimiters into one regular expression via alternation. 1420 | var matcher = RegExp([ 1421 | (settings.escape || noMatch).source, 1422 | (settings.interpolate || noMatch).source, 1423 | (settings.evaluate || noMatch).source 1424 | ].join('|') + '|$', 'g'); 1425 | 1426 | // Compile the template source, escaping string literals appropriately. 1427 | var index = 0; 1428 | var source = "__p+='"; 1429 | text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { 1430 | source += text.slice(index, offset).replace(escaper, escapeChar); 1431 | index = offset + match.length; 1432 | 1433 | if (escape) { 1434 | source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; 1435 | } else if (interpolate) { 1436 | source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; 1437 | } else if (evaluate) { 1438 | source += "';\n" + evaluate + "\n__p+='"; 1439 | } 1440 | 1441 | // Adobe VMs need the match returned to produce the correct offest. 1442 | return match; 1443 | }); 1444 | source += "';\n"; 1445 | 1446 | // If a variable is not specified, place data values in local scope. 1447 | if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; 1448 | 1449 | source = "var __t,__p='',__j=Array.prototype.join," + 1450 | "print=function(){__p+=__j.call(arguments,'');};\n" + 1451 | source + 'return __p;\n'; 1452 | 1453 | try { 1454 | var render = new Function(settings.variable || 'obj', '_', source); 1455 | } catch (e) { 1456 | e.source = source; 1457 | throw e; 1458 | } 1459 | 1460 | var template = function(data) { 1461 | return render.call(this, data, _); 1462 | }; 1463 | 1464 | // Provide the compiled source as a convenience for precompilation. 1465 | var argument = settings.variable || 'obj'; 1466 | template.source = 'function(' + argument + '){\n' + source + '}'; 1467 | 1468 | return template; 1469 | }; 1470 | 1471 | // Add a "chain" function. Start chaining a wrapped Underscore object. 1472 | _.chain = function(obj) { 1473 | var instance = _(obj); 1474 | instance._chain = true; 1475 | return instance; 1476 | }; 1477 | 1478 | // OOP 1479 | // --------------- 1480 | // If Underscore is called as a function, it returns a wrapped object that 1481 | // can be used OO-style. This wrapper holds altered versions of all the 1482 | // underscore functions. Wrapped objects may be chained. 1483 | 1484 | // Helper function to continue chaining intermediate results. 1485 | var result = function(instance, obj) { 1486 | return instance._chain ? _(obj).chain() : obj; 1487 | }; 1488 | 1489 | // Add your own custom functions to the Underscore object. 1490 | _.mixin = function(obj) { 1491 | _.each(_.functions(obj), function(name) { 1492 | var func = _[name] = obj[name]; 1493 | _.prototype[name] = function() { 1494 | var args = [this._wrapped]; 1495 | push.apply(args, arguments); 1496 | return result(this, func.apply(_, args)); 1497 | }; 1498 | }); 1499 | }; 1500 | 1501 | // Add all of the Underscore functions to the wrapper object. 1502 | _.mixin(_); 1503 | 1504 | // Add all mutator Array functions to the wrapper. 1505 | _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { 1506 | var method = ArrayProto[name]; 1507 | _.prototype[name] = function() { 1508 | var obj = this._wrapped; 1509 | method.apply(obj, arguments); 1510 | if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0]; 1511 | return result(this, obj); 1512 | }; 1513 | }); 1514 | 1515 | // Add all accessor Array functions to the wrapper. 1516 | _.each(['concat', 'join', 'slice'], function(name) { 1517 | var method = ArrayProto[name]; 1518 | _.prototype[name] = function() { 1519 | return result(this, method.apply(this._wrapped, arguments)); 1520 | }; 1521 | }); 1522 | 1523 | // Extracts the result from a wrapped and chained object. 1524 | _.prototype.value = function() { 1525 | return this._wrapped; 1526 | }; 1527 | 1528 | // Provide unwrapping proxy for some methods used in engine operations 1529 | // such as arithmetic and JSON stringification. 1530 | _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; 1531 | 1532 | _.prototype.toString = function() { 1533 | return '' + this._wrapped; 1534 | }; 1535 | 1536 | // AMD registration happens at the end for compatibility with AMD loaders 1537 | // that may not enforce next-turn semantics on modules. Even though general 1538 | // practice for AMD registration is to be anonymous, underscore registers 1539 | // as a named module because, like jQuery, it is a base library that is 1540 | // popular enough to be bundled in a third party lib, but not be part of 1541 | // an AMD load request. Those cases could generate an error when an 1542 | // anonymous define() is called outside of a loader request. 1543 | if (typeof define === 'function' && define.amd) { 1544 | define('underscore', [], function() { 1545 | return _; 1546 | }); 1547 | } 1548 | }.call(this)); 1549 | --------------------------------------------------------------------------------