From f4692182c0d2b28036916e6379198a99c8912b6a Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Wed, 2 Jan 2013 16:32:47 +0800 Subject: [PATCH] when mouse move to button of announcement file : image => preview pic, file => type --- .../announcement/back_end/bulletins_helper.rb | 13 +- .../bulletins/_form_bulletin_file.html.erb | 143 +++++++++--------- 2 files changed, 77 insertions(+), 79 deletions(-) diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb index 7b145bd2..65d172fa 100644 --- a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb +++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb @@ -38,20 +38,17 @@ module Panel::Announcement::BackEnd::BulletinsHelper def file_picture_preview_setting(file_path) res= "" - ext = File.extname(file_path) + ext = File.extname(file_path)[1..-1] + puts ext unless file_path.nil? case ext - when ".jpg",".jpeg",".png",".gif" - #res = '' - #res.html_safe + when "jpg","jpeg","png","gif" {"data-content" => "#{image_tag file_path}" } + when "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx" + {"data-content" => "#{image_tag("http://#{request.host_with_port}/assets/ft-icons/#{ext}/#{ext}-48_32.png")}"} else {"data-content" => t("sys.not_previewable") } end end end - - end diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb index a1697b2a..1cd0d6f3 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form_bulletin_file.html.erb @@ -1,75 +1,76 @@ <% # encoding: utf-8 %> - " class='list_item'> - -
-
- <%= f.file_field :file %> - <%#= form_bulletin_file.file.file ? ( link_to t(:view), form_bulletin_file.file.url, {:class => 'btn', :target => '_blank', :title => t(:view)} ) : '' %> - <%= form_bulletin_file.file.file ? ( link_to t(:view), form_bulletin_file.file.url, {:class => 'for_preview btn', :target => '_blank', :title => t(:view)}.merge(file_picture_preview_setting(form_bulletin_file.file.url)) ) : '' %> -
-
- - - -
- - <% @site_valid_locales.each_with_index do |locale, i| %> - -
"> - - <%= f.fields_for :title_translations do |f| %> -
- -
- <%= f.text_field locale, :id => "link-#{locale}", :value => (form_bulletin_file.title_translations[locale] rescue nil) %> -
-
- <% end %> - -
+" class='list_item'> + +
+
+ <% if form_bulletin_file.new_record? %> + <%= f.file_field :file %> + <% end %> + <%= form_bulletin_file.file.file ? ( link_to t(:view), form_bulletin_file.file.url, {:class => 'for_preview btn', :target => '_blank', :title => t(:view), "data-trigger" => :hover}.merge(file_picture_preview_setting(form_bulletin_file.file.url)) ) : '' %> +
+
+ + - <% end %> - -
- - - - -
- - <% @site_valid_locales.each_with_index do |locale, i| %> - -
"> - - <%= f.fields_for :description_translations do |f| %> -
- -
- <%= f.text_field locale, :id => "link-#{locale}", :value => (form_bulletin_file.description_translations[locale] rescue nil) %> -
-
- <% end %> - -
+
+ + <% @site_valid_locales.each_with_index do |locale, i| %> + +
"> + + <%= f.fields_for :title_translations do |f| %> +
+ +
+ <%= f.text_field locale, :id => "link-#{locale}", :value => (form_bulletin_file.title_translations[locale] rescue nil) %> +
+
+ <% end %> + +
+ + <% end %> + +
+ + + + +
+ + <% @site_valid_locales.each_with_index do |locale, i| %> + +
"> + + <%= f.fields_for :description_translations do |f| %> +
+ +
+ <%= f.text_field locale, :id => "link-#{locale}", :value => (form_bulletin_file.description_translations[locale] rescue nil) %> +
+
+ <% end %> + +
+ + <% end %> + +
+ + + + + <% if form_bulletin_file.new_record? %> + + <% else %> + <%= f.hidden_field :id %> + <%= hidden_field_tag :tr, (dom_id form_bulletin_file) %> + + <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> + <% end %> + + + + - <% end %> - -
- - - - - <% if form_bulletin_file.new_record? %> - - <% else %> - <%= f.hidden_field :id %> - <%= hidden_field_tag :tr, (dom_id form_bulletin_file) %> - - <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> - <% end %> - - - - -