Add error message and disabling of preview button

This commit is contained in:
Andrew Miner
2015-06-08 12:27:36 -07:00
parent 3535c19db0
commit 4e39b9bb0c
9 changed files with 75 additions and 18 deletions
+4
View File
@@ -61,10 +61,14 @@ module.exports = class MarkdownImage extends BaseModel
return @_mimeType
isValid: ->
return @status in [ Status.creatable, Status.unchanged, Status.updateable ]
Object.defineProperties @prototype,
fullPath: {get:@prototype.getFullPath}
imageUrl: {get:@prototype.getImageUrl}
mimeType: {get:@prototype.getMimeType}
valid: {get:@prototype.isValid}
# BaseModel Overrides ##########################################################################
+11 -1
View File
@@ -41,6 +41,9 @@ module.exports = class MarkdownImageList extends BaseModel
image.fetch()
reset: ->
for fileName, image of @_images
@stopListening image
@_images = {}
@_analyzeMarkdownText()
@@ -54,13 +57,19 @@ module.exports = class MarkdownImageList extends BaseModel
return result
isValid: ->
for fileName, image of @_images
return false unless image.valid
return true
Object.defineProperties @prototype,
all: {get:@prototype.getAll}
valid: {get:@prototype.isValid}
# Private Methods ##############################################################################
_analyzeMarkdownText: ->
regex = /\!\[([^\]]*)\]\(([^\)]*)\)/g
regex = /\!\[([^\]\n]*)\]\(([^\)\n]*)\)/g
newImages = {}
changed = false
@@ -73,6 +82,7 @@ module.exports = class MarkdownImageList extends BaseModel
image = @_images[fileName]
if not image?
image = new MarkdownImage {fileName:fileName, path:@imageBase}, {client:@client}
@listenTo image, Event.change, => @trigger Event.change, this
@trigger Event.add, this, image
changed = true