From 5143e7bf065a3cbdf8400cf095b653d51bc83b8f Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 6 Jan 2012 18:10:47 -0800 Subject: feat(module): new module loader --- Rakefile | 23 +++ angularFiles.js | 1 + docs/content/api/angular.module.ngdoc | 54 ------- .../guide/dev_guide.bootstrap.auto_bootstrap.ngdoc | 91 +++-------- .../dev_guide.bootstrap.manual_bootstrap.ngdoc | 2 +- docs/content/guide/dev_guide.bootstrap.ngdoc | 8 +- ...dev_guide.compiler.understanding_compiler.ngdoc | 3 +- .../guide/dev_guide.di.understanding_di.ngdoc | 2 +- .../guide/dev_guide.di.using_di_controllers.ngdoc | 4 +- docs/content/guide/dev_guide.forms.ngdoc | 14 +- docs/content/guide/dev_guide.i18n.ngdoc | 4 +- docs/content/guide/dev_guide.overview.ngdoc | 20 +-- docs/content/guide/dev_guide.templates.ngdoc | 4 +- docs/content/misc/downloading.ngdoc | 4 +- docs/content/misc/started.ngdoc | 11 +- docs/content/tutorial/step_00.ngdoc | 14 +- docs/content/tutorial/step_02.ngdoc | 3 +- docs/content/tutorial/step_07.ngdoc | 3 +- docs/src/templates/doc_widgets.js | 70 ++++----- docs/src/templates/docs.js | 7 +- docs/src/templates/index.html | 3 +- example/personalLog/personalLog.html | 4 +- example/temp.html | 4 +- i18n/e2e/localeTest_cs.html | 4 +- i18n/e2e/localeTest_de.html | 4 +- i18n/e2e/localeTest_en.html | 4 +- i18n/e2e/localeTest_es.html | 4 +- i18n/e2e/localeTest_sk.html | 4 +- i18n/e2e/localeTest_zh.html | 4 +- i18n/locale/angular-locale_am-et.js | 6 +- i18n/locale/angular-locale_am.js | 6 +- i18n/locale/angular-locale_ar-eg.js | 6 +- i18n/locale/angular-locale_ar.js | 6 +- i18n/locale/angular-locale_bg-bg.js | 6 +- i18n/locale/angular-locale_bg.js | 6 +- i18n/locale/angular-locale_bn-bd.js | 6 +- i18n/locale/angular-locale_bn.js | 6 +- i18n/locale/angular-locale_ca-es.js | 6 +- i18n/locale/angular-locale_ca.js | 6 +- i18n/locale/angular-locale_cs-cz.js | 6 +- i18n/locale/angular-locale_cs.js | 6 +- i18n/locale/angular-locale_da-dk.js | 6 +- i18n/locale/angular-locale_da.js | 6 +- i18n/locale/angular-locale_de-at.js | 6 +- i18n/locale/angular-locale_de-be.js | 6 +- i18n/locale/angular-locale_de-ch.js | 6 +- i18n/locale/angular-locale_de-de.js | 6 +- i18n/locale/angular-locale_de-lu.js | 6 +- i18n/locale/angular-locale_de.js | 6 +- i18n/locale/angular-locale_el-gr.js | 6 +- i18n/locale/angular-locale_el-polyton.js | 6 +- i18n/locale/angular-locale_el.js | 6 +- i18n/locale/angular-locale_en-as.js | 6 +- i18n/locale/angular-locale_en-au.js | 6 +- i18n/locale/angular-locale_en-dsrt-us.js | 6 +- i18n/locale/angular-locale_en-dsrt.js | 6 +- i18n/locale/angular-locale_en-gb.js | 6 +- i18n/locale/angular-locale_en-gu.js | 6 +- i18n/locale/angular-locale_en-ie.js | 6 +- i18n/locale/angular-locale_en-in.js | 6 +- i18n/locale/angular-locale_en-iso.js | 6 +- i18n/locale/angular-locale_en-mh.js | 6 +- i18n/locale/angular-locale_en-mp.js | 6 +- i18n/locale/angular-locale_en-sg.js | 6 +- i18n/locale/angular-locale_en-um.js | 6 +- i18n/locale/angular-locale_en-us.js | 6 +- i18n/locale/angular-locale_en-vi.js | 6 +- i18n/locale/angular-locale_en-za.js | 6 +- i18n/locale/angular-locale_en-zz.js | 6 +- i18n/locale/angular-locale_en.js | 6 +- i18n/locale/angular-locale_es-es.js | 6 +- i18n/locale/angular-locale_es.js | 6 +- i18n/locale/angular-locale_et-ee.js | 6 +- i18n/locale/angular-locale_et.js | 6 +- i18n/locale/angular-locale_eu-es.js | 6 +- i18n/locale/angular-locale_eu.js | 6 +- i18n/locale/angular-locale_fa-ir.js | 6 +- i18n/locale/angular-locale_fa.js | 6 +- i18n/locale/angular-locale_fi-fi.js | 6 +- i18n/locale/angular-locale_fi.js | 6 +- i18n/locale/angular-locale_fil-ph.js | 6 +- i18n/locale/angular-locale_fil.js | 6 +- i18n/locale/angular-locale_fr-bl.js | 6 +- i18n/locale/angular-locale_fr-ca.js | 6 +- i18n/locale/angular-locale_fr-fr.js | 6 +- i18n/locale/angular-locale_fr-gp.js | 6 +- i18n/locale/angular-locale_fr-mc.js | 6 +- i18n/locale/angular-locale_fr-mf.js | 6 +- i18n/locale/angular-locale_fr-mq.js | 6 +- i18n/locale/angular-locale_fr-re.js | 6 +- i18n/locale/angular-locale_fr.js | 6 +- i18n/locale/angular-locale_gl-es.js | 6 +- i18n/locale/angular-locale_gl.js | 6 +- i18n/locale/angular-locale_gsw-ch.js | 6 +- i18n/locale/angular-locale_gsw.js | 6 +- i18n/locale/angular-locale_gu-in.js | 6 +- i18n/locale/angular-locale_gu.js | 6 +- i18n/locale/angular-locale_he-il.js | 6 +- i18n/locale/angular-locale_he.js | 6 +- i18n/locale/angular-locale_hi-in.js | 6 +- i18n/locale/angular-locale_hi.js | 6 +- i18n/locale/angular-locale_hr-hr.js | 6 +- i18n/locale/angular-locale_hr.js | 6 +- i18n/locale/angular-locale_hu-hu.js | 6 +- i18n/locale/angular-locale_hu.js | 6 +- i18n/locale/angular-locale_id-id.js | 6 +- i18n/locale/angular-locale_id.js | 6 +- i18n/locale/angular-locale_in.js | 6 +- i18n/locale/angular-locale_is-is.js | 6 +- i18n/locale/angular-locale_is.js | 6 +- i18n/locale/angular-locale_it-it.js | 6 +- i18n/locale/angular-locale_it.js | 6 +- i18n/locale/angular-locale_iw.js | 6 +- i18n/locale/angular-locale_ja-jp.js | 6 +- i18n/locale/angular-locale_ja.js | 6 +- i18n/locale/angular-locale_kn-in.js | 6 +- i18n/locale/angular-locale_kn.js | 6 +- i18n/locale/angular-locale_ko-kr.js | 6 +- i18n/locale/angular-locale_ko.js | 6 +- i18n/locale/angular-locale_ln-cd.js | 6 +- i18n/locale/angular-locale_ln.js | 6 +- i18n/locale/angular-locale_lt-lt.js | 6 +- i18n/locale/angular-locale_lt.js | 6 +- i18n/locale/angular-locale_lv-lv.js | 6 +- i18n/locale/angular-locale_lv.js | 6 +- i18n/locale/angular-locale_ml-in.js | 6 +- i18n/locale/angular-locale_ml.js | 6 +- i18n/locale/angular-locale_mo.js | 6 +- i18n/locale/angular-locale_mr-in.js | 6 +- i18n/locale/angular-locale_mr.js | 6 +- i18n/locale/angular-locale_ms-my.js | 6 +- i18n/locale/angular-locale_ms.js | 6 +- i18n/locale/angular-locale_mt-mt.js | 6 +- i18n/locale/angular-locale_mt.js | 6 +- i18n/locale/angular-locale_nl-nl.js | 6 +- i18n/locale/angular-locale_nl.js | 6 +- i18n/locale/angular-locale_no.js | 6 +- i18n/locale/angular-locale_or-in.js | 6 +- i18n/locale/angular-locale_or.js | 6 +- i18n/locale/angular-locale_pl-pl.js | 6 +- i18n/locale/angular-locale_pl.js | 6 +- i18n/locale/angular-locale_pt-br.js | 6 +- i18n/locale/angular-locale_pt-pt.js | 6 +- i18n/locale/angular-locale_pt.js | 6 +- i18n/locale/angular-locale_ro-ro.js | 6 +- i18n/locale/angular-locale_ro.js | 6 +- i18n/locale/angular-locale_ru-ru.js | 6 +- i18n/locale/angular-locale_ru.js | 6 +- i18n/locale/angular-locale_sk-sk.js | 6 +- i18n/locale/angular-locale_sk.js | 6 +- i18n/locale/angular-locale_sl-si.js | 6 +- i18n/locale/angular-locale_sl.js | 6 +- i18n/locale/angular-locale_sq-al.js | 6 +- i18n/locale/angular-locale_sq.js | 6 +- i18n/locale/angular-locale_sr-cyrl-rs.js | 6 +- i18n/locale/angular-locale_sr-latn-rs.js | 6 +- i18n/locale/angular-locale_sr-rs.js | 6 +- i18n/locale/angular-locale_sr.js | 6 +- i18n/locale/angular-locale_sv-se.js | 6 +- i18n/locale/angular-locale_sv.js | 6 +- i18n/locale/angular-locale_sw-tz.js | 6 +- i18n/locale/angular-locale_sw.js | 6 +- i18n/locale/angular-locale_ta-in.js | 6 +- i18n/locale/angular-locale_ta.js | 6 +- i18n/locale/angular-locale_te-in.js | 6 +- i18n/locale/angular-locale_te.js | 6 +- i18n/locale/angular-locale_th-th.js | 6 +- i18n/locale/angular-locale_th.js | 6 +- i18n/locale/angular-locale_tl-ph.js | 6 +- i18n/locale/angular-locale_tl.js | 6 +- i18n/locale/angular-locale_tr-tr.js | 6 +- i18n/locale/angular-locale_tr.js | 6 +- i18n/locale/angular-locale_uk-ua.js | 6 +- i18n/locale/angular-locale_uk.js | 6 +- i18n/locale/angular-locale_ur-pk.js | 6 +- i18n/locale/angular-locale_ur.js | 6 +- i18n/locale/angular-locale_vi-vn.js | 6 +- i18n/locale/angular-locale_vi.js | 6 +- i18n/locale/angular-locale_zh-cn.js | 6 +- i18n/locale/angular-locale_zh-hans-cn.js | 6 +- i18n/locale/angular-locale_zh-hans.js | 6 +- i18n/locale/angular-locale_zh-hk.js | 6 +- i18n/locale/angular-locale_zh-tw.js | 6 +- i18n/locale/angular-locale_zh.js | 6 +- i18n/src/closureSlurper.js | 17 +-- i18n/src/converter.js | 5 +- perf/DCLvsWindowOnLoad.html | 6 +- src/Angular.js | 120 +++++++++------ src/AngularPublic.js | 80 +++++----- src/Injector.js | 48 ++++-- src/angular-bootstrap.js | 9 +- src/angular-mocks.js | 63 ++++---- src/angular.suffix | 4 +- src/directives.js | 27 ---- src/loader.js | 167 +++++++++++++++++++++ src/loader.prefix | 7 + src/loader.suffix | 20 +++ src/scenario/Application.js | 12 +- src/scenario/angular.suffix | 12 +- test/AngularSpec.js | 163 ++++++-------------- test/InjectorSpec.js | 41 ++++- test/angular-mocksSpec.js | 54 +++---- test/loaderSpec.js | 63 ++++++++ test/scenario/ApplicationSpec.js | 4 +- test/scenario/RunnerSpec.js | 4 +- test/scenario/dslSpec.js | 36 ++--- test/scenario/e2e/widgets.html | 4 +- test/service/cookiesSpec.js | 2 +- test/service/filter/filtersSpec.js | 8 +- test/service/logSpec.js | 2 +- test/widgetsSpec.js | 8 - 211 files changed, 1051 insertions(+), 1242 deletions(-) delete mode 100644 docs/content/api/angular.module.ngdoc mode change 100644 => 100755 i18n/src/closureSlurper.js create mode 100644 src/loader.js create mode 100644 src/loader.prefix create mode 100644 src/loader.suffix create mode 100644 test/loaderSpec.js diff --git a/Rakefile b/Rakefile index e71fd0cf..512d1e73 100644 --- a/Rakefile +++ b/Rakefile @@ -109,6 +109,27 @@ task :compile => [:init, :compile_scenario, :compile_jstd_scenario_adapter] do --js_output_file #{path_to('angular.min.js')}) FileUtils.cp_r 'i18n/locale', path_to('i18n') + + File.open(path_to('angular-loader.js'), 'w') do |f| + concat = 'cat ' + [ + 'src/loader.prefix', + 'src/loader.js', + 'src/loader.suffix'].flatten.join(' ') + + content = %x{#{concat}}. + gsub('"NG_VERSION_FULL"', NG_VERSION.full). + gsub(/^\s*['"]use strict['"];?\s*$/, '') # remove all file-specific strict mode flags + + f.write(content) + end + + %x(java -jar lib/closure-compiler/compiler.jar \ + --compilation_level SIMPLE_OPTIMIZATIONS \ + --language_in ECMASCRIPT5_STRICT \ + --js #{path_to('angular-loader.js')} \ + --js_output_file #{path_to('angular-loader.min.js')}) + + end @@ -134,7 +155,9 @@ task :package => [:clean, :compile, :docs] do ['src/angular-mocks.js', path_to('angular.js'), + path_to('angular-loader.js'), path_to('angular.min.js'), + path_to('angular-loader.min.js'), path_to('angular-scenario.js'), path_to('jstd-scenario-adapter.js'), path_to('jstd-scenario-adapter-config.js'), diff --git a/angularFiles.js b/angularFiles.js index 8d35764b..889d7f52 100644 --- a/angularFiles.js +++ b/angularFiles.js @@ -1,6 +1,7 @@ angularFiles = { 'angularSrc': [ 'src/Angular.js', + 'src/loader.js', 'src/AngularPublic.js', 'src/JSON.js', 'src/Injector.js', diff --git a/docs/content/api/angular.module.ngdoc b/docs/content/api/angular.module.ngdoc deleted file mode 100644 index ccfec6b7..00000000 --- a/docs/content/api/angular.module.ngdoc +++ /dev/null @@ -1,54 +0,0 @@ -@ngdoc overview -@name angular.module -@description - -The angular.module namespace is a global place for registering angular modules. All modules -(angular core or 3rd party) that should be available to an application must be registered in this -namespace. - -# Module - -A module is a function that is used to register new service providers and configure existing -providers. Once a provider is registered, {@link angular.module.AUTO.$injector $injector} will use -it to ask for a service instance when it is resolving a dependency for the first time. - -
-// Declare the module configuration function.
-// The function arguments are fully injectable so that the module function
-// can create new providers or configure existing ones.
-function MyModule($provide, $locationProvider){
-  // see $provide for more information.
-  $provide.value('appName', 'MyCoolApp');
-
-  // Configure existing providers
-  $locationProvider.hashPrefix = '!';
-};
-
- -See: {@link angular.module.AUTO.$provide $provide}, {@link angular.module.ng.$locationProvider $locationProvider}. - -# Registering Module Function - -In your JavaScript file: -
-// Create the angular.module namespace if one does not exist
-// This allows the module code to be loaded before angular.js code.
-if (!window.angular) window.angular = {};
-if (!angular.module) angular.module = {};
-
-angular.module.MyModule = function(){
-  // add configuration code here.
-};
-
- -Then you can refer to your module like this: - -
-var injector = angular.injector('ng', 'MyModule')
-
- -Or - -
-var injector = angular.injector('ng', angular.module.MyModule)
-
diff --git a/docs/content/guide/dev_guide.bootstrap.auto_bootstrap.ngdoc b/docs/content/guide/dev_guide.bootstrap.auto_bootstrap.ngdoc index d461bfb4..ff14a703 100644 --- a/docs/content/guide/dev_guide.bootstrap.auto_bootstrap.ngdoc +++ b/docs/content/guide/dev_guide.bootstrap.auto_bootstrap.ngdoc @@ -2,88 +2,33 @@ @name Developer Guide: Initializing Angular: Automatic Initialization @description -Angular initializes automatically when you load the angular script into your page, specifying -angular's `ng:autobind` attribute with no arguments: - - + + + I can add: {{ 1+2 }}. + + From a high-level view, this is what happens during angular's automatic initialization process: -1. The browser loads the page, and then runs the angular script. - - The `ng:autobind` attribute tells angular to compile and manage the whole HTML document. The -compilation phase is initiated in the page's `onLoad()` handler. Angular doesn't begin processing -the page until after the page load is complete. - -2. Angular finds the root of the HTML document and creates the global variable `angular` in the -global namespace. Everything that angular subsequently creates is bound to fields in this global -object. - -3. Angular walks the DOM looking for angular widgets, directives, and markup (such as `ng:init` or -`ng:repeat`). As angular encounters these, it creates child scopes as necessary and attaches them -to the DOM, registers listeners on those scopes, associates any controller functions with their -data and their part of the view, and ultimately constructs a runnable application. The resulting -app features two-way data-binding and a nice separation between data, presentation, and business -logic. +1. The browser loads the page, and then runs the angular script. Angular waits for the +`DOMContentLoaded` (or 'Load') event to attempt to bootstrap. -4. For the duration of the application session (while the page is loaded), angular monitors the -state of the application, and updates the view and the data model whenever the state of either one -changes. - -For details on how the compiler works, see {@link dev_guide.compiler Angular HTML Compiler}. +2. Angular looks for the `ng:app` directive. If found it then proceeds to compile the DOM element and its children. +Optionally the `ng:app` may specify a {@link api/angular.module module} to load before the compilation. For details on +how the compiler works, see {@link dev_guide.compiler Angular HTML Compiler}. ## Initialization Options -The reason why `ng:autobind` exists is because angular should not assume that the entire HTML +The reason why `ng:app` exists is because angular should not assume that the entire HTML document should be processed just because the `angular.js` script is included. In order to compile -only a part of the document, specify the ID of the element you want to use for angular's root -element as the value of the `ng:autobind` attribute: - - ng:autobind="angularContent" - - -## Auto-bootstrap with `#autobind` - -In some rare cases you can't define the `ng:` prefix before the script tag's attribute (for -example, in some CMS systems). In those situations it is possible to auto-bootstrap angular by -appending `#autobind` to the ` - - -
- Hello {{'world'}}! -
- - - - -As with `ng:autobind`, you can specify an element id that should be exclusively targeted for -compilation as the value of the `#autobind`, for example: `#autobind=angularContent`. - -If angular.js file is being combined with other scripts into a single script file, then all of the -config options above apply to this processed script as well. That means if the contents of -`angular.js` were appended to `all-my-scripts.js`, then the app can be bootstrapped as: - -
-  
-  
-   
-    
-   
-   
-     
- Hello {{'world'}}! -
- - -
- +only a part of the document set the `ng:app` on the root element of this portion. ## Global Angular Object diff --git a/docs/content/guide/dev_guide.bootstrap.manual_bootstrap.ngdoc b/docs/content/guide/dev_guide.bootstrap.manual_bootstrap.ngdoc index c042b2e3..1c934745 100644 --- a/docs/content/guide/dev_guide.bootstrap.manual_bootstrap.ngdoc +++ b/docs/content/guide/dev_guide.bootstrap.manual_bootstrap.ngdoc @@ -7,7 +7,7 @@ angular, but advanced users who want more control over the initialization proces the manual bootstrapping method instead. The best way to get started with manual bootstrapping is to look at the what happens when you use -{@link api/angular.directive.ng:autobind ng:autobind}, by showing each step of the process +{@link api/angular.directive.ng:app ng:app}, by showing each step of the process explicitly.
diff --git a/docs/content/guide/dev_guide.bootstrap.ngdoc b/docs/content/guide/dev_guide.bootstrap.ngdoc
index ed36a543..5b688e3a 100644
--- a/docs/content/guide/dev_guide.bootstrap.ngdoc
+++ b/docs/content/guide/dev_guide.bootstrap.ngdoc
@@ -7,20 +7,20 @@ angular should process and manage the page. To initialize angular you do the fol
 
 * Specify the angular namespace in the `` page
 * Choose which flavor of angular script to load (debug or production)
-* Specify whether or not angular should process and manage the page automatically (`ng:autobind`)
+* Specify whether or not angular should process and manage the page automatically (`ng:app`)
 
 The simplest way to initialize angular is to load the angular script and tell angular to compile
 and manage the whole page. You do this as follows:
 
 
 
-
+
   
     ...
   
   
     ...
-    
+
+
 
  ...
 
diff --git a/docs/content/guide/dev_guide.forms.ngdoc b/docs/content/guide/dev_guide.forms.ngdoc
index db2f88cd..b4e37abd 100644
--- a/docs/content/guide/dev_guide.forms.ngdoc
+++ b/docs/content/guide/dev_guide.forms.ngdoc
@@ -516,9 +516,8 @@ function LoginController() {
 }
 
 describe('LoginController', function() {
-  it('should disable login button when form is invalid', function() {
-    var scope = angular.module.ng.$rootScope.Scope();
-    var loginController = scope.$new(LoginController);
+  it('should disable login button when form is invalid', inject(function($rootScope) {
+    var loginController = $rootScope.$new(LoginController);
 
     // In production the 'loginForm' form instance gets set from the view,
     // but in unit-test we have to set it manually.
@@ -533,7 +532,7 @@ describe('LoginController', function() {
     // Now simulate a valid form
     loginController.loginForm.$emit('$valid', 'MyReason');
     expect(loginController.disableLogin()).toBe(false);
-  });
+  }));
 });
 
@@ -569,9 +568,8 @@ function LoginController(){ } describe('LoginController', function() { - it('should disable login button when form is invalid', function() { - var scope = angular.module.ng.$rootScope.Scope(); - var loginController = scope.$new(LoginController); + it('should disable login button when form is invalid', inject(function($rootScope) { + var loginController = $rootScope.$new(LoginController); var input = angular.element(''); // In production the 'loginForm' form instance gets set from the view, @@ -609,7 +607,7 @@ describe('LoginController', function() { loginController.password = 'abcdef'; // should be valid scope.$digest(); expect(loginController.loginForm.password.$valid).toBe(true); - }); + })); });
diff --git a/docs/content/guide/dev_guide.i18n.ngdoc b/docs/content/guide/dev_guide.i18n.ngdoc index d88715cd..1b9c1cde 100644 --- a/docs/content/guide/dev_guide.i18n.ngdoc +++ b/docs/content/guide/dev_guide.i18n.ngdoc @@ -67,10 +67,10 @@ You can also include the locale specific js file in the index.html page. For exa requires German locale, you would serve index_de-ge.html which will look something like this:
-
+
  
 ….
-   
+   
    
 ….
  
diff --git a/docs/content/guide/dev_guide.overview.ngdoc b/docs/content/guide/dev_guide.overview.ngdoc
index 2e555dd8..3b4d237f 100644
--- a/docs/content/guide/dev_guide.overview.ngdoc
+++ b/docs/content/guide/dev_guide.overview.ngdoc
@@ -79,22 +79,18 @@ easier a web developer's life can if they're using angular:
 Try out the Live Preview above, and then let's walk through the example and describe what's going
 on.
 
-In the `` tag, we add an attribute to let the browser know about the angular namespace:
+In the `` tag, we add an attribute to let the browser know about the angular namespace.
+This ensures angular runs nicely in all major browsers. We also specify that it is an angular
+application with the `ng:app` directive. The `ng:app' will cause the angular to {@link
+dev_guide.bootstrap auto initialize} your application.
 
-        
+        
 
-This ensures angular runs nicely in all major browsers.
+We load the angular using the  ``
 
-1. We load `angular.js`.
-2. The angular {@link api/angular.directive.ng:autobind ng:autobind} directive tells angular to
-{@link dev_guide.compiler compile} and manage the whole HTML document.
-
-    ``
-
-From the `name` attribute of the `` tags, angular automatically sets up two-way data
+From the `ng:model` attribute of the `` tags, angular automatically sets up two-way data
 binding, and we also demonstrate some easy input validation:
 
         Quantity: 
diff --git a/docs/content/guide/dev_guide.templates.ngdoc b/docs/content/guide/dev_guide.templates.ngdoc
index 584fdcfe..561773f1 100644
--- a/docs/content/guide/dev_guide.templates.ngdoc
+++ b/docs/content/guide/dev_guide.templates.ngdoc
@@ -27,7 +27,7 @@ angular {@link dev_guide.compiler.directives directives}, {@link dev_guide.compi
 and {@link dev_guide.expressions expressions}:
 
 
-
+
  
  
    
@@ -35,7 +35,7 @@ and {@link dev_guide.expressions expressions}:
           string expression 'buttonText'
           wrapped in "{{ }}" markup -->
    
-   
+      
     
     
     
diff --git a/docs/content/misc/started.ngdoc b/docs/content/misc/started.ngdoc
index 591fb859..08e37668 100644
--- a/docs/content/misc/started.ngdoc
+++ b/docs/content/misc/started.ngdoc
@@ -27,18 +27,17 @@ Now let's take a closer look at that code, and see what is going on behind
 the scenes.
 
 The first line of interest defines the `ng` namespace, which makes
-AngularJS work across all browsers (especially important for IE):
+AngularJS work across all browsers (especially important for IE). The
+`ng:app` tags tells angular to process the entire HTML when it is loaded:
 
 
-    
+    
 
-The next line downloads the angular script, and instructs angular to process -the entire HTML page when it is loaded: +The next line downloads the angular script:
-    
+    
 
(For details on what happens when angular processes an HTML page, diff --git a/docs/content/tutorial/step_00.ngdoc b/docs/content/tutorial/step_00.ngdoc index b1bdf628..b7f469ff 100644 --- a/docs/content/tutorial/step_00.ngdoc +++ b/docs/content/tutorial/step_00.ngdoc @@ -149,7 +149,7 @@ below. The code contains some key Angular elements that we will need going forwa __`app/index.html`:__
 
-
+
 
   
   my angular app
@@ -159,7 +159,7 @@ __`app/index.html`:__
 
   Nothing here yet!
 
-  
+  
 
 
 
@@ -170,7 +170,7 @@ __`app/index.html`:__ * xmlns declaration - + This `xmlns` declaration for the `ng` namespace must be specified in all Angular applications in order to make Angular work with XHTML and IE versions older than 9 (regardless of whether you are @@ -178,15 +178,15 @@ using XHTML or HTML). * Angular script tag - + diff --git a/docs/content/tutorial/step_07.ngdoc b/docs/content/tutorial/step_07.ngdoc index 1467a8a7..0aebb9fe 100644 --- a/docs/content/tutorial/step_07.ngdoc +++ b/docs/content/tutorial/step_07.ngdoc @@ -103,12 +103,13 @@ route into the layout template, which makes it a perfect fit for our `index.html __`app/index.html`:__
+
 ...
 
 
   
 
-  
+  
   
 
 
diff --git a/docs/src/templates/doc_widgets.js b/docs/src/templates/doc_widgets.js
index eb8f36f6..c130add8 100644
--- a/docs/src/templates/doc_widgets.js
+++ b/docs/src/templates/doc_widgets.js
@@ -13,27 +13,31 @@
 
 
   var HTML_TEMPLATE =
-  '\n' +
-  '\n' +
-  ' \n' +
-  ' \n' +
-  '_HTML_SOURCE_\n' +
-  ' \n' +
-  '';
+    '\n' +
+    '\n' +
+    ' \n' +
+    '_SCRIPT_SOURCE_' +
+    ' \n' +
+    '_HTML_SOURCE_\n' +
+    ' \n' +
+    '';
 
   angular.widget('doc:example', ['$injector', '$element', function($injector, element){
     this.descend(true); //compile the example code
-    var module = element.attr('module');
+    var module = element.attr('module') || '';
 
     //jQuery find() methods in this widget contain primitive selectors on purpose so that we can use
     //jqlite instead. jqlite's find() method currently supports onlt getElementsByTagName!
     var example = element.find('pre').eq(0),  //doc-source
-        exampleSrc = example.text(),
+        scriptSrc = '',
+        htmlSrc = example.text().replace(/]*>([\s\S]+)<\/script>/im, function(_, script) {
+            scriptSrc = script;
+            return '';
+          }),
         showSource = example.attr('source') !== 'false',
         jsfiddle = example.attr('jsfiddle') || true,
         scenario = element.find('pre').eq(1); //doc-scenario
 
-    var code = indent(exampleSrc);
     var tabHtml =
       '
    '; @@ -43,13 +47,12 @@ '
  • Source

  • ' + '
  • ' + jsFiddleButton(jsfiddle) + // may or may not have value - '
  • '; + '
    ';
         }
         // show live preview tab
         tabHtml +=
             '
  • Live Preview

  • ' + - '
  • ' + exampleSrc +'
  • '; + '
  • ' + htmlSrc +'
  • '; // show scenario tab, if present if (scenario.text()) { tabHtml += @@ -62,19 +65,18 @@ tabs.find('li').eq(1).find('pre').text( HTML_TEMPLATE. - replace('_HTML_SOURCE_', code.html). - replace('_MODULE_', (module ? (' ng:module="' + module + '"') : ''))); + replace('_SCRIPT_SOURCE_', scriptSrc ? ' \n' : ''). + replace('_HTML_SOURCE_', indent(htmlSrc, ' ')). + replace('_MODULE_', module ? '="' + module + '"' : '')); element.html(''); element.append(tabs); - var script = (exampleSrc.match(/]*>([\s\S]*)<\/script>/) || [])[1] || ''; - try { if (window.execScript) { // IE - window.execScript(script || '"stupid IE!"'); // IE complains when evaling empty string + window.execScript(scriptSrc || '"stupid IE!"'); // IE complains when evaling empty string } else { - window.eval(script); + window.eval(scriptSrc); } } catch (e) { alert(e); @@ -86,20 +88,20 @@ function jsFiddleButton(jsfiddle) { + var fixJsFiddleIssue132 = true; if (jsfiddle !== 'false') { if(jsfiddle === true) { //dynamically generate a fiddle - var fiddleUrl = 'http://jsfiddle.net/api/post/library/pure/', - fiddleSrc = exampleSrc, - stripIndent = fiddleSrc.match(/^(\s*)/)[1].length; + var fiddleUrl = 'http://jsfiddle.net/api/post/library/pure/'; - //escape closing textarea - fiddleSrc = fiddleSrc.replace(/<\/textarea>/gi,'</textarea>'); - //strip extra indentation - fiddleSrc = fiddleSrc.replace(new RegExp('^\\s{' + stripIndent + '}', 'gm'), ''); + function jsFiddleEscape(text, prefix) { + return indent(text.replace(/<\/textarea>/gi,'</textarea>'), prefix); + } return '
    ' + - '') + + '' + '' + '' + + '' + '' + '
    '; } else { @@ -127,10 +128,10 @@ } }]); - function indent(text) { + function indent(text, prefix) { + prefix = prefix || ''; if (!text) return text; var lines = text.split(/\r?\n/); - var lineNo = []; var i; // remove any leading blank lines @@ -147,10 +148,9 @@ } for (i = 0; i < lines.length; i++) { - lines[i] = ' ' + lines[i].substring(minIndent); - lineNo.push(5 + i); + lines[i] = prefix + lines[i].substring(minIndent); } - return {html: lines.join('\n'), hilite: lineNo.join(',') }; + return lines.join('\n'); } var HTML_TPL = diff --git a/docs/src/templates/docs.js b/docs/src/templates/docs.js index 6b76a953..38a75236 100644 --- a/docs/src/templates/docs.js +++ b/docs/src/templates/docs.js @@ -152,10 +152,7 @@ function TutorialInstructionsCtrl($cookieStore) { }; } -window.angular = window.angular || {}; -angular.module = angular.module || {}; - -angular.module.ngdocs = function($locationProvider, $filterProvider) { +angular.module('ngdocs', [], function($locationProvider, $filterProvider) { $locationProvider.html5Mode(true).hashPrefix('!'); $filterProvider.register('title', function(){ @@ -165,4 +162,4 @@ angular.module.ngdocs = function($locationProvider, $filterProvider) { }); } }); -}; +}); diff --git a/docs/src/templates/index.html b/docs/src/templates/index.html index 8a6dc7a7..9054f095 100644 --- a/docs/src/templates/index.html +++ b/docs/src/templates/index.html @@ -1,6 +1,7 @@ @@ -27,7 +28,7 @@ type: 'text/css'}); addTag('script', {src: 'syntaxhighlighter/syntaxhighlighter-combined.js'}, sync); if (jQuery) addTag('script', {src: 'jquery.min.js'}); - addTag('script', {src: angularPath, 'ng:autobind':'', 'ng:modules':'ngdocs'}, sync); + addTag('script', {src: angularPath}, sync); addTag('script', {src: 'docs-combined.js'}, sync); addTag('script', {src: 'docs-keywords.js'}, sync); diff --git a/example/personalLog/personalLog.html b/example/personalLog/personalLog.html index 4f74a402..bc7e2e25 100644 --- a/example/personalLog/personalLog.html +++ b/example/personalLog/personalLog.html @@ -1,8 +1,8 @@ - + Personal Log - + diff --git a/example/temp.html b/example/temp.html index 41fb4746..e12b4437 100644 --- a/example/temp.html +++ b/example/temp.html @@ -1,8 +1,8 @@ - + angular dev sandbox - + + + + diff --git a/i18n/e2e/localeTest_es.html b/i18n/e2e/localeTest_es.html index 50c8c076..9584e34e 100644 --- a/i18n/e2e/localeTest_es.html +++ b/i18n/e2e/localeTest_es.html @@ -1,9 +1,9 @@ - + locale test - + + + DOMContentLoaded test - + + diff --git a/test/service/cookiesSpec.js b/test/service/cookiesSpec.js index a4db9546..d73923a6 100644 --- a/test/service/cookiesSpec.js +++ b/test/service/cookiesSpec.js @@ -3,7 +3,7 @@ describe('$cookies', function() { beforeEach(inject(function($provide) { $provide.factory('$browser', function(){ - return angular.extend(new angular.module.ngMock.$Browser(), {cookieHash: {preexisting:'oldCookie'}}); + return angular.extend(new angular.mock.$Browser(), {cookieHash: {preexisting:'oldCookie'}}); }); })); diff --git a/test/service/filter/filtersSpec.js b/test/service/filter/filtersSpec.js index 70497a61..40a78558 100644 --- a/test/service/filter/filtersSpec.js +++ b/test/service/filter/filtersSpec.js @@ -187,10 +187,10 @@ describe('filters', function() { describe('date', function() { - var morning = new angular.module.ngMock.TzDate(+5, '2010-09-03T12:05:08.000Z'); //7am - var noon = new angular.module.ngMock.TzDate(+5, '2010-09-03T17:05:08.000Z'); //12pm - var midnight = new angular.module.ngMock.TzDate(+5, '2010-09-03T05:05:08.000Z'); //12am - var earlyDate = new angular.module.ngMock.TzDate(+5, '0001-09-03T05:05:08.000Z'); + var morning = new angular.mock.TzDate(+5, '2010-09-03T12:05:08.000Z'); //7am + var noon = new angular.mock.TzDate(+5, '2010-09-03T17:05:08.000Z'); //12pm + var midnight = new angular.mock.TzDate(+5, '2010-09-03T05:05:08.000Z'); //12am + var earlyDate = new angular.mock.TzDate(+5, '0001-09-03T05:05:08.000Z'); var date; diff --git a/test/service/logSpec.js b/test/service/logSpec.js index a26e190f..ee250b66 100644 --- a/test/service/logSpec.js +++ b/test/service/logSpec.js @@ -13,7 +13,7 @@ describe('$log', function() { $window = {}; logger = ''; $provide.service('$log', $LogProvider); - $provide.value('$exceptionHandler', angular.module.ngMock.rethrow); + $provide.value('$exceptionHandler', angular.mock.rethrow); $provide.value('$window', $window); })); diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index e21eb64a..632724ce 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -501,14 +501,6 @@ describe('widget', function() { expect(element.text()).toBe('a|b|||c||d|'); })); - it('should iterate over all kinds of types', inject(function($rootScope, $compile) { - var element = $compile('
    • {{item}}|
    ')($rootScope); - $rootScope.array = ['a', 1, null, undefined, {}]; - $rootScope.$digest(); - - expect(element.text()).toBe('a|1|||{\n }|'); - })); - it('should iterate over all kinds of types', inject(function($rootScope, $compile) { var element = $compile('
    • {{item}}|
    ')($rootScope); -- cgit v1.2.3