alliance/corp maps. build process optimization, new/edit map dialog fixes

This commit is contained in:
exodus4d
2015-05-20 20:32:15 +02:00
parent e2945ea058
commit 34e41a6553
80 changed files with 3692 additions and 2182 deletions

View File

@@ -1,32 +0,0 @@
/**
* Client
*/
define(["jquery"], function($) {
"use strict";
// client object
function Client(){}
var getClient = function(){
var headerData = getHeaderData();
};
// private functions ========================================================
var getHeaderData = function(){
console.log('TERST');
$.ajax({
url: 'http://localhost/exodus4d/pathfinder/',
headers:{'foo':'bar'},
complete: function() {
alert(this.headers.foo);
}
});
};
return {
getClient: getClient
};
});

View File

@@ -11,7 +11,7 @@ define([
'app/ui/header',
'app/ui/logo',
'app/ui/demo_map',
'dialog/settings',
'dialog/settings'
], function($, Init, Util, Gallery) {
'use strict';
@@ -144,7 +144,8 @@ define([
var options = {
index: link,
event: e,
container: '#' + config.galleryId
container: '#' + config.galleryId,
titleProperty: 'description'
};

View File

@@ -62,7 +62,9 @@ define([
});
/**
* main function for init all map relevant trigger calls
*/
$.fn.initMapModule = function(){
var mapModule = $(this);
@@ -112,7 +114,7 @@ define([
if(mapData.length === 0){
// no map data available -> show "new map" dialog
$(document).trigger('pf:menuEditMap', {newMap: true});
$(document).trigger('pf:menuShowMapSettings');
}else{
// map data found

View File

@@ -9,7 +9,6 @@ define([
'customScrollbar',
'dragToSelect',
'select2',
'hoverIntent',
'app/map/contextmenu'
], function($, Init, Util, Render, bootbox, CCP) {
@@ -3065,8 +3064,6 @@ define([
setConnectionWHStatus(connection, 'wh_fresh');
}
var sourceSystem = $('#' + info.sourceId);
// prevent multiple connections between same systems ----------------------------
var connections = checkForConnection(newJsPlumbInstance, info.sourceId, info.targetId );
@@ -3083,7 +3080,6 @@ define([
// -----------------------------------------------------------------------------
return true;
});
// event before Detach connection

View File

@@ -214,16 +214,19 @@ define([
// get user data for each active map
var mapUserData = null;
for(var j = 0; j < mapModuleData.mapUserData.length; j++){
if(mapModuleData.mapUserData){
for(var j = 0; j < mapModuleData.mapUserData.length; j++){
var tempMapUserData = mapModuleData.mapUserData[j];
if(tempMapUserData.config.id === mapId){
// map userData found
mapUserData = tempMapUserData;
break;
var tempMapUserData = mapModuleData.mapUserData[j];
if(tempMapUserData.config.id === mapId){
// map userData found
mapUserData = tempMapUserData;
break;
}
}
}
// update map with current user data
if(mapUserData){
mapElement.updateUserData(mapUserData);
@@ -313,18 +316,23 @@ define([
// change tabClass
var listElement = tabElement.parent();
listElement.removeClass().addClass([config.mapTabClass, options.type.classTab ].join(' '));
// set title for tooltip
if(options.type.name !== undefined){
listElement.attr('title', options.type.name + ' map');
if(options.type.name !== undefined){ console.log(options.type.name)
listElement.tooltip('destroy');
var mapTooltipOptions = {
toggle: 'tooltip',
placement: 'bottom',
container: 'body',
title: options.type.name + ' map',
trigger: 'hover',
delay: 200
};
listElement.tooltip(mapTooltipOptions);
$(listElement).tooltip(mapTooltipOptions);
}
if(options.right === true){
@@ -668,7 +676,7 @@ define([
if(mapId === 0){
// add new Tab selected
$(document).trigger('pf:menuEditMap', {newMap: true});
$(document).trigger('pf:menuShowMapSettings');
e.preventDefault();
}
});

View File

@@ -7,8 +7,7 @@ define([
'pnotify.nonblock',
'pnotify.desktop',
//'pnotify.history',
'pnotify.callbacks',
//'pnotify.reference'
'pnotify.callbacks'
], function($, Init, PNotify) {
'use strict';

View File

@@ -14,7 +14,7 @@ define([
'dialog/map_info',
'dialog/settings',
'dialog/manual',
'dialog/map',
'dialog/map_settings',
'dialog/system_effects',
'dialog/jump_info',
'dialog/credit',
@@ -150,7 +150,7 @@ define([
href: '#'
}).html('&nbsp;&nbsp;Effect info').prepend(
$('<i>',{
class: 'fa fa-cogs fa-fw'
class: 'fa fa-crosshairs fa-fw'
})
).on('click', function(){
$(document).triggerMenuEvent('ShowSystemEffectInfo');
@@ -247,12 +247,12 @@ define([
$('<a>', {
class: 'list-group-item',
href: '#'
}).html('&nbsp;&nbsp;Edit').prepend(
}).html('&nbsp;&nbsp;Settings').prepend(
$('<i>',{
class: 'fa fa-edit fa-fw'
class: 'fa fa-gears fa-fw'
})
).on('click', function(){
$(document).triggerMenuEvent('EditMap', {newMap: false});
$(document).triggerMenuEvent('ShowMapSettings', {newMap: false});
})
).append(
$('<a>', {
@@ -454,19 +454,17 @@ define([
return false;
});
$(document).on('pf:menuEditMap', function(e, data){
$(document).on('pf:menuShowMapSettings', function(e){
// show map edit dialog or edit map
var mapData = false;
if(data.newMap === false){
var activeMap = Util.getMapModule().getActiveMap();
var activeMap = Util.getMapModule().getActiveMap();
if(activeMap){
mapData = activeMap.getMapData(true);
}
if(activeMap){
mapData = activeMap.getMapData(true);
}
$.fn.showNewMapDialog(mapData);
$.fn.showMapSettingsDialog(mapData);
return false;
});

View File

@@ -35,12 +35,14 @@ define([
pieChartClass : Init.classes.pieChart.pieChartMapCounterClass,
mapCounterClass : Init.classes.pieChart.pieChartMapCounterClass,
mapTypeGlobalClass: Util.getInfoForMap( 'global', 'class'),
mapTypeGlobalLabel: Util.getInfoForMap( 'global', 'label'),
mapTypePrivateClass: Util.getInfoForMap( 'private', 'class'),
mapTypePrivateLabel: Util.getInfoForMap( 'private', 'label'),
mapTypeCorporationClass: Util.getInfoForMap( 'corporation', 'class'),
mapTypeCorporationLabel: Util.getInfoForMap( 'corporation', 'label'),
mapTypeAllianceClass: Util.getInfoForMap( 'alliance', 'class'),
mapTypeAllianceLabel: Util.getInfoForMap( 'alliance', 'label'),
mapTypePrivateClass: Util.getInfoForMap( 'private', 'class'),
mapTypePrivateLabel: Util.getInfoForMap( 'private', 'label')
mapTypeGlobalClass: Util.getInfoForMap( 'global', 'class'),
mapTypeGlobalLabel: Util.getInfoForMap( 'global', 'label')
};

View File

@@ -1,144 +0,0 @@
/**
* map module dialogs
*/
define([
'jquery',
'app/init',
'app/util',
'app/render',
'bootbox',
], function($, Init, Util, Render, bootbox) {
'use strict';
var config = {
// map dialog
newMapDialogId: 'pf-map-new-dialog' // id for edit/update map dialog
};
/**
* shows the add/edit map dialog
* @param mapData
*/
$.fn.showNewMapDialog = function(mapData){
var formData = {};
// check if dialog is already open
var mapInfoDialogElement = $('#' + config.newMapDialogId);
if(!mapInfoDialogElement.is(':visible')){
requirejs(['text!templates/dialog/map.html', 'mustache'], function(template, Mustache) {
var data = {
id: config.newMapDialogId,
scope: Util.getMapScopes(),
type: Util.getMapTypes(),
icon: Util.getMapIcons(),
formData: formData
};
var content = Mustache.render(template, data);
var dialogTitle = 'Create new map';
var dialogSaveButton = 'add map';
if(mapData !== false){
dialogTitle = 'Edit map';
dialogSaveButton = 'save map';
content = $(content);
content.find('input[name="id"]').val( mapData.config.id );
content.find('select[name="icon"]').val( mapData.config.icon );
content.find('input[name="name"]').val( mapData.config.name );
content.find('select[name="scopeId"]').val( mapData.config.scope.id );
content.find('select[name="typeId"]').val( mapData.config.type.id );
}
var mapInfoDialog = bootbox.dialog({
title: dialogTitle,
message: content,
buttons: {
close: {
label: 'cancel',
className: 'btn-default'
},
success: {
label: '<i class="fa fa-code-fork fa-fw"></i>' + dialogSaveButton,
className: 'btn-primary',
callback: function() {
// get form Values
var form = $('#' + config.newMapDialogId).find('form');
// validate form
form.validator('validate');
// check weather the form is valid
var formValid = form.isValidForm();
if(formValid === true){
var newMapData = {mapData: form.getFormValues()};
$.ajax({
type: 'POST',
url: Init.path.saveMap,
data: newMapData,
dataType: 'json'
}).done(function(data){
Util.showNotify({title: dialogTitle, text: 'Map: ' + data.name, type: 'success'});
$(mapInfoDialog).modal('hide');
$(document).trigger('pf:closeMenu', [{}]);
}).fail(function( jqXHR, status, error) {
var reason = status + ' ' + error;
Util.showNotify({title: jqXHR.status + ': saveMap', text: reason, type: 'warning'});
$(document).setProgramStatus('problem');
});
}
return false;
}
}
}
});
});
}
};
/**
* shows the delete map Dialog
* @param mapElement
*/
$.fn.showDeleteMapDialog = function(mapData){
var mapName = mapData.config.name;
var mapDeleteDialog = bootbox.confirm('Delete map "' + mapName + '"?', function(result){
if(result){
var data = {mapData: mapData.config};
$.ajax({
type: 'POST',
url: Init.path.deleteMap,
data: data,
dataType: 'json'
}).done(function(data){
Util.showNotify({title: 'Map deleted', text: 'Map: ' + mapName, type: 'success'});
$(mapDeleteDialog).modal('hide');
}).fail(function( jqXHR, status, error) {
var reason = status + ' ' + error;
Util.showNotify({title: jqXHR.status + ': deleteMap', text: reason, type: 'warning'});
$(document).setProgramStatus('problem');
});
return false;
}
});
};
});

View File

@@ -0,0 +1,196 @@
/**
* map settings dialogs
*/
define([
'jquery',
'app/init',
'app/util',
'app/render',
'bootbox',
], function($, Init, Util, Render, bootbox) {
'use strict';
var config = {
// map dialog
newMapDialogId: 'pf-map-new-dialog', // id for edit/update map dialog
dialogMapCreateContainerId: 'pf-map-dialog-create', // id for the "new map" container
dialogMapEditContainerId: 'pf-map-dialog-edit', // id for the "edit" container
dialogMapSettingsContainerId: 'pf-map-dialog-settings', // id for the "settings" container
dialogMessageContainerId: 'pf-map-dialog-message-container' // id for dialog form message container
};
/**
* shows the add/edit map dialog
* @param mapData
*/
$.fn.showMapSettingsDialog = function(mapData){
// check if dialog is already open
var mapInfoDialogElement = $('#' + config.newMapDialogId);
if(!mapInfoDialogElement.is(':visible')){
requirejs([
'text!templates/dialog/map.html',
'text!templates/form/map_settings.html',
'mustache'
], function(templateMapDialog, templateMapSettings, Mustache) {
var dialogTitle = 'Map settings';
// if there are no maps -> hide settings tab
var hideSettingsTab = false;
var hideEditTab = false;
if(mapData === false){
hideSettingsTab = true;
hideEditTab = true;
}
var data = {
scope: Util.getMapScopes(),
type: Util.getMapTypes(true),
icon: Util.getMapIcons()
};
// render "new map" tab content -------------------------------------------
var contentNewMap = Mustache.render(templateMapSettings, data);
// render "edit map" tab content ------------------------------------------
var contentEditMap = Mustache.render(templateMapSettings, data);
contentEditMap = $(contentEditMap);
if(mapData !== false){
contentEditMap.find('input[name="id"]').val( mapData.config.id );
contentEditMap.find('select[name="icon"]').val( mapData.config.icon );
contentEditMap.find('input[name="name"]').val( mapData.config.name );
contentEditMap.find('select[name="scopeId"]').val( mapData.config.scope.id );
contentEditMap.find('select[name="typeId"]').val( mapData.config.type.id );
}
// render main dialog -----------------------------------------------------
data = {
id: config.newMapDialogId,
dialogMapCreateContainerId: config.dialogMapCreateContainerId,
dialogMapEditContainerId: config.dialogMapEditContainerId,
dialogMapSettingsContainerId: config.dialogMapSettingsContainerId,
dialogMessageContainerId: config.dialogMessageContainerId,
hideEditTab: hideEditTab,
hideSettingsTab: hideSettingsTab
};
var contentDialog = Mustache.render(templateMapDialog, data);
contentDialog = $(contentDialog);
// set tab content
$('#' + config.dialogMapCreateContainerId, contentDialog).html(contentNewMap);
$('#' + config.dialogMapEditContainerId, contentDialog).html(contentEditMap);
var mapInfoDialog = bootbox.dialog({
title: dialogTitle,
message: contentDialog,
buttons: {
close: {
label: 'cancel',
className: 'btn-default'
},
success: {
label: '<i class="fa fa-check fa-fw"></i>&nbsp;save',
className: 'btn-success',
callback: function() {
// get the current active form
var form = $('#' + config.newMapDialogId).find('form').filter(':visible');
console.log(form)
// validate form
form.validator('validate');
// check weather the form is valid
var formValid = form.isValidForm();
if(formValid === true){
var newMapData = {mapData: form.getFormValues()};
$.ajax({
type: 'POST',
url: Init.path.saveMap,
data: newMapData,
dataType: 'json'
}).done(function(data){
Util.showNotify({title: dialogTitle, text: 'Map: ' + data.name, type: 'success'});
$(mapInfoDialog).modal('hide');
$(document).trigger('pf:closeMenu', [{}]);
}).fail(function( jqXHR, status, error) {
var reason = status + ' ' + error;
Util.showNotify({title: jqXHR.status + ': saveMap', text: reason, type: 'warning'});
$(document).setProgramStatus('problem');
});
}
return false;
}
}
}
});
// after modal is shown =======================================================================
mapInfoDialog.on('shown.bs.modal', function(e) {
mapInfoDialog.initTooltips();
// set form validator
mapInfoDialog.find('form').validator();
if(mapData === false){
// no map data found (probably new user
$('#' + config.dialogMessageContainerId).showMessage({type: 'warning', title: 'No maps found', text: 'Create a new map before you can start'});
}
});
});
}
};
/**
* shows the delete map Dialog
* @param mapElement
*/
$.fn.showDeleteMapDialog = function(mapData){
var mapName = mapData.config.name;
var mapDeleteDialog = bootbox.confirm('Delete map "' + mapName + '"?', function(result){
if(result){
var data = {mapData: mapData.config};
$.ajax({
type: 'POST',
url: Init.path.deleteMap,
data: data,
dataType: 'json'
}).done(function(data){
Util.showNotify({title: 'Map deleted', text: 'Map: ' + mapName, type: 'success'});
$(mapDeleteDialog).modal('hide');
}).fail(function( jqXHR, status, error) {
var reason = status + ' ' + error;
Util.showNotify({title: jqXHR.status + ': deleteMap', text: reason, type: 'warning'});
$(document).setProgramStatus('problem');
});
return false;
}
});
};
});

View File

@@ -27,8 +27,22 @@ define([
settingsCloneRowButtonClass: 'pf-dialog-clone-button', // class for clone button (api row)
settingsDeleteRowButtonClass: 'pf-dialog-delete-button', // class for delete button (api row)
// form messages
settingsErrorId: 'pf-dialog-error-id', // id for "error" form element
settingsWarningId: 'pf-dialog-warning-id', // id for "warning" form element
settingsMessageVelocityOptions: {
duration: 180
},
// captcha
captchaImageId: 'pf-dialog-captcha-image' // id for "captcha image"
captchaImageWrapperId: 'pf-dialog-captcha-wrapper', // id for "captcha image" wrapper
captchaImageId: 'pf-dialog-captcha-image', // id for "captcha image"
loadingOptions: { // config for loading overlay
icon: {
size: 'fa-2x'
}
}
};
@@ -59,18 +73,173 @@ define([
callback(base64Image);
}).fail(function( jqXHR, status, error) {
console.log(status)
console.log(error)
var reason = status + ' ' + error;
Util.showNotify({title: jqXHR.status + ': saveConfig', text: reason, type: 'warning'});
});
};
/**
* clear a field and reset success/error classes
* @param fieldId
*/
var resetFormField = function(fieldId){
var field = $('#' + fieldId);
field.val('');
field.parents('.form-group').removeClass('has-error has-success');
}
/**
* request captcha image and show in form
*/
var showCaptchaImage = function(){
var captchaWrapper = $('#' + config.captchaImageWrapperId);
var captchaImage = $('#' + config.captchaImageId);
captchaWrapper.showLoadingAnimation(config.loadingOptions);
getCaptchaImage(function(base64Image){
captchaImage.attr('src', base64Image).show();
captchaWrapper.hideLoadingAnimation();
// reset captcha field
resetFormField('captcha');
});
};
/**
* show form messages
* @param errors
*/
var showFormMessage = function(errors){
var errorMessage = [];
var warningMessage = [];
for(var i = 0; i < errors.length; i++){
if(errors[i].type === 'error'){
errorMessage.push( errors[i].message );
}else if(errors[i].type === 'warning'){
warningMessage.push( errors[i].message );
}
}
if(errorMessage.length > 0){
hideFormMessage('error', function(element){
$(element).find('small').text( errorMessage.join('<br>') );
$(element).velocity('transition.slideUpIn', config.settingsMessageVelocityOptions);
});
}
if(warningMessage.length > 0){
hideFormMessage('warning', function(element){
$(element).find('small').text( warningMessage.join('<br>') );
$(element).velocity('transition.slideUpIn', config.settingsMessageVelocityOptions);
});
}
};
/**
* ide all form messages
* @param type
* @param callback
*/
var hideFormMessage = function(type, callback){
var settingsMessageVelocityOptions = $.extend({}, config.settingsMessageVelocityOptions);
// check if callback exists
if(callback !== undefined){
settingsMessageVelocityOptions.complete = callback;
// new error will be shown afterwards -> keep display
settingsMessageVelocityOptions.display = 'block';
}
if(type === 'error'){
var errorMessageElement = $('#' + config.settingsErrorId);
// check if element is visible
if(errorMessageElement.is(':visible')){
errorMessageElement.velocity('transition.slideDownOut', settingsMessageVelocityOptions);
}else if(callback){
// skip hide animation
callback(errorMessageElement);
}
}
if(type === 'warning'){
var warningMessageElement = $('#' + config.settingsWarningId);
// check if element is visible
if(warningMessageElement.is(':visible')){
warningMessageElement.velocity('transition.slideDownOut', settingsMessageVelocityOptions);
}else if(callback){
// skip hide animation
callback(warningMessageElement);
}
}
};
/**
* init popovers in dialog
* @param dialogElement
*/
var initPopover = function(dialogElement){
var apiCloneButtons = dialogElement.find('.' + config.settingsCloneRowButtonClass);
var apiDeleteButtons = dialogElement.find('.' + config.settingsDeleteRowButtonClass);
var confirmationSettings = {
container: 'body',
placement: 'left',
btnCancelClass: 'btn btn-sm btn-default',
btnCancelLabel: 'cancel',
btnCancelIcon: 'fa fa-fw fa-ban'
};
// add API key row
var cloneConfirmationSettings = $.extend({
title: 'Add additional key',
btnOkClass: 'btn btn-sm btn-success',
btnOkLabel: 'confirm',
btnOkIcon: 'fa fa-fw fa-check',
onConfirm: function(e) {
var cloneRow = dialogElement.find('.' + config.settingsCloneApiRowClass).last();
var newApiRow = cloneRow.clone();
newApiRow.find('.form-group').removeClass('has-success has-error')
newApiRow.find('input').val('');
cloneRow.after(newApiRow);
// init new row with popups
initPopover(dialogElement);
}
}, confirmationSettings);
// delete API key row
var deleteConfirmationSettings = $.extend({
title: 'Delete key',
btnOkClass: 'btn btn-sm btn-danger',
btnOkLabel: 'delete',
btnOkIcon: 'fa fa-fw fa-close',
onConfirm: function(e, target) {
$(target).parents('.row').remove();
}
}, confirmationSettings);
$(apiCloneButtons).confirmation(cloneConfirmationSettings);
$(apiDeleteButtons).confirmation(deleteConfirmationSettings);
};
/**
* show "register/settings" dialog
*/
$.fn.showSettingsDialog = function(register){
var reroutePath = '';
// check navigation buttons and show/hide them
var checkNavigationButton = function(dialog){
var navigationBarElement = $(dialog).find('.' + config.dialogWizardNavigationClass);
@@ -92,9 +261,18 @@ define([
}
};
requirejs(['text!templates/dialog/settings.html', 'mustache'], function(template, Mustache) {
// if this is a new registration there is no API key -> fake an empty API to make fields visible
if(register){
Init.currentUserData = {};
Init.currentUserData.api = [{
keyId: '',
vCode: ''
}];
}
var data = {
id: config.settingsDialogId,
register: register,
@@ -102,18 +280,34 @@ define([
userData: Init.currentUserData,
cloneApiRowClass: config.settingsCloneApiRowClass,
cloneRowButtonClass: config.settingsCloneRowButtonClass,
deleteRowButtonClass: config.settingsDeleteRowButtonClass
deleteRowButtonClass: config.settingsDeleteRowButtonClass,
captchaImageWrapperId: config.captchaImageWrapperId,
captchaImageId: config.captchaImageId,
settingsErrorId: config.settingsErrorId,
settingsWarningId: config.settingsWarningId
};
var content = Mustache.render(template, data);
var selectCharacterDialog = bootbox.dialog({
title: register ? 'Register' : 'Account settings',
title: register ? 'Registration' : 'Account settings',
message: content,
buttons: {
close: {
label: 'finish',
className: ['btn-success', 'pull-right', config.settingsFinishButtonClass].join(' ')
className: ['btn-success', 'pull-right', config.settingsFinishButtonClass].join(' '),
callback: function(e){
if(register){
if(reroutePath !== undefined){
// root user to main app
window.location = Util.buildUrl(reroutePath);
}
}else{
// close dialog
return true;
}
}
},
prev: {
label: '<i class="fa fa-fw fa-angle-left"></i>back',
@@ -134,6 +328,7 @@ define([
var currentActiveTab = getActiveTabElement(dialogElement);
var currentActiveLink = currentActiveTab.find('a');
var tabContentElement = $(currentActiveLink.attr('href'));
var form = tabContentElement.find('form');
var changeTab = function(){
currentActiveTab.addClass('finished');
@@ -145,10 +340,10 @@ define([
};
// validate form
var form = tabContentElement.find('form');
form.validator('validate');
var formValid = form.isValidForm();
if(!formValid){
currentActiveTab.removeClass('disabled');
currentActiveLink.removeClass('btn-default btn-primary');
@@ -166,8 +361,6 @@ define([
selectCharacterDialog.find('.modal-content').showLoadingAnimation();
$.ajax({
type: 'POST',
url: Init.path.saveUserConfig,
@@ -175,60 +368,94 @@ define([
dataType: 'json'
}).done(function(responseData){
selectCharacterDialog.find('.modal-content').hideLoadingAnimation();
console.log(responseData)
if(responseData.error){
var errorAlert = form.find('.alert');
for(var i = 0; i < responseData.error.length; i++){
var errorData = responseData.error[i];
if(errorData.type === 'api'){
errorAlert.find('small').text(errorData.message + '. Key ID: ' + errorData.keyId);
}
}
errorAlert.velocity('transition.slideUpIn',{
duration: 500
});
// set new captcha for any request
// captcha is required for sensitive data (not for all data)
if(
responseData.error &&
responseData.error.length > 0
){
showFormMessage(responseData.error);
showCaptchaImage();
}else{
// store new/updated user data -> update head
if(!register){
if(responseData.userData){
Util.setCurrentUserData(responseData.userData);
}
// store reroute path after registration finished
if(responseData.reroute){
reroutePath = responseData.reroute;
}
dialogElement.find('.alert').velocity('transition.slideDownOut',{
duration: 500,
complete: function(){
// switch tab
changeTab();
showCaptchaImage();
}
});
Util.showNotify({title: 'Account data saved', type: 'success'});
}
Util.showNotify({title: 'Account data saved', type: 'success'});
}).fail(function( jqXHR, status, error) {
selectCharacterDialog.find('.modal-content').hideLoadingAnimation();
var reason = status + ' ' + error;
Util.showNotify({title: jqXHR.status + ': saveConfig', text: reason, type: 'warning'});
Util.showNotify({title: jqXHR.status + ': saveConfig', text: reason, type: 'error'});
// set new captcha for any request
// captcha is required for sensitive data (not for all)
showCaptchaImage();
// check for DB errors
if(jqXHR.status === 500){
if(jqXHR.responseText){
var errorObj = $.parseJSON(jqXHR.responseText);
if(errorObj.text !== undefined){
// DB error
if(errorObj.text.match('Duplicate')){
// duplicate DB key
var fieldName = 'name';
if(errorObj.text.match( fieldName )){
// name exist
showFormMessage([{type: 'error', message: 'Username already exists'}]);
resetFormField( fieldName );
}
fieldName = 'email';
if(errorObj.text.match( fieldName )){
// name exist
showFormMessage([{type: 'error', message: 'Email already exists'}]);
resetFormField( fieldName );
resetFormField( fieldName + '_confirm');
}
}
}
}
}
if(!register){
$(document).setProgramStatus('problem');
}
// close dialog
selectCharacterDialog.modal('hide');
});
}else{
// no request required -> change tab
changeTab();
}
}
return false;
}
}
@@ -240,11 +467,30 @@ console.log(responseData)
var dialogElement = $(this);
var tabLinkElements = dialogElement.find('a[data-toggle="tab"]');
var form = dialogElement.find('form');
// request captcha image
getCaptchaImage(function(base64Image){
// request captcha image and show
showCaptchaImage();
$('#' + config.captchaImageId).attr('src', base64Image).show();
// init dialog tooltips
dialogElement.initTooltips();
// init popups
initPopover( dialogElement );
// init form validation
form.validator();
// validation event listener
form.on('valid.bs.validator', function(validatorObj){
var inputGroup = $(validatorObj.relatedTarget).parents('.form-group');
inputGroup.removeClass('has-error').addClass('has-success');
});
form.on('invalid.bs.validator', function(validatorObj){
var field = $(validatorObj.relatedTarget);
var inputGroup = field.parents('.form-group');
inputGroup.removeClass('has-success').addClass('has-error');
});
// on Tab switch ======================================================================
@@ -305,11 +551,13 @@ console.log(responseData)
var content = Mustache.render(template, characterTemplateData);
dialogElement.find('#pf-dialog-settings-character form').html(content);
var characterForm = dialogElement.find('#pf-dialog-settings-character form');
// add form HTML
characterForm.html(content);
var imageWrapperElements = dialogElement.find('.' + config.settingsImageWrapperClass);
// special effects :)
imageWrapperElements.velocity('stop').delay(100).velocity('transition.flipBounceXIn', {
display: 'inline-block',
@@ -317,12 +565,8 @@ console.log(responseData)
drag: true,
duration: 400,
complete: function(){
// init all tooltips
var tooltipElements = dialogElement.find('[title]');
tooltipElements.tooltip({
placement: 'top',
container: dialogElement
});
// init new character tooltips
dialogElement.initTooltips();
}
});
@@ -377,20 +621,6 @@ console.log(responseData)
});
// API Tab ================================================================================
dialogElement.find('.' + config.settingsCloneRowButtonClass).on('click', function(){
var cloneRow = dialogElement.find('.' + config.settingsCloneApiRowClass).last();
var newApiRow = cloneRow.clone(true);
newApiRow.find('input').val('');
cloneRow.after(newApiRow);
});
dialogElement.find('.' + config.settingsDeleteRowButtonClass).on('click', function(){
$(this).parents('.row').remove();
});
});

View File

@@ -14,7 +14,8 @@ define([
var config = {
// shutdown dialog
shutdownDialogId: 'pf-shutdown-dialog' // id for "trust" dialog
shutdownDialogId: 'pf-shutdown-dialog', // id for "shutdown" dialog
shutdownDialogClass: 'pf-shutdown-dialog' // class for "shutdown" dialog
};
@@ -41,52 +42,55 @@ define([
*/
$.fn.showShutdownDialog = function(dialogData){
requirejs(['text!templates/dialog/shutdown.html', 'mustache'], function(template, Mustache) {
// check if there is already a shutdown dialog open
var $shutdownDialoges = $('.' + config.shutdownDialogClass);
var data = {
id: config.shutdownDialogId,
reason: dialogData.reason
};
if($shutdownDialoges.length === 0){
var content = Mustache.render(template, data);
// close all modals
$('.modal').modal('hide');
// show dialog
var shutdownDialog = bootbox.dialog({
title: 'Shutdown',
message: content,
buttons: {
logout: {
label: '<i class="fa fa-fw fa-power-off"></i> logout',
className: ['btn-default', 'pull-left'].join(' '),
callback: function() {
requirejs(['text!templates/dialog/shutdown.html', 'mustache'], function(template, Mustache) {
$(document).trigger('pf:menuLogout');
}
},
refresh: {
label: '<i class="fa fa-fw fa-repeat"></i> reload',
className: ['btn-danger'].join(' '),
callback: function(){
// refresh page
location.reload();
return false;
var data = {
id: config.shutdownDialogId,
reason: dialogData.reason
};
var content = Mustache.render(template, data);
// show dialog
var shutdownDialog = bootbox.dialog({
title: 'Shutdown',
message: content,
className: config.shutdownDialogClass,
buttons: {
logout: {
label: '<i class="fa fa-fw fa-refresh"></i> restart',
className: ['btn-primary'].join(' '),
callback: function() {
$(document).trigger('pf:menuLogout');
}
}
}
}
});
shutdownDialog.on('shown.bs.modal', function(e) {
// remove close button
var dialog = $(this);
dialog.find('.bootbox-close-button').remove();
dialog.find('button').blur();
// show error message
showPageContent(dialog);
});
});
}
shutdownDialog.on('shown.bs.modal', function(e) {
// remove close button
var dialog = $(this);
dialog.find('.bootbox-close-button').remove();
dialog.find('button').blur();
// show error message
showPageContent(dialog);
});
});
};

View File

@@ -49,7 +49,6 @@ define([
var showKillmails = function(moduleElement, killboardData){
console.log(killboardData)
// change order (show right to left)
killboardData.tableData.reverse();

View File

@@ -9,7 +9,9 @@ define([
'velocityUI',
'validator',
'xEditable',
'easyPieChart'
'easyPieChart',
'hoverIntent',
'bootstrapConfirmation'
], function($, Init, bootbox) {
'use strict';
@@ -306,24 +308,6 @@ define([
);
};
/**
* add a temporary class elements for a certain time
* @param className
* @param duration
* @returns {*}
*/
$.fn.addTemporaryClass = function(className, duration){
var elements = this;
setTimeout(function() {
elements.removeClass(className);
}, duration);
return this.each(function() {
$(this).addClass(className);
});
};
/**
* trigger a notification (on screen or desktop)
* @param customConfig
@@ -426,9 +410,11 @@ define([
/**
* get all available map Types
* optional they can be filtered by current access level of a user
* @param filterByUser
* @returns {Array}
*/
var getMapTypes = function(){
var getMapTypes = function(filterByUser){
var mapTypes = [];
@@ -443,6 +429,39 @@ define([
}
});
if(filterByUser === true){
var corporationId = getCurrentUserInfo('corporationId');
var allianceId = getCurrentUserInfo('allianceId');
var authorizedMapTypes = [];
// check if character data exists
if(corporationId > 0) {
authorizedMapTypes.push('corporation');
}
if(allianceId > 0){
authorizedMapTypes.push('alliance');
}
// private maps are always allowed
authorizedMapTypes.push('private');
// compare "all" map types with "authorized" types
var tempMapTypes = [];
for(var i = 0; i < mapTypes.length; i++){
for(var j = 0; j < authorizedMapTypes.length; j++){
if(mapTypes[i].name === authorizedMapTypes[j]){
console.log('OK')
tempMapTypes.push(mapTypes[i]);
break;
}
}
}
mapTypes = tempMapTypes;
}
return mapTypes;
};
@@ -601,38 +620,24 @@ define([
var statusInfo = '';
var corporationId = null;
var allianceId = null;
// character status can not be checked if there are no reference data
// e.g. during registration process (landing page)
if(Init.characterStatus){
var corporationId = getCurrentUserInfo('corporationId');
var allianceId = getCurrentUserInfo('allianceId');
var currentUserData = getCurrentUserData();
if(
currentUserData &&
currentUserData.character
){
var tempCharacterData = currentUserData.character;
// check if current user has a corpId
if(tempCharacterData.corporation){
corporationId = tempCharacterData.corporation.id;
// compare current user data with given user data
if(
characterData.corporation &&
characterData.corporation.id === corporationId
){
statusInfo = Init.characterStatus.corporation[option];
}else if(
characterData.alliance &&
characterData.alliance.id === allianceId
){
statusInfo = Init.characterStatus.alliance[option];
}
// check if current user has a allianceId
if(tempCharacterData.alliance){
allianceId = tempCharacterData.alliance.id;
}
}
// compare current user data with given user data
if(
characterData.corporation &&
characterData.corporation.id === corporationId
){
statusInfo = Init.characterStatus.corporation[option];
}else if(
characterData.alliance &&
characterData.alliance.id === allianceId
){
statusInfo = Init.characterStatus.alliance[option];
}
return statusInfo;
@@ -853,7 +858,11 @@ define([
Init.currentUserData = userData;
$.fn.updateHeaderUserData();
// check if function is available
// this is not the case for "landing" page
if( $.fn.updateHeaderUserData ){
$.fn.updateHeaderUserData();
}
return getCurrentUserData();
};
@@ -866,6 +875,40 @@ define([
return Init.currentUserData;
};
/**
* get information for the current mail user
* @param option
* @returns {boolean}
*/
var getCurrentUserInfo = function(option){
var currentUserData = getCurrentUserData();
var userInfo = false;
if(currentUserData){
// user data is set -> user data will be set AFTER the main init request!
var characterData = currentUserData.character;
if(
option === 'allianceId' &&
characterData.alliance
){
userInfo = characterData.alliance.id;
}
if(
option === 'corporationId' &&
characterData.corporation
){
userInfo = characterData.corporation.id;
}
}
return userInfo;
};
/**
* set currentSystemData as "global" variable
* @param systemData
@@ -925,6 +968,23 @@ define([
return dateString + ' ' + timeString;
};
/**
* init tooltips on an element
* @returns {any|JQuery|*}
*/
$.fn.initTooltips = function(){
return this.each(function(){
var tooltipElements = $(this).find('[title]');
tooltipElements.tooltip({
container: this,
delay: 100
});
});
};
/**
* adds a popup tooltip with character information (created/updated)
* @param tooltipData
@@ -953,7 +1013,7 @@ define([
var statusCreatedClass = getStatusInfoForCharacter(createdData.character, 'class');
var statusUpdatedClass = getStatusInfoForCharacter(updatedData.character, 'class');
// convert timestamps v
// convert timestamps
var dateCreated = new Date(createdData.created * 1000);
var dateUpdated = new Date(updatedData.updated * 1000);
var dateCreatedUTC = convertDateToUTC(dateCreated);
@@ -1072,6 +1132,7 @@ define([
getCurrentUserData: getCurrentUserData,
setCurrentSystemData: setCurrentSystemData,
getCurrentSystemData: getCurrentSystemData,
getCurrentUserInfo: getCurrentUserInfo,
convertDateToString: convertDateToString,
formatPrice: formatPrice
};