From 9f876b78de91694b4bfdf444da2fddad6ebe4c04 Mon Sep 17 00:00:00 2001 From: abijah Date: Mon, 15 Jun 2009 00:13:57 +0000 Subject: [PATCH] I apparently forgot to check the pmgr_jqGrid.js file in a few checkins ago, meaning those revisions are all broken. This is finally the checkin to include it. git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@125 97e9348a-65ac-dc4b-aefc-98561f571b83 --- site/webroot/js/pmgr_jqGrid.js | 91 ++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 site/webroot/js/pmgr_jqGrid.js diff --git a/site/webroot/js/pmgr_jqGrid.js b/site/webroot/js/pmgr_jqGrid.js new file mode 100644 index 0000000..e5021a2 --- /dev/null +++ b/site/webroot/js/pmgr_jqGrid.js @@ -0,0 +1,91 @@ +function gridRestore(grid_id) { +// $('#debug').append("RESTORE
"); + $('.filt-text-'+grid_id).val(''); + jQuery('#'+grid_id).removePostDataItem('filt'); + jQuery('#'+grid_id).removePostDataItem('filtField'); + jQuery('#'+grid_id).removePostDataItem('filtValue'); + jQuery('#'+grid_id) + .setGridParam({ page: 1 }) + .trigger("reloadGrid"); +} + + +function gridFilter(field_id) { + var grid_id = $("#"+field_id).attr('filt-grid'); + var field = $("#"+field_id).attr('filt-index'); + var value = $("#"+field_id).val(); + + // Make sure we're not issuing blank queries. + // It will work without observable effect, but + // it will result in slower queries. Just + // clear out all filter terms instead. + if (value == '') { + gridRestore(grid_id); + return; + } + +// $('#debug').append("RELOAD: field_id:"+field_id+"; grid:"+grid_id+"; field:"+field+"; value:"+value+"
"); + jQuery('#'+grid_id).setPostDataItem('filt', true); + jQuery('#'+grid_id).setPostDataItem('filtField', field); + jQuery('#'+grid_id).setPostDataItem('filtValue', value); + + $('.filt-text-'+grid_id).each(function(){ + if ($(this).attr('id') != field_id) + $(this).val(''); + }); + + jQuery('#'+grid_id) + .setGridParam({ page: 1 }) + .trigger("reloadGrid"); +} + + +var timeoutHnd; +function handleFiltKeydown(e){ + var field_id = $(this).attr('id'); + if (e.which == 8 || e.which >= 32) /* backspace OR printable */ + { +// $('#debug').append("KEYDOWN: id:"+field_id+"
"); + if(timeoutHnd) + clearTimeout(timeoutHnd); + timeoutHnd = setTimeout(function() + {gridFilter(field_id)}, + 500); + } + else + handleFiltReturn(e); +} + +function handleFiltReturn(e) { + var field_id = $(this).attr('id'); + if (e.which == 10 || e.which == 13) { +// $('#debug').append("KEYDOWN: id:"+field_id+" CHAR 10/13
"); + if(timeoutHnd) + clearTimeout(timeoutHnd); + gridFilter(field_id); + } +} + + +function enableAutosubmit(state) { + $(".filt-submit").attr("disabled",state); + $('.filt-autosearch').attr('checked', state); + if (state) { + $(".filt-text").unbind('keydown', handleFiltReturn); + $(".filt-text").keydown(handleFiltKeydown); +// $('#debug').append("BIND: id:"+id+"
"); + } + else { + $(".filt-text").unbind('keydown', handleFiltKeydown); + $(".filt-text").keydown(handleFiltReturn); +// $('#debug').append("UNBIND: id:"+id+"
"); + } +} + + +jQuery(document).ready(function(){ + $('.filt-submit').click(function(){ + gridFilter($(this).attr('id').replace(/^submit_/, 'filt_')); + }); + enableAutosubmit(true); + });