-
-
Save charlycoste/6570339 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
FadeTransitionRegion = Backbone.Marionette.Region.extend | |
show: (view)-> | |
@ensureEl() | |
view.render() | |
@close -> | |
return if @currentView and @currentView isnt view | |
@currentView = view | |
@open view, -> | |
view.onShow?() | |
view.trigger "show" | |
@onShow? view | |
@trigger "view:show", view | |
close: (cb) -> | |
view = @currentView | |
delete @currentView | |
if not view | |
cb?.call @ | |
return | |
view.fadeOut => | |
view.close?() | |
@trigger "view:closed", view | |
cb?.call @ | |
open: (view, callback) -> | |
@$el.html view.$el.hide() | |
view.fadeIn => | |
callback.call @ |
This file contains hidden or 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
// Generated by CoffeeScript 1.6.1 | |
var FadeTransitionRegion; | |
FadeTransitionRegion = Backbone.Marionette.Region.extend({ | |
show: function(view) { | |
this.ensureEl(); | |
view.render(); | |
return this.close(function() { | |
if (this.currentView && this.currentView !== view) { | |
return; | |
} | |
this.currentView = view; | |
return this.open(view, function() { | |
if (typeof view.onShow === "function") { | |
view.onShow(); | |
} | |
view.trigger("show"); | |
if (typeof this.onShow === "function") { | |
this.onShow(view); | |
} | |
return this.trigger("view:show", view); | |
}); | |
}); | |
}, | |
close: function(cb) { | |
var view, | |
_this = this; | |
view = this.currentView; | |
delete this.currentView; | |
if (!view) { | |
if (cb != null) { | |
cb.call(this); | |
} | |
return; | |
} | |
return view.fadeOut(function() { | |
if (typeof view.close === "function") { | |
view.close(); | |
} | |
_this.trigger("view:closed", view); | |
return cb != null ? cb.call(_this) : void 0; | |
}); | |
}, | |
open: function(view, callback) { | |
var _this = this; | |
this.$el.html(view.$el.hide()); | |
return view.fadeIn(function() { | |
return callback.call(_this); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment