Commit ad994069 authored by azul's avatar azul

cleanup: disabled gallery views and helper functions

parent 8fd0de54
module GalleryHelper
def gallery_detail_view_url(gallery, image = nil, this_id = nil)
image = (image.is_a?(Showing) ? image.asset : image)
page_url(gallery, action: 'detail_view', id: (image ? image.id :
this_id))
end
# navigation for gallery. pass elements to show as arguments. possible
# elements are (right now, maybe more to come):
# * count - shows number of total images (or current image index if we
# are in detail_view action)
# * download - link to download the gallery in zipped format. (detail_view:
# download this image)
# * slideshow - link to GalleryController#slideshow
# * edit - link to edit action (or show if we are in edit action)
# * show - link to show action (no matter where we are)
# * upload - link to display upload box (or go to upload action if JS is
# disabled)
#
# Elements need to be passed as symbols or strings. They will appear in the
# order they are given.
# Raises an argument error if the element doesn't exist.
def gallery_navigation(*_elements)
available_elements = {
detail_view: lambda {
@detail_view_navigation or ''
},
add_existing: lambda {
link_to(I18n.t(:add_existing_image),
page_url(@page, action: 'find'),
class: 'small_icon plus_16')
}
}
output = '<div class="gallery-nav" align="right">'
output << available_elements[:detail_view].call
output << '<span class="gallery-actions">'
# TODO: We are not allowing to selected uploaded photos for now see ticket #1654
# output << available_elements[:add_existing].call unless params[:action] == 'find'
output << '</span>'
output << '</div>'
output
end
def gallery_display_image_position
if @image_index
......@@ -51,23 +8,6 @@ module GalleryHelper
end
end
def upload_images_link
link_to_modal I18n.t(:add_images_to_gallery_link),
page_url(@page, action: 'new', controller: :image),
complete: 'styleUpload();',
class: 'icon plus_16'
end
def gallery_edit_image(image)
url = page_url @page,
controller: :image,
action: 'edit',
id: image.id
link_to_modal '&nbsp;', url,
title: I18n.t(:edit_image),
class: 'small_icon empty pencil_16'
end
def gallery_make_images_sortable_js
sortable_element 'assets_list',
constraint: false,
......@@ -75,77 +15,6 @@ module GalleryHelper
url: sort_images_url(page_id: @page)
end
def gallery_move_image_without_js(image)
output = '<noscript>'
output += link_to(image_tag('icons/small_png/left.png',
title: I18n.t(:move_image_left)),
controller: 'gallery',
action: 'update_order',
page_id: @page.id,
id: image.id,
direction: 'left')
output += link_to(image_tag('icons/small_png/right.png',
title: I18n.t(:move_image_right)),
controller: 'gallery',
action: 'update_order',
page_id: @page.id,
id: image.id,
direction: 'right')
output += '</noscript>'
output
end
def render_image_form_with_progress
render_form_with_progress_for @image,
url: gallery_image_form_url,
upload_id: @image_upload_id
end
def gallery_image_form_url
page_url @page,
:controller => :image,
:action => @image ? 'update' : 'create',
'X-Progress-ID' => @image_upload_id,
:id => @image && @image.id
end
def js_style(var, style)
output = []
style.split(';').each do |part|
key, value = part.split(':')
output << "#{var}.style['#{key}'] = '#{value}';"
end
output.join "\n"
end
def image_title(image)
change_title = "$('change_title_form').show();$('detail_image_title').hide();return false;"
caption = image.caption ? h(image.caption) : '[click here to edit caption]'
output = content_tag :p, caption, class: 'description small_icon pencil_16',
id: 'detail_image_title', onclick: change_title
output << render('change_image_title', image: image)
output
end
# form_options = {
# :url => image_url(image, page_id: @page)
# :update => 'detail_image_title',
# :complete => "$('detail_image_title').show()",
# :pending => "$('change_title_spinner').show()"
# }
def save_caption_form_options(page, image)
{ url: page_url(page,
controller: :image,
action: 'update',
id: image.id),
update: 'detail_image_title',
complete: %{$('detail_image_title').show();
$('change_title_form').hide();
$('save_caption_buttons').show();
$('change_title_spinner').hide();},
loading: "$('save_caption_buttons').hide(); $('change_title_spinner').show();" }
end
def next_image_link
if @next
url = image_url(@next.asset_id, page_id: @page)
......
content_html = ''
item.images.each do |image|
xml << render(:partial => 'asset_page/rss_asset_tags', :locals => {:object => image})
content_html << content_tag(:p,
image_tag(url_for(:controller => image.url, :only_path => false), :width => image.width, :height => image.height, :alt => image.page.nil? ? "" : image.page.title) +
(image.page.nil? ? "" : "<br />" + content_tag(:strong, image.page.title.to_s) +
"<br />" + image.page.summary.to_s)
)
end
xml.content :encoded do
xml.cdata! content_html
end
\ No newline at end of file
<%-
cancel_action = "$('change_title_form').hide();$('detail_image_title').show();"
-%>
<div id="change_title_form" style='display:none' class='p'>
<% form_remote_tag(save_caption_form_options(@page, @image)) do -%>
<%= text_area_tag 'image[caption]', h(@image.caption), :cols => '50' %>
<%= spinner('change_title') %>
<span id='save_caption_buttons'>
<input type="submit" value="<%= I18n.t(:save_button) %>" id='save_caption_button' />
<%= button_to_function I18n.t(:cancel), cancel_action %>
</div>
<% end -%>
</div>
<%-
#submit_action = "$('change_title_form_submit').disabled=true;this.value='Saving...';$('change_title_spinner').show();$('change_title_form_cancel').hide();"
#form_options = {
# :url => images_url(image, page_id: @page),
# :update => 'detail_image_title',
# :complete => "$('detail_image_title').show()",
# :pending => "$('change_title_spinner').show()"
#}
form_options = page_url(@page, :action => 'image-update', :id => image.id)
cancel_action = "$('change_title_form').hide();$('detail_image_title').show();"
-%>
<div id="change_title_form" style='display:none' class='p'>
<% form_tag(form_options) do -%>
<%= text_field_tag 'image[caption]', h(image.caption) %>
<input type="submit", value="<%= I18n.t(:save_button) %>" />
<%= button_to_function I18n.t(:cancel), cancel_action %>
<%# spinner('change_title') %>
<% end -%>
</div>
%hr
%div{align: 'right'}
= spinner('close_button')
#close_button
= button_to_function I18n.t(:close_and_reload_gallery), "$('close_button').hide(); $('close_button_spinner').show(); window.location='"+page_url(@page,action: 'edit')+"';"
\ No newline at end of file
#update_message{style: "color: red;"}
#show-image= render partial: 'show_image', locals: {size: 'medium', no_link: true}
#upload-new-image
= render_image_form_with_progress
.gallery_item
= image_title @image
<%= javascript_include_tag('as_needed/upload') %>
<% upload_image_form = capture do %>
<% form_for(:image, :url => page_url(@page, :action => 'image-update', 'X-Progress-ID' => @upload_id, :id => @image.id),
:html => {:multipart => true, :target => 'upload_frame'}) do |f| -%>
<%= hidden_field_tag 'X-Progress-ID', @upload_id %>
<div class='action'>
<%= render :partial => 'asset_page/file_field', :locals => {:size => 25} %>
</div>
<%= submit_tag 'Upload', :onClick => "startProgressBar(this);" %>
<%= spinner 'upload' %>
<% end -%>
<iframe id='upload_frame' name="upload_frame" style="width:1px;height:1px;border:0px" src="about:blank"></iframe>
<%= render :partial => 'common/upload_progress_bar' %>
<% end %>
<%= upload_image_form %>
\ No newline at end of file
=# this partial only responds to ajax requests
- if params.has_key? 'caption'
= h(@image.caption)
\ No newline at end of file
#upload-template(style="display:none")
= render partial:'asset_page/file_field', locals: {size: 25}
= render partial:'asset_page/file_field', locals: {size: 25}
#add_file_field.action
%a(onclick="addFileField();")
=I18n.t(:add_another_file)
= render partial: 'common/progress_bar/bar'
<h2> <%= link_to_remote I18n.t(:upload_images_link),
{ :url => page_url(@page, :action => 'upload'), :update => 'target_for_upload'}
%> |
<%= I18n.t(:upload_zip_file_link) %></h2>
<% form_tag page_url(@page, :action => 'upload_zip'), :method => :post, :multipart => true do -%>
<%= spinner('upload') %>
<input type="file" size="38" name="zipfile" /><br />
<%= submit_tag I18n.t(:upload), :onClick => "$('upload_spinner').show();" %>
<%= button_to_function I18n.t(:cancel), "new Effect.SlideUp($('target_for_upload'));" %>
<% end -%>
%h2.big_icon.page_gallery_48.title
= I18n.t :edit_image_header
= render partial: 'gallery_image/edit'
= render partial: 'close_and_reload_button'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment