Sha256: 48b13dd1d8160bb708b0816c71e0adf01d13e6ee41baa6e7e3e705d31eaf7e50
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 KB
Contents
class IuguUI.Base extends Backbone.View defaults: baseURL: "" initialize: -> _.bindAll @, 'render', 'root', 'identifier', 'delegateChild', 'mapDOMEvent', 'handleEvent', 'handleDOMEvent', 'unload', 'close' @options = _.extend {}, @defaults, @options @layout = @options.layout if @options.layout @parent = @options.parent if @options.parent @identifier = ( -> @options.identifier + ':' ) if @options.identifier @handleEvent 'initialize' @ render: -> $(@el).html @getLayout() @context() @ getLayout: -> if JST[ "web-app/presenters/" + @layout ] return JST[ "web-app/presenters/" + @layout ] JST[ "iugu-ux/components/presenters/" + @layout ] context: -> return { } historyNavigate: (url) -> Backbone.history.navigate @options.baseURL + '/' + url root: -> _.result(@parent,'root') or @ identifier: -> _.result(@parent,'identifier') or '' delegateChild: ( selector, view ) -> selectors = {} if _.isObject(selector) selectors = selector else selectors[selector] = view return unless selectors _.each( selectors, ( view, selector ) -> view.setElement(@$(selector)).render() , this ) mapDOMEvent: (type) -> switch type when 'click' then return 'click' when 'mouseover' then return 'mouseover' when 'mouseout' then return 'mouseout' else return type handleEvent: (triggerType) -> @root().trigger( @identifier() + triggerType, @ ) handleDOMEvent: (e) -> e.preventDefault() triggerType = @mapDOMEvent e.type @handleEvent triggerType trigger: (events) -> if app.debug_events debug 'Triggered Event: ' + arguments[0] super unload: () -> debug 'Called IuguUI.Base:unload' @undelegateEvents() @off() close: () -> debug 'Called IuguUI.Base:close' @unload() @remove @IuguUI.Base = IuguUI.Base
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
iugu-ux-0.8.6 | vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-base.js.coffee |
iugu-ux-0.8.5 | vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-base.js.coffee |