ninjs 0.14.1 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -2
- data/.travis.yml +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +13 -11
- data/README.md +108 -93
- data/Rakefile +17 -7
- data/VERSION +1 -1
- data/bin/ninjs +24 -22
- data/lib/ninjs/command.rb +32 -21
- data/lib/ninjs/configuration.rb +35 -53
- data/lib/ninjs/generator.rb +6 -6
- data/lib/ninjs/notification.rb +5 -5
- data/lib/ninjs/project.rb +31 -25
- data/ninjs.gemspec +18 -142
- data/repository/ninjs/core/application.js +13 -24
- data/repository/ninjs/core/dom.js +87 -68
- data/repository/ninjs/core/existence.js +44 -105
- data/repository/ninjs/core/extend.js +11 -32
- data/repository/ninjs/core/module.js +53 -107
- data/repository/ninjs/core/nin.js +5 -7
- data/repository/ninjs/tests/extension.test.js +0 -10
- data/repository/ninjs/tests/index.html +19 -20
- data/repository/ninjs/tests/module.test.js +52 -56
- data/repository/ninjs/utilities/array.js +8 -8
- data/repository/ninjs/utilities/cookie.js +59 -0
- data/repository/ninjs/utilities/css.js +7 -7
- data/repository/ninjs/utilities/number.js +2 -2
- data/repository/ninjs/utilities/string.js +26 -26
- data/spec/cli_spec.rb +90 -88
- data/spec/command_spec.rb +104 -137
- data/spec/configuration_spec.rb +23 -37
- data/spec/fixtures/_global.module.js +9 -0
- data/spec/fixtures/compressed.myapp.js +23 -44
- data/spec/fixtures/foo.elements.js +1 -1
- data/spec/fixtures/foo.js +5 -5
- data/spec/fixtures/foo.model.js +1 -1
- data/spec/fixtures/foo.module.js +3 -3
- data/spec/fixtures/hello.elements.js +1 -1
- data/spec/fixtures/hello.js +5 -5
- data/spec/fixtures/hello.model.js +1 -1
- data/spec/fixtures/hello.module.js +3 -3
- data/spec/fixtures/myapp.initial.js +198 -329
- data/spec/fixtures/myapp.js +285 -357
- data/spec/fixtures/mymodule.alias.module.js +2 -2
- data/spec/fixtures/mymodule.dependencies.module.js +2 -2
- data/spec/fixtures/mymodule.elements.js +1 -1
- data/spec/fixtures/mymodule.model.js +1 -1
- data/spec/fixtures/mymodule.module.js +2 -2
- data/spec/fixtures/mymodule.module_alias.module.js +10 -0
- data/spec/fixtures/new.ninjs.conf +2 -0
- data/spec/fixtures/nin.js +198 -329
- data/spec/fixtures/ninjs.conf +2 -0
- data/spec/fixtures/updated.ninjs.conf +8 -0
- data/spec/generator_spec.rb +37 -26
- data/spec/ninjs_spec.rb +6 -6
- data/spec/project_spec.rb +229 -221
- data/spec/spec_helper.rb +3 -1
- data/spec/testspec_spec.rb +7 -0
- metadata +28 -145
- data/repository/json2.js +0 -482
- data/repository/modernizr/1.5.js +0 -28
- data/repository/modernizr/latest.js +0 -1
- data/repository/ninjs/docs/Data/ClassHierarchy.nd +0 -0
- data/repository/ninjs/docs/Data/ConfigFileInfo.nd +0 -0
- data/repository/ninjs/docs/Data/FileInfo.nd +0 -16
- data/repository/ninjs/docs/Data/ImageFileInfo.nd +0 -0
- data/repository/ninjs/docs/Data/ImageReferenceTable.nd +0 -0
- data/repository/ninjs/docs/Data/IndexInfo.nd +0 -0
- data/repository/ninjs/docs/Data/PreviousMenuState.nd +0 -0
- data/repository/ninjs/docs/Data/PreviousSettings.nd +0 -0
- data/repository/ninjs/docs/Data/SymbolTable.nd +0 -0
- data/repository/ninjs/docs/Languages.txt +0 -113
- data/repository/ninjs/docs/Menu.txt +0 -63
- data/repository/ninjs/docs/Topics.txt +0 -81
- data/repository/ninjs/docs/files/core/application-js.html +0 -44
- data/repository/ninjs/docs/files/core/existence-js.html +0 -60
- data/repository/ninjs/docs/files/core/extend-js.html +0 -55
- data/repository/ninjs/docs/files/core/module-js.html +0 -80
- data/repository/ninjs/docs/files/core/nin-js.html +0 -38
- data/repository/ninjs/docs/index.html +0 -1
- data/repository/ninjs/docs/index/Classes.html +0 -33
- data/repository/ninjs/docs/index/Files.html +0 -45
- data/repository/ninjs/docs/index/Functions.html +0 -65
- data/repository/ninjs/docs/index/General.html +0 -85
- data/repository/ninjs/docs/index/Variables.html +0 -45
- data/repository/ninjs/docs/javascript/main.js +0 -841
- data/repository/ninjs/docs/javascript/prettify.js +0 -1526
- data/repository/ninjs/docs/javascript/searchdata.js +0 -152
- data/repository/ninjs/docs/search/ClassesN.html +0 -20
- data/repository/ninjs/docs/search/FilesA.html +0 -20
- data/repository/ninjs/docs/search/FilesE.html +0 -20
- data/repository/ninjs/docs/search/FilesM.html +0 -20
- data/repository/ninjs/docs/search/FilesN.html +0 -20
- data/repository/ninjs/docs/search/FunctionsA.html +0 -20
- data/repository/ninjs/docs/search/FunctionsC.html +0 -20
- data/repository/ninjs/docs/search/FunctionsE.html +0 -20
- data/repository/ninjs/docs/search/FunctionsI.html +0 -20
- data/repository/ninjs/docs/search/FunctionsM.html +0 -20
- data/repository/ninjs/docs/search/FunctionsR.html +0 -20
- data/repository/ninjs/docs/search/FunctionsS.html +0 -20
- data/repository/ninjs/docs/search/FunctionsSymbols.html +0 -20
- data/repository/ninjs/docs/search/FunctionsU.html +0 -20
- data/repository/ninjs/docs/search/GeneralA.html +0 -20
- data/repository/ninjs/docs/search/GeneralC.html +0 -20
- data/repository/ninjs/docs/search/GeneralD.html +0 -20
- data/repository/ninjs/docs/search/GeneralE.html +0 -20
- data/repository/ninjs/docs/search/GeneralF.html +0 -20
- data/repository/ninjs/docs/search/GeneralI.html +0 -20
- data/repository/ninjs/docs/search/GeneralM.html +0 -20
- data/repository/ninjs/docs/search/GeneralN.html +0 -20
- data/repository/ninjs/docs/search/GeneralR.html +0 -20
- data/repository/ninjs/docs/search/GeneralS.html +0 -20
- data/repository/ninjs/docs/search/GeneralSymbols.html +0 -20
- data/repository/ninjs/docs/search/GeneralT.html +0 -20
- data/repository/ninjs/docs/search/GeneralU.html +0 -20
- data/repository/ninjs/docs/search/GeneralV.html +0 -20
- data/repository/ninjs/docs/search/NoResults.html +0 -15
- data/repository/ninjs/docs/search/VariablesD.html +0 -20
- data/repository/ninjs/docs/search/VariablesN.html +0 -20
- data/repository/ninjs/docs/search/VariablesR.html +0 -20
- data/repository/ninjs/docs/search/VariablesT.html +0 -20
- data/repository/ninjs/docs/styles/main.css +0 -828
- data/repository/nullconsole.js +0 -7
- data/repository/qunit/assets/css/qunit.css +0 -196
- data/repository/qunit/qunit.js +0 -1374
- data/repository/selectivizr/1.0.js +0 -5
- data/repository/selectivizr/latest.js +0 -1
- data/repository/syntaxhighlighter/all.js +0 -11
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCore.css +0 -226
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDefault.css +0 -328
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDjango.css +0 -331
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEclipse.css +0 -339
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEmacs.css +0 -324
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMDUltra.css +0 -324
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMidnight.css +0 -324
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreRDark.css +0 -324
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDefault.css +0 -117
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDjango.css +0 -120
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEclipse.css +0 -128
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEmacs.css +0 -113
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMDUltra.css +0 -113
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMidnight.css +0 -113
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeRDark.css +0 -113
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCore.scss +0 -216
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDefault.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDjango.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEclipse.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEmacs.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreFadeToGrey.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMDUltra.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMidnight.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreRDark.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDefault.scss +0 -7
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDjango.scss +0 -36
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEclipse.scss +0 -48
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEmacs.scss +0 -32
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeFadeToGrey.scss +0 -36
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMDUltra.scss +0 -32
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMidnight.scss +0 -32
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeRDark.scss +0 -32
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_theme_template.scss +0 -120
- data/repository/syntaxhighlighter/shAutoloader.js +0 -17
- data/repository/syntaxhighlighter/shBrushAS3.js +0 -59
- data/repository/syntaxhighlighter/shBrushAppleScript.js +0 -75
- data/repository/syntaxhighlighter/shBrushBash.js +0 -59
- data/repository/syntaxhighlighter/shBrushCSharp.js +0 -65
- data/repository/syntaxhighlighter/shBrushColdFusion.js +0 -100
- data/repository/syntaxhighlighter/shBrushCpp.js +0 -97
- data/repository/syntaxhighlighter/shBrushCss.js +0 -91
- data/repository/syntaxhighlighter/shBrushDelphi.js +0 -55
- data/repository/syntaxhighlighter/shBrushDiff.js +0 -41
- data/repository/syntaxhighlighter/shBrushErlang.js +0 -52
- data/repository/syntaxhighlighter/shBrushGroovy.js +0 -67
- data/repository/syntaxhighlighter/shBrushJScript.js +0 -52
- data/repository/syntaxhighlighter/shBrushJava.js +0 -57
- data/repository/syntaxhighlighter/shBrushJavaFX.js +0 -58
- data/repository/syntaxhighlighter/shBrushPerl.js +0 -72
- data/repository/syntaxhighlighter/shBrushPhp.js +0 -88
- data/repository/syntaxhighlighter/shBrushPlain.js +0 -33
- data/repository/syntaxhighlighter/shBrushPowerShell.js +0 -74
- data/repository/syntaxhighlighter/shBrushPython.js +0 -64
- data/repository/syntaxhighlighter/shBrushRuby.js +0 -55
- data/repository/syntaxhighlighter/shBrushSass.js +0 -94
- data/repository/syntaxhighlighter/shBrushScala.js +0 -51
- data/repository/syntaxhighlighter/shBrushSql.js +0 -66
- data/repository/syntaxhighlighter/shBrushVb.js +0 -56
- data/repository/syntaxhighlighter/shBrushXml.js +0 -69
- data/repository/syntaxhighlighter/shCore.js +0 -17
- data/repository/syntaxhighlighter/shLegacy.js +0 -17
data/spec/fixtures/nin.js
CHANGED
@@ -1,170 +1,88 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
return ((suspect === undefined) || (suspect === null)) ? false : true;
|
5
|
-
};
|
6
|
-
}
|
7
|
-
|
8
|
-
if (!is_defined(window.is_undefined)) {
|
9
|
-
window.is_undefined = function(suspect) {
|
10
|
-
return (suspect === undefined) ? true : false;
|
11
|
-
};
|
12
|
-
}
|
13
|
-
|
14
|
-
if (is_undefined(window.is_typeof)) {
|
15
|
-
window.is_typeof = function(type, suspect) {
|
16
|
-
if (is_undefined(type)) {
|
17
|
-
throw new SyntaxError("is_typeof(Type, suspect): type is undefined");
|
18
|
-
}
|
19
|
-
if (is_undefined(suspect)) {
|
20
|
-
throw new SyntaxError("is_typeof(Type, suspect): suspect is undefined");
|
21
|
-
}
|
22
|
-
|
23
|
-
return (suspect.constructor == type) ? true : false;
|
24
|
-
};
|
25
|
-
}
|
1
|
+
is_defined = function(suspect) {
|
2
|
+
return ((suspect === undefined) || (suspect === null)) ? false : true;
|
3
|
+
};
|
26
4
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
return true;
|
31
|
-
}
|
32
|
-
else {
|
33
|
-
var pattern = /^-?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;
|
34
|
-
return pattern.test(suspect);
|
35
|
-
}
|
36
|
-
};
|
37
|
-
}
|
38
|
-
|
39
|
-
if (is_undefined(window.is_string)) {
|
40
|
-
window.is_string = function(suspect) {
|
41
|
-
return is_typeof(String, suspect);
|
42
|
-
};
|
43
|
-
}
|
44
|
-
|
45
|
-
if (is_undefined(window.is_array)) {
|
46
|
-
window.is_array = function(suspect) {
|
47
|
-
return is_typeof(Array, suspect);
|
48
|
-
};
|
49
|
-
}
|
5
|
+
is_undefined = function(suspect) {
|
6
|
+
return (suspect === undefined) ? true : false;
|
7
|
+
};
|
50
8
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
};
|
9
|
+
is_typeof = function(type, suspect) {
|
10
|
+
if (is_undefined(type)) {
|
11
|
+
throw new SyntaxError("is_typeof(Type, suspect): type is undefined");
|
55
12
|
}
|
56
|
-
|
57
|
-
|
58
|
-
window.is_date = function(suspect) {
|
59
|
-
return is_typeof(Date, suspect);
|
60
|
-
};
|
13
|
+
if (is_undefined(suspect)) {
|
14
|
+
throw new SyntaxError("is_typeof(Type, suspect): suspect is undefined");
|
61
15
|
}
|
62
16
|
|
63
|
-
|
64
|
-
|
65
|
-
return is_typeof(Boolean, suspect);
|
66
|
-
};
|
67
|
-
}
|
17
|
+
return (suspect.constructor == type) ? true : false;
|
18
|
+
};
|
68
19
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
};
|
20
|
+
is_numeric = function(suspect) {
|
21
|
+
if(is_typeof(Number, suspect)) {
|
22
|
+
return true;
|
73
23
|
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
window.is_empty = function(suspect) {
|
78
|
-
return suspect.length === 0;
|
79
|
-
};
|
24
|
+
else {
|
25
|
+
var pattern = /^-?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;
|
26
|
+
return pattern.test(suspect);
|
80
27
|
}
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
28
|
+
};
|
29
|
+
|
30
|
+
is_string = function(suspect) {
|
31
|
+
return is_typeof(String, suspect);
|
32
|
+
};
|
33
|
+
|
34
|
+
is_array = function(suspect) {
|
35
|
+
return is_typeof(Array, suspect);
|
36
|
+
};
|
37
|
+
|
38
|
+
is_number = function(suspect) {
|
39
|
+
return is_typeof(Number, suspect);
|
40
|
+
};
|
41
|
+
|
42
|
+
is_date = function(suspect) {
|
43
|
+
return is_typeof(Date, suspect);
|
44
|
+
};
|
45
|
+
|
46
|
+
is_bool = function(suspect) {
|
47
|
+
return is_typeof(Boolean, suspect);
|
48
|
+
};
|
49
|
+
|
50
|
+
is_regex = function(suspect) {
|
51
|
+
return is_typeof(RegExp, suspect);
|
52
|
+
};
|
53
|
+
|
54
|
+
is_empty = function(suspect) {
|
55
|
+
return suspect.length === 0;
|
56
|
+
};
|
57
|
+
|
58
|
+
is_not_empty = function(suspect) {
|
59
|
+
return suspect.length >= 1;
|
60
|
+
};
|
61
|
+
unless = function(expression, callback, fallback) {
|
62
|
+
if (is_undefined(callback)) {
|
63
|
+
throw new SyntaxError("unless(expression, callback[, fallback]): callback is undefined");
|
86
64
|
}
|
87
65
|
|
88
|
-
if (
|
89
|
-
|
90
|
-
if (is_undefined(name)) {
|
91
|
-
throw new SyntaxError("Object.method(name, func): name is undefined");
|
92
|
-
}
|
93
|
-
|
94
|
-
if (is_undefined(func)) {
|
95
|
-
throw new SyntaxError("Object.method(name, func): func is undefined");
|
96
|
-
}
|
97
|
-
|
98
|
-
if (is_undefined(this.prototype[name])) {
|
99
|
-
this.prototype[name] = func;
|
100
|
-
return this;
|
101
|
-
}
|
102
|
-
};
|
66
|
+
if (!!!expression) {
|
67
|
+
callback.call(this);
|
103
68
|
}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
throw new SyntaxError("unless(expression, callback[, fallback]): expression is undefined");
|
109
|
-
}
|
110
|
-
|
111
|
-
if (is_undefined(callback)) {
|
112
|
-
throw new SyntaxError("unless(expression, callback[, fallback]): callback is undefined");
|
113
|
-
}
|
114
|
-
|
115
|
-
if (!expression) {
|
116
|
-
callback.call(this);
|
117
|
-
}
|
118
|
-
else if (is_defined(fallback)) {
|
119
|
-
fallback.call(this);
|
120
|
-
}
|
121
|
-
};
|
122
|
-
}
|
123
|
-
if (is_undefined(Function.prototype['method'])) {
|
124
|
-
Function.prototype.method = function(name, func) {
|
125
|
-
if (is_undefined(name)) {
|
126
|
-
throw new SyntaxError("Object.method(name, func): name is undefined");
|
127
|
-
}
|
128
|
-
|
129
|
-
if (is_undefined(func)) {
|
130
|
-
throw new SyntaxError("Object.method(name, func): func is undefined");
|
131
|
-
}
|
132
|
-
|
133
|
-
if (is_undefined(this.prototype[name])) {
|
134
|
-
this.prototype[name] = func;
|
135
|
-
return this;
|
136
|
-
}
|
137
|
-
};
|
138
|
-
}
|
139
|
-
|
140
|
-
if (is_undefined(window.unless)) {
|
141
|
-
window.unless = function(expression, callback, fallback) {
|
142
|
-
if (is_undefined(expression)) {
|
143
|
-
throw new SyntaxError("unless(expression, callback[, fallback]): expression is undefined");
|
144
|
-
}
|
145
|
-
|
146
|
-
if (is_undefined(callback)) {
|
147
|
-
throw new SyntaxError("unless(expression, callback[, fallback]): callback is undefined");
|
148
|
-
}
|
149
|
-
|
150
|
-
if (!expression) {
|
151
|
-
callback.call(this);
|
152
|
-
}
|
153
|
-
else if (is_defined(fallback)) {
|
154
|
-
fallback.call(this);
|
155
|
-
}
|
156
|
-
};
|
69
|
+
else {
|
70
|
+
if (is_defined(fallback)) {
|
71
|
+
fallback.call(this);
|
72
|
+
}
|
157
73
|
}
|
74
|
+
};
|
75
|
+
var dom = (function() {
|
158
76
|
var userAgent = navigator.userAgent;
|
159
77
|
var browser = {
|
160
78
|
agent: userAgent,
|
161
|
-
mozilla: (/mozilla/.test(userAgent.toLowerCase())) && (
|
79
|
+
mozilla: (/mozilla/.test(userAgent.toLowerCase())) && !(/(compatible|webkit)/.test(userAgent.toLowerCase())),
|
162
80
|
webkit: /webkit/.test(userAgent.toLowerCase()),
|
163
81
|
firefox: /firefox/.test(userAgent.toLowerCase()),
|
164
82
|
chrome: /webkit/.test(userAgent.toLowerCase()),
|
165
83
|
safari: /safari/.test(userAgent.toLowerCase()),
|
166
84
|
opera: /opera/.test(userAgent.toLowerCase()),
|
167
|
-
msie: (/msie/.test(userAgent.toLowerCase())) && (
|
85
|
+
msie: (/msie/.test(userAgent.toLowerCase())) && !(/opera/.test( userAgent.toLowerCase() ))
|
168
86
|
};
|
169
87
|
|
170
88
|
var readyBound = false;
|
@@ -184,23 +102,24 @@
|
|
184
102
|
}
|
185
103
|
|
186
104
|
function addLoadEvent(func) {
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
105
|
+
var oldonload = window.onload;
|
106
|
+
if (typeof window.onload != 'function') {
|
107
|
+
window.onload = func;
|
108
|
+
}
|
109
|
+
else {
|
110
|
+
window.onload = function() {
|
111
|
+
if (oldonload) {
|
112
|
+
oldonload();
|
113
|
+
}
|
114
|
+
func();
|
115
|
+
};
|
116
|
+
}
|
117
|
+
}
|
199
118
|
|
200
119
|
function bindReady() {
|
201
120
|
if (readyBound) {
|
202
|
-
|
203
|
-
|
121
|
+
return;
|
122
|
+
}
|
204
123
|
|
205
124
|
readyBound = true;
|
206
125
|
|
@@ -208,46 +127,55 @@
|
|
208
127
|
document.addEventListener("DOMContentLoaded", domReady, false);
|
209
128
|
}
|
210
129
|
|
211
|
-
if (browser.msie && window == top)
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
130
|
+
if (browser.msie && window == top) {
|
131
|
+
(function() {
|
132
|
+
if (isReady) {
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
try {
|
136
|
+
document.documentElement.doScroll("left");
|
137
|
+
} catch(error) {
|
138
|
+
setTimeout(arguments.callee, 0);
|
139
|
+
return;
|
140
|
+
}
|
141
|
+
domReady();
|
142
|
+
})();
|
143
|
+
}
|
221
144
|
|
222
145
|
if (browser.opera) {
|
223
146
|
document.addEventListener( "DOMContentLoaded", function () {
|
224
|
-
if (isReady)
|
225
|
-
|
147
|
+
if (isReady) {
|
148
|
+
return;
|
149
|
+
}
|
150
|
+
for (var i = 0; i < document.styleSheets.length; i++) {
|
226
151
|
if (document.styleSheets[i].disabled) {
|
227
152
|
setTimeout( arguments.callee, 0 );
|
228
153
|
return;
|
229
154
|
}
|
230
|
-
|
155
|
+
domReady();
|
156
|
+
}
|
231
157
|
}, false);
|
232
158
|
}
|
233
159
|
|
234
160
|
if (browser.safari) {
|
235
|
-
|
236
|
-
(function(){
|
237
|
-
if (isReady)
|
161
|
+
var numStyles;
|
162
|
+
(function() {
|
163
|
+
if (isReady) {
|
164
|
+
return;
|
165
|
+
}
|
238
166
|
if (document.readyState != "loaded" && document.readyState != "complete") {
|
239
167
|
setTimeout( arguments.callee, 0 );
|
240
168
|
return;
|
241
169
|
}
|
242
170
|
if (numStyles === undefined) {
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
171
|
+
var links = document.getElementsByTagName("link");
|
172
|
+
for (var i=0; i < links.length; i++) {
|
173
|
+
if (links[i].getAttribute('rel') == 'stylesheet') {
|
174
|
+
numStyles++;
|
175
|
+
}
|
176
|
+
}
|
177
|
+
var styles = document.getElementsByTagName("style");
|
178
|
+
numStyles += styles.length;
|
251
179
|
}
|
252
180
|
if (document.styleSheets.length != numStyles) {
|
253
181
|
setTimeout( arguments.callee, 0 );
|
@@ -258,171 +186,112 @@
|
|
258
186
|
})();
|
259
187
|
}
|
260
188
|
|
261
|
-
|
262
|
-
}
|
189
|
+
addLoadEvent(domReady);
|
190
|
+
}
|
263
191
|
|
264
|
-
|
265
|
-
|
192
|
+
return {
|
193
|
+
bind: bindReady,
|
194
|
+
is_ready: isReady,
|
195
|
+
ready_list: readyList
|
266
196
|
};
|
197
|
+
})();
|
267
198
|
|
268
|
-
|
269
|
-
|
199
|
+
NinjsDOM = function() {
|
200
|
+
this.cached_selectors = {};
|
201
|
+
};
|
270
202
|
|
271
|
-
|
272
|
-
|
273
|
-
}
|
274
|
-
else {
|
275
|
-
readyList.push( function() { return fn.call(window, []); } );
|
276
|
-
}
|
277
|
-
});
|
203
|
+
NinjsDOM.prototype.ready = function(fn, args) {
|
204
|
+
dom.bind();
|
278
205
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
this.tests = [];
|
287
|
-
};
|
288
|
-
|
289
|
-
NinjsModule.method('actions', function() {});
|
206
|
+
if (dom.is_ready()) {
|
207
|
+
fn.call(window, args || []);
|
208
|
+
}
|
209
|
+
else {
|
210
|
+
dom.ready_list.push( function() { return fn.call(window, args || []); } );
|
211
|
+
}
|
212
|
+
};
|
290
213
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
214
|
+
dom.bind();
|
215
|
+
NinjsModule = function(name) {
|
216
|
+
this.dom = new NinjsDOM(this);
|
217
|
+
this.data = {};
|
218
|
+
this.name = name;
|
219
|
+
};
|
297
220
|
|
298
|
-
|
299
|
-
if (this.run_tests) {
|
300
|
-
this._run_tests();
|
301
|
-
}
|
221
|
+
NinjsModule.prototype.actions = function() {};
|
302
222
|
|
303
|
-
|
223
|
+
NinjsModule.prototype.run = function() {
|
224
|
+
var mod = this;
|
225
|
+
this.dom.ready(function() {
|
226
|
+
mod.execute();
|
304
227
|
});
|
228
|
+
};
|
305
229
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
throw new SyntaxError("NinjsModule.elements(elements): elements is undefined");
|
310
|
-
}
|
311
|
-
else if (is_string(elements)) {
|
312
|
-
throw new SyntaxError("NinjsModule.elements(name): name is undefined");
|
313
|
-
}
|
314
|
-
}
|
230
|
+
NinjsModule.prototype.execute = function() {
|
231
|
+
this.actions();
|
232
|
+
};
|
315
233
|
|
316
|
-
|
317
|
-
|
318
|
-
|
234
|
+
NinjsModule.prototype.elements = function(elements) {
|
235
|
+
if (is_undefined(elements)) {
|
236
|
+
if (is_typeof(Object, elements)) {
|
237
|
+
throw new SyntaxError("NinjsModule.elements(elements): elements is undefined");
|
319
238
|
}
|
320
|
-
else {
|
321
|
-
|
322
|
-
dom.ready(function() {
|
323
|
-
for(var key in elements) {
|
324
|
-
if (elements.hasOwnProperty(key)) {
|
325
|
-
dom.cached_selectors[key] = elements[key];
|
326
|
-
}
|
327
|
-
}
|
328
|
-
});
|
329
|
-
}
|
330
|
-
});
|
331
|
-
|
332
|
-
NinjsModule.method('set_data', function(key, value) {
|
333
|
-
if (is_undefined(key)) {
|
334
|
-
throw new SyntaxError('NinjsModule.set_data(key, value): key is undefined');
|
335
|
-
}
|
336
|
-
|
337
|
-
if (is_typeof(String, key) && is_undefined(value)) {
|
338
|
-
throw new SyntaxError('NinjsModule.set_data(key, value): value is undefined');
|
239
|
+
else if (is_string(elements)) {
|
240
|
+
throw new SyntaxError("NinjsModule.elements(name): name is undefined");
|
339
241
|
}
|
242
|
+
}
|
340
243
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
244
|
+
if (is_string(elements)) {
|
245
|
+
var name = elements;
|
246
|
+
return this.dom.cached_selectors[name];
|
247
|
+
}
|
248
|
+
else {
|
249
|
+
var dom = this.dom;
|
250
|
+
dom.ready(function() {
|
251
|
+
for(var key in elements) {
|
252
|
+
if (elements.hasOwnProperty(key)) {
|
253
|
+
dom.cached_selectors[key] = elements[key];
|
254
|
+
}
|
348
255
|
}
|
349
|
-
}
|
350
|
-
|
351
|
-
|
352
|
-
});
|
256
|
+
});
|
257
|
+
}
|
258
|
+
};
|
353
259
|
|
354
|
-
|
355
|
-
|
356
|
-
|
260
|
+
NinjsModule.prototype.set_data = function(key, value) {
|
261
|
+
if (is_undefined(key)) {
|
262
|
+
throw new SyntaxError('NinjsModule.set_data(key, value): key is undefined');
|
263
|
+
}
|
357
264
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
test_template.push('<h1 id="qunit-header">' + this.name + ' module tests</h1>');
|
362
|
-
test_template.push('<h2 id="qunit-banner"></h2>');
|
363
|
-
test_template.push('<h2 id="qunit-userAgent"></h2>');
|
364
|
-
test_template.push('<ol id="qunit-tests"></ol>');
|
365
|
-
test_template.push('</div>');
|
366
|
-
|
367
|
-
var qunit_dependencies = '<script src="' + _.tests_path +'qunit/qunit.js"></script>';
|
368
|
-
$.getScript(_.tests_path + 'qunit/qunit.js');
|
369
|
-
var qunit_styles = '<link rel="stylesheet" href="' + _.tests_path + 'qunit/qunit.css">';
|
370
|
-
$('body').append(qunit_styles);
|
371
|
-
$('body').append(test_template.join("\n"));
|
372
|
-
|
373
|
-
this.tests.each(function(test) {
|
374
|
-
$.getScript(_.tests_path + test + '.test.js', function() {
|
375
|
-
var test_results_dialog = $('.test-results');
|
376
|
-
var height = $(window).height() - 200;
|
377
|
-
var width = $(window).width() - 300;
|
378
|
-
try {
|
379
|
-
test_results_dialog.dialog({
|
380
|
-
width: width,
|
381
|
-
height: height,
|
382
|
-
autoOpen: false,
|
383
|
-
buttons: {
|
384
|
-
"Thanks buddy": function() {
|
385
|
-
test_results_dialog.dialog('close');
|
386
|
-
}
|
387
|
-
}
|
388
|
-
});
|
389
|
-
var failed = $('.failed');
|
390
|
-
console.log(failed.html());
|
391
|
-
test_results_dialog.dialog('open');
|
392
|
-
}
|
393
|
-
catch(error) {
|
394
|
-
alert("Test harness requires jQueryUI");
|
395
|
-
}
|
396
|
-
});
|
397
|
-
});
|
398
|
-
});
|
265
|
+
if (is_typeof(String, key) && is_undefined(value)) {
|
266
|
+
throw new SyntaxError('NinjsModule.set_data(key, value): value is undefined');
|
267
|
+
}
|
399
268
|
|
400
|
-
|
401
|
-
|
402
|
-
|
269
|
+
if (is_typeof(String, key)) {
|
270
|
+
this.data[key] = value;
|
271
|
+
}
|
272
|
+
else if (is_typeof(Object, key)) {
|
273
|
+
var data = key;
|
274
|
+
for(var property in data) {
|
275
|
+
this.data[property] = data[property];
|
403
276
|
}
|
277
|
+
}
|
404
278
|
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
return base_url + path;
|
409
|
-
};
|
410
|
-
}
|
411
|
-
};
|
279
|
+
return this;
|
280
|
+
};
|
281
|
+
NinjsApplication = function() {};
|
412
282
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
283
|
+
NinjsApplication.prototype.add_module = function(name) {
|
284
|
+
if (is_undefined(name)) {
|
285
|
+
throw new SyntaxError("NinjsApplication.add_module(name): name is undefined");
|
286
|
+
}
|
417
287
|
|
418
|
-
|
419
|
-
|
420
|
-
|
288
|
+
if (is_defined(this[name])) {
|
289
|
+
throw new SyntaxError("NinjsApplication.add_module(name): '" + name + "' already declared");
|
290
|
+
}
|
421
291
|
|
422
|
-
|
423
|
-
|
424
|
-
|
292
|
+
if (this.name === name) {
|
293
|
+
throw new SyntaxError("NinjsApplication.add_module(name): a module cannot have the same name as the application");
|
294
|
+
}
|
425
295
|
|
426
|
-
|
427
|
-
|
428
|
-
})();
|
296
|
+
return this[name] = new NinjsModule(name);
|
297
|
+
};
|