Created
March 7, 2012 22:53
-
-
Save andrewvc/1996862 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pose.Models.LabelTag = Backbone.Model.extend | |
Pose.Models.Color = Backbone.Model.extend | |
Pose.Models.Label = Backbone.Model.extend | |
defaults: | |
color: Pose.Models.Color | |
label_tags: Pose.Collections.LabelTags | |
Pose.Collections.Colors = Backbone.Collection.extend | |
model: Pose.Models.Color | |
Pose.Collections.LabelTags = Backbone.Collection.extend | |
model: Pose.Models.LabelTag | |
search: (text) -> | |
@models.set search_it(text) | |
Pose.Views.Tagging.ColorSelector = Backbone.View.extend | |
initialize: (opts) -> | |
@color_pallet = opts.color_pallete | |
_.bindAll(this, 'render') | |
@collection.bind('change') | |
events: | |
"click .swatch": "pick" | |
"mouseover .swatch": "zoom" | |
pick: (e) -> | |
@model.set | |
color: Colors.get($(e.currentTarget).data('color-id')) | |
Pose.Views.Tagging.DetailDisplay: | |
events: | |
"click .label-tag-destroy": 'destroy_label_tag' | |
initialize: | |
_.bindAll(this, 'render') | |
@model.bind('change', this.render) | |
@tmpl = $('#tagging_detail_display_tmpl') | |
render: | |
@el.html($.tmpl(@tmpl, @model)) | |
destroy_label_tag: (e) -> | |
label_tag = @model.get('label_tags').get($(e.currentTarget).data('id')) | |
@model.get('label_tags').remove(label_tag) | |
Pose.Views.Tagging.LabelTagAndColor | |
initialize: (opts) -> | |
@pallete = new Pose.Collections.Colors(opts.pallete) | |
@label_tag_library = new Pose.Collections.LabelTags(opts.label_tag_library) | |
@color_selector = new Pose.Views.Tagging.ColorSelector model: @model, color_pallete: Pose.Collections.Colors | |
@label_tag_selector = new Pose.Views.Tagging.LabelTagSelector model: @model, label_tag_library: @label_tag_library | |
@detail_display = new Pose.Views.Tagging.DetailDisplay model: @model | |
render: | |
@color_selector.render() | |
@label_tag_selector.render() | |
@detail_display.render() | |
$ -> | |
raw_colors = get_colors | |
label_tags = get_label_tags | |
Pose.Views.Tagging.LabelTagAndColor pallete: raw_colors, label_tag_library: raw_label_tags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment