From 2430f52bb97fa9d682e5f028c977c5bf94c5ec38 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Fri, 23 Mar 2012 14:03:24 -0700
Subject: chore(module): move files around in preparation for more modules
---
src/directive/a.js | 29 -
src/directive/booleanAttrDirs.js | 314 ----------
src/directive/directives.js | 11 -
src/directive/form.js | 267 ---------
src/directive/input.js | 1194 --------------------------------------
src/directive/ngBind.js | 155 -----
src/directive/ngClass.js | 143 -----
src/directive/ngCloak.js | 61 --
src/directive/ngController.js | 103 ----
src/directive/ngEventDirs.js | 222 -------
src/directive/ngInclude.js | 131 -----
src/directive/ngInit.js | 37 --
src/directive/ngNonBindable.js | 33 --
src/directive/ngPluralize.js | 204 -------
src/directive/ngRepeat.js | 181 ------
src/directive/ngShowHide.js | 80 ---
src/directive/ngStyle.js | 42 --
src/directive/ngSwitch.js | 112 ----
src/directive/ngTransclude.js | 58 --
src/directive/ngView.js | 170 ------
src/directive/script.js | 43 --
src/directive/select.js | 449 --------------
src/directive/style.js | 6 -
23 files changed, 4045 deletions(-)
delete mode 100644 src/directive/a.js
delete mode 100644 src/directive/booleanAttrDirs.js
delete mode 100644 src/directive/directives.js
delete mode 100644 src/directive/form.js
delete mode 100644 src/directive/input.js
delete mode 100644 src/directive/ngBind.js
delete mode 100644 src/directive/ngClass.js
delete mode 100644 src/directive/ngCloak.js
delete mode 100644 src/directive/ngController.js
delete mode 100644 src/directive/ngEventDirs.js
delete mode 100644 src/directive/ngInclude.js
delete mode 100644 src/directive/ngInit.js
delete mode 100644 src/directive/ngNonBindable.js
delete mode 100644 src/directive/ngPluralize.js
delete mode 100644 src/directive/ngRepeat.js
delete mode 100644 src/directive/ngShowHide.js
delete mode 100644 src/directive/ngStyle.js
delete mode 100644 src/directive/ngSwitch.js
delete mode 100644 src/directive/ngTransclude.js
delete mode 100644 src/directive/ngView.js
delete mode 100644 src/directive/script.js
delete mode 100644 src/directive/select.js
delete mode 100644 src/directive/style.js
(limited to 'src/directive')
diff --git a/src/directive/a.js b/src/directive/a.js
deleted file mode 100644
index d96af784..00000000
--- a/src/directive/a.js
+++ /dev/null
@@ -1,29 +0,0 @@
-'use strict';
-
-/*
- * Modifies the default behavior of html A tag, so that the default action is prevented when href
- * attribute is empty.
- *
- * The reasoning for this change is to allow easy creation of action links with ng-click without
- * changing the location or causing page reloads, e.g.:
- * Save
- */
-var htmlAnchorDirective = valueFn({
- restrict: 'E',
- compile: function(element, attr) {
- // turn link into a link in IE
- // but only if it doesn't have name attribute, in which case it's an anchor
- if (!attr.href) {
- attr.$set('href', '');
- }
-
- return function(scope, element) {
- element.bind('click', function(event){
- // if we have no href url, then don't navigate anywhere.
- if (!element.attr('href')) {
- event.preventDefault();
- }
- });
- }
- }
-});
diff --git a/src/directive/booleanAttrDirs.js b/src/directive/booleanAttrDirs.js
deleted file mode 100644
index 7da52db0..00000000
--- a/src/directive/booleanAttrDirs.js
+++ /dev/null
@@ -1,314 +0,0 @@
-'use strict';
-
-/**
- * @ngdoc directive
- * @name angular.module.ng.$compileProvider.directive.ng-href
- * @restrict A
- *
- * @description
- * Using markup like {{hash}} in an href attribute makes
- * the page open to a wrong URL, if the user clicks that link before
- * angular has a chance to replace the {{hash}} with actual URL, the
- * link will be broken and will most likely return a 404 error.
- * The `ng-href` solves this problem by placing the `href` in the
- * `ng-` namespace.
- *
- * The buggy way to write it:
- *
- *
- *
- *
- * The correct way to write it:
- *
- *
- *
- *
- * @element A
- * @param {template} ng-href any string which can contain `{{}}` markup.
- *
- * @example
- * This example uses `link` variable inside `href` attribute:
-
-
-
- link 1 (link, don't reload)
- link 2 (link, don't reload)
- link 3 (link, reload!)
- anchor (link, don't reload)
- anchor (no link)
- link (link, change hash)
-
-
- it('should execute ng-click but not reload when href without value', function() {
- element('#link-1').click();
- expect(input('value').val()).toEqual('1');
- expect(element('#link-1').attr('href')).toBe("");
- });
-
- it('should execute ng-click but not reload when href empty string', function() {
- element('#link-2').click();
- expect(input('value').val()).toEqual('2');
- expect(element('#link-2').attr('href')).toBe("");
- });
-
- it('should execute ng-click and change url when ng-href specified', function() {
- expect(element('#link-3').attr('href')).toBe("/123");
-
- element('#link-3').click();
- expect(browser().window().path()).toEqual('/123');
- });
-
- it('should execute ng-click but not reload when href empty string and name specified', function() {
- element('#link-4').click();
- expect(input('value').val()).toEqual('4');
- expect(element('#link-4').attr('href')).toBe("");
- });
-
- it('should execute ng-click but not reload when no href but name specified', function() {
- element('#link-5').click();
- expect(input('value').val()).toEqual('5');
- expect(element('#link-5').attr('href')).toBe("");
- });
-
- it('should only change url when only ng-href', function() {
- input('value').enter('6');
- expect(element('#link-6').attr('href')).toBe("/6");
-
- element('#link-6').click();
- expect(browser().window().path()).toEqual('/6');
- });
-
-
- */
-
-/**
- * @ngdoc directive
- * @name angular.module.ng.$compileProvider.directive.ng-src
- * @restrict A
- *
- * @description
- * Using markup like `{{hash}}` in a `src` attribute doesn't
- * work right: The browser will fetch from the URL with the literal
- * text `{{hash}}` until replaces the expression inside
- * `{{hash}}`. The `ng-src` attribute solves this problem by placing
- * the `src` attribute in the `ng-` namespace.
- *
- * The buggy way to write it:
- *
- *
- *
- *
- * The correct way to write it:
- *
- *
- *
- *
- * @element IMG
- * @param {template} ng-src any string which can contain `{{}}` markup.
- */
-
-/**
- * @ngdoc directive
- * @name angular.module.ng.$compileProvider.directive.ng-disabled
- * @restrict A
- *
- * @description
- *
- * The following markup will make the button enabled on Chrome/Firefox but not on IE8 and older IEs:
- *
- *
- *
- *
- *
- *
- * The HTML specs do not require browsers to preserve the special attributes such as disabled.
- * (The presence of them means true and absence means false)
- * This prevents the angular compiler from correctly retrieving the binding expression.
- * To solve this problem, we introduce ng-disabled.
- *
- * @example
-
-
- Click me to toggle:
-
-
-
- it('should toggle button', function() {
- expect(element('.doc-example-live :button').prop('disabled')).toBeFalsy();
- input('checked').check();
- expect(element('.doc-example-live :button').prop('disabled')).toBeTruthy();
- });
-
-
- *
- * @element INPUT
- * @param {string} expression Angular expression that will be evaluated.
- */
-
-
-/**
- * @ngdoc directive
- * @name angular.module.ng.$compileProvider.directive.ng-checked
- * @restrict A
- *
- * @description
- * The HTML specs do not require browsers to preserve the special attributes such as checked.
- * (The presence of them means true and absence means false)
- * This prevents the angular compiler from correctly retrieving the binding expression.
- * To solve this problem, we introduce ng-checked.
- * @example
-
-
- Check me to check both:
-
-
-
- it('should check both checkBoxes', function() {
- expect(element('.doc-example-live #checkSlave').prop('checked')).toBeFalsy();
- input('master').check();
- expect(element('.doc-example-live #checkSlave').prop('checked')).toBeTruthy();
- });
-
-
- *
- * @element INPUT
- * @param {string} expression Angular expression that will be evaluated.
- */
-
-
-/**
- * @ngdoc directive
- * @name angular.module.ng.$compileProvider.directive.ng-multiple
- * @restrict A
- *
- * @description
- * The HTML specs do not require browsers to preserve the special attributes such as multiple.
- * (The presence of them means true and absence means false)
- * This prevents the angular compiler from correctly retrieving the binding expression.
- * To solve this problem, we introduce ng-multiple.
- *
- * @example
-
-
- Check me check multiple:
-
-
-
- it('should toggle multiple', function() {
- expect(element('.doc-example-live #select').prop('multiple')).toBeFalsy();
- input('checked').check();
- expect(element('.doc-example-live #select').prop('multiple')).toBeTruthy();
- });
-
-
- *
- * @element SELECT
- * @param {string} expression Angular expression that will be evaluated.
- */
-
-
-/**
- * @ngdoc directive
- * @name angular.module.ng.$compileProvider.directive.ng-readonly
- * @restrict A
- *
- * @description
- * The HTML specs do not require browsers to preserve the special attributes such as readonly.
- * (The presence of them means true and absence means false)
- * This prevents the angular compiler from correctly retrieving the binding expression.
- * To solve this problem, we introduce ng-readonly.
- * @example
-
-
- Check me to make text readonly:
-
-
-
- it('should toggle readonly attr', function() {
- expect(element('.doc-example-live :text').prop('readonly')).toBeFalsy();
- input('checked').check();
- expect(element('.doc-example-live :text').prop('readonly')).toBeTruthy();
- });
-
-
- *
- * @element INPUT
- * @param {string} expression Angular expression that will be evaluated.
- */
-
-
-/**
- * @ngdoc directive
- * @name angular.module.ng.$compileProvider.directive.ng-selected
- * @restrict A
- *
- * @description
- * The HTML specs do not require browsers to preserve the special attributes such as selected.
- * (The presence of them means true and absence means false)
- * This prevents the angular compiler from correctly retrieving the binding expression.
- * To solve this problem, we introduce ng-selected.
- * @example
-
-
- Check me to select:
-
-
-
- it('should select Greetings!', function() {
- expect(element('.doc-example-live #greet').prop('selected')).toBeFalsy();
- input('selected').check();
- expect(element('.doc-example-live #greet').prop('selected')).toBeTruthy();
- });
-
-
- *
- * @element OPTION
- * @param {string} expression Angular expression that will be evaluated.
- */
-
-
-var ngAttributeAliasDirectives = {};
-
-
-// boolean attrs are evaluated
-forEach(BOOLEAN_ATTR, function(propName, attrName) {
- var normalized = directiveNormalize('ng-' + attrName);
- ngAttributeAliasDirectives[normalized] = function() {
- return {
- compile: function(tpl, attr) {
- attr.$observers[attrName] = [];
- return function(scope, element, attr) {
- scope.$watch(attr[normalized], function(value) {
- attr.$set(attrName, value);
- });
- };
- }
- };
- };
-});
-
-
-// ng-src, ng-href are interpolated
-forEach(['src', 'href'], function(attrName) {
- var normalized = directiveNormalize('ng-' + attrName);
- ngAttributeAliasDirectives[normalized] = function() {
- return {
- compile: function(tpl, attr) {
- attr.$observers[attrName] = [];
- return function(scope, element, attr) {
- attr.$observe(normalized, function(value) {
- attr.$set(attrName, value);
- });
- };
- }
- };
- };
-});
diff --git a/src/directive/directives.js b/src/directive/directives.js
deleted file mode 100644
index 123645f9..00000000
--- a/src/directive/directives.js
+++ /dev/null
@@ -1,11 +0,0 @@
-'use strict';
-
-function ngDirective(directive) {
- if (isFunction(directive)) {
- directive = {
- link: directive
- }
- }
- directive.restrict = directive.restrict || 'AC';
- return valueFn(directive);
-};
diff --git a/src/directive/form.js b/src/directive/form.js
deleted file mode 100644
index b6d3f4be..00000000
--- a/src/directive/form.js
+++ /dev/null
@@ -1,267 +0,0 @@
-'use strict';
-
-
-var nullFormCtrl = {
- $addControl: noop,
- $removeControl: noop,
- $setValidity: noop,
- $setDirty: noop
-}
-
-/**
- * @ngdoc object
- * @name angular.module.ng.$compileProvider.directive.form.FormController
- *
- * @property {boolean} $pristine True if user has not interacted with the form yet.
- * @property {boolean} $dirty True if user has already interacted with the form.
- * @property {boolean} $valid True if all of the containg forms and controls are valid.
- * @property {boolean} $invalid True if at least one containing control or form is invalid.
- *
- * @property {Object} $error Is an object hash, containing references to all invalid controls or
- * forms, where:
- *
- * - keys are validation tokens (error names) — such as `REQUIRED`, `URL` or `EMAIL`),
- * - values are arrays of controls or forms that are invalid with given error.
- *
- * @description
- * `FormController` keeps track of all its controls and nested forms as well as state of them,
- * such as being valid/invalid or dirty/pristine.
- *
- * Each {@link angular.module.ng.$compileProvider.directive.form form} directive creates an instance
- * of `FormController`.
- *
- */
-FormController.$inject = ['$element', '$attrs'];
-function FormController(element, attrs) {
- var form = this,
- parentForm = element.parent().controller('form') || nullFormCtrl,
- invalidCount = 0, // used to easily determine if we are valid
- errors = form.$error = {};
-
- // init state
- form.$name = attrs.name;
- form.$dirty = false;
- form.$pristine = true;
- form.$valid = true;
- form.$invalid = false;
-
- parentForm.$addControl(form);
-
- // Setup initial state of the control
- element.addClass(PRISTINE_CLASS);
- toggleValidCss(true);
-
- // convenience method for easy toggling of classes
- function toggleValidCss(isValid, validationErrorKey) {
- validationErrorKey = validationErrorKey ? '-' + snake_case(validationErrorKey, '-') : '';
- element.
- removeClass((isValid ? INVALID_CLASS : VALID_CLASS) + validationErrorKey).
- addClass((isValid ? VALID_CLASS : INVALID_CLASS) + validationErrorKey);
- }
-
- form.$addControl = function(control) {
- if (control.$name && !form.hasOwnProperty(control.$name)) {
- form[control.$name] = control;
- }
- };
-
- form.$removeControl = function(control) {
- if (control.$name && form[control.$name] === control) {
- delete form[control.$name];
- }
- forEach(errors, cleanupControlErrors, control);
- };
-
- form.$setValidity = function(validationToken, isValid, control) {
- if (isValid) {
- cleanupControlErrors(errors[validationToken], validationToken, control);
-
- if (!invalidCount) {
- toggleValidCss(isValid);
- form.$valid = true;
- form.$invalid = false;
- }
- } else {
- if (!invalidCount) {
- toggleValidCss(isValid);
- }
- addControlError(validationToken, control);
-
- form.$valid = false;
- form.$invalid = true;
- }
- };
-
- form.$setDirty = function() {
- element.removeClass(PRISTINE_CLASS).addClass(DIRTY_CLASS);
- form.$dirty = true;
- form.$pristine = false;
- };
-
- function cleanupControlErrors(queue, validationToken, control) {
- if (queue) {
- control = control || this; // so that we can be used in forEach;
- arrayRemove(queue, control);
- if (!queue.length) {
- invalidCount--;
- errors[validationToken] = false;
- toggleValidCss(true, validationToken);
- parentForm.$setValidity(validationToken, true, form);
- }
- }
- }
-
- function addControlError(validationToken, control) {
- var queue = errors[validationToken];
- if (queue) {
- if (includes(queue, control)) return;
- } else {
- errors[validationToken] = queue = [];
- invalidCount++;
- toggleValidCss(false, validationToken);
- parentForm.$setValidity(validationToken, false, form);
- }
- queue.push(control);
- }
-}
-
-
-/**
- * @ngdoc directive
- * @name angular.module.ng.$compileProvider.directive.ng-form
- * @restrict EAC
- *
- * @description
- * Nestable alias of {@link angular.module.ng.$compileProvider.directive.form `form`} directive. HTML
- * does not allow nesting of form elements. It is useful to nest forms, for example if the validity of a
- * sub-group of controls needs to be determined.
- *
- * @param {string=} ng-form|name Name of the form. If specified, the form controller will be published into
- * related scope, under this name.
- *
- */
-
- /**
- * @ngdoc directive
- * @name angular.module.ng.$compileProvider.directive.form
- * @restrict E
- *
- * @description
- * Directive that instantiates
- * {@link angular.module.ng.$compileProvider.directive.form.FormController FormController}.
- *
- * If `name` attribute is specified, the form controller is published onto the current scope under
- * this name.
- *
- * # Alias: {@link angular.module.ng.$compileProvider.directive.ng-form `ng-form`}
- *
- * In angular forms can be nested. This means that the outer form is valid when all of the child
- * forms are valid as well. However browsers do not allow nesting of `