Sha256: 68b20937e1d422e370b82e3807d83a2598f7c117e1bc77be700e4486e25310e3
Contents?: true
Size: 1.35 KB
Versions: 3
Compression:
Stored size: 1.35 KB
Contents
#= require 'overlays/image' class OverlayMe.Overlays.DynamicManager extends Backbone.Model initialize: () -> if ( listJSON = localStorage.getItem('dyn_image_list') ) @list = JSON.parse(listJSON) else @list = [] isPresent: (image_id) -> for saved in @list return true if saved.id == image_id return false isEmpty: -> return @list.length == 0 addImage: (src, options = {} ) -> new_image = @loadImage(src, options) if new_image && !@isPresent(new_image.image_id) @list.push { id: new_image.image_id, src: new_image.image_src } @saveList() new_image loadImage: (src, options = {} ) -> image_id = OverlayMe.Overlays.urlToId(src) unless $o("#overlay_me_images_container ##{image_id}").length > 0 _default_css = $o.extend { display: 'block' }, options.default_css image = new OverlayMe.Overlays.Image(src, { destroyable: true, default_css: _default_css }) OverlayMe.images_management_div.append image.render() image delImage: (image_id) -> for image in @list if image.id == image_id @list.splice(@list.indexOf(image), 1) @saveList() break OverlayMe.images_management_div.del image_id loadAll: () -> for image in @list @addImage(image.src) saveList: -> localStorage.setItem('dyn_image_list', JSON.stringify(@list))
Version data entries
3 entries across 3 versions & 1 rubygems