153 lines
2.8 KiB
JavaScript
153 lines
2.8 KiB
JavaScript
cdb.admin.overlays.Fullscreen = cdb.core.View.extend({
|
|
|
|
tagName: 'div',
|
|
className: 'cartodb-fullscreen',
|
|
|
|
events: {
|
|
"click a": "_toggleFullScreen"
|
|
},
|
|
|
|
template_name: 'table/views/overlays/fullscreen',
|
|
|
|
initialize: function() {
|
|
|
|
_.bindAll(this, "_close");
|
|
|
|
this.template = this.getTemplate(this.template_name);
|
|
|
|
this._setupModels();
|
|
|
|
},
|
|
|
|
_killEvent: function(e) {
|
|
|
|
e && e.preventDefault();
|
|
e && e.stopPropagation();
|
|
|
|
},
|
|
|
|
// Setup the internal and custom model
|
|
_setupModels: function() {
|
|
|
|
this.model = this.options.model;
|
|
|
|
this.model.on("change:display", this._onChangeDisplay, this);
|
|
this.model.on("change:y", this._onChangeY, this);
|
|
|
|
this.model.on("destroy", function() {
|
|
this.$el.remove();
|
|
}, this);
|
|
|
|
},
|
|
|
|
_onChangeY: function() {
|
|
|
|
var y = this.model.get("y");
|
|
this.$el.animate({ top: y }, 150);
|
|
|
|
this.trigger("change_y", this);
|
|
|
|
},
|
|
|
|
_onChangeDisplay: function() {
|
|
|
|
var display = this.model.get("display");
|
|
|
|
if (display) {
|
|
this.show();
|
|
} else {
|
|
this.hide();
|
|
}
|
|
|
|
},
|
|
|
|
_onMouseDown: function() { },
|
|
_onMouseEnterText: function() { },
|
|
_onMouseLeaveText: function() { },
|
|
_onMouseEnter: function() { },
|
|
_onMouseLeave: function() { },
|
|
|
|
show: function() {
|
|
|
|
var self = this;
|
|
|
|
this.$el.fadeIn(250, function() {
|
|
self.trigger("change_y", self);
|
|
});
|
|
|
|
},
|
|
|
|
hide: function(callback) {
|
|
|
|
var self = this;
|
|
|
|
callback && callback();
|
|
|
|
this.$el.fadeOut(250, function() {
|
|
self.trigger("change_y", self);
|
|
});
|
|
|
|
},
|
|
|
|
_close: function(e) {
|
|
|
|
this._killEvent(e);
|
|
|
|
var self = this;
|
|
|
|
this.hide(function() {
|
|
self.trigger("remove", self);
|
|
});
|
|
|
|
},
|
|
|
|
_toggleFullScreen: function(ev) {
|
|
|
|
ev.stopPropagation();
|
|
ev.preventDefault();
|
|
|
|
var doc = window.document;
|
|
var docEl = doc.documentElement;
|
|
|
|
if (this.options.doc) { // we use a custom element
|
|
docEl = $(this.options.doc)[0];
|
|
}
|
|
|
|
var requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
|
|
var cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
|
|
|
|
var mapView = this.options.mapView;
|
|
|
|
if (!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) {
|
|
|
|
requestFullScreen.call(docEl);
|
|
|
|
if (mapView) {
|
|
|
|
if (this.model.get("allowWheelOnFullscreen")) {
|
|
mapView.options.map.set("scrollwheel", true);
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cancelFullScreen.call(doc);
|
|
|
|
}
|
|
},
|
|
|
|
render: function() {
|
|
|
|
var self = this;
|
|
|
|
this.$el.append(this.template());
|
|
|
|
this.$el.css({ left: this.model.get("x"), top: this.model.get("y") });
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
});
|