summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/lib/ModalView.js
blob: 1c41861d009d3f7d89adb90368353c5e8b5a42d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var ModalView = View.extend({
	events: {
		"click .close": 'close',
	},
	
	initialize: function(opt){
		if (opt && opt.parent) {
			this.parent = opt.parent
		}
	},
	
	usesFileUpload: false,
	
	show: function(){
		$(".mediaDrawer").removeClass("active")
		
		if (! this.usesFileUpload) {
		  $(".fileUpload").removeClass("active")
		}
		if (this.fixedClose) {
			$("#fixed_close").addClass("active")
			$("#fixed_close").bind("click", this.hide.bind(this))
		}
		
		this.$el.addClass("active")
    $("body").addClass("noOverflow")
	},

	hide: function(){
    // $(".mediaDrawer, .room1").removeClass("active editing");
		if (this.fixedClose) {
			$("#fixed_close").removeClass("active")
			$("#fixed_close").unbind("click", this.hide.bind(this))
		}
		this.$el.removeClass("active");
    $("body").removeClass("noOverflow");
	},
	
	close: function(){
		if (window.isModalView) {
			window.location.pathname = "/"
		}
		else {
			history.pushState(null, document.title, app.router.originalPath)
			this.hide()
		}
	}

})