mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-09-12 07:10:07 +02:00
This commit is contained in:
parent
6d1a00291e
commit
b765a21369
@ -1,3 +1,8 @@
|
|||||||
|
// Hack for bootstrap issue with IE10. https://github.com/twbs/bootstrap/issues/3672
|
||||||
|
if ($.browser.msie && $.browser.version > 9) {
|
||||||
|
$('.modal').removeClass('fade');
|
||||||
|
}
|
||||||
|
|
||||||
$.fn.dataTableExt.oApi.fnReloadAjax = function (oSettings, sNewSource, fnCallback, bStandingRedraw) {
|
$.fn.dataTableExt.oApi.fnReloadAjax = function (oSettings, sNewSource, fnCallback, bStandingRedraw) {
|
||||||
if (typeof sNewSource != 'undefined' && sNewSource != null) {
|
if (typeof sNewSource != 'undefined' && sNewSource != null) {
|
||||||
oSettings.sAjaxSource = sNewSource;
|
oSettings.sAjaxSource = sNewSource;
|
||||||
@ -100,60 +105,60 @@ jQuery.fn.dialogForm = function (options) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Success actions ...
|
// Success actions ...
|
||||||
var onSuccess = function (jqXHR, textStatus,data) {
|
var onSuccess = function (jqXHR, textStatus, data) {
|
||||||
if (options.redirect) {
|
if (options.redirect) {
|
||||||
var resourceId = jqXHR.getResponseHeader("ResourceId");
|
var resourceId = jqXHR.getResponseHeader("ResourceId");
|
||||||
var redirectUrl = options.redirect;
|
var redirectUrl = options.redirect;
|
||||||
redirectUrl = redirectUrl.replace("{header.resourceId}", resourceId);
|
redirectUrl = redirectUrl.replace("{header.resourceId}", resourceId);
|
||||||
|
|
||||||
// Hack: IE ignore the base href tag ...
|
// Hack: IE ignore the base href tag ...
|
||||||
var baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf("c/maps/"));
|
var baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf("c/maps/"));
|
||||||
window.open(baseUrl + redirectUrl, '_self');
|
window.open(baseUrl + redirectUrl, '_self');
|
||||||
|
|
||||||
} else if (options.postUpdate) {
|
} else if (options.postUpdate) {
|
||||||
options.postUpdate(formData);
|
options.postUpdate(formData);
|
||||||
}
|
}
|
||||||
dialogElem.modal('hide');
|
dialogElem.modal('hide');
|
||||||
};
|
};
|
||||||
|
|
||||||
// On error message
|
// On error message
|
||||||
var onFailure = function(jqXHR,textStatus, data){
|
var onFailure = function (jqXHR, textStatus, data) {
|
||||||
var errors = JSON.parse(jqXHR.responseText);
|
var errors = JSON.parse(jqXHR.responseText);
|
||||||
// Mark fields with errors ...
|
// Mark fields with errors ...
|
||||||
var fieldErrors = errors.fieldErrors;
|
var fieldErrors = errors.fieldErrors;
|
||||||
if (fieldErrors) {
|
if (fieldErrors) {
|
||||||
for (var fieldName in fieldErrors) {
|
for (var fieldName in fieldErrors) {
|
||||||
// Mark the field with errors ...
|
// Mark the field with errors ...
|
||||||
var message = fieldErrors[fieldName];
|
var message = fieldErrors[fieldName];
|
||||||
var inputField = $("#" + containerId + " input[name='" + fieldName + "']");
|
var inputField = $("#" + containerId + " input[name='" + fieldName + "']");
|
||||||
|
|
||||||
$("#" + containerId).find(".errorMessage").text(message).addClass("alert alert-error");
|
$("#" + containerId).find(".errorMessage").text(message).addClass("alert alert-error");
|
||||||
inputField.parent().addClass('error');
|
inputField.parent().addClass('error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
||||||
acceptBtn.button('reset');
|
acceptBtn.button('reset');
|
||||||
};
|
};
|
||||||
|
|
||||||
var onError = function (jqXHR, textStatus, errorThrown) {
|
var onError = function (jqXHR, textStatus, errorThrown) {
|
||||||
console.log(errorThrown);
|
console.log(errorThrown);
|
||||||
console.log(jqXHR);
|
console.log(jqXHR);
|
||||||
dialogElem.modal('hide');
|
dialogElem.modal('hide');
|
||||||
$('#messagesPanel div div').text(errorThrown);
|
$('#messagesPanel div div').text(errorThrown);
|
||||||
$('#messagesPanel').show()
|
$('#messagesPanel').show()
|
||||||
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
var acceptBtn = $('#' + containerId + ' .btn-accept');
|
||||||
acceptBtn.button('reset');
|
acceptBtn.button('reset');
|
||||||
};
|
};
|
||||||
|
|
||||||
$(acceptBtn).button('loading');
|
$(acceptBtn).button('loading');
|
||||||
var dialogElem = this;
|
var dialogElem = this;
|
||||||
jQuery.ajax(url, {
|
jQuery.ajax(url, {
|
||||||
async:false,
|
async: false,
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:JSON.stringify(formData),
|
data: JSON.stringify(formData),
|
||||||
type:options.type ? options.type : 'POST',
|
type: options.type ? options.type : 'POST',
|
||||||
contentType:"application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
statusCode:{
|
statusCode: {
|
||||||
200: onSuccess,
|
200: onSuccess,
|
||||||
201: onSuccess,
|
201: onSuccess,
|
||||||
204: onSuccess,
|
204: onSuccess,
|
||||||
@ -227,12 +232,12 @@ function updateStarred(spanElem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jQuery.ajax("c/restful/maps/" + mapId + "/starred", {
|
jQuery.ajax("c/restful/maps/" + mapId + "/starred", {
|
||||||
async:false,
|
async: false,
|
||||||
dataType:'json',
|
dataType: 'json',
|
||||||
data:"" + starred,
|
data: "" + starred,
|
||||||
type:'PUT',
|
type: 'PUT',
|
||||||
contentType:"text/plain",
|
contentType: "text/plain",
|
||||||
success:function () {
|
success: function () {
|
||||||
if (starred) {
|
if (starred) {
|
||||||
$(spanElem).removeClass('starredOff');
|
$(spanElem).removeClass('starredOff');
|
||||||
$(spanElem).addClass('starredOn');
|
$(spanElem).addClass('starredOn');
|
||||||
@ -241,7 +246,7 @@ function updateStarred(spanElem) {
|
|||||||
$(spanElem).addClass('starredOff');
|
$(spanElem).addClass('starredOff');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error:function (jqXHR, textStatus, errorThrown) {
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
$('#messagesPanel div').text(errorThrown).parent().show();
|
$('#messagesPanel div').text(errorThrown).parent().show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -263,8 +268,8 @@ $(function () {
|
|||||||
$("#newBtn").click(
|
$("#newBtn").click(
|
||||||
function () {
|
function () {
|
||||||
$("#new-dialog-modal").dialogForm({
|
$("#new-dialog-modal").dialogForm({
|
||||||
redirect:"c/maps/{header.resourceId}/edit",
|
redirect: "c/maps/{header.resourceId}/edit",
|
||||||
url:"c/restful/maps"
|
url: "c/restful/maps"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -283,8 +288,8 @@ $(function () {
|
|||||||
|
|
||||||
// Initialize dialog ...
|
// Initialize dialog ...
|
||||||
$("#duplicate-dialog-modal").dialogForm({
|
$("#duplicate-dialog-modal").dialogForm({
|
||||||
redirect:"c/maps/{header.resourceId}/edit",
|
redirect: "c/maps/{header.resourceId}/edit",
|
||||||
url:"c/restful/maps/" + mapId
|
url: "c/restful/maps/" + mapId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -309,16 +314,16 @@ $(function () {
|
|||||||
|
|
||||||
// Initialize dialog ...
|
// Initialize dialog ...
|
||||||
$("#rename-dialog-modal").dialogForm({
|
$("#rename-dialog-modal").dialogForm({
|
||||||
type:'PUT',
|
type: 'PUT',
|
||||||
clearForm:false,
|
clearForm: false,
|
||||||
postUpdate:function (reqBodyData) {
|
postUpdate: function (reqBodyData) {
|
||||||
tableElem.dataTableExt.removeSelectedRows();
|
tableElem.dataTableExt.removeSelectedRows();
|
||||||
|
|
||||||
rowData.title = reqBodyData.title;
|
rowData.title = reqBodyData.title;
|
||||||
rowData.description = reqBodyData.description;
|
rowData.description = reqBodyData.description;
|
||||||
dataTable.fnAddData(JSON.parse(JSON.stringify(rowData)));
|
dataTable.fnAddData(JSON.parse(JSON.stringify(rowData)));
|
||||||
},
|
},
|
||||||
url:"c/restful/maps/" + mapId
|
url: "c/restful/maps/" + mapId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -331,12 +336,12 @@ $(function () {
|
|||||||
if (mapIds.length > 0) {
|
if (mapIds.length > 0) {
|
||||||
// Initialize dialog ...
|
// Initialize dialog ...
|
||||||
$("#delete-dialog-modal").dialogForm({
|
$("#delete-dialog-modal").dialogForm({
|
||||||
type:'DELETE',
|
type: 'DELETE',
|
||||||
postUpdate:function () {
|
postUpdate: function () {
|
||||||
// Remove old entry ...
|
// Remove old entry ...
|
||||||
tableUI.dataTableExt.removeSelectedRows();
|
tableUI.dataTableExt.removeSelectedRows();
|
||||||
},
|
},
|
||||||
url:"c/restful/maps/batch?ids=" + jQuery.makeArray(mapIds).join(',')
|
url: "c/restful/maps/batch?ids=" + jQuery.makeArray(mapIds).join(',')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user