Fix two bugs
* Make sure no elements of the markdown section are displayed when they shouldn't be by taking advantage of the jQuery animation queue * Don't crash when the user cancels selecting a file
This commit is contained in:
@@ -35,6 +35,7 @@ module.exports = class MarkdownImageController extends BaseController
|
||||
if @_reader? then @_reader.abort = true
|
||||
|
||||
file = @$input.prop('files')[0]
|
||||
return unless file?
|
||||
|
||||
if file.size > MAX_FILE_SIZE
|
||||
logger.warning "The choosen file, #{file.name}, is too large: #{file.size}"
|
||||
@@ -123,20 +124,20 @@ module.exports = class MarkdownImageController extends BaseController
|
||||
@$button.html 'Choose'
|
||||
|
||||
if @model.status is MarkdownImage.Status.checking
|
||||
@$loaded.hide duration:Duration.normal
|
||||
@$loading.show duration:Duration.normal, queue:true
|
||||
@$loaded.fadeOut duration:Duration.normal
|
||||
@$loading.fadeIn duration:Duration.normal, queue:true
|
||||
else
|
||||
@$loading.hide duration:Duration.normal
|
||||
@$loaded.show duration:Duration.normal, queue:true
|
||||
@$loading.fadeOut duration:Duration.normal
|
||||
@$loaded.fadeIn duration:Duration.normal, queue:true
|
||||
|
||||
if @model.status is MarkdownImage.Status.empty
|
||||
@$errorMessage.html 'please choose an image'
|
||||
@$errorContainer.show duration:Duration.normal
|
||||
@$errorContainer.fadeIn duration:Duration.normal
|
||||
else if @errorMessage?
|
||||
@$errorMessage.html @errorMessage
|
||||
@$errorContainer.show duration:Duration.normal
|
||||
@$errorContainer.fadeIn duration:Duration.normal
|
||||
else
|
||||
@$errorContainer.hide duration:Duration.normal
|
||||
@$errorContainer.fadeOut duration:Duration.normal
|
||||
|
||||
super
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ All rights reserved.
|
||||
_ = require 'underscore'
|
||||
BaseController = require './base_controller'
|
||||
convertMarkdown = require 'marked'
|
||||
{Duration} = require '../constants'
|
||||
{Event} = require '../constants'
|
||||
MarkdownImageListController = require './markdown_image_list_controller'
|
||||
{Url} = require '../constants'
|
||||
@@ -244,6 +245,8 @@ module.exports = class MarkdownSectionController extends BaseController
|
||||
return if @_lastUpdatedState is @state
|
||||
@_lastUpdatedState = @state
|
||||
|
||||
logger.verbose => "Updating markdown section visibility for state: #{@state}"
|
||||
|
||||
elements =
|
||||
appologizingPanel: @$('.appologizing')
|
||||
buttonPanel: @$('.buttons')
|
||||
@@ -283,13 +286,13 @@ module.exports = class MarkdownSectionController extends BaseController
|
||||
toHide = ($el for name, $el of elements when not visible[name])
|
||||
toShow = ($el for name, $el of elements when visible[name])
|
||||
|
||||
$el.clearQueue() for name, $el of elements
|
||||
|
||||
if toHide.length > 0
|
||||
@hide $el for $el in toHide
|
||||
if toShow.length > 0
|
||||
@once Event.animate.hide.finish, =>
|
||||
@show $el for $el in toShow
|
||||
else if toShow.length > 0
|
||||
@show $el for $el in toShow
|
||||
$el.fadeOut(duration:Duration.normal) for $el in toHide
|
||||
$el.delay(Duration.normal) for $el in toShow
|
||||
|
||||
$el.fadeIn(duration:Duration.normal) for $el in toShow
|
||||
|
||||
if @state is State.editing
|
||||
@once Event.animate.show.finish, =>
|
||||
|
||||
Reference in New Issue
Block a user