3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha › Tools › Quote editor</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 [% Asset.css("css/quotes.css") %]
7 [% Asset.css("css/datatables.css") %]
10 <body id="tools_quotes" class="tools">
11 [% INCLUDE 'header.inc' %]
12 [% INCLUDE 'cat-search.inc' %]
14 <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>
16 <div id="doc3" class="yui-t2">
20 [% INCLUDE 'quotes-toolbar.inc' %]
22 <div id="instructions">
23 <fieldset id="quote_editor_help" class="rows">
24 <legend>Instructions</legend>
25 <div id="quote_editor_inst">
27 <li>Click on the 'Add quote' button to add a single quote; Press the <Enter> key to save the quote.<br />
28 <b>Note: </b>Both the 'source' and 'text' fields must have content in order for the quote to be saved.</li>
29 <li>Click on any field to edit the contents; Press the <Enter> key to save edit.</li>
30 <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>
31 <li>Click the 'Import quotes' button in the toolbar to import a CSV file of quotes.</li>
36 <table id="quotes_editor">
39 <th><span style="cursor: help" id="id_help">ID</span></th>
42 <th>Last displayed</th>
46 <!-- tbody content is generated by DataTables -->
50 <td>Loading data...</td>
55 <fieldset id="footer" class="action">
59 <div class="yui-b noprint">
60 [% INCLUDE 'tools-menu.inc' %]
64 [% MACRO jsinclude BLOCK %]
65 [% Asset.js("js/tools-menu.js") %]
66 [% INCLUDE 'datatables.inc' %]
67 [% Asset.js("lib/jquery/plugins/dataTables.fnReloadAjax.js") %]
68 [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") %]
69 <script type="text/javascript">
70 var oTable; /* oTable needs to be global */
71 var sEmptyTable = _("No quotes available. Please use the 'Add quote' button to add a quote."); /* override the default message in datatables.inc */
72 $(document).ready(function() {
73 /* NOTE: This is an ajax-source datatable and *not* a server-side sourced datatable. */
74 /* See the datatable docs if you don't understand this difference. */
75 oTable = $("#quotes_editor").dataTable({
79 "sPaginationType" : "full_numbers",
80 "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
81 "sAjaxSource" : "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
90 "sFirst": MSG_DT_FIRST,
93 "sPrevious": MSG_DT_PREVIOUS,
95 "sEmptyTable": MSG_DT_EMPTY_TABLE,
97 "sInfoEmpty": MSG_DT_INFO_EMPTY,
98 "sInfoFiltered": MSG_DT_INFO_FILTERED,
99 "sLengthMenu": MSG_DT_LENGTH_MENU,
100 "sLoadingRecords": MSG_DT_LOADING_RECORDS,
101 "sProcessing": MSG_DT_PROCESSING,
102 "sSearch": MSG_DT_SEARCH,
103 "sZeroRecords": MSG_DT_ZERO_RECORDS,
105 "fnPreDrawCallback": function(oSettings) {
108 "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
109 /* do foo on the current row and its child nodes */
110 var noEditFields = [];
111 var quoteID = $('td', nRow)[0].innerHTML;
112 $(nRow).attr("id", quoteID); /* set row ids to quote id */
113 $('td:eq(0)', nRow).click(function() {$(this.parentNode).toggleClass('selected',this.clicked);}); /* add row selectors */
114 $('td:eq(0)', nRow).attr("title", _("Click ID to select/deselect quote"));
115 $('td', nRow).attr("id",quoteID); /* FIXME: this is a bit of a hack */
116 if (isNaN(quoteID)) {
117 noEditFields = [0,1,2,3]; /* all fields when adding a quote */
119 noEditFields = [0,3]; /* id, timestamp */
121 /* apply no_edit id to noEditFields */
122 for (i=0; i<noEditFields.length; i++) {
123 $('td', nRow)[noEditFields[i]].setAttribute("id","no_edit");
127 "fnDrawCallback": function(oSettings) {
128 /* Apply the jEditable handlers to the table on all fields w/o the no_edit id */
129 $('#quotes_editor tbody td[id!="no_edit"]').editable( "/cgi-bin/koha/tools/quotes/quotes_ajax.pl", {
130 "submitdata" : function ( value, settings ) {
132 "column" : oTable.fnGetPosition( this )[2],
137 "placeholder" : "Saving data...",
141 $("#add_quote").click(function(){
145 $("#delete_quote").click(function(){
149 $("#id_help").on("click",function(e){
151 alert( _("Click on the quote's id to select or deselect the quote. Multiple quotes may be selected.") );
155 function fnClickAddQuote(e, node) {
157 /* some browsers only give charCode, so this will need to be */
158 /* fixed up to handle that */
159 console.log('charCode: '+e.charCode);
161 if (e.keyCode == 13) {
162 var quoteSource = $('#quoteSource').val();
163 var quoteText = $('#quoteText').val()
164 /* If passed a quote source, add the quote to the db */
165 if (quoteSource && quoteText) {
167 url: "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
170 "source" : quoteSource,
174 success: function(data){
175 var newQuote = data[0];
176 var aRow = oTable.fnUpdate(
183 oTable.fnPageChange( 'last' );
184 $('.add_quote_button').attr('onclick', 'fnClickAddRow()'); // re-enable add button
188 alert(_("Please supply both the text and source of the quote before saving."));
190 } else if (e.keyCode == 27) {
191 if (confirm(_("Are you sure you want to cancel adding this quote?"))) {
192 oTable.fnDeleteRow(node);
199 function fnClickAddRow() {
200 $('.add_quote_button').removeAttr('onclick'); // disable add button once it has been clicked
201 var aRow = oTable.fnAddData(
203 'NA', // this is hackish to fool the datatable sort routine into placing this row at the end of the list...
204 '<input id="quoteSource" type="text" style="height:14px; width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>',
205 '<input id="quoteText" type="text" style="height:14px; width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>',
206 '0000-00-00 00:00:00',
210 oTable.fnPageChange( 'last' );
211 $('#quoteSource').focus();
214 function fnClickDeleteRow() {
215 var idsToDelete = oTable.$('.selected').map(function() {
219 alert(_("Please select a quote(s) by clicking the quote id(s) you desire to delete."));
220 } else if (confirm(_("Are you sure you wish to delete quote(s) %s?").format(idsToDelete))) {
221 oTable.$('.selected').each(function(){
222 var quoteID = $(this).attr('id');
224 url: "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
230 /* Delete the row from the datatable */
232 oTable.fnDeleteRow(this);
233 oTable.fnReloadAjax(null, null, true);
244 [% INCLUDE 'intranet-bottom.inc' %]