app/assets/javascripts/chr/loft/asset-item.coffee in loft-0.1.0 vs app/assets/javascripts/chr/loft/asset-item.coffee in loft-0.1.1
- old
+ new
@@ -1,12 +1,19 @@
-# add file icon
-# add selectbox for delete
-# add modal dialog mode
+# -----------------------------------------------------------------------------
+# Author: Alexander Kravets <alex@slatestudio.com>,
+# Slate Studio (http://www.slatestudio.com)
+#
+# Coding Guide:
+# https://github.com/thoughtbot/guides/tree/master/style/coffeescript
+# -----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
+# Loft Asset Item
+# -----------------------------------------------------------------------------
class @LoftAssetItem extends Item
constructor: (@module, @path, @object, @config) ->
- @$el =$ "<div class='item asset' data-id='#{ @object._id }' data-title=''></div>"
+ @$el =$ "<div class='item asset asset-#{ @object.type }' data-id='#{ @object._id }' data-title=''></div>"
@render()
render: ->
@$el.html('').removeClass('item-folder has-subtitle has-thumbnail')
@@ -16,17 +23,29 @@
# asset icon with link
@$link =$ "<a class='asset-icon' href='#{ @object.file.url }' target='_blank'></a>"
@$el.prepend(@$link)
+ # thumbnail for images
+ if @object.type == 'image' && @object.grid_item_thumbnail != ''
+ @$thumbnailSmall =$ "<img class='asset-thumbnail-small' src='#{ @object.item_thumbnail.small }' />"
+ @$thumbnailMedium =$ "<img class='asset-thumbnail-medium' src='#{ @object.item_thumbnail.medium }' />"
+ @$link.append @$thumbnailSmall
+ @$link.append @$thumbnailMedium
+
# checkbox for item selection
- @$checkbox =$ "<input class='asset-checkbox' type='checkbox' />"
+ @$checkbox =$ "<div class='asset-checkbox'></div>"
+ @$checkboxInput =$ "<input type='checkbox' />"
+ @$checkbox.append(@$checkboxInput)
@$el.prepend(@$checkbox)
+
# input for assets name
name = @$el.attr('data-title')
- @$nameInput =$ "<input class='asset-name' type='text' value='#{ name }' />"
- @$title.before @$nameInput
+ @$name =$ "<div class='asset-name'></div>"
+ @$nameInput =$ "<input type='text' value='#{ name }' />"
+ @$name.append @$nameInput
+ @$title.before @$name
@_bind_name_input()
# handler for asset name change on title click
@$title.on 'click', (e) => @_edit_name(e)