allahu snackbar

This commit is contained in:
nilsding 2014-11-08 20:41:08 +01:00
parent d236fd38ec
commit 2cc1062af7
2 changed files with 35 additions and 5 deletions

View File

@ -8,4 +8,34 @@
#= require_tree . #= require_tree .
NProgress.configure NProgress.configure
showSpinner: false showSpinner: false
$(document).on "click", "button[name=qb-ask]", ->
btn = $(this)
btn.button "loading"
promote = btn[0].dataset.promote == "true"
$("textarea[name=qb-question]").attr "readonly", "readonly"
anonymousQuestion = if $("input[name=qb-anonymous]")[0] != undefined
$("input[name=qb-anonymous]")[0].checked
else
true
console.log "some AJAX magic should happen here!"
btn.button "reset"
$("textarea[name=qb-question]").removeAttr "readonly"
if true # data.success
$("textarea[name=qb-question]").val ''
if promote
$("div#question-box").hide()
$("div#question-box-promote").show()
else
$.snackbar # allahu snackbar
content: "Successfully asked question"
style: "snackbar"
timeout: 5000
$(document).on "click", "button#create-account", ->
Turbolinks.visit "/sign_up"
$(document).on "click", "button#new-question", ->
$("div#question-box").show()
$("div#question-box-promote").hide()

View File

@ -6,17 +6,17 @@
#question-box.row #question-box.row
.row .row
.col-xs-12 .col-xs-12
%textarea.form-control{:name => "qb_question", :placeholder => "Type your question here…"} %textarea.form-control{:name => "qb-question", :placeholder => "Type your question here…"}
.row{:style => "padding-top: 5px; padding-left: 5px; padding-right: 5px;"} .row{:style => "padding-top: 5px; padding-left: 5px; padding-right: 5px;"}
.col-xs-6 .col-xs-6
- if user_signed_in? # and @user.allow_anonymous - if user_signed_in? # and @user.allow_anonymous
%input{:name => "qb_hidename", :type => "checkbox"}/ %input{:name => "qb-anonymous", :type => "checkbox"}/
Hide your name Hide your name
%br/ %br/
.col-xs-6 .col-xs-6
%p.pull-right %p.pull-right
%input{:name => "qb_to", :type => "hidden", :value => @user.id}/ %input{name: 'qb-to', type: 'hidden', :value => @user.id}/
%button#qb_ask.btn.btn-primary{"data-loading-text" => "Asking...", "data-promote" => user_signed_in? ? "true" : "false", :type => "button"} Ask %button.btn.btn-primary{name: 'qb-ask', 'data-loading-text' => "Asking...", "data-promote" => user_signed_in? ? "false" : "true", :type => "button"} Ask
- unless user_signed_in? - unless user_signed_in?
#question-box-promote.row{:style => "display: none;"} #question-box-promote.row{:style => "display: none;"}
.row .row