puffer 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/app/cells/puffer/base/additional.html.erb +13 -5
- data/app/helpers/puffer_helper.rb +6 -1
- data/app/views/layouts/puffer.html.erb +5 -3
- data/app/views/puffer/_form.html.erb +1 -1
- data/app/views/puffer/associated/one.js.erb +9 -0
- data/app/views/puffer/edit.html.erb +1 -1
- data/app/views/puffer/index.html.erb +7 -7
- data/app/views/puffer/new.html.erb +1 -1
- data/app/views/puffer/show.html.erb +4 -4
- data/lib/generators/puffer/install/templates/puffer/javascripts/application.js +10 -0
- data/lib/generators/puffer/install/templates/puffer/javascripts/rails-src.js +36 -378
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-autocompleter-src.js +621 -0
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-autocompleter.js +18 -0
- data/lib/generators/puffer/install/templates/puffer/javascripts/right-autocompleter.js.gz +0 -0
- data/lib/generators/puffer/install/templates/puffer/stylesheets/puffer.css +107 -6
- data/lib/puffer/base.rb +4 -3
- data/lib/puffer/controller/actions.rb +4 -70
- data/lib/puffer/controller/dsl.rb +23 -5
- data/lib/puffer/controller/generated.rb +65 -0
- data/lib/puffer/extensions/activerecord.rb +3 -3
- data/lib/puffer/extensions/core.rb +14 -0
- data/lib/puffer/extensions/mapper.rb +20 -0
- data/lib/puffer/fields.rb +11 -2
- data/lib/puffer/fields/field.rb +24 -1
- data/lib/puffer/inputs.rb +1 -3
- data/lib/puffer/inputs/association.rb +27 -1
- data/lib/puffer/inputs/base.rb +12 -4
- data/lib/puffer/inputs/boolean.rb +1 -1
- data/lib/puffer/inputs/date_time.rb +1 -1
- data/lib/puffer/resource.rb +1 -1
- data/lib/puffer/resource/routing.rb +2 -2
- data/lib/puffer/resource/scoping.rb +5 -1
- data/puffer.gemspec +15 -5
- data/spec/dummy/app/controllers/admin/profiles_controller.rb +2 -2
- data/spec/dummy/app/views/admin/users/index.html.erb +3 -1
- data/spec/dummy/config/database.yml +1 -1
- data/spec/dummy/public/puffer/javascripts/application.js +10 -0
- data/spec/dummy/public/puffer/javascripts/rails-src.js +36 -378
- data/spec/dummy/public/puffer/javascripts/right-autocompleter-src.js +621 -0
- data/spec/dummy/public/puffer/javascripts/right-autocompleter.js +18 -0
- data/spec/dummy/public/puffer/javascripts/right-autocompleter.js.gz +0 -0
- data/spec/dummy/public/puffer/stylesheets/puffer.css +107 -6
- data/spec/lib/extensions/core_spec.rb +29 -0
- data/spec/lib/resource/routing_spec.rb +11 -11
- metadata +28 -18
- data/lib/generators/puffer/install/templates/puffer/javascripts/rails.js +0 -14
- data/spec/dummy/public/puffer/javascripts/rails.js +0 -14
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
@@ -1,17 +1,25 @@
|
|
1
1
|
<dl>
|
2
2
|
<dt>Links</dt>
|
3
3
|
<dd>
|
4
|
-
<%= link_to_unless_current t(:list, :target => resource.human), resource.
|
4
|
+
<%= link_to_unless_current t(:list, :target => resource.human), resource.collection_path %>
|
5
5
|
<%= link_to_unless_current t(:add, :target => resource.human), resource.new_path %>
|
6
6
|
</dd>
|
7
7
|
<dt>Search</dt>
|
8
8
|
<dd>
|
9
|
-
<%= form_tag resource.
|
10
|
-
<%= text_field_tag :
|
9
|
+
<%= form_tag resource.collection_path, {:method => :get} do %>
|
10
|
+
<%= text_field_tag :search, params[:search] %>
|
11
11
|
<%= submit_tag 'Search' %>
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
<% if false %>
|
16
|
+
<% if resource_session[:search].present? %>
|
17
|
+
<%= link_to 'clear', resource.collection_path(:search => '') %>
|
14
18
|
<% end %>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
|
22
|
+
|
15
23
|
<% end %>
|
16
24
|
</dd>
|
17
25
|
</dl>
|
@@ -14,8 +14,13 @@ module PufferHelper
|
|
14
14
|
else ''
|
15
15
|
end
|
16
16
|
else
|
17
|
-
res =
|
17
|
+
res = record.call_chain(field.field)
|
18
18
|
end
|
19
|
+
unless field.native?
|
20
|
+
url = edit_polymorphic_path [resource.prefix, record.call_chain(field.path)] rescue nil
|
21
|
+
res = link_to res, url if url
|
22
|
+
end
|
23
|
+
res
|
19
24
|
end
|
20
25
|
|
21
26
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
<html
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
3
|
<head>
|
4
4
|
<title><%= [@title, 'Puffer'].compact.join(' - ') %></title>
|
5
5
|
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
@@ -9,8 +9,10 @@
|
|
9
9
|
<%= yield :stylesheet %>
|
10
10
|
|
11
11
|
<%= javascript_include_tag '/puffer/javascripts/right-src' %>
|
12
|
-
<%= javascript_include_tag '/puffer/javascripts/rails-src' %>
|
13
12
|
<%= javascript_include_tag '/puffer/javascripts/right-calendar-src' %>
|
13
|
+
<%= javascript_include_tag '/puffer/javascripts/right-autocompleter-src' %>
|
14
|
+
<%= javascript_include_tag '/puffer/javascripts/rails-src' %>
|
15
|
+
<%= javascript_include_tag '/puffer/javascripts/application' %>
|
14
16
|
<%= yield :javascript %>
|
15
17
|
</head>
|
16
18
|
<body>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<ul>
|
2
|
+
<% primary_key = @field.reflection.primary_key_column.name.to_sym %>
|
3
|
+
<% records.each do |record| %>
|
4
|
+
<li data-id="<%= record[primary_key] %>">
|
5
|
+
<div class="title"><strong><%= record[primary_key] %></strong> — <%= record.to_title %></div>
|
6
|
+
<div class="description">record.password</div>
|
7
|
+
</li>
|
8
|
+
<% end %>
|
9
|
+
</ul>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% @title = "Edit #{resource.human}" %>
|
2
2
|
<h1><%= @title %></h1>
|
3
|
-
<%= form_for record, :url => resource.
|
3
|
+
<%= form_for record, :url => resource.member_path, :html => {:multipart => true} do |f| %>
|
4
4
|
<%= render :partial => 'terbium/form', :locals => { :f => f, :action => 'edit' } %>
|
5
5
|
<% end %>
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% @title = resource.human %>
|
2
2
|
<h1><%= @title %></h1>
|
3
|
-
<%= will_paginate records, :url => resource.
|
3
|
+
<%= will_paginate records, :url => resource.collection_path(:page => '') %>
|
4
4
|
<% if records.present? %>
|
5
5
|
<table class="list_table">
|
6
6
|
<thead>
|
@@ -18,9 +18,9 @@
|
|
18
18
|
<td><%= render_field field, record %></td>
|
19
19
|
<% end -%>
|
20
20
|
<td class="actions">
|
21
|
-
<%= link_to 'show', resource.
|
21
|
+
<%= link_to 'show', resource.member_path(record), :class => 'show_entry' if show_fields.present? || resource.children.present? %>
|
22
22
|
<%= link_to 'edit', resource.edit_path(record), :class => 'edit_entry' if update_fields.present? %>
|
23
|
-
<%= link_to 'destroy', resource.
|
23
|
+
<%= link_to 'destroy', resource.member_path(record), :confirm => "Are you sure?", :method => :delete, :class => 'remove_entry' if configuration.destroy %>
|
24
24
|
</td>
|
25
25
|
</tr>
|
26
26
|
<% end -%>
|
@@ -29,16 +29,16 @@
|
|
29
29
|
<% else %>
|
30
30
|
<p>Sorry, but there is no records in <%= resource.human %></p>
|
31
31
|
<% end %>
|
32
|
-
<%= will_paginate records, :url => resource.
|
32
|
+
<%= will_paginate records, :url => resource.collection_path(:page => '') %>
|
33
33
|
|
34
34
|
<% if false %>
|
35
35
|
<% content_for :additional_navigation do %>
|
36
36
|
<ul class="buttons">
|
37
37
|
<% resource.ancestors.each do |resource| %>
|
38
|
-
<%= link_to resource.plural? ? resource.human : resource.member.to_title, resource.
|
39
|
-
<%= link_to resource.member.to_title, resource.
|
38
|
+
<%= link_to resource.plural? ? resource.human : resource.member.to_title, resource.collection_path %>
|
39
|
+
<%= link_to resource.member.to_title, resource.member_path unless resource.plural? %>
|
40
40
|
<% end %>
|
41
|
-
<%= link_to resource.plural? ? resource.human : resource.member.to_title, resource.
|
41
|
+
<%= link_to resource.plural? ? resource.human : resource.member.to_title, resource.collection_path %>
|
42
42
|
</ul>
|
43
43
|
<% end %>
|
44
44
|
<% end %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% @title = "New #{resource.human}" %>
|
2
2
|
<h1><%= @title %></h1>
|
3
|
-
<%= form_for record, :url => resource.
|
3
|
+
<%= form_for record, :url => resource.collection_path, :html => {:multipart => true} do |f| %>
|
4
4
|
<%= render :partial => 'terbium/form', :locals => { :f => f, :action => 'new' } %>
|
5
5
|
<% end %>
|
6
6
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<li>
|
6
6
|
<h2>Associations</h2>
|
7
7
|
<% resource.children.each do |child| %>
|
8
|
-
<%= link_to child.human, child.
|
8
|
+
<%= link_to child.human, child.collection_path %>
|
9
9
|
<% end %>
|
10
10
|
</li>
|
11
11
|
<% end %>
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<li>
|
15
15
|
<h2><%= field.label %></h2>
|
16
16
|
<div>
|
17
|
-
<%= render_field
|
17
|
+
<%= render_field field, record %>
|
18
18
|
</div>
|
19
19
|
</li>
|
20
20
|
<% end if show_fields && record -%>
|
@@ -22,8 +22,8 @@
|
|
22
22
|
<% content_for :additional_navigation do %>
|
23
23
|
<ul class="buttons">
|
24
24
|
<% (resource.ancestors + [resource]).each do |resource| %>
|
25
|
-
<%= link_to resource.plural? ? resource.human : resource.member.to_title, resource.
|
26
|
-
<%= link_to resource.member.to_title, resource.
|
25
|
+
<%= link_to resource.plural? ? resource.human : resource.member.to_title, resource.collection_path %>
|
26
|
+
<%= link_to resource.member.to_title, resource.member_path unless resource.plural? %>
|
27
27
|
<% end %>
|
28
28
|
</ul>
|
29
29
|
<% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
var association_done = function(event) {
|
2
|
+
current = this.first('li.current')
|
3
|
+
this.input.next('input[type=hidden]').value(current.get('data-id'));
|
4
|
+
this.input.value(current.find('.title').first().html().stripTags()).disable();
|
5
|
+
}
|
6
|
+
|
7
|
+
'.association_clear'.on('click', function(event) {
|
8
|
+
this.prev('input[type=text]').value('').enable();
|
9
|
+
this.next('input[type=hidden]').value('');
|
10
|
+
});
|
@@ -1,115 +1,16 @@
|
|
1
|
-
/**
|
2
|
-
* The Ruby On Rails plugin for RightJS
|
3
|
-
* http://github.com/MadRabbit/right-rails
|
4
|
-
*
|
5
|
-
* Copyright (C) 2009-2010 Nikolay Nemshilov
|
6
|
-
*/
|
7
1
|
(function(window, document, RightJS) {
|
8
|
-
/**
|
9
|
-
* Underscored aliases for Ruby On Rails
|
10
|
-
*
|
11
|
-
* Copyright (C) 2009-2010 Nikolay Nemshilov
|
12
|
-
*/
|
13
2
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
*/
|
3
|
+
var $ = RightJS.$,
|
4
|
+
$$ = RightJS.$$,
|
5
|
+
$E = RightJS.$E,
|
6
|
+
Xhr = RightJS.Xhr;
|
19
7
|
|
20
|
-
var
|
21
|
-
|
22
|
-
|
23
|
-
$E = RightJS.$E,
|
24
|
-
Xhr = RightJS.Xhr,
|
25
|
-
Object = RightJS.Object;
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
// the language and window level aliases
|
30
|
-
R([
|
31
|
-
RightJS.String.prototype,
|
32
|
-
RightJS.Array.prototype,
|
33
|
-
RightJS.Function.prototype,
|
34
|
-
RightJS.Object,
|
35
|
-
RightJS.Options,
|
36
|
-
RightJS.Observer,
|
37
|
-
RightJS.Observer.prototype,
|
38
|
-
window,
|
39
|
-
document
|
40
|
-
]).each(function(object) {
|
41
|
-
for (var key in object) {
|
42
|
-
try { // some keys are not accessable
|
43
|
-
|
44
|
-
if (/[A-Z]/.test(key) && typeof(object[key]) === 'function') {
|
45
|
-
var u_key = R(key).underscored();
|
46
|
-
if (object[u_key] === null || object[u_key] === undefined) {
|
47
|
-
object[u_key] = object[key];
|
48
|
-
}
|
49
|
-
}
|
50
|
-
} catch (e) {}
|
51
|
-
}
|
52
|
-
});
|
53
|
-
|
54
|
-
|
55
|
-
// DOM package aliases
|
56
|
-
R([
|
57
|
-
RightJS.Element,
|
58
|
-
RightJS.Event,
|
59
|
-
RightJS.Form,
|
60
|
-
RightJS.Input
|
61
|
-
]).each(function(object) {
|
62
|
-
if (!object) { return; }
|
63
|
-
|
64
|
-
var aliases = {}, methods = object.prototype;
|
65
|
-
|
66
|
-
for (var key in methods) {
|
67
|
-
if (/[A-Z]/.test(key) && typeof(methods[key]) === 'function') {
|
68
|
-
object.prototype[R(key).underscored()] = methods[key];
|
69
|
-
}
|
8
|
+
var cancel = function(element) {
|
9
|
+
var message = element.get('data-confirm');
|
10
|
+
return(message && !confirm(message));
|
70
11
|
}
|
71
|
-
});
|
72
12
|
|
73
|
-
|
74
|
-
RightJS.$alias(RightJS.String.prototype, {
|
75
|
-
index_of: 'indexOf',
|
76
|
-
last_index_of: 'lastIndexOf',
|
77
|
-
to_f: 'toFloat',
|
78
|
-
to_i: 'toInt',
|
79
|
-
gsub: 'replace',
|
80
|
-
downcase: 'toLowerCase',
|
81
|
-
upcase: 'toUpperCase',
|
82
|
-
index: 'indexOf',
|
83
|
-
rindex: 'lastIndexOf',
|
84
|
-
strip: 'trim'
|
85
|
-
});
|
86
|
-
|
87
|
-
RightJS.$alias(RightJS.Array.prototype, {
|
88
|
-
collect: 'map',
|
89
|
-
detect: 'filter',
|
90
|
-
index_of: 'indexOf',
|
91
|
-
last_index_of: 'lastIndexOf',
|
92
|
-
index: 'indexOf',
|
93
|
-
rindex: 'lastIndexOf'
|
94
|
-
});
|
95
|
-
|
96
|
-
/**
|
97
|
-
* Rails 3 UJS support module
|
98
|
-
*
|
99
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
100
|
-
*/
|
101
|
-
(function() {
|
102
|
-
// tries to cancel the event via confirmation
|
103
|
-
var user_cancels = function(event, element) {
|
104
|
-
var message = element.get('data-confirm');
|
105
|
-
if (message && !confirm(message)) {
|
106
|
-
event.stop();
|
107
|
-
return true;
|
108
|
-
}
|
109
|
-
};
|
110
|
-
|
111
|
-
// adds XHR events to the element
|
112
|
-
var add_xhr_events = function(element, options) {
|
13
|
+
var xhr_events = function(element, options) {
|
113
14
|
return Object.merge({
|
114
15
|
onCreate: function() { element.fire('ajax:loading', this); },
|
115
16
|
onComplete: function() { element.fire('ajax:complete', this); },
|
@@ -117,283 +18,40 @@ RightJS.$alias(RightJS.Array.prototype, {
|
|
117
18
|
onFailure: function() { element.fire('ajax:failure', this); }
|
118
19
|
}, options);
|
119
20
|
};
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
21
|
+
|
22
|
+
'form[data-remote]'.on('submit', function(event) {
|
23
|
+
event.stop();
|
24
|
+
this.send();
|
25
|
+
});
|
26
|
+
|
27
|
+
'a[data-confirm], a[data-method], a[data-remote]'.on('click', function(event) {
|
28
|
+
if (cancel(this)) { event.stop(); return; }
|
29
|
+
|
30
|
+
var method = this.get('data-method') || 'get',
|
31
|
+
remote = !!this.get('data-remote'),
|
32
|
+
url = this.get('href');
|
33
|
+
|
34
|
+
if (method != 'get' || remote) { event.stop(); }
|
35
|
+
|
131
36
|
if (remote) {
|
132
|
-
Xhr.load(url,
|
133
|
-
method: method
|
134
|
-
spinner:
|
37
|
+
Xhr.load(url, xhr_events(this, {
|
38
|
+
method: method,
|
39
|
+
spinner: this.get('data-spinner')
|
135
40
|
}));
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
41
|
+
}
|
42
|
+
|
43
|
+
if (method != 'get') {
|
44
|
+
var param = $$('meta[name=csrf-param]')[0].get('content'),
|
45
|
+
token = $$('meta[name=csrf-token]')[0].get('content'),
|
140
46
|
form = $E('form', {action: url, method: 'post'});
|
141
|
-
|
47
|
+
|
142
48
|
if (param && token) {
|
143
|
-
form.insert('<input type="hidden" name="'+param
|
49
|
+
form.insert('<input type="hidden" name="' + param + '" value="' + token + '" />');
|
144
50
|
}
|
145
|
-
|
146
|
-
form.insert('<input type="hidden" name="_method" value="'+method+'"/>')
|
147
|
-
.insertTo(document.body).submit();
|
148
|
-
}
|
149
|
-
};
|
150
51
|
|
151
|
-
|
152
|
-
|
153
|
-
click: function(event) {
|
154
|
-
var tag = event.target._.tagName;
|
155
|
-
if (tag === 'A' || tag === 'BUTTON') {
|
156
|
-
try_link_submit(event);
|
157
|
-
}
|
158
|
-
},
|
159
|
-
|
160
|
-
submit: function(event) {
|
161
|
-
var form = event.target;
|
162
|
-
if (form.has('data-remote') && !user_cancels(event, form)) {
|
163
|
-
event.stop();
|
164
|
-
form.send(add_xhr_events(form, {
|
165
|
-
spinner: form.get('data-spinner') || form.first('.spinner')
|
166
|
-
}));
|
167
|
-
}
|
52
|
+
form.insert('<input type="hidden" name="_method" value="' + method + '"/>')
|
53
|
+
.insertTo(document.body).submit();
|
168
54
|
}
|
169
55
|
});
|
170
|
-
})();
|
171
|
-
|
172
|
-
|
173
|
-
/**
|
174
|
-
* RR is the common ajax operations wrapper for ruby on rails
|
175
|
-
*
|
176
|
-
* Copyright (C) 2009-2010 Nikolay Nemshilov
|
177
|
-
*/
|
178
|
-
var RR = {
|
179
|
-
/**
|
180
|
-
* Basic options
|
181
|
-
*
|
182
|
-
* NOTE: DO NOT CHANGE this hash right here
|
183
|
-
* Use your application.js file to alter the options
|
184
|
-
*/
|
185
|
-
Options: {
|
186
|
-
format: 'js', // the working format for remote requests over the application
|
187
|
-
|
188
|
-
flashId: 'flashes', // the flashes element id
|
189
|
-
flashHideFx: 'slide', // use null if you don't want any fx in here
|
190
|
-
flashHideDelay: 3200, // use -1 to disable the flash element hidding
|
191
|
-
|
192
|
-
highlightUpdates: true,
|
193
|
-
|
194
|
-
removeFx: 'fade', // blocks removing fx
|
195
|
-
insertFx: 'fade', // blocks insertion fx
|
196
|
-
|
197
|
-
insertPosition: 'bottom', // default insert position
|
198
|
-
|
199
|
-
linkToAjaxEdit: '.ajax_edit',
|
200
|
-
linkToAjaxDelete: '.ajax_delete',
|
201
|
-
|
202
|
-
rescanWithScopes: true // if it should rescan only updated elements
|
203
|
-
},
|
204
|
-
|
205
|
-
/**
|
206
|
-
* Updates the flashes block with the source
|
207
|
-
*
|
208
|
-
* @param String new content
|
209
|
-
* @return RR this
|
210
|
-
*/
|
211
|
-
update_flash: function(content) {
|
212
|
-
var element = $(this.Options.flashId);
|
213
|
-
if (element) {
|
214
|
-
this.replace(element, content).hide_flash();
|
215
|
-
}
|
216
|
-
return this;
|
217
|
-
},
|
218
|
-
|
219
|
-
/**
|
220
|
-
* Initializes the delayed flashes hide call
|
221
|
-
*
|
222
|
-
* @return RR this
|
223
|
-
*/
|
224
|
-
hide_flash: function() {
|
225
|
-
if (this.Options.flashHideDelay > -1) {
|
226
|
-
var element = $(this.Options.flashId);
|
227
|
-
if (element && element.visible()) {
|
228
|
-
element.hide.bind(element, this.Options.flashHideFx).delay(this.Options.flashHideDelay);
|
229
|
-
}
|
230
|
-
}
|
231
|
-
return this;
|
232
|
-
},
|
233
|
-
|
234
|
-
/**
|
235
|
-
* Highlights the element according to the options
|
236
|
-
*
|
237
|
-
* @param String element id
|
238
|
-
* @return RR this
|
239
|
-
*/
|
240
|
-
highlight: function(id) {
|
241
|
-
if ($(id) && this.Options.highlightUpdates) {
|
242
|
-
$(id).highlight();
|
243
|
-
}
|
244
|
-
return this;
|
245
|
-
},
|
246
|
-
|
247
|
-
/**
|
248
|
-
* Inserts the content into the given element
|
249
|
-
*
|
250
|
-
* @param destination String destination id
|
251
|
-
* @param content String content
|
252
|
-
* @param position String position
|
253
|
-
* @return RR this
|
254
|
-
*/
|
255
|
-
insert: function(where, what, in_position) {
|
256
|
-
var position = in_position || this.Options.insertPosition, new_element,
|
257
|
-
container = $(where).insert(what, position);
|
258
|
-
|
259
|
-
// trying to find the new block
|
260
|
-
switch (position) {
|
261
|
-
case 'bottom': new_element = container.children().last(); break;
|
262
|
-
case 'top': new_element = container.first(); break;
|
263
|
-
case 'before': new_element = container.prev(); break;
|
264
|
-
case 'after': new_element = container.next(); break;
|
265
|
-
}
|
266
|
-
|
267
|
-
// necely displaying the new block
|
268
|
-
if (new_element && this.Options.insertFx) {
|
269
|
-
new_element.hide().show(this.Options.insertFx, {
|
270
|
-
onFinish: this.highlight.bind(this, new_element)
|
271
|
-
});
|
272
|
-
} else {
|
273
|
-
this.highlight(new_element);
|
274
|
-
}
|
275
|
-
|
276
|
-
return this.rescan(where);
|
277
|
-
},
|
278
|
-
|
279
|
-
/**
|
280
|
-
* Replaces the given element with a new content
|
281
|
-
*
|
282
|
-
* @param destination String destination id
|
283
|
-
* @param content String content
|
284
|
-
* @return RR this
|
285
|
-
*/
|
286
|
-
replace: function(id, source) {
|
287
|
-
$(id).replace(source);
|
288
|
-
return this.highlight(id).rescan(id);
|
289
|
-
},
|
290
|
-
|
291
|
-
/**
|
292
|
-
* removes the element by id
|
293
|
-
*
|
294
|
-
* @param String element id
|
295
|
-
* @return RR this
|
296
|
-
*/
|
297
|
-
remove: function(id) {
|
298
|
-
if ($(id)) {
|
299
|
-
$(id).remove(this.Options.removeFx);
|
300
|
-
}
|
301
|
-
},
|
302
|
-
|
303
|
-
/**
|
304
|
-
* Makes a remote form out of the form
|
305
|
-
*
|
306
|
-
* @param String form id
|
307
|
-
* @return RR this
|
308
|
-
*/
|
309
|
-
remotize_form: function(id) {
|
310
|
-
var form = $(id);
|
311
|
-
if (form) {
|
312
|
-
form.remotize().enable()._.action += '.'+this.Options.format;
|
313
|
-
}
|
314
|
-
return this;
|
315
|
-
},
|
316
|
-
|
317
|
-
/**
|
318
|
-
* Replaces the form with new content and makes it remote
|
319
|
-
*
|
320
|
-
* @param form id String form id
|
321
|
-
* @param content String content
|
322
|
-
* @return RR this
|
323
|
-
*/
|
324
|
-
replace_form: function(id, source) {
|
325
|
-
var form = $(id);
|
326
|
-
if (form) {
|
327
|
-
form.replace(source);
|
328
|
-
this.remotize_form(id);
|
329
|
-
}
|
330
|
-
|
331
|
-
return this.rescan(id);
|
332
|
-
},
|
333
|
-
|
334
|
-
/**
|
335
|
-
* Inserts the form source into the given element
|
336
|
-
*
|
337
|
-
* @param target id String target id
|
338
|
-
* @param source String form source
|
339
|
-
* @return RR this
|
340
|
-
*/
|
341
|
-
show_form_for: function(id, source) {
|
342
|
-
$(id).select('form').each('remove'); // removing old forms
|
343
|
-
$(id).insert(source);
|
344
|
-
|
345
|
-
return this.remotize_form($(id).first('form')).rescan(id);
|
346
|
-
},
|
347
|
-
|
348
|
-
/**
|
349
|
-
* watches link clicks and processes the ajax edit/delete operations
|
350
|
-
*
|
351
|
-
* @param Event event
|
352
|
-
*/
|
353
|
-
process_click: function(event) {
|
354
|
-
var link;
|
355
|
-
|
356
|
-
if ((link = event.find('a'+ this.Options.linkToAjaxEdit))) {
|
357
|
-
event.stop();
|
358
|
-
Xhr.load(link.get('href') + '.' + this.Options.format);
|
359
|
-
} else if ((link = event.find('a'+ this.Options.linkToAjaxDelete)) && link.has('onclick')) {
|
360
|
-
event.stop();
|
361
|
-
eval('({f:'+ link.onclick.toString().replace('.submit', '.send')+'})').f.call(link);
|
362
|
-
}
|
363
|
-
},
|
364
|
-
|
365
|
-
/**
|
366
|
-
* Scans for updated elements
|
367
|
-
*
|
368
|
-
* @return RR this
|
369
|
-
*/
|
370
|
-
rescan: function(scope) {
|
371
|
-
$w('Draggable Droppable Tabs Slider Selectable').each(function(name) {
|
372
|
-
if (name in window) {
|
373
|
-
window[name].rescan(this.Options.rescanWithScopes ? scope : null);
|
374
|
-
}
|
375
|
-
}, this);
|
376
|
-
|
377
|
-
|
378
|
-
return this;
|
379
|
-
}
|
380
|
-
};
|
381
56
|
|
382
|
-
|
383
|
-
/**
|
384
|
-
* the document onload hooks
|
385
|
-
*
|
386
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
387
|
-
*/
|
388
|
-
$(document).on({
|
389
|
-
ready: function() {
|
390
|
-
RR.hide_flash();
|
391
|
-
},
|
392
|
-
|
393
|
-
click: function(event) {
|
394
|
-
RR.process_click(event);
|
395
|
-
}
|
396
|
-
});
|
397
|
-
|
398
|
-
window.RR = RR;
|
399
|
-
})(window, document, RightJS);
|
57
|
+
})(window, document, RightJS);
|