2 * Description: display a query result in a datatables-powered <table>
3 * Copyright (c) 2012-2013 UPMC Sorbonne Universite - INRIA
12 var UnivbrisFvf = Plugin.extend({
14 init: function(options, element) {
15 //alert("foam init called");
16 this.classname="univbrisfvf";
17 this._super(options, element);
19 //alert(this.options.hidden_columns);
20 /* Member variables */
21 // in general we expect 2 queries here
22 // query_uuid refers to a single object (typically a slice)
23 // query_all_uuid refers to a list (typically resources or users)
24 // these can return in any order so we keep track of which has been received yet
25 //this.received_all_query = false;
26 //this.received_query = false;
28 // We need to remember the active filter for datatables filtering
29 this.filters = Array();
31 // an internal buffer for records that are 'in' and thus need to be checked
32 this.buffered_records_to_check = [];
33 // an internal buffer for keeping lines and display them in one call to fnAddData
34 this.buffered_lines = [];
37 // xx somehow non of these triggers at all for now
38 //this.elmt().on('show', this, this.on_show);
39 //this.elmt().on('shown.bs.tab', this, this.on_show);
40 //this.elmt().on('resize', this, this.on_resize);
42 //var query = manifold.query_store.find_analyzed_query(this.options.query_uuid);
43 //this.object = query.object;
45 //// we need 2 different keys
46 // * canonical_key is the primary key as derived from metadata (typically: urn)
47 // and is used to communicate about a given record with the other plugins
48 // * init_key is a key that both kinds of records
49 // (i.e. records returned by both queries) must have (typically: hrn or hostname)
50 // in general query_all will return well populated records, but query
51 // returns records with only the fields displayed on startup
52 var keys = manifold.metadata.get_key(this.object);
53 this.canonical_key = (keys && keys.length == 1) ? keys[0] : undefined;
55 this.init_key = this.options.init_key;
56 // have init_key default to canonical_key
57 this.init_key = this.init_key || this.canonical_key;
59 if ( ! this.init_key ) messages.warning ("UnivbrisFvf : cannot find init_key");
60 if ( ! this.canonical_key ) messages.warning ("UnivbrisFvf : cannot find canonical_key");
61 if (debug) messages.debug("UnivbrisFvf: canonical_key="+this.canonical_key+" init_key="+this.init_key);
63 /* Setup query and record handlers */
64 //this.listen_query(options.query_uuid);
65 //this.listen_query(options.query_all_uuid, 'all');
67 /* GUI setup and event binding */
68 //this.initialize_table();
70 jQuery("#uob_fv_table_form").hide();
72 $('<button id="cancel_addflowspaceform" type="button" style="height: 25px; width: 200px" onclick="fnCancel()">Cancel</button>').appendTo('#fvf_table_button');
74 $('<button id="addflowspaceform" type="button" style="height: 25px; width: 200px" onclick="fnAddflowspace()">Add flowspace</button>').appendTo('#fvf_table_button');
76 this._querytable_draw_callback();
81 on_show: function(e) {
82 if (debug) messages.debug("univbrisfvf.on_show");
84 self.table.fnAdjustColumnSizing();
87 on_resize: function(e) {
88 if (debug) messages.debug("univbrisfvf.on_resize");
90 self.table.fnAdjustColumnSizing();
95 /* GUI MANIPULATION */
97 initialize_table: function()
99 /* Transforms the table into DataTable, and keep a pointer to it */
101 var actual_options = {
102 // Customize the position of Datatables elements (length,filter,button,...)
103 // we use a fluid row on top and another on the bottom, making sure we take 12 grid elt's each time
104 //sDom: "<'row'<'col-xs-5'l><'col-xs-1'r><'col-xs-6'f>>t<'row'<'col-xs-5'i><'col-xs-7'p>>",
105 //sDom: "<'row'<'col-xs-2'l><'col-xs-9'r><'col-xs-2'f>>t<'row'<'col-xs-5'i><'col-xs-5'p>><'next'>",
106 sDom: "<'row'<'col-xs-9'r>t<'buttons'>",
107 // XXX as of sept. 2013, I cannot locate a bootstrap3-friendly mode for now
108 // hopefully this would come with dataTables v1.10 ?
109 // in any case, search for 'sPaginationType' all over the code for more comments
110 sPaginationType: 'bootstrap',
111 // Handle the null values & the error : Datatables warning Requested unknown parameter
112 // http://datatables.net/forums/discussion/5331/datatables-warning-...-requested-unknown-parameter/p2
113 aoColumnDefs: [{sDefaultContent: '',aTargets: [ '_all' ]}],
114 // WARNING: this one causes tables in a 'tabs' that are not exposed at the time this is run to show up empty
115 // sScrollX: '100%', /* Horizontal scrolling */
116 bProcessing: false, /* Loading */
117 fnDrawCallback: function() { self._querytable_draw_callback.call(self);}
118 //fnFooterCallback: function() {self._univbrisfvf_footer_callback.call(self,nFoot, aData, iStart, iEnd, aiDisplay)};}
119 // XXX use $.proxy here !
121 // the intention here is that options.datatables_options as coming from the python object take precedence
122 // xxx DISABLED by jordan: was causing errors in datatables.js
123 // xxx turned back on by Thierry - this is the code that takes python-provided options into account
124 // check your datatables_options tag instead
125 // however, we have to accumulate in aoColumnDefs from here (above)
126 // and from the python wrapper (checkboxes management, plus any user-provided aoColumnDefs)
127 if ( 'aoColumnDefs' in this.options.datatables_options) {
128 actual_options['aoColumnDefs']=this.options.datatables_options['aoColumnDefs'].concat(actual_options['aoColumnDefs']);
129 delete this.options.datatables_options['aoColumnDefs'];
131 $.extend(actual_options, this.options.datatables_options );
132 this.table = $("#univbris_flowspace_form__table").dataTable(actual_options);
136 /* Setup the SelectAll button in the dataTable header */
137 /* xxx not sure this is still working */
138 var oSelectAll = $('#datatableSelectAll-'+ this.options.plugin_uuid);
139 oSelectAll.html("<span class='glyphicon glyphicon-ok' style='float:right;display:inline-block;'></span>Select All");
141 oSelectAll.css('font-size','11px');
142 oSelectAll.css('float','right');
143 oSelectAll.css('margin-right','15px');
144 oSelectAll.css('margin-bottom','5px');
145 oSelectAll.unbind('click');
146 oSelectAll.click(this._selectAll);
148 /* Add a filtering function to the current table
149 * Note: we use closure to get access to the 'options'
151 $.fn.dataTableExt.afnFiltering.push(function( oSettings, aData, iDataIndex ) {
152 /* No filtering if the table does not match */
153 if (oSettings.nTable.id != self.options.plugin_uuid + '__table')
155 return self._querytable_filter.call(self, oSettings, aData, iDataIndex);
158 //alert(this.options.hidden_columns);
160 /* Processing hidden_columns */
161 $.each(this.options.hidden_columns, function(i, field) {
162 //manifold.raise_event(self.options.query_all_uuid, FIELD_REMOVED, field);
164 self.hide_column(field);
165 //self.hide_column(field);
168 }, // initialize_table
171 fnCancel:function(e){
172 //var sData=$("#uob_fv_table_form").find("input").serialize();
173 //alert("add flowspace:" + sData);
174 jQuery("#uob_fv_table_form").hide();
175 jQuery( "#univbris_flowspace_selection" ).show();
178 fnAddflowspace:function(e){
180 pk_flowspace_index=1+pk_flowspace_index;
181 jQuery("#uob_fv_table_form").hide();
182 var sData=$("#uob_fv_table_form").find("input").serialize();
183 var form =serializeAnything("#uob_fv_table_form");
184 this.table = $("#univbris_flowspace_selection__table").dataTable();
187 var string = "<p id='"+form+"'> <a onclick=\'fnPopTable(\""+form+"\");'>"+$("#flowspace_name").val()+"</a></p>";
188 this.table.fnAddData([string, '<a class="edit">Edit</a>', '<a class="delete" href="">Delete</a>']);
189 jQuery( "#univbris_flowspace_selection" ).show();
192 jQuery("#uob_fv_table_form").hide();
193 var sData=$("#uob_fv_table_form").find("input").serialize();
194 var form =serializeAnything("#uob_fv_table_form");
195 this.table = $("#univbris_flowspace_selection__table").dataTable();
198 var string = "<p id='"+form+"'> <a onclick=\'fnPopTable(\""+form+"\");'>"+$("#flowspace_name").val()+"</a></p>";
199 this.table.fnDeleteRow(fvf_nrow);
200 this.table.fnAddData([string, '<a class="edit">Edit</a>', '<a class="delete" href="">Delete</a>']);
201 jQuery( "#univbris_flowspace_selection" ).show();
207 fnModflowspace:function(e){
210 jQuery("#uob_fv_table_form").hide();
211 var sData=$("#uob_fv_table_form").find("input").serialize();
212 var form =serializeAnything("#uob_fv_table_form");
213 this.table = $("#univbris_flowspace_selection__table").dataTable();
215 alert(form+"\n"+sData);
217 var string = "<p id='"+form+"'> <a onclick=\'fnPopTable(\""+form+"\");'>"+$("#flowspace_name").val()+"</a></p>";
218 this.table.fnDeleteRow(fvf_nrow);
219 this.table.fnAddData([string, '<a class="edit">Edit</a>', '<a class="delete" href="">Delete</a>']);
220 jQuery( "#univbris_flowspace_selection" ).show();
224 * @brief Determine index of key in the table columns
228 getColIndex: function(key, cols) {
229 var tabIndex = $.map(cols, function(x, i) { if (x.sTitle == key) return i; });
230 return (tabIndex.length > 0) ? tabIndex[0] : -1;
233 // create a checkbox <input> tag
234 // computes 'id' attribute from canonical_key
235 // computes 'init_id' from init_key for initialization phase
236 // no need to used convoluted ids with plugin-uuid or others, since
237 // we search using table.$ which looks only in this table
238 checkbox_html : function (record) {
240 // Prefix id with plugin_uuid
242 result += " class='univbrisfvf-checkbox'";
243 // compute id from canonical_key
244 var id = record[this.canonical_key]
245 // compute init_id form init_key
246 var init_id=record[this.init_key];
247 // set id - for retrieving from an id, or for posting events upon user's clicks
248 result += " id='"+record[this.canonical_key]+"'";
250 result += "init_id='" + init_id + "'";
252 result += " type='checkbox'";
253 result += " autocomplete='off'";
254 result += "></input>";
258 fake_checkbox_html : function (record) {
259 //alert("fake fun called");
261 // Prefix id with plugin_uuid
263 //result += " class='univbrisfvf-checkbox'";
264 // set id - for retrieving from an id, or for posting events upon user's clicks
265 result += " id='"+ record +"'";
266 result += " name='"+ record +"'";
268 result += " init_id='" + record + "'";
270 result += " type='checkbox'";
271 result += " autocomplete='off'";
272 result += "></input>";
278 new_record: function(record)
281 // this models a line in dataTables, each element in the line describes a cell
284 // go through table headers to get column names we want
285 // in order (we have temporarily hack some adjustments in names)
286 var cols = this.table.fnSettings().aoColumns;
287 var colnames = cols.map(function(x) {return x.sTitle})
288 var nb_col = cols.length;
289 /* if we've requested checkboxes, then forget about the checkbox column for now */
290 if (this.options.checkboxes) nb_col -= 1;
293 /*replace production*/
294 /* fill in stuff depending on the column name */
295 var cols = this.table.fnSettings().aoColumns;
296 //alert("col "+cols);
297 var colnames = cols.map(function(x) {return x.sTitle})
298 var nb_col = cols.length;
299 //alert("nb_col: "+ nb_col);
300 /* if we've requested checkboxes, then forget about the checkbox column for now */
301 if (this.options.checkboxes) nb_col -= 1;
302 //alert("nb_col: "+ nb_col);
304 /*replace production*/
305 /* fill in stuff depending on the column name */
306 for (var j = 0; j < nb_col; j++) {
307 if (typeof colnames[j] == 'undefined') {
309 } else if (colnames[j] == 'Flowspace Selector') {
315 /*if (typeof colnames[j] == 'undefined') {
317 } else if (colnames[j] == 'hostname') {
318 if (record['type'] == 'resource,link')
319 //TODO: we need to add source/destination for links
322 line.push(record['hostname']);
324 } else if (colnames[j] == 'hrn' && typeof(record) != 'undefined') {
325 line.push('<a href="../resource/'+record['urn']+'"><span class="glyphicon glyphicon-search"></span></a> '+record['hrn']);
327 if (record[colnames[j]])
328 line.push(record[colnames[j]]);
334 // catch up with the last column if checkboxes were requested
335 if (this.options.checkboxes) {
336 // Use a key instead of hostname (hard coded...)
337 line.push(this.checkbox_html(record));
340 // adding an array in one call is *much* more efficient
341 // this.table.fnAddData(line);
342 this.buffered_lines.push(line);
343 this.table.fnAddData(this.buffered_lines);
344 //this.table.redraw();
345 //this._querytable_draw_callback();
348 clear_table: function()
350 this.table.fnClearTable();
353 redraw_table: function()
358 show_column: function(field)
360 var oSettings = this.table.fnSettings();
361 var cols = oSettings.aoColumns;
362 var index = this.getColIndex(field,cols);
364 this.table.fnSetColumnVis(index, true);
367 hide_column: function(field)
369 var oSettings = this.table.fnSettings();
370 var cols = oSettings.aoColumns;
371 var index = this.getColIndex(field,cols);
373 //alert(field + ": index: " + index );
375 //alert(field + ": hidden with index: " + index );
376 this.table.fnSetColumnVis(index, false);
379 // this is used at init-time, at which point only init_key can make sense
380 // (because the argument record, if it comes from query, might not have canonical_key set
381 set_checkbox_from_record: function (record, checked) {
382 if (checked === undefined) checked = true;
383 var init_id = record[this.init_key];
384 if (debug) messages.debug("univbrisfvf.set_checkbox_from_record, init_id="+init_id);
385 // using table.$ to search inside elements that are not visible
386 var element = this.table.$('[init_id="'+init_id+'"]');
387 element.attr('checked',checked);
390 // id relates to canonical_key
391 set_checkbox_from_data: function (id, checked) {
392 if (checked === undefined) checked = true;
393 if (debug) messages.debug("univbrisfvf.set_checkbox_from_data, id="+id);
394 // using table.$ to search inside elements that are not visible
395 var element = this.table.$("[id='"+id+"']");
396 element.attr('checked',checked);
399 /*************************** QUERY HANDLER ****************************/
401 on_filter_added: function(filter)
403 this.filters.push(filter);
407 on_filter_removed: function(filter)
409 // Remove corresponding filters
410 this.filters = $.grep(this.filters, function(x) {
416 on_filter_clear: function()
422 on_field_added: function(field)
424 this.show_column(field);
427 on_field_removed: function(field)
429 this.hide_column(field);
432 on_field_clear: function()
434 alert('UnivbrisFvf::clear_fields() not implemented');
437 /* XXX TODO: make this generic a plugin has to subscribe to a set of Queries to avoid duplicated code ! */
438 /*************************** ALL QUERY HANDLER ****************************/
440 on_all_filter_added: function(filter)
446 on_all_filter_removed: function(filter)
452 on_all_filter_clear: function()
458 on_all_field_added: function(field)
460 this.show_column(field);
463 on_all_field_removed: function(field)
465 this.hide_column(field);
468 on_all_field_clear: function()
470 alert('UnivbrisFvf::clear_fields() not implemented');
474 /*************************** RECORD HANDLER ***************************/
476 on_new_record: function(record)
478 if (this.received_all_query) {
479 // if the 'all' query has been dealt with already we may turn on the checkbox
480 this.set_checkbox_from_record(record, true);
482 this.buffered_records_to_check.push(record);
486 on_clear_records: function()
490 // Could be the default in parent
491 on_query_in_progress: function()
496 on_query_done: function()
498 this.received_query = true;
499 // unspin once we have received both
500 if (this.received_all_query && this.received_query) this.unspin();
503 on_field_state_changed: function(data)
505 switch(data.request) {
506 case FIELD_REQUEST_ADD:
507 case FIELD_REQUEST_ADD_RESET:
508 this.set_checkbox_from_data(data.value, true);
510 case FIELD_REQUEST_REMOVE:
511 case FIELD_REQUEST_REMOVE_RESET:
512 this.set_checkbox_from_data(data.value, false);
519 /* XXX TODO: make this generic a plugin has to subscribe to a set of Queries to avoid duplicated code ! */
521 on_all_field_state_changed: function(data)
523 switch(data.request) {
524 case FIELD_REQUEST_ADD:
525 case FIELD_REQUEST_ADD_RESET:
526 this.set_checkboxfrom_data(data.value, true);
528 case FIELD_REQUEST_REMOVE:
529 case FIELD_REQUEST_REMOVE_RESET:
530 this.set_checkbox_from_data(data.value, false);
537 on_all_new_record: function(record)
539 this.new_record(record);
542 on_all_clear_records: function()
548 on_all_query_in_progress: function()
552 }, // on_all_query_in_progress
554 on_all_query_done: function()
556 if (debug) messages.debug("1-shot initializing dataTables content with " + this.buffered_lines.length + " lines");
557 this.table.fnAddData (this.buffered_lines);
558 this.buffered_lines=[];
561 // if we've already received the slice query, we have not been able to set
562 // checkboxes on the fly at that time (dom not yet created)
563 $.each(this.buffered_records_to_check, function(i, record) {
564 if (debug) messages.debug ("querytable delayed turning on checkbox " + i + " record= " + record);
565 self.set_checkbox_from_record(record, true);
567 this.buffered_records_to_check = [];
569 this.received_all_query = true;
570 // unspin once we have received both
571 if (this.received_all_query && this.received_query) this.unspin();
573 }, // on_all_query_done
575 /************************** PRIVATE METHODS ***************************/
578 * @brief QueryTable filtering function
580 _querytable_filter: function(oSettings, aData, iDataIndex)
583 $.each (this.filters, function(index, filter) {
584 /* XXX How to manage checkbox ? */
587 var value = filter[2];
589 /* Determine index of key in the table columns */
590 var col = $.map(oSettings.aoColumns, function(x, i) {if (x.sTitle == key) return i;})[0];
592 /* Unknown key: no filtering */
593 if (typeof(col) == 'undefined')
596 col_value=unfold.get_value(aData[col]);
597 /* Test whether current filter is compatible with the column */
598 if (op == '=' || op == '==') {
599 if ( col_value != value || col_value==null || col_value=="" || col_value=="n/a")
601 }else if (op == '!=') {
602 if ( col_value == value || col_value==null || col_value=="" || col_value=="n/a")
605 if ( parseFloat(col_value) >= value || col_value==null || col_value=="" || col_value=="n/a")
608 if ( parseFloat(col_value) <= value || col_value==null || col_value=="" || col_value=="n/a")
610 } else if(op=='<=' || op=='≤') {
611 if ( parseFloat(col_value) > value || col_value==null || col_value=="" || col_value=="n/a")
613 } else if(op=='>=' || op=='≥') {
614 if ( parseFloat(col_value) < value || col_value==null || col_value=="" || col_value=="n/a")
617 // How to break out of a loop ?
618 alert("filter not supported");
626 _querytable_draw_callback: function()
629 * Handle clicks on checkboxes: reassociate checkbox click every time
630 * the table is redrawn
632 this.elts('querytable-checkbox').unbind('click').click(this, this._check_click);
633 //alert("fvf_add: "+fvf_add);
635 $("#addflowspaceform").unbind('click').click(this, this.fnAddflowspace);
638 $("[id='addflowspaceform'").unbind('click').click(this, this.fnModflowspace);
640 $("#cancel_addflowspaceform").unbind('click').click(this,this.fnCancel);
645 /* Remove pagination if we show only a few results */
646 var wrapper = this.table; //.parent().parent().parent();
647 var rowsPerPage = this.table.fnSettings()._iDisplayLength;
648 var rowsToShow = this.table.fnSettings().fnRecordsDisplay();
649 var minRowsPerPage = this.table.fnSettings().aLengthMenu[0];
651 if ( rowsToShow <= rowsPerPage || rowsPerPage == -1 ) {
652 $('.querytable_paginate', wrapper).css('visibility', 'hidden');
654 $('.querytable_paginate', wrapper).css('visibility', 'visible');
657 if ( rowsToShow <= minRowsPerPage ) {
658 $('.querytable_length', wrapper).css('visibility', 'hidden');
660 $('.querytable_length', wrapper).css('visibility', 'visible');
667 _check_click: function(e)
674 // this.id = key of object to be added... what about multiple keys ?
675 if (debug) messages.debug("querytable._check_click key="+this.canonical_key+"->"+id+" checked="+this.checked);
676 //manifold.raise_event(self.options.query_uuid, this.checked?SET_ADD:SET_REMOVED, id);
677 //return false; // prevent checkbox to be checked, waiting response from manifold plugin api
681 _selectAll: function()
683 // requires jQuery id
684 var uuid=this.id.split("-");
685 var oTable=$("#querytable-"+uuid[1]).dataTable();
686 // Function available in QueryTable 1.9.x
687 // Filter : displayed data only
688 var filterData = oTable._('tr', {"filter":"applied"});
689 /* TODO: WARNING if too many nodes selected, use filters to reduce nuber of nodes */
690 if(filterData.length<=100){
691 $.each(filterData, function(index, obj) {
692 var last=$(obj).last();
693 var key_value=unfold.get_value(last[0]);
694 if(typeof($(last[0]).attr('checked'))=="undefined"){
695 $.publish('selected', 'add/'+key_value);
703 $.plugin('UnivbrisFvf', UnivbrisFvf);
705 /* define the 'dom-checkbox' type for sorting in datatables
706 http://datatables.net/examples/plug-ins/dom_sort.html
707 using trial and error I found that the actual column number
708 was in fact given as a third argument, and not second
709 as the various online resources had it - go figure */
710 $.fn.dataTableExt.afnSortData['dom-checkbox'] = function ( oSettings, _, iColumn ) {
711 return $.map( oSettings.oApi._fnGetTrNodes(oSettings), function (tr, i) {
712 return result=$('td:eq('+iColumn+') input', tr).prop('checked') ? '1' : '0';
721 function fnPopTable(e){
723 //this.table = $("#univbris_flowspace_selection__table").dataTable();
725 /**var rows = $("#univbris_flowspace_selection__table").dataTable().fnGetNodes();
726 for(var i=0;i<rows.length;i++)
728 alert($(rows[i]).find("td:eq(0)").html());
733 //var anSelected = fnGetSelected( this.table );
734 //var iRow = oTable.fnGetPosition( anSelected[0] );
737 //var rowIndex = this.table.fnGetPosition( $(this).closest('tr')[0]);
739 $("[id='addflowspaceform']").hide();
740 $("#uob_fv_table_form :input").prop("disabled", false);
741 $("#uob_fv_table_form").deserialize(e);
742 $("[name='flowspace_name']").prop("disabled", true)
743 $("#uob_fv_table_form :input").prop("disabled", true);
744 $("[id='cancel_addflowspaceform']").prop("disabled", false);
745 $("[id='cancel_addflowspaceform']").text('close');
746 //$("[id='addflowspaceform'").hide();
747 jQuery("#univbris_flowspace_selection").hide();
748 jQuery("#uob_fv_table_form").show();
753 function fnGetSelected( oTableLocal )
755 var aReturn = new Array();
756 var aTrs = oTableLocal.fnGetNodes();
758 for ( var i=0 ; i<aTrs.length ; i++ )
760 if ( $(aTrs[i]).hasClass('row_selected') )
762 aReturn.push( aTrs[i] );
768 function serializeAnything (form){
770 var els = $(form).find(':input').get();
772 $.each(els, function() {
773 if (this.name && (this.checked || /select|textarea/i.test(this.nodeName) || /text|hidden|password/i.test(this.type))) {
774 var val = $(this).val();
775 toReturn.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( val ) );
779 return toReturn.join("&").replace(/%20/g, "+");
786 deserialize : function (d, config) {
790 $currentSavedValue = null,
793 keyValPairString = [],
794 keyValPairObject = {},
798 if (d === undefined || !$self.is('form')) {
806 config = $.extend(defaults, config);
808 if (d.constructor === String) {
811 d = decodeURIComponent(d.replace(/\+/g, " "));
813 keyValPairString = d.split('&');
815 for (i = 0; i < keyValPairString.length; i++) {
816 tmp = keyValPairString[i].split('=');
817 keyValPairObject[tmp[0]] = tmp[1];
822 $('input, select, textarea', $self).each(function (i) {
825 currentDom = $current.get(0);
826 $currentSavedValue = keyValPairObject[$current.attr('name')];
828 if (currentDom.disabled === true) {
829 //current.val($currentSavedValue);
833 if ($current.is('textarea')) {
834 if ($currentSavedValue === undefined) {
837 $current.val($currentSavedValue);
842 if ($current.is('select')) {
843 if ($currentSavedValue === undefined) {
846 currentDom.selectedIndex = $currentSavedValue;
851 if ($current.is('input:radio')) {
852 if ($currentSavedValue !== undefined) {
854 $current.each(function () {
855 if ($(this).val() === $currentSavedValue) {
856 $(this).get(0).checked = true;
864 if ($current.is('input:checkbox')) {
865 currentDom.checked = ($current.val() === $currentSavedValue);
869 if ($current.is('input:text, input:hidden')) {
870 if ($currentSavedValue === undefined) {
873 $current.val($currentSavedValue);