ninjs 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +38 -0
- data/README.textile +1 -1
- data/Rakefile +60 -0
- data/VERSION +1 -0
- data/lib/ninjs.rb +0 -1
- data/lib/ninjs/command.rb +16 -1
- data/lib/ninjs/manifest.rb +1 -1
- data/lib/ninjs/project.rb +74 -91
- data/ninjs.gemspec +305 -104
- data/repository/jquery/fancybox/assets/1.3.1/images/fancybox/jquery.easing-1.3.pack.js +72 -0
- data/repository/jquery/fancybox/assets/1.3.1/scss/fancybox.scss +69 -0
- data/repository/jquery/ui/1.8.7.js +783 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.accordion.css +19 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.all.css +11 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.autocomplete.css +53 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.base.css +11 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.button.css +38 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.core.css +41 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.datepicker.css +68 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.dialog.css +21 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.progressbar.css +11 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.resizable.css +20 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.selectable.css +10 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.slider.css +24 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.tabs.css +18 -0
- data/repository/jquery/ui/assets/1.8.7/css/jqueryui/jquery.ui.theme.css +252 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_222222_256x240.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_2e83ff_256x240.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_454545_256x240.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_888888_256x240.png +0 -0
- data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-icons_cd0a0a_256x240.png +0 -0
- data/repository/jquery/ui/latest.js +1 -0
- data/repository/ninjs/core/.core.pdoc.yaml +0 -0
- data/repository/ninjs/core/.existence.pdoc.yaml +12 -0
- data/repository/ninjs/core/.extend.pdoc.yaml +0 -0
- data/repository/ninjs/core/.nin.pdoc.yaml +0 -0
- data/repository/ninjs/core/application.js +43 -0
- data/repository/ninjs/core/existence.js +221 -11
- data/repository/ninjs/core/extend.js +18 -0
- data/repository/ninjs/core/module.js +230 -0
- data/repository/ninjs/core/nin.js +3 -137
- 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 +16 -0
- 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 +113 -0
- data/repository/ninjs/docs/Menu.txt +63 -0
- data/repository/ninjs/docs/Topics.txt +81 -0
- data/repository/ninjs/docs/files/core/application-js.html +44 -0
- data/repository/ninjs/docs/files/core/existence-js.html +60 -0
- data/repository/ninjs/docs/files/core/extend-js.html +46 -0
- data/repository/ninjs/docs/files/core/module-js.html +80 -0
- data/repository/ninjs/docs/files/core/nin-js.html +38 -0
- data/repository/ninjs/docs/files/existence-js.html +54 -0
- data/repository/ninjs/docs/index.html +1 -0
- data/repository/ninjs/docs/index/Classes.html +33 -0
- data/repository/ninjs/docs/index/Files.html +45 -0
- data/repository/ninjs/docs/index/Functions.html +57 -0
- data/repository/ninjs/docs/index/General.html +77 -0
- data/repository/ninjs/docs/index/Variables.html +45 -0
- data/repository/ninjs/docs/javascript/main.js +841 -0
- data/repository/ninjs/docs/javascript/prettify.js +1526 -0
- data/repository/ninjs/docs/javascript/searchdata.js +152 -0
- data/repository/ninjs/docs/search/ClassesN.html +20 -0
- data/repository/ninjs/docs/search/FilesA.html +20 -0
- data/repository/ninjs/docs/search/FilesE.html +20 -0
- data/repository/ninjs/docs/search/FilesM.html +20 -0
- data/repository/ninjs/docs/search/FilesN.html +20 -0
- data/repository/ninjs/docs/search/FunctionsA.html +20 -0
- data/repository/ninjs/docs/search/FunctionsC.html +20 -0
- data/repository/ninjs/docs/search/FunctionsE.html +20 -0
- data/repository/ninjs/docs/search/FunctionsI.html +20 -0
- data/repository/ninjs/docs/search/FunctionsM.html +20 -0
- data/repository/ninjs/docs/search/FunctionsR.html +20 -0
- data/repository/ninjs/docs/search/FunctionsS.html +20 -0
- data/repository/ninjs/docs/search/GeneralA.html +20 -0
- data/repository/ninjs/docs/search/GeneralC.html +20 -0
- data/repository/ninjs/docs/search/GeneralD.html +20 -0
- data/repository/ninjs/docs/search/GeneralE.html +20 -0
- data/repository/ninjs/docs/search/GeneralF.html +20 -0
- data/repository/ninjs/docs/search/GeneralI.html +20 -0
- data/repository/ninjs/docs/search/GeneralM.html +20 -0
- data/repository/ninjs/docs/search/GeneralN.html +20 -0
- data/repository/ninjs/docs/search/GeneralR.html +20 -0
- data/repository/ninjs/docs/search/GeneralS.html +20 -0
- data/repository/ninjs/docs/search/GeneralT.html +20 -0
- data/repository/ninjs/docs/search/GeneralV.html +20 -0
- data/repository/ninjs/docs/search/NoResults.html +15 -0
- data/repository/ninjs/docs/search/VariablesD.html +20 -0
- data/repository/ninjs/docs/search/VariablesN.html +20 -0
- data/repository/ninjs/docs/search/VariablesR.html +20 -0
- data/repository/ninjs/docs/search/VariablesT.html +20 -0
- data/repository/ninjs/docs/styles/main.css +828 -0
- data/repository/ninjs/docs/styles/mystyles.css +828 -0
- data/repository/ninjs/tests/index.html +6 -6
- data/repository/ninjs/tests/ninjs.test.js +94 -43
- data/repository/ninjs/tests/ninjs.utilities.test.js +6 -18
- data/repository/ninjs/tests/qunit/qunit.css +197 -0
- data/repository/ninjs/tests/qunit/qunit.js +1415 -0
- data/repository/ninjs/utilities/all.js +2 -1
- data/repository/ninjs/utilities/array.js +3 -3
- data/repository/ninjs/utilities/cookie.js +0 -0
- data/repository/ninjs/utilities/number.js +2 -2
- data/repository/ninjs/utilities/string.js +3 -3
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCore.css +226 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDefault.css +328 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDjango.css +331 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEclipse.css +339 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEmacs.css +324 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreFadeToGrey.css +328 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMDUltra.css +324 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMidnight.css +324 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreRDark.css +324 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDefault.css +117 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDjango.css +120 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEclipse.css +128 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEmacs.css +113 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeFadeToGrey.css +117 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMDUltra.css +113 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMidnight.css +113 -0
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeRDark.css +113 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCore.scss +216 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDefault.scss +2 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDjango.scss +2 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEclipse.scss +2 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEmacs.scss +2 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreFadeToGrey.scss +2 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMDUltra.scss +2 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMidnight.scss +2 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreRDark.scss +2 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDefault.scss +7 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDjango.scss +36 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEclipse.scss +48 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEmacs.scss +32 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeFadeToGrey.scss +36 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMDUltra.scss +32 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMidnight.scss +32 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeRDark.scss +32 -0
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_theme_template.scss +120 -0
- data/repository/syntaxhighlighter/default.js +2 -1
- data/repository/syntaxhighlighter/shBrushAppleScript.js +1 -1
- data/repository/syntaxhighlighter/shBrushPerl.js +1 -1
- data/repository/syntaxhighlighter/shBrushPhp.js +4 -4
- metadata +317 -33
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/repository/jquery/ui/assets/1.8.7/images/jqueryui/ui-bg_highlight-soft_75_cccccc_1x100.png
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require "1.8.7"
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
/*
|
2
|
+
File: application.js
|
3
|
+
|
4
|
+
Class: NinjsApplication
|
5
|
+
An NinjsApplication object serves as your application's namespace and includes a utility to add modules to the application object.
|
6
|
+
|
7
|
+
See Also:
|
8
|
+
<NinjsModule>
|
9
|
+
*/
|
10
|
+
var NinjsApplication = function() {
|
11
|
+
if (is_undefined(window._)) {
|
12
|
+
window._ = this;
|
13
|
+
}
|
14
|
+
|
15
|
+
if (is_undefined(window.app)) {
|
16
|
+
window.app = this;
|
17
|
+
}
|
18
|
+
};
|
19
|
+
|
20
|
+
/*
|
21
|
+
Method: add_module
|
22
|
+
Adds a NinjsModule to the application.
|
23
|
+
|
24
|
+
Parameters:
|
25
|
+
name - the name of the module
|
26
|
+
|
27
|
+
> myapp.add_module('my_module');
|
28
|
+
*/
|
29
|
+
NinjsApplication.method('add_module', function(name) {
|
30
|
+
try {
|
31
|
+
if (is_undefined(name)) {
|
32
|
+
throw new SyntaxError("NinjsApplication.add_module(name): name is undefined");
|
33
|
+
}
|
34
|
+
|
35
|
+
if (is_defined(this[name])) {
|
36
|
+
throw new SyntaxError("NinjsApplication.add_module(name): '" + name + "' already declared");
|
37
|
+
}
|
38
|
+
this[name] = new NinjsModule(name);
|
39
|
+
}
|
40
|
+
catch(error) {
|
41
|
+
alert(error.message);
|
42
|
+
}
|
43
|
+
});
|
@@ -1,26 +1,75 @@
|
|
1
|
+
/* File: existence.js */
|
1
2
|
if (is_defined === undefined) {
|
2
|
-
|
3
|
-
|
3
|
+
/*
|
4
|
+
Function: is_defined
|
5
|
+
Checks if a variable is undefined.
|
6
|
+
|
7
|
+
Parameters:
|
8
|
+
suspect - suspect variable to test
|
9
|
+
|
10
|
+
Returns:
|
11
|
+
bool
|
12
|
+
|
13
|
+
See Also:
|
14
|
+
|
15
|
+
<is_undefined>
|
16
|
+
*/
|
17
|
+
var is_defined = function(suspect) {
|
18
|
+
return (suspect === undefined) ? false : true;
|
4
19
|
};
|
5
20
|
}
|
6
21
|
|
7
22
|
if (!is_defined(is_undefined)) {
|
8
|
-
|
9
|
-
|
23
|
+
/*
|
24
|
+
Function: is_undefined
|
25
|
+
Checks if a variable is defined.
|
26
|
+
|
27
|
+
Parameters:
|
28
|
+
suspect - suspect variable to test
|
29
|
+
|
30
|
+
Returns:
|
31
|
+
bool
|
32
|
+
|
33
|
+
See Also:
|
34
|
+
|
35
|
+
<is_defined>
|
36
|
+
*/
|
37
|
+
var is_undefined = function(suspect) {
|
38
|
+
return (suspect === undefined) ? true : false;
|
10
39
|
};
|
11
40
|
}
|
12
41
|
|
13
42
|
if (is_undefined(is_typeof)) {
|
14
|
-
|
43
|
+
/*
|
44
|
+
Function: is_typeof
|
45
|
+
Determine an object's type strictly by comparing constructors.
|
46
|
+
|
47
|
+
Parameters:
|
48
|
+
type - The type you expect (ie. String, Number, Array without quotes: is_typeof(String, 'hello'): // true)
|
49
|
+
suspect - The variable to check against type
|
50
|
+
|
51
|
+
Returns:
|
52
|
+
bool
|
53
|
+
|
54
|
+
See Also:
|
55
|
+
<is_numeric>,
|
56
|
+
<is_string>,
|
57
|
+
<is_array>,
|
58
|
+
<is_number>,
|
59
|
+
<is_date>,
|
60
|
+
<is_bool>,
|
61
|
+
<is_regex>
|
62
|
+
*/
|
63
|
+
var is_typeof = function(type, suspect) {
|
15
64
|
try {
|
16
65
|
if (is_undefined(type)) {
|
17
|
-
throw new SyntaxError("is_typeof(Type,
|
66
|
+
throw new SyntaxError("is_typeof(Type, suspect): type is undefined");
|
18
67
|
}
|
19
|
-
if (is_undefined(
|
20
|
-
throw new SyntaxError("is_typeof(Type,
|
68
|
+
if (is_undefined(suspect)) {
|
69
|
+
throw new SyntaxError("is_typeof(Type, suspect): suspect is undefined");
|
21
70
|
}
|
22
71
|
|
23
|
-
return (
|
72
|
+
return (suspect.constructor == type) ? true : false;
|
24
73
|
}
|
25
74
|
catch(error) {
|
26
75
|
alert(error.message);
|
@@ -28,8 +77,21 @@ if (is_undefined(is_typeof)) {
|
|
28
77
|
};
|
29
78
|
}
|
30
79
|
|
31
|
-
if (is_undefined(
|
32
|
-
|
80
|
+
if (is_undefined(is_numeric)) {
|
81
|
+
/*
|
82
|
+
Function: is_numeric
|
83
|
+
Determine if the suspect string represents a numeric value.
|
84
|
+
|
85
|
+
Parameters:
|
86
|
+
suspect - variable to check for numeric value
|
87
|
+
|
88
|
+
Returns:
|
89
|
+
bool
|
90
|
+
|
91
|
+
See Also:
|
92
|
+
<is_number>
|
93
|
+
*/
|
94
|
+
var is_numeric = function(suspect) {
|
33
95
|
if(is_typeof(Number, suspect)) {
|
34
96
|
return true;
|
35
97
|
}
|
@@ -39,3 +101,151 @@ if (is_undefined(is_mumeric)) {
|
|
39
101
|
}
|
40
102
|
};
|
41
103
|
}
|
104
|
+
|
105
|
+
if (is_undefined(is_string)) {
|
106
|
+
/*
|
107
|
+
Function: is_string
|
108
|
+
Determine the suspect is a String. This is a proxy method for is_typeof(String, suspect).
|
109
|
+
|
110
|
+
Parameters:
|
111
|
+
suspect - supect variable to test
|
112
|
+
|
113
|
+
Returns:
|
114
|
+
bool
|
115
|
+
|
116
|
+
See Also:
|
117
|
+
<is_typeof>,
|
118
|
+
<is_numeric>,
|
119
|
+
<is_array>,
|
120
|
+
<is_number>,
|
121
|
+
<is_date>,
|
122
|
+
<is_bool>,
|
123
|
+
<is_regex>
|
124
|
+
*/
|
125
|
+
var is_string = function(suspect) {
|
126
|
+
return is_typeof(String, suspect);
|
127
|
+
};
|
128
|
+
}
|
129
|
+
|
130
|
+
if (is_undefined(is_array)) {
|
131
|
+
/*
|
132
|
+
Function: is_array
|
133
|
+
Determine if the suspect is an Array. This is a proxy method for is_typeof(Array, suspect).
|
134
|
+
|
135
|
+
Parameters:
|
136
|
+
suspect - suspect variable to test
|
137
|
+
|
138
|
+
Returns:
|
139
|
+
bool
|
140
|
+
|
141
|
+
See Also:
|
142
|
+
<is_typeof>,
|
143
|
+
<is_numeric>,
|
144
|
+
<is_string>,
|
145
|
+
<is_number>,
|
146
|
+
<is_date>,
|
147
|
+
<is_bool>,
|
148
|
+
<is_regex>
|
149
|
+
*/
|
150
|
+
var is_array = function(suspect) {
|
151
|
+
return is_typeof(Array, suspect);
|
152
|
+
};
|
153
|
+
}
|
154
|
+
|
155
|
+
if (is_undefined(is_number)) {
|
156
|
+
/*
|
157
|
+
Function: is_number
|
158
|
+
Determines if the suspect is a Number. This is a proxy method for is_typeof(Number, suspect).
|
159
|
+
|
160
|
+
Parameters:
|
161
|
+
suspect - suspect variable to test
|
162
|
+
|
163
|
+
Returns:
|
164
|
+
bool
|
165
|
+
|
166
|
+
See Also:
|
167
|
+
<is_typeof>,
|
168
|
+
<is_numeric>,
|
169
|
+
<is_string>,
|
170
|
+
<is_array>,
|
171
|
+
<is_date>,
|
172
|
+
<is_bool>,
|
173
|
+
<is_regex>
|
174
|
+
*/
|
175
|
+
var is_number = function(suspect) {
|
176
|
+
return is_typeof(Number, suspect);
|
177
|
+
};
|
178
|
+
}
|
179
|
+
|
180
|
+
if (is_undefined(is_date)) {
|
181
|
+
/*
|
182
|
+
Function: is_date
|
183
|
+
Determines if the suspect is a Date. This is a proxy method for is_typeof(Date, suspect).
|
184
|
+
|
185
|
+
Parameters:
|
186
|
+
suspect - suspect variable to test
|
187
|
+
|
188
|
+
Returns:
|
189
|
+
bool
|
190
|
+
|
191
|
+
See Also:
|
192
|
+
<is_typeof>,
|
193
|
+
<is_numeric>,
|
194
|
+
<is_string>,
|
195
|
+
<is_array>,
|
196
|
+
<is_number>,
|
197
|
+
<is_bool>,
|
198
|
+
<is_regex>
|
199
|
+
*/
|
200
|
+
var is_date = function(suspect) {
|
201
|
+
return is_typeof(Date, suspect);
|
202
|
+
};
|
203
|
+
}
|
204
|
+
|
205
|
+
if (is_undefined(is_bool)) {
|
206
|
+
/*
|
207
|
+
Function: is_bool
|
208
|
+
Determines if the suspect is a Boolean. This is a proxy method for is_typeof(Boolean, suspect).
|
209
|
+
|
210
|
+
Parameters:
|
211
|
+
suspect - suspect variable to test
|
212
|
+
|
213
|
+
Returns:
|
214
|
+
bool
|
215
|
+
|
216
|
+
See Also:
|
217
|
+
<is_typeof>,
|
218
|
+
<is_numeric>,
|
219
|
+
<is_string>,
|
220
|
+
<is_array>,
|
221
|
+
<is_number>,
|
222
|
+
<is_regex>
|
223
|
+
*/
|
224
|
+
var is_bool = function(suspect) {
|
225
|
+
return is_typeof(Boolean, suspect);
|
226
|
+
};
|
227
|
+
}
|
228
|
+
|
229
|
+
if (is_undefined(is_regex)) {
|
230
|
+
/*
|
231
|
+
Function: is_regex
|
232
|
+
Determines if the suspect is a RegExp. This is a proxy method for is_typeof(RegExp, suspect).
|
233
|
+
|
234
|
+
Parameters:
|
235
|
+
suspect - suspect variable to test
|
236
|
+
|
237
|
+
Returns:
|
238
|
+
bool
|
239
|
+
|
240
|
+
See Also:
|
241
|
+
<is_typeof>,
|
242
|
+
<is_numeric>,
|
243
|
+
<is_string>,
|
244
|
+
<is_array>,
|
245
|
+
<is_number>,
|
246
|
+
<is_bool>
|
247
|
+
*/
|
248
|
+
var is_regex = function(suspect) {
|
249
|
+
return is_typeof(RegExp, suspect);
|
250
|
+
};
|
251
|
+
}
|
@@ -1,6 +1,24 @@
|
|
1
|
+
/* File: extend.js */
|
1
2
|
//= require "existence"
|
2
3
|
|
3
4
|
if (is_undefined(Function.prototype['method'])) {
|
5
|
+
/*
|
6
|
+
Function: method
|
7
|
+
Method to add a method to an object (ie. String.method('my_method', my_func); //-> 'hello'.my_func())
|
8
|
+
|
9
|
+
Parameters:
|
10
|
+
name - name of the method
|
11
|
+
func - function definition
|
12
|
+
|
13
|
+
Returns:
|
14
|
+
this === Function
|
15
|
+
|
16
|
+
> String.method('custom_method', function() {
|
17
|
+
> // define custom_method
|
18
|
+
> });
|
19
|
+
>
|
20
|
+
> "hello".custom_method();
|
21
|
+
*/
|
4
22
|
Function.prototype.method = function(name, func) {
|
5
23
|
try {
|
6
24
|
if (is_undefined(name)) {
|
@@ -0,0 +1,230 @@
|
|
1
|
+
/*
|
2
|
+
File: module.js
|
3
|
+
|
4
|
+
Class: NinjsModule
|
5
|
+
A NinjsModule is an object which encapsulates a certain behavior or functionality.
|
6
|
+
|
7
|
+
Parameters:
|
8
|
+
name - the name of the module
|
9
|
+
|
10
|
+
See Also:
|
11
|
+
<NinjsApplication>
|
12
|
+
*/
|
13
|
+
var NinjsModule = function(name) {
|
14
|
+
/*
|
15
|
+
Variable: data
|
16
|
+
The module's data object
|
17
|
+
*/
|
18
|
+
this.data = {};
|
19
|
+
/*
|
20
|
+
Variable: name
|
21
|
+
The module's name (string)
|
22
|
+
*/
|
23
|
+
this.name = name;
|
24
|
+
/*
|
25
|
+
Variable: run_tests (beta)
|
26
|
+
Boolean to turn tests on/off
|
27
|
+
*/
|
28
|
+
this.run_tests = false;
|
29
|
+
/*
|
30
|
+
Variable: tests (beta)
|
31
|
+
Array of test files to run
|
32
|
+
*/
|
33
|
+
this.tests = [];
|
34
|
+
};
|
35
|
+
|
36
|
+
/*
|
37
|
+
Method: actions
|
38
|
+
The actions method contains code to be executed when run is called. This method is a placeholder to be overwritten.
|
39
|
+
|
40
|
+
> MyModule.actions = function() {
|
41
|
+
> // define actions here
|
42
|
+
>};
|
43
|
+
*/
|
44
|
+
NinjsModule.method('actions', function() {});
|
45
|
+
|
46
|
+
|
47
|
+
/*
|
48
|
+
Method: run
|
49
|
+
Waits for the DOM to load then calls execute.
|
50
|
+
|
51
|
+
> MyModule.run();
|
52
|
+
*/
|
53
|
+
NinjsModule.method('run', function() {
|
54
|
+
this.call_on_ready(this.execute);
|
55
|
+
});
|
56
|
+
|
57
|
+
/*
|
58
|
+
Method: call_on_ready
|
59
|
+
Waits for the DOM to be ready and then executes a callback.
|
60
|
+
|
61
|
+
Parameters:
|
62
|
+
callback - function to be called when the DOM is ready
|
63
|
+
|
64
|
+
> MyModule.call_on_ready(function() {
|
65
|
+
> // some code to execute when the DOM is ready
|
66
|
+
> });
|
67
|
+
*/
|
68
|
+
NinjsModule.method('call_on_ready', function(callback) {
|
69
|
+
var timer;
|
70
|
+
var module = this;
|
71
|
+
|
72
|
+
function check_ready() {
|
73
|
+
timer = setInterval(is_ready, 13);
|
74
|
+
}
|
75
|
+
|
76
|
+
function is_ready() {
|
77
|
+
if (document && document.getElementsByTagName && document.getElementById && document.body) {
|
78
|
+
clearInterval(timer);
|
79
|
+
timer = null;
|
80
|
+
callback.call(module);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
check_ready();
|
85
|
+
});
|
86
|
+
|
87
|
+
/*
|
88
|
+
Method: execute
|
89
|
+
Wrapper method that set's up the environment and then calls actions.
|
90
|
+
|
91
|
+
> MyModule.execute();
|
92
|
+
*/
|
93
|
+
NinjsModule.method('execute', function() {
|
94
|
+
// swap out the __ alias
|
95
|
+
this.old__ = is_defined(window.__) ? window.__ : undefined;
|
96
|
+
window.__ = this;
|
97
|
+
|
98
|
+
if (this.run_tests) {
|
99
|
+
this._run_tests();
|
100
|
+
}
|
101
|
+
this.actions();
|
102
|
+
|
103
|
+
// reset the __ alias
|
104
|
+
if(is_defined(this.old__)) {
|
105
|
+
window.__ = this.old__;
|
106
|
+
}
|
107
|
+
});
|
108
|
+
|
109
|
+
/*
|
110
|
+
Method: elements
|
111
|
+
Method to define module elements.
|
112
|
+
|
113
|
+
Parameters:
|
114
|
+
callback - function to define a module's elements
|
115
|
+
|
116
|
+
> MyModule.elements(function() {
|
117
|
+
> // element definitions go here
|
118
|
+
> });
|
119
|
+
*/
|
120
|
+
NinjsModule.method('elements', function(callback) {
|
121
|
+
// swap out the __ alias
|
122
|
+
this.old__ = is_defined(window.__) ? window.__ : undefined;
|
123
|
+
window.__ = this;
|
124
|
+
|
125
|
+
this.call_on_ready(callback);
|
126
|
+
|
127
|
+
// reset the __ alias
|
128
|
+
if(is_defined(this.old__)) {
|
129
|
+
window.__ = this.old__;
|
130
|
+
}
|
131
|
+
});
|
132
|
+
|
133
|
+
|
134
|
+
/*
|
135
|
+
Method: set_data
|
136
|
+
Adds properties to the module's data object.
|
137
|
+
|
138
|
+
Parameters:
|
139
|
+
key - string or object (if string = key, if object sets multiple properties)
|
140
|
+
value - value of key if key is string
|
141
|
+
|
142
|
+
> MyModule.set_data('some_key', 'some_value');
|
143
|
+
> MyModule.data.some_key === 'some_value'
|
144
|
+
|
145
|
+
> MyModule.set_data({
|
146
|
+
> 'property_one': 'value_one',
|
147
|
+
> 'property_two': 'value_two'
|
148
|
+
> });
|
149
|
+
> MyModule.data.property_one === 'value_one'
|
150
|
+
> MyModule.data.property_two === 'value_two'
|
151
|
+
*/
|
152
|
+
NinjsModule.method('set_data', function(key, value) {
|
153
|
+
try {
|
154
|
+
if (is_undefined(key)) {
|
155
|
+
throw new SyntaxError('NinjsModule.set_data(key, value): key is undefined');
|
156
|
+
}
|
157
|
+
|
158
|
+
if (is_typeof(String, key) && is_undefined(value)) {
|
159
|
+
throw new SyntaxError('NinjsModule.set_data(key, value): value is undefined');
|
160
|
+
}
|
161
|
+
|
162
|
+
if (is_typeof(String, key)) {
|
163
|
+
this.data[key] = value;
|
164
|
+
}
|
165
|
+
else if (is_typeof(Object, key)) {
|
166
|
+
var data = key;
|
167
|
+
for(var property in data) {
|
168
|
+
this.data[property] = data[property];
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
return this;
|
173
|
+
}
|
174
|
+
catch(error) {
|
175
|
+
alert(error.message);
|
176
|
+
}
|
177
|
+
});
|
178
|
+
|
179
|
+
/*
|
180
|
+
Method: add_test
|
181
|
+
Adds a test file to the tests array (beta).
|
182
|
+
|
183
|
+
Parameters:
|
184
|
+
test_file - File to add to the tests array
|
185
|
+
|
186
|
+
> MyModule.add_test('mytest.test.js');
|
187
|
+
*/
|
188
|
+
NinjsModule.method('add_test', function(test_file) {
|
189
|
+
this.tests.push(test_file);
|
190
|
+
});
|
191
|
+
|
192
|
+
/*
|
193
|
+
Method: run_tests
|
194
|
+
Runs the test files in the test array. This method is automatically called by the execute method if run_tests === true
|
195
|
+
*/
|
196
|
+
NinjsModule.method('run_tests', function() {
|
197
|
+
var test_template = [];
|
198
|
+
test_template.push('<div class="test-results" title="Test Results">');
|
199
|
+
test_template.push('<h1 id="qunit-header">' + this.name + ' module tests</h1>');
|
200
|
+
test_template.push('<h2 id="qunit-banner"></h2>');
|
201
|
+
test_template.push('<h2 id="qunit-userAgent"></h2>');
|
202
|
+
test_template.push('<ol id="qunit-tests"></ol>');
|
203
|
+
test_template.push('</div>');
|
204
|
+
|
205
|
+
$('body').append(test_template.join("\n"));
|
206
|
+
|
207
|
+
this.tests.each(function(test) {
|
208
|
+
$.getScript('tests/' + some + '.test.js', function() {
|
209
|
+
var test_results_dialog = $('.test-results');
|
210
|
+
var height = test_results_dialog.height() + 130;
|
211
|
+
var width = $(window).width() - 300;
|
212
|
+
var maxHeight = $(window).height() - 200;
|
213
|
+
try {
|
214
|
+
test_results_dialog.dialog({
|
215
|
+
width: width,
|
216
|
+
height: height,
|
217
|
+
maxHeight: maxHeight,
|
218
|
+
buttons: {
|
219
|
+
"Thanks buddy": function() {
|
220
|
+
test_results_dialog.dialog('close');
|
221
|
+
}
|
222
|
+
}
|
223
|
+
});
|
224
|
+
}
|
225
|
+
catch(error) {
|
226
|
+
alert("Test harness requires jQueryUI");
|
227
|
+
}
|
228
|
+
});
|
229
|
+
});
|
230
|
+
});
|