edit_menu.js

Go to the documentation of this file.
00001 // -*-C-*-
00002 /*
00003   This file is part of  DocBookWiki.  DocBookWiki is a web application
00004   that displays and edits DocBook documents.
00005 
00006   Copyright (C) 2004, 2005, 2006, 2007
00007   Dashamir Hoxha, dashohoxha@users.sourceforge.net
00008 
00009   DocBookWiki is free software;  you can redistribute it and/or modify
00010   it under the terms of the GNU General Public License as published by
00011   the Free  Software Foundation; either  version 2 of the  License, or
00012   (at your option) any later version.
00013 
00014   DocBookWiki is distributed  in the hope that it  will be useful, but
00015   WITHOUT  ANY   WARRANTY;  without  even  the   implied  warranty  of
00016   MERCHANTABILITY or  FITNESS FOR A  PARTICULAR PURPOSE.  See  the GNU
00017   General Public License for more details.
00018 
00019   You should  have received a copy  of the GNU  General Public License
00020   along  with  DocBookWiki;  if   not,  write  to  the  Free  Software
00021   Foundation, Inc., 59 Temple  Place, Suite 330, Boston, MA 02111-1307
00022   USA
00023 */
00024 
00025 function apply()
00026 {
00027   var msg = T_("This will copy the modified menu to the main menu.");
00028   if (confirm(msg))
00029     {
00030       SendEvent('edit_menu', 'apply');
00031     }
00032 }
00033 
00034 function cancel()
00035 {
00036   var msg = T_("This will get a fresh copy of the main menu, discarding any modifications");
00037   if (confirm(msg))
00038     {
00039       SendEvent('edit_menu', 'cancel');
00040     }
00041 }
00042 
00043 function update()
00044 {
00045   var form = document.edit_menu_item;
00046   var bookid = form.item_bookid.value;
00047   var caption = form.item_caption.value;
00048 
00049   if (caption=='')
00050     {
00051       alert(T_("Caption cannot be empty."));
00052       form.item_caption.focus();
00053       return;
00054     }
00055 
00056   var event_args = 'bookid='+bookid+';caption='+caption;
00057   SendEvent('edit_menu', 'update', event_args);
00058 }
00059 
00060 function del()
00061 {
00062   var msg = T_("You are deleting this item and all its subitems.");
00063   if (confirm(msg))
00064     {
00065       SendEvent('edit_menu', 'delete');
00066     }
00067 }
00068 
00069 function move_up(item_id)
00070 {
00071   SendEvent('edit_menu', 'move_up', 'item_id='+item_id);
00072 }
00073 
00074 function move_down(item_id)
00075 {
00076   SendEvent('edit_menu', 'move_down', 'item_id='+item_id);
00077 }
00078 
00079 function add_subitem()
00080 {
00081   var form = document.new_menu_item;
00082   var new_bookid = form.new_bookid.value;
00083   var new_caption = form.new_caption.value;
00084 
00085   if (new_caption=='')
00086     {
00087       alert(T_("Please fill the Caption field."));
00088       form.new_caption.focus();
00089       return;
00090     }
00091 
00092   var event_args = 'new_bookid='+new_bookid+';new_caption='+new_caption;
00093   SendEvent('edit_menu', 'add_subitem', event_args);
00094 }
00095 
00096 function copy_to_cb()
00097 {
00098   var id = session.getVar('edit_menu->item_id');
00099   var bookid = session.getVar('edit_menu->item_bookid');
00100   var caption = session.getVar('edit_menu->item_caption');
00101   var item = id+':' + bookid + ':' + caption;
00102   var clipboard = session.getVar('edit_menu->clipboard');
00103   session.setVar('edit_menu->clipboard', clipboard + item + '\n');
00104 
00105   //display an notification message
00106   var msg = T_("Item 'v_item' appended to clipboard.");
00107   item = item.replace(/^[^:]*:/, '');
00108   msg = msg.replace(/v_item/, item);
00109   alert(msg);
00110 }
00111 
00112 function paste_from_cb()
00113 {
00114   var clipboard = session.getVar('edit_menu->clipboard');
00115   if (clipboard=='')
00116     {
00117       alert(T_("Clipboard is empty!"));
00118       return;
00119     }
00120 
00121   SendEvent('edit_menu', 'paste');
00122 }
00123 
00124 function show_cb()
00125 {
00126   var clipboard = session.getVar('edit_menu->clipboard');
00127   clipboard = clipboard.replace(/^[^:]*:/, '');
00128   clipboard = clipboard.replace(/\n[^:]*:/g, '\n');
00129   if (clipboard=='')
00130     alert(T_("Clipboard is empty."));
00131   else
00132     alert(clipboard);
00133 }
00134 
00135 function empty_cb()
00136 {
00137   session.setVar('edit_menu->clipboard', '');
00138   alert(T_("Clipboard is now empty."));
00139 }
00140 
00141 function select_book(listbox)
00142 {
00143   //get the selected book id
00144   var idx = listbox.selectedIndex;
00145   var book_id = listbox.options[idx].value;
00146 
00147   //set it to the field new_bookid of the form
00148   document.new_menu_item.new_bookid.value = book_id;
00149   document.new_menu_item.new_caption.value = book_id;
00150 }

Generated on Wed Jan 9 08:27:32 2008 for DokBookWiki by  doxygen 1.5.2