From 3edfbb42a11c5493d9fdfa19e2dd9073aff25b39 Mon Sep 17 00:00:00 2001 From: Andreas N Date: Sun, 18 Jan 2015 00:16:06 +0100 Subject: [PATCH 01/10] add design stuff for header display --- app/assets/stylesheets/scss/user.scss | 14 +++++++++++++- app/views/user/show.html.haml | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/scss/user.scss b/app/assets/stylesheets/scss/user.scss index 55101e25..23829370 100644 --- a/app/assets/stylesheets/scss/user.scss +++ b/app/assets/stylesheets/scss/user.scss @@ -53,7 +53,7 @@ position: absolute; z-index: 0; width: 100%; - height: 40vh; + height: 300px; background-color: darken($navbar-inverse-bg, 10%); background-size: cover; } @@ -124,4 +124,16 @@ .user--banned { text-decoration: line-through !important; +} + +.profile--panel-push-50 { + display: block; + height: 50px; + width: 100%; +} + +.profile--panel-push-200 { + display: block; + height: 180px; + width: 100%; } \ No newline at end of file diff --git a/app/views/user/show.html.haml b/app/views/user/show.html.haml index 087ecc93..446f4548 100644 --- a/app/views/user/show.html.haml +++ b/app/views/user/show.html.haml @@ -1,9 +1,11 @@ .profile--header .container.j2-page .col-md-3.col-xs-12.col-sm-4 + .profile--panel-push-50.hidden-xs = render 'user/profile_info' .hidden-xs= render 'shared/links' .col-md-9.col-xs-12.col-sm-8 + .profile--panel-push-200.hidden-xs = render 'shared/questionbox' #answers - @answers.each do |a| From 5b67ac7f0a5b8bafc45794cbaf311987da0522fd Mon Sep 17 00:00:00 2001 From: Andreas N Date: Sun, 18 Jan 2015 00:23:55 +0100 Subject: [PATCH 02/10] added template css file --- app/views/user/show.css.erb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 app/views/user/show.css.erb diff --git a/app/views/user/show.css.erb b/app/views/user/show.css.erb new file mode 100644 index 00000000..9a5f71d6 --- /dev/null +++ b/app/views/user/show.css.erb @@ -0,0 +1,5 @@ +/* TODO: Add image link to background with url() */ + +.profile--header { + background: #49298A; +} \ No newline at end of file From 2e6ffdaab7425bac0aea9cdf81f7b9fd06abe62e Mon Sep 17 00:00:00 2001 From: Yuki Date: Fri, 8 May 2015 21:14:16 +0530 Subject: [PATCH 03/10] basic implementation --- .gitignore | 5 +- Gemfile | 1 + Gemfile.lock | 6 +++ app/assets/javascripts/settings.coffee | 44 +++++++++++++++++- app/assets/stylesheets/scss/user.scss | 28 ++++++----- app/controllers/user_controller.rb | 3 +- app/models/user.rb | 7 +++ app/views/user/edit.html.haml | 24 +++++++++- app/views/user/show.html.haml | 8 ++-- ..._add_attachment_profile_header_to_users.rb | 12 +++++ db/schema.rb | 28 ++++++++++- public/images/header/mobile/no_header.jpg | Bin 0 -> 886 bytes public/images/header/original/no_header.jpg | Bin 0 -> 9170 bytes public/images/header/retina/no_header.jpg | Bin 0 -> 2576 bytes public/images/header/web/no_header.jpg | Bin 0 -> 6491 bytes 15 files changed, 144 insertions(+), 22 deletions(-) create mode 100644 db/migrate/20150508144336_add_attachment_profile_header_to_users.rb create mode 100644 public/images/header/mobile/no_header.jpg create mode 100644 public/images/header/original/no_header.jpg create mode 100644 public/images/header/retina/no_header.jpg create mode 100644 public/images/header/web/no_header.jpg diff --git a/.gitignore b/.gitignore index 3f798c97..e21f5f45 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,7 @@ coverage/ *~ # every fucking time, dolphin -.directory \ No newline at end of file +.directory +# lookin' at you, OS trash +.DS_Store +Thumbs.DB diff --git a/Gemfile b/Gemfile index f966887f..6351f278 100644 --- a/Gemfile +++ b/Gemfile @@ -79,4 +79,5 @@ group :development, :test do gem 'simplecov-json', require: false gem 'simplecov-rcov', require: false gem 'database_cleaner' + gem 'better_errors' end diff --git a/Gemfile.lock b/Gemfile.lock index b94af2ab..af406aa4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -46,6 +46,10 @@ GEM addressable (2.3.8) arel (6.0.0) bcrypt (3.1.10) + better_errors (2.1.1) + coderay (>= 1.0.0) + erubis (>= 2.6.6) + rack (>= 0.9.0) bootstrap-sass (3.2.0.2) sass (~> 3.2) bootstrap3-datetimepicker-rails (4.7.14) @@ -68,6 +72,7 @@ GEM cliver (0.3.2) cocaine (0.5.7) climate_control (>= 0.0.3, < 1.0) + coderay (1.1.0) coffee-rails (4.1.0) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -365,6 +370,7 @@ PLATFORMS DEPENDENCIES bcrypt (~> 3.1.7) + better_errors bootstrap-sass (~> 3.2.0.1) bootstrap3-datetimepicker-rails (~> 4.7.14) bootstrap_form diff --git a/app/assets/javascripts/settings.coffee b/app/assets/javascripts/settings.coffee index 5742e5b9..f5616cbf 100644 --- a/app/assets/javascripts/settings.coffee +++ b/app/assets/javascripts/settings.coffee @@ -48,4 +48,46 @@ cropper.attr 'src', e.target.result - fr.readAsDataURL(input.files[0]) \ No newline at end of file + fr.readAsDataURL(input.files[0]) + +($ document).on 'change', 'input#user_profile_header[type=file]', -> + input = ($ this)[0] + + ($ '#profile-header-crop-controls').slideUp 400, -> + if input.files and input.files[0] + fr = new FileReader() + ($ fr).on 'load', (e) -> + cropper = ($ '#profile-header-cropper') + preview = ($ '#profile-header-preview') + + updateVars = (data, action) -> + ($ '#crop_h_x').val Math.floor(data.x / data.scale) + ($ '#crop_h_y').val Math.floor(data.y / data.scale) + ($ '#crop_h_w').val Math.floor(data.w / data.scale) + ($ '#crop_h_h').val Math.floor(data.h / data.scale) +# rx = 100 / data.w +# ry = 100 / data.h +# ($ '#profile-picture-preview').css +# width: Math.round(rx * preview[0].naturalWidth) + 'px' +# height: Math.round(ry * preview[0].naturalHeight) + 'px' +# marginLeft: '-' + Math.round(rx * data.x) + 'px' +# marginTop: '-' + Math.round(ry * data.y) + 'px' + + cropper.on 'load', -> + width = 1500 + height = 500 + + cropper.guillotine + width: 1500 + height: 500 + onChange: updateVars + + updateVars cropper.guillotine('getData'), 'drag' # just because + + ($ '#cropper-zoom-out').click -> cropper.guillotine 'zoomOut' + ($ '#cropper-zoom-in').click -> cropper.guillotine 'zoomIn' + ($ '#profile-header-crop-controls').slideDown() + + cropper.attr 'src', e.target.result + + fr.readAsDataURL(input.files[0]) diff --git a/app/assets/stylesheets/scss/user.scss b/app/assets/stylesheets/scss/user.scss index dbb73a94..377b2f68 100644 --- a/app/assets/stylesheets/scss/user.scss +++ b/app/assets/stylesheets/scss/user.scss @@ -28,13 +28,11 @@ margin-top: 0.65em; } -.profile--header { - position: absolute; - z-index: 0; +#profile--header { + position: relative; + z-index: -1; width: 100%; - height: 300px; background-color: darken($navbar-inverse-bg, 10%); - background-size: cover; } .profile--panel .panel-heading { @@ -100,14 +98,20 @@ $colours: danger $brand-danger, text-decoration: line-through !important; } -.profile--panel-push-50 { +.profile--panel-push-inner { display: block; - height: 50px; + height: 60px; +} + +.profile--header-img { + display: block; + min-width: 900px; width: 100%; } -.profile--panel-push-200 { - display: block; - height: 180px; - width: 100%; -} \ No newline at end of file +@media(min-width: 767px) { + .container.headerable { + padding-top: 0; + margin-top: -30px; + } +} diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 4667e2b0..43d3451c 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -24,11 +24,12 @@ class UserController < ApplicationController end def update - user_attributes = params.require(:user).permit(:display_name, :profile_picture, :motivation_header, :website, + user_attributes = params.require(:user).permit(:display_name, :profile_picture, :profile_header, :motivation_header, :website, :location, :bio, :crop_x, :crop_y, :crop_w, :crop_h) if current_user.update_attributes(user_attributes) text = 'Your profile has been updated!' text += ' It might take a few minutes until your new profile picture is shown everywhere.' if user_attributes[:profile_picture] + text += ' It might take a few minutes until your new profile header is shown everywhere.' if user_attributes[:profile_header] flash[:success] = text else flash[:error] = 'An error occurred. ;_;' diff --git a/app/models/user.rb b/app/models/user.rb index b8dc904d..8a07e97a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -49,7 +49,14 @@ class User < ActiveRecord::Base default_url: "/images/:style/no_avatar.png", use_timestamp: false, processors: [:cropper] validates_attachment_content_type :profile_picture, :content_type => /\Aimage\/.*\Z/ + + has_attached_file :profile_header, styles: { web: "1500x350#", mobile: "450x105#", retina: "900x210#" }, + default_url: '/images/header/:style/no_header.jpg', use_timestamp: false, + processors: [:cropper] + validates_attachment_content_type :profile_header, :content_type => /\Aimage\/.*\Z/ + process_in_background :profile_picture + process_in_background :profile_header before_save do self.display_name = 'WRYYYYYYYY' if display_name == 'Dio Brando' diff --git a/app/views/user/edit.html.haml b/app/views/user/edit.html.haml index f5d6af9c..84c379af 100644 --- a/app/views/user/edit.html.haml +++ b/app/views/user/edit.html.haml @@ -16,7 +16,7 @@ .row#profile-picture-crop-controls{style: 'display: none;'} .col-sm-10.col-md-8 - %strong Adjust your new image + %strong Adjust your new avatar %img#profile-picture-cropper{src: current_user.profile_picture.url(:medium)} .col-sm-2.col-md-4 .btn-group @@ -25,6 +25,23 @@ %button#cropper-zoom-in.btn.btn-inverse{type: :button} %i.fa.fa-search-plus + .media + .pull-left + %img.img-rounded.header--img{src: current_user.profile_header.url(:mobile)} + .media-body + = f.file_field :profile_header + + .row#profile-header-crop-controls{style: 'display: none;'} + .col-sm-10.col-md-8 + %strong Adjust your new header + %img#profile-header-cropper{src: current_user.profile_header.url(:web)} + .col-sm-2.col-md-4 + .btn-group + %button#cropper-zoom-out.btn.btn-inverse{type: :button} + %i.fa.fa-search-minus + %button#cropper-zoom-in.btn.btn-inverse{type: :button} + %i.fa.fa-search-plus + = f.text_field :motivation_header, label: "Motivation header", placeholder: 'Ask me anything!' = f.text_field :website, label: "Website", placeholder: 'http://example.com' @@ -36,4 +53,7 @@ - for attrib in %i(crop_x crop_y crop_w crop_h) = f.hidden_field attrib, id: attrib - = f.submit "Save settings", class: 'btn btn-primary' \ No newline at end of file + - for attrib in %i(crop_h_x crop_h_y crop_h_w crop_h_h) + = f.hidden_field attrib, id: attrib + + = f.submit "Save settings", class: 'btn btn-primary' diff --git a/app/views/user/show.html.haml b/app/views/user/show.html.haml index 836d12b1..9b2cb3ee 100644 --- a/app/views/user/show.html.haml +++ b/app/views/user/show.html.haml @@ -1,10 +1,12 @@ -.profile--header -.container.j2-page +#profile--header.hidden-xs + %img.profile--header-img{src: current_user.profile_header.url(:web)} +#profile--panel-push-n.hidden-xs +.container.j2-page.headerable .col-md-3.col-xs-12.col-sm-4.j2-col-reset = render 'user/profile_info' .hidden-xs= render 'shared/links' .col-md-9.col-xs-12.col-sm-8.j2-col-reset - .profile--panel-push-200.hidden-xs + .profile--panel-push-inner.hidden-xs = render 'shared/questionbox' - unless @user.banned? #answers diff --git a/db/migrate/20150508144336_add_attachment_profile_header_to_users.rb b/db/migrate/20150508144336_add_attachment_profile_header_to_users.rb new file mode 100644 index 00000000..7cd1ae7e --- /dev/null +++ b/db/migrate/20150508144336_add_attachment_profile_header_to_users.rb @@ -0,0 +1,12 @@ +class AddAttachmentProfileHeaderToUsers < ActiveRecord::Migration + def change + change_table :users do |t| + t.attachment :profile_header + t.boolean :profile_header_processing + t.integer :crop_h_x + t.integer :crop_h_y + t.integer :crop_h_w + t.integer :crop_h_h + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a18869e4..a2d647b9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150422024104) do +ActiveRecord::Schema.define(version: 20150508144336) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -28,12 +28,24 @@ ActiveRecord::Schema.define(version: 20150422024104) do add_index "answers", ["user_id", "created_at"], name: "index_answers_on_user_id_and_created_at", using: :btree + create_table "comment_smiles", force: :cascade do |t| + t.integer "user_id" + t.integer "comment_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "comment_smiles", ["comment_id"], name: "index_comment_smiles_on_comment_id", using: :btree + add_index "comment_smiles", ["user_id", "comment_id"], name: "index_comment_smiles_on_user_id_and_comment_id", unique: true, using: :btree + add_index "comment_smiles", ["user_id"], name: "index_comment_smiles_on_user_id", using: :btree + create_table "comments", force: :cascade do |t| t.string "content" t.integer "answer_id" t.integer "user_id" t.datetime "created_at" t.datetime "updated_at" + t.integer "smile_count", default: 0, null: false end add_index "comments", ["user_id", "created_at"], name: "index_comments_on_user_id_and_created_at", using: :btree @@ -206,9 +218,21 @@ ActiveRecord::Schema.define(version: 20150422024104) do t.boolean "privacy_allow_public_timeline", default: true t.boolean "privacy_allow_stranger_answers", default: true t.boolean "privacy_show_in_search", default: true - t.boolean "banned", default: false + t.boolean "permanently_banned", default: false t.boolean "blogger", default: false t.boolean "contributor", default: false + t.string "ban_reason" + t.datetime "banned_until" + t.integer "comment_smiled_count", default: 0, null: false + t.string "profile_header_file_name" + t.string "profile_header_content_type" + t.integer "profile_header_file_size" + t.datetime "profile_header_updated_at" + t.boolean "profile_header_processing" + t.integer "crop_h_x" + t.integer "crop_h_y" + t.integer "crop_h_w" + t.integer "crop_h_h" end add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree diff --git a/public/images/header/mobile/no_header.jpg b/public/images/header/mobile/no_header.jpg new file mode 100644 index 0000000000000000000000000000000000000000..320833533b22eb3c5c9df2d794f43679e3f5b5bd GIT binary patch literal 886 zcmeH@%MHRX3_$Is4f(aTTVNdyNR?m{=HbQ!jDZkC0KKqDu#fExiDO@+D0zzQ*!h`1 zK*!-Q03w1e$Rq5*6pHRfC~c`YYb)zr2;O-gQkz0-qW3k|O-sZSQrCCX%b7F@YNRQh z1XA=-?2qIdu!9rc4KfsrhA}^2BVUCnPV}1Q7Q}9)t(mV@`kH4}`hG()D0K|O4$kA{ QIxVu?mI?e}0&RYM0f%`YwEzGB literal 0 HcmV?d00001 diff --git a/public/images/header/original/no_header.jpg b/public/images/header/original/no_header.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2e951ed4d39652474ff13f37a763907190ceeffd GIT binary patch literal 9170 zcmeIuyKTcT6ouh?MM)+pStjKq>!b)^z+Nw1Cde2rJVau-@DS;l%hKvnr2CHmLOS3> z{K{9kOFA8n2T@h2kCa8;#5FZ_be6VnYkc2#eef{`A3_{=V;rU-gl*nVyOeT@M>bZY0gEU)sue0)A0!WRMvAb?fC=crO@cGF8!Pe`DN3H=IC<%r zJ`j)NVFW~kJRnW52U_LinIuJ3|p{;4&Pz2o(qJq`nSe=Gc2l8o23)p7cl` z3div<5;IeNC{45{RpjJRNy@s+(RE$bMq6vNG1hn9y4D%f#HQ^+h{5`P=))lIA#cKY zr7E>749+-de@wbj)O@PmiX#<~RpfN1jr=OjqorPlWlPd- Date: Fri, 8 May 2015 21:16:07 +0530 Subject: [PATCH 04/10] fix scroll issue w/ headers --- app/assets/stylesheets/scss/user.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/scss/user.scss b/app/assets/stylesheets/scss/user.scss index 377b2f68..7500baff 100644 --- a/app/assets/stylesheets/scss/user.scss +++ b/app/assets/stylesheets/scss/user.scss @@ -32,6 +32,7 @@ position: relative; z-index: -1; width: 100%; + overflow: hidden; background-color: darken($navbar-inverse-bg, 10%); } From e20ce9999ebee25aae5ce438f65dee9e4c973b59 Mon Sep 17 00:00:00 2001 From: Yuki Date: Fri, 8 May 2015 21:19:10 +0530 Subject: [PATCH 05/10] cleanup --- app/assets/javascripts/settings.coffee | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/settings.coffee b/app/assets/javascripts/settings.coffee index f5616cbf..89fe7512 100644 --- a/app/assets/javascripts/settings.coffee +++ b/app/assets/javascripts/settings.coffee @@ -65,24 +65,14 @@ ($ '#crop_h_y').val Math.floor(data.y / data.scale) ($ '#crop_h_w').val Math.floor(data.w / data.scale) ($ '#crop_h_h').val Math.floor(data.h / data.scale) -# rx = 100 / data.w -# ry = 100 / data.h -# ($ '#profile-picture-preview').css -# width: Math.round(rx * preview[0].naturalWidth) + 'px' -# height: Math.round(ry * preview[0].naturalHeight) + 'px' -# marginLeft: '-' + Math.round(rx * data.x) + 'px' -# marginTop: '-' + Math.round(ry * data.y) + 'px' cropper.on 'load', -> - width = 1500 - height = 500 - cropper.guillotine width: 1500 - height: 500 + height: 350 onChange: updateVars - updateVars cropper.guillotine('getData'), 'drag' # just because + updateVars cropper.guillotine('getData'), 'drag' ($ '#cropper-zoom-out').click -> cropper.guillotine 'zoomOut' ($ '#cropper-zoom-in').click -> cropper.guillotine 'zoomIn' From 975909f197340c95f74e434152ca9be039e3595a Mon Sep 17 00:00:00 2001 From: Yuki Date: Fri, 8 May 2015 21:24:03 +0530 Subject: [PATCH 06/10] remove unused file --- app/views/user/show.css.erb | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 app/views/user/show.css.erb diff --git a/app/views/user/show.css.erb b/app/views/user/show.css.erb deleted file mode 100644 index 9a5f71d6..00000000 --- a/app/views/user/show.css.erb +++ /dev/null @@ -1,5 +0,0 @@ -/* TODO: Add image link to background with url() */ - -.profile--header { - background: #49298A; -} \ No newline at end of file From 9633511859feb9fcbe5a1e6ab2c621512843afb0 Mon Sep 17 00:00:00 2001 From: Yuki Date: Fri, 8 May 2015 21:34:58 +0530 Subject: [PATCH 07/10] Some fixes (whoops used current_user instead of user) --- app/assets/stylesheets/scss/user.scss | 8 ++++++-- app/views/user/show.html.haml | 9 ++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/scss/user.scss b/app/assets/stylesheets/scss/user.scss index 7500baff..527286c3 100644 --- a/app/assets/stylesheets/scss/user.scss +++ b/app/assets/stylesheets/scss/user.scss @@ -36,6 +36,10 @@ background-color: darken($navbar-inverse-bg, 10%); } +#profile--header.profile--no-header { + position: absolute; +} + .profile--panel .panel-heading { color: $brand-primary; border-bottom: 2px solid $brand-primary; @@ -99,7 +103,7 @@ $colours: danger $brand-danger, text-decoration: line-through !important; } -.profile--panel-push-inner { +.profile--panel-push-inner:not(.profile--no-header) { display: block; height: 60px; } @@ -111,7 +115,7 @@ $colours: danger $brand-danger, } @media(min-width: 767px) { - .container.headerable { + .container.headerable:not(.profile--no-header) { padding-top: 0; margin-top: -30px; } diff --git a/app/views/user/show.html.haml b/app/views/user/show.html.haml index 9b2cb3ee..ab96e75a 100644 --- a/app/views/user/show.html.haml +++ b/app/views/user/show.html.haml @@ -1,12 +1,11 @@ -#profile--header.hidden-xs - %img.profile--header-img{src: current_user.profile_header.url(:web)} -#profile--panel-push-n.hidden-xs -.container.j2-page.headerable +#profile--header.hidden-xs{class: unless @user.profile_header.exists? then "profile--no-header" end} + %img.profile--header-img{src: @user.profile_header.url(:web)} +.container.j2-page.headerable{class: unless @user.profile_header.exists? then "profile--no-header" end} .col-md-3.col-xs-12.col-sm-4.j2-col-reset = render 'user/profile_info' .hidden-xs= render 'shared/links' .col-md-9.col-xs-12.col-sm-8.j2-col-reset - .profile--panel-push-inner.hidden-xs + .profile--panel-push-inner.hidden-xs{class: unless @user.profile_header.exists? then "profile--no-header" end} = render 'shared/questionbox' - unless @user.banned? #answers From 94433f4484040d6c667c18d8eef4aca67cef449d Mon Sep 17 00:00:00 2001 From: Yuki Date: Fri, 8 May 2015 21:37:09 +0530 Subject: [PATCH 08/10] trim the fat --- app/views/user/show.html.haml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/user/show.html.haml b/app/views/user/show.html.haml index ab96e75a..ab34fcdc 100644 --- a/app/views/user/show.html.haml +++ b/app/views/user/show.html.haml @@ -1,11 +1,12 @@ -#profile--header.hidden-xs{class: unless @user.profile_header.exists? then "profile--no-header" end} +- no_header = unless @user.profile_header.exists? then "profile--no-header" else "" end +#profile--header.hidden-xs{class: no_header} %img.profile--header-img{src: @user.profile_header.url(:web)} -.container.j2-page.headerable{class: unless @user.profile_header.exists? then "profile--no-header" end} +.container.j2-page.headerable{class: no_header} .col-md-3.col-xs-12.col-sm-4.j2-col-reset = render 'user/profile_info' .hidden-xs= render 'shared/links' .col-md-9.col-xs-12.col-sm-8.j2-col-reset - .profile--panel-push-inner.hidden-xs{class: unless @user.profile_header.exists? then "profile--no-header" end} + .profile--panel-push-inner.hidden-xs{class: no_header} = render 'shared/questionbox' - unless @user.banned? #answers From b71466535d02f15496ffe434a6b75aefb08b63c3 Mon Sep 17 00:00:00 2001 From: Yuki Date: Fri, 8 May 2015 21:44:54 +0530 Subject: [PATCH 09/10] Fix zooming when cropping header --- app/assets/javascripts/settings.coffee | 4 ++-- app/views/user/edit.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/settings.coffee b/app/assets/javascripts/settings.coffee index 89fe7512..f3eb6c84 100644 --- a/app/assets/javascripts/settings.coffee +++ b/app/assets/javascripts/settings.coffee @@ -74,8 +74,8 @@ updateVars cropper.guillotine('getData'), 'drag' - ($ '#cropper-zoom-out').click -> cropper.guillotine 'zoomOut' - ($ '#cropper-zoom-in').click -> cropper.guillotine 'zoomIn' + ($ '#cropper-header-zoom-out').click -> cropper.guillotine 'zoomOut' + ($ '#cropper-header-zoom-in').click -> cropper.guillotine 'zoomIn' ($ '#profile-header-crop-controls').slideDown() cropper.attr 'src', e.target.result diff --git a/app/views/user/edit.html.haml b/app/views/user/edit.html.haml index 84c379af..66e537cb 100644 --- a/app/views/user/edit.html.haml +++ b/app/views/user/edit.html.haml @@ -37,9 +37,9 @@ %img#profile-header-cropper{src: current_user.profile_header.url(:web)} .col-sm-2.col-md-4 .btn-group - %button#cropper-zoom-out.btn.btn-inverse{type: :button} + %button#cropper-header-zoom-out.btn.btn-inverse{type: :button} %i.fa.fa-search-minus - %button#cropper-zoom-in.btn.btn-inverse{type: :button} + %button#cropper-header-zoom-in.btn.btn-inverse{type: :button} %i.fa.fa-search-plus = f.text_field :motivation_header, label: "Motivation header", placeholder: 'Ask me anything!' From fa5196134197f44b08591fb342caeb1e60a47693 Mon Sep 17 00:00:00 2001 From: Yuki Date: Fri, 8 May 2015 21:50:57 +0530 Subject: [PATCH 10/10] prevent double binding controls --- app/assets/javascripts/settings.coffee | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/settings.coffee b/app/assets/javascripts/settings.coffee index f3eb6c84..6142a7dd 100644 --- a/app/assets/javascripts/settings.coffee +++ b/app/assets/javascripts/settings.coffee @@ -42,8 +42,10 @@ updateVars cropper.guillotine('getData'), 'drag' # just because - ($ '#cropper-zoom-out').click -> cropper.guillotine 'zoomOut' - ($ '#cropper-zoom-in').click -> cropper.guillotine 'zoomIn' + unless ($ '#profile-picture-crop-controls')[0].dataset.bound? + ($ '#cropper-zoom-out').click -> cropper.guillotine 'zoomOut' + ($ '#cropper-zoom-in').click -> cropper.guillotine 'zoomIn' + ($ '#profile-picture-crop-controls')[0].dataset.bound = true ($ '#profile-picture-crop-controls').slideDown() cropper.attr 'src', e.target.result @@ -74,8 +76,10 @@ updateVars cropper.guillotine('getData'), 'drag' - ($ '#cropper-header-zoom-out').click -> cropper.guillotine 'zoomOut' - ($ '#cropper-header-zoom-in').click -> cropper.guillotine 'zoomIn' + unless ($ '#profile-header-crop-controls')[0].dataset.bound? + ($ '#cropper-header-zoom-out').click -> cropper.guillotine 'zoomOut' + ($ '#cropper-header-zoom-in').click -> cropper.guillotine 'zoomIn' + ($ '#profile-header-crop-controls')[0].dataset.bound = true ($ '#profile-header-crop-controls').slideDown() cropper.attr 'src', e.target.result