client.js.otp.widgets.Widget.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
/* This program is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
otp.namespace("otp.widgets");
otp.widgets.Widget = otp.Class({
id : null,
owner : null,
mainDiv : null,
header : null,
minimizedTab : null,
// fields that can be set via the options parameter, and default values:
draggable : true,
minimizable : true,
closeable : false,
resizable : false,
showHeader : true,
title : '', // string
openInitially : true,
persistOnClose : false, // whether widget can be opened via 'toolbar' dropdown when closed
transparent : false, // whether to hide the default gray background / frame
isOpen : true, // whether or not widget is displayed in applicable module view
isMinimized : false,
initialize : function(id, owner, options) {
//console.log('widget constructor: '+this.id);
if(typeof options !== 'undefined') {
_.extend(this, options);
}
this.id = id;
this.owner = owner;
this.owner.addWidget(this);
// set up the main widget DOM element:
this.mainDiv = $('').attr('id', id).addClass('otp-widget').appendTo('body');
if(!this.transparent) this.mainDiv.addClass('otp-widget-nonTransparent');
if(!this.openInitially) {
this.isOpen = false;
this.mainDiv.css('display','none');
}
if(typeof this.cssClass !== 'undefined') {
this.mainDiv.addClass(this.cssClass);
}
if(this.resizable) this.mainDiv.resizable();
if(this.showHeader) this.addHeader();
var this_ = this;
if(this.draggable) {
this.mainDiv.draggable({
containment: "#map",
start: function(event, ui) {
$(this_.mainDiv).css({'bottom' : 'auto', 'right' : 'auto'});
},
cancel: '.notDraggable'
});
}
},
addHeader : function() {
var this_ = this;
//this.title = title;
this.header = $(' ').appendTo(this.mainDiv);
var buttons = $('').appendTo(this.mainDiv);
if(this.closeable) {
$("