File tree Expand file tree Collapse file tree 6 files changed +58
-14
lines changed Expand file tree Collapse file tree 6 files changed +58
-14
lines changed Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ <!--
3
+
4
+ This test demonstrates the time difference between document's DOMContentLoaded and window's load events.
5
+
6
+ -->
7
+ < html >
8
+ < head >
9
+ < script >
10
+ startTS = new Date ( ) . getTime ( ) ;
11
+ onDOMContentLoadedTS = 0 ; // default for browsers where DOMCL is not supported
12
+ </ script >
13
+ < title > DOMContentLoaded test</ title >
14
+ < script src ="../build/angular.min.js " ng:autobind > </ script >
15
+ < script >
16
+ angular . element ( document ) . bind ( 'DOMContentLoaded' , function ( e ) { onDOMContentLoadedTS = new Date ( ) . getTime ( ) } ) ;
17
+ angular . element ( window ) . bind ( 'load' , function ( e ) {
18
+ onloadTS = new Date ( ) . getTime ( ) ;
19
+ log . innerHTML = 'start: ' + new Date ( startTS ) + '<br/>DOMContentLoaded: +' + ( onDOMContentLoadedTS - startTS ) + 'ms<br/> load: +' + ( onloadTS - startTS ) + 'ms' ;
20
+ } ) ;
21
+ </ script >
22
+ </ head >
23
+ < body >
24
+ < h1 > DOMContentLoaded test</ h1 >
25
+ < p > {{ 'yay!' || 'angular starting...' }}</ p >
26
+
27
+ < img width ="100px " src ="http://lh5.ggpht.com/_BLyMhylclm0/TST_bbGH0zI/AAAAAAAAATY/oNUn9kivKN8/s912/1020047.jpg " />
28
+ < img width ="100px " src ="http://lh5.ggpht.com/_MqEybfAuUFk/TSOOiegUlPI/AAAAAAAADHY/AEwEWc64_-M/s800/IMG_7294.JPG " />
29
+ < img width ="100px " src ="http://lh3.ggpht.com/_LdjD3ua8rpE/TSOW99rwjZI/AAAAAAAAFC0/0qJRhhN45RM/s912/Saison%2010%20%2834%29.JPG " />
30
+ < img width ="100px " src ="http://lh6.ggpht.com/_oy_-am3CVUw/TSOQBddZpwI/AAAAAAAACaw/ogFgoD79bVE/s912/P1100886.JPG " />
31
+ < img width ="100px " src ="http://lh4.ggpht.com/_srSaA7ZN7oc/TDdxXbA_i1I/AAAAAAAAQ2w/ii3vgrnfCrM/s800/Urlaub10%20157.jpg " />
32
+ < img width ="100px " src ="http://lh5.ggpht.com/_y6vXu6iRrfM/SIaYhRQBYNI/AAAAAAAAAmE/lV2NYwxtsQM/s912/North%20Dakota%20Trip%20014.JPG " />
33
+ < img width ="100px " src ="http://lh5.ggpht.com/_Jjv9cIn9cS8/RuwZCgfOl6I/AAAAAAAAAOc/QrrMe8vpawg/s800/Shark%20Trip%20-%20day%202%20513.JPG " />
34
+
35
+ < p id ="log "> </ p >
36
+ </ body >
37
+ </ html >
Original file line number Diff line number Diff line change 21
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
* THE SOFTWARE.
23
23
*/
24
- (function(window, document, previousOnLoad ){
24
+ (function(window, document){
Original file line number Diff line number Diff line change 1
1
2
- window.onload = function(){
3
- try {
4
- if (previousOnLoad) previousOnLoad();
5
- } catch(e) {}
2
+ jqLite(document).ready(function(){
6
3
angularInit(angularJsConfig(document));
7
- };
4
+ }) ;
8
5
9
- })(window, document, window.onload );
6
+ })(window, document);
Original file line number Diff line number Diff line change @@ -87,6 +87,19 @@ JQLite.prototype = {
87
87
} ) ( this [ 0 ] ) ;
88
88
} ,
89
89
90
+ ready : function ( fn ) {
91
+ var fired = false ;
92
+
93
+ function trigger ( ) {
94
+ if ( fired ) return ;
95
+ fired = true ;
96
+ fn ( ) ;
97
+ }
98
+
99
+ this . bind ( 'DOMContentLoaded' , trigger ) ; // works for modern browsers and IE9
100
+ jqLite ( window ) . bind ( 'load' , trigger ) ; // fallback to window.onload for others
101
+ } ,
102
+
90
103
bind : function ( type , fn ) {
91
104
var self = this ,
92
105
element = self [ 0 ] ,
Original file line number Diff line number Diff line change 21
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
22
* THE SOFTWARE.
23
23
*/
24
- (function(window, document, previousOnLoad ){
24
+ (function(window, document){
25
25
var _jQuery = window.jQuery.noConflict(true);
Original file line number Diff line number Diff line change 1
1
var $scenario = new angular.scenario.Runner(window);
2
2
3
- window.onload = function() {
4
- try {
5
- if (previousOnLoad) previousOnLoad();
6
- } catch(e) {}
3
+ jqLite(document).ready(function() {
7
4
angularScenarioInit($scenario, angularJsConfig(document));
8
- };
5
+ }) ;
9
6
10
- })(window, document, window.onload );
7
+ })(window, document);
You can’t perform that action at this time.
0 commit comments