Skip to content
Snippets Groups Projects
Commit b0ecad43 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Initial import

parents
No related branches found
No related tags found
No related merge requests found
<!DOCTYPE html><title></title>
table.ordernumber-countertable {
border: 1px solid #888888;
display: inline-table;
width: inherit;
}
table.ordernumber-countertable td, table.ordernumber-countertable th {
padding-bottom: 0px;
padding-top: 0px;
}
table.ordernumber-countertable thead th {
text-align: center;
width: auto;
}
table.ordernumber-countertable thead > tr:nth-child(odd) > th,
table.ordernumber-countertable tfoot > tr.addcounter_row > td {
background: #E0E0E0;
}
table.ordernumber-countertable tbody > tr:nth-child(even) > td {
background: #F0F0F0;
}
table.ordernumber-countertable.table-striped tbody > tr:nth-child(odd) > th {
background: #E0E0E0;
}
.ordernumber-btn {
cursor: pointer;
}
col.counter_type, th.counter_type, td.counter_type {
display:none;
}
td.counter_value {
text-align: center;
}
fieldset table.ordernumber-countertable img {
padding: 0;
margin: 0;
}
div.ordernumber-ajax-loading, div.ordernumber-counter-addbtn {
display: inline;
}
div.ordernumber-ajax-loading, div.ordernumber-ajax-loading img.ordernumber-btn {
position: relative;
top: 0; left: 0;
}
div.ordernumber-ajax-loading img {
z-index:0;
}
img.ordernumber-loading {
display: none;
position: absolute;
top: 2px;
left: 0px;
z-index: 9999;
}
/* Counter custom variable replacements */
table.ordernumber_variables {
border: 1px solid #888888;
width: inherit;
}
table.ordernumber_variables td, table.ordernumber_variables th {
padding: 0px;
vertical-align: middle;
}
/* table.ordernumber_variables td.sort:before { */
/* float: none; */
/* display: inline-block; */
/* } */
table.ordernumber_variables thead th {
text-align: center;
width: auto;
}
td.counter_value {
text-align: center;
}
table.ordernumber_variables input {
background-color: rgba(255,255,255,0.75);
}
table.ordernumber_variables thead > tr:nth-child(odd) > th,
table.ordernumber_variables tfoot > tr.addreplacement_row > td {
background: #E0E0E0;
}
table.ordernumber_variables tbody > tr:nth-child(even) > td {
background: #F0F0F0;
}
table.ordernumber_variables tbody tr td input {
width: 100%;
}
.ordernumber-btn {
cursor: pointer;
}
table.ordernumber_variables img {
padding: 0;
margin: 0;
}
tr.rowhidden {
display: none;
}
/* Adjust the columns of the replacements table */
col.variables_ifvar, col.variables_ifval {
width: 15%;
}
col.variables_ifop {
width: 10%;
}
col.variables_thenvar, col.variables_thenval {
width: 25%;
}
.variables_then, .variables_settings {
text-align: center;
width: 20px;
}
images/icon-16-delete.png

555 B

images/icon-16-edit.png

623 B

images/icon-16-new.png

430 B

<!DOCTYPE html><title></title>
images/loading.gif

2.16 KiB

images/loading.png

17.7 KiB

<!DOCTYPE html><title></title>
<!DOCTYPE html><title></title>
/**********************************************************************************
* The global ajax_ordernumber object should have the following entries:
* - Translations:
* ORDERNUMBER_JS_NOT_AUTHORIZED, ORDERNUMBER_JS_INVALID_COUNTERVALUE, ORDERNUMBER_JS_JSONERROR
* ORDERNUMBER_JS_NEWCOUNTER, ORDERNUMBER_JS_EDITCOUNTER, ORDERNUMBER_JS_DELETECOUNTER
* ORDERNUMBER_JS_ADD_FAILED, ORDERNUMBER_JS_MODIFY_FAILED, ORDERNUMBER_JS_DELETE_FAILED
* - ajax_url: The URL for all AJAX calls
* Optional entries (callback functions) are:
* - updateMessages(messages, cssidentifier)
* - parseAjaxResponse(response) => return json
* - modifyAjaxArgs(ajaxargs) => return ajaxargs with modified arguments for jquery.ajax calls
*/
/**********************************************************************************
*
* Javascript for the counter modification table
*
**********************************************************************************/
String.Format = function() {
var s = arguments[0];
for (var i = 0; i < arguments.length - 1; i++) {
var reg = new RegExp("\\{" + i + "\\}", "gm");
s = s.replace(reg, arguments[i + 1]);
}
return s;
}
var getCounterData = function (btn) {
var row = jQuery(btn).closest("tr.counter_row");
return { row: row };
}
var handleJSONResponse = function (json, counter) {
if ('updateMessages' in ajax_ordernumber) {
ajax_ordernumber.updateMessages(json['messages'], "ordernumber");
}
if (!json.authorized && !json.success) {
alert(ajax_ordernumber.ORDERNUMBER_JS_NOT_AUTHORIZED);
} else if (json.error) {
alert(json.error);
} else {
// TODO: Which other error checks can we do?
}
}
var ajaxEditCounter = function (btn, nrtype, ctr, value) {
var counter = getCounterData(btn);
counter.type=nrtype;
counter.counter=ctr;
counter.value=value;
var value = NaN;
var msgprefix = "";
while (isNaN(value) && (value != null)) {
value = prompt (String.Format(ajax_ordernumber.ORDERNUMBER_JS_EDITCOUNTER, msgprefix, counter.counter, counter.value), counter.value);
if (value != null)
value = parseInt(value);
if (isNaN(value))
msgprefix = ajax_ordernumber.ORDERNUMBER_JS_INVALID_COUNTERVALUE;
}
if (value != null) {
var loading = jQuery("img.ordernumber-loading").first().clone().insertAfter(btn).show();
var ajaxargs = {
type: "POST",
url: ajax_ordernumber.ajax_url,
data: {
action: 'setCounter',
nrtype: counter.type,
counter: counter.counter,
value: value
},
success: function ( json ) {
try {
if ('parseAjaxResponse' in ajax_ordernumber) {
json = ajax_ordernumber.parseAjaxResponse(json);
}
handleJSONResponse(json, counter);
} catch (e) {
alert(ajax_ordernumber.ORDERNUMBER_JS_JSONERROR+"\n"+e);
return;
}
if (json.success>0) {
// replace the whole row with the html returned by the AJAX call:
jQuery(counter.row).replaceWith(json.row);
// jQuery(counter.row).find(".counter_value").text(value);
} else {
alert (String.Format(ajax_ordernumber.ORDERNUMBER_JS_MODIFY_FAILED, counter.counter));
}
},
error: function() { alert (String.Format(ajax_ordernumber.ORDERNUMBER_JS_MODIFY_FAILED, counter.counter)); },
complete: function() { jQuery(loading).remove(); },
};
if ('modifyAjaxArgs' in ajax_ordernumber) {
ajaxargs = ajax_ordernumber.modifyAjaxArgs(ajaxargs);
}
jQuery.ajax(ajaxargs);
}
}
var ajaxDeleteCounter = function (btn, nrtype, ctr, value) {
var counter = getCounterData(btn);
counter.type=nrtype;
counter.counter=ctr;
counter.value=value;
var proceed = confirm (String.Format(ajax_ordernumber.ORDERNUMBER_JS_DELETECOUNTER, counter.counter, counter.value));
if (proceed == true) {
var loading = jQuery("img.ordernumber-loading").first().clone().insertAfter(btn).show();
var ajaxargs = {
type: "POST",
dataType: "json",
url: ajax_ordernumber.ajax_url,
data: {
action: 'deleteCounter',
nrtype: counter.type,
counter: counter.counter
},
success: function ( json ) {
try {
if ('parseAjaxResponse' in ajax_ordernumber) {
json = ajax_ordernumber.parseAjaxResponse(json);
}
handleJSONResponse(json, counter);
} catch (e) {
alert(ajax_ordernumber.ORDERNUMBER_JS_JSONERROR+"\n"+e);
return;
}
if (json.success>0) {
jQuery(counter.row).fadeOut(1500, function() { jQuery(counter.row).remove(); });
} else {
alert (String.Format(ajax_ordernumber.ORDERNUMBER_JS_DELETE_FAILED, counter.counter));
}
},
error: function() { alert (String.Format(ajax_ordernumber.ORDERNUMBER_JS_DELETE_FAILED, counter.counter)); },
complete: function() { jQuery(loading).remove(); },
};
if ('modifyAjaxArgs' in ajax_ordernumber) {
ajaxargs = ajax_ordernumber.modifyAjaxArgs(ajaxargs);
}
jQuery.ajax(ajaxargs);
}
}
var ajaxAddCounter = function (btn, nrtype) {
var row = jQuery(btn).parents("tr.addcounter_row");
var countername = prompt (ajax_ordernumber.ORDERNUMBER_JS_NEWCOUNTER);
if (countername != null) {
var loading = jQuery("img.ordernumber-loading").first().clone().insertAfter(jQuery(btn).find("img.ordernumber-counter-addbtn")).show();
var ajaxargs = {
type: "POST",
dataType: "json",
url: ajax_ordernumber.ajax_url,
data: {
action: "addCounter",
nrtype: nrtype,
counter: countername
},
success: function ( json ) {
try {
if ('parseAjaxResponse' in ajax_ordernumber) {
json = ajax_ordernumber.parseAjaxResponse(json);
}
handleJSONResponse(json, null);
} catch (e) {
alert(ajax_ordernumber.ORDERNUMBER_JS_JSONERROR+"\n"+e);
return;
}
if (json.success>0) {
if (json.row) {
jQuery(row).before(jQuery(json.row));
}
} else {
alert (String.Format(ajax_ordernumber.ORDERNUMBER_JS_ADD_FAILED, countername));
}
},
error: function() { alert (String.Format(ajax_ordernumber.ORDERNUMBER_JS_ADD_FAILED, countername)); },
complete: function() { jQuery(loading).remove(); },
};
if ('modifyAjaxArgs' in ajax_ordernumber) {
ajaxargs = ajax_ordernumber.modifyAjaxArgs(ajaxargs);
}
jQuery.ajax(ajaxargs);
}
}
/**********************************************************************************
*
* Javascript for the Custom Variables table
*
**********************************************************************************/
var ordernumberVariablesAddRow = function (template, element) {
var cl = jQuery("#" + template + " tr").clone(true);
// Enable all form controls
jQuery(cl).find('input,select,button,img').removeAttr('disabled');
if (jQuery.fn.chosen) {
// select boxes handled by the chosen juery plugin cannot simply be cloned,
// instead we need to re-initialize chosen!
jQuery(cl).find('select').removeClass("chzn-done").removeAttr("id").css("display", "block").next().remove();
jQuery(cl).find('select').chosen({width: "50px"});
}
// Now insert this new row into the table
jQuery(cl).appendTo("table#" + element + " tbody");
jQuery("tr#ordernumber-replacements-empty-row")
.addClass("rowhidden")
.find('input')
.attr('disabled', 'disabled');
}
jQuery(document).ready (function () {
jQuery('img.ordernumber-replacement-deletebtn').click(
function () {
var count = jQuery(this).closest('table').find('tbody tr').length;
if (count<=1) {
jQuery("tr#ordernumber-replacements-empty-row")
.removeClass("rowhidden")
.find('input,select,button,img')
.removeAttr('disabled');
}
jQuery(this).closest('tr').remove();
}
);
jQuery("#ordernumber_variables tbody").sortable();
});
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment