', {
- id: config.mapTabIdPrefix + parseInt( options.id ),
- class: [config.mapTabContentClass].join(' ')
- }).attr('data-mapid', parseInt( options.id ));
-
- contentElement.addClass('tab-pane');
-
- tabContent.append(contentElement);
-
- // init tab ---------------------------------------------------------------------------------------------------
- linkElement.on('click', function(e){
- e.preventDefault();
-
- // callback function after tab switch
- function switchTabCallback(mapElement, tabLinkElement){
- tabLinkElement.tab('show');
- // unfreeze map
- mapElement.data('frozen', false);
- return false;
- }
-
- if(mapTabChangeBlocked === false){
- let tabLinkElement = $(this);
- let mapId = tabLinkElement.data('map-id');
-
- // ignore "add" tab. no need for map change
- if(mapId > 0){
- let mapElement = $('#' + config.mapTabElementId).getActiveMap();
-
- if(mapId !== mapElement.data('id')){
- // block tabs until switch is done
- mapTabChangeBlocked = true;
-
- // freeze active map -> no user data update while map switch
- mapElement.data('frozen', true);
-
- // hide current map with animation
- mapElement.visualizeMap('hide', function(){
- // un-block map tabs
- mapTabChangeBlocked = switchTabCallback(mapElement, tabLinkElement);
- });
+ tabElement.find('.nav.nav-tabs').each((index, tabListElement) => {
+ // set tab sortable ---------------------------------------------------------------------------------------
+ let sortable = Sortable.create(tabListElement, {
+ group: {
+ name: 'list_' + tabListElement.getAttribute('data-position')
+ },
+ animation: Init.animationSpeed.mapModule,
+ handle: '.' + config.mapTabDragHandlerClass,
+ draggable: '.' + config.mapTabClass,
+ ghostClass: 'pf-sortable-ghost',
+ scroll: false,
+ dataIdAttr: 'data-mapId',
+ sort: true,
+ filter: function(e, listElement){
+ listElement = $(listElement);
+ let mapId = parseInt(listElement.attr('data-mapid')) || 0;
+ return !Boolean(mapId);
+ },
+ store: {
+ get: function (sortable) {
+ return [];
+ },
+ set: function (sortable) {
+ let key = 'maps_' + sortable.options.group.name;
+ // convert string array to int array
+ let order = sortable.toArray().map((x) => parseInt(x, 10));
+ MapUtil.storeLocalData('character', characterId, key, order);
}
- }else{
+ },
+ onStart: function (e) {
+ // Element dragging started
+ // -> save initial sort state -> see store.set()
+ this.save();
+ }
+ });
+
+ // set tab click ------------------------------------------------------------------------------------------
+ $(tabListElement).on('click', 'a', function(e){
+ e.preventDefault();
+
+ // callback function after tab switch
+ function switchTabCallback(mapElement, tabLinkElement){
tabLinkElement.tab('show');
+ // unfreeze map
+ mapElement.data('frozen', false);
+ return false;
}
- }
- });
- return {
- listElement: newListElement,
- contentElement: contentElement
- };
- };
+ if(mapTabChangeBlocked === false){
+ let tabLinkElement = $(this);
+ let mapId = tabLinkElement.data('map-id');
- /**
- * deletes a map tab for a given map id
- * @param mapId
- */
- $.fn.deleteTab = function(mapId){
- let tabElement = $(this);
- let linkElement = tabElement.find('a[href="#' + config.mapTabIdPrefix + mapId + '"]');
- let deletedTabName = '';
+ // ignore "add" tab. no need for map change
+ if(mapId > 0){
+ let mapElement = $('#' + config.mapTabElementId).getActiveMap();
- if(linkElement.length > 0){
- deletedTabName = linkElement.find('.' + config.mapTabLinkTextClass).text();
+ if(mapId !== mapElement.data('id')){
+ // block tabs until switch is done
+ mapTabChangeBlocked = true;
- let liElement = linkElement.parent();
- let contentElement = tabElement.find('div[id="' + config.mapTabIdPrefix + mapId + '"]');
+ // freeze active map -> no user data update while map switch
+ mapElement.data('frozen', true);
- let findNewActiveTab = false;
- // check if liElement was active
- if(liElement.hasClass('active')){
- // search any remaining li element and set active
- findNewActiveTab = true;
- }
-
- liElement.remove();
- contentElement.remove();
-
- // remove map instance from local cache
- Map.clearMapInstance(mapId);
-
- if(findNewActiveTab === true){
- tabElement.find('.' + config.mapTabClass + ':not(.pull-right):first a').tab('show');
- }
- }
-
- return deletedTabName;
- };
-
- /**
- * clear all active maps
- */
- $.fn.clearMapModule = function(){
- let mapModuleElement = $(this);
- let tabMapElement = $('#' + config.mapTabElementId);
-
- if(tabMapElement.length > 0){
- let tabElements = mapModuleElement.getMapTabElements();
-
- for(let i = 0; i < tabElements.length; i++){
- let tabElement = $(tabElements[i]);
- let mapId = tabElement.data('map-id');
-
- if(mapId > 0){
- tabMapElement.deleteTab(mapId);
- }
- }
- }
- };
-
- /**
- * load/update map module into element (all maps)
- * @returns {boolean}
- */
- $.fn.updateMapModule = function(){
- let mapModuleElement = $(this);
-
- // store current map data global (cache)
- // temp store current map data to prevent data-change while function execution!
- let tempMapData = Util.getCurrentMapData();
-
- if(tempMapData.length === 0){
- // clear all existing maps
- mapModuleElement.clearMapModule();
-
- // no map data available -> show "new map" dialog
- $(document).trigger('pf:menuShowMapSettings', {tab: 'new'});
-
- return true;
- }
-
- // performance logging (time measurement)
- let logKeyClientMapData = Init.performanceLogging.keyClientMapData;
- Util.timeStart(logKeyClientMapData);
-
- // check if tabs module is already loaded
- let tabMapElement = $('#' + config.mapTabElementId);
-
- // check if tabs have changed
- let tabsChanged = false;
-
- if(tabMapElement.length > 0){
- // tab element already exists
- let tabElements = mapModuleElement.getMapTabElements();
-
- // map ID that is currently active
- let activeMapId = 0;
-
- // mapIds that are currently active
- let activeMapIds = [];
-
- // check whether a tab/map is still active
- for(let i = 0; i < tabElements.length; i++){
- let tabElement = $(tabElements[i]);
- let mapId = tabElement.data('map-id');
-
- if(mapId > 0){
- let tabMapData = Util.getCurrentMapData(mapId);
-
- if(tabMapData !== false){
- // map data available ->
- activeMapIds.push(mapId);
-
- // check for map data change and update tab
- if(tabMapData.config.updated.updated > tabElement.data('updated')){
- tabElement.updateTabData(tabMapData.config);
+ // hide current map with animation
+ mapElement.visualizeMap('hide', function(){
+ // un-block map tabs
+ mapTabChangeBlocked = switchTabCallback(mapElement, tabLinkElement);
+ });
}
}else{
- // map data not available -> remove tab
- let deletedTabName = tabMapElement.deleteTab(mapId);
-
- tabsChanged = true;
-
- if(deletedTabName.length > 0){
- Util.showNotify({title: 'Map removed', text: deletedTabName + ' deleted', type: 'warning'});
- }
+ tabLinkElement.tab('show');
}
}
- }
-
- // add new tabs for new maps
- $.each(tempMapData, function(i, data){
- if( activeMapIds.indexOf( data.config.id ) === -1 ){
- // add new map tab
-
- let newTabElements = tabMapElement.addTab(data.config);
-
- // check if there is any active map yet (this is not the case
- // when ALL maps are removed AND new maps are added in one call
- // e.g. character switch)
- if(tabMapElement.find('.' + config.mapTabClass + '.active:not(.pull-right)').length === 0){
- tabMapElement.find('.' + config.mapTabClass + ':not(.pull-right):first a').tab('show');
-
- activeMapId = data.config.id;
- }
-
- // set observer for manually triggered map events
- newTabElements.contentElement.setTabContentObserver();
-
- // load all the structure elements for the new tab
- initContentStructure(newTabElements.contentElement);
-
- tabsChanged = true;
-
- Util.showNotify({title: 'Map added', text: data.config.name + ' added', type: 'success'});
- }
});
- // get current active map
- if(activeMapId === 0){
- activeMapId = Util.getMapModule().getActiveMap().data('id');
- }
- let activeMapData = Util.getCurrentMapData(activeMapId);
-
- if(activeMapData !== false){
- // update active map with new mapData
- let currentTabContentElement = $('#' + config.mapTabIdPrefix + activeMapId);
-
- $( currentTabContentElement).loadMap( activeMapData, {} );
- }
- }else{
- // create Tab Element
- tabsChanged = true;
-
- let options = {
- barId: config.mapTabBarId
- };
-
- tabMapElement = getTabElement(options);
-
- // add new tab for each map
- for(let j = 0; j < tempMapData.length; j++){
- let data = tempMapData[j];
- tabMapElement.addTab(data.config);
- }
-
- // add "add" button
- let tabAddOptions = {
- id: 0,
- type: {
- classTab: MapUtil.getInfoForMap( 'standard', 'classTab')
- },
- icon: 'fa-plus',
- name: 'add',
- right: true
- };
-
- tabMapElement.addTab(tabAddOptions);
-
- mapModuleElement.prepend(tabMapElement);
-
- let currentUserData = Util.getCurrentUserData();
- let promiseStore = MapUtil.getLocaleData('character', currentUserData.character.id);
-
- promiseStore.then(function(data) {
- // array key where map data is available (0 == first map found)
- let mapDataIndex = 0;
- // tab dom selector
- let mapKeyTabSelector = 'first';
-
- if(
- data &&
- data.defaultMapId
- ){
- mapDataIndex = Util.getCurrentMapDataIndex(data.defaultMapId);
- mapKeyTabSelector = 'nth-child(' + ( mapDataIndex + 1 ) + ')';
- }
-
- // ----------------------------------------------------------------------------------------------------
-
- // this new created module
- let tabContentElements = tabMapElement.find('.' + config.mapTabContentClass);
-
- // set observer for manually triggered map events
- tabContentElements.setTabContentObserver();
-
- // load all the structure elements for ALL Tab Content Body
- initContentStructure(tabContentElements);
-
- // set first Tab active
- tabMapElement.find('.' + config.mapTabClass + ':' + mapKeyTabSelector + ' a').tab('show');
- });
-
- }
-
- if(tabsChanged === true){
-
- // remove previous event handlers
- let allTabElements = mapModuleElement.getMapTabElements();
- allTabElements.off('show.bs.tab');
- allTabElements.off('shown.bs.tab');
- allTabElements.off('hide.bs.tab');
-
-
- // check for "new map" action before tap-change
- allTabElements.on('show.bs.tab', function (e) {
+ // tab switch --------------------------------------------------------------------------------------------
+ $(tabListElement).on('show.bs.tab', 'a', function(e){
let mapId = $(e.target).data('map-id');
if(mapId > 0){
// save mapId as new "default" (local storage)
- let userData = MapUtil.storeDefaultMapId(mapId);
+ MapUtil.storeDefaultMapId(mapId);
}else{
// add new Tab selected
$(document).trigger('pf:menuShowMapSettings', {tab: 'new'});
e.preventDefault();
}
+
});
- // load new map right after tab-change
- allTabElements.on('shown.bs.tab', function (e) {
+ $(tabListElement).on('shown.bs.tab', 'a', function(e){
+ // load new map right after tab-change
let mapId = $(e.target).data('map-id');
let tabMapData = Util.getCurrentMapData(mapId);
if(tabMapData !== false){
// load map
let currentTabContentElement = $('#' + config.mapTabIdPrefix + mapId);
-
- $( currentTabContentElement).loadMap( tabMapData, {showAnimation: true} );
+ currentTabContentElement.loadMap( tabMapData, {showAnimation: true} );
// "wake up" scrollbar for map and get previous state back
let scrollableElement = currentTabContentElement.find('.' + config.mapWrapperClass);
- $(scrollableElement).mCustomScrollbar( 'update');
- }else{
- // no map data found -> remove tab
- tabMapElement.deleteTab(mapId);
+ $(scrollableElement).mCustomScrollbar('update');
}
});
- allTabElements.on('hide.bs.tab', function (e) {
+ $(tabListElement).on('hide.bs.tab', 'a', function(e){
let newMapId = $(e.relatedTarget).data('map-id');
let oldMapId = $(e.target).data('map-id');
@@ -972,14 +642,483 @@ define([
let scrollableElement = currentTabContentElement.find('.' + config.mapWrapperClass);
$(scrollableElement).mCustomScrollbar( 'disable' );
}
+
});
+
+ });
+ };
+
+ /**
+ * set data for a map tab, or update an existing map tab with new data return promise
+ * @param tabElement
+ * @param options
+ * @returns {Promise
}
+ */
+ let updateTabData = (tabElement, options) => {
+
+ /**
+ * update tab promise
+ * @param resolve
+ * @param reject
+ */
+ let updateTabExecutor = (resolve, reject) => {
+ // set "main" data
+ tabElement.data('map-id', options.id);
+
+ // add updated timestamp (not available for "add" tab
+ if(Util.getObjVal(options, 'updated.updated')){
+ tabElement.data('updated', options.updated.updated);
+ }
+
+ // change "tab" link
+ tabElement.attr('href', '#' + config.mapTabIdPrefix + options.id);
+
+ // change "map" icon
+ let mapIconElement = tabElement.find('.' + config.mapTabIconClass);
+ mapIconElement.removeClass().addClass([config.mapTabIconClass, 'fa', 'fa-fw', options.icon].join(' '));
+
+ // change "shared" icon
+ let mapSharedIconElement = tabElement.find('.' + config.mapTabSharedIconClass);
+ mapSharedIconElement.hide();
+
+ // check if the map is a "shared" map
+ if(options.access){
+ if(
+ options.access.character.length > 1 ||
+ options.access.corporation.length > 1 ||
+ options.access.alliance.length > 1
+ ){
+ mapSharedIconElement.show();
+ }
+ }
+
+ // change map name label
+ let tabLinkTextElement = tabElement.find('.' + config.mapTabLinkTextClass);
+ tabLinkTextElement.text(options.name);
+
+ // change tabClass
+ let listElement = tabElement.parent();
+
+ // new tab classes
+ let tabClasses = [config.mapTabClass, options.type.classTab ];
+
+ // check if tab was "active" before
+ if( listElement.hasClass('active') ){
+ tabClasses.push('active');
+ }
+ listElement.removeClass().addClass( tabClasses.join(' ') );
+
+ // set title for tooltip
+ if(options.type.name !== undefined){
+ tabLinkTextElement.attr('title', options.type.name + ' map');
+ }
+
+ let mapTooltipOptions = {
+ placement: 'bottom',
+ container: 'body',
+ trigger: 'hover',
+ delay: 150
+ };
+
+ listElement.find('[title]').tooltip(mapTooltipOptions).tooltip('fixTitle');
+
+ if(options.right === true){
+ listElement.addClass('pull-right');
+ }
+
+ resolve({
+ action: 'update',
+ data: {
+ mapId: options.id,
+ mapName: options.name
+ }
+ });
+ };
+
+ return new Promise(updateTabExecutor);
+ };
+
+ /**
+ * add a new tab to tab-map-module end return promise
+ * @param tabElement
+ * @param options
+ * @param currentUserData
+ * @returns {Promise}
+ */
+ let addTab = (tabElement, options, currentUserData) => {
+
+ /**
+ * get new element used as map tab
+ * @param options
+ * @returns {jQuery|*|void}
+ */
+ let getTabListElement = (options) => {
+ let listElement = $('')
+ .attr('role', 'presentation')
+ .attr('data-mapId', options.id);
+
+ if(options.right === true){
+ listElement.addClass('pull-right');
+ }
+
+ // link element
+ let linkElement = $('').attr('role', 'tab');
+
+ // map drag handler element
+ let linkDragElement = null;
+ if(options.id > 0){
+ linkDragElement = $('', {
+ class: config.mapTabDragHandlerClass
+ });
+ }
+
+ // map icon element
+ let mapIconElement = $('', {
+ class: config.mapTabIconClass
+ });
+
+ // map shared icon element
+ let mapSharedIconElement = $('', {
+ class: [config.mapTabSharedIconClass, 'fa', 'fa-fw', 'fa-share-alt'].join(' '),
+ title: 'shared map'
+ });
+
+ // text element
+ let textElement = $('', {
+ class: config.mapTabLinkTextClass
+ });
+
+ let newListElement = listElement.append(
+ linkElement.append(linkDragElement).append(mapIconElement)
+ .append(textElement).append(mapSharedIconElement)
+ );
+
+ return newListElement;
+ };
+
+ /**
+ * get tab content element
+ * @param options
+ * @returns {jQuery}
+ */
+ let getTabContentElement = (options) => {
+ let contentElement = $('', {
+ id: config.mapTabIdPrefix + parseInt( options.id ),
+ class: [config.mapTabContentClass, 'tab-pane'].join(' ')
+ }).attr('data-mapid', parseInt( options.id ));
+
+ return contentElement;
+ };
+
+ /**
+ * add tab promise
+ * @param resolve
+ * @param reject
+ */
+ let addTabExecutor = (resolve, reject) => {
+ let promiseStore = MapUtil.getLocaleData('character', currentUserData.character.id);
+ promiseStore.then( function(dataStore){
+ let tabBar = this.tabElement.find('> ul.nav-tabs');
+ let tabContent = this.tabElement.find('> div.tab-content');
+ let tabListElement = getTabListElement(options);
+ let tabContentElement = getTabContentElement(options);
+ let defaultPosition = 0;
+
+ // check for stored map tab order in indexDB (client) -------------------------------------------------
+ let key = 'maps_list_' + tabBar.attr('data-position');
+ if(dataStore && dataStore[key]){
+ let positionIndex = dataStore[key].indexOf(this.options.id);
+ if (positionIndex !== -1) {
+ // first index (0) => is position 1
+ defaultPosition = positionIndex + 1;
+ }
+ }
+
+ // find correct position for new tabs -----------------------------------------------------------------
+ let position = getModulePosition(tabBar, defaultPosition);
+ tabListElement.attr('data-position', defaultPosition);
+
+ console.log('mapId: '+ this.options.id, 'defaultPosition: ' + defaultPosition, 'position: ' + position);
+
+ // insert at correct position -------------------------------------------------------------------------
+ let prevListElement = tabBar.find('li' + '' + ':nth-child(' + position + ')');
+ if (prevListElement.length) {
+ tabListElement.insertAfter(prevListElement);
+ } else {
+ tabBar.prepend(tabListElement);
+ }
+
+ // update Tab element -> set data
+ updateTabData(tabListElement.find('a'), options);
+
+ tabContent.append(tabContentElement);
+
+ // load all the structure elements for the new tab
+ initContentStructure(tabContentElement);
+
+ resolve({
+ action: 'add',
+ data: {
+ mapId: options.id,
+ mapName: options.name
+ }
+ });
+ }.bind({
+ tabElement: tabElement,
+ options: options
+ }));
+ };
+
+ return new Promise(addTabExecutor);
+ };
+
+ /**
+ * deletes tab from tab-map-module end return promise
+ * @param tabElement
+ * @param mapId
+ * @returns {Promise
}
+ */
+ let deleteTab = (tabElement, mapId) => {
+
+ /**
+ * delete tab promise
+ * @param resolve
+ * @param reject
+ */
+ let deleteTabExecutor = (resolve, reject) => {
+ let linkElement = tabElement.find('a[href="#' + config.mapTabIdPrefix + mapId + '"]');
+ let deletedTabName = '';
+
+ if(linkElement.length > 0){
+ deletedTabName = linkElement.find('.' + config.mapTabLinkTextClass).text();
+
+ let liElement = linkElement.parent();
+ let contentElement = tabElement.find('div[id="' + config.mapTabIdPrefix + mapId + '"]');
+
+ liElement.remove();
+ contentElement.remove();
+
+ // remove map instance from local cache
+ Map.clearMapInstance(mapId);
+ }
+
+ resolve({
+ action: 'delete',
+ data: {
+ mapId: mapId,
+ mapName: deletedTabName
+ }
+ });
+ };
+
+ return new Promise(deleteTabExecutor);
+ };
+
+ /**
+ * clear all active maps
+ * @param mapModuleElement
+ * @returns {Promise}
+ */
+ let clearMapModule = (mapModuleElement) => {
+ let promiseDeleteTab = [];
+ let tabMapElement = $('#' + config.mapTabElementId);
+
+ if(tabMapElement.length > 0){
+ let tabElements = mapModuleElement.getMapTabElements();
+ for(let i = 0; i < tabElements.length; i++){
+ let tabElement = $(tabElements[i]);
+ let mapId = tabElement.data('map-id');
+ if(mapId > 0){
+ promiseDeleteTab.push(deleteTab(tabMapElement, mapId));
+ }
+ }
}
- // log client map update time
- let duration = Util.timeStop(logKeyClientMapData);
- Util.log(logKeyClientMapData, {duration: duration, type: 'client', description: 'update map'});
+ return Promise.all(promiseDeleteTab);
+ };
- return true;
+ /**
+ * set "default" map tab
+ * -> default mapId might be available in local storage
+ * @param tabMapElement
+ * @param currentUserData
+ * @returns {Promise}
+ */
+ let showDefaultTab = (tabMapElement, currentUserData) => {
+
+ /**
+ * show default tab promise
+ * @param resolve
+ * @param reject
+ */
+ let showDefaultTabExecutor = (resolve, reject) => {
+ let promiseStore = MapUtil.getLocaleData('character', currentUserData.character.id);
+ promiseStore.then((data) => {
+ let activeTabLinkElement = false;
+
+ if(data && data.defaultMapId){
+ // make specific map tab active
+ activeTabLinkElement = tabMapElement.find('.' + config.mapTabClass + '[data-mapid="' + data.defaultMapId + '"] > a');
+ }
+
+ if(!activeTabLinkElement || !activeTabLinkElement.length){
+ // make first map tab active (default)
+ activeTabLinkElement = tabMapElement.find('.' + config.mapTabClass + ':not(.pull-right):first > a');
+ }
+
+ if(activeTabLinkElement.length){
+ activeTabLinkElement.tab('show');
+ }
+
+ resolve();
+ });
+ };
+
+ return new Promise(showDefaultTabExecutor);
+ };
+
+ /**
+ * load/update map module into element (all maps)
+ * @param mapModuleElement
+ * @returns {Promise}
+ */
+ let updateMapModule = (mapModuleElement) => {
+ // performance logging (time measurement)
+ let logKeyClientMapData = Init.performanceLogging.keyClientMapData;
+ Util.timeStart(logKeyClientMapData);
+
+ let updateMapModuleExecutor = (resolve, reject) => {
+ // check if tabs module is already loaded
+ let tabMapElement = $('#' + config.mapTabElementId);
+
+ let currentUserData = Util.getCurrentUserData();
+
+ // store current map data global (cache)
+ // temp store current map data to prevent data-change while function execution!
+ let tempMapData = Util.getCurrentMapData();
+
+ if(tempMapData.length === 0){
+ // clear all existing maps ----------------------------------------------------------------------------
+ clearMapModule(mapModuleElement)
+ .then((payload) => {
+ // no map data available -> show "new map" dialog
+ $(document).trigger('pf:menuShowMapSettings', {tab: 'new'});
+ })
+ .then((payload) => resolve());
+ }else{
+ if(tabMapElement.length > 0){
+ // tab element exists -> update -------------------------------------------------------------------
+ let promisesAddTab = [];
+ let promiseDeleteTab = [];
+ let promiseUpdateTab = [];
+
+ let tabDeletedCallback = (payload) => {
+ Util.showNotify({title: 'Map removed', text: payload.data.mapName + ' deleted', type: 'warning'});
+ };
+
+ let tabAddCallback = (payload) => {
+ Util.showNotify({title: 'Map added', text: payload.data.mapName + ' added', type: 'success'});
+ };
+
+ // tab element already exists
+ let tabElements = mapModuleElement.getMapTabElements();
+
+ // mapIds that are currently active
+ let activeMapIds = [];
+
+ // check whether a tab/map is still active
+ for(let i = 0; i < tabElements.length; i++){
+ let tabElement = $(tabElements[i]);
+ let mapId = tabElement.data('map-id');
+
+ if(mapId > 0){
+ let tabMapData = Util.getCurrentMapData(mapId);
+ if(tabMapData !== false){
+ // map data available ->
+ activeMapIds.push(mapId);
+
+ // check for map data change and update tab
+ if(tabMapData.config.updated.updated > tabElement.data('updated')){
+ promiseUpdateTab.push(updateTabData(tabElement, tabMapData.config));
+ }
+ }else{
+ // map data not available -> remove tab
+ promiseDeleteTab.push(deleteTab(tabMapElement, mapId).then(tabDeletedCallback));
+ }
+ }
+ }
+
+ // add new tabs for new maps
+ for(let data of tempMapData) {
+ if( activeMapIds.indexOf( data.config.id ) === -1 ){
+ // add new map tab
+ promisesAddTab.push(addTab(tabMapElement, data.config, currentUserData).then(tabAddCallback));
+ }
+ }
+
+ // wait until ALL "add", "delete", "update" promises are fulfilled
+ let promisesAll = promisesAddTab.concat(promiseDeleteTab, promiseUpdateTab);
+
+ Promise.all(promisesAll).then((payload) => {
+ // if there is an active map ...
+ let activeMap = Util.getMapModule().getActiveMap();
+ if(activeMap){
+ let activeMapId = activeMap.data('id');
+ let activeMapData = Util.getCurrentMapData(activeMapId);
+ if(activeMapData !== false){
+ // .. active map found, just update no tab switch
+ $('#' + config.mapTabIdPrefix + activeMapId).loadMap( activeMapData, {} );
+ }
+ return new Promise(resolve => resolve()); // fake promise returned
+ }else{
+ // .. no map active, make one active
+ return showDefaultTab(tabMapElement, currentUserData);
+ }
+ }).then((payload) => resolve());
+
+ }else{
+ // tab Element does not exists -> create ----------------------------------------------------------
+ let promisesAddTab = [];
+
+ let options = {
+ barId: config.mapTabBarId,
+ position: 1 // for "sortable tabs"
+ };
+
+ tabMapElement = getMapTabElement(options, currentUserData);
+ mapModuleElement.prepend(tabMapElement);
+
+ // add new tab for each map
+ for(let j = 0; j < tempMapData.length; j++){
+ let data = tempMapData[j];
+ promisesAddTab.push(addTab(tabMapElement, data.config, currentUserData)) ;
+ }
+
+ // add "add" button
+ let tabAddOptions = {
+ id: 0,
+ type: {
+ classTab: MapUtil.getInfoForMap( 'standard', 'classTab')
+ },
+ icon: 'fa-plus',
+ name: 'add',
+ right: true
+ };
+
+ promisesAddTab.push(addTab(tabMapElement, tabAddOptions, currentUserData));
+
+ Promise.all(promisesAddTab)
+ .then((payload) => showDefaultTab(tabMapElement, currentUserData))
+ .then((payload) => resolve());
+ }
+ }
+ };
+
+ return new Promise(updateMapModuleExecutor).then((payload) => {
+ // log client map update time
+ let duration = Util.timeStop(logKeyClientMapData);
+ Util.log(logKeyClientMapData, {duration: duration, type: 'client', description: 'update map'});
+ });
};
/**
@@ -1010,4 +1149,8 @@ define([
return data;
};
+ return {
+ updateTabData: updateTabData,
+ updateMapModule: updateMapModule
+ };
});
\ No newline at end of file
diff --git a/public/js/v1.3.2/app/ui/dialog/map_settings.js b/public/js/v1.3.2/app/ui/dialog/map_settings.js
index ba65c6c0..4b5d3c4d 100644
--- a/public/js/v1.3.2/app/ui/dialog/map_settings.js
+++ b/public/js/v1.3.2/app/ui/dialog/map_settings.js
@@ -8,8 +8,9 @@ define([
'app/util',
'app/render',
'bootbox',
- 'app/map/util'
-], function($, Init, Util, Render, bootbox, MapUtil) {
+ 'app/map/util',
+ 'app/module_map'
+], function($, Init, Util, Render, bootbox, MapUtil, ModuleMap) {
'use strict';
let config = {
@@ -382,7 +383,7 @@ define([
let tabLinkElement = Util.getMapModule().getMapTabElements(responseData.mapData.mapData.id);
if(tabLinkElement.length === 1){
- tabLinkElement.updateTabData(responseData.mapData.mapData);
+ ModuleMap.updateTabData(tabLinkElement, responseData.mapData.mapData);
}
$(mapInfoDialog).modal('hide');
diff --git a/sass/_main.scss b/sass/_main.scss
index 4acd15ec..0b8810a0 100644
--- a/sass/_main.scss
+++ b/sass/_main.scss
@@ -1008,12 +1008,13 @@ input[type="email"]{
}
.nav-tabs>li>a {
- color: $gray-lighter;
+ color: $gray-light;
+ //color: $gray-lighter;
font-family: $font-family-bold;
&:hover{
- color: $gray-darkest;
- border-color: transparent transparent $gray-lighter transparent;
+ color: $gray-lighter;
+ border-color: transparent transparent $gray-light transparent;
margin-top: 1px;
border-top-width: 0;
}
@@ -1021,7 +1022,7 @@ input[type="email"]{
.nav-tabs > li.active > a {
background-color: $gray-lighter;
- color: $gray-darker;
+ color: $gray-darkest;
border-top-width: 0px !important;
margin-top: 1px !important;
font-weight:bold;
diff --git a/sass/_variables.scss b/sass/_variables.scss
index 5b677c2f..874c67f1 100644
--- a/sass/_variables.scss
+++ b/sass/_variables.scss
@@ -392,7 +392,7 @@ $navbar-inverse-toggle-border-color: #333;
//=== Shared nav styles
$nav-link-padding: 5px 6px 5px;
-$nav-link-hover-bg: $gray-light;
+$nav-link-hover-bg: $gray;
$nav-disabled-link-color: $gray-light;
$nav-disabled-link-hover-color: $gray-light;
diff --git a/sass/layout/_main.scss b/sass/layout/_main.scss
index be23414d..5988fb4c 100644
--- a/sass/layout/_main.scss
+++ b/sass/layout/_main.scss
@@ -19,7 +19,7 @@ a, .pf-link{
will-change: color;
text-decoration: none;
cursor: pointer;
- @include transition( color 0.08s ease-out );
+ @include transition( color 0.08s ease-out, background-color 0.08s ease-out );
&:hover{
color: $teal-lightest;
@@ -506,6 +506,26 @@ table{
// Tabs (colored)
#pf-map-tabs {
+ a[role="tab"]:hover{
+ .pf-map-tab-handler:before{
+ color: $orange
+ }
+ }
+
+ .pf-map-tab-handler{
+ &:before{
+ content: '\22EE\22EE\00A0';
+ display: inline-block;
+ cursor: -moz-grab !important;
+ cursor: -webkit-grab !important;
+ cursor: grab !important;
+ color: $gray-light;
+ width: 12px;
+ transition: color 0.15s ease-out, background-color 0.15s ease-out;
+ pointer-events: all;
+ }
+ }
+
.pf-map-type-tab-default{
border-top: 2px solid transparent;
}
@@ -527,11 +547,11 @@ table{
}
.pf-map-tab-icon{
- margin-right: 5px;
+ margin-right: 3px;
}
.pf-map-tab-shared-icon{
- margin-left: 5px;
+ margin-left: 3px;
}
}
}