function() { g.copy_editor_prefs[ 'template_menu' ] = { 'value' : g.template_menu.value }; g.save_attributes(); },
false
);
+
+ if (xulG.unified_interface) {
+ if (typeof xulG.update_unified_template_list == 'function') {
+ xulG.update_unified_template_list(list);
+ // functions the unified wrapper should use to let the item attribute editor do the heavy lifting for templates
+ xulG.update_item_editor_template_selection = function(new_value) {
+ g.template_menu.value = new_value;
+ g.copy_editor_prefs[ 'template_menu' ] = { 'value' : g.template_menu.value };
+ g.save_attributes();
+ }
+ xulG.item_editor_apply_template = function() { g.apply_template(); };
+ xulG.item_editor_delete_template = function() { g.delete_template(); };
+ xulG.item_editor_save_template = function() { g.save_template(); };
+ xulG.item_editor_import_templates = function() { g.import_templates(); };
+ xulG.item_editor_export_templates = function() { g.export_templates(); };
+ xulG.item_editor_reset = function() { g.reset(); };
+ }
+ }
+
} catch(E) {
g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.retrieve_templates.error'), E);
}
<caption id="caption" label="&staff.cat.copy_editor.groupbox1.label;"/>
<hbox id="top_nav">
- <hbox style="background: grey">
+ <hbox id="template_bar" style="background: grey" flex="1">
<vbox><spacer flex="1"/><label value="&staff.cat.copy_editor.templates.label;" style="font-weight: bold"/><spacer flex="1"/></vbox>
<hbox id="template_placeholder"/>
<button id="apply_template" label="&staff.cat.copy_editor.templates.apply_template.label;" accesskey="&staff.cat.copy_editor.templates.apply_template.accesskey;" oncommand="g.apply_template()"/>
<button id="import_templates" label="&staff.cat.copy_editor.templates.import_template.label;" oncommand="g.import_templates()"/>
<button id="export_templates" label="&staff.cat.copy_editor.templates.export_template.label;" oncommand="g.export_templates()"/>
<button id="save_template" label="&staff.cat.copy_editor.templates.save_template.label;" oncommand="g.save_template()"/>
+ <spacer flex="1"/>
+ <button label="&staff.cat.copy_editor.templates.reset.label;" accesskey="&staff.cat.copy_editor.templates.reset.accesskey;" oncommand="g.reset()"/>
</hbox>
- <spacer flex="1"/>
- <button label="&staff.cat.copy_editor.templates.reset.label;" accesskey="&staff.cat.copy_editor.templates.reset.accesskey;" oncommand="g.reset()"/>
</hbox>
<hbox flex="1" style="overflow: scroll">
var error;
+var g = {};
function my_init() {
try {
xulG.not_modal = true;
xulG.edit = true;
- // Spawn the two interfaces
+ // Spawn the volume/copy creator
JSAN.use('util.browser');
var volume_pane = new util.browser();
volume_pane.init(
}
);
+ setup_templates();
+
+ // Spawn the item attribute editor
var item_pane = new util.browser();
item_pane.init(
{
'push_xulG' : true,
'alt_print' : false,
'browser_id' : 'item_pane',
- 'passthru_content_params' : xulG
+ 'passthru_content_params' : xulG,
+ 'on_url_load' : g.clone_template_bar // from setup_templates()
}
);
-
} catch(E) {
- try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); }
+ alert('Error in volume_copy_editor.js, my_init(): ' + E);
}
}
+function setup_templates() {
+ try {
+ JSAN.use('util.widgets'); JSAN.use('util.functional');
+
+ // Once the item attribute editor is loaded, clone and import its template menu to this window with this callback
+ g.clone_template_bar = function() {
+ var item_editor_template_bar = get_contentWindow( $('item_pane') ).document.getElementById('template_bar');
+ $('template_bar_holder').appendChild(
+ document.importNode(
+ item_editor_template_bar,
+ true // children
+ )
+ );
+ item_editor_template_bar.hidden = true;
+ g.apply_template = function() { xulG.item_editor_apply_template(); };
+ g.delete_template = function() { xulG.item_editor_delete_template(); };
+ g.save_template = function() { xulG.item_editor_save_template(); };
+ g.import_templates = function() { xulG.item_editor_import_templates(); };
+ g.export_templates = function() { xulG.item_editor_apply_templates(); };
+ g.reset = function() { xulG.item_editor_reset(); };
+
+ // just do this once; not sure if on_url_load could fire multiple times
+ g.clone_template_bar = function() {};
+ }
+
+ // callback for populating the list of templates
+ xulG.update_unified_template_list = function(list) {
+ try {
+ util.widgets.remove_children('template_placeholder');
+ g.template_menu = util.widgets.make_menulist( list );
+ g.template_menu.setAttribute('id','template_menu');
+ $('template_placeholder').appendChild(g.template_menu);
+ g.template_menu.addEventListener(
+ 'command',
+ function() {
+ xulG.update_item_editor_template_selection( g.template_menu.value );
+ },
+ false
+ );
+ } catch(E) {
+ alert('Error in volume_copy_editor.js, xulG.update_unified_template_list(): ' + E);
+ }
+ };
+
+ } catch(E) {
+ alert('Error in volume_copy_editor.js, setup_templates(): ' + E);
+ }
+}