Skip to content

Instantly share code, notes, and snippets.

View varyform's full-sized avatar

Oleh Khomei varyform

View GitHub Profile
@varyform
varyform / new.html.haml
Created August 27, 2012 20:23
Photo picker with live preview
%div.tac
-# remotipart for ajax image upload
= form_for Parent.new, url: upload_parent_photo_path, remote: true, html: { id: 'file-form' } do |f|
#temp-photo.tac{ style: "position: relative; background: url('#{image_path(resource.avatar.url(:thumb))}') center center no-repeat; height: 120px" }
-# prompt
= link_to '#', class: 'btn btn-mini btn-light', style: 'opacity: 0.9; position: absolute; bottom: 0; left: 50%; width: 100px; margin-left: -55px' do
Choose Photo
-# almost transparent file field which actually receives mouse click and "covers" link above
= f.file_field :avatar, id: 'temp-avatar', style: 'position: absolute; cursor: pointer; opacity: 0.01; top: 0; left: 0; width: 100%; height: 100%; '