(function($){
// TEMP
- var ELEMENT_KEY = 'resource_hrn';
var debug=false;
debug=true
/* XXX Events XXX */
// this.$element.on('show.Datatables', this.on_show);
- this.el().on('show', this, this.on_show);
+ this.elmt().on('show', this, this.on_show);
// Unbind all events using namespacing
// TODO in destructor
// $(window).unbind('Hazelnut');
this.listen_query(options.query_uuid);
this.listen_query(options.query_all_uuid, 'all');
+ /* an internal buffer for keeping lines and display them in one call to fnAddData */
+ this.buffered_lines = [];
+
/* GUI setup and event binding */
this.initialize_table();
},
actual_options = {
// Customize the position of Datatables elements (length,filter,button,...)
// we use a fluid row on top and another on the bottom, making sure we take 12 grid elt's each time
- sDom: "<'row-fluid'<'span5'l><'span1'r><'span6'f>>t<'row-fluid'<'span5'i><'span7'p>>",
- sPaginationType: 'bootstrap',
+ sDom: "<'row'<'col-md-5'l><'col-md-1'r><'col-md-6'f>>t<'row'<'col-md-5'i><'col-md-7'p>>",
+ // XXX as of sept. 2013, I cannot locate a bootstrap3-friendly mode for now
+ // hopefully this would come with dataTables v1.10 ?
+ // in any case, search for 'sPaginationType' all over the code for more comments
+ sPaginationType: 'full_numbers',
// Handle the null values & the error : Datatables warning Requested unknown parameter
// http://datatables.net/forums/discussion/5331/datatables-warning-...-requested-unknown-parameter/p2
aoColumnDefs: [{sDefaultContent: '',aTargets: [ '_all' ]}],
};
// the intention here is that options.datatables_options as coming from the python object take precedence
// XXX DISABLED by jordan: was causing errors in datatables.js $.extend(actual_options, options.datatables_options );
- this.table = this.el('table').dataTable(actual_options);
+ this.table = this.elmt('table').dataTable(actual_options);
/* Setup the SelectAll button in the dataTable header */
/* xxx not sure this is still working */
// UNUSED ? //
// UNUSED ? // }, // update_plugin
- checkbox: function (plugin_uuid, header, field) //, selected_str, disabled_str)
+ checkbox: function (key, value)
{
var result="";
- if (header === null)
- header = '';
// Prefix id with plugin_uuid
result += "<input";
result += " class='hazelnut-checkbox'";
- result += " id='" + this.id('checkbox', this.id_from_key(this.key, unfold.get_value(header))) + "'";
- //hazelnut-checkbox-" + plugin_uuid + "-" + unfold.get_value(header).replace(/\\/g, '') + "'";
- result += " name='" + unfold.get_value(field) + "'";
+ result += " id='" + this.id('checkbox', this.id_from_key(key, value)) + "'";
+ result += " name='" + key + "'";
result += " type='checkbox'";
- //result += selected_str;
- //result += disabled_str;
result += " autocomplete='off'";
- result += " value='" + unfold.get_value(header) + "'";
+ result += " value='" + value + "'";
result += "></input>";
return result;
}, // checkbox
if (this.options.checkboxes)
// Use a key instead of hostname (hard coded...)
// XXX remove the empty checked attribute
- line.push(this.checkbox(this.options.plugin_uuid, record[ELEMENT_KEY], record['type']));
+ line.push(this.checkbox(this.key, record[this.key]));
// XXX Is adding an array of lines more efficient ?
- this.table.fnAddData(line);
+// this.table.fnAddData(line);
+ this.buffered_lines.push(line)
},
this.unspin();
}
+ this.table.fnAddData (this.buffered_lines);
+ this.buffered_lines=[];
this.received_all = true;
}, // on_all_query_done
* Handle clicks on checkboxes: reassociate checkbox click every time
* the table is redrawn
*/
- this.els('hazelnut-checkbox').unbind('click').click(this, this._check_click);
+ this.elts('hazelnut-checkbox').unbind('click').click(this, this._check_click);
if (!this.table)
return;