hobo 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/hobo +21 -22
- data/hobo_files/plugin/CHANGES.txt +429 -4
- data/hobo_files/plugin/Rakefile +2 -2
- data/hobo_files/plugin/generators/hobo_front_controller/templates/index.dryml +6 -5
- data/hobo_files/plugin/generators/hobo_front_controller/templates/search.dryml +2 -2
- data/hobo_files/plugin/generators/hobo_migration/hobo_migration_generator.rb +20 -15
- data/hobo_files/plugin/generators/hobo_model/templates/model.rb +1 -0
- data/hobo_files/plugin/generators/hobo_model_controller/templates/controller.rb +2 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/hobo_base.css +1 -2
- data/hobo_files/plugin/generators/hobo_rapid/templates/hobo_rapid.css +4 -3
- data/hobo_files/plugin/generators/hobo_rapid/templates/hobo_rapid.js +94 -12
- data/hobo_files/plugin/generators/hobo_rapid/templates/lowpro.js +5 -183
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/stylesheets/application.css +1 -1
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/views/application.dryml +23 -1
- data/hobo_files/plugin/generators/hobo_user_controller/templates/controller.rb +2 -0
- data/hobo_files/plugin/generators/hobo_user_model/templates/model.rb +3 -1
- data/hobo_files/plugin/init.rb +18 -7
- data/hobo_files/plugin/lib/active_record/has_many_association.rb +2 -2
- data/hobo_files/plugin/lib/extensions.rb +56 -12
- data/hobo_files/plugin/lib/hobo.rb +25 -88
- data/hobo_files/plugin/lib/hobo/composite_model.rb +2 -0
- data/hobo_files/plugin/lib/hobo/controller.rb +40 -20
- data/hobo_files/plugin/lib/hobo/dryml.rb +122 -106
- data/hobo_files/plugin/lib/hobo/dryml/dryml_builder.rb +2 -1
- data/hobo_files/plugin/lib/hobo/dryml/part_context.rb +3 -2
- data/hobo_files/plugin/lib/hobo/dryml/taglib.rb +19 -3
- data/hobo_files/plugin/lib/hobo/dryml/template.rb +40 -25
- data/hobo_files/plugin/lib/hobo/dryml/template_environment.rb +41 -20
- data/hobo_files/plugin/lib/hobo/email_address.rb +4 -1
- data/hobo_files/plugin/lib/hobo/enum_string.rb +50 -0
- data/hobo_files/plugin/lib/hobo/field_declaration_dsl.rb +36 -0
- data/hobo_files/plugin/lib/hobo/field_spec.rb +4 -7
- data/hobo_files/plugin/lib/hobo/hobo_helper.rb +47 -44
- data/hobo_files/plugin/lib/hobo/html_string.rb +2 -0
- data/hobo_files/plugin/lib/hobo/markdown_string.rb +2 -0
- data/hobo_files/plugin/lib/hobo/model.rb +158 -89
- data/hobo_files/plugin/lib/hobo/model_controller.rb +422 -376
- data/hobo_files/plugin/lib/hobo/model_queries.rb +1 -1
- data/hobo_files/plugin/lib/hobo/model_router.rb +174 -0
- data/hobo_files/plugin/lib/hobo/password_string.rb +2 -0
- data/hobo_files/plugin/lib/hobo/percentage.rb +14 -0
- data/hobo_files/plugin/lib/hobo/plugins.rb +4 -4
- data/hobo_files/plugin/lib/hobo/rapid_helper.rb +10 -2
- data/hobo_files/plugin/lib/hobo/text.rb +3 -3
- data/hobo_files/plugin/lib/hobo/textile_string.rb +2 -0
- data/hobo_files/plugin/lib/hobo/undefined.rb +3 -2
- data/hobo_files/plugin/lib/hobo/{authenticated_user.rb → user.rb} +10 -3
- data/hobo_files/plugin/lib/hobo/user_controller.rb +27 -23
- data/hobo_files/plugin/tags/core.dryml +8 -2
- data/hobo_files/plugin/tags/rapid.dryml +52 -40
- data/hobo_files/plugin/tags/rapid_document_tags.dryml +15 -11
- data/hobo_files/plugin/tags/rapid_editing.dryml +41 -9
- data/hobo_files/plugin/tags/rapid_forms.dryml +136 -36
- data/hobo_files/plugin/tags/rapid_navigation.dryml +2 -2
- data/hobo_files/plugin/tags/rapid_pages.dryml +204 -221
- data/hobo_files/plugin/tags/rapid_plus.dryml +8 -6
- data/hobo_files/plugin/tags/rapid_support.dryml +2 -3
- metadata +44 -42
- data/hobo_files/plugin/lib/hobo/define_tags.rb +0 -56
- data/hobo_files/plugin/lib/hobo/http_parameters.rb +0 -225
data/hobo_files/plugin/Rakefile
CHANGED
@@ -25,8 +25,8 @@ PLUGIN_DIR = File.dirname(__FILE__)
|
|
25
25
|
|
26
26
|
rspec_base = File.expand_path(PLUGIN_DIR + '/spec/rails_root/vendor/plugins/rspec/lib')
|
27
27
|
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
28
|
-
require 'spec/rake/spectask'
|
29
|
-
require 'spec/translator'
|
28
|
+
require '../hobo_spec/rails_root/vendor/plugins/rspec/lib/spec/rake/spectask'
|
29
|
+
require '../hobo_spec/rails_root/vendor/plugins/rspec/lib/spec/translator'
|
30
30
|
|
31
31
|
spec_prereq = :noop # File.exist?(File.join(PLUGIN_DIR, 'config', 'database.yml')) ? "db:test:prepare" : :noop
|
32
32
|
task :noop do
|
@@ -1,9 +1,7 @@
|
|
1
1
|
<Page title="<%= app_name %>">
|
2
2
|
|
3
|
-
<
|
4
|
-
<
|
5
|
-
<h1 class="front_page_title"><%= app_name %></h1>
|
6
|
-
</header>
|
3
|
+
<content_header>
|
4
|
+
<h1 class="front_page_title"><%= app_name %></h1>
|
7
5
|
<panel>
|
8
6
|
<div style="margin-left: 40px; ">
|
9
7
|
<h3>Congratulations! Your Hobo Rails App is up and running</h3>
|
@@ -12,7 +10,10 @@
|
|
12
10
|
</ul>
|
13
11
|
</div>
|
14
12
|
</panel>
|
13
|
+
</content_header>
|
15
14
|
|
15
|
+
|
16
|
+
<content_body>
|
16
17
|
<repeat with="&Hobo.models">
|
17
18
|
<panel>
|
18
19
|
<header><h2><%%= this.name.titlecase.pluralize %></h2></header>
|
@@ -32,6 +33,6 @@
|
|
32
33
|
</section>
|
33
34
|
</panel>
|
34
35
|
</repeat>
|
35
|
-
</
|
36
|
+
</content_body>
|
36
37
|
|
37
38
|
</Page>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<Page title="Search">
|
2
2
|
<body onload="Hobo.applyEvents(); Hobo.doSearch('search_field')"/>
|
3
3
|
|
4
|
-
<
|
4
|
+
<content_body>
|
5
5
|
<panel class="red" style="margin-top: 40px">
|
6
6
|
<h2>Search</h2>
|
7
7
|
<div class='search' style='margin:10px'>
|
@@ -14,6 +14,6 @@
|
|
14
14
|
<h2>Results</h2>
|
15
15
|
<section id="search_results"> </section>
|
16
16
|
</panel>
|
17
|
-
</
|
17
|
+
</content_body>
|
18
18
|
|
19
19
|
</Page>
|
@@ -15,16 +15,18 @@ class HoboMigrationGenerator < Rails::Generator::Base
|
|
15
15
|
# Force load of hobo models
|
16
16
|
Hobo.models
|
17
17
|
|
18
|
-
|
19
|
-
ignore_models = (Hobo::Migrations.ignore + Hobo::Migrations.ignore_models).every(:underscore)
|
18
|
+
ignore_model_names = Hobo::Migrations.ignore.every(:underscore)
|
20
19
|
|
21
|
-
|
20
|
+
all_models = ActiveRecord::Base.send(:subclasses).reject {|c| c.name.starts_with?("CGI::") }
|
21
|
+
models, ignore_models = all_models.partition do |m|
|
22
|
+
m.name.underscore.not_in?(ignore_model_names) && m < Hobo::Model
|
23
|
+
end
|
24
|
+
ignore_tables = ignore_models.every(:table_name) | Hobo::Migrations.ignore_tables
|
22
25
|
|
23
|
-
|
24
|
-
models = models.reject {|m| m.name.underscore.in?(ignore_models) }
|
25
|
-
table_models = models.index_by {|m| m.table_name}
|
26
|
+
models_by_table_name = models.index_by {|m| m.table_name}
|
26
27
|
model_table_names = models.every(:table_name)
|
27
|
-
|
28
|
+
db_tables = connection.tables - ignore_tables
|
29
|
+
|
28
30
|
to_create = model_table_names - db_tables
|
29
31
|
to_drop = db_tables - model_table_names - ['schema_info']
|
30
32
|
to_change = db_tables & model_table_names
|
@@ -46,7 +48,7 @@ class HoboMigrationGenerator < Rails::Generator::Base
|
|
46
48
|
end * "\n\n"
|
47
49
|
|
48
50
|
creates = to_create.map do |t|
|
49
|
-
create_table(
|
51
|
+
create_table(models_by_table_name[t])
|
50
52
|
end * "\n\n"
|
51
53
|
undo_creates = to_create.map do |t|
|
52
54
|
"drop_table :#{t}"
|
@@ -55,27 +57,30 @@ class HoboMigrationGenerator < Rails::Generator::Base
|
|
55
57
|
changes = []
|
56
58
|
undo_changes = []
|
57
59
|
to_change.each do |t|
|
58
|
-
change, undo = change_table(
|
60
|
+
change, undo = change_table(models_by_table_name[t])
|
59
61
|
changes << change
|
60
62
|
undo_changes << undo
|
61
63
|
end
|
62
64
|
|
63
65
|
up = [renames, drops, creates, changes].flatten.select{|s|!s.blank?} * "\n\n"
|
64
66
|
down = [undo_renames, undo_drops, undo_creates, undo_changes].flatten.select{|s|!s.blank?} * "\n\n"
|
65
|
-
|
67
|
+
|
68
|
+
if up.blank?
|
69
|
+
puts "Database and models match -- nothing to change"
|
70
|
+
return record {|m| }
|
71
|
+
end
|
72
|
+
|
66
73
|
puts "\n---------- Up Migration ----------", up, "----------------------------------"
|
67
74
|
puts "\n---------- Down Migration --------", down, "----------------------------------"
|
68
75
|
|
69
|
-
return record {|m| } if up.blank?
|
70
|
-
|
71
76
|
action = input("What now: [g]enerate migrations, generate and [m]igrate now or [c]ancel?", %w(g m c))
|
72
77
|
|
73
78
|
if action == 'c'
|
74
79
|
# record nothing to keep the generator happy
|
75
80
|
record {|m| }
|
76
81
|
else
|
77
|
-
puts "\
|
78
|
-
migration_name = input("
|
82
|
+
puts "\nMigration filename:", "(you can type spaces instead of '_' -- every little helps)"
|
83
|
+
migration_name = input("Filename [#@migration_name]:").strip.gsub(' ', '_')
|
79
84
|
migration_name = @migration_name if migration_name.blank?
|
80
85
|
|
81
86
|
at_exit { system "rake db:migrate" } if action == 'm'
|
@@ -189,7 +194,7 @@ class HoboMigrationGenerator < Rails::Generator::Base
|
|
189
194
|
change_spec[:precision] = spec.precision if !spec.precision.nil?
|
190
195
|
change_spec[:scale] = spec.scale if !spec.scale.nil?
|
191
196
|
change_spec[:null] = false unless spec.null
|
192
|
-
change_spec[:default] = spec.default
|
197
|
+
change_spec[:default] = spec.default
|
193
198
|
|
194
199
|
changes << "change_column :#{table_name}, :#{c}, " +
|
195
200
|
([":#{spec.sql_type}"] + format_options(change_spec, spec.sql_type)).join(", ")
|
@@ -73,9 +73,10 @@ textarea { height: 200px; }
|
|
73
73
|
textarea.wide { width: 100%; }
|
74
74
|
textarea.tall { height: 350px; }
|
75
75
|
|
76
|
+
.field_list input.percentage {width: 25px; display: inline; margin-right: 5px; padding: 1px 3px;}
|
76
77
|
|
77
78
|
/* rails error message */
|
78
|
-
.
|
79
|
+
.error_messages {
|
79
80
|
font-family: "Lucida Grande", arial, sans-serif;
|
80
81
|
background: #9d0018;
|
81
82
|
border: 1px solid #7a0013;
|
@@ -83,11 +84,11 @@ textarea.tall { height: 350px; }
|
|
83
84
|
color: white;
|
84
85
|
margin-bottom: 20px;
|
85
86
|
}
|
86
|
-
.
|
87
|
+
.error_messages h2 {
|
87
88
|
text-transform: none;
|
88
89
|
letter-spacing: normal;
|
89
90
|
color: white;
|
90
91
|
}
|
91
|
-
.
|
92
|
+
.error_messages li {
|
92
93
|
margin-left: 20px;
|
93
94
|
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
Object.extend = function(destination) {
|
3
2
|
$A(arguments).slice(1).each(function (src) {
|
4
3
|
for (var property in src) {
|
@@ -46,13 +45,18 @@ var Hobo = {
|
|
46
45
|
var params = []
|
47
46
|
var i = 0
|
48
47
|
if (updates.length > 0) {
|
49
|
-
updates.each(function(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
updates.each(function(id_or_el) {
|
49
|
+
var el = $(id_or_el)
|
50
|
+
if (el) { // ignore update of parts that do not exist
|
51
|
+
var dom_id
|
52
|
+
dom_id = el.id
|
53
|
+
if (!hoboParts[dom_id]) { throw "Update of dom-id that is not a part: " + dom_id }
|
54
|
+
params.push("render["+i+"][part_context]=" + encodeURIComponent(hoboParts[dom_id]))
|
55
|
+
params.push("render["+i+"][id]=" + dom_id)
|
56
|
+
i += 1
|
57
|
+
}
|
54
58
|
})
|
55
|
-
params.push("
|
59
|
+
params.push("page_path=" + hoboPagePath)
|
56
60
|
}
|
57
61
|
|
58
62
|
if (resultUpdates) {
|
@@ -299,7 +303,7 @@ var Hobo = {
|
|
299
303
|
|
300
304
|
putUrl: function(el) {
|
301
305
|
spec = Hobo.parseFieldId(el)
|
302
|
-
return urlBase + "/" +
|
306
|
+
return urlBase + "/" + Hobo.pluralise(spec.name) + "/" + spec.id + "?_method=PUT"
|
303
307
|
},
|
304
308
|
|
305
309
|
|
@@ -314,13 +318,15 @@ var Hobo = {
|
|
314
318
|
afterFinish: function (ef) { ef.element.remove() } });
|
315
319
|
},
|
316
320
|
|
317
|
-
removeButton: function(el, url, updates,
|
318
|
-
if (fade == null) { fade = true; }
|
319
|
-
if (confirm
|
321
|
+
removeButton: function(el, url, updates, options) {
|
322
|
+
if (options.fade == null) { options.fade = true; }
|
323
|
+
if (options.confirm == null) { options.fade = "Are you sure?"; }
|
324
|
+
|
325
|
+
if (options.confirm == false || confirm(options.confirm)) {
|
320
326
|
objEl = Hobo.objectElementFor(el)
|
321
327
|
Hobo.showSpinner('Removing');
|
322
328
|
function complete() {
|
323
|
-
if (fade) { Hobo.fadeObjectElement(el) }
|
329
|
+
if (options.fade) { Hobo.fadeObjectElement(el) }
|
324
330
|
Hobo.hideSpinner()
|
325
331
|
}
|
326
332
|
if (updates && updates.length > 0) {
|
@@ -400,8 +406,26 @@ var Hobo = {
|
|
400
406
|
|
401
407
|
backgroundColor: function(el) {
|
402
408
|
return Hobo.rgbColorToHex(Hobo.getStyle(el, 'background-color'))
|
409
|
+
},
|
410
|
+
|
411
|
+
partFor: function(el) {
|
412
|
+
while (el) {
|
413
|
+
if (el.id && hoboParts[el.id]) { return el }
|
414
|
+
el = el.parentNode
|
415
|
+
}
|
416
|
+
return null
|
417
|
+
},
|
418
|
+
|
419
|
+
pluralise: function(s) {
|
420
|
+
return pluralisations[s] || s + "s"
|
421
|
+
},
|
422
|
+
|
423
|
+
addUrlParams: function(params) {
|
424
|
+
params = $H(window.location.search.toQueryParams()).merge(params)
|
425
|
+
return window.location.href.sub(/(\?.*|$)/, "?" + params.toQueryString())
|
403
426
|
}
|
404
427
|
|
428
|
+
|
405
429
|
}
|
406
430
|
|
407
431
|
Element.findContaining = function(el, tag) {
|
@@ -430,6 +454,16 @@ Ajax.InPlaceEditor.prototype.enterEditMode = function(evt) {
|
|
430
454
|
return false
|
431
455
|
}
|
432
456
|
|
457
|
+
// Fix Safari in-place-editor bug
|
458
|
+
Ajax.InPlaceEditor.prototype.removeForm = function() {
|
459
|
+
if(this.form) {
|
460
|
+
if (this.form.parentNode) {
|
461
|
+
try { Element.remove(this.form); } catch (e) {}
|
462
|
+
}
|
463
|
+
this.form = null;
|
464
|
+
}
|
465
|
+
}
|
466
|
+
|
433
467
|
// Silence errors from IE :-(
|
434
468
|
Field.scrollFreeActivate = function(field) {
|
435
469
|
setTimeout(function() {
|
@@ -438,3 +472,51 @@ Field.scrollFreeActivate = function(field) {
|
|
438
472
|
} catch(e) {}
|
439
473
|
}, 1);
|
440
474
|
}
|
475
|
+
|
476
|
+
|
477
|
+
Element.Methods.$$ = function(e, css) {
|
478
|
+
return new Selector(css).findElements(e)
|
479
|
+
}
|
480
|
+
|
481
|
+
// --- has_many_through_input --- //
|
482
|
+
|
483
|
+
HasManyThroughInput = Behavior.create({
|
484
|
+
|
485
|
+
initialize : function() {
|
486
|
+
// onchange doesn't bubble in IE6 so...
|
487
|
+
Event.observe(this.element.down('select'), 'change', this.addOne.bind(this))
|
488
|
+
},
|
489
|
+
|
490
|
+
addOne : function() {
|
491
|
+
var select = this.element.down('select')
|
492
|
+
var selected = select.options[select.selectedIndex]
|
493
|
+
if (selected.style.display != "none" & selected.value != "") {
|
494
|
+
var newItem = strToDom(this.element.down('.item_proto').innerHTML)
|
495
|
+
this.element.down('.items').appendChild(newItem);
|
496
|
+
newItem.down('span').innerHTML = selected.innerHTML
|
497
|
+
newItem.down('input[type=hidden]').value = selected.innerHTML
|
498
|
+
selected.style.display = 'none'
|
499
|
+
select.value = ""
|
500
|
+
}
|
501
|
+
},
|
502
|
+
|
503
|
+
onclick : function(e) {
|
504
|
+
var el = Event.element(e);
|
505
|
+
Event.stop(e);
|
506
|
+
if (el.match(".remove_item")) { this.removeOne(el.parentNode) }
|
507
|
+
},
|
508
|
+
|
509
|
+
removeOne : function(el) {
|
510
|
+
new Effect.BlindUp(el,
|
511
|
+
{ duration: 0.3,
|
512
|
+
afterFinish: function (ef) { ef.element.remove() } } )
|
513
|
+
var label = el.down('span').innerHTML
|
514
|
+
var option = $A(this.element.getElementsByTagName('option')).find(function(o) { return o.innerHTML == label })
|
515
|
+
option.style.display = 'block'
|
516
|
+
}
|
517
|
+
|
518
|
+
})
|
519
|
+
|
520
|
+
Event.addBehavior({
|
521
|
+
'div.has_many_through.input' : HasManyThroughInput()
|
522
|
+
});
|
@@ -1,30 +1,11 @@
|
|
1
1
|
LowPro = {};
|
2
|
-
LowPro.Version = '0.
|
2
|
+
LowPro.Version = '0.5';
|
3
3
|
|
4
4
|
if (!Element.addMethods)
|
5
5
|
Element.addMethods = function(o) { Object.extend(Element.Methods, o) };
|
6
6
|
|
7
7
|
// Simple utility methods for working with the DOM
|
8
8
|
DOM = {
|
9
|
-
insertAfter : function(element, node, otherNode) {
|
10
|
-
element = $(element);
|
11
|
-
if (otherNode.nextSibling)
|
12
|
-
return element.insertBefore(node, otherNode.nextSibling);
|
13
|
-
else
|
14
|
-
return element.appendChild(node);
|
15
|
-
},
|
16
|
-
addBefore : function(element, node) {
|
17
|
-
element = $(element);
|
18
|
-
return element.parentNode.insertBefore(node, element);
|
19
|
-
},
|
20
|
-
addAfter : function(element, node) {
|
21
|
-
element = $(element);
|
22
|
-
return $(element.parentNode).insertAfter(node, element);
|
23
|
-
},
|
24
|
-
replaceElement : function(element, node) {
|
25
|
-
$(element).parentNode.replaceChild(node, element);
|
26
|
-
return node;
|
27
|
-
},
|
28
9
|
prependChild : function(element, node) {
|
29
10
|
$(element).insertBefore(node, element.firstChild);
|
30
11
|
},
|
@@ -42,24 +23,6 @@ Element.addMethods(DOM);
|
|
42
23
|
|
43
24
|
// DOMBuilder for prototype
|
44
25
|
DOM.Builder = {
|
45
|
-
IE_TRANSLATIONS : {
|
46
|
-
'class' : 'className',
|
47
|
-
'for' : 'htmlFor'
|
48
|
-
},
|
49
|
-
cache: {},
|
50
|
-
ieAttrSet : function(attrs, attr, el) {
|
51
|
-
var trans;
|
52
|
-
if (trans = this.IE_TRANSLATIONS[attr]) el[trans] = attrs[attr];
|
53
|
-
else if (attr == 'style') el.style.cssText = attrs[attr];
|
54
|
-
else if (attr.match(/^on/)) el[attr] = new Function(attrs[attr]);
|
55
|
-
else el.setAttribute(attr, attrs[attr]);
|
56
|
-
},
|
57
|
-
getElement : function(tag) {
|
58
|
-
var element = DOM.Builder.cache[tag];
|
59
|
-
if (element == null)
|
60
|
-
element = DOM.Builder.cache[tag] = document.createElement(tag);
|
61
|
-
return element.cloneNode(false);
|
62
|
-
},
|
63
26
|
tagFunc : function(tag) {
|
64
27
|
return function() {
|
65
28
|
var attrs, children;
|
@@ -77,20 +40,7 @@ DOM.Builder = {
|
|
77
40
|
},
|
78
41
|
create : function(tag, attrs, children) {
|
79
42
|
attrs = attrs || {}; children = children || []; tag = tag.toLowerCase();
|
80
|
-
var
|
81
|
-
var el = (isIE && attrs.name) ?
|
82
|
-
document.createElement("<" + tag + " name=" + attrs.name + ">") :
|
83
|
-
DOM.Builder.getElement(tag);
|
84
|
-
|
85
|
-
for (var attr in attrs) {
|
86
|
-
if (attrs[attr] === true) attrs[attr] = attr;
|
87
|
-
if (typeof attrs[attr] != 'function') {
|
88
|
-
if (isIE) this.ieAttrSet(attrs, attr, el);
|
89
|
-
else el.setAttribute(attr, attrs[attr].toString());
|
90
|
-
} else if (attr.match(/^on(.+)$/)) {
|
91
|
-
Event.observe(el, RegExp.$1, attrs[attr]);
|
92
|
-
};
|
93
|
-
}
|
43
|
+
var el = new Element(tag, attrs);
|
94
44
|
|
95
45
|
for (var i=0; i<children.length; i++) {
|
96
46
|
if (typeof children[i] == 'string')
|
@@ -121,141 +71,16 @@ DOM.Builder.fromHTML = function(html) {
|
|
121
71
|
return root.childNodes[0];
|
122
72
|
};
|
123
73
|
|
124
|
-
String.prototype.toElement = function() {
|
125
|
-
return DOM.Builder.fromHTML(this);
|
126
|
-
};
|
127
|
-
|
128
|
-
(function() {
|
129
|
-
var old$ = $;
|
130
|
-
$ = function(element) {
|
131
|
-
if (element && element.toElement && element.match(/^<(.+)>$/))
|
132
|
-
return $(element.toElement());
|
133
|
-
return old$.apply(this, arguments);
|
134
|
-
}
|
135
|
-
})();
|
136
|
-
|
137
74
|
|
138
75
|
|
139
|
-
//
|
140
|
-
// http://www.vivabit.com/bollocks/2006/06/21/a-dom-ready-extension-for-prototype
|
141
|
-
// which was based on work by Matthias Miller, Dean Edwards and John Resig
|
76
|
+
// Wraps the 1.6 contentloaded event for backwards compatibility
|
142
77
|
//
|
143
78
|
// Usage:
|
144
79
|
//
|
145
80
|
// Event.onReady(callbackFunction);
|
146
81
|
Object.extend(Event, {
|
147
|
-
_domReady : function() {
|
148
|
-
if (arguments.callee.done) return;
|
149
|
-
arguments.callee.done = true;
|
150
|
-
|
151
|
-
if (Event._timer) clearInterval(Event._timer);
|
152
|
-
|
153
|
-
Event._readyCallbacks.each(function(f) { f() });
|
154
|
-
Event._readyCallbacks = null;
|
155
|
-
|
156
|
-
},
|
157
82
|
onReady : function(f) {
|
158
|
-
|
159
|
-
var domReady = this._domReady;
|
160
|
-
|
161
|
-
if (domReady.done) return f();
|
162
|
-
|
163
|
-
if (document.addEventListener)
|
164
|
-
document.addEventListener("DOMContentLoaded", domReady, false);
|
165
|
-
|
166
|
-
/*@cc_on @*/
|
167
|
-
/*@if (@_win32)
|
168
|
-
var dummy = location.protocol == "https:" ? "https://javascript:void(0)" : "javascript:void(0)";
|
169
|
-
document.write("<script id=__ie_onload defer src='" + dummy + "'><\/script>");
|
170
|
-
document.getElementById("__ie_onload").onreadystatechange = function() {
|
171
|
-
if (this.readyState == "complete") { domReady(); }
|
172
|
-
};
|
173
|
-
/*@end @*/
|
174
|
-
|
175
|
-
if (/WebKit/i.test(navigator.userAgent)) {
|
176
|
-
this._timer = setInterval(function() {
|
177
|
-
if (/loaded|complete/.test(document.readyState)) domReady();
|
178
|
-
}, 10);
|
179
|
-
}
|
180
|
-
|
181
|
-
Event.observe(window, 'load', domReady);
|
182
|
-
Event._readyCallbacks = [];
|
183
|
-
}
|
184
|
-
Event._readyCallbacks.push(f);
|
185
|
-
}
|
186
|
-
});
|
187
|
-
|
188
|
-
// Extend Element with observe and stopObserving.
|
189
|
-
if (typeof Element.Methods.observe == 'undefined') Element.addMethods({
|
190
|
-
observe : function(el, event, callback) {
|
191
|
-
Event.observe(el, event, callback);
|
192
|
-
},
|
193
|
-
stopObserving : function(el, event, callback) {
|
194
|
-
Event.stopObserving(el, event, callback);
|
195
|
-
}
|
196
|
-
});
|
197
|
-
|
198
|
-
// Replace out existing event observe code with Dean Edwards' addEvent
|
199
|
-
// http://dean.edwards.name/weblog/2005/10/add-event/
|
200
|
-
Object.extend(Event, {
|
201
|
-
_observeAndCache : function(el, type, func) {
|
202
|
-
if (!func.$$guid) func.$$guid = Event._guid++;
|
203
|
-
if (!el.events) el.events = {};
|
204
|
-
var handlers = el.events[type];
|
205
|
-
if (!handlers) {
|
206
|
-
handlers = el.events[type] = {};
|
207
|
-
if (el["on" + type]) {
|
208
|
-
handlers[0] = el["on" + type];
|
209
|
-
}
|
210
|
-
}
|
211
|
-
handlers[func.$$guid] = func;
|
212
|
-
el["on" + type] = Event._handleEvent;
|
213
|
-
|
214
|
-
if (!Event.observers) Event.observers = [];
|
215
|
-
Event.observers.push([el, type, func, false]);
|
216
|
-
},
|
217
|
-
stopObserving : function(el, type, func) {
|
218
|
-
el = $(el);
|
219
|
-
if (el.events && el.events[type]) delete el.events[type][func.$$guid];
|
220
|
-
|
221
|
-
for (var i = 0; i < Event.observers.length; i++) {
|
222
|
-
if (Event.observers[i] &&
|
223
|
-
Event.observers[i][0] == el &&
|
224
|
-
Event.observers[i][1] == type &&
|
225
|
-
Event.observers[i][2] == func) delete Event.observers[i];
|
226
|
-
}
|
227
|
-
},
|
228
|
-
_handleEvent : function(e) {
|
229
|
-
var returnValue = true;
|
230
|
-
e = e || Event._fixEvent(window.event);
|
231
|
-
var handlers = this.events[e.type], el = $(this);
|
232
|
-
for (var i in handlers) {
|
233
|
-
el.$$handleEvent = handlers[i];
|
234
|
-
if (el.$$handleEvent(e) === false) returnValue = false;
|
235
|
-
}
|
236
|
-
if (returnValue == false) e.preventDefault();
|
237
|
-
return returnValue;
|
238
|
-
},
|
239
|
-
_fixEvent : function(e) {
|
240
|
-
e.preventDefault = Event._preventDefault;
|
241
|
-
e.stopPropagation = Event._stopPropagation;
|
242
|
-
return e;
|
243
|
-
},
|
244
|
-
_preventDefault : function() { this.returnValue = false },
|
245
|
-
_stopPropagation : function() { this.cancelBubble = true },
|
246
|
-
_guid : 1
|
247
|
-
});
|
248
|
-
|
249
|
-
// Allows you to trigger an event element.
|
250
|
-
Object.extend(Event, {
|
251
|
-
trigger : function(element, event, fakeEvent) {
|
252
|
-
element = $(element);
|
253
|
-
fakeEvent = fakeEvent || { type : event };
|
254
|
-
if(element.events && element.events[event]) {
|
255
|
-
$H(element.events[event]).each(function(cache) {
|
256
|
-
cache[1].call(element, fakeEvent);
|
257
|
-
});
|
258
|
-
}
|
83
|
+
document.observe('contentloaded', f);
|
259
84
|
}
|
260
85
|
});
|
261
86
|
|
@@ -366,9 +191,7 @@ Behavior = {
|
|
366
191
|
var behavior = function() {
|
367
192
|
var behavior = arguments.callee;
|
368
193
|
if (this == window || $H(this).values().include(behavior)) {
|
369
|
-
var args =
|
370
|
-
for (var i = 0; i < arguments.length; i++)
|
371
|
-
args.push(arguments[i]);
|
194
|
+
var args = $A(arguments);
|
372
195
|
|
373
196
|
return function() {
|
374
197
|
var initArgs = [this].concat(args);
|
@@ -402,4 +225,3 @@ Behavior = {
|
|
402
225
|
}
|
403
226
|
};
|
404
227
|
|
405
|
-
|