285 lines
7.6 KiB
JavaScript
285 lines
7.6 KiB
JavaScript
var edit_history = new Array();
|
|
|
|
function save() {
|
|
var jqxhr;
|
|
var form_data;
|
|
form_data = $('#object_edit_form').serialize();
|
|
|
|
jqxhr = $.ajax({
|
|
'url': './index.php?admin_modul=admin_object_edit&action=save&object=' + edit_object_class_name + '&object_id=' + object_id,
|
|
'dataType': 'JSON',
|
|
'type': 'POST',
|
|
'data': form_data
|
|
});
|
|
|
|
jqxhr.success(function(data) {
|
|
if (data.status == 'success') {
|
|
object_id = data.object_id;
|
|
$("#edit-form").load(edit_link + encodeURIComponent(object_id), function() {
|
|
edit_history = new Array();
|
|
edit_history_state();
|
|
});
|
|
} else {
|
|
alert('Error!');
|
|
}
|
|
});
|
|
jqxhr.error(function() {
|
|
alert("ERROR: can't load url");
|
|
});
|
|
|
|
return;
|
|
}
|
|
|
|
function edit_history_state() {
|
|
if (edit_history.length > 0) {
|
|
$('.object_edit_table_toolbar .save').removeClass('inactive');
|
|
}
|
|
else {
|
|
$('.object_edit_table_toolbar .save').addClass('inactive');
|
|
}
|
|
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
|
|
//==============================================
|
|
// key actions
|
|
//==============================================
|
|
/*$(window).keydown(function(event) {
|
|
alert(event.keyCode);
|
|
});*/
|
|
|
|
|
|
//==============================================
|
|
// toolbar
|
|
//==============================================
|
|
|
|
// save button
|
|
$('.object_edit_table_toolbar .save').click(function(e) {
|
|
e.preventDefault();
|
|
save();
|
|
});
|
|
|
|
// change language
|
|
$('.object_edit_table_toolbar .lang').change(function(e) {
|
|
e.preventDefault();
|
|
|
|
$("#edit-form").load(edit_link + encodeURIComponent(object_id) + '&lang=' + $(this).val(), function() {
|
|
edit_history = new Array();
|
|
edit_history_state();
|
|
});
|
|
});
|
|
|
|
// close button
|
|
$('.object_edit_table_toolbar .close').click(function(e) {
|
|
e.preventDefault();
|
|
if (edit_history.length > 0) {
|
|
var uri = $(this).attr('href');
|
|
bend.dialogs.confirmationDialog({
|
|
confirmation: 'Schließen',
|
|
denial: 'Abbrechen',
|
|
confirmationFunction: function() {
|
|
load_list_items();
|
|
$("#edit-form").dialog("close");
|
|
},
|
|
heading: 'Schließen',
|
|
message: 'Wollen Sie wirklich das Fenster schließen ohne zu speichern?'
|
|
});
|
|
}
|
|
else {
|
|
load_list_items();
|
|
$("#edit-form").dialog("close");
|
|
}
|
|
});
|
|
|
|
// delete button
|
|
$('.object_edit_table_toolbar .delete').click(function(e) {
|
|
e.preventDefault();
|
|
bend.dialogs.confirmationDialog({
|
|
confirmation: 'Löschen',
|
|
denial: 'Abbrechen',
|
|
confirmationFunction: function() {
|
|
// delete object
|
|
var jqxhr;
|
|
object_id = selected_ids.shift();
|
|
jqxhr = $.ajax({
|
|
url: './index.php?admin_modul=admin_object_edit&object=' + object_class_name + '&action=delete_item&object_id=' + object_id
|
|
});
|
|
jqxhr.success(function(data) {
|
|
try {
|
|
var mydata = $.parseJSON(data);
|
|
if (mydata.status != 'success') {
|
|
alert('ERROR: ' + mydata.message);
|
|
}
|
|
else {
|
|
// success action
|
|
load_list_items();
|
|
$("#edit-form").dialog("close");
|
|
}
|
|
} catch (e) {
|
|
alert('ERROR: return data is wrong');
|
|
}
|
|
});
|
|
|
|
jqxhr.error(function() {
|
|
alert("ERROR: can't load url");
|
|
});
|
|
},
|
|
heading: 'Löschen',
|
|
message: 'Wollen Sie wirklich das Objekt löschen?'
|
|
});
|
|
});
|
|
|
|
// test send button
|
|
$('.object_edit_table_toolbar .test_send').click(function(e) {
|
|
e.preventDefault();
|
|
var user_email = '';
|
|
var input = prompt('An welche E-Mail Adresse soll die Test E-Mail gesendet werden.', user_email);
|
|
if (input) {
|
|
jqxhr = $.ajax({
|
|
url: './index.php?admin_modul=admin_object_edit&email=' + input + '&object=' + object_class_name + '&action=test_email&object_id=' + object_id
|
|
});
|
|
jqxhr.success(function(data) {
|
|
try {
|
|
var mydata = $.parseJSON(data);
|
|
if (mydata.status != 'success') {
|
|
alert('ERROR: ' + mydata.message);
|
|
}
|
|
else {
|
|
// success action
|
|
alert('E-Mail versendet!');
|
|
}
|
|
} catch (e) {
|
|
alert('ERROR: return data is wrong');
|
|
}
|
|
});
|
|
|
|
jqxhr.error(function() {
|
|
alert("ERROR: can't load url");
|
|
});
|
|
}
|
|
});
|
|
|
|
// send newsletter
|
|
$('.newsletter_send').click(function(e) {
|
|
e.preventDefault();
|
|
var customer_group = $('#customer_group').val();
|
|
if (customer_group > 0) {
|
|
jqxhr = $.ajax({
|
|
url: './index.php?admin_modul=admin_object_edit&customer_group=' + customer_group + '&object=' + object_class_name + '&action=send_email&object_id=' + object_id
|
|
});
|
|
jqxhr.success(function(data) {
|
|
try {
|
|
var mydata = $.parseJSON(data);
|
|
if (mydata.status != 'success') {
|
|
alert('ERROR: ' + mydata.message);
|
|
}
|
|
else {
|
|
// success action
|
|
alert('E-Mail versendet!');
|
|
}
|
|
} catch (e) {
|
|
alert('ERROR: return data is wrong');
|
|
}
|
|
});
|
|
|
|
jqxhr.error(function() {
|
|
alert("ERROR: can't load url");
|
|
});
|
|
}
|
|
else {
|
|
alert('Keine Kundengruppe gewählt!')
|
|
}
|
|
});
|
|
|
|
|
|
|
|
$('.edit_field').change(function(e) {
|
|
e.preventDefault();
|
|
edit_history.push($(this).attr('name'));
|
|
edit_history_state();
|
|
});
|
|
|
|
// html editor
|
|
$('.texteditor').tinymce({
|
|
script_url : '../../../libs/tinymce/tinymce.min.js',
|
|
width: "500",
|
|
height: "300",
|
|
plugins: 'advlist autolink link image lists charmap print preview hr anchor pagebreak searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking save table contextmenu directionality emoticons template paste',
|
|
toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media',
|
|
statusbar: false,
|
|
branding: false,
|
|
relative_urls: false
|
|
});
|
|
|
|
// file upload
|
|
$('#file_upload').uploadify({
|
|
'uploader': '../../../../libs/uploadify/uploadify.swf',
|
|
'script': './index.php?admin_modul=admin_object_edit',
|
|
'cancelImg': '../../../../libs/uploadify/cancel.png',
|
|
'folder': '../../../../libs/uploads',
|
|
'scriptData': {
|
|
'action': 'upload_image',
|
|
'object': object_class_name,
|
|
'object_id': object_id
|
|
},
|
|
'fileDesc': 'Web Image Files',
|
|
'buttonText': 'Dateiauswahl',
|
|
'auto': true,
|
|
'multi': false,
|
|
'onComplete': function(event, ID, fileObj, response, data) {
|
|
try {
|
|
var mydata = $.parseJSON(response);
|
|
|
|
if (mydata.status == 'success') {
|
|
$("#edit-form").load(edit_link + encodeURIComponent(object_id), function() {
|
|
edit_history = new Array();
|
|
edit_history_state();
|
|
});
|
|
} else {
|
|
$().easywayShopMessageDialog("ERROR: can't save", {}, function() {
|
|
$().easywayShopMessageDialog(mydata.data, {}, function() {
|
|
});
|
|
});
|
|
}
|
|
} catch (e) {
|
|
$().easywayShopMessageDialog("ERROR: can't upload", {}, function() {
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
// delete file
|
|
$('.delete_image').click(function(e) {
|
|
e.preventDefault();
|
|
var url = './index.php?admin_modul=admin_object_edit&object=' + object_class_name + '&action=delete_image&object_id=' + object_id
|
|
var jqxhr = $.ajax({
|
|
'url': url
|
|
});
|
|
|
|
jqxhr.success(function(data) {
|
|
try {
|
|
data = $.parseJSON(data);
|
|
|
|
if (data.status == 'success') {
|
|
$("#edit-form").load(edit_link + encodeURIComponent(object_id), function() {
|
|
edit_history = new Array();
|
|
edit_history_state();
|
|
});
|
|
} else {
|
|
$().easywayShopMessageDialog("ERROR: no delete'", {}, function() {
|
|
});
|
|
}
|
|
} catch (e) {
|
|
$().easywayShopMessageDialog("ERROR: wrong answer", {}, function() {
|
|
});
|
|
}
|
|
});
|
|
|
|
jqxhr.error(function() {
|
|
$().easywayShopMessageDialog("ERROR", {}, function() {
|
|
});
|
|
});
|
|
});
|
|
|
|
}); |