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 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
6 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/dataTables.fnReloadAjax.js"></script>
7 [% INCLUDE 'datatables-strings.inc' %]
9 <script type="text/javascript" src="/intranet-tmpl/prog/en/js/datatables.js"></script>
10 <script type="text/javascript" src="/intranet-tmpl/prog/en/js/jquery.jeditable.mini.js"></script>
11 <script type="text/javascript">
13 var oTable; /* oTable needs to be global */
14 var sEmptyTable = _('No quotes available. Please use the \"Add Quote\" button to add a quote.'); /* override the default message in datatables-strings.inc */
15 $(document).ready(function() {
16 /* NOTE: This is an ajax-source datatable and *not* a server-side sourced datatable. */
17 /* See the datatable docs if you don't understand this difference. */
18 oTable = $("#quotes_editor").dataTable({
22 "sPaginationType" : "full_numbers",
23 "sAjaxSource" : "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
31 "sEmptyTable": sEmptyTable,
33 "fnPreDrawCallback": function(oSettings) {
36 "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
37 /* do foo on the current row and its child nodes */
38 var noEditFields = [];
39 var quoteID = $('td', nRow)[0].innerHTML;
40 $(nRow).attr("id", quoteID); /* set row ids to quote id */
41 $('td:eq(0)', nRow).click(function() {$(this.parentNode).toggleClass('selected',this.clicked);}); /* add row selectors */
42 $('td:eq(0)', nRow).attr("title", "Click ID to select/deselect quote");
44 noEditFields = [0,1,2,3]; /* all fields when adding a quote */
47 noEditFields = [0,3]; /* id, timestamp */
49 /* apply no_edit id to noEditFields */
50 for (i=0; i<noEditFields.length; i++) {
51 $('td', nRow)[noEditFields[i]].setAttribute("id","no_edit");
55 "fnDrawCallback": function(oSettings) {
56 /* Apply the jEditable handlers to the table on all fields w/o the no_edit id */
57 $('#quotes_editor tbody td[id!="no_edit"]').editable( "/cgi-bin/koha/tools/quotes/quotes_ajax.pl", {
58 "submitdata" : function ( value, settings ) {
60 "column" : oTable.fnGetPosition( this )[2],
65 "placeholder" : "Saving data...",
71 function fnClickAddQuote(e, node) {
73 /* some browsers only give charCode, so this will need to be */
74 /* fixed up to handle that */
75 console.log('charCode: '+e.charCode);
77 if (e.keyCode == 13) {
78 var quoteSource = $('#quoteSource').val();
79 var quoteText = $('#quoteText').val()
80 /* If passed a quote source, add the quote to the db */
81 if (quoteSource && quoteText) {
83 url: "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
86 "source" : quoteSource,
90 success: function(data){
91 var newQuote = data[0];
92 var aRow = oTable.fnUpdate(
98 oTable.fnPageChange( 'last' );
99 $('.add_quote_button').attr('onclick', 'fnClickAddRow()'); // re-enable add button
104 alert('Please supply both the text and source of the quote before saving.');
107 else if (e.keyCode == 27) {
108 if (confirm('Are you sure you want to cancel adding this quote?')) {
109 oTable.fnDeleteRow(node);
117 function fnClickAddRow() {
118 $('.add_quote_button').removeAttr('onclick'); // disable add button once it has been clicked
119 var aRow = oTable.fnAddData(
121 'NA', // this is hackish to fool the datatable sort routine into placing this row at the end of the list...
122 '<input id="quoteSource" type="text" style="height:14px; width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>',
123 '<input id="quoteText" type="text" style="height:14px; width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>',
124 '0000-00-00 00:00:00',
128 oTable.fnPageChange( 'last' );
129 $('#quoteSource').focus();
132 function fnClickDeleteRow() {
133 var idsToDelete = oTable.$('.selected').map(function() {
137 alert('Please select a quote(s) by clicking the quote id(s) you desire to delete.');
139 else if (confirm('Are you sure you wish to delete quote(s) '+idsToDelete+'?')) {
140 oTable.$('.selected').each(function(){
141 var quoteID = $(this).attr('id');
143 url: "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
149 /* Delete the row from the datatable */
151 oTable.fnDeleteRow(this);
152 oTable.fnReloadAjax(null, null, true);
164 <body id="tools_quotes" class="tools">
165 [% INCLUDE 'header.inc' %]
166 [% INCLUDE 'cat-search.inc' %]
168 <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>
170 <div id="doc3" class="yui-t2">
174 [% INCLUDE 'quotes-toolbar.inc' %]
175 <h2>Quote editor</h2>
176 <table id="quotes_editor" style="float: left; width: 100%;">
179 <th><span style="cursor: help" onclick="event.stopPropagation();alert('Click on the quote\'s id to select or deselect the quote. Multiple quotes may be selected.');">ID</span></th>
182 <th>Last Displayed</th>
183 <!-- <th>Actions</th>-->
187 <!-- tbody content is generated by DataTables -->
191 <td>Loading data...</td>
197 <fieldset id="footer" class="action" style="height:25px;">
201 <div class="yui-b noprint">
202 [% INCLUDE 'tools-menu.inc' %]
205 [% INCLUDE 'intranet-bottom.inc' %]