[open-ils-commits] r17438 - in branches/rel_2_0/Open-ILS: examples xul/staff_client/server/admin xul/staff_client/server/cat (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Sep 1 23:31:42 EDT 2010
Author: dbs
Date: 2010-09-01 23:31:39 -0400 (Wed, 01 Sep 2010)
New Revision: 17438
Modified:
branches/rel_2_0/Open-ILS/examples/fm_IDL.xml
branches/rel_2_0/Open-ILS/xul/staff_client/server/admin/copy_locations.js
branches/rel_2_0/Open-ILS/xul/staff_client/server/admin/copy_locations.xhtml
branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/spine_labels.js
branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/spine_labels.xul
Log:
UI portions of spine label editing enhancements listed in r17437
Also include the IDL for the new fields on asset.copy_location. Oops.
Modified: branches/rel_2_0/Open-ILS/examples/fm_IDL.xml
===================================================================
--- branches/rel_2_0/Open-ILS/examples/fm_IDL.xml 2010-09-02 03:29:51 UTC (rev 17437)
+++ branches/rel_2_0/Open-ILS/examples/fm_IDL.xml 2010-09-02 03:31:39 UTC (rev 17438)
@@ -3058,6 +3058,8 @@
<field reporter:label="Owning Org Unit" name="owning_lib" reporter:datatype="org_unit"/>
<field reporter:label="Copy Location Orders" name="orders" oils_persist:virtual="true" reporter:datatype="link"/>
<field reporter:label="Copies" name="copies" oils_persist:virtual="true" reporter:datatype="link"/>
+ <field reporter:label="Label Prefix" name="label_prefix" reporter:datatype="text" oils_persist:i18n="true"/>
+ <field reporter:label="Label Suffix" name="label_suffix" reporter:datatype="text" oils_persist:i18n="true"/>
</fields>
<links>
<link field="owning_lib" reltype="has_a" key="id" map="" class="aou"/>
Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/admin/copy_locations.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/admin/copy_locations.js 2010-09-02 03:29:51 UTC (rev 17437)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/admin/copy_locations.js 2010-09-02 03:31:39 UTC (rev 17438)
@@ -160,6 +160,8 @@
appendClear($n( row, 'cl_hold_verify'), (isTrue(cl.hold_verify())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
appendClear($n( row, 'cl_visible'), (isTrue(cl.opac_visible())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
appendClear($n( row, 'cl_circulate'), (isTrue(cl.circulate())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
+ $n( row, 'cl_label_prefix').appendChild(text(cl.label_prefix() || ''));
+ $n( row, 'cl_label_suffix').appendChild(text(cl.label_suffix() || ''));
var edit = $n( row, 'cl_edit');
edit.onclick = function() { clEdit( cl, tbody, row ); };
@@ -201,6 +203,22 @@
if(isTrue(cl.hold_verify())) arr[6].checked = true;
else arr[7].checked = true;
+ var label_prefix = $n(r, 'cl_edit_label_prefix');
+ if (cl.label_prefix()) {
+ label_prefix.setAttribute('size', cl.label_prefix().length + 3);
+ } else {
+ label_prefix.setAttribute('size', 3);
+ }
+ label_prefix.value = cl.label_prefix();
+
+ var label_suffix = $n(r, 'cl_edit_label_suffix');
+ if (cl.label_suffix()) {
+ label_suffix.setAttribute('size', cl.label_suffix().length + 3);
+ } else {
+ label_suffix.setAttribute('size', 3);
+ }
+ label_suffix.value = cl.label_suffix();
+
$n(r, 'cl_edit_cancel').onclick = function(){cleanTbody(tbody,'edit');}
$n(r, 'cl_edit_commit').onclick = function(){clEditCommit( tbody, r, cl ); }
@@ -234,6 +252,8 @@
if(arr[6].checked) cl.hold_verify(1);
else cl.hold_verify(0);
cl.name($n(r, 'cl_edit_name').value);
+ cl.label_prefix($n(r, 'cl_edit_label_prefix').value);
+ cl.label_suffix($n(r, 'cl_edit_label_suffix').value);
var req = new Request( UPDATE_CL, SESSION, cl );
req.send(true);
Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/admin/copy_locations.xhtml
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/admin/copy_locations.xhtml 2010-09-02 03:29:51 UTC (rev 17437)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/admin/copy_locations.xhtml 2010-09-02 03:31:39 UTC (rev 17438)
@@ -37,7 +37,7 @@
<body onload='try{clEditorInit();}catch(e){alert(js2JSON(e));}'>
<div class='welcome_box'>
- <span>Welcome </span><b><span id='user'/></b>
+ <span>&staff.server.admin.copy_locations.editor.welcome; </span><b><span id='user'/></b>
</div>
<center>
@@ -96,7 +96,7 @@
</td>
</tr>
<tr>
- <td colspan='4'><input id='sc_new_submit' type='submit' value='Create' disabled='disabled'/></td>
+ <td colspan='4'><input id='sc_new_submit' type='submit' value='&staff.server.admin.copy_locations.editor.create;' disabled='disabled'/></td>
</tr>
</tbody>
</table>
@@ -116,6 +116,8 @@
<td width=''>&staff.server.admin.copy_locations.editor.hold_verify;</td>
<td width=''>&staff.server.admin.copy_locations.editor.opac_visible;</td>
<td width=''>&staff.server.admin.copy_locations.editor.circulate;</td>
+ <td width=''>&staff.server.admin.copy_locations.editor.prefix;</td>
+ <td width=''>&staff.server.admin.copy_locations.editor.suffix;</td>
<td width=''>&staff.server.admin.copy_locations.editor.edit;</td>
<td width=''>&staff.server.admin.copy_locations.editor.delete;</td>
</tr>
@@ -131,8 +133,10 @@
<td name='cl_hold_verify'> </td>
<td name='cl_visible'> </td>
<td name='cl_circulate'> </td>
- <td><input type='submit' value='Edit' name='cl_edit' disabled='disabled'> </input></td>
- <td><input type='submit' value='Delete' name='cl_delete' disabled='disabled'> </input></td>
+ <td name='cl_label_prefix'> </td>
+ <td name='cl_label_suffix'> </td>
+ <td><input type='submit' value='&staff.server.admin.copy_locations.editor.edit;' name='cl_edit' disabled='disabled'> </input></td>
+ <td><input type='submit' value='&staff.server.admin.copy_locations.editor.delete;' name='cl_delete' disabled='disabled'> </input></td>
</tr>
</tbody>
</table>
@@ -194,6 +198,8 @@
<input type='radio' name='cl_edit_circulate'/>
</span>
</td>
+ <td><input name='cl_edit_label_prefix' type='text'> </input></td>
+ <td><input name='cl_edit_label_suffix' type='text'> </input></td>
<td><input type='submit' name='cl_edit_commit' value='&staff.server.admin.copy_locations.submit;'/></td>
<td><input type='submit' name='cl_edit_cancel' value='&staff.server.admin.copy_locations.cancel;'/></td>
</tr>
Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/spine_labels.js
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/spine_labels.js 2010-09-02 03:29:51 UTC (rev 17437)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/spine_labels.js 2010-09-02 03:31:39 UTC (rev 17438)
@@ -33,11 +33,18 @@
for (var i = 0; i < g.barcodes.length; i++) {
var copy = g.network.simple_request( 'FM_ACP_RETRIEVE_VIA_BARCODE.authoritative', [ g.barcodes[i] ] );
if (typeof copy.ilsevent != 'undefined') throw(copy);
+ var label_prefix = copy.location().label_prefix() || '';
+ var label_suffix = copy.location().label_suffix() || '';
if (!g.volumes[ copy.call_number() ]) {
var volume = g.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ copy.call_number() ] );
if (typeof volume.ilsevent != 'undefined') throw(volume);
var record = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative', [ volume.record() ]);
volume.record( record );
+
+ /* Jam the prefixes and suffixes into the volume object */
+ volume.prefix = label_prefix;
+ volume.suffix = label_suffix;
+
g.volumes[ volume.id() ] = volume;
}
if (g.volumes[ copy.call_number() ].copies()) {
@@ -67,142 +74,398 @@
alert( util.functional.map_list( g.cols, function(o) { return '%' + o.id + '%'; } ).join(" ") );
}
- function $(id) { return document.getElementById(id); }
+ function $(id) { return dojo.byId(id); }
- function generate() {
+ function generate(override) {
try {
var idx = 0;
- JSAN.use('util.text'); JSAN.use('util.money');
- JSAN.use('util.widgets'); util.widgets.remove_children('panel'); var pn = $('panel'); $('preview').disabled = false;
- var lw = Number($('lw').value) || 8; /* spine label width */
- var ll = Number($('ll').value) || 9; /* spine label length */
- var plw = Number($('plw').value) || 28; /* pocket label width */
- var pll = Number($('pll').value) || 9; /* pocket label length */
- for (var i in g.volumes) {
- var vb = document.createElement('vbox'); pn.appendChild(vb); vb.setAttribute('name','template'); vb.setAttribute('acn_id',g.volumes[i].id());
- var ds = document.createElement('description'); vb.appendChild(ds);
- ds.appendChild( document.createTextNode( g.volumes[i].label() ) );
- var ds2 = document.createElement('description'); vb.appendChild(ds2);
- ds2.appendChild( document.createTextNode( g.volumes[i].copies().length + (
- g.volumes[i].copies().length == 1 ? $("catStrings").getString('staff.cat.spine_labels.copy') : $("catStrings").getString('staff.cat.spine_labels.copies')) ) );
- ds2.setAttribute('style','color: green');
- var hb = document.createElement('hbox'); vb.appendChild(hb);
+ JSAN.use('util.text');
+ JSAN.use('util.money');
+ JSAN.use('util.widgets');
+ var pn = $('panel');
+ $('preview').disabled = false;
- var gb = document.createElement('groupbox'); hb.appendChild(gb);
- /* take the call number and split it on whitespace */
- var names = String(g.volumes[i].label()).split(/\s+/);
- var j = 0;
- while (j < ll || j < pll) {
- var hb2 = document.createElement('hbox'); gb.appendChild(hb2);
-
- /* spine */
- if (j < ll) {
- var tb = document.createElement('textbox'); hb2.appendChild(tb);
- tb.value = '';
- tb.setAttribute('class','plain'); tb.setAttribute('style','font-family: monospace');
- tb.setAttribute('size',lw+1); tb.setAttribute('maxlength',lw);
- tb.setAttribute('name','spine');
- var name = names.shift(); if (name) {
- name = String( name );
- /* if the name is greater than the label width... */
- if (name.length > lw) {
- /* then try to split it on periods */
- var sname = name.split(/\./);
- if (sname.length > 1) {
- /* if we can, then put the periods back in on each splitted element */
- if (name.match(/^\./)) sname[0] = '.' + sname[0];
- for (var k = 1; k < sname.length; k++) sname[k] = '.' + sname[k];
- /* and put all but the first one back into the names array */
- names = sname.slice(1).concat( names );
- /* if the name fragment is still greater than the label width... */
- if (sname[0].length > lw) {
- /* then just truncate and throw the rest back into the names array */
- tb.value = sname[0].substr(0,lw);
- names = [ sname[0].substr(lw) ].concat( names );
- } else {
- /* otherwise we're set */
- tb.value = sname[0];
- }
- } else {
- /* if we can't split on periods, then just truncate and throw the rest back into the names array */
- tb.value = name.substr(0,lw);
- names = [ name.substr(lw) ].concat( names );
- }
+ /* Grab from OU settings, then fall back to hardcoded defaults */
+ var label_cfg = {};
+ label_cfg.spine_width = Number($('lw').value); /* spine label width */
+ if (!label_cfg.spine_width) {
+ label_cfg.spine_width = g.data.hash.aous['cat.spine.line.width'] || 8;
+ $('lw').value = label_cfg.spine_width;
+ }
+ label_cfg.spine_length = Number($('ll').value); /* spine label length */
+ if (!label_cfg.spine_length) {
+ label_cfg.spine_length = g.data.hash.aous['cat.spine.line.height'] || 9;
+ $('ll').value = label_cfg.spine_length;
+ }
+ label_cfg.spine_left_margin = Number($('lm').value); /* left margin */
+ if (!label_cfg.spine_left_margin) {
+ label_cfg.spine_left_margin = g.data.hash.aous['cat.spine.line.margin'] || 0;
+ $('lm').value = label_cfg.spine_left_margin;
+ }
+ label_cfg.font_size = Number( $('pt').value ); /* font size */
+ if (!label_cfg.font_size) {
+ label_cfg.font_size = g.data.hash.aous['cat.label.font.size'] || 10;
+ $('pt').value = label_cfg.font_size;
+ }
+ label_cfg.font_weight = $('font_weight').value; /* font weight */
+ if (!label_cfg.font_weight) {
+ label_cfg.font_weight = g.data.hash.aous['cat.label.font.weight'] || 'normal';
+ $('font_weight').value = label_cfg.font_weight;
+ }
+ label_cfg.font_family = g.data.hash.aous['cat.label.font.family'] || 'monospace';
+ label_cfg.pocket_width = Number($('plw').value) || 28; /* pocket label width */
+ label_cfg.pocket_length = Number($('pll').value) || 9; /* pocket label length */
+
+ if (override) {
+ var gb = $('acn_' + g.volumes[override.acn].id());
+ util.widgets.remove_children('acn_' + g.volumes[override.acn].id());
+ generate_labels(g.volumes[override.acn], gb, label_cfg, override);
+ } else {
+ util.widgets.remove_children('panel');
+ for (var i in g.volumes) {
+ var vb = document.createElement('vbox'); pn.appendChild(vb);
+ vb.setAttribute('name','template');
+ vb.setAttribute('acn_id',g.volumes[i].id());
+ var ds = document.createElement('description'); vb.appendChild(ds);
+ ds.appendChild( document.createTextNode( g.volumes[i].label() ) );
+ var ds2 = document.createElement('description'); vb.appendChild(ds2);
+ ds2.appendChild( document.createTextNode( g.volumes[i].copies().length + ' ' + (
+ g.volumes[i].copies().length == 1 ? $("catStrings").getString('staff.cat.spine_labels.copy') : $("catStrings").getString('staff.cat.spine_labels.copies')) ) );
+ ds2.setAttribute('style','color: green');
+ var hb = document.createElement('hbox'); vb.appendChild(hb);
+
+ var gb = document.createElement('groupbox');
+ hb.appendChild(gb);
+ gb.setAttribute('id','acn_' + g.volumes[i].id());
+ gb.setAttribute('style','border: solid black 2px');
+
+ generate_labels(g.volumes[i], gb, label_cfg, override);
+
+ idx++;
+ }
+ }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.generate.std_unexpeceted_err'),E);
+ }
+ }
+
+ function generate_labels(volume, label_node, label_cfg, override) {
+ var names;
+ var callnum;
+
+ if (override && volume.id() == override.acn) {
+ /* If we're calling ourself, we'll have an altered label */
+ callnum = String(override.label);
+ } else {
+ /* take the call number and split it on whitespace */
+ callnum = String(volume.label());
+ }
+
+ /* for LC, split between classification subclass letters and numbers */
+ var lc_class_re = /^([A-Z]{1,3})([0-9]+.*?)$/i;
+ var lc_class_match = lc_class_re.exec(callnum);
+ if (lc_class_match && lc_class_match.length > 1) {
+ callnum = lc_class_match[1] + ' ' + lc_class_match[2];
+ }
+
+ /* for LC, split between Cutter numbers */
+ var lc_cutter_re = /^(.*)(\.[A-Z]{1}[0-9]+.*?)$/ig;
+ var lc_cutter_match = lc_cutter_re.exec(callnum);
+ if (lc_cutter_match && lc_cutter_match.length > 1) {
+ callnum = '';
+ for (var i = 1; i < lc_cutter_match.length; i++) {
+ callnum += lc_cutter_match[i] + ' ';
+ }
+ }
+
+ /* Only add the prefixes and suffixes once */
+ if (!override || volume.id() != override.acn) {
+ if (volume.prefix) {
+ callnum = volume.prefix + ' ' + callnum;
+ }
+ if (volume.suffix) {
+ callnum += ' ' + volume.suffix;
+ }
+ }
+
+ names = callnum.split(/\s+/);
+ var j = 0;
+ while (j < label_cfg.spine_length || j < label_cfg.pocket_length) {
+ var hb2 = document.createElement('hbox'); label_node.appendChild(hb2);
+
+ /* spine */
+ if (j < label_cfg.spine_length) {
+ var tb = document.createElement('textbox'); hb2.appendChild(tb);
+ tb.value = '';
+ tb.setAttribute('class','plain');
+ tb.setAttribute('style',
+ 'font-family: ' + label_cfg.font_family
+ + '; font-size: ' + label_cfg.font_size
+ + '; font-weight: ' + label_cfg.font_weight
+ );
+ tb.setAttribute('size',label_cfg.spine_width+1);
+ tb.setAttribute('maxlength',label_cfg.spine_width);
+ tb.setAttribute('name','spine');
+ var spine_row_id = 'acn_' + volume.id() + '_spine_' + j;
+ tb.setAttribute('id',spine_row_id);
+
+ var name = names.shift();
+ if (name) {
+ name = String( name );
+
+ /* if the name is greater than the label width... */
+ if (name.length > label_cfg.spine_width) {
+ /* then try to split it on periods */
+ var sname = name.split(/\./);
+ if (sname.length > 1) {
+ /* if we can, then put the periods back in on each splitted element */
+ if (name.match(/^\./)) sname[0] = '.' + sname[0];
+ for (var k = 1; k < sname.length; k++) sname[k] = '.' + sname[k];
+ /* and put all but the first one back into the names array */
+ names = sname.slice(1).concat( names );
+ /* if the name fragment is still greater than the label width... */
+ if (sname[0].length > label_cfg.spine_width) {
+ /* then just truncate and throw the rest back into the names array */
+ tb.value = sname[0].substr(0,label_cfg.spine_width);
+ names = [ sname[0].substr(label_cfg.spine_width) ].concat( names );
} else {
/* otherwise we're set */
- tb.value = name;
+ tb.value = sname[0];
}
+ } else {
+ /* if we can't split on periods, then just truncate and throw the rest back into the names array */
+ tb.value = name.substr(0,label_cfg.spine_width);
+ names = [ name.substr(label_cfg.spine_width) ].concat( names );
}
+ } else {
+ /* otherwise we're set */
+ tb.value = name;
}
+ }
+ dojo.connect($(spine_row_id), 'onkeypress', 'spine_label_key_events');
+ }
- /* pocket */
- if ($('pl').checked && j < pll) {
- var tb2 = document.createElement('textbox'); hb2.appendChild(tb2);
+ /* pocket */
+ if ($('pl').checked && j < label_cfg.pocket_length) {
+ var tb2 = document.createElement('textbox'); hb2.appendChild(tb2);
+ tb2.value = '';
+ tb2.setAttribute('class','plain');
+ tb2.setAttribute('style',
+ 'font-family: ' + label_cfg.font_family
+ + '; font-size: ' + label_cfg.font_size
+ + '; font-weight: ' + label_cfg.font_weight
+ );
+ tb2.setAttribute('size',label_cfg.pocket_width+1); tb2.setAttribute('maxlength',label_cfg.pocket_width);
+ tb2.setAttribute('name','pocket');
+ if ($('title').checked && $('title_line').value == j + 1 && instanceOf(volume.record(),mvr)) {
+ if (volume.record().title()) {
+ tb2.value = util.text.wrap_on_space( volume.record().title(), label_cfg.pocket_width )[0];
+ } else {
tb2.value = '';
- tb2.setAttribute('class','plain'); tb2.setAttribute('style','font-family: monospace');
- tb2.setAttribute('size',plw+1); tb2.setAttribute('maxlength',plw);
- tb2.setAttribute('name','pocket');
- if ($('title').checked && $('title_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) {
- if (g.volumes[i].record().title()) {
- tb2.value = util.text.wrap_on_space( g.volumes[i].record().title(), plw )[0];
- } else {
- tb2.value = '';
- }
+ }
+ }
+ if ($('title_r').checked && $('title_r_line').value == j + 1 && instanceOf(volume.record(),mvr)) {
+ if (volume.record().title()) {
+ tb2.value = ( ($('title_r_indent').checked ? ' ' : '') + util.text.wrap_on_space( volume.record().title(), label_cfg.pocket_width )[1]).substr(0,label_cfg.pocket_width);
+ } else {
+ tb2.value = '';
+ }
+ }
+ if ($('author').checked && $('author_line').value == j + 1 && instanceOf(volume.record(),mvr)) {
+ if (volume.record().author()) {
+ tb2.value = volume.record().author().substr(0,label_cfg.pocket_width);
+ } else {
+ tb2.value = '';
+ }
+ }
+ if ($('call_number').checked && $('call_number_line').value == j + 1) {
+ tb2.value = volume.label().substr(0,label_cfg.pocket_width);
+ }
+ if ($('owning_lib_shortname').checked && $('owning_lib_shortname_line').value == j + 1) {
+ var lib = volume.owning_lib();
+ if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ];
+ tb2.value = lib.shortname().substr(0,label_cfg.pocket_width);
+ }
+ if ($('owning_lib').checked && $('owning_lib_line').value == j + 1) {
+ var lib = volume.owning_lib();
+ if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ];
+ tb2.value = lib.name().substr(0,label_cfg.pocket_width);
+ }
+ if ($('shelving_location').checked && $('shelving_location_line').value == j + 1) {
+ tb2.value = '%location%';
+ }
+ if ($('barcode').checked && $('barcode_line').value == j + 1) {
+ tb2.value = '%barcode%';
+ }
+ if ($('custom1').checked && $('custom1_line').value == j + 1) {
+ tb2.value = $('custom1_tb').value;
+ }
+ if ($('custom2').checked && $('custom2_line').value == j + 1) {
+ tb2.value = $('custom2_tb').value;
+ }
+ if ($('custom3').checked && $('custom3_line').value == j + 1) {
+ tb2.value = $('custom3_tb').value;
+ }
+ if ($('custom4').checked && $('custom4_line').value == j + 1) {
+ tb2.value = $('custom4_tb').value;
+ }
+ }
+
+ j++;
+ }
+ }
+
+ function spine_label_key_events (event) {
+
+ /* Current value of the inpux box */
+ var line_value = event.target.value;
+
+ /* Cursor positions */
+ var sel_start = event.target.selectionStart;
+ var sel_end = event.target.selectionEnd;
+
+ /* Identifiers for this row: "acn_ID_spine_ROW" */
+ var atts = event.target.id.split('_');
+ var row_id = {
+ "acn": atts[1],
+ "spine": atts[3],
+ "prefix": 'acn_' + atts[1] + '_spine_'
+ };
+
+ switch (event.charOrCode) {
+ case dojo.keys.ENTER : {
+ /* Create a new row by inserting a space at the
+ * current cursor point, then regenerating the
+ * label
+ */
+ if (sel_start == sel_end) {
+ if (sel_start == 0) {
+ /* If the cursor is at the start of the line:
+ * insert new line
+ */
+ line_value = ' ' + line_value;
+ } else if (sel_start == line_value.length) {
+ /* Special case if the cursor is at the end of the line:
+ * move to next line
+ */
+ var next_row = $(row_id.prefix + (parseInt(row_id.spine) + 1));
+ if (next_row) {
+ next_row.focus();
}
- if ($('title_r').checked && $('title_r_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) {
- if (g.volumes[i].record().title()) {
- tb2.value = ( ($('title_r_indent').checked ? ' ' : '') + util.text.wrap_on_space( g.volumes[i].record().title(), plw )[1]).substr(0,plw);
- } else {
- tb2.value = '';
- }
+ break;
+ } else {
+ line_value = line_value.substr(0, sel_start) + ' ' + line_value.substr(sel_end);
+ }
+ } else {
+ line_value = line_value.substr(0, sel_start) + ' ' + line_value.substr(sel_end);
+ }
+ event.target.value = line_value;
+
+ /* Recreate the label */
+ var new_label = '';
+ var chunk;
+ var x = 0;
+ while (chunk = $(row_id.prefix + x)) {
+ if (x > 0) {
+ new_label += ' ' + chunk.value;
+ } else {
+ new_label = chunk.value;
+ }
+ x++;
+ }
+ generate({"acn": row_id.acn, "label": new_label});
+ $(row_id.prefix + row_id.spine).focus();
+ break;
+ }
+
+ case dojo.keys.BACKSPACE : {
+ /* Delete line if at the start of an input box */
+ if (sel_start == 0 && sel_end == sel_start) {
+ var new_label = '';
+ var chunk;
+ var x = 0;
+ while (x <= (row_id.spine - 1) && (chunk = $(row_id.prefix + x))) {
+ if (x > 0) {
+ new_label += ' ' + chunk.value;
+ } else {
+ new_label = chunk.value;
}
- if ($('author').checked && $('author_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) {
- if (g.volumes[i].record().author()) {
- tb2.value = g.volumes[i].record().author().substr(0,plw);
- } else {
- tb2.value = '';
- }
+ x++;
+ }
+
+ if (chunk = $(row_id.prefix + x)) {
+ new_label += chunk.value;
+ x++;
+ }
+
+ while (chunk = $(row_id.prefix + x)) {
+ new_label += ' ' + chunk.value;
+ x++;
+ }
+ generate({"acn": row_id.acn, "label": new_label});
+ $(row_id.prefix + row_id.spine).focus();
+ }
+ if (sel_start == 0) {
+ /* Move to the previous row */
+ var prev_row = $(row_id.prefix + (parseInt(row_id.spine) - 1));
+ if (prev_row) {
+ prev_row.focus();
+ }
+ }
+ break;
+ }
+
+ case dojo.keys.DELETE : {
+ /* Delete line if at the end of an input box */
+ if (sel_start == event.target.textLength) {
+ var new_label = '';
+ var chunk;
+ var x = 0;
+ while (x <= row_id.spine && (chunk = $(row_id.prefix + x))) {
+ if (x > 0) {
+ new_label += ' ' + chunk.value;
+ } else {
+ new_label = chunk.value;
}
- if ($('call_number').checked && $('call_number_line').value == j + 1) {
- tb2.value = g.volumes[i].label().substr(0,plw);
- }
- if ($('owning_lib_shortname').checked && $('owning_lib_shortname_line').value == j + 1) {
- var lib = g.volumes[i].owning_lib();
- if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ];
- tb2.value = lib.shortname().substr(0,plw);
- }
- if ($('owning_lib').checked && $('owning_lib_line').value == j + 1) {
- var lib = g.volumes[i].owning_lib();
- if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ];
- tb2.value = lib.name().substr(0,plw);
- }
- if ($('shelving_location').checked && $('shelving_location_line').value == j + 1) {
- tb2.value = '%location%';
- }
- if ($('barcode').checked && $('barcode_line').value == j + 1) {
- tb2.value = '%barcode%';
- }
- if ($('custom1').checked && $('custom1_line').value == j + 1) {
- tb2.value = $('custom1_tb').value;
- }
- if ($('custom2').checked && $('custom2_line').value == j + 1) {
- tb2.value = $('custom2_tb').value;
- }
- if ($('custom3').checked && $('custom3_line').value == j + 1) {
- tb2.value = $('custom3_tb').value;
- }
- if ($('custom4').checked && $('custom4_line').value == j + 1) {
- tb2.value = $('custom4_tb').value;
- }
+ x++;
}
- j++;
+ if (chunk = $(row_id.prefix + x)) {
+ new_label += chunk.value;
+ x++;
+ }
+
+ while (chunk = $(row_id.prefix + x)) {
+ new_label += ' ' + chunk.value;
+ x++;
+ }
+ generate({"acn": row_id.acn, "label": new_label});
+ $(row_id.prefix + row_id.spine).focus();
}
+ break;
+ }
- idx++;
+ case dojo.keys.UP_ARROW : {
+ /* Move to the previous row */
+ var prev_row = $(row_id.prefix + (parseInt(row_id.spine) - 1));
+ if (prev_row) {
+ prev_row.focus();
+ }
+ break;
}
- } catch(E) {
- g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.generate.std_unexpeceted_err'),E);
+
+ case dojo.keys.DOWN_ARROW : {
+ /* Move to the next row */
+ var next_row = $(row_id.prefix + (parseInt(row_id.spine) + 1));
+ if (next_row) {
+ next_row.focus();
+ }
+ break;
+ }
+
+ default : {
+ break;
+ }
}
}
@@ -225,14 +488,35 @@
function preview(idx) {
try {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- var pt = Number( $('pt').value ) || 10; /* font size */
- var lm = Number($('lm').value); if (lm == NaN) lm = 11; /* left margin */
+ var pt = Number( $('pt').value ); /* font size */
+ if (!pt) {
+ pt = g.data.hash.aous['cat.label.font.size'] || 10;
+ $('pt').value = pt;
+ }
+ var ff = g.data.hash.aous['cat.label.font.family'] || 'monospace';
+ var fw = $('font_weight').value; /* font weight */
+ if (!fw) {
+ fw = g.data.hash.aous['cat.label.font.weight'] || 'normal';
+ }
+ var lm = Number($('lm').value); /* left margin */
+ if (!lm) {
+ lm = g.data.hash.aous['cat.spine.line.margin'] || 0;
+ }
var mm = Number($('mm').value); if (mm == NaN) mm = 2; /* middle margin */
- var lw = Number($('lw').value) || 8; var ll = Number($('ll').value) || 9; /* spine label width and length */
+ var lw = Number($('lw').value); /* spine label width */
+ if (!lw) {
+ lw = g.data.hash.aous['cat.spine.line.width'] || 8;
+ $('lw').value = lw;
+ }
+ var ll = Number($('ll').value); /* spine label length */
+ if (!ll) {
+ ll = g.data.hash.aous['cat.spine.line.height'] || 9;
+ $('ll').value = ll;
+ }
var plw = Number($('plw').value) || 28; var pll = Number($('pll').value) || 9; /* pocket label width and length */
var html = "<html><head>";
html += "<link type='text/css' rel='stylesheet' href='" + xulG.url_prefix('/xul/server/skin/print.css') + "'></link>"
- html += "<link type='text/css' rel='stylesheet' href='data:text/css,pre{font-size:" + pt + "pt;}'></link>";
+ html += "<link type='text/css' rel='stylesheet' href='data:text/css,pre{font-family:" + ff + ";font-size:" + pt + "pt; font-weight: " + fw + ";}'></link>";
html += "<title>Spine Labels</title></head><body>\n";
var nl = document.getElementsByAttribute('name','template');
for (var i = 0; i < nl.length; i++) {
@@ -267,22 +551,65 @@
}
}
html += '</body></html>';
- var loc = ( urls.XUL_BROWSER );
- xulG.new_tab(
- loc,
- {
- 'tab_name' : $("catStrings").getString('staff.cat.spine_labels.preview.title')
- },
- {
- 'url' : 'data:text/html;charset=utf-8,'+window.escape(html),
- 'html_source' : html,
- 'show_print_button' : 1,
- 'no_xulG' : 1
- }
- );
+
+ /* From https://developer.mozilla.org/en/Using_nsIXULAppInfo */
+ var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULAppInfo);
+ var platformVer = appInfo.platformVersion;
+
+ /* We need to use different print strategies for different
+ * XUL versions, apparently
+ */
+ if (platformVer.substr(0, 5) == '1.9.0') {
+ preview_xul_190(html);
+ } else {
+ preview_xul_192(html);
+ }
+
+
} catch(E) {
g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.preview.std_unexpected_err'),E);
}
}
+ function preview_xul_190(html) {
+ JSAN.use('util.window'); var win = new util.window();
+ var loc = ( urls.XUL_REMOTE_BROWSER );
+ //+ '?url=' + window.escape('about:blank') + '&show_print_button=1&alternate_print=1&no_xulG=1&title=' + window.escape('Spine Labels');
+ var w = win.open( loc, 'spine_preview', 'chrome,resizable,width=750,height=550');
+ w.xulG = {
+ 'url' : 'about:blank',
+ 'show_print_button' : 1,
+ 'alternate_print' : 1,
+ 'no_xulG' : 1,
+ 'title' : $("catStrings").getString('staff.cat.spine_labels.preview.title'),
+ 'on_url_load' : function(b) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ if (typeof w.xulG.written == 'undefined') {
+ w.xulG.written = true;
+ w.g.browser.get_content().document.write(html);
+ w.g.browser.get_content().document.close();
+ }
+ } catch(E) {
+ alert(E);
+ }
+ }
+ };
+ }
+ function preview_xul_192(html) {
+ var loc = ( urls.XUL_BROWSER );
+ xulG.new_tab(
+ loc,
+ {
+ 'tab_name' : $("catStrings").getString('staff.cat.spine_labels.preview.title')
+ },
+ {
+ 'url' : 'data:text/html;charset=utf-8,'+window.escape(html),
+ 'html_source' : html,
+ 'show_print_button' : 1,
+ 'no_xulG' : 1
+ }
+ );
+ }
Modified: branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/spine_labels.xul
===================================================================
--- branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/spine_labels.xul 2010-09-02 03:29:51 UTC (rev 17437)
+++ branches/rel_2_0/Open-ILS/xul/staff_client/server/cat/spine_labels.xul 2010-09-02 03:31:39 UTC (rev 17438)
@@ -47,16 +47,22 @@
accesskey="&staff.cat.spine_labels.close_window.accesskey;" oncommand="window.close()"/>
</hbox>
- <hbox>
- <label value="&staff.cat.spine_labels.font_size.label;" control="pt"/>
- <textbox id="pt" value="10" onchange="this.setAttribute('value',this.value)" oils_persist="value" context="clipboard"/>
- </hbox>
+ <grid><columns><column/><column/></columns><rows>
+ <row>
+ <label value="&staff.cat.spine_labels.font_size.label;" control="pt"/>
+ <textbox id="pt" value="" onchange="this.setAttribute('value',this.value)" oils_persist="value" context="clipboard"/>
+ </row>
+ <row>
+ <label value="&staff.cat.spine_labels.font_weight.label;" control="font_weight"/>
+ <textbox id="font_weight" value="" onchange="this.setAttribute('value',this.value)" oils_persist="value" context="clipboard"/>
+ </row>
+ </rows></grid>
<grid><columns><column/><column/><column/><column/></columns><rows>
<row> <label class="header" value="&staff.cat.spine_labels.spine_label.label;"/><spacer/> </row>
- <row> <label value="&staff.cat.spine_labels.spine_label.left_margin.label;" control="lm"/><textbox id="lm" value="0" onchange="this.setAttribute('value',this.value)" oils_persist="value" context="clipboard"/> </row>
- <row> <label value="&staff.cat.spine_labels.spine_label.label_width.label;" control="lw"/><textbox id="lw" value="8" onchange="this.setAttribute('value',this.value)" oils_persist="value" context="clipboard"/> </row>
- <row> <label value="&staff.cat.spine_labels.spine_label.label_length.label;" control="ll"/><textbox id="ll" value="9" onchange="this.setAttribute('value',this.value)" oils_persist="value" context="clipboard"/> </row>
- <row> <label class="header" value="&staff.cat.spine_labels.pocket_label.label;"/><checkbox id="pl" checked="false" oils_persist="checked" label="Enabled"/> </row>
+ <row> <label value="&staff.cat.spine_labels.spine_label.left_margin.label;" control="lm"/><textbox id="lm" value="" onchange="this.setAttribute('value',this.value)" oils_persist="value" context="clipboard"/> </row>
+ <row> <label value="&staff.cat.spine_labels.spine_label.label_width.label;" control="lw"/><textbox id="lw" value="" onchange="this.setAttribute('value',this.value)" oils_persist="value" context="clipboard"/> </row>
+ <row> <label value="&staff.cat.spine_labels.spine_label.label_length.label;" control="ll"/><textbox id="ll" value="" onchange="this.setAttribute('value',this.value)" oils_persist="value" context="clipboard"/> </row>
+ <row> <label class="header" value="&staff.cat.spine_labels.pocket_label.label;"/><checkbox id="pl" checked="false" oils_persist="checked" label="&staff.cat.spine_labels.pocket_label.enabled.label;"/> </row>
<row> <label value="&staff.cat.spine_labels.pocket_label.middle_margin.label;" control="mm"/><textbox id="mm" value="2" onchange="this.setAttribute('value',this.value)" oils_persist="value" context="clipboard"/> </row>
<row> <label value="&staff.cat.spine_labels.pocket_label.label_width.label;" control="plw"/><textbox id="plw" value="28" onchange="this.setAttribute('value',this.value)" oils_persist="value" context="clipboard"/> </row>
<row> <label value="&staff.cat.spine_labels.pocket_label.label_length.label;" control="pll"/><textbox id="pll" value="9" onchange="this.setAttribute('value',this.value)" oils_persist="value" context="clipboard"/> </row>
@@ -76,7 +82,7 @@
</row>
<row> <spacer/><checkbox id="title_r_indent" checked="true" oils_persist="checked" label="&staff.cat.spine_labels.indent_title.label;"/> </row>
<row>
- <checkbox id="author" checked="true" oils_persist="checked" label="Include Author"/>
+ <checkbox id="author" checked="true" oils_persist="checked" label="&staff.cat.spine_labels.pocket_label.include_author.label;"/>
<hbox>
<label value="&staff.cat.spine_labels.on_line.label;"/>
<textbox id="author_line" value="3" oils_persist="value" onchange="this.setAttribute('value',this.value)" context="clipboard"/>
More information about the open-ils-commits
mailing list