/**
* `cercalia.widget.MainMenuStatus.TAB_FIND_OPEN`<br/>
* `cercalia.widget.MainMenuStatus.TAB_ROUTING_OPEN`<br/>
* `cercalia.widget.MainMenuStatus.TAB_POIS_OPEN`<br/>
* `cercalia.widget.MainMenuStatus.CLOSED`<br/>
* `cercalia.widget.MainMenuStatus.HIDDEN`<br/>
* @enum {string}
*/
cercalia.widget.MainMenuStatus = {
TAB_FIND_OPEN: 'find',
TAB_ROUTING_OPEN: 'routing',
TAB_POIS_OPEN: 'pois',
CLOSED: 'closed',
HIDDEN: 'hidden'
};
/**
* Constructor del widget MainMenu.<br/>
* Esta clase contiene el mapa junto con todos los widgets.<br/>
* Se añade en el mapa una barra en uno de los dos laterales. La posición se especifica por parámetro con la opción 'option.position'.
* Deben pasarse también las opciones del mapa (cercaliax.MapOptions)<br/>
* <br/>
* Si se desea acceder al objeto map se puede referenciar la variable mediante la funcion getMap() del objeto creado de esta clase.
*
* @class
* @constructor
* @param {cercaliax.widget.MainMenuOptions=} opt_options Opciones del MainMenu
*/
cercalia.widget.MainMenu = function(opt_options) {
var options = opt_options ? opt_options : {};
/**
* @private
* @type {string}
*/
this.CLASS_NAME_ = 'cercalia.widget.MainMenu';
/**
* @private
* @type {divId}
*/
this.divId_ = options.div ? (options.div === 'body' ? options.div : '#' + options.div) : 'body';
/**
* Posicion del menu. Valores possibles: 'west' o 'east'.
* @private
* @type {string}
*/
this.position_ = options.position ? (options.position !== 'west' && options.position !== 'east' ? 'west' : options.position) : 'west';
/**
* Width del menu lateral en estado abierto en pixeles.
* @private
* @type {number}
*/
this.openSize_ = options.openSize ? options.openSize : 336;
/**
* Width del menu lateral en estado cerrado en pixeles.
* @private
* @type {number}
*/
this.closeSize_ = options.closeSize ? options.closeSize : 44;
/**
* Estado inicial del menu lateral. Valores possibles: 'open' y 'close'.
* @private
* @type {string}
*/
this.initalState_ = options.initalState ? (options.initalState === 'open' || options.initalState === 'close' ? options.initalState : 'open') : 'open';
/**
* Opciones para el mapa.
* @private
* @type {cercaliax.MapOptions}
*/
this.mapOptions_ = options.mapOptions ? options.mapOptions : {
controls: [
cercalia.MapControls.RotateNorth,
cercalia.MapControls.ZoomSlider,
cercalia.MapControls.FullScreen,
cercalia.MapControls.ScaleLine,
cercalia.MapControls.DragControl,
cercalia.MapControls.DrawControl,
cercalia.MapControls.CleanControl,
cercalia.MapControls.MeasureControl,
cercalia.MapControls.MeteoControl,
cercalia.MapControls.LayerSwitcher,
cercalia.MapControls.Traffic,
cercalia.MapControls.GasStations
]
};
/**
* Opciones para el widget de geocoding.
* @private
* @type {cercaliax.widget.GeocodingOptions}
*/
this.geocodingOptions_ = options.geocodingOptions ? options.geocodingOptions : {
type: 'cp'
};
/**
* Opciones para el widget de geocoding suggest.
* @private
* @type {cercaliax.widget.GeocodingSuggestOptions}
*/
this.geocodingSuggestOptions_ = options.geocodingSuggestOptions ? options.geocodingSuggestOptions : {
searchClosestHouseNumber: true
};
/**
* Opciones para el widget de routing
* @private
* @type {cercaliax.widget.RoutingOptions}
*/
this.routingOptions_ = options.routingOptions ? options.routingOptions : null;
/**
* Opciones para el widget de POI map.
* @private
* @type {cercaliax.widget.PoiMapOptions}
*/
this.poiMapOptions_ = options.poiMapOptions ? options.poiMapOptions : null;
/**
* Opciones para el widget de POI proximity.
* @private
* @type {cercaliax.widget.PoiProximityOptions}
*/
this.poiProximityOptions_ = options.poiProximityOptions ? options.poiProximityOptions : null;
/**
* Opciones para el widget de POI suggest
* @private
* @type {cercaliax.widget.PoiSuggestOptions}
*/
this.poiSuggestOptions_ = options.poiSuggestOptions ? options.poiSuggestOptions : null;
/**
* Opciones para el widget de reverse geocoding
* @private
* @type {cercaliax.widget.ReverseGeocodingOptions}
*/
this.reverseGeocodingOptions_ = options.reverseGeocodingOptions ? options.reverseGeocodingOptions : {};
/**
* @private
* @type {string}
*/
this.defaultCountry_ = options.defaultCountry ? options.defaultCountry : null;
/**
* @private
* @type {Function|null}
*/
this.resizeCallbackFunction_ = options.resizeCallbackFunction ? options.resizeCallbackFunction : null;
/**
* @private
* @type {cercalia.LonLat}
*/
this.lastPositionProxReq_ = new cercalia.LonLat(0, 0);
/* VARIABLES PRIVADAS */
/**
* Lista de marcadores pintados en el mapa.
* @private
* @type {jQuery.layout}
*/
this.layout_ = null;
/**
* Tabs de jQuery UI.
* @private
* @type {jQuery.ui.Tabs}
*/
this.tabs_ = null;
this.lastTabActivated_ = 0;
/**
* Actualiza el tamaño del mapa OL.
* @private
* @type {Function}
*/
this.resizePanes_ = function() {
this.map_.getMap().updateSize();
if (this.poiProximity_ !== null) {
this.poiProximity_.resize();
}
if (this.routing_ !== null) {
this.routing_.resize();
}
if (this.resizeCallbackFunction_) {
this.resizeCallbackFunction_();
}
};
/**
* Configuración del jQuery Layout.
* @private
* @type {Object}
*/
var self = this;
this.layoutOptions_ = {
name: 'layoutMapa',
defaults: {
size: 'auto',
minSize: 30,
paneClass: 'pane',
resizerClass: 'resizer',
togglerClass: 'toggler',
buttonClass: 'button',
contentSelector: '.content',
contentIgnoreSelector: 'span',
togglerLength_open: 35,
togglerLength_closed: 35,
hideTogglerOnSlide: true,
fxName: 'none'
},
center: {
paneSelector: '',
minWidth: 200,
minHeight: 200,
onresize_start: function() {},
onresize: function() {},
onresize_end: function() {
self.map_.getMap().updateSize();
if (self.poiProximity_ !== null) self.poiProximity_.resize();
if (self.routing_ !== null) self.routing_.resize();
},
resizable: false
}
};
this.layoutOptions_[this.position_] = {
size: this.openSize_,
paneSelector: '',
resizable: false,
onresize_start: function() {},
onresize: function() {},
onresize_end: function() {
self.map_.getMap().updateSize();
if (self.poiProximity_ !== null) self.poiProximity_.resize();
if (self.routing_ !== null) self.routing_.resize();
},
spacing_open: 0,
spacing_closed: 10,
cercaliaState: 'open', //this.initalState_,
cercaliaOpenSize: this.openSize_,
cercaliaCloseSize: this.closeSize_
};
/**
* Mapa.
* @private
* @type {cercalia.Map}
*/
this.map_ = null;
/**
* Boton para cerrar el layout
* @private
* @type {Object}
*/
this.closeLayoutButton_ = null;
/* WIDGETS Y SERVICIOS DE CERCALIA*/
/**
* Widget de autocomplete.
* @private
* @type {cercalia.widget.GeocodingSuggest}
*/
this.autocomplete_ = null;
/**
* Widget de geocoding.
* @private
* @type {cercalia.widget.Geocoding}
*/
this.geocoding_ = null;
/**
* Widget de reverse geocoding.
* @private
* @type {cercalia.widget.ReverseGeocoding}
*/
this.reverseGeocoding_ = null;
/**
* Widget de reverse routing.
* @private
* @type {cercalia.widget.Routing}
*/
this.routing_ = null;
/**
* Widget de poi en mapa.
* @private
* @type {cercalia.widget.PoiMap}
*/
this.poiMapa_ = null;
/**
* Widget de poi suggest.
* @private
* @type {cercalia.widget.PoiSuggest}
*/
this.poiSuggest_ = null;
/**
* Widget de poi proximity.
* @private
* @type {cercalia.widget.PoiProximity}
*/
this.poiProximity_ = null;
/**
* @private
* @type {boolean}
*/
this.visiblePanel_ = true;
// Inicialización
this.initialize_();
this.initializeEvents_();
};
/**
* Inicializa el elemento
* @private
*/
cercalia.widget.MainMenu.prototype.initialize_ = function() {
if (!this.divId_) {
cercalia.Exception(cercalia.i18n._('WIDGET_ERR_NO_DIV "%"', this.CLASS_NAME_));
} else {
var self = this;
/********************************
* CREACIÓN ESTRUCTURA BÁSICA
********************************/
var prefixId = this.divId_.replace('#', '') + '_';
var element = cercalia.jQuery(this.divId_).addClass('cercalia-widget cercalia-widget-mainmenu');
var center = cercalia.jQuery('<div />').attr('id', prefixId + 'center').addClass('cercalia-widget-mainmenu-center').appendTo(element);
var mainMenu = cercalia.jQuery('<div />').attr('id', prefixId + 'menu').addClass('cercalia-widget-mainmenu-' + this.position_).appendTo(element);
// Configuramos divs en la config. del layout
this.layoutOptions_['center'].paneSelector = '#' + prefixId + 'center';
this.layoutOptions_[this.position_].paneSelector = '#' + prefixId + 'menu';
var icon = this.position_ == 'west' ? 'ui-icon-carat-1-w' : 'ui-icon-carat-1-e';
// Inicializamos Layout
this.layout_ = cercalia.jQuery(this.divId_).layout(this.layoutOptions_);
// Boton para cerrar layout
this.closeLayoutButton_ = jQuery('<div />')
.addClass('closeLayout')
.appendTo(mainMenu)
.click(function() {
//self.tabs_.tabs('option', 'active', 3);
/*self.closePanel (self.position_, function () {
//self.tabs_.find('.ui-tabs-panel').hide();
closeLayout.hide();
});*/
//self.resizePanes_();
self.closePanel();
});
cercalia.jQuery('<span />').addClass('ui-icon ' + icon).appendTo(this.closeLayoutButton_);
// Mapa
cercalia.jQuery('<div />').attr('id', prefixId + 'map').addClass('cercalia-widget-mainmenu-map').appendTo(center);
this.mapOptions_.target = prefixId + 'map';
this.map_ = new cercalia.Map(this.mapOptions_);
this.map_.setMainMenu(this);
/********************************
* CREACIÓN TABS
********************************/
var tabsDiv = cercalia.jQuery('<div />').attr('id', prefixId + 'tabs')
.addClass('cercalia-widget-mainmenu-tabs')
.appendTo(mainMenu);
var ul = cercalia.jQuery('<ul />').appendTo(tabsDiv);
cercalia.jQuery('<li />').appendTo(ul).append(
cercalia.jQuery('<a />')
.attr('href', '#' + prefixId + 'find')
.append(
cercalia.jQuery('<span />').addClass('ui-icon cercalia-big-icon cercalia-big-icon-magnifier')
)
.append(
cercalia.jQuery('<span />').addClass('text-btn').text(cercalia.i18n._('Find'))
)
);
cercalia.jQuery('<li />').appendTo(ul).append(
cercalia.jQuery('<a />')
.attr('href', '#' + prefixId + 'routing')
.append(
cercalia.jQuery('<span />').addClass('ui-icon cercalia-big-icon cercalia-big-icon-road')
)
.append(
cercalia.jQuery('<span />').addClass('text-btn').text(cercalia.i18n._('Routing'))
)
);
cercalia.jQuery('<li />').appendTo(ul).append(
cercalia.jQuery('<a />')
.attr('href', '#' + prefixId + 'pois')
.append(
cercalia.jQuery('<span />').addClass('ui-icon cercalia-big-icon cercalia-big-icon-pois')
)
.append(
cercalia.jQuery('<span />').addClass('text-btn').text(cercalia.i18n._('POI'))
)
);
cercalia.jQuery('<li />').addClass('cercalia-widget-mainmenu-tabs-no').appendTo(ul).append(
cercalia.jQuery('<a />').attr('href', '#' + prefixId + 'no')
);
var find = cercalia.jQuery('<div />').attr('id', prefixId + 'find').addClass('cercalia-widget-mainmenu-contentTab-find').appendTo(tabsDiv);
var routing = cercalia.jQuery('<div />').attr('id', prefixId + 'routing').addClass('cercalia-widget-mainmenu-contentTab-routing').appendTo(tabsDiv);
var puntosInteres = cercalia.jQuery('<div />').attr('id', prefixId + 'pois').addClass('cercalia-widget-mainmenu-contentTab-poi').appendTo(tabsDiv);
//var no = cercalia.jQuery('<div />').attr('id', prefixId + 'no').appendTo(tabsDiv);
// Inicializamos TABS
this.tabs_ = tabsDiv.tabs({
beforeActivate: function(event, ui) {
var newTab = ui.newTab,
oldTab = ui.oldTab,
newPanel = ui.newPanel,
oldPanel = ui.oldPanel;
var tabActiveNo = newPanel.selector == ('#' + prefixId + 'no');
if (!tabActiveNo) {
self.openPanel();
}
}
});
if (this.initalState_ === 'close') {
this.closeLayoutButton_.click();
}
/********************************
* CREACIÓN TAB 1
********************************/
var findType = cercalia.jQuery('<div />')
.attr('id', prefixId + 'findType')
.addClass('cercalia-widget-mainmenu-contentTab-findType')
.appendTo(find); //tipo_busqueda
cercalia.jQuery('<input />')
.attr('type', 'radio')
.attr('options', prefixId + 'findDirection')
.attr('id', prefixId + 'findDirectionOption')
.attr('name', prefixId + 'find')
.appendTo(findType);
cercalia.jQuery('<label />')
.attr('for', prefixId + 'findDirectionOption')
.html(cercalia.i18n._('Address'))
.appendTo(findType);
cercalia.jQuery('<input />')
.attr('type', 'radio')
.attr('options', prefixId + 'findPC')
.attr('id', prefixId + 'findPCOption')
.attr('name', prefixId + 'find')
.appendTo(findType);
cercalia.jQuery('<label />')
.attr('for', prefixId + 'findPCOption')
.html(cercalia.i18n._('Postal code'))
.appendTo(findType);
cercalia.jQuery('<input />')
.attr('type', 'radio')
.attr('options', prefixId + 'findCoordinates')
.attr('id', prefixId + 'findCoordinatesOption')
.attr('name', prefixId + 'find')
.appendTo(findType);
cercalia.jQuery('<label />')
.attr('for', prefixId + 'findCoordinatesOption')
.html(cercalia.i18n._('Coordinates'))
.appendTo(findType);
// Buttonset de tipo de busqueda
findType.buttonset();
findType.find('input').change(function() {
if (cercalia.jQuery(this).is(':checked')) self.changeModoBusqueda_(this);
});
// Widget Geocoding Suggest
var geocodingSuggestDiv = cercalia.jQuery('<div />').attr('id', prefixId + 'findDirection').addClass('cercalia-widget-mainmenu-contentTab-find-options').appendTo(find);
this.geocodingSuggestOptions_.div = geocodingSuggestDiv.attr('id');
this.geocodingSuggestOptions_.filterType = true;
if (this.defaultCountry_) {
this.geocodingSuggestOptions_.defaultCountry = this.defaultCountry_;
}
this.autocomplete_ = new cercalia.widget.GeocodingSuggest(this.geocodingSuggestOptions_);
this.map_.addWidget(this.autocomplete_);
// Widget Geocoding
var geocodingDiv = cercalia.jQuery('<div />').attr('id', prefixId + 'findPC').addClass('cercalia-widget-mainmenu-contentTab-find-options').appendTo(find);
this.geocodingOptions_.div = geocodingDiv.attr('id');
this.geocoding_ = new cercalia.widget.Geocoding(this.geocodingOptions_);
this.map_.addWidget(this.geocoding_);
// Widget Reverse Geocoding
var reverseGeocodingDiv = cercalia.jQuery('<div />').attr('id', prefixId + 'findCoordinates').addClass('cercalia-widget-mainmenu-contentTab-find-options').appendTo(find);
this.reverseGeocodingOptions_.div = reverseGeocodingDiv.attr('id');
this.reverseGeocoding_ = new cercalia.widget.ReverseGeocoding(this.reverseGeocodingOptions_);
this.map_.addWidget(this.reverseGeocoding_);
// Inicializamos buttons sets por defecto
cercalia.jQuery('#' + prefixId + 'findDirectionOption').attr('checked', 'checked');
findType.find('input').change();
/********************************
* CREACIÓN TAB 2
********************************/
// Widget Routing
var routingOptions = this.routingOptions_ ? this.routingOptions_ : {};
if (!routingOptions.height) {
routingOptions.height = function() {
return tabsDiv.outerHeight() - tabsDiv.find('ul').outerHeight() - 10;
};
}
if (!routingOptions.showUI) {
routingOptions.showUI = function() {
self.tabs_.tabs('option', 'active', 1);
}
}
routingOptions.div = routing.attr('id');
if (this.defaultCountry_) {
routingOptions.defaultCountry = this.defaultCountry_;
}
this.routing_ = new cercalia.widget.Routing(routingOptions);
this.map_.addWidget(this.routing_);
/********************************
* CREACIÓN TAB 3
********************************/
var poiType = cercalia.jQuery('<div />')
.attr('id', prefixId + 'poiType')
.addClass('cercalia-widget-mainmenu-contentTab-poiType')
.appendTo(puntosInteres); //tipo_puntosInteres
cercalia.jQuery('<input />')
.attr('type', 'radio')
.attr('options', prefixId + 'poiMap')
.attr('id', prefixId + 'poiMapOption')
.attr('name', prefixId + 'poi')
.appendTo(poiType);
cercalia.jQuery('<label />')
.attr('for', prefixId + 'poiMapOption')
.html(cercalia.i18n._('Active in map'))
.css('width', '48%')
.appendTo(poiType);
cercalia.jQuery('<input />')
.attr('type', 'radio')
.attr('options', prefixId + 'poiProximity')
.attr('id', prefixId + 'poiProximityOption')
.attr('name', prefixId + 'poi')
.appendTo(poiType);
cercalia.jQuery('<label />')
.attr('for', prefixId + 'poiProximityOption')
.css('width', '48%')
.html(cercalia.i18n._('Proximity'))
.appendTo(poiType);
/*
cercalia.jQuery('<input />')
.attr('type','radio')
.attr('options', prefixId + 'poiName')
.attr('id', prefixId + 'poiNameOption')
.attr('name', prefixId + 'poi')
.appendTo(poiType);
cercalia.jQuery('<label />')
.attr('for', prefixId + 'poiNameOption')
.html(cercalia.i18n._('By name'))
.appendTo(poiType);
*/
// Buttonset de tipo de pois
poiType.buttonset();
poiType.find('input').change(function() {
if (cercalia.jQuery(this).is(':checked')) {
self.changeModoPuntosInteres_(this);
}
});
// Widget PoiMap
var poiMapDiv = cercalia.jQuery('<div />').attr('id', prefixId + 'poiMap').addClass('cercalia-widget-mainmenu-contentTab-poi-options').appendTo(puntosInteres);
this.poiMapOptions_ = this.poiMapOptions_ !== null ? this.poiMapOptions_ : {
poiListOptions: {
'heightMenu': '200px'
}
};
this.poiMapOptions_.div = poiMapDiv.attr('id');
this.poiMap_ = new cercalia.widget.PoiMap(this.poiMapOptions_);
this.map_.addWidget(this.poiMap_);
// Widget PoiProximity
var poiProximityDiv = cercalia.jQuery('<div />').attr('id', prefixId + 'poiProximity').addClass('cercalia-widget-mainmenu-contentTab-poi-options').appendTo(puntosInteres);
this.poiProximityOptions_ = this.poiProximityOptions_ !== null ? this.poiProximityOptions_ : {
poiListOptions: {
'heightMenu': '200px'
},
height: function() {
return tabsDiv.outerHeight() - tabsDiv.find('ul').outerHeight() - poiType.outerHeight() - 35;
},
showUI: function() {
self.tabs_.tabs('option', 'active', 2);
cercalia.jQuery('#' + prefixId + 'poiProximityOption').attr('checked', 'checked');
poiType.buttonset('refresh');
poiType.find('input').change();
}
};
this.poiProximityOptions_.div = poiProximityDiv.attr('id');
this.poiProximity_ = new cercalia.widget.PoiProximity(this.poiProximityOptions_);
this.map_.addWidget(this.poiProximity_);
// Widget PoiSuggest
var poiSuggestDiv = cercalia.jQuery('<div />').attr('id', prefixId + 'poiName').addClass('cercalia-widget-mainmenu-contentTab-poi-options').appendTo(puntosInteres);
this.poiSuggestOptions_ = this.poiSuggestOptions_ !== null ? this.poiSuggestOptions_ : {
poiListOptions: {
'heightMenu': '200px'
},
height: tabsDiv.outerHeight() - tabsDiv.find('ul').outerHeight() - poiType.outerHeight() - 35
};
this.poiSuggestOptions_.div = poiSuggestDiv.attr('id');
this.poiSuggest_ = new cercalia.widget.PoiSuggest(this.poiSuggestOptions_);
this.map_.addWidget(this.poiSuggest_);
// Inicializamos buttons sets por defecto
cercalia.jQuery('#' + prefixId + 'poiMapOption').attr('checked', 'checked');
poiType.find('input').change();
}
};
/**
* Inicializa el elemento
* @private
*/
cercalia.widget.MainMenu.prototype.initializeEvents_ = function() {
var olMap = this.map_.getMap();
olMap.on('moveend', this.handleMoveEnd_.bind(this));
}
/**
* @private
* @param {ol.MapEvent} event Event.
*/
cercalia.widget.MainMenu.prototype.handleMoveEnd_ = function(event) {
//Update priority country
var center = this.map_.getCenter();
var distanceThreshold = 20000;
if (center && (cercalia.Util.distanceTo(center, this.lastPositionProxReq_) > distanceThreshold)) {
var proximityService = new cercalia.service.Proximity();
proximityService.setSearch({
x: center.getLon(),
y: center.getLat(),
rqge: 'ctry'
});
proximityService.proximity(function(data) {
if (data.cercalia.proximity.gelist && center) {
var ge = data.cercalia.proximity.gelist.ge;
var countryId = ge.id;
this.lastPositionProxReq_ = center;
if (this.lastPositionProxReq_['entities'] !== countryId) {
this.lastPositionProxReq_['entities'] = countryId;
this.updatePriorityAutocompletes_([countryId]);
}
}
}.bind(this));
}
};
/**
* @private
* @param {Array.<string>} entities Entities.
*/
cercalia.widget.MainMenu.prototype.updatePriorityAutocompletes_ = function(entities) {
var autocompleteService = this.autocomplete_.getService();
autocompleteService.setSearchPreferredEntity(entities);
var routingAutocompleteWidgets = this.routing_.getAutocompletesWidgets();
for (var i = 0; i < routingAutocompleteWidgets.length; i++) {
var autocompleteService = this.autocomplete_.getService();
autocompleteService.setSearchPreferredEntity(entities);
}
};
/**
* Abre/Cierra el panel lateral. Tiene que tener definidas las variables cercalia.
*/
cercalia.widget.MainMenu.prototype.togglePanel = function() {
var pane = this.position_;
var paneOptions = this.layout_[pane].options;
if (paneOptions) {
if (typeof(paneOptions.cercaliaState) !== 'undefined' && paneOptions.cercaliaState !== null) {
if (paneOptions.cercaliaState == 'open') {
this.closePanel();
} else {
this.openPanel();
}
} else {
console.error('El panel no tiene los parametros de cercalia');
}
}
};
/**
* Abre el panel indicado si antes estaba cerrado.
*/
cercalia.widget.MainMenu.prototype.openPanel = function() {
//var tab2Open = this.lastTabActivated_;
var paneOptions = this.layout_[this.position_].options;
if (paneOptions) {
if (typeof(paneOptions.cercaliaState) !== 'undefined' && paneOptions.cercaliaState !== null) {
if (paneOptions.cercaliaState === 'open') {
//Ya esta abierto
} else {
// Cambiamos estado
paneOptions.cercaliaState = 'open';
//cercalia.jQuery(this.tabs_.find('.ui-tabs-panel')[tab2Open]).show();
this.closeLayoutButton_.show();
// Cambiamos tamaño del panel
this.tabs_.find('li').removeClass('closed');
this.tabs_.find('li .text-btn').show();
this.layout_.sizePane(this.position_, paneOptions.cercaliaOpenSize);
}
// Resize del contenido de los paneles
this.resizePanes_();
} else {
console.error('El panel no tiene los parametros de ccercalia');
}
}
};
/**
* Cierra el panel indicado si antes estaba abierto.
*/
cercalia.widget.MainMenu.prototype.closePanel = function() {
var paneOptions = this.layout_[this.position_].options;
if (paneOptions) {
if (typeof(paneOptions.cercaliaState) !== 'undefined' && paneOptions.cercaliaState !== null) {
if (paneOptions.cercaliaState === 'close') {
//Ya esta cerrado
} else {
// Cambiamos estado
paneOptions.cercaliaState = 'close';
this.lastTabActivated_ = this.tabs_.tabs('option', 'active');
this.tabs_.tabs('option', 'active', 3);
this.tabs_.find('.ui-tabs-panel').hide();
this.closeLayoutButton_.hide();
// Cambiamos tamaño del panel
this.layout_.sizePane(this.position_, paneOptions.cercaliaCloseSize);
//Escondemos el texto
this.tabs_.find('li').addClass('closed');
this.tabs_.find('li .text-btn').hide();
// Resize del contenido de los paneles
this.resizePanes_();
}
} else {
console.error('El panel no tiene los parametros de cercalia');
}
}
};
/**
* Esconde el panel.
*/
cercalia.widget.MainMenu.prototype.hidePanel = function() {
this.layout_.hide(this.position_);
this.resizePanes_();
this.visiblePanel_ = false;
};
/**
* Abre el panel. Lo abre en el último estado en el que se encontraba (cerrado o abierto)
*/
cercalia.widget.MainMenu.prototype.showPanel = function() {
this.layout_.show(this.position_);
var paneOptions = this.layout_[this.position_].options;
if (typeof(paneOptions.cercaliaState) !== 'undefined' && paneOptions.cercaliaState !== null) {
if (paneOptions.cercaliaState === 'close') {
this.closePanel();
} else {
this.openPanel();
}
} else {
this.resizePanes_();
}
this.visiblePanel_ = true;
};
/**
* Cambia la pantalla del modo de busqueda segun el tipo escojido.
* @param {Object} input : Radiobutton activado.
* @private
*/
cercalia.widget.MainMenu.prototype.changeModoBusqueda_ = function(input) {
cercalia.jQuery('.cercalia-widget-mainmenu-contentTab-find-options').hide();
var options = cercalia.jQuery(input).attr('options');
cercalia.jQuery('#' + options).show();
};
/**
* Cambia la pantalla del modo de puntos de interés segun el tipo escojido.
* @param {Object} input : Radiobutton activado.
* @private
*/
cercalia.widget.MainMenu.prototype.changeModoPuntosInteres_ = function(input) {
cercalia.jQuery('.cercalia-widget-mainmenu-contentTab-poi-options').hide();
var options = cercalia.jQuery(input).attr('options');
cercalia.jQuery('#' + options).show();
};
/**
* Esconde todos los controles (añadidos previamente en el mapa) y el menú. Deja solamente el mapa.
*/
cercalia.widget.MainMenu.prototype.hideAll = function() {
this.map_.hideAllControls();
this.hidePanel();
};
/**
* Muestra todos los controles (añadidos previamente en el mapa) y el menú. Deja solamente el mapa.
*/
cercalia.widget.MainMenu.prototype.showAll = function() {
this.map_.showAllControls();
this.showPanel();
};
/**
* Devuelve el mapa.
* @return {cercalia.Map}
*/
cercalia.widget.MainMenu.prototype.getMap = function() {
return this.map_;
};
/**
* Destroy function.
*/
cercalia.widget.MainMenu.prototype.destroy = function() {
this.map_.getMap().setTarget(null);
this.map_.destroy();
cercalia.jQuery(this.divId_).empty();
for (var key in this) {
this[key] = undefined;
}
};
/**
* Returns current tab enabled
* @return {string} Return state tabs, possibles values: first tab: `find`, second tab: `routing` or third tab: `pois` or if layout is closed: `closed` or if it is hidden: `hidden`
*/
cercalia.widget.MainMenu.prototype.getStatus = function() {
if (this.visiblePanel_) {
switch (this.tabs_.tabs('option', 'active')) {
case 0:
return cercalia.widget.MainMenuStatus.TAB_FIND_OPEN;
case 1:
return cercalia.widget.MainMenuStatus.TAB_ROUTING_OPEN;
case 2:
return cercalia.widget.MainMenuStatus.TAB_POIS_OPEN;
case 3:
return cercalia.widget.MainMenuStatus.CLOSED;
}
} else {
return cercalia.widget.MainMenuStatus.HIDDEN;
}
};