ninjs 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -3
- data/Gemfile.lock +1 -67
- data/README.md +348 -0
- data/Rakefile +2 -4
- data/VERSION +1 -1
- data/bin/ninjs +196 -39
- data/lib/ninjs/command.rb +23 -64
- data/lib/ninjs/configuration.rb +16 -38
- data/lib/ninjs/generator.rb +23 -12
- data/lib/ninjs/project.rb +7 -6
- data/ninjs.gemspec +9 -33
- data/repository/ninjs/core/module.js +32 -105
- data/repository/ninjs/docs/Data/ClassHierarchy.nd +0 -0
- data/repository/ninjs/docs/Data/ConfigFileInfo.nd +0 -0
- data/repository/ninjs/docs/Data/IndexInfo.nd +0 -0
- data/repository/ninjs/docs/Data/SymbolTable.nd +0 -0
- data/repository/ninjs/extensions/ninjs.jquery.js +67 -0
- metadata +74 -100
- data/README.textile +0 -287
- data/tmp/metric_fu/output/churn.html +0 -692
- data/tmp/metric_fu/output/flay.html +0 -566
- data/tmp/metric_fu/output/flay.js +0 -11
- data/tmp/metric_fu/output/flog.html +0 -2392
- data/tmp/metric_fu/output/flog.js +0 -12
- data/tmp/metric_fu/output/hotspots.html +0 -3607
- data/tmp/metric_fu/output/index.html +0 -572
- data/tmp/metric_fu/output/lib_ninjs.rb.html +0 -49
- data/tmp/metric_fu/output/lib_ninjs_command.rb.html +0 -137
- data/tmp/metric_fu/output/lib_ninjs_configuration.rb.html +0 -107
- data/tmp/metric_fu/output/lib_ninjs_project.rb.html +0 -236
- data/tmp/metric_fu/output/rcov.html +0 -566
- data/tmp/metric_fu/output/rcov.js +0 -11
- data/tmp/metric_fu/output/reek.html +0 -1294
- data/tmp/metric_fu/output/reek.js +0 -20
- data/tmp/metric_fu/output/roodi.html +0 -599
- data/tmp/metric_fu/output/roodi.js +0 -11
- data/tmp/metric_fu/report.yml +0 -1548
data/lib/ninjs/generator.rb
CHANGED
@@ -1,36 +1,47 @@
|
|
1
1
|
module Ninjs
|
2
2
|
class Generator
|
3
3
|
|
4
|
+
attr_writer :alias, :app_name
|
5
|
+
|
4
6
|
def initialize(project, name)
|
5
7
|
@project = project
|
6
8
|
@name = name
|
9
|
+
@alias = false
|
10
|
+
@app_name = @use_alias ? 'app' : @project.config.name
|
7
11
|
end
|
8
12
|
|
9
|
-
def generate_module_file(with = { :elements => false, :model => false })
|
13
|
+
def generate_module_file(with = { :elements => false, :model => false })
|
14
|
+
|
10
15
|
File.open "#{@project.project_path}modules/#{@name.downcase}.module.js", "w" do |file|
|
11
|
-
file << "(function(){\n"
|
12
|
-
file << "\tvar self =
|
13
|
-
file << "\t" + '//= require "../elements/' + @name.downcase + '.elements
|
14
|
-
file << "\t" + '//= require "../models/' + @name.downcase + '.model
|
15
|
-
file << "\t#{@
|
16
|
-
file << "\t#{@
|
17
|
-
file << "})();"
|
16
|
+
file << "(function(#{@app_name if @alias}){\n"
|
17
|
+
file << "\tvar self = #{@app_name}.add_module('#{@name}');\n\n"
|
18
|
+
file << "\t" + '//= require "../elements/' + @name.downcase + '.elements"' + "\n\n" if with[:elements]
|
19
|
+
file << "\t" + '//= require "../models/' + @name.downcase + '.model"' + "\n\n" if with[:model]
|
20
|
+
file << "\t #{@app_name}.#{@name}.actions = function() {\n\n\t};\n\n"
|
21
|
+
file << "\t #{@app_name}.#{@name}.run();\n"
|
22
|
+
file << "})(#{@project.config.name if @alias});"
|
18
23
|
Ninjs::Notification.added "created #{@name.downcase}.module.js"
|
19
24
|
end unless File.exists? "#{@project.project_path}modules/#{@name.downcase}.module.js"
|
25
|
+
|
26
|
+
self
|
20
27
|
end
|
21
28
|
|
22
|
-
def generate_elements_file
|
29
|
+
def generate_elements_file
|
23
30
|
File.open("#{@project.project_path}elements/#{@name.downcase}" + ".elements.js", "w") do |file|
|
24
|
-
file <<
|
31
|
+
file << "#{@app_name}.#{@name}.elements({\n\n});"
|
25
32
|
Ninjs::Notification.added "created #{@name.downcase}.elements.js"
|
26
33
|
end unless File.exists? "#{@project.project_path}elements/#{@name.downcase}.elements.js"
|
34
|
+
|
35
|
+
self
|
27
36
|
end
|
28
37
|
|
29
|
-
def generate_model_file
|
38
|
+
def generate_model_file
|
30
39
|
File.open "#{@project.project_path}models/#{@name.downcase}.model.js", "w" do |file|
|
31
|
-
file <<
|
40
|
+
file << "#{@app_name}.#{@name}.set_data({\n\t\n});"
|
32
41
|
Ninjs::Notification.added "created #{@name.downcase}.model.js"
|
33
42
|
end unless File.exists? "#{@project.project_path}models/#{@name.downcase}.model.js"
|
43
|
+
|
44
|
+
self
|
34
45
|
end
|
35
46
|
|
36
47
|
end
|
data/lib/ninjs/project.rb
CHANGED
@@ -12,6 +12,7 @@ module Ninjs
|
|
12
12
|
@project_path = Dir.getwd + path
|
13
13
|
@modules = Array.new
|
14
14
|
@config = Ninjs::Configuration.new @project_path, name
|
15
|
+
@app_filename = @config.name.downcase
|
15
16
|
end
|
16
17
|
|
17
18
|
def add_slashes(dir)
|
@@ -64,12 +65,12 @@ module Ninjs
|
|
64
65
|
end
|
65
66
|
|
66
67
|
def create_ninjs_application_file
|
67
|
-
filename = "#{@project_path}application/#{@
|
68
|
+
filename = "#{@project_path}application/#{@app_filename}.js"
|
68
69
|
|
69
70
|
File.open(filename, "w+") do |file|
|
70
71
|
file << "//-- Ninjs #{Time.now.to_s} --//\n"
|
71
72
|
file << File.open("#{@project_path}lib/nin.js", 'r').readlines.join('')
|
72
|
-
file << "\nvar #{@config.name} = new NinjsApplication(
|
73
|
+
file << "\nvar #{@config.name} = new NinjsApplication();"
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
@@ -127,7 +128,7 @@ module Ninjs
|
|
127
128
|
|
128
129
|
ninjs_lib_secretary = Sprockets::Secretary.new(
|
129
130
|
:root => "#{Ninjs::BASE_DIR}",
|
130
|
-
:asset_root => @config.asset_root
|
131
|
+
:asset_root => @config.asset_root,
|
131
132
|
:load_path => ["repository"],
|
132
133
|
:source_files => ["#{module_src}"]
|
133
134
|
)
|
@@ -144,7 +145,7 @@ module Ninjs
|
|
144
145
|
end
|
145
146
|
|
146
147
|
def update_application_file
|
147
|
-
application_file = "#{@project_path}application/#{@
|
148
|
+
application_file = "#{@project_path}application/#{@app_filename}.js"
|
148
149
|
|
149
150
|
File.open(application_file, "w+") do |file|
|
150
151
|
write_dependencies(file)
|
@@ -166,7 +167,7 @@ module Ninjs
|
|
166
167
|
def write_core(file)
|
167
168
|
file << "/*---------- Ninjs core ../lib/nin.js ----------*/\n"
|
168
169
|
file << "//= require \"../lib/nin.js\"\n\n"
|
169
|
-
file << "\nvar #{@config.name} = new NinjsApplication(
|
170
|
+
file << "\nvar #{@config.name} = new NinjsApplication();\n\n"
|
170
171
|
end
|
171
172
|
|
172
173
|
def write_autoload(file)
|
@@ -181,7 +182,7 @@ module Ninjs
|
|
181
182
|
begin
|
182
183
|
ninjs_lib_secretary = Sprockets::Secretary.new(
|
183
184
|
:root => "#{Ninjs::BASE_DIR}",
|
184
|
-
:asset_root => @config.asset_root
|
185
|
+
:asset_root => @config.asset_root,
|
185
186
|
:load_path => ["repository"],
|
186
187
|
:source_files => ["#{file}"]
|
187
188
|
)
|
data/ninjs.gemspec
CHANGED
@@ -5,18 +5,18 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ninjs}
|
8
|
-
s.version = "0.13.
|
8
|
+
s.version = "0.13.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dayton Nolan"]
|
12
|
-
s.date = %q{2011-04
|
12
|
+
s.date = %q{2011-05-04}
|
13
13
|
s.default_executable = %q{ninjs}
|
14
14
|
s.description = %q{Ninjs is a ruby application and small javascript framework that helps you build clean, modular javascript applications. Ninjs encourages "Good Parts" best practices and the Crockford school Module pattern (http://www.crockford.com/). The ninjs command line application is an automatic compiler, written in ruby, and based on the Sprockets library (http://getsprockets.org/).}
|
15
15
|
s.email = %q{daytonn@gmail.com}
|
16
16
|
s.executables = ["ninjs"]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
19
|
-
"README.
|
19
|
+
"README.md"
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".bundle/config",
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
"Gemfile",
|
25
25
|
"Gemfile.lock",
|
26
26
|
"LICENSE",
|
27
|
-
"README.
|
27
|
+
"README.md",
|
28
28
|
"Rakefile",
|
29
29
|
"VERSION",
|
30
30
|
"bin/ninjs",
|
@@ -186,6 +186,7 @@ Gem::Specification.new do |s|
|
|
186
186
|
"repository/ninjs/docs/search/VariablesR.html",
|
187
187
|
"repository/ninjs/docs/search/VariablesT.html",
|
188
188
|
"repository/ninjs/docs/styles/main.css",
|
189
|
+
"repository/ninjs/extensions/ninjs.jquery.js",
|
189
190
|
"repository/ninjs/tests/index.html",
|
190
191
|
"repository/ninjs/tests/ninjs.test.js",
|
191
192
|
"repository/ninjs/tests/ninjs.utilities.test.js",
|
@@ -282,37 +283,19 @@ Gem::Specification.new do |s|
|
|
282
283
|
"tmp/ff9e83aa019b712b90200b8d1b8fa0c7e14576af.json",
|
283
284
|
"tmp/metric_fu/_data/20110305.yml",
|
284
285
|
"tmp/metric_fu/output/bluff-min.js",
|
285
|
-
"tmp/metric_fu/output/churn.html",
|
286
286
|
"tmp/metric_fu/output/excanvas.js",
|
287
|
-
"tmp/metric_fu/output/flay.html",
|
288
|
-
"tmp/metric_fu/output/flay.js",
|
289
|
-
"tmp/metric_fu/output/flog.html",
|
290
|
-
"tmp/metric_fu/output/flog.js",
|
291
|
-
"tmp/metric_fu/output/hotspots.html",
|
292
|
-
"tmp/metric_fu/output/index.html",
|
293
287
|
"tmp/metric_fu/output/js-class.js",
|
294
|
-
"tmp/metric_fu/output/lib_ninjs.rb.html",
|
295
|
-
"tmp/metric_fu/output/lib_ninjs_command.rb.html",
|
296
|
-
"tmp/metric_fu/output/lib_ninjs_configuration.rb.html",
|
297
288
|
"tmp/metric_fu/output/lib_ninjs_dependencies.rb.html",
|
298
289
|
"tmp/metric_fu/output/lib_ninjs_helpers.rb.html",
|
299
290
|
"tmp/metric_fu/output/lib_ninjs_manifest.rb.html",
|
300
|
-
"tmp/metric_fu/output/lib_ninjs_project.rb.html",
|
301
291
|
"tmp/metric_fu/output/rails_best_practices.js",
|
302
|
-
"tmp/metric_fu/output/rcov.html",
|
303
|
-
"tmp/metric_fu/output/rcov.js",
|
304
|
-
"tmp/metric_fu/output/reek.html",
|
305
|
-
"tmp/metric_fu/output/reek.js",
|
306
|
-
"tmp/metric_fu/output/roodi.html",
|
307
|
-
"tmp/metric_fu/output/roodi.js",
|
308
|
-
"tmp/metric_fu/report.yml",
|
309
292
|
"tmp/metric_fu/scratch/rcov/rcov.txt"
|
310
293
|
]
|
311
294
|
s.homepage = %q{http://github.com/textnotspeech/ninjs}
|
312
295
|
s.licenses = ["MIT"]
|
313
296
|
s.require_paths = ["lib"]
|
314
297
|
s.rubyforge_project = %q{nowarning}
|
315
|
-
s.rubygems_version = %q{1.
|
298
|
+
s.rubygems_version = %q{1.5.2}
|
316
299
|
s.summary = %q{ninjs is a command line application to help you write clean, modular javascript applications.}
|
317
300
|
s.test_files = [
|
318
301
|
"spec/ninjs_spec.rb",
|
@@ -320,15 +303,12 @@ Gem::Specification.new do |s|
|
|
320
303
|
]
|
321
304
|
|
322
305
|
if s.respond_to? :specification_version then
|
323
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
324
306
|
s.specification_version = 3
|
325
307
|
|
326
308
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
327
|
-
s.add_runtime_dependency(%q<rubikon>, [">= 0"])
|
328
309
|
s.add_runtime_dependency(%q<fssm>, [">= 0"])
|
329
310
|
s.add_runtime_dependency(%q<jsmin>, [">= 0"])
|
330
|
-
s.add_runtime_dependency(%q<sprockets>, ["
|
331
|
-
s.add_development_dependency(%q<metric_fu>, [">= 0"])
|
311
|
+
s.add_runtime_dependency(%q<sprockets>, ["= 1.0.2"])
|
332
312
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
333
313
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
334
314
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
@@ -340,11 +320,9 @@ Gem::Specification.new do |s|
|
|
340
320
|
s.add_runtime_dependency(%q<sprockets>, [">= 0"])
|
341
321
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
342
322
|
else
|
343
|
-
s.add_dependency(%q<rubikon>, [">= 0"])
|
344
323
|
s.add_dependency(%q<fssm>, [">= 0"])
|
345
324
|
s.add_dependency(%q<jsmin>, [">= 0"])
|
346
|
-
s.add_dependency(%q<sprockets>, ["
|
347
|
-
s.add_dependency(%q<metric_fu>, [">= 0"])
|
325
|
+
s.add_dependency(%q<sprockets>, ["= 1.0.2"])
|
348
326
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
349
327
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
350
328
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
@@ -357,11 +335,9 @@ Gem::Specification.new do |s|
|
|
357
335
|
s.add_dependency(%q<rspec>, [">= 0"])
|
358
336
|
end
|
359
337
|
else
|
360
|
-
s.add_dependency(%q<rubikon>, [">= 0"])
|
361
338
|
s.add_dependency(%q<fssm>, [">= 0"])
|
362
339
|
s.add_dependency(%q<jsmin>, [">= 0"])
|
363
|
-
s.add_dependency(%q<sprockets>, ["
|
364
|
-
s.add_dependency(%q<metric_fu>, [">= 0"])
|
340
|
+
s.add_dependency(%q<sprockets>, ["= 1.0.2"])
|
365
341
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
366
342
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
367
343
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
@@ -1,70 +1,17 @@
|
|
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
1
|
var NinjsModule = function(name) {
|
14
|
-
|
15
|
-
Variable: data
|
16
|
-
The module's data object
|
17
|
-
*/
|
2
|
+
this.dom = {};
|
18
3
|
this.data = {};
|
19
|
-
/*
|
20
|
-
Variable: name
|
21
|
-
The module's name (string)
|
22
|
-
*/
|
23
4
|
this.name = name;
|
24
|
-
/*
|
25
|
-
Variable: run_tests (beta)
|
26
|
-
Boolean to turn tests on/off
|
27
|
-
*/
|
28
5
|
this.run_tests = false;
|
29
|
-
/*
|
30
|
-
Variable: tests (beta)
|
31
|
-
Array of test files to run
|
32
|
-
*/
|
33
6
|
this.tests = [];
|
34
7
|
};
|
35
8
|
|
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
9
|
NinjsModule.method('actions', function() {});
|
45
10
|
|
46
|
-
|
47
|
-
/*
|
48
|
-
Method: run
|
49
|
-
Waits for the DOM to load then calls execute.
|
50
|
-
|
51
|
-
> MyModule.run();
|
52
|
-
*/
|
53
11
|
NinjsModule.method('run', function() {
|
54
12
|
this.call_on_ready(this.execute);
|
55
13
|
});
|
56
14
|
|
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
15
|
NinjsModule.method('call_on_ready', function(callback) {
|
69
16
|
var timer;
|
70
17
|
var module = this;
|
@@ -84,12 +31,6 @@ NinjsModule.method('call_on_ready', function(callback) {
|
|
84
31
|
check_ready();
|
85
32
|
});
|
86
33
|
|
87
|
-
/*
|
88
|
-
Method: execute
|
89
|
-
Wrapper method that set's up the environment and then calls actions.
|
90
|
-
|
91
|
-
> MyModule.execute();
|
92
|
-
*/
|
93
34
|
NinjsModule.method('execute', function() {
|
94
35
|
if (this.run_tests) {
|
95
36
|
this._run_tests();
|
@@ -98,40 +39,39 @@ NinjsModule.method('execute', function() {
|
|
98
39
|
this.actions();
|
99
40
|
});
|
100
41
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
42
|
+
NinjsModule.method('elements', function(elements) {
|
43
|
+
try {
|
44
|
+
if (is_undefined(elements)) {
|
45
|
+
if (is_typeof(Object, elements)) {
|
46
|
+
throw new SyntaxError("NinjsModule.elements(elements): elements is undefined");
|
47
|
+
}
|
48
|
+
else if (is_string(elements)) {
|
49
|
+
throw new SyntaxError("NinjsModule.elements(name): name is undefined");
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
// If first argument is a string, retrieve the element
|
54
|
+
if (is_string(elements)) {
|
55
|
+
var name = elements;
|
56
|
+
return is_defined(this.dom[name]) ? this.dom[name] : undefined;
|
57
|
+
}
|
58
|
+
// Set elements
|
59
|
+
else {
|
60
|
+
this.call_on_ready(function() {
|
61
|
+
for(var key in elements) {
|
62
|
+
if (elements.hasOwnProperty(key)) {
|
63
|
+
this.dom[key] = elements[key];
|
64
|
+
}
|
65
|
+
}
|
66
|
+
});
|
67
|
+
}
|
68
|
+
}
|
69
|
+
catch(error) {
|
70
|
+
alert(error.message);
|
71
|
+
}
|
72
|
+
|
114
73
|
});
|
115
74
|
|
116
|
-
|
117
|
-
/*
|
118
|
-
Method: set_data
|
119
|
-
Adds properties to the module's data object.
|
120
|
-
|
121
|
-
Parameters:
|
122
|
-
key - string or object (if string = key, if object sets multiple properties)
|
123
|
-
value - value of key if key is string
|
124
|
-
|
125
|
-
> MyModule.set_data('some_key', 'some_value');
|
126
|
-
> MyModule.data.some_key === 'some_value'
|
127
|
-
|
128
|
-
> MyModule.set_data({
|
129
|
-
> 'property_one': 'value_one',
|
130
|
-
> 'property_two': 'value_two'
|
131
|
-
> });
|
132
|
-
> MyModule.data.property_one === 'value_one'
|
133
|
-
> MyModule.data.property_two === 'value_two'
|
134
|
-
*/
|
135
75
|
NinjsModule.method('set_data', function(key, value) {
|
136
76
|
try {
|
137
77
|
if (is_undefined(key)) {
|
@@ -159,23 +99,10 @@ NinjsModule.method('set_data', function(key, value) {
|
|
159
99
|
}
|
160
100
|
});
|
161
101
|
|
162
|
-
/*
|
163
|
-
Method: add_test
|
164
|
-
Adds a test file to the tests array (beta).
|
165
|
-
|
166
|
-
Parameters:
|
167
|
-
test_file - File to add to the tests array
|
168
|
-
|
169
|
-
> MyModule.add_test('mytest.test.js');
|
170
|
-
*/
|
171
102
|
NinjsModule.method('add_test', function(test_file) {
|
172
103
|
this.tests.push(test_file);
|
173
104
|
});
|
174
105
|
|
175
|
-
/*
|
176
|
-
Method: _run_tests
|
177
|
-
Runs the test files in the test array. This method is automatically called by the execute method if run_tests === true
|
178
|
-
*/
|
179
106
|
NinjsModule.method('_run_tests', function() {
|
180
107
|
var test_template = [];
|
181
108
|
test_template.push('<div class="test-results" title="Test Results">');
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,67 @@
|
|
1
|
+
(function($) {
|
2
|
+
|
3
|
+
NinjsModule.prototype.elements = function(elements, force) {
|
4
|
+
var self = this;
|
5
|
+
|
6
|
+
unless(is_defined(force), function() {
|
7
|
+
force = false;
|
8
|
+
});
|
9
|
+
|
10
|
+
if (is_string(elements)) {
|
11
|
+
var key = elements;
|
12
|
+
|
13
|
+
try {
|
14
|
+
if (is_undefined(self.dom[key])) {
|
15
|
+
throw new SyntaxError("NinjsModule.elements('" + key + "'): " + self.name + ".dom." + key + " is undefined");
|
16
|
+
}
|
17
|
+
|
18
|
+
if (is_string(self.dom[key])) {
|
19
|
+
var selection = $(self.dom[key]);
|
20
|
+
|
21
|
+
unless(selection.length === 0, function() {
|
22
|
+
return self.dom[key] = selection;
|
23
|
+
}, function() {
|
24
|
+
return self.dom[key];
|
25
|
+
});
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
if (self.dom[key].length === 0 || force) {
|
29
|
+
|
30
|
+
var return_obj = undefined;
|
31
|
+
|
32
|
+
if (is_string(force)) {
|
33
|
+
var selector = self.dom[key].selector;
|
34
|
+
self.dom[key] = $(force).find(selector);
|
35
|
+
self.dom[key].selector = selector;
|
36
|
+
|
37
|
+
return_obj = self.dom[key];
|
38
|
+
}
|
39
|
+
|
40
|
+
var selection = $(self.dom[key].selector);
|
41
|
+
unless(selection.length === 0, function() {
|
42
|
+
return_obj = selection;
|
43
|
+
});
|
44
|
+
|
45
|
+
return return_obj;
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
return self.dom[key];
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
catch(error) {
|
53
|
+
alert(error.message);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
else if (is_typeof(Object, elements)){
|
57
|
+
self.call_on_ready(function() {
|
58
|
+
for(var key in elements) {
|
59
|
+
if (elements.hasOwnProperty(key)) {
|
60
|
+
self.dom[key] = elements[key];
|
61
|
+
}
|
62
|
+
}
|
63
|
+
});
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
})(jQuery);
|