Sha256: b8fcbe2b9f402301cd55d9be19a62724d9e782d3ea24cd56bb1dcb47a56b56fd

Contents?: true

Size: 1.83 KB

Versions: 5

Compression:

Stored size: 1.83 KB

Contents

class Lanes.Components.ModalDialog extends Lanes.Components.Base

    constructor: (options={})->
        _.extend(this, _.pick(options, 'hideOnBackdropClick', 'hideButton'))
        super

    domEvents:
        'hide.bs.modal': '_onHide'

    hideOnEsc: true
    showHideButton: true
    hideOnBackdropClick: true

    bindings:
        'viewport.layout_size': { type:'class',selector:'.modal-dialog'}
        'viewport.layout_size': { selector: '.modal', type: 'class' }

    buttons:
        close: { label: 'Close', type: 'default', dismiss: true }

    session:
        dialog_title: 'string'

    toggleShown: (show)->
        if show then this.show() else this.hide()

    bodyClass: 'base'

    template: ->
        tmpl = Lanes.Templates.find('lanes/components/modal/template')
        tmpl({
            size    : @size  || 'lg'
            title   : @title# || context.dialog_title
            body    : this.renderTemplateMethod('bodyTemplate')
            bodyClass: _.result(this,'bodyClass')
            buttons : @buttons
            showHideButton : @showHideButton
        })

    renderContextFree: ->
        this.replaceEl( this.renderTemplateMethod() );
        this

    hide:->
        this.$el.modal('hide')
        this.notification?.resolve(this)

    show: ->
        if this.rendered
            this.viewport.el.append(this.el)
            this.$el.modal('show')
        else
            this.render()
            this.$el.modal({
                body: this.viewport.el
                backdrop: if this.hideOnBackdropClick then true else 'static'
                hideOnEsc: true
                keyboard: @hideOnEsc
            })
        this.notification = new _.DeferredPromise
        return this.notification.promise

    destroy: ->
        this.detach()

    _onHide: (ev)->
        this.detach()
        this.notification.resolve(this)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lanes-0.1.9 client/lanes/components/modal/ModalDialog.coffee
lanes-0.1.8 client/lanes/components/modal/ModalDialog.coffee
lanes-0.1.7 client/lanes/components/modal/ModalDialog.coffee
lanes-0.1.6 client/lanes/components/modal/ModalDialog.coffee
lanes-0.1.5 client/lanes/components/modal/ModalDialog.coffee