when mouse move to button of announcement file : image => preview pic, file => type
This commit is contained in:
		
							parent
							
								
									506770bf33
								
							
						
					
					
						commit
						f4692182c0
					
				| 
						 | 
				
			
			@ -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 = '<div class="for_preview" style="display:none;">'
 | 
			
		||||
          #res << image_tag(file_path, {:title => t(:view)})
 | 
			
		||||
          #res << '</div>'
 | 
			
		||||
          #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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,75 +1,76 @@
 | 
			
		|||
<% # encoding: utf-8 %>
 | 
			
		||||
 | 
			
		||||
		<tr id="<%= "bulletin_file_#{form_bulletin_file.id}" if !form_bulletin_file.new_record? %>" class='list_item'>
 | 
			
		||||
			<td>
 | 
			
		||||
				<div class="control-group">
 | 
			
		||||
					<div class="controls">
 | 
			
		||||
					<%= 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)) ) : '' %>
 | 
			
		||||
					</div>
 | 
			
		||||
				</div>
 | 
			
		||||
			</td>	
 | 
			
		||||
			<td>	
 | 
			
		||||
			
 | 
			
		||||
				<div class="tab-content">
 | 
			
		||||
				
 | 
			
		||||
					<% @site_valid_locales.each_with_index do |locale, i| %>
 | 
			
		||||
					
 | 
			
		||||
					<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
 | 
			
		||||
						
 | 
			
		||||
						<%= f.fields_for :title_translations do |f| %>
 | 
			
		||||
							<div class="control-group">
 | 
			
		||||
								<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
 | 
			
		||||
								<div class="controls">
 | 
			
		||||
								<%= f.text_field locale, :id => "link-#{locale}", :value => (form_bulletin_file.title_translations[locale] rescue nil) %>
 | 
			
		||||
								</div>
 | 
			
		||||
							</div>
 | 
			
		||||
						<% end %>
 | 
			
		||||
						
 | 
			
		||||
					</div>
 | 
			
		||||
<tr id="<%= "bulletin_file_#{form_bulletin_file.id}" if !form_bulletin_file.new_record? %>" class='list_item'>
 | 
			
		||||
  <td>
 | 
			
		||||
    <div class="control-group">
 | 
			
		||||
      <div class="controls">
 | 
			
		||||
        <% 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)) ) : '' %>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
  </td> 
 | 
			
		||||
  <td> 
 | 
			
		||||
 | 
			
		||||
					<% end %>
 | 
			
		||||
					
 | 
			
		||||
				</div>
 | 
			
		||||
				
 | 
			
		||||
			</td>
 | 
			
		||||
			<td>	
 | 
			
		||||
			
 | 
			
		||||
				<div class="tab-content">
 | 
			
		||||
				
 | 
			
		||||
					<% @site_valid_locales.each_with_index do |locale, i| %>
 | 
			
		||||
					
 | 
			
		||||
					<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
 | 
			
		||||
						
 | 
			
		||||
						<%= f.fields_for :description_translations do |f| %>
 | 
			
		||||
							<div class="control-group">
 | 
			
		||||
								<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
 | 
			
		||||
								<div class="controls">
 | 
			
		||||
								<%= f.text_field locale, :id => "link-#{locale}", :value => (form_bulletin_file.description_translations[locale] rescue nil) %>
 | 
			
		||||
								</div>
 | 
			
		||||
							</div>
 | 
			
		||||
						<% end %>
 | 
			
		||||
						
 | 
			
		||||
					</div>
 | 
			
		||||
    <div class="tab-content">
 | 
			
		||||
 | 
			
		||||
      <% @site_valid_locales.each_with_index do |locale, i| %>
 | 
			
		||||
 | 
			
		||||
        <div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
 | 
			
		||||
 | 
			
		||||
          <%= f.fields_for :title_translations do |f| %>
 | 
			
		||||
            <div class="control-group">
 | 
			
		||||
              <label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
 | 
			
		||||
              <div class="controls">
 | 
			
		||||
                <%= f.text_field locale, :id => "link-#{locale}", :value => (form_bulletin_file.title_translations[locale] rescue nil) %>
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
          <% end %>
 | 
			
		||||
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
      <% end %>
 | 
			
		||||
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
  </td>
 | 
			
		||||
  <td> 
 | 
			
		||||
 | 
			
		||||
    <div class="tab-content">
 | 
			
		||||
 | 
			
		||||
      <% @site_valid_locales.each_with_index do |locale, i| %>
 | 
			
		||||
 | 
			
		||||
        <div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
 | 
			
		||||
 | 
			
		||||
          <%= f.fields_for :description_translations do |f| %>
 | 
			
		||||
            <div class="control-group">
 | 
			
		||||
              <label for="link-<%= locale %>" class="control-label"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></label>
 | 
			
		||||
              <div class="controls">
 | 
			
		||||
                <%= f.text_field locale, :id => "link-#{locale}", :value => (form_bulletin_file.description_translations[locale] rescue nil) %>
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
          <% end %>
 | 
			
		||||
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
      <% end %>
 | 
			
		||||
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
  </td> 
 | 
			
		||||
  <td>
 | 
			
		||||
    <span class="action">
 | 
			
		||||
      <% if form_bulletin_file.new_record? %>
 | 
			
		||||
        <a class="delete"><i class="icon-remove"></i></a>
 | 
			
		||||
      <% else %> 
 | 
			
		||||
        <%= f.hidden_field :id %>
 | 
			
		||||
        <%= hidden_field_tag :tr, (dom_id form_bulletin_file) %>
 | 
			
		||||
        <a class="remove_existing_record"><i class="icon-remove"></i></a>
 | 
			
		||||
        <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
 | 
			
		||||
      <% end %>
 | 
			
		||||
    </span>
 | 
			
		||||
 | 
			
		||||
  </td>
 | 
			
		||||
</tr>
 | 
			
		||||
 | 
			
		||||
					<% end %>
 | 
			
		||||
					
 | 
			
		||||
				</div>
 | 
			
		||||
				
 | 
			
		||||
			</td>	
 | 
			
		||||
			<td>
 | 
			
		||||
				<span class="action">
 | 
			
		||||
				<% if form_bulletin_file.new_record? %>
 | 
			
		||||
				  <a class="delete"><i class="icon-remove"></i></a>
 | 
			
		||||
				<% else %>	
 | 
			
		||||
				  <%= f.hidden_field :id %>
 | 
			
		||||
				  <%= hidden_field_tag :tr, (dom_id form_bulletin_file) %>
 | 
			
		||||
				  <a class="remove_existing_record"><i class="icon-remove"></i></a>
 | 
			
		||||
				  <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
 | 
			
		||||
				<% end %>
 | 
			
		||||
				</span>
 | 
			
		||||
			
 | 
			
		||||
			</td>
 | 
			
		||||
		</tr>
 | 
			
		||||
		
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue