DG IZ; added simple image picker for edit profile page. currently displays all images uploaded.
This commit is contained in:
parent
e08ed8805f
commit
7901791ee3
6 changed files with 71 additions and 7 deletions
|
|
@ -12,6 +12,7 @@ class UsersController < ApplicationController
|
||||||
def edit
|
def edit
|
||||||
@user = User.first(:id => params[:id])
|
@user = User.first(:id => params[:id])
|
||||||
@profile = @user.profile
|
@profile = @user.profile
|
||||||
|
@photos = Photo.all
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@
|
||||||
= stylesheet_link_tag "blueprint/screen", :media => 'screen'
|
= stylesheet_link_tag "blueprint/screen", :media => 'screen'
|
||||||
= stylesheet_link_tag "application"
|
= stylesheet_link_tag "application"
|
||||||
/= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
|
/= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
|
||||||
= javascript_include_tag 'jquery142', 'rails', 'view', 'publisher', 'google'
|
= javascript_include_tag 'jquery142', 'rails', 'google'
|
||||||
|
= javascript_include_tag 'view', 'publisher', 'image_picker'
|
||||||
= javascript_include_tag 'tiny_mce/tiny_mce', 'jquery.infieldlabel'
|
= javascript_include_tag 'tiny_mce/tiny_mce', 'jquery.infieldlabel'
|
||||||
= render 'js/websocket_js'
|
= render 'js/websocket_js'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,31 @@
|
||||||
%h3 Editing Profile
|
%h1 Editing Profile
|
||||||
|
|
||||||
= form_for @user do |f|
|
= form_for @user do |f|
|
||||||
= f.error_messages
|
= f.error_messages
|
||||||
|
|
||||||
= f.fields_for :profile do |p|
|
= f.fields_for :profile do |p|
|
||||||
|
|
||||||
|
%h3 Picture
|
||||||
|
%div#image_picker
|
||||||
|
= p.hidden_field :image_url, :value => @profile.image_url, :id => 'image_url_field'
|
||||||
|
- for photo in @photos
|
||||||
|
- if photo.image.url(:thumb_medium) == @profile.image_url
|
||||||
|
%div.small_photo{:id => photo.image.thumb_medium.url, :class=>'selected'}
|
||||||
|
= check_box_tag 'checked_photo', true, true
|
||||||
|
= link_to image_tag(photo.image.url(:thumb_medium)), "#"
|
||||||
|
- else
|
||||||
|
%div.small_photo{:id => photo.image.thumb_medium.url}
|
||||||
|
= check_box_tag 'checked_photo'
|
||||||
|
= link_to image_tag(photo.image.url(:thumb_medium)), "#"
|
||||||
|
|
||||||
|
|
||||||
|
%h3 Info
|
||||||
%p
|
%p
|
||||||
= p.label :first_name
|
= p.label :first_name
|
||||||
= p.text_field :first_name, :value => @profile.first_name
|
= p.text_field :first_name, :value => @profile.first_name
|
||||||
%p
|
%p
|
||||||
= p.label :last_name
|
= p.label :last_name
|
||||||
= p.text_field :last_name, :value => @profile.last_name
|
= p.text_field :last_name, :value => @profile.last_name
|
||||||
%p
|
|
||||||
= p.label :image_url
|
|
||||||
= p.text_field :image_url, :value => @profile.image_url
|
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= f.label :email
|
= f.label :email
|
||||||
|
|
|
||||||
11
public/javascripts/image_picker.js
Normal file
11
public/javascripts/image_picker.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
$(document).ready( function() {
|
||||||
|
$('div#image_picker div.small_photo').click( function() {
|
||||||
|
$('#image_url_field').val($(this).attr('id'));
|
||||||
|
|
||||||
|
$('div#image_picker div.small_photo').removeClass('selected');
|
||||||
|
$("div#image_picker div.small_photo input[type='checkbox']").attr("checked", false);
|
||||||
|
|
||||||
|
$(this).addClass('selected');
|
||||||
|
$(this).children("input[type='checkbox']").attr("checked", true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -193,6 +193,7 @@ ul.comment_set {
|
||||||
img.person_picture {
|
img.person_picture {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
-webkit-border-radius: 3px;
|
||||||
-moz-border-radius: 3px;
|
-moz-border-radius: 3px;
|
||||||
display: inline block; }
|
display: inline block; }
|
||||||
|
|
||||||
|
|
@ -297,5 +298,20 @@ ul#publisher_content_pickers li {
|
||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
margin-right: 5px; }
|
margin-right: 5px; }
|
||||||
|
|
||||||
.selected {
|
#publisher.selected {
|
||||||
border-bottom: 3px solid #999999; }
|
border-bottom: 3px solid #999999; }
|
||||||
|
|
||||||
|
#image_picker .small_photo {
|
||||||
|
height: 100px;
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 1em;
|
||||||
|
margin-bottom: 1em; }
|
||||||
|
#image_picker .small_photo img {
|
||||||
|
border-radius: 3px; }
|
||||||
|
#image_picker .small_photo input[type='checkbox'] {
|
||||||
|
position: absolute; }
|
||||||
|
#image_picker .selected {
|
||||||
|
-webkit-box-shadow: 0 3px 6px black;
|
||||||
|
-moz-box-shadow: 0 3px 6px black;
|
||||||
|
border: 1px solid white; }
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,7 @@ ul.comment_set
|
||||||
img.person_picture
|
img.person_picture
|
||||||
:max-width 100%
|
:max-width 100%
|
||||||
:border-radius 3px
|
:border-radius 3px
|
||||||
|
:-webkit-border-radius 3px
|
||||||
:-moz-border-radius 3px
|
:-moz-border-radius 3px
|
||||||
:display inline block
|
:display inline block
|
||||||
|
|
||||||
|
|
@ -348,6 +349,27 @@ ul#publisher_content_pickers li
|
||||||
:margin
|
:margin
|
||||||
:right 5px
|
:right 5px
|
||||||
|
|
||||||
.selected
|
#publisher.selected
|
||||||
:border
|
:border
|
||||||
:bottom 3px solid #999
|
:bottom 3px solid #999
|
||||||
|
|
||||||
|
#image_picker
|
||||||
|
.small_photo
|
||||||
|
:height 100px
|
||||||
|
:position relative
|
||||||
|
:display inline-block
|
||||||
|
:margin
|
||||||
|
:right 1em
|
||||||
|
:bottom 1em
|
||||||
|
|
||||||
|
img
|
||||||
|
:border-radius 3px
|
||||||
|
|
||||||
|
input[type='checkbox']
|
||||||
|
:position absolute
|
||||||
|
|
||||||
|
.selected
|
||||||
|
:-webkit-box-shadow 0 3px 6px #000
|
||||||
|
:-moz-box-shadow 0 3px 6px #000
|
||||||
|
:border 1px solid #fff
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue