Fixed by moving parent button popover content to jade.

This commit is contained in:
Nick Winter 2015-04-10 13:46:53 -07:00
parent 5c40221ab2
commit 7e2caddd02
3 changed files with 28 additions and 24 deletions

View file

@ -175,11 +175,11 @@
border-width: 14px 20px 20px 20px
color: darken(white, 5%)
#email-parent-form
.email-parent-form
.email_invalid
color: red
display: none
#email-parent-complete
.email-parent-complete
display: none
//- Errors

View file

@ -88,3 +88,16 @@
span(aria-hidden="true") ×
p(data-i18n="loading_error.unknown")
p= stateMessage
.parent-button-popover-content.hidden
.email-parent-form
p(data-i18n="subscribe.parent_email_description")
form
.form-group
label(data-i18n="subscribe.parent_email_input_label")
input.parent-input.form-control(type='email', data-i18n="[placeholder]subscribe.parent_email_input_placeholder")
.parent-email-validator.email_invalid(data-i18n="subscribe.parent_email_input_invalid")
button.parent-send.btn.btn-default(type='submit', data-i18n="subscribe.parent_email_send")
.email-parent-complete
p(data-i18n="subscribe.parent_email_sent")
button.btn(type='button', onclick="$('.parent-button').popover('hide');", data-i18n="modal.close")

View file

@ -18,7 +18,8 @@ module.exports = class SubscribeModal extends ModalView
events:
'click #close-modal': 'hide'
'click #parent-send': 'onClickParentSendButton'
'click .popover-content .parent-send': 'onClickParentSendButton'
'click .email-parent-complete button': 'onClickParentEmailCompleteButton'
'click .purchase-button': 'onClickPurchaseButton'
constructor: (options) ->
@ -42,22 +43,9 @@ module.exports = class SubscribeModal extends ModalView
setupParentButtonPopover: ->
popoverTitle = $.i18n.t 'subscribe.parent_email_title'
popoverTitle += '<button type="button" class="close" onclick="$(&#39;.parent-button&#39;).popover(&#39;hide&#39;);">&times;</button>'
popoverContent = "<div id='email-parent-form'>"
popoverContent += "<p>#{$.i18n.t('subscribe.parent_email_description')}</p>"
popoverContent += "<form>"
popoverContent += " <div class='form-group'>"
popoverContent += " <label>#{$.i18n.t('subscribe.parent_email_input_label')}</label>"
popoverContent += " <input id='parent-input' type='email' class='form-control' placeholder='#{$.i18n.t('subscribe.parent_email_input_placeholder')}'/>"
popoverContent += " <div id='parent-email-validator' class='email_invalid'>#{$.i18n.t('subscribe.parent_email_input_invalid')}</div>"
popoverContent += " </div>"
popoverContent += " <button id='parent-send' type='submit' class='btn btn-default'>#{$.i18n.t('subscribe.parent_email_send')}</button>"
popoverContent += "</form>"
popoverContent += "</div>"
popoverContent += "<div id='email-parent-complete'>"
popoverContent += " <p>#{$.i18n.t('subscribe.parent_email_sent')}</p>"
popoverContent += " <button type='button' onclick='$(&#39;.parent-button&#39;).popover(&#39;hide&#39;);'>#{$.i18n.t('modal.close')}</button>"
popoverContent += "</div>"
popoverContent = ->
console.log 'found html', $('.parent-button-popover-content').html()
$('.parent-button-popover-content').html()
@$el.find('.parent-button').popover(
animation: true
html: true
@ -104,10 +92,10 @@ module.exports = class SubscribeModal extends ModalView
onClickParentSendButton: (e) ->
# TODO: Popover sometimes dismisses immediately after send
email = $('#parent-input').val()
email = @$el.find('.popover-content .parent-input').val()
unless /[\w\.]+@\w+\.\w+/.test email
$('#parent-input').parent().addClass('has-error')
$('#parent-email-validator').show()
@$el.find('.popover-content .parent-input').parent().addClass('has-error')
@$el.find('.popover-content .parent-email-validator').show()
return false
request = @supermodel.addRequestResource 'send_one_time_email', {
@ -117,10 +105,13 @@ module.exports = class SubscribeModal extends ModalView
}, 0
request.load()
$('#email-parent-form').hide()
$('#email-parent-complete').show()
@$el.find('.popover-content .email-parent-form').hide()
@$el.find('.popover-content .email-parent-complete').show()
false
onClickParentEmailCompleteButton: (e) ->
@$el.find('.parent-button').popover('hide')
onClickPurchaseButton: (e) ->
@playSound 'menu-button-click'
return @openModalView new AuthModal() if me.get('anonymous')