diff options
| -rw-r--r-- | app/controllers/pages_controller.rb | 14 | ||||
| -rw-r--r-- | app/views/nodes/edit.html.erb | 23 | ||||
| -rw-r--r-- | app/views/nodes/show.html.erb | 2 | ||||
| -rw-r--r-- | config/routes.rb | 2 | ||||
| -rw-r--r-- | public/javascripts/admin_interface.js | 36 | ||||
| -rw-r--r-- | public/stylesheets/admin.css | 28 |
6 files changed, 98 insertions, 7 deletions
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index e298265..4b3b541 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb | |||
| @@ -12,4 +12,18 @@ class PagesController < ApplicationController | |||
| 12 | end | 12 | end |
| 13 | 13 | ||
| 14 | end | 14 | end |
| 15 | |||
| 16 | |||
| 17 | def sort_images | ||
| 18 | page = Page.find(params[:id]) | ||
| 19 | |||
| 20 | page.related_assets.destroy_all | ||
| 21 | |||
| 22 | params[:images].each_with_index do |id, index| | ||
| 23 | asset = Asset.find(id) | ||
| 24 | page.related_assets.create(:asset_id => asset.id, :position => index+1) | ||
| 25 | end | ||
| 26 | |||
| 27 | render :nothing => true, :status => 200 | ||
| 28 | end | ||
| 15 | end | 29 | end |
diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index 00815b7..a8138c2 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb | |||
| @@ -36,10 +36,15 @@ | |||
| 36 | </tr> | 36 | </tr> |
| 37 | <tr> | 37 | <tr> |
| 38 | <td class="description">Images</td> | 38 | <td class="description">Images</td> |
| 39 | <td style="height: 200px"> | 39 | <td> |
| 40 | <% @draft.assets.images.each do |image| %> | 40 | <ul id="image_box" rel="<%= @draft.id %>"> |
| 41 | <%= image_tag(image.upload.url(:thumb)) %> | 41 | <% @draft.assets.images.each do |image| %> |
| 42 | <% end %> | 42 | <li rel="images_<%= image.id %>"> |
| 43 | <%= image_tag(image.upload.url(:thumb)) %> | ||
| 44 | </li> | ||
| 45 | <% end %> | ||
| 46 | </ul> | ||
| 47 | add image | ||
| 43 | </td> | 48 | </td> |
| 44 | </tr> | 49 | </tr> |
| 45 | </table> | 50 | </table> |
| @@ -69,4 +74,14 @@ | |||
| 69 | </table> | 74 | </table> |
| 70 | <% end %> | 75 | <% end %> |
| 71 | <% end %> | 76 | <% end %> |
| 77 | </div> | ||
| 78 | |||
| 79 | |||
| 80 | |||
| 81 | <div id="asset_toolbox"> | ||
| 82 | <ul> | ||
| 83 | <% Asset.images.each do |image| %> | ||
| 84 | <li rel="images_<%= image.id %>"><%= image_tag(image.upload.url(:thumb)) %></li> | ||
| 85 | <% end %> | ||
| 86 | </ul> | ||
| 72 | </div> \ No newline at end of file | 87 | </div> \ No newline at end of file |
diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb index 8aaedc5..15547f9 100644 --- a/app/views/nodes/show.html.erb +++ b/app/views/nodes/show.html.erb | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <% content_for :subnavigation do %> | 1 | <% content_for :subnavigation do %> |
| 2 | <%= link_to 'Edit', edit_node_path(@node), :id => 'button', :class => "unselected" %> | 2 | <%= link_to 'Edit', edit_node_path(@node), :class => "unselected" %> |
| 3 | <%= link_to 'Preview', preview_page_path(@page) %> | 3 | <%= link_to 'Preview', preview_page_path(@page) %> |
| 4 | <%= link_to 'Revisions', revision_path(params[:id]) %> | 4 | <%= link_to 'Revisions', revision_path(params[:id]) %> |
| 5 | <% end %> | 5 | <% end %> |
diff --git a/config/routes.rb b/config/routes.rb index f94b61c..b8c877b 100644 --- a/config/routes.rb +++ b/config/routes.rb | |||
| @@ -13,7 +13,7 @@ ActionController::Routing::Routes.draw do |map| | |||
| 13 | map.resources :occurrences | 13 | map.resources :occurrences |
| 14 | map.resources :events | 14 | map.resources :events |
| 15 | map.resources :revisions, :member => {:diff => :post, :restore => :put} | 15 | map.resources :revisions, :member => {:diff => :post, :restore => :put} |
| 16 | map.resources :pages, :member => {:preview => :get} | 16 | map.resources :pages, :member => {:preview => :get, :sort_images => :put} |
| 17 | map.resources :nodes, :member => {:publish => :put, :unlock => :put} | 17 | map.resources :nodes, :member => {:publish => :put, :unlock => :put} |
| 18 | map.logout '/logout', :controller => 'sessions', :action => 'destroy' | 18 | map.logout '/logout', :controller => 'sessions', :action => 'destroy' |
| 19 | map.login '/login', :controller => 'sessions', :action => 'new' | 19 | map.login '/login', :controller => 'sessions', :action => 'new' |
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index ce971a4..977e42a 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js | |||
| @@ -4,6 +4,7 @@ $(document).ready(function () { | |||
| 4 | meta_data.initialize(); | 4 | meta_data.initialize(); |
| 5 | menu_item_sorter.initialize(); | 5 | menu_item_sorter.initialize(); |
| 6 | 6 | ||
| 7 | |||
| 7 | jQuery.ajaxSetup({ | 8 | jQuery.ajaxSetup({ |
| 8 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} | 9 | 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} |
| 9 | }) | 10 | }) |
| @@ -27,6 +28,7 @@ meta_data = { | |||
| 27 | 28 | ||
| 28 | if ($("#button").attr("class") == "unselected") { | 29 | if ($("#button").attr("class") == "unselected") { |
| 29 | $("#button").attr("class", "selected"); | 30 | $("#button").attr("class", "selected"); |
| 31 | image_interface.initialize(); | ||
| 30 | } | 32 | } |
| 31 | else { | 33 | else { |
| 32 | $("#button").attr("class", "unselected"); | 34 | $("#button").attr("class", "unselected"); |
| @@ -110,5 +112,39 @@ menu_item_sorter = { | |||
| 110 | $(".ui-state-highlight").html("<td colspan='100%'></td>"); | 112 | $(".ui-state-highlight").html("<td colspan='100%'></td>"); |
| 111 | } | 113 | } |
| 112 | } | 114 | } |
| 115 | |||
| 116 | image_interface = { | ||
| 117 | initialize : function() { | ||
| 118 | $("ul#image_box").sortable({ | ||
| 119 | revert : true, | ||
| 120 | stop : function(event, ui) { | ||
| 121 | $.ajax({ | ||
| 122 | type : "POST", | ||
| 123 | url : "/pages/" + $("ul#image_box").attr("rel") + "/sort_images", | ||
| 124 | dataType : "json", | ||
| 125 | data : $("ul#image_box").sortable("serialize", {attribute : "rel"}) + "&_method=put", | ||
| 126 | success : function() {} | ||
| 127 | }); | ||
| 128 | } | ||
| 129 | }); | ||
| 130 | |||
| 131 | $("ul#image_box").droppable({ | ||
| 132 | out : function(event, ui) { | ||
| 133 | $(ui.draggable).bind("mouseup", function() {$(this).remove()}) | ||
| 134 | } | ||
| 135 | }); | ||
| 136 | |||
| 137 | $("div#asset_toolbox ul li").draggable({ | ||
| 138 | connectToSortable : 'ul#image_box', | ||
| 139 | helper : 'clone', | ||
| 140 | revert : 'invalid', | ||
| 141 | stop : function() { | ||
| 142 | |||
| 143 | } | ||
| 144 | }); | ||
| 145 | |||
| 146 | $("ul, li").disableSelection(); | ||
| 147 | } | ||
| 148 | } | ||
| 113 | 149 | ||
| 114 | 150 | ||
diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index a2da502..d414b94 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css | |||
| @@ -355,4 +355,30 @@ table#content th.content { | |||
| 355 | 355 | ||
| 356 | .ui-state-highlight td{ | 356 | .ui-state-highlight td{ |
| 357 | height: 20px; | 357 | height: 20px; |
| 358 | } \ No newline at end of file | 358 | } |
| 359 | |||
| 360 | #metadata ul#image_box { | ||
| 361 | margin: 0; | ||
| 362 | padding-left: 0; | ||
| 363 | height: 100px; | ||
| 364 | width: 690px; | ||
| 365 | padding-top: 10px; | ||
| 366 | padding-bottom: 10px; | ||
| 367 | border: 1px solid #989898; | ||
| 368 | } | ||
| 369 | |||
| 370 | #metadata ul#image_box li { | ||
| 371 | float: left; | ||
| 372 | list-style-type: none; | ||
| 373 | margin: 5px; | ||
| 374 | } | ||
| 375 | |||
| 376 | div#asset_toolbox { | ||
| 377 | position: absolute; | ||
| 378 | top: 40px; | ||
| 379 | left: 800px; | ||
| 380 | } | ||
| 381 | |||
| 382 | div#asset_toolbox ul li { | ||
| 383 | list-style-type: none; | ||
| 384 | } | ||
