- widget_id ||= input_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, '_').sub(/_$/, '') - desc = file.try(:description).try(:to_s).try!(:strip).try!(:truncate, 15).presence - empty_desc = t 'neofiles.views.no_description' - classes = [] - classes << 'neofiles-image-compact-empty' unless file - classes << 'neofiles-image-compact-with-description' if file && with_desc .neofiles-image-compact(id=widget_id data-url=neofiles_file_save_path){class: classes} - if error.present? %p.neofiles-error = error - if file .neofiles-image-compact-view= file.admin_compact_view self %a(href=neofiles_file_remove_path class="neofiles-image-compact-remove") %i.icon-remove.glyphicon.glyphicon-remove - if Neofiles.is_admin? self - options_form = capture do - if file.description.present? %p= file.description %p= raw t 'neofiles.views.created_at', local_date: l(file.created_at, format: t('neofiles.views.local_date_format')) - file_options = [] - if file.respond_to? :dimensions - file_options << "#{file.dimensions.join('×').html_safe} px" - file_options << "#{number_to_human_size file.length, precision: 0}" %p= file_options.join(', ') - if file.owner_type.present? || file.owner_id.present? %p #{t 'neofiles.views.owner'}: #{file.owner_type}#{file.owner_id} - if file.respond_to?(:no_wm) && !no_wm %p.checkbox - uniq_name = "#{widget_id}_no_wm" %label(for=uniq_name) = check_box_tag uniq_name, '1', file.no_wm, class: 'neofiles-image-compact-nowm', data: {update_url: neofiles_file_update_path} = t 'neofiles.views.no_wm' %a(href="#" tabindex="0" class="neofiles-image-compact-options" data-toggle="popover" data-trigger="click" data-placement="top" data-html="true" data-animation="false" data-title="#{file.filename}" data-content="#{options_form}") %i.icon-wrench.glyphicon.glyphicon-wrench - if with_desc - description_form = capture do - area_name = "#{widget_id}_description" = text_area_tag area_name, file.description, class: 'neofiles-image-compact-description-input', rows: 10, data: {update_url: neofiles_file_update_path} .text-center %button.btn.btn-primary.btn-small.neofiles-image-compact-description-save= t 'neofiles.views.save' - popover_template = capture do .popover.neofiles-image-compact-description-popover(role="tooltip") .arrow %h3.popover-title .popover-content .neofiles-image-compact-description %a.neofiles-image-compact-description-handle(href="#" data-empty=empty_desc data-toggle="popover" data-trigger="click" data-placement="bottom" data-html="true" data-animation="false" data-title="#{t 'neofiles.views.description'}" data-content=description_form data-template=popover_template){class: ('neofiles-image-compact-description-empty' unless desc)}= desc || empty_desc %span.neofiles-image-compact-upload-icon %i.icon-upload.glyphicon.glyphicon-upload - common_options = {id: nil, disabled: disabled} = hidden_field_tag input_name, file.try(:id), common_options.merge(class: 'neofiles-image-transfer-input') = hidden_field_tag 'neofiles[id]', file.try(:id), common_options = hidden_field_tag 'neofiles[input_name]', input_name, common_options = hidden_field_tag 'neofiles[widget_id]', widget_id, common_options = hidden_field_tag 'neofiles[clean_remove]', clean_remove ? 1 : 0, common_options = hidden_field_tag 'neofiles[append_create]', file ? 0 : (append_create ? 1 : 0), common_options = hidden_field_tag 'neofiles[multiple]', multiple ? 1 : 0, common_options = hidden_field_tag 'neofiles[with_desc]', with_desc ? 1 : 0, common_options - if no_wm = hidden_field_tag 'neofiles[no_wm]', 1, common_options = file_field_tag 'neofiles[file][]', id: nil, class: 'neofiles-image-compact-file', disabled: disabled, multiple: multiple && !file :javascript $(function() { $("##{widget_id}").image(); }); - if append_create and file = render partial: 'file_compact', locals: {file: nil, input_name: input_name, widget_id: widget_id + '_ap', clean_remove: clean_remove, append_create: true, error: nil, disabled: disabled, multiple: multiple, with_desc: with_desc, no_wm: no_wm}