summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/lib/Toolbar.js
blob: a9ce51c7de16bded31b54bbdcc7ddc485893c411 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var Toolbar = Fiber.extend(function(base){
  var exports = {}
  exports.init = function(rapper){
    this.rapper = (typeof rapper == "string") ? $(rapper)[0] : rapper
    this.tools = {}
    this.els = {}
  }
  exports.add = function(role, fn){
    var self = this
    this.tools[role] = fn
    this.els[role] = $("[data-role=" + role + "]", self.rapper)
    this.els[role].click(function(){
      $(".active", self.rapper).removeClass('active')
      $(this).addClass('active')
      fn()
    })
  }
  exports.pick = function(role){
    this.els[role].trigger("click")
  }
  return exports
})