1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha › Tools › Quote editor</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
5 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/quotes.css" />
6 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
7 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/dataTables.fnReloadAjax.js"></script>
8 [% INCLUDE 'datatables-strings.inc' %]
9 <script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
10 <script type="text/javascript" src="[% themelang %]/js/jquery.jeditable.mini.js"></script>
11 <script type="text/javascript">
13 var MSG_ID_HELP = _("Click on the quote's id to select or deselect the quote. Multiple quotes may be selected.");
15 var oTable; /* oTable needs to be global */
16 var sEmptyTable = _("No quotes available. Please use the \"Add quote\" button to add a quote."); /* override the default message in datatables-strings.inc */
17 $(document).ready(function() {
18 /* NOTE: This is an ajax-source datatable and *not* a server-side sourced datatable. */
19 /* See the datatable docs if you don't understand this difference. */
20 oTable = $("#quotes_editor").dataTable({
24 "sPaginationType" : "full_numbers",
25 "sAjaxSource" : "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
34 "sFirst": MSG_DT_FIRST,
37 "sPrevious": MSG_DT_PREVIOUS,
39 "sEmptyTable": MSG_DT_EMPTY_TABLE,
41 "sInfoEmpty": MSG_DT_INFO_EMPTY,
42 "sInfoFiltered": MSG_DT_INFO_FILTERED,
43 "sLengthMenu": MSG_DT_LENGTH_MENU,
44 "sLoadingRecords": MSG_DT_LOADING_RECORDS,
45 "sProcessing": MSG_DT_PROCESSING,
46 "sSearch": MSG_DT_SEARCH,
47 "sZeroRecords": MSG_DT_ZERO_RECORDS,
49 "fnPreDrawCallback": function(oSettings) {
52 "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
53 /* do foo on the current row and its child nodes */
54 var noEditFields = [];
55 var quoteID = $('td', nRow)[0].innerHTML;
56 $(nRow).attr("id", quoteID); /* set row ids to quote id */
57 $('td:eq(0)', nRow).click(function() {$(this.parentNode).toggleClass('selected',this.clicked);}); /* add row selectors */
58 $('td:eq(0)', nRow).attr("title", _("Click ID to select/deselect quote"));
59 $('td', nRow).attr("id",quoteID); /* FIXME: this is a bit of a hack */
61 noEditFields = [0,1,2,3]; /* all fields when adding a quote */
64 noEditFields = [0,3]; /* id, timestamp */
66 /* apply no_edit id to noEditFields */
67 for (i=0; i<noEditFields.length; i++) {
68 $('td', nRow)[noEditFields[i]].setAttribute("id","no_edit");
72 "fnDrawCallback": function(oSettings) {
73 /* Apply the jEditable handlers to the table on all fields w/o the no_edit id */
74 $('#quotes_editor tbody td[id!="no_edit"]').editable( "/cgi-bin/koha/tools/quotes/quotes_ajax.pl", {
75 "submitdata" : function ( value, settings ) {
77 "column" : oTable.fnGetPosition( this )[2],
82 "placeholder" : "Saving data...",
86 $("#add_quote").click(function(){
90 $("#delete_quote").click(function(){
96 function fnClickAddQuote(e, node) {
98 /* some browsers only give charCode, so this will need to be */
99 /* fixed up to handle that */
100 console.log('charCode: '+e.charCode);
102 if (e.keyCode == 13) {
103 var quoteSource = $('#quoteSource').val();
104 var quoteText = $('#quoteText').val()
105 /* If passed a quote source, add the quote to the db */
106 if (quoteSource && quoteText) {
108 url: "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
111 "source" : quoteSource,
115 success: function(data){
116 var newQuote = data[0];
117 var aRow = oTable.fnUpdate(
123 oTable.fnPageChange( 'last' );
124 $('.add_quote_button').attr('onclick', 'fnClickAddRow()'); // re-enable add button
129 alert(_("Please supply both the text and source of the quote before saving."));
132 else if (e.keyCode == 27) {
133 if (confirm(_("Are you sure you want to cancel adding this quote?"))) {
134 oTable.fnDeleteRow(node);
142 function fnClickAddRow() {
143 $('.add_quote_button').removeAttr('onclick'); // disable add button once it has been clicked
144 var aRow = oTable.fnAddData(
146 'NA', // this is hackish to fool the datatable sort routine into placing this row at the end of the list...
147 '<input id="quoteSource" type="text" style="height:14px; width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>',
148 '<input id="quoteText" type="text" style="height:14px; width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>',
149 '0000-00-00 00:00:00',
153 oTable.fnPageChange( 'last' );
154 $('#quoteSource').focus();
157 function fnClickDeleteRow() {
158 var idsToDelete = oTable.$('.selected').map(function() {
162 alert(_("Please select a quote(s) by clicking the quote id(s) you desire to delete."));
164 else if (confirm(_("Are you sure you wish to delete quote(s) ")+idsToDelete+"?")) {
165 oTable.$('.selected').each(function(){
166 var quoteID = $(this).attr('id');
168 url: "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
174 /* Delete the row from the datatable */
176 oTable.fnDeleteRow(this);
177 oTable.fnReloadAjax(null, null, true);
189 <body id="tools_quotes" class="tools">
190 [% INCLUDE 'header.inc' %]
191 [% INCLUDE 'cat-search.inc' %]
193 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › Quote Editor</div>
195 <div id="doc3" class="yui-t2">
199 [% INCLUDE 'quotes-toolbar.inc' %]
200 <h2>Quote editor</h2>
201 <div id="instructions">
202 <fieldset id="quote_editor_help" class="rows">
203 <legend>Instructions</legend>
204 <div id="quote_editor_inst">
206 <li>Click on the 'Add quote' button to add a single quote; Press the <Enter> key to save the quote. <b>Note:</b> Both the 'source' and 'text' fields must have content in order for the quote to be saved.</li>
207 <li>Click on any field to edit the contents; Press the <Enter> key to save edit.</li>
208 <li>Click on one or more quote numbers to select entire quotes for deletion; Click the 'Delete quote(s)' button to delete selected quotes.</li>
209 <li>Click the 'Import quotes' button in the toolbar to import a CSV file of quotes.</li>
214 <table id="quotes_editor">
217 <th><span style="cursor: help" onclick="event.stopPropagation();alert(MSG_ID_HELP);">ID</span></th>
220 <th>Last displayed</th>
224 <!-- tbody content is generated by DataTables -->
228 <td>Loading data...</td>
233 <fieldset id="footer" class="action">
237 <div class="yui-b noprint">
238 [% INCLUDE 'tools-menu.inc' %]
241 [% INCLUDE 'intranet-bottom.inc' %]