Skip to content
Browse files

Start rolling multi-upload into galleries.

  • Loading branch information...
1 parent 518006e commit 23158da0c9164e5db9f2ba36165e8ff0d3b9108c @robyurkowski robyurkowski committed Mar 28, 2012
View
32 app/assets/javascripts/refinery/portfolio/admin/portfolio.js.coffee
@@ -0,0 +1,32 @@
+# Use local alias
+$ = jQuery
+
+window.portfolio =
+ append_image: (image) ->
+ image_id = $(image).attr('id').replace 'image', ''
+ new_image = $('#page_images li.image_field:first-child').clone() # Clone li
+
+ # new_item.find('input').next().val image_id # Set input image_id value = image_id
+
+ # Update thumbnail
+ new_image.find('.thumb img').attr('src', $(image).attr('data-grid'))
+ # Update id
+ new_image.attr('id', "image_#{image_id}")
+
+ # Append to list
+ new_image.appendTo '#page_images'
+
+$ ->
+ page_options.init(false, '', '')
+ $('#page_images').sortable()
+
+ # Edit image association?
+
+ # Remove image association
+ $('.delete_image').on 'click', ->
+ if confirm("Are you sure you want to delete this image?")
+ $(this).parents('li').remove()
+ else
+ false
+
+
View
0 ...cripts/refinery/portfolio/frontend.js.erb → ...ripts/refinery/portfolio/portfolio.js.erb
File renamed without changes.
View
3 app/assets/stylesheets/refinery/portfolio/admin/galleries.css.scss
@@ -1,3 +0,0 @@
-#records .actions {
- width: 150px;
-}
View
55 app/assets/stylesheets/refinery/portfolio/admin/galleries.css.scss.erb
@@ -0,0 +1,55 @@
+<% thumb_width, thumb_height = ::Refinery::Portfolio.cover_image_thumb_size.split('x').map(&:to_i) %>
+
+#records .actions {
+ width: 150px;
+}
+
+a#add_image_link {
+ background: image-url('refinery/icons/add.png') no-repeat 0 6px;
+ margin-top: 10px;
+ line-height: 29px;
+ padding-left: 20px;
+ display: inline;
+}
+
+#page_images {
+ li.image_field {
+ text-align: center;
+ position: relative;
+ margin: 5px;
+ width: <%= thumb_width %>px;
+ float: left;
+
+ &:hover div.image_actions {
+ display: block;
+ width: 100%;
+ position: absolute;
+ top: 50%;
+ height: 1px;
+ overflow: visible;
+ text-align: center;
+
+ div.floater {
+ position: absolute;
+ left: 50%;
+ margin-left: -20px;
+ margin-top: -8px;
+ width: 50px;
+ text-align: center;
+ height: 22px;
+
+ img {
+ cursor: pointer;
+ }
+ }
+ }
+
+ div.image_actions {
+ display: none;
+ }
+ }
+}
+
+div.wym_skin_refinery {
+ opacity: 1 !important;
+}
View
15 app/views/refinery/portfolio/admin/galleries/_form.html.erb
@@ -22,13 +22,19 @@
<%= link_to t("#{part}", :scope => "activerecord.attributes.refinery/portfolio/gallery", :default => part.to_s.titleize), "##{part}" %>
</li>
<% end %>
+ <li class='ui-state-default'>
+ <%= link_to t('.images'), "#images" %>
+ </li>
</ul>
<div id='page_part_editors'>
<% [:body].each do |part| %>
<div class='page_part' id='<%= part %>'>
<%= f.text_area part, :rows => 20, :class => 'wymeditor widest' -%>
</div>
<% end %>
+ <div class='page_part' id='images'>
+ <%= render :partial => 'images', :locals => {:f => f} %>
+ </div>
</div>
</div>
</div>
@@ -49,10 +55,5 @@
:delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @gallery.title)
} %>
<% end -%>
-<% content_for :javascripts do %>
- <script>
- $(document).ready(function(){
- page_options.init(false, '', '');
- });
- </script>
-<% end %>
+<% content_for :javascripts, javascript_include_tag('refinery/portfolio/admin/portfolio') %>
+<% content_for :stylesheets, stylesheet_link_tag('refinery/portfolio/admin/galleries') %>
View
15 app/views/refinery/portfolio/admin/galleries/_image.html.erb
@@ -0,0 +1,15 @@
+<div class='wym_box field item_group'>
+ <ul id='page_images' class='clearfix'>
+ <% f.object.items.order("position").each_with_index do |item, i| %>
+ <li id='<%= dom_id(item) %>' class='image_field'>
+ <div class='thumb'><%= image_fu item.image, ::Refinery::Portfolio.cover_image_thumb_size %></div>
+ <div class='image_actions'>
+ <div class='floater'>
+ <%= image_tag('refinery/icons/edit.png', {:width => 22, :height => 22, :class => 'edit_image', :alt => 'edit', :'data-item-id' => item.id }) %>
+ <%= image_tag('refinery/icons/delete.png', {:width => 22, :height => 22, :class => 'delete_image', :alt => 'delete', :'data-item-id' => item.id }) %>
+ </div>
+ </div>
+ </li>
+ <% end %>
+ </ul>
+</div>
View
13 app/views/refinery/portfolio/admin/galleries/_images.html.erb
@@ -0,0 +1,13 @@
+<div class='wym_skin_refinery' id='images_picker'>
+ <%= render :partial => "image", :locals => {:f => f} %>
+
+ <span class='clearfix label_inline_with_link'>
+ <%= link_to t('.add_new_image'), refinery.insert_admin_images_url({
+ :dialog => true,
+ :width => 950,
+ :height => 510,
+ :callback => "portfolio.append_image"
+ }),
+ :id => "add_image_link" %>
+ </span>
+</div>
View
3 config/locales/en.yml
@@ -47,6 +47,9 @@ en:
parent_gallery_help: You can nest a gallery inside another gallery, creating a multiple-level portfolio. Choose a gallery to make this gallery the child of the one you select, or leave it blank to keep it as a top-level gallery.
cover_image: Cover Image
cover_image_help: The image that is used as the cover of this gallery.
+ images: Images
+ items:
+ add_new_image: Add an image
galleries:
show:
other: Other Galleries

0 comments on commit 23158da

Please sign in to comment.
Something went wrong with that request. Please try again.