2022-09-20 20:10:34 +08:00
|
|
|
/* eslint-disable no-param-reassign eslint-disable no-undef */
|
|
|
|
/* global I18n zebraPrint */
|
2022-08-04 17:14:35 +08:00
|
|
|
|
|
|
|
(function() {
|
2022-09-20 20:10:34 +08:00
|
|
|
var zebraPrinter;
|
|
|
|
|
|
|
|
function initZebraPrinterList() {
|
|
|
|
var zebraContainer = $('.zebra-printers');
|
|
|
|
zebraPrinter = zebraPrint.init(
|
|
|
|
zebraContainer,
|
|
|
|
{
|
|
|
|
clearSelectorOnFirstDevice: true,
|
|
|
|
noDevices: function() {
|
|
|
|
zebraContainer.empty();
|
|
|
|
zebraContainer.append(`<li>
|
|
|
|
${I18n.t('users.settings.account.label_printer.no_printers_available')}</li>`);
|
|
|
|
},
|
|
|
|
appendDevice: function(device) {
|
|
|
|
zebraContainer.append(`<li>${device.name} <span class="zebra-status-tag ${device.status.toLowerCase()}">
|
2022-08-04 17:14:35 +08:00
|
|
|
${device.status}</span></li>`);
|
2022-09-20 20:10:34 +08:00
|
|
|
},
|
|
|
|
beforeRefresh: function() {
|
|
|
|
zebraContainer.empty();
|
2022-09-27 18:02:50 +08:00
|
|
|
zebraContainer.append(`
|
|
|
|
<li class="searching-printers">
|
|
|
|
<img src="/images/medium/loading.svg"></img>
|
|
|
|
${I18n.t('users.settings.account.label_printer.looking_for_printers')}
|
|
|
|
</li>`);
|
2022-08-04 17:14:35 +08:00
|
|
|
}
|
2022-10-12 22:56:58 +08:00
|
|
|
},
|
|
|
|
true
|
2022-09-20 20:10:34 +08:00
|
|
|
);
|
2022-08-04 17:14:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
$('.zebra-printer-refresh').on('click', function() {
|
2022-09-20 20:10:34 +08:00
|
|
|
zebraPrinter.refreshList();
|
2022-08-04 17:14:35 +08:00
|
|
|
});
|
|
|
|
|
2022-09-20 20:10:34 +08:00
|
|
|
initZebraPrinterList();
|
2022-08-04 17:14:35 +08:00
|
|
|
}());
|