app/assets/javascripts/backbone/views/page.js.coffee in tawork-0.0.11 vs app/assets/javascripts/backbone/views/page.js.coffee in tawork-0.0.12

- old
+ new

@@ -1,7 +1,8 @@ class Tawork.Views.PageView extends Backbone.View - events: {} + events: + 'click a.star': 'starred' initialize: (options = {}) -> @page_id = @$el.data("page-id") @initialize_sortable_tree() @setup_uploader() @@ -70,7 +71,34 @@ Error: (up, err) -> document.getElementById("console").innerHTML += "\nError #" + err.code + ": " + err.message ) uploader.init() - + + starred: (event) -> + $star = $(event.target).closest("a.star") + $icon = $star.find("i.fa") + $.blockUI(message: "") + + if $icon.hasClass("fa-star-o") + star = true + else + star = false + + $.ajax + type: $star.data("type") + url: $star.data("url") + data: + to_star: star + success: (data) -> + if $icon.hasClass("fa-star-o") + $icon.removeClass("fa-star-o") + $icon.addClass("fa-star") + else + $icon.removeClass("fa-star") + $icon.addClass("fa-star-o") + complete: -> + $.unblockUI() + + + false