Update image list to fetch images from GitHub

This commit is contained in:
Andrew Miner
2015-06-07 14:13:30 -07:00
parent dd760018df
commit 2227e81b8b
10 changed files with 118 additions and 19 deletions
+14 -1
View File
@@ -14,14 +14,27 @@ MarkdownImage = require './markdown_image'
module.exports = class MarkdownImageList extends BaseModel
constructor: (attributes={}, options={})->
attributes.imageBase ?= ''
attributes.markdownText ?= null
super attributes, options
@client = options.client
@_images = {}
@on Event.change + ':imageBase', =>
for fileName, image of @_images
image.path = @imageBase
@on Event.change + ':markdownText', => @_analyzeMarkdownText()
@_analyzeMarkdownText()
# Public Methods ###############################################################################
loadImages: ->
for fileName, image of @_images
if image.status is MarkdownImage.Status.unknown
image.fetch()
# Property Methods #############################################################################
getAll: ->
@@ -50,7 +63,7 @@ module.exports = class MarkdownImageList extends BaseModel
fileName = match[2]
image = @_images[fileName]
if not image?
image = new MarkdownImage fileName:fileName
image = new MarkdownImage {fileName:fileName, path:@imageBase}, {client:@client}
@trigger Event.add, this, image
changed = true