function oils_lock_page(params) {
dump('oils_lock_page\n');
if (!params) { params = {}; }
- if (window.oils_lock) {
+ if (window.oils_lock > 0) {
if (!params.allow_multiple_locks) {
- return 'already locked';
+ return window.oils_lock;
}
}
- window.oils_lock = true;
+ window.oils_lock++;
if (typeof xulG != 'undefined') {
if (typeof xulG.unlock_tab == 'function') {
xulG.lock_tab();
}
}
- return 'locked';
+ return window.oils_lock;
}
function oils_unlock_page(params) {
dump('oils_unlock_page\n');
- window.oils_lock = false;
+ window.oils_lock--;
+ if (window.oils_lock < 0) { window.oils_lock = 0; }
if (typeof xulG != 'undefined') {
if (typeof xulG.unlock_tab == 'function') {
xulG.unlock_tab();
}
}
- return 'unlocked';
+ return window.oils_lock;
}
+ window.oils_lock = 0;
window.addEventListener(
'close',
function(ev) {
try {
dump('oils_lock_page/oils_unlock_page onclose handler\n');
- if (window.oils_lock) {
+ if (window.oils_lock > 0) {
var confirmation = window.confirm($('offlineStrings').getString('menu.close_window.unsaved_data_warning'));
if (!confirmation) {
ev.preventDefault();
}
}
- window.oils_lock = false;
+ window.oils_lock = 0;
if (typeof xulG != 'undefined') {
if (typeof xulG.unlock_tab == 'function') {
xulG.unlock_tab();
],
'cmd_checkout' : [
['command'],
- function() { obj.deck.set_iframe('offline_checkout.xul',{},{}); }
+ function() {
+ obj.deck.set_iframe(
+ 'offline_checkout.xul',
+ {},
+ {
+ 'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
+ 'unlock' : oils_unlock_page
+ }
+ );
+ }
],
'cmd_renew' : [
['command'],
- function() { obj.deck.set_iframe('offline_renew.xul',{},{}); }
+ function() {
+ obj.deck.set_iframe(
+ 'offline_renew.xul',
+ {},
+ {
+ 'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
+ 'unlock' : oils_unlock_page
+ }
+ );
+ }
],
'cmd_in_house_use' : [
['command'],
- function() { obj.deck.set_iframe('offline_in_house_use.xul',{},{}); }
+ function() {
+ obj.deck.set_iframe(
+ 'offline_in_house_use.xul',
+ {},
+ {
+ 'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
+ 'unlock' : oils_unlock_page
+ }
+ );
+ }
],
'cmd_checkin' : [
['command'],
- function() { obj.deck.set_iframe('offline_checkin.xul',{},{}); }
+ function() {
+ obj.deck.set_iframe(
+ 'offline_checkin.xul',
+ {},
+ {
+ 'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
+ 'unlock' : oils_unlock_page
+ }
+ );
+ }
],
'cmd_register_patron' : [
['command'],
- function() { obj.deck.set_iframe('offline_register.xul',{},{}); }
+ function() {
+ obj.deck.set_iframe(
+ 'offline_register.xul',
+ {},
+ {
+ 'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
+ 'unlock' : oils_unlock_page
+ }
+ );
+ }
],
'cmd_print_last_receipt' : [
['command'],
],
'cmd_exit' : [
['command'],
- function() { try { xulG.close_tab(); } catch(E) { window.close(); } }
+ function() {
+ try {
+ xulG.close_tab();
+ } catch(E) {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('close',window);
+ }
+ }
],
}
}
var offlineStrings;
+var local_lock = false;
function my_init() {
try {
JSAN.use('util.date');
+ function handle_lock(ev) {
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+ }
+ $('i_barcode').addEventListener('change',handle_lock,false);
$('i_barcode').addEventListener('keypress',handle_keypress,false);
$('i_barcode').focus();
var x = $('i_barcode'); x.value = ''; x.focus();
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+
} catch(E) {
dump(E+'\n'); alert(E);
}
file.close();
+ if (local_lock) {
+ local_lock = false;
+ xulG.unlock();
+ }
+
if ($('print_receipt').checked) {
try {
var params = {
</hbox>
<hbox>
<spacer flex="1"/>
- <button id="cancel" label="&common.cancel;" oncommand="g.list.clear()"/>
+ <button id="cancel" hidden="true" label="&common.cancel;" oncommand="g.list.clear()"/>
<button id="submit" label="&common.save_transactions.label;" accesskey="&common.save_transactions.accesskey;" />
</hbox>
</vbox>
var offlineStrings;
+var local_lock = false;
function my_init() {
try {
var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*14 );
todayPlus = util.date.formatted_date(todayPlus,"%F");
+ function handle_lock(ev) {
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+ }
+
$('duedate').setAttribute('value',todayPlus);
$('duedate').addEventListener('change',check_date,false);
$('p_barcode').addEventListener('change',test_patron,false);
+ $('p_barcode').addEventListener('change',handle_lock,false);
$('p_barcode').addEventListener('keypress',handle_keypress,false);
$('p_barcode').focus();
+ $('i_barcode').addEventListener('change',handle_lock,false);
$('i_barcode').addEventListener('keypress',handle_keypress,false);
$('enter').addEventListener('command',handle_enter,false);
var x = $('i_barcode'); x.value = ''; x.focus();
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+
} catch(E) {
dump(E+'\n'); alert(E);
file.append_object(row);
}
file.close();
+
+ if (local_lock) {
+ local_lock = false;
+ xulG.unlock();
+ }
}
function next_patron(cancel) {
</hbox>
<hbox>
<spacer flex="1"/>
- <button id="cancel" label="&common.cancel;" />
+ <button id="cancel" hidden="true" label="&common.cancel;" />
<button id="submit" label="&common.save_transactions.label;" accesskey="&common.save_transactions.accesskey;" />
</hbox>
</vbox>
var offlineStrings;
+var local_lock = false;
function my_init() {
try {
'map_row_to_column' : circ.util.std_map_row_to_column(),
} );
+ function handle_lock(ev) {
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+ }
+ $('i_barcode').addEventListener('change',handle_lock,false);
$('i_barcode').addEventListener('keypress',handle_keypress,false);
$('enter').addEventListener('command',handle_enter,false);
$('submit').addEventListener('command',next_patron,false);
var x = $('i_barcode'); x.value = ''; x.focus();
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+
} catch(E) {
dump(E+'\n'); alert(E);
}
file.close();
+ if (local_lock) {
+ local_lock = false;
+ xulG.unlock();
+ }
+
if ($('print_receipt').checked) {
try {
var params = {
</hbox>
<hbox>
<spacer flex="1"/>
- <button id="cancel" label="&common.cancel;" oncommand="g.list.clear()"/>
+ <button id="cancel" hidden="true" label="&common.cancel;" oncommand="g.list.clear()"/>
<button id="submit" label="&common.save_transactions.label;" accesskey="&common.save_transactions.accesskey;" />
</hbox>
</vbox>
var offlineStrings;
+var local_lock = false;
function my_init() {
try {
$('barcode').addEventListener('keypress',handle_keypress,false);
$('submit').addEventListener('command',next_patron,false);
+ function handle_lock(ev) {
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+ }
+ $('barcode').addEventListener('change',handle_lock,false);
+ $('passwd').addEventListener('change',handle_lock,false);
+ $('ident_value').addEventListener('change',handle_lock,false);
+ $('first_given_name').addEventListener('change',handle_lock,false);
+ $('family_name').addEventListener('change',handle_lock,false);
+ $('dob').addEventListener('change',handle_lock,false);
+ $('street1').addEventListener('change',handle_lock,false);
+ $('street2').addEventListener('change',handle_lock,false);
+ $('city').addEventListener('change',handle_lock,false);
+ $('state').addEventListener('change',handle_lock,false);
+ $('country').addEventListener('change',handle_lock,false);
+ $('post_code').addEventListener('change',handle_lock,false);
+
+ $('cancel').addEventListener(
+ 'command',
+ function(ev) {
+ $('barcode').value = '';
+ $('passwd').value = '';
+ $('ident_value').value = '';
+ $('first_given_name').value = '';
+ $('family_name').value = '';
+ $('dob').value = '';
+ $('street1').value = '';
+ $('street2').value = '';
+ $('city').value = '';
+ $('state').value = '';
+ $('country').value = '';
+ $('post_code').value = '';
+ if (local_lock) {
+ local_lock = false;
+ xulG.unlock();
+ }
+ },
+ false
+ );
+
JSAN.use('util.file');
JSAN.use('util.widgets');
file.append_object(obj);
file.close();
+ if (local_lock) {
+ local_lock = false;
+ xulG.unlock();
+ }
+
alert(offlineStrings.getString('circ.offline_register.patron.saved'));
$('passwd').value = parseInt(Math.random()*8999+1000);
</hbox>
<hbox>
<spacer flex="1"/>
- <button id="cancel" label="&common.cancel;" />
+ <button id="cancel" hidden="true" label="&common.cancel;" />
<button id="submit" label="&staff.circ.offline_register.submit.label;" accesskey="&staff.circ.offline_register.submit.accesskey;" />
</hbox>
</groupbox>
var offlineStrings;
+var local_lock = false;
+
function my_init() {
try {
offlineStrings = $('offlineStrings');
var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*14 );
todayPlus = util.date.formatted_date(todayPlus,"%F");
+ function handle_lock(ev) {
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+ }
+
$('duedate').setAttribute('value',todayPlus);
$('duedate').addEventListener('change',check_date,false);
+ $('p_barcode').addEventListener('change',handle_lock,false);
$('p_barcode').addEventListener('change',test_patron,false);
$('p_barcode').addEventListener('keypress',handle_keypress,false);
$('p_barcode').focus();
+ $('i_barcode').addEventListener('change',handle_lock,false);
$('i_barcode').addEventListener('keypress',handle_keypress,false);
$('enter').addEventListener('command',handle_enter,false);
var x = $('i_barcode'); x.value = ''; x.focus();
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+
} catch(E) {
dump(E+'\n'); alert(E);
file.append_object(row);
}
file.close();
-
+
+ if (local_lock) {
+ local_lock = false;
+ xulG.unlock();
+ }
+
if ($('print_receipt').checked) {
try {
var params = {
</hbox>
<hbox>
<spacer flex="1"/>
- <button id="cancel" label="&common.cancel;" />
+ <button id="cancel" hidden="true" label="&common.cancel;" />
<button id="submit" label="&common.save_transactions.label;" accesskey="&common.save_transactions.accesskey;" />
</hbox>
</vbox>