summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/config/manifest.js1
-rw-r--r--app/assets/javascripts/admin_bundle.js5
-rwxr-xr-xapp/assets/javascripts/jquery.hotkeys.js244
-rw-r--r--app/helpers/link_helper.rb12
-rw-r--r--app/helpers/nodes_helper.rb16
-rw-r--r--app/views/admin/_drafts.html.erb2
-rw-r--r--app/views/admin/_menu.html.erb2
-rw-r--r--app/views/assets/index.html.erb2
-rw-r--r--app/views/events/index.html.erb2
-rw-r--r--app/views/layouts/admin.html.erb5
-rw-r--r--app/views/menu_items/index.html.erb9
-rw-r--r--app/views/nodes/edit.html.erb2
-rw-r--r--app/views/occurrences/index.html.erb2
-rw-r--r--app/views/pages/index.html.erb2
-rw-r--r--app/views/revisions/index.html.erb38
-rw-r--r--app/views/users/_user.html.erb9
16 files changed, 308 insertions, 45 deletions
diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js
index e69de29..56d7f6d 100644
--- a/app/assets/config/manifest.js
+++ b/app/assets/config/manifest.js
@@ -0,0 +1 @@
//= link admin_bundle.js
diff --git a/app/assets/javascripts/admin_bundle.js b/app/assets/javascripts/admin_bundle.js
new file mode 100644
index 0000000..687266c
--- /dev/null
+++ b/app/assets/javascripts/admin_bundle.js
@@ -0,0 +1,5 @@
1//= require jquery
2//= require jquery_ujs
3//= require jquery-ui
4//= require jquery.hotkeys
5//= require_self
diff --git a/app/assets/javascripts/jquery.hotkeys.js b/app/assets/javascripts/jquery.hotkeys.js
new file mode 100755
index 0000000..9a8f2de
--- /dev/null
+++ b/app/assets/javascripts/jquery.hotkeys.js
@@ -0,0 +1,244 @@
1/*
2(c) Copyrights 2007 - 2008
3
4Original idea by by Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/
5
6jQuery Plugin by Tzury Bar Yochay
7tzury.by@gmail.com
8http://evalinux.wordpress.com
9http://facebook.com/profile.php?id=513676303
10
11Project's sites:
12http://code.google.com/p/js-hotkeys/
13http://github.com/tzuryby/hotkeys/tree/master
14
15License: same as jQuery license.
16
17USAGE:
18 // simple usage
19 $(document).bind('keydown', 'Ctrl+c', function(){ alert('copy anyone?');});
20
21 // special options such as disableInIput
22 $(document).bind('keydown', {combi:'Ctrl+x', disableInInput: true} , function() {});
23
24Note:
25 This plugin wraps the following jQuery methods: $.fn.find, $.fn.bind and $.fn.unbind
26*/
27
28(function (jQuery){
29 // keep reference to the original $.fn.bind, $.fn.unbind and $.fn.find
30 jQuery.fn.__bind__ = jQuery.fn.bind;
31 jQuery.fn.__unbind__ = jQuery.fn.unbind;
32 jQuery.fn.__find__ = jQuery.fn.find;
33
34 var hotkeys = {
35 version: '0.7.9',
36 override: /keypress|keydown|keyup/g,
37 triggersMap: {},
38
39 specialKeys: { 27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll',
40 20: 'capslock', 144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del',
41 35:'end', 33: 'pageup', 34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down',
42 109: '-',
43 112:'f1',113:'f2', 114:'f3', 115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8',
44 120:'f9', 121:'f10', 122:'f11', 123:'f12', 191: '/'},
45
46 shiftNums: { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&",
47 "8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<",
48 ".":">", "/":"?", "\\":"|" },
49
50 newTrigger: function (type, combi, callback) {
51 // i.e. {'keyup': {'ctrl': {cb: callback, disableInInput: false}}}
52 var result = {};
53 result[type] = {};
54 result[type][combi] = {cb: callback, disableInInput: false};
55 return result;
56 }
57 };
58 // add firefox num pad char codes
59 //if (jQuery.browser.mozilla){
60 // add num pad char codes
61 hotkeys.specialKeys = jQuery.extend(hotkeys.specialKeys, { 96: '0', 97:'1', 98: '2', 99:
62 '3', 100: '4', 101: '5', 102: '6', 103: '7', 104: '8', 105: '9', 106: '*',
63 107: '+', 109: '-', 110: '.', 111 : '/'
64 });
65 //}
66
67 // a wrapper around of $.fn.find
68 // see more at: http://groups.google.com/group/jquery-en/browse_thread/thread/18f9825e8d22f18d
69 jQuery.fn.find = function( selector ) {
70 this.query = selector;
71 return jQuery.fn.__find__.apply(this, arguments);
72 };
73
74 jQuery.fn.unbind = function (type, combi, fn){
75 if (jQuery.isFunction(combi)){
76 fn = combi;
77 combi = null;
78 }
79 if (combi && typeof combi === 'string'){
80 var selectorId = ((this.prevObject && this.prevObject.query) || (this[0].id && this[0].id) || this[0]).toString();
81 var hkTypes = type.split(' ');
82 for (var x=0; x<hkTypes.length; x++){
83 delete hotkeys.triggersMap[selectorId][hkTypes[x]][combi];
84 }
85 }
86 // call jQuery original unbind
87 return this.__unbind__(type, fn);
88 };
89
90 jQuery.fn.bind = function(type, data, fn){
91 // grab keyup,keydown,keypress
92 var handle = type.match(hotkeys.override);
93
94 if (jQuery.isFunction(data) || !handle){
95 // call jQuery.bind only
96 return this.__bind__(type, data, fn);
97 }
98 else{
99 // split the job
100 var result = null,
101 // pass the rest to the original $.fn.bind
102 pass2jq = jQuery.trim(type.replace(hotkeys.override, ''));
103
104 // see if there are other types, pass them to the original $.fn.bind
105 if (pass2jq){
106 result = this.__bind__(pass2jq, data, fn);
107 }
108
109 if (typeof data === "string"){
110 data = {'combi': data};
111 }
112 if(data.combi){
113 for (var x=0; x < handle.length; x++){
114 var eventType = handle[x];
115 var combi = data.combi.toLowerCase(),
116 trigger = hotkeys.newTrigger(eventType, combi, fn),
117 selectorId = ((this.prevObject && this.prevObject.query) || (this[0].id && this[0].id) || this[0]).toString();
118
119 //trigger[eventType][combi].propagate = data.propagate;
120 trigger[eventType][combi].disableInInput = data.disableInInput;
121
122 // first time selector is bounded
123 if (!hotkeys.triggersMap[selectorId]) {
124 hotkeys.triggersMap[selectorId] = trigger;
125 }
126 // first time selector is bounded with this type
127 else if (!hotkeys.triggersMap[selectorId][eventType]) {
128 hotkeys.triggersMap[selectorId][eventType] = trigger[eventType];
129 }
130 // make trigger point as array so more than one handler can be bound
131 var mapPoint = hotkeys.triggersMap[selectorId][eventType][combi];
132 if (!mapPoint){
133 hotkeys.triggersMap[selectorId][eventType][combi] = [trigger[eventType][combi]];
134 }
135 else if (mapPoint.constructor !== Array){
136 hotkeys.triggersMap[selectorId][eventType][combi] = [mapPoint];
137 }
138 else {
139 hotkeys.triggersMap[selectorId][eventType][combi][mapPoint.length] = trigger[eventType][combi];
140 }
141
142 // add attribute and call $.event.add per matched element
143 this.each(function(){
144 // jQuery wrapper for the current element
145 var jqElem = jQuery(this);
146
147 // element already associated with another collection
148 if (jqElem.attr('hkId') && jqElem.attr('hkId') !== selectorId){
149 selectorId = jqElem.attr('hkId') + ";" + selectorId;
150 }
151 jqElem.attr('hkId', selectorId);
152 });
153 result = this.__bind__(handle.join(' '), data, hotkeys.handler)
154 }
155 }
156 return result;
157 }
158 };
159 // work-around for opera and safari where (sometimes) the target is the element which was last
160 // clicked with the mouse and not the document event it would make sense to get the document
161 hotkeys.findElement = function (elem){
162 if (!jQuery(elem).attr('hkId')){
163 if (jQuery.browser.opera || jQuery.browser.safari){
164 while (!jQuery(elem).attr('hkId') && elem.parentNode){
165 elem = elem.parentNode;
166 }
167 }
168 }
169 return elem;
170 };
171 // the event handler
172 hotkeys.handler = function(event) {
173 var target = hotkeys.findElement(event.currentTarget),
174 jTarget = jQuery(target),
175 ids = jTarget.attr('hkId');
176
177 if(ids){
178 ids = ids.split(';');
179 var code = event.which,
180 type = event.type,
181 special = hotkeys.specialKeys[code],
182 // prevent f5 overlapping with 't' (or f4 with 's', etc.)
183 character = !special && String.fromCharCode(code).toLowerCase(),
184 shift = event.shiftKey,
185 ctrl = event.ctrlKey,
186 // patch for jquery 1.2.5 && 1.2.6 see more at:
187 // http://groups.google.com/group/jquery-en/browse_thread/thread/83e10b3bb1f1c32b
188 alt = event.altKey || event.originalEvent.altKey,
189 mapPoint = null;
190
191 for (var x=0; x < ids.length; x++){
192 if (hotkeys.triggersMap[ids[x]][type]){
193 mapPoint = hotkeys.triggersMap[ids[x]][type];
194 break;
195 }
196 }
197
198 //find by: id.type.combi.options
199 if (mapPoint){
200 var trigger;
201 // event type is associated with the hkId
202 if(!shift && !ctrl && !alt) { // No Modifiers
203 trigger = mapPoint[special] || (character && mapPoint[character]);
204 }
205 else{
206 // check combinations (alt|ctrl|shift+anything)
207 var modif = '';
208 if(alt) modif +='alt+';
209 if(ctrl) modif+= 'ctrl+';
210 if(shift) modif += 'shift+';
211 // modifiers + special keys or modifiers + character or modifiers + shift character or just shift character
212 trigger = mapPoint[modif+special];
213 if (!trigger){
214 if (character){
215 trigger = mapPoint[modif+character]
216 || mapPoint[modif+hotkeys.shiftNums[character]]
217 // '$' can be triggered as 'Shift+4' or 'Shift+$' or just '$'
218 || (modif === 'shift+' && mapPoint[hotkeys.shiftNums[character]]);
219 }
220 }
221 }
222 if (trigger){
223 var result = false;
224 for (var x=0; x < trigger.length; x++){
225 if(trigger[x].disableInInput){
226 // double check event.currentTarget and event.target
227 var elem = jQuery(event.target);
228 if (jTarget.is("input") || jTarget.is("textarea") || jTarget.is("select")
229 || elem.is("input") || elem.is("textarea") || elem.is("select")) {
230 return true;
231 }
232 }
233 // call the registered callback function
234 result = result || trigger[x].cb.apply(this, [event]);
235 }
236 return result;
237 }
238 }
239 }
240 };
241 // place it under window so it can be extended and overridden by others
242 window.hotkeys = hotkeys;
243 return jQuery;
244})(jQuery);
diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb
index cb13c8d..ea6c26f 100644
--- a/app/helpers/link_helper.rb
+++ b/app/helpers/link_helper.rb
@@ -39,11 +39,11 @@ module LinkHelper
39 end 39 end
40 40
41 def unlock_link 41 def unlock_link
42 message = "Are you sure you want to unlock?\n" + 42 message = "Are you sure you want to unlock?\n" \
43 "Locked by #{@node.lock_owner.login}\n" + 43 "Locked by #{@node.lock_owner.login}\n" \
44 "Last modified #{@page.updated_at.to_fs(:db)}" 44 "Last modified #{@page.updated_at.to_fs(:db)}"
45 45 button_to 'Unlock', unlock_node_path(@node),
46 link_to 'Unlock', unlock_node_path(@node), :method => :put, :data => { :confirm => message } 46 method: :put,
47 form: { data: { confirm: message } }
47 end 48 end
48
49end 49end
diff --git a/app/helpers/nodes_helper.rb b/app/helpers/nodes_helper.rb
index c739ccd..a054a2e 100644
--- a/app/helpers/nodes_helper.rb
+++ b/app/helpers/nodes_helper.rb
@@ -28,14 +28,20 @@ module NodesHelper
28 def user_list 28 def user_list
29 User.all.map {|u| [u.login, u.id]} 29 User.all.map {|u| [u.login, u.id]}
30 end 30 end
31 31
32 def event_information 32 def event_information
33 if @node.event 33 if @node.event
34 "#{@node.event.start_time.to_fs(:db)} - #{@node.event.end_time.to_fs(:db)} > " \ 34 safe_join([
35 "#{link_to 'show', event_path(@node.event)} " \ 35 "#{@node.event.start_time.to_fs(:db)} - #{@node.event.end_time.to_fs(:db)} > ",
36 "#{link_to 'edit', edit_event_path(@node.event)}" 36 link_to('show', event_path(@node.event)),
37 ' ',
38 link_to('edit', edit_event_path(@node.event))
39 ])
37 else 40 else
38 "no event attached > #{link_to 'add', new_event_path(:node_id => @node.id)}" 41 safe_join([
42 'no event attached > ',
43 link_to('add', new_event_path(:node_id => @node.id))
44 ])
39 end 45 end
40 end 46 end
41end 47end
diff --git a/app/views/admin/_drafts.html.erb b/app/views/admin/_drafts.html.erb
index 2036d12..a35b0ab 100644
--- a/app/views/admin/_drafts.html.erb
+++ b/app/views/admin/_drafts.html.erb
@@ -17,7 +17,7 @@
17 <td class="actions"> 17 <td class="actions">
18 <%= link_to 'Show', node_path(draft.node) %> 18 <%= link_to 'Show', node_path(draft.node) %>
19 <%= link_to "Revisions", revision_path(draft.node.id) %> 19 <%= link_to "Revisions", revision_path(draft.node.id) %>
20 <%= link_to "Publish", publish_node_path(draft.node), :method => :put, :data => { :confirm => "Do you really want to publish?" } %> 20 <%= button_to "Publish", publish_node_path(draft.node), method: :put, form: { data: { confirm: "Do you really want to publish?" } } %>
21 </td> 21 </td>
22 </tr> 22 </tr>
23 <% end %> 23 <% end %>
diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb
index 3188d94..6f217eb 100644
--- a/app/views/admin/_menu.html.erb
+++ b/app/views/admin/_menu.html.erb
@@ -1,5 +1,5 @@
1<%= language_selector %> 1<%= language_selector %>
2<%= link_to 'Logout', logout_path, :method => :delete %> 2<%= button_to 'Logout', logout_path, method: :delete %>
3<%= link_to 'Overview', admin_path %> 3<%= link_to 'Overview', admin_path %>
4<%= link_to 'Nodes', nodes_path, selected?('nodes') %> 4<%= link_to 'Nodes', nodes_path, selected?('nodes') %>
5<%= link_to 'Assets', assets_path, selected?('assets') %> 5<%= link_to 'Assets', assets_path, selected?('assets') %>
diff --git a/app/views/assets/index.html.erb b/app/views/assets/index.html.erb
index e7ef313..83d55c2 100644
--- a/app/views/assets/index.html.erb
+++ b/app/views/assets/index.html.erb
@@ -15,7 +15,7 @@
15 <td><%= asset.upload.content_type %></td> 15 <td><%= asset.upload.content_type %></td>
16 <td><%= link_to 'Show', asset %></td> 16 <td><%= link_to 'Show', asset %></td>
17 <td><%= link_to 'Edit', edit_asset_path(asset) %></td> 17 <td><%= link_to 'Edit', edit_asset_path(asset) %></td>
18 <td><%= link_to 'Destroy', asset, :data => { :confirm => 'Are you sure?' }, :method => :delete %></td> 18 <td><%= button_to 'Destroy', asset, method: :delete, form: { data: { confirm: 'Are you sure?' } } %></td>
19 </tr> 19 </tr>
20<% end %> 20<% end %>
21</table> 21</table>
diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb
index 93c95fa..19b21ce 100644
--- a/app/views/events/index.html.erb
+++ b/app/views/events/index.html.erb
@@ -26,7 +26,7 @@
26 <td><%=h event.node_id %></td> 26 <td><%=h event.node_id %></td>
27 <td><%= link_to 'Show', event %></td> 27 <td><%= link_to 'Show', event %></td>
28 <td><%= link_to 'Edit', edit_event_path(event) %></td> 28 <td><%= link_to 'Edit', edit_event_path(event) %></td>
29 <td><%= link_to 'Destroy', event, :data => { :confirm => 'Are you sure?' }, :method => :delete %></td> 29 <td><%= button_to 'Destroy', event, method: :delete, form: { data: { confirm: 'Are you sure?' } } %></td>
30 </tr> 30 </tr>
31<% end %> 31<% end %>
32</table> 32</table>
diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb
index e64850b..2a90786 100644
--- a/app/views/layouts/admin.html.erb
+++ b/app/views/layouts/admin.html.erb
@@ -7,14 +7,13 @@
7 <%= csrf_meta_tags %> 7 <%= csrf_meta_tags %>
8 8
9 <title><%= "#{params[:controller]} | #{params[:action]}" %></title> 9 <title><%= "#{params[:controller]} | #{params[:action]}" %></title>
10 <%= javascript_include_tag 'jquery', 'jquery_ujs' %> 10 <%= javascript_include_tag 'admin_bundle' %>
11 <%= javascript_include_tag 'jquery-ui-1.7.2.custom.min' %>
12 <%= javascript_include_tag 'jquery.hotkeys' %>
13 <%= javascript_include_tag 'tiny_mce/jquery.tinymce.js' %> 11 <%= javascript_include_tag 'tiny_mce/jquery.tinymce.js' %>
14 <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %> 12 <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
15 <%= stylesheet_link_tag 'admin' %> 13 <%= stylesheet_link_tag 'admin' %>
16 <%= javascript_include_tag 'admin_search.js' %> 14 <%= javascript_include_tag 'admin_search.js' %>
17 <%= javascript_include_tag 'admin_interface.js' %> 15 <%= javascript_include_tag 'admin_interface.js' %>
16 <%= stylesheet_link_tag 'admin' %>
18 </head> 17 </head>
19 18
20 <body> 19 <body>
diff --git a/app/views/menu_items/index.html.erb b/app/views/menu_items/index.html.erb
index 7d0ce62..c52c150 100644
--- a/app/views/menu_items/index.html.erb
+++ b/app/views/menu_items/index.html.erb
@@ -14,12 +14,9 @@
14 <td class="menu_item_title"><%= menu_item.title %></td> 14 <td class="menu_item_title"><%= menu_item.title %></td>
15 <td><%= link_to "Edit", edit_menu_item_path(menu_item) %></td> 15 <td><%= link_to "Edit", edit_menu_item_path(menu_item) %></td>
16 <td> 16 <td>
17 <%= link_to( 17 <%= button_to "Delete", menu_item_path(menu_item),
18 "Delete", 18 method: :delete,
19 menu_item_path(menu_item), 19 form: { data: { confirm: "Are you sure?" } } %>
20 :method => :delete,
21 :data => { :confirm => "Are you sure?" }
22 ) %>
23 </td> 20 </td>
24 </tr> 21 </tr>
25 <% end %> 22 <% end %>
diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb
index 64884cf..596f992 100644
--- a/app/views/nodes/edit.html.erb
+++ b/app/views/nodes/edit.html.erb
@@ -2,7 +2,7 @@
2 <%= link_to 'metadata', '#', :id => 'button', :class => "unselected" %> 2 <%= link_to 'metadata', '#', :id => 'button', :class => "unselected" %>
3 <%= link_to 'Show', @node %> 3 <%= link_to 'Show', @node %>
4 <%= link_to 'Preview', preview_page_path(@draft) %> 4 <%= link_to 'Preview', preview_page_path(@draft) %>
5 <%= link_to 'Publish', publish_node_path, :method => :put, :data => { :confirm => "Publish this draft?" } %> 5 <%= button_to 'Publish', publish_node_path(@node), method: :put, form: { data: { confirm: "Publish this draft?" } } %>
6 <%= link_to 'Revisions', node_revisions_path(@node) %> 6 <%= link_to 'Revisions', node_revisions_path(@node) %>
7<% end %> 7<% end %>
8 8
diff --git a/app/views/occurrences/index.html.erb b/app/views/occurrences/index.html.erb
index 7b8ffb8..0e99857 100644
--- a/app/views/occurrences/index.html.erb
+++ b/app/views/occurrences/index.html.erb
@@ -18,7 +18,7 @@
18 <td><%=h occurrence.event_id %></td> 18 <td><%=h occurrence.event_id %></td>
19 <td><%= link_to 'Show', occurrence %></td> 19 <td><%= link_to 'Show', occurrence %></td>
20 <td><%= link_to 'Edit', edit_occurrence_path(occurrence) %></td> 20 <td><%= link_to 'Edit', edit_occurrence_path(occurrence) %></td>
21 <td><%= link_to 'Destroy', occurrence, :data => { :confirm => 'Are you sure?' }, :method => :delete %></td> 21 <td><%= button_to 'Destroy', occurrence, method: :delete, form: { data: { confirm: 'Are you sure?' } } %></td>
22 </tr> 22 </tr>
23<% end %> 23<% end %>
24</table> 24</table>
diff --git a/app/views/pages/index.html.erb b/app/views/pages/index.html.erb
index 4b28c9b..91e5359 100644
--- a/app/views/pages/index.html.erb
+++ b/app/views/pages/index.html.erb
@@ -12,7 +12,7 @@
12 <td><%=h page.title %></td> 12 <td><%=h page.title %></td>
13 <td><%= link_to 'Show', content_path(:page_path => page.node.unique_path) %></td> 13 <td><%= link_to 'Show', content_path(:page_path => page.node.unique_path) %></td>
14 <td><%= link_to 'Edit', edit_page_path(page) %></td> 14 <td><%= link_to 'Edit', edit_page_path(page) %></td>
15 <td><%= link_to 'Destroy', page, :data => { :confirm => 'Are you sure?' }, :method => :delete %></td> 15 <td><%= button_to 'Destroy', page, method: :delete, form: { data: { confirm: 'Are you sure?' } } %></td>
16 </tr> 16 </tr>
17<% end %> 17<% end %>
18</table> 18</table>
diff --git a/app/views/revisions/index.html.erb b/app/views/revisions/index.html.erb
index e038ed2..b875a4f 100644
--- a/app/views/revisions/index.html.erb
+++ b/app/views/revisions/index.html.erb
@@ -4,7 +4,6 @@
4 4
5<h2>Revisions for Node: <%= @node.unique_name %></h2> 5<h2>Revisions for Node: <%= @node.unique_name %></h2>
6 6
7<%= form_tag diff_node_revisions_path(@node) do %>
8<table id="revisions"> 7<table id="revisions">
9 <tr class="header"> 8 <tr class="header">
10 <th>First</th> 9 <th>First</th>
@@ -14,6 +13,7 @@
14 <th>Editor</th> 13 <th>Editor</th>
15 <th>Date</th> 14 <th>Date</th>
16 <th></th> 15 <th></th>
16 <th></th>
17 </tr> 17 </tr>
18<% (@pages || @node.pages.all).reverse.each do |page| %> 18<% (@pages || @node.pages.all).reverse.each do |page| %>
19 <tr> 19 <tr>
@@ -23,22 +23,36 @@
23 <td class="title"><%= page.title %></td> 23 <td class="title"><%= page.title %></td>
24 <td class="user"><%= page.editor.try(:login) %></td> 24 <td class="user"><%= page.editor.try(:login) %></td>
25 <td class="date"><%= page.updated_at %></td> 25 <td class="date"><%= page.updated_at %></td>
26 <td><%= link_to 'show', node_revision_path(@node, page) %></td>
26 <td> 27 <td>
27 <%= link_to 'show', node_revision_path(@node, page) %> 28 <%= button_to 'restore', restore_node_revision_path(@node, page),
28 </td> 29 method: :put,
29 <td> 30 form: { data: { confirm: "Restore this revision?" } } %>
30 <%= link_to(
31 'restore',
32 restore_node_revision_path(@node, page),
33 :method => :put,
34 :data => { :confirm => "Restore this revision?" }
35 ) %>
36 </td> 31 </td>
37 </tr> 32 </tr>
38<% end %> 33<% end %>
39 <tr class="no_hover"> 34 <tr class="no_hover">
40 <td colspan="8" class="right"><%= submit_tag 'Diff revisions' %></td> 35 <td colspan="8" class="right">
36 <%= button_to 'Diff revisions', diff_node_revisions_path(@node),
37 method: :post,
38 form: { id: 'diff_form' } %>
39 </td>
41 </tr> 40 </tr>
42</table> 41</table>
43 42
44<% end %> 43<script>
44 document.getElementById('diff_form').addEventListener('submit', function(e) {
45 var start = document.querySelector('input[name="start_revision"]:checked');
46 var end = document.querySelector('input[name="end_revision"]:checked');
47 if (start) {
48 var s = document.createElement('input');
49 s.type = 'hidden'; s.name = 'start_revision'; s.value = start.value;
50 this.appendChild(s);
51 }
52 if (end) {
53 var en = document.createElement('input');
54 en.type = 'hidden'; en.name = 'end_revision'; en.value = end.value;
55 this.appendChild(en);
56 }
57 });
58</script>
diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb
index 9987e31..ddb7afd 100644
--- a/app/views/users/_user.html.erb
+++ b/app/views/users/_user.html.erb
@@ -7,12 +7,9 @@
7 <%= link_to "edit", edit_user_path(user) %> 7 <%= link_to "edit", edit_user_path(user) %>
8 </td> 8 </td>
9 <td> 9 <td>
10 <%= link_to( 10 <%= button_to "destroy", user_path(user),
11 "destroy", 11 method: :delete,
12 user_path(user), 12 form: { data: { confirm: "Do you really want to delete user #{user.login}?" } } %>
13 :method => :delete,
14 :data => { :confirm => "Do you really want to delete user #{user.login}?" }
15 ) %>
16 </td> 13 </td>
17 <% end %> 14 <% end %>
18</tr> 15</tr>