code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
<div> This example show a online editing and saving row. This is done when the user click on some row.<br> Note the use of a second parameter of editRow method. This way when we press Enter data is saved<br> to the server and when we press ESC key the editing is canceled. </div> <br /> <table id="rowed3" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="prowed3" class="scroll" style="text-align:center;"></div> <br /> <script src="rowedex3.js" type="text/javascript"> </script> <br /> <br /> <b> HTML </b> <XMP> ... <table id="rowed3" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="prowed3" class="scroll" style="text-align:center;"></div> <br /> <script src="rowedex3.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... var lastsel; jQuery("#rowed3").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90, editable:true}, {name:'name',index:'name', width:100,editable:true}, {name:'amount',index:'amount', width:80, align:"right",editable:true}, {name:'tax',index:'tax', width:80, align:"right",editable:true}, {name:'total',index:'total', width:80,align:"right",editable:true}, {name:'note',index:'note', width:150, sortable:false,editable:true} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#prowed3'), sortname: 'id', viewrecords: true, sortorder: "desc", onSelectRow: function(id){ if(id && id!==lastsel){ jQuery('#rowed3').restoreRow(lastsel); jQuery('#rowed3').editRow(id,true); lastsel=id; } }, editurl: "server.php", caption: "Using events example" }).navGrid("#prowed3",{edit:false,add:false,del:false}); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo json_encode($responce); ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/rowedex3.html
HTML
gpl2
3,437
<div> This example show how we can add dialog for data editing.<br/> See below for all available options. <br/> Note: The data is not saved to the server<br/> </div> <br /> <table id="editgrid" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pagered" class="scroll" style="text-align:center;"></div> <input type="BUTTON" id="bedata" value="Edit Selected" /> <script src="editing.js" type="text/javascript"> </script> <br /><br /> <b> Description </b> <br /> This method uses <b>colModel</b> and <b>editurl</b> parameters from jqGrid <br/> <code> Calling: jQuery("#grid_id").editGridRow( the_row_id, options ); </code> <br/> <b>the_row_id</b> is the row to edit <br/> <b> options </b> <br/> <b>top : 0</b> the initial top position of edit dialog<br/> <b>left: 0</b> the initinal left position of edit dialog<br/> If the left and top positions are not set the dialog apper on<br/> upper left corner of the grid <br/> <b>width: 0</b>, the width of edit dialog - default 300<br/> <b>height: 0</b>, the height of edit dialog default 200<br/> <b>modal: false</b>, determine if the dialog should be in modal mode default is false<br/> <b>drag: true</b>,determine if the dialog is dragable default true<br/> <b>addCaption: "Add Record"</b>,the caption of the dialog if the mode is adding<br/> <b>editCaption: "Edit Record"</b>,the caption of the dialog if the mode is editing<br/> <b>bSubmit: "Submit"</b>, the text of the button when you click to data default Submit<br/> <b>bCancel: "Cancel"</b>,the text of the button when you click to close dialog default Cancel<br/> <b>url: </b>, url where to post data. If set replace the editurl <br/> <b>processData: "Processing..."</b>, Indicator when posting data<br/> <b>closeAfterAdd : false</b>, when add mode closes the dialog after add record - default false<br/> <b>clearAfterAdd : true</b>, when add mode clears the data after adding data - default true<br/> <b>closeAfterEdit : false</b>, when in edit mode closes the dialog after editing - default false<br/> <b>reloadAfterSubmit : true</b> reloads grid data after posting default is true <br/> // <i>Events</i> <br/> <b>intializeForm: null</b> fires only once when creating the data for editing and adding.<br/> Paramter passed to the event is the id of the constructed form.<br/> <b>beforeInitData: null</b> fires before initialize the form data.<br/> Paramter passed to the event is the id of the constructed form.<br/> <b>beforeShowForm: null</b> fires before showing the form data.<br/> Paramter passed to the event is the id of the constructed form.<br/> <b>afterShowForm: null</b> fires after the form is shown.<br/> Paramter passed to the event is the id of the constructed form.<br/> <b>beforeSubmit: null</b> fires before the data is submitted to the server<br/> Paramter is array of type name:value. When called the event can return array <br/> where the first parameter can be true or false and the second is the message of the error if any<br/> Example: [false,"The value is not valid"]<br/> <b>afterSubmit: null</b> fires after the data is posted to the server. Typical this <br/> event is used to recieve status form server if the data is posted with success.<br/> Parameters to this event are the returned data from the request and array of the<br/> posted values of type name:value<br/> <br/> <b> HTML </b> <XMP> ... <<table id="editgrid" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pagered" class="scroll" style="text-align:center;"></div> <input type="BUTTON" id="bedata" value="Edit Selected" /> </XMP> <b>Java Scrpt code</b> <XMP> jQuery("#editgrid").jqGrid({ url:'editing.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Closed','Ship via','Notes'], colModel:[ {name:'id',index:'id', width:55,editable:false,editoptions:{readonly:true,size:10}}, {name:'invdate',index:'invdate', width:80,editable:true,editoptions:{size:10}}, {name:'name',index:'name', width:90,editable:true,editoptions:{size:25}}, {name:'amount',index:'amount', width:60, align:"right",editable:true,editoptions:{size:10}}, {name:'tax',index:'tax', width:60, align:"right",editable:true,editoptions:{size:10}}, {name:'total',index:'total', width:60,align:"right",editable:true,editoptions:{size:10}}, {name:'closed',index:'closed',width:55,align:'center',editable:true,edittype:"checkbox",editoptions:{value:"Yes:No"}}, {name:'ship_via',index:'ship_via',width:70, editable: true,edittype:"select",editoptions:{value:"FE:FedEx;TN:TNT"}}, {name:'note',index:'note', width:100, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"20"}} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pagered'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Editing Example", editurl:"someurl.php" }); $("#bedata").click(function(){ var gr = jQuery("#editgrid").getGridParam('selrow'); if( gr != null ) jQuery("#editgrid").editGridRow(gr,{height:280,reloadAfterSubmit:false}); else alert("Please Select Row"); }); </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/editing.html
HTML
gpl2
5,263
var lastsel3; jQuery("#rowed6").jqGrid({ datatype: "local", height: 250, colNames:['ID Number','Last Sales','Name', 'Stock', 'Ship via','Notes'], colModel:[ {name:'id',index:'id', width:90, sorttype:"int", editable: true}, {name:'sdate',index:'sdate',width:90, editable:true, sorttype:"date"}, {name:'name',index:'name', width:150,editable: true,editoptions:{size:"20",maxlength:"30"}}, {name:'stock',index:'stock', width:60, editable: true,edittype:"checkbox",editoptions: {value:"Yes:No"}}, {name:'ship',index:'ship', width:90, editable: true,edittype:"select",editoptions:{value:"FE:FedEx;IN:InTime;TN:TNT;AR:ARAMEX"}}, {name:'note',index:'note', width:200, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"10"}} ], imgpath: gridimgpath, onSelectRow: function(id){ if(id && id!==lastsel3){ jQuery('#rowed6').restoreRow(lastsel3); jQuery('#rowed6').editRow(id,true,pickdates); lastsel3=id; } }, editurl: "server.php", caption: "Date Picker Integration" }); var mydata3 = [ {id:"12345",name:"Desktop Computer",note:"note",stock:"Yes",ship:"FedEx", sdate:"2007-12-03"}, {id:"23456",name:"Laptop",note:"Long text ",stock:"Yes",ship:"InTime",sdate:"2007-12-03"}, {id:"34567",name:"LCD Monitor",note:"note3",stock:"Yes",ship:"TNT",sdate:"2007-12-03"}, {id:"45678",name:"Speakers",note:"note",stock:"No",ship:"ARAMEX",sdate:"2007-12-03"}, {id:"56789",name:"Laser Printer",note:"note2",stock:"Yes",ship:"FedEx",sdate:"2007-12-03"}, {id:"67890",name:"Play Station",note:"note3",stock:"No", ship:"FedEx",sdate:"2007-12-03"}, {id:"76543",name:"Mobile Telephone",note:"note",stock:"Yes",ship:"ARAMEX",sdate:"2007-12-03"}, {id:"87654",name:"Server",note:"note2",stock:"Yes",ship:"TNT",sdate:"2007-12-03"}, {id:"98765",name:"Matrix Printer",note:"note3",stock:"No", ship:"FedEx",sdate:"2007-12-03"} ]; for(var i=0;i<mydata3.length;i++) jQuery("#rowed6").addRowData(mydata3[i].id,mydata3[i]); function pickdates(id){ jQuery("#"+id+"_sdate","#rowed6").datepicker({dateFormat:"yy-mm-dd"}); }
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/calen.js
JavaScript
gpl2
2,145
<p style="font-size:12px;"> This sample demonstrates how jqGrid works with large amount of data.<br> We have put into a table in a Mysql database about 12.000 records filled with random words. jqGrid, using Ajax, loads only those records, that are visible.<br> If you want to make a search (just enter some word into input fields), grid sends search criteria to server and loads only data that correspond to entered criteria.<br> Speed is increased about 2 times if we index the column. In this case this is column Code<br> <i>Important: sample is working with real data - <b>12.000</b> records! Enjoy it's performance</i> <br /> <div class="h">Search By:</div> <div> Code<br /> <input type="text" id="search_cd" onkeydown="doSearch(arguments[0]||event)" /> <input type="checkbox" id="autosearch" onclick="enableAutosubmit(this.checked)"> Enable Autosearch <br/> </div> <div> Name<br> <input type="text" id="item_nm" onkeydown="doSearch(arguments[0]||event)" /> <button onclick="gridReload()" id="submitButton" style="margin-left:30px;">Search</button> </div> <br /> <table id="bigset" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pagerb" class="scroll" style="text-align:center;"></div> <script src="bigset.js" type="text/javascript"> </script> <br /> <b> HTML </b> <XMP> ... <div class="h">Search By:</div> <div> <input type="checkbox" id="autosearch" onclick="enableAutosubmit(this.checked)"> Enable Autosearch <br/> Code<br /> <input type="text" id="search_cd" onkeydown="doSearch(arguments[0]||event)" /> </div> <div> Name<br> <input type="text" id="item" onkeydown="doSearch(arguments[0]||event)" /> <button onclick="gridReload()" id="submitButton" style="margin-left:30px;">Search</button> </div> <br /> <table id="bigset" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pagerb" class="scroll" style="text-align:center;"></div> <script src="bigset.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> jQuery("#bigset").jqGrid({ url:'bigset.php', datatype: "json", height: 255, colNames:['Index','Name', 'Code'], colModel:[ {name:'item_id',index:'item_id', width:65}, {name:'item',index:'item', width:150}, {name:'item_cd',index:'item_cd', width:100} ], rowNum:12, // rowList:[10,20,30], imgpath: gridimgpath, mtype: "POST", pager: jQuery('#pagerb'), sortname: 'item_id', viewrecords: true, sortorder: "asc" }); var timeoutHnd; var flAuto = false; function doSearch(ev){ if(!flAuto) return; // var elem = ev.target||ev.srcElement; if(timeoutHnd) clearTimeout(timeoutHnd) timeoutHnd = setTimeout(gridReload,500) } function gridReload(){ var nm_mask = jQuery("#item_nm").val(); var cd_mask = jQuery("#search_cd").val(); jQuery("#bigset").setGridParam({url:"bigset.php?nm_mask="+nm_mask+"&cd_mask="+cd_mask,page:1}).trigger("reloadGrid"); } function enableAutosubmit(state){ flAuto = state; jQuery("#submitButton").attr("disabled",state); } </XMP> <b>PHP with MySQL (bigset.php)</b> <XMP> <?php ini_set('max_execution_time', 600); include("dbconfig.php"); // coment the above lines if php 5 include("JSON.php"); $json = new Services_JSON(); // end comment $examp = $_GET["q"]; //query number $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; if(isset($_GET["nm_mask"])) $nm_mask = $_GET['nm_mask']; else $nm_mask = ""; if(isset($_GET["cd_mask"])) $cd_mask = $_GET['cd_mask']; else $cd_mask = ""; //construct where clause $where = "WHERE 1=1"; if($nm_mask!='') $where.= " AND item LIKE '$nm_mask%'"; if($cd_mask!='') $where.= " AND item_cd LIKE '$cd_mask%'"; // connect to the database $db = mysql_pconnect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM items ".$where); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; if ($limit<0) $limit = 0; $start = $limit*$page - $limit; // do not put $limit*($page - 1) if ($start<0) $start = 0; $SQL = "SELECT item_id, item, item_cd FROM items ".$where." ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn’t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[item_id]; $responce->rows[$i]['cell']=array($row[item_id],$row[item],$row[item_cd]); $i++; } echo $json->encode($responce); // coment if php 5 //echo json_encode($responce); mysql_close($db); ?> </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/bigset.html
HTML
gpl2
5,145
jQuery("#params").jqGrid({ url:'server.php', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pparams'), sortname: 'id', mtype: "POST", postData:{q:1}, viewrecords: true, sortorder: "desc", caption:"New Methods" }).navGrid('#pparams',{edit:false,add:false,del:false}); jQuery("#pp1").click( function() { $.extend($.jgrid.defaults,{recordtext: "Record(s)",loadtext: "Processing"}); alert("New parameters are set - reopen the grid"); });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/defparams.js
JavaScript
gpl2
1,022
jQuery("#search").jqGrid({ url:'server.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pagersr'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Search Example", editurl:"someurl.php" }); $("#bsdata").click(function(){ jQuery("#search").searchGrid( {sopt:['cn','bw','eq','ne','lt','gt','ew']} ); });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/searching.js
JavaScript
gpl2
913
jQuery("#treegrid").jqGrid({ url: 'server.php?q=tree', treedatatype: "xml", mtype: "POST", colNames:["id","Account","Acc Num", "Debit", "Credit","Balance"], colModel:[ {name:'id',index:'id', width:1,hidden:true,key:true}, {name:'name',index:'name', width:180}, {name:'num',index:'acc_num', width:80, align:"center"}, {name:'debit',index:'debit', width:80, align:"right"}, {name:'credit',index:'credit', width:80,align:"right"}, {name:'balance',index:'balance', width:80,align:"right"} ], height:'auto', pager : jQuery("#ptreegrid"), imgpath: gridimgpath, treeGrid: true, ExpandColumn : 'name', caption: "Treegrid example" });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/treegrid.js
JavaScript
gpl2
712
jQuery("#listdt").jqGrid({ //url:'server.php?q=2', datatype : function (pdata) { $.ajax({ url:'server.php?q=2', data:pdata, dataType:"json", complete: function(jsondata,stat){ if(stat=="success") { var thegrid = jQuery("#listdt")[0]; thegrid.addJSONData(eval("("+jsondata.responseText+")")) } } }); }, colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right", editable:true,editrules:{number:true,minValue:100,maxValue:350}}, {name:'tax',index:'tax', width:80, align:"right",editable:true,edittype:"select",editoptions:{value:"IN:InTime;TN:TNT;AR:ARAMEX"}}, {name:'total',index:'total', width:80,align:"right",editable: true,edittype:"checkbox",editoptions: {value:"Yes:No"} }, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pagerdt'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Data type as function Example", cellEdit: true }).navGrid('#pagerdt',{edit:false,add:false,del:false});
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/datatype.js
JavaScript
gpl2
1,368
jQuery("#list9").jqGrid({ url:'server.php?q=2&nd='+new Date().getTime(), datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pager9'), sortname: 'id', viewrecords: true, sortorder: "desc", multiselect: true, caption: "Multi Select Example" }).navGrid('#pager9',{add:false,del:false,edit:false,position:"right"}); jQuery("#m1").click( function() { var s; s = jQuery("#list9").getGridParam('selarrrow'); alert(s); }); jQuery("#m1s").click( function() { jQuery("#list9").setSelection("13"); });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/multiex.js
JavaScript
gpl2
1,067
var lastsel; jQuery("#rowed3").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90, editable:true}, {name:'name',index:'name', width:100,editable:true}, {name:'amount',index:'amount', width:80, align:"right",editable:true}, {name:'tax',index:'tax', width:80, align:"right",editable:true}, {name:'total',index:'total', width:80,align:"right",editable:true}, {name:'note',index:'note', width:150, sortable:false,editable:true} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#prowed3'), sortname: 'id', viewrecords: true, sortorder: "desc", onSelectRow: function(id){ if(id && id!==lastsel){ jQuery('#rowed3').restoreRow(lastsel); jQuery('#rowed3').editRow(id,true); lastsel=id; } }, editurl: "server.php", caption: "Using events example" }).navGrid("#prowed3",{edit:false,add:false,del:false});
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/rowedex3.js
JavaScript
gpl2
1,105
<div> This example show the new feature of jqGrid forceFit. Try to resize a column. <br> We can see that the adjacent column (to the right) resizes so that the overall grid width is maintained <br> Again with this we can set the width and height dynamically. <br> Another feature here is that we can apply a sort to a certain column instead of clicking on <br> another one. Click on date colummn. The sort is not by date, but of client name. </div> <br /> <table id="gwidth" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pgwidth" class="scroll" style="text-align:center;"></div> <br/> <input id="setwidth" type="text" /><input type="button" id="snw" value="Set New Width"/> <br/> <input id="setheight" type="text" /><input type="button" id="snh" value="Set New Height"/> <script src="gridwidth.js" type="text/javascript"> </script> <br /> <b> HTML </b> <XMP> ... <table id="gwidth" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pgwidth" class="scroll" style="text-align:center;"></div> <br/> <input id="setwidth" type="text" /><input type="button" id="snw" value="Set New Width"/> <br/> <input id="setheight" type="text" /><input type="button" id="snh" value="Set New Height"/> <script src="gridwidth.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#gwidth").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pgwidth'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Dynamic height/width Example", forceFit : true, onSortCol :function (nm,index) { if (nm=='invdate') { jQuery("#gwidth").setGridParam({sortname:'name'}); } } }).navGrid('#pgwidth',{edit:false,add:false,del:false}); jQuery("#snw").click(function (){ var nw = parseInt(jQuery("#setwidth").val()); if(isNaN(nw)) { alert("Value must be a number"); } else if (nw<200 || nw > 700) { alert("Value can be between 200 and 700") } else { jQuery("#gwidth").setGridWidth(nw); } }); jQuery("#snh").click(function (){ var nh = jQuery("#setheight").val(); jQuery("#gwidth").setGridHeight(nh); }); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo json_encode($responce); ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/gridwidth.html
HTML
gpl2
4,256
jQuery("#rowed1").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90, editable:true}, {name:'name',index:'name', width:100,editable:true}, {name:'amount',index:'amount', width:80, align:"right",editable:true}, {name:'tax',index:'tax', width:80, align:"right",editable:true}, {name:'total',index:'total', width:80,align:"right",editable:true}, {name:'note',index:'note', width:150, sortable:false,editable:true} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#prowed1'), sortname: 'id', viewrecords: true, sortorder: "desc", editurl: "server.php", caption: "Basic Example" }).navGrid("#prowed1",{edit:false,add:false,del:false}); jQuery("#ed1").click( function() { jQuery("#rowed1").editRow("13"); this.disabled = 'true'; jQuery("#sved1,#cned1").attr("disabled",false); }); jQuery("#sved1").click( function() { jQuery("#rowed1").saveRow("13"); jQuery("#sved1,#cned1").attr("disabled",true); jQuery("#ed1").attr("disabled",false); }); jQuery("#cned1").click( function() { jQuery("#rowed1").restoreRow("13"); jQuery("#sved1,#cned1").attr("disabled",true); jQuery("#ed1").attr("disabled",false); });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/rowedex1.js
JavaScript
gpl2
1,412
<div> This example accepting json data in the format of type:<br> { total: xxx, page: yyy, records: zzz, rows: [ <br> {name1:”Row01″,name2:”Row 11″,name3:”Row 12″,name4:”Row 13″,name5:”Row 14″}, <br> ...<br> Note the MySQL PHP code. </div> <br /> <table id="jsonmap" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pjmap" class="scroll" style="text-align:center;"></div> <script src="jsonmap.js" type="text/javascript"> </script> <br /> <b> HTML </b> <XMP> ... <table id="jsonmap" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pjmap" class="scroll" style="text-align:center;"></div> <script src="jsonmap.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#jsonmap").jqGrid({ url:'server.php?q=4', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90, jsonmap:"invdate"}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pjmap'), sortname: 'id', viewrecords: true, sortorder: "desc", jsonReader: { repeatitems : false, id: "0" }, caption: "JSON Mapping", height: '100%' }).navGrid('#pjmap',{edit:false,add:false,del:false}); </XMP> <b>PHP with MySQL</b> <XMP> ... $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) if ($start<0) $start = 0; $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn’t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]=$row; $i++; } echo $json->encode($responce); // coment if php 5 break; ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/jsonmap.html
HTML
gpl2
2,750
jQuery("#gwidth").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pgwidth'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Dynamic height/width Example", forceFit : true, onSortCol :function (nm,index) { if (nm=='invdate') { jQuery("#gwidth").setGridParam({sortname:'name'}); } }, onHeaderClick: function (status){ alert("My status is now: "+ status); } }).navGrid('#pgwidth',{edit:false,add:false,del:false}); jQuery("#snw").click(function (){ var nw = parseInt(jQuery("#setwidth").val()); if(isNaN(nw)) { alert("Value must be a number"); } else if (nw<200 || nw > 700) { alert("Value can be between 200 and 700") } else { jQuery("#gwidth").setGridWidth(nw); } }); jQuery("#snh").click(function (){ var nh = jQuery("#setheight").val(); jQuery("#gwidth").setGridHeight(nh); });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/gridwidth.js
JavaScript
gpl2
1,457
jQuery("#list6").jqGrid({ url:'server.php?q=2&nd='+new Date().getTime(), datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, //rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pager6'), sortname: 'id', viewrecords: true, sortorder: "desc", onSortCol: function(name,index){ alert("Column Name: "+name+" Column Index: "+index);}, ondblClickRow: function(id){ alert("You double click row with id: "+id);}, caption:" Get Methods", height: 200 }); jQuery("#list6").navGrid("#pager6",{edit:false,add:false,del:false});
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/getex.js
JavaScript
gpl2
1,040
jQuery("#loaderr").jqGrid({ url:'server_bad.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#ploaderr'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Server Errors", loadError : function(xhr,st,err) { jQuery("#rsperror").html("Type: "+st+"; Response: "+ xhr.status + " "+xhr.statusText); } }).navGrid('#pmethod',{edit:false,add:false,del:false});
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/loaderror.js
JavaScript
gpl2
965
<div> We can have a full control on what is done at server side when we save the data. <br> It is well known that the post can be successful, but the same saving to the database can be not.<br> To control that we can use a callback function when data is saving to the server.<br> The function accept one parameter - data returned from the server. Depending on this data<br> the function should return true or false. When true this means the saving is done and false othewise.<br> In our case the save is missing, since the server return nothing. </div> <br /> <table id="rowed4" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="prowed4" class="scroll" style="text-align:center;"></div> <br /> <input type="BUTTON" id="ed4" value="Edit row 13" /> <input type="BUTTON" id="sved4" disabled='true' value="Save row 13" /> <script src="rowedex4.js" type="text/javascript"> </script> <br /> <br /> <b> HTML </b> <XMP> ... <table id="rowed4" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="prowed4" class="scroll" style="text-align:center;"></div> <br /> <input type="BUTTON" id="ed4" value="Edit row 13" /> <input type="BUTTON" id="sved4" disabled='true' value="Save row 13" /> <script src="rowedex4.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#rowed4").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90, editable:true}, {name:'name',index:'name', width:100,editable:true}, {name:'amount',index:'amount', width:80, align:"right",editable:true}, {name:'tax',index:'tax', width:80, align:"right",editable:true}, {name:'total',index:'total', width:80,align:"right",editable:true}, {name:'note',index:'note', width:150, sortable:false,editable:true} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#prowed4'), sortname: 'id', viewrecords: true, sortorder: "desc", editurl: "server.php", caption: "Full control" }); jQuery("#ed4").click( function() { jQuery("#rowed4").editRow("13"); this.disabled = 'true'; jQuery("#sved4").attr("disabled",false); }); jQuery("#sved4").click( function() { jQuery("#rowed4").saveRow("13", checksave); jQuery("#sved4").attr("disabled",true); jQuery("#ed4").attr("disabled",false); }); function checksave(result) { if (result=="") {alert("Update is missing!"); return false;} return true; } </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo json_encode($responce); ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/rowedex4.html
HTML
gpl2
4,153
jQuery("#ainsrow").jqGrid({ url:'server.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#painsrow'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"After insert row event", multiselect: true, afterInsertRow: function(rowid, aData){ switch (aData.name) { case 'Client 1': jQuery("#ainsrow").setCell(rowid,'total','',{color:'green'}); break; case 'Client 2': jQuery("#ainsrow").setCell(rowid,'total','',{color:'red'}); break; case 'Client 3': jQuery("#ainsrow").setCell(rowid,'total','',{color:'blue'}); break; } } }).navGrid('#painsrow',{edit:false,add:false,del:false});
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/afterinsrow.js
JavaScript
gpl2
1,272
<div> This example demonstartes constructing of two grids and how we <br> can realize master detail.Try to click row on Invoice Header. </div> <br /> <table id="list10" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager10" class="scroll" style="text-align:center;"></div> <br /> <table id="list10_d" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager10_d" class="scroll" style="text-align:center;"></div> <a href="javascript:void(0)" id="ms1">Get Selected id's</a> <script src="masterex.js" type="text/javascript"> </script> <br /> <br /> <b> HTML </b> <XMP> ... Invoice Header <table id="list10" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager10" class="scroll" style="text-align:center;"></div> <br /> Invoice Detail <table id="list10_d" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager10_d" class="scroll" style="text-align:center;"></div> <a href="javascript:void(0)" id="ms1">Get Selected id's</a> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#list10").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pager10'), sortname: 'id', viewrecords: true, sortorder: "desc", multiselect: false, caption: "Invoice Header", onSelectRow: function(ids) { if(ids == null) { ids=0; if(jQuery("#list10_d").getGridParam('records') >0 ) { jQuery("#list10_d").setGridParam({url:"subgrid.php?q=1&id="+ids,page:1}) .setCaption("Invoice Detail: "+ids) .trigger('reloadGrid'); } } else { jQuery("#list10_d").setGridParam({url:"subgrid.php?q=1&id="+ids,page:1}) .setCaption("Invoice Detail: "+ids) .trigger('reloadGrid'); } } }).navGrid('#pager10',{add:false,edit:false,del:false}); jQuery("#list10_d").jqGrid({ height: 100, url:'subgrid.php?q=1&id=0', datatype: "json", colNames:['No','Item', 'Qty', 'Unit','Line Total'], colModel:[ {name:'num',index:'num', width:55}, {name:'item',index:'item', width:180}, {name:'qty',index:'qty', width:80, align:"right"}, {name:'unit',index:'unit', width:80, align:"right"}, {name:'linetotal',index:'linetotal', width:80,align:"right", sortable:false, search:false} ], rowNum:5, rowList:[5,10,20], imgpath: gridimgpath, pager: jQuery('#pager10_d'), sortname: 'item', viewrecords: true, sortorder: "asc", multiselect: true, caption:"Invoice Detail" }).navGrid('#pager10_d',{add:false,edit:false,del:false}); jQuery("#ms1").click( function() { var s; s = jQuery("#list10_d").getMultiRow(); alert(s); }); </XMP> <b>PHP with MySQL Master</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo json_encode($responce); ... </XMP> <b>PHP with MySQL Detail</b> <XMP> ... <?php include("dbconfig.php"); $examp = $_GET["q"]; //query number $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction $id = $_GET['id']; if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); switch ($examp) { case 1: $result = mysql_query("SELECT COUNT(*) AS count FROM invlines WHERE id=".$id); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) if ($start<0) $start = 0; $SQL = "SELECT num, item, qty, unit FROM invlines WHERE id=".$id." ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn’t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[num]; $responce->rows[$i]['cell']=array($row[num],$row[item],$row[qty],$row[unit],number_format($row[qty]*$row[unit],2,'.',' ')); $i++; } echo json_encode($responce); break; } ?> </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/masterex.html
HTML
gpl2
6,450
<div> This example shows a typical implementation of jqGrid.<br> You can view this in example.html and example.php files included into demo package. Click on the example link to view the result </div> <br /> <b><a href="http://trirand.com/jqgrid/example.html" target="_blank"> example.html</a> </b> <XMP> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jqGrid Demos</title> <!-- In head section we should include the style sheet for the grid --> <link rel="stylesheet" type="text/css" media="screen" href="themes/sand/grid.css" /> <!-- Of course we should load the jquery library --> <script src="js/jquery.js" type="text/javascript"></script> <!-- and at end the jqGrid Java Script file --> <script src="js/jquery.jqGrid.js" type="text/javascript"></script> <script type="text/javascript"> // We use a document ready jquery function. jQuery(document).ready(function(){ jQuery("#list2").jqGrid({ // the url parameter tells from where to get the data from server // adding ?nd='+new Date().getTime() prevent IE caching url:'example.php?nd='+new Date().getTime(), // datatype parameter defines the format of data returned from the server // in this case we use a JSON data datatype: "json", // colNames parameter is a array in which we describe the names // in the columns. This is the text that apper in the head of the grid. colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], // colModel array describes the model of the column. // name is the name of the column, // index is the name passed to the server to sort data // note that we can pass here nubers too. // width is the width of the column // align is the align of the column (default is left) // sortable defines if this column can be sorted (default true) colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], // pager parameter define that we want to use a pager bar // in this case this must be a valid html element. // note that the pager can have a position where you want pager: jQuery('#pager2'), // rowNum parameter describes how many records we want to // view in the grid. We use this in example.php to return // the needed data. rowNum:10, // rowList parameter construct a select box element in the pager //in wich we can change the number of the visible rows rowList:[10,20,30], // path to mage location needed for the grid imgpath: themes/sand/images, // sortname sets the initial sorting column. Can be a name or number. // this parameter is added to the url sortname: 'id', //viewrecords defines the view the total records from the query in the pager //bar. The related tag is: records in xml or json definitions. viewrecords: true, //sets the sorting order. Default is asc. This parameter is added to the url sortorder: "desc", caption: "Demo", }); }); </script> </head> <body> <!-- the grid definition in html is a table tag with class 'scroll' --> <table id="list2" class="scroll" cellpadding="0" cellspacing="0"></table> <!-- pager definition. class scroll tels that we want to use the same theme as grid --> <div id="pager2" class="scroll" style="text-align:center;"></div> </body> </html> </XMP> <b>example.php</b> <XMP> <?php // Include the information needed for the connection to // MySQL data base server. include("dbconfig.php"); //since we want to use a JSON data we should include //encoder and decoder for JSON notation //If you use a php >= 5 this file is not needed include("JSON.php"); // create a JSON service $json = new Services_JSON(); // to the url parameter are added 4 parameter // we shuld get these parameter to construct the needed query // // get the requested page $page = $_GET['page']; // get how many rows we want to have into the grid // rowNum parameter in the grid $limit = $_GET['rows']; // get index row - i.e. user click to sort // at first time sortname parameter - after that the index from colModel $sidx = $_GET['sidx']; // sorting order - at first time sortorder $sord = $_GET['sord']; // if we not pass at first time index use the first column for the index if(!$sidx) $sidx =1; // connect to the MySQL database server $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); // select the database mysql_select_db($database) or die("Error conecting to db."); // calculate the number of rows for the query. We need this to paging the result $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; // calculation of total pages for the query if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } // if for some reasons the requested page is greater than the total // set the requested page to total page if ($page > $total_pages) $page=$total_pages; // calculate the starting position of the rows $start = $limit*$page - $limit; // do not put $limit*($page - 1) // if for some reasons start position is negative set it to 0 // typical case is that the user type 0 for the requested page if($start <0) $start = 0; // the actual query for the grid data $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); // constructing a JSON $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } // return the formated data echo $json->encode($responce); ?> </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/demo.html
HTML
gpl2
6,666
jQuery("#scrgrid").jqGrid({ url:'server.php?q=5', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:5, scroll: true, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pscrgrid'), sortname: 'id', viewrecords: true, sortorder: "desc", jsonReader: { repeatitems : true, cell:"", id: "0" }, caption: "Autoloading data with scroll", height: 80 });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/scrgrid.js
JavaScript
gpl2
883
jQuery("#toolbar1").jqGrid({ url:'server.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pgtoolbar1'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Toolbar Example", editurl:"someurl.php", toolbar: [true,"top"] }).navGrid('#pgtoolbar1',{edit:false,add:false,del:false}); $("#t_toolbar1").append("<input type='button' value='Click Me' style='height:20px;font-size:-3'/>"); $("input","#t_toolbar1").click(function(){ alert("Hi! I'm added button at this toolbar"); }); jQuery("#toolbar2").jqGrid({ url:'server.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pgtoolbar2'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"User Data Example", editurl:"someurl.php", toolbar: [true,"bottom"], loadComplete: function() { var udata = $("#toolbar2").getUserData(); $("#t_toolbar2").css("text-align","right").html("Totals Amount:"+udata.tamount+" Tax: "+udata.ttax+" Total: "+udata.ttotal+ "&nbsp;&nbsp;&nbsp;"); } }).navGrid('#pgtoolbar2',{edit:false,add:false,del:false});
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/toolbar.js
JavaScript
gpl2
2,190
jQuery("#method32").jqGrid({ url:'server.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pmethod32'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"setLabel/setCell methods", multiselect: true, loadui: "block" }).navGrid('#pmethod32',{edit:false,add:false,del:false}); jQuery("#shc").click( function() { $("#method32").setLabel("tax","Tax Amt",{'font-weight': 'bold','font-style': 'italic'}); }); jQuery("#scc").click( function() { $("#method32").setCell("12","tax","",{'font-weight': 'bold',color: 'red','text-align':'center'}); }); jQuery("#cdat").click( function() { $("#method32").clearGridData(); });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/methods32.js
JavaScript
gpl2
1,234
jQuery("#hidengrid").jqGrid({ url:'server.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#phidengrid'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Initial Hidden Grid", multiselect: false, hiddengrid: true }).navGrid('#phidengrid',{edit:false,add:false,del:false});
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/hiddengrid.js
JavaScript
gpl2
881
<div> This example demonstrates two new fetures in jqGrid <br> 1. loadComplete() callback - this function is executed immediately after data is loaded.<br> This way we can make some changes depending on the needs.<br> 2. New method getDataIDs() - returns the id's of currently loaded data.<br> This method can be used in combination with loadComplete callback. </div> <br /> <table id="list15" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager15" class="scroll" style="text-align:center;"></div> <a href="javascript:void(0)" id="sids">Get Grid id's</a><br/> <script src="loadcml.js" type="text/javascript"> </script> <br /> <b> HTML </b> <XMP> ... <table id="list15" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager15" class="scroll" style="text-align:center;"></div> <a href="javascript:void(0)" id="sids">Get Grid id's</a><br/> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#list15").jqGrid({ url:'server.php?q=2&nd='+new Date().getTime(), datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pager15'), sortname: 'id', viewrecords: true, sortorder: "desc", loadComplete: function(){ var ret; alert("This function is executed immediately after\n data is loaded. We try to update data in row 13."); ret = jQuery("#list15").getRowData("13"); if(ret.id == "13"){ jQuery("#list15").setRowData(ret.id,{note:"<font color='red'>Row 13 is updated!</font>"}) } } }); jQuery("#sids").click( function() { alert("Id's of Grid: \n"+jQuery("#list15").getDataIDs()); }); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo json_encode($responce); ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/loadcml.html
HTML
gpl2
3,661
jQuery("#ttogrid").click(function (){ tableToGrid("#mytable"); });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/tbltogrid.js
JavaScript
gpl2
69
jQuery("#celltbl").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90,editable:true}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right",editable:true,editrules:{number:true}}, {name:'tax',index:'tax', width:80, align:"right",editable:true,editrules:{number:true}}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pcelltbl'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Cell Edit Example", forceFit : true, cellEdit: true, cellsubmit: 'clientArray', afterEditCell: function (id,name,val,iRow,iCol){ if(name=='invdate') { jQuery("#"+iRow+"_invdate","#celltbl").datepicker({dateFormat:"yy-mm-dd"}); } }, afterSaveCell : function(rowid,name,val,iRow,iCol) { if(name == 'amount') { var taxval = jQuery("#celltbl").getCell(rowid,iCol+1); jQuery("#celltbl").setRowData(rowid,{total:parseFloat(val)+parseFloat(taxval)}); } if(name == 'tax') { var amtval = jQuery("#celltbl").getCell(rowid,iCol-1); jQuery("#celltbl").setRowData(rowid,{total:parseFloat(val)+parseFloat(amtval)}); } } }).navGrid('#pgwidth',{edit:false,add:false,del:false});
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/celledit.js
JavaScript
gpl2
1,559
<div> This module is contributed from Peter Romianowski <br> The module convert existing html table to Grid<br> </div> <br /> <br/> <a href="#" id="ttogrid">Convert To Grid</a> <br/><br> <div style="width:500px;"> <table id="mytable" border="1"> <thead> <tr> <th>Header1</th> <th>Header2</th> <th>Header3</th> </tr> </thead> <tbody> <tr> <td>Cell 11</td> <td>Cell 12</td> <td>Cell 13</td> </tr> <tr> <td>Cell 21</td> <td>Cell 22</td> <td>Cell 23</td> </tr> <tr> <td>Cell 31</td> <td>Cell 32</td> <td>Cell 33</td> </tr> </tbody> </table> </div> <script src="tbltogrid.js" type="text/javascript"> </script> <br /> <b> HTML </b> <XMP> <a href="#" id="ttogrid">Convert To Grid</a> <br/><br> <div style="width:500px;"> <table id="mytable" border="1"> <thead> <tr> <th>Header1</th> <th>Header2</th> <th>Header3</th> </tr> </thead> <tbody> <tr> <td>Cell 11</td> <td>Cell 12</td> <td>Cell 13</td> </tr> <tr> <td>Cell 21</td> <td>Cell 22</td> <td>Cell 23</td> </tr> <tr> <td>Cell 31</td> <td>Cell 32</td> <td>Cell 33</td> </tr> </tbody> </table> </div> <script src="tbltogrid.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> jQuery("#ttogrid").click(function (){ tableToGrid("#mytable"); }); </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/tbltogrid.html
HTML
gpl2
1,310
jQuery("#hideshow").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#phideshow'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Dynamic hide/show column groups" }).navGrid("#phideshow",{edit:false,add:false,del:false}); jQuery("#hcg").click( function() { jQuery("#hideshow").hideCol(["amount","tax"]); }); jQuery("#scg").click( function() { jQuery("#hideshow").showCol(["amount","tax"]); });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/hideshow.js
JavaScript
gpl2
1,035
<?php /************************************************************************ * CSS and Javascript Combinator 0.5 * * Copyright 2006 by Niels Leenheer * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ $cache = true; $cachedir = dirname(__FILE__) . './cache'; $cssdir = dirname(__FILE__) . '/themes'; $jsdir = dirname(__FILE__) . './'; // Determine the directory and type we should use switch ($_GET['type']) { case 'css': $base = realpath($cssdir); break; case 'javascript': $base = realpath($jsdir); break; default: header ("HTTP/1.0 503 Not Implemented"); exit; }; $type = $_GET['type']; $elements = explode(',', $_GET['files']); //echo $type, $elements, $base; // Determine last modification date of the files $lastmodified = 0; while (list(,$element) = each($elements)) { $path = realpath($base . '/' . $element); if (($type == 'javascript' && substr($path, -3) != '.js') || ($type == 'css' && substr($path, -4) != '.css')) { header ("HTTP/1.0 403 Forbidden"); exit; } if (substr($path, 0, strlen($base)) != $base || !file_exists($path)) { header ("HTTP/1.0 404 Not Found"); exit; } $lastmodified = max($lastmodified, filemtime($path)); } // Send Etag hash $hash = $lastmodified . '-' . md5($_GET['files']); header ("Etag: \"" . $hash . "\""); if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) == '"' . $hash . '"') { // Return visit and no modifications, so do not send anything header ("HTTP/1.0 304 Not Modified"); header ('Content-Length: 0'); } else { // First time visit or files were modified if ($cache) { // Determine supported compression method $gzip = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'); $deflate = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate'); // Determine used compression method $encoding = $gzip ? 'gzip' : ($deflate ? 'deflate' : 'none'); // Check for buggy versions of Internet Explorer if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Opera') && preg_match('/^Mozilla\/4\.0 \(compatible; MSIE ([0-9]\.[0-9])/i', $_SERVER['HTTP_USER_AGENT'], $matches)) { $version = floatval($matches[1]); if ($version < 6) $encoding = 'none'; if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1')) $encoding = 'none'; } // Try the cache first to see if the combined files were already generated $cachefile = 'cache-' . $hash . '.' . $type . ($encoding != 'none' ? '.' . $encoding : ''); if (file_exists($cachedir . '/' . $cachefile)) { if ($fp = fopen($cachedir . '/' . $cachefile, 'rb')) { if ($encoding != 'none') { header ("Content-Encoding: " . $encoding); } header ("Content-Type: text/" . $type); header ("Content-Length: " . filesize($cachedir . '/' . $cachefile)); fpassthru($fp); fclose($fp); exit; } } } // Get contents of the files $contents = ''; reset($elements); while (list(,$element) = each($elements)) { $path = realpath($base . '/' . $element); $contents .= "\n\n" . file_get_contents($path); } // Send Content-Type header ("Content-Type: text/" . $type); if (isset($encoding) && $encoding != 'none') { // Send compressed contents $contents = gzencode($contents, 9, $gzip ? FORCE_GZIP : FORCE_DEFLATE); header ("Content-Encoding: " . $encoding); header ('Content-Length: ' . strlen($contents)); echo $contents; } else { // Send regular contents header ('Content-Length: ' . strlen($contents)); echo $contents; } // Store cache if ($cache) { if ($fp = fopen($cachedir . '/' . $cachefile, 'wb')) { fwrite($fp, $contents); fclose($fp); } } }
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/combine.php
PHP
gpl2
4,814
;(function ($) { /* * jqGrid 3.4.3 - jQuery Grid * Copyright (c) 2008, Tony Tomov, tony@trirand.com * Dual licensed under the MIT and GPL licenses * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * Date: 2009-03-12 rev 84 */ $.fn.jqGrid = function( p ) { p = $.extend(true,{ url: "", height: 150, page: 1, rowNum: 20, records: 0, pager: "", pgbuttons: true, pginput: true, colModel: [], rowList: [], colNames: [], sortorder: "asc", sortname: "", datatype: "xml", mtype: "GET", imgpath: "", sortascimg: "sort_asc.gif", sortdescimg: "sort_desc.gif", firstimg: "first.gif", previmg: "prev.gif", nextimg: "next.gif", lastimg: "last.gif", altRows: true, selarrrow: [], savedRow: [], shrinkToFit: true, xmlReader: {}, jsonReader: {}, subGrid: false, subGridModel :[], lastpage: 0, lastsort: 0, selrow: null, beforeSelectRow: null, onSelectRow: null, onSortCol: null, ondblClickRow: null, onRightClickRow: null, onPaging: null, onSelectAll: null, loadComplete: null, gridComplete: null, loadError: null, loadBeforeSend: null, afterInsertRow: null, beforeRequest: null, onHeaderClick: null, viewrecords: false, loadonce: false, multiselect: false, multikey: false, editurl: null, search: false, searchdata: {}, caption: "", hidegrid: true, hiddengrid: false, postData: {}, userData: {}, treeGrid : false, treeGridModel : 'nested', treeReader : {}, treeANode : 0, ExpandColumn: null, tree_root_level : 0, prmNames: {page:"page",rows:"rows", sort: "sidx",order: "sord"}, sortclass: "grid_sort", resizeclass: "grid_resize", forceFit : false, gridstate : "visible", cellEdit: false, cellsubmit: "remote", nv:0, loadui: "enable", toolbar: [false,""], scroll: false, multiboxonly : false, scrollrows : false, deselectAfterSort: true }, $.jgrid.defaults, p || {}); var grid={ headers:[], cols:[], dragStart: function(i,x) { this.resizing = { idx: i, startX: x}; this.hDiv.style.cursor = "e-resize"; }, dragMove: function(x) { if(this.resizing) { var diff = x-this.resizing.startX, h = this.headers[this.resizing.idx], newWidth = h.width + diff, hn, nWn; if(newWidth > 25) { if(p.forceFit===true ){ hn = this.headers[this.resizing.idx+p.nv]; nWn = hn.width - diff; if(nWn >25) { h.el.style.width = newWidth+"px"; h.newWidth = newWidth; this.cols[this.resizing.idx].style.width = newWidth+"px"; hn.el.style.width = nWn +"px"; hn.newWidth = nWn; this.cols[this.resizing.idx+p.nv].style.width = nWn+"px"; this.newWidth = this.width; } } else { h.el.style.width = newWidth+"px"; h.newWidth = newWidth; this.cols[this.resizing.idx].style.width = newWidth+"px"; this.newWidth = this.width+diff; $('table:first',this.bDiv).css("width",this.newWidth +"px"); $('table:first',this.hDiv).css("width",this.newWidth +"px"); this.hDiv.scrollLeft = this.bDiv.scrollLeft; } } } }, dragEnd: function() { this.hDiv.style.cursor = "default"; if(this.resizing) { var idx = this.resizing.idx; this.headers[idx].width = this.headers[idx].newWidth || this.headers[idx].width; this.cols[idx].style.width = this.headers[idx].newWidth || this.headers[idx].width; // here code to set the width in colmodel if(p.forceFit===true){ this.headers[idx+p.nv].width = this.headers[idx+p.nv].newWidth || this.headers[idx+p.nv].width; this.cols[idx+p.nv].style.width = this.headers[idx+p.nv].newWidth || this.headers[idx+p.nv].width; } if(this.newWidth) {this.width = this.newWidth;} this.resizing = false; } }, scrollGrid: function() { if(p.scroll === true) { var scrollTop = this.bDiv.scrollTop; if (scrollTop != this.scrollTop) { this.scrollTop = scrollTop; if ((this.bDiv.scrollHeight-scrollTop-$(this.bDiv).height()) <= 0) { if(parseInt(p.page,10)+1<=parseInt(p.lastpage,10)) { p.page = parseInt(p.page,10)+1; this.populate(); } } } } this.hDiv.scrollLeft = this.bDiv.scrollLeft; } }; $.fn.getGridParam = function(pName) { var $t = this[0]; if (!$t.grid) {return;} if (!pName) { return $t.p; } else {return $t.p[pName] ? $t.p[pName] : null;} }; $.fn.setGridParam = function (newParams){ return this.each(function(){ if (this.grid && typeof(newParams) === 'object') {$.extend(true,this.p,newParams);} }); }; $.fn.getDataIDs = function () { var ids=[]; this.each(function(){ $(this.rows).slice(1).each(function(i){ ids[i]=this.id; }); }); return ids; }; $.fn.setSortName = function (newsort) { return this.each(function(){ var $t = this; for(var i=0;i< $t.p.colModel.length;i++){ if($t.p.colModel[i].name===newsort || $t.p.colModel[i].index===newsort){ $("tr th:eq("+$t.p.lastsort+") div img",$t.grid.hDiv).remove(); $t.p.lastsort = i; $t.p.sortname=newsort; break; } } }); }; $.fn.setSelection = function(selection,onsr,sd) { return this.each(function(){ var $t = this, stat,pt, ind; onsr = onsr === false ? false : true; if(selection===false) {pt = sd;} else { ind = $($t).getInd($t.rows,selection); pt=$($t.rows[ind]);} selection = $(pt).attr("id"); if (!pt.html()) {return;} if($t.p.selrow && $t.p.scrollrows===true) { var olr = $($t).getInd($t.rows,$t.p.selrow); var ner = $($t).getInd($t.rows,selection); if(ner >=0 ){ if(ner > olr ) { scrGrid(ner,'d'); } else { scrGrid(ner,'u'); } } } if(!$t.p.multiselect) { if($(pt).attr("class") !== "subgrid") { if( $t.p.selrow ) {$("tr#"+$t.p.selrow.replace(".", "\\."),$t.grid.bDiv).removeClass("selected");} $t.p.selrow = selection; $(pt).addClass("selected"); if( $t.p.onSelectRow && onsr) { $t.p.onSelectRow($t.p.selrow, true); } } } else { $t.p.selrow = selection; var ia = $.inArray($t.p.selrow,$t.p.selarrrow); if ( ia === -1 ){ if($(pt).attr("class") !== "subgrid") { $(pt).addClass("selected");} stat = true; $("#jqg_"+$t.p.selrow.replace(".", "\\.") ,$t.rows).attr("checked",stat); $t.p.selarrrow.push($t.p.selrow); if( $t.p.onSelectRow && onsr) { $t.p.onSelectRow($t.p.selrow, stat); } } else { if($(pt).attr("class") !== "subgrid") { $(pt).removeClass("selected");} stat = false; $("#jqg_"+$t.p.selrow.replace(".", "\\.") ,$t.rows).attr("checked",stat); $t.p.selarrrow.splice(ia,1); if( $t.p.onSelectRow && onsr) { $t.p.onSelectRow($t.p.selrow, stat); } var tpsr = $t.p.selarrrow[0]; $t.p.selrow = (tpsr==undefined) ? null : tpsr; } } function scrGrid(iR,tp){ var ch = $($t.grid.bDiv)[0].clientHeight, st = $($t.grid.bDiv)[0].scrollTop, nROT = $t.rows[iR].offsetTop+$t.rows[iR].clientHeight, pROT = $t.rows[iR].offsetTop; if(tp == 'd') { if(nROT >= ch) { $($t.grid.bDiv)[0].scrollTop = st + nROT-pROT; } } if(tp == 'u'){ if (pROT < st) { $($t.grid.bDiv)[0].scrollTop = st - nROT+pROT; } } } }); }; $.fn.resetSelection = function(){ return this.each(function(){ var t = this, ind; if(!t.p.multiselect) { if(t.p.selrow) { $("tr#"+t.p.selrow.replace(".", "\\."),t.grid.bDiv).removeClass("selected"); t.p.selrow = null; } } else { $(t.p.selarrrow).each(function(i,n){ ind = $(t).getInd(t.rows,n); $(t.rows[ind]).removeClass("selected"); $("#jqg_"+n.replace(".", "\\."),t.rows[ind]).attr("checked",false); }); $("#cb_jqg",t.grid.hDiv).attr("checked",false); t.p.selarrrow = []; } }); }; $.fn.getRowData = function( rowid ) { var res = {}; if (rowid){ this.each(function(){ var $t = this,nm,ind; ind = $($t).getInd($t.rows,rowid); if (!ind) {return res;} $('td',$t.rows[ind]).each( function(i) { nm = $t.p.colModel[i].name; if ( nm !== 'cb' && nm !== 'subgrid') { if($t.p.treeGrid===true && nm == $t.p.ExpandColumn) { res[nm] = $.htmlDecode($("span:first",this).html()); } else { res[nm] = $.htmlDecode($(this).html()); } } }); }); } return res; }; $.fn.delRowData = function(rowid) { var success = false, rowInd, ia; if(rowid) { this.each(function() { var $t = this; rowInd = $($t).getInd($t.rows,rowid); if(!rowInd) {return false;} else { $($t.rows[rowInd]).remove(); $t.p.records--; $t.updatepager(); success=true; if(rowid == $t.p.selrow) {$t.p.selrow=null;} ia = $.inArray(rowid,$t.p.selarrrow); if(ia != -1) {$t.p.selarrrow.splice(ia,1);} } if(rowInd == 1 && success && ($.browser.opera || $.browser.safari)) { $($t.rows[1]).each( function( k ) { $(this).css("width",$t.grid.headers[k].width+"px"); $t.grid.cols[k] = this; }); } if( $t.p.altRows === true && success) { $($t.rows).slice(1).each(function(i){ if(i % 2 ==1) {$(this).addClass('alt');} else {$(this).removeClass('alt');} }); } }); } return success; }; $.fn.setRowData = function(rowid, data) { var nm, success=false; this.each(function(){ var t = this, vl, ind, ttd; if(!t.grid) {return false;} if( data ) { ind = $(t).getInd(t.rows,rowid); if(!ind) {return false;} success=true; $(this.p.colModel).each(function(i){ nm = this.name; vl = data[nm]; if( vl !== undefined ) { if(t.p.treeGrid===true && nm == t.p.ExpandColumn) { ttd = $("td:eq("+i+") > span:first",t.rows[ind]); } else { ttd = $("td:eq("+i+")",t.rows[ind]); } t.formatter(ttd, t.rows[ind], vl, i, 'edit'); success = true; } }); } }); return success; }; $.fn.addRowData = function(rowid,data,pos,src) { if(!pos) {pos = "last";} var success = false, nm, row, td, gi=0, si=0,sind, i; if(data) { this.each(function() { var t = this; row = document.createElement("tr"); row.id = rowid || t.p.records+1; $(row).addClass("jqgrow"); if(t.p.multiselect) { td = $('<td></td>'); $(td[0],t.grid.bDiv).html("<input type='checkbox'"+" id='jqg_"+rowid+"' class='cbox'/>"); row.appendChild(td[0]); gi = 1; } if(t.p.subGrid ) { try {$(t).addSubGrid(t.grid.bDiv,row,gi);} catch(e){} si=1;} for(i = gi+si; i < this.p.colModel.length;i++){ nm = this.p.colModel[i].name; td = $('<td></td>'); t.formatter(td, row, data[nm], i, 'add'); t.formatCol($(td[0],t.grid.bDiv),i); row.appendChild(td[0]); } switch (pos) { case 'last': $(t.rows[t.rows.length-1]).after(row); break; case 'first': $(t.rows[0]).after(row); break; case 'after': sind = $(t).getInd(t.rows,src); sind >= 0 ? $(t.rows[sind]).after(row): ""; break; case 'before': sind = $(t).getInd(t.rows,src); sind > 0 ? $(t.rows[sind-1]).after(row): ""; break; } t.p.records++; if($.browser.safari || $.browser.opera) { t.scrollLeft = t.scrollLeft; $("td",t.rows[1]).each( function( k ) { $(this).css("width",t.grid.headers[k].width+"px"); t.grid.cols[k] = this; }); } if( t.p.altRows === true ) { if (pos == "last") { if (t.rows.length % 2 == 1) {$(row).addClass('alt');} } else { $(t.rows).slice(1).each(function(i){ if(i % 2 ==1) {$(this).addClass('alt');} else {$(this).removeClass('alt');} }); } } try {t.p.afterInsertRow(row.id,data); } catch(e){} t.updatepager(); success = true; }); } return success; }; $.fn.hideCol = function(colname) { return this.each(function() { var $t = this,w=0, fndh=false, gtw; if (!$t.grid ) {return;} if( typeof colname == 'string') {colname=[colname];} $(this.p.colModel).each(function(i) { if ($.inArray(this.name,colname) != -1 && !this.hidden) { w = parseInt($("tr th:eq("+i+")",$t.grid.hDiv).css("width"),10); $("tr th:eq("+i+")",$t.grid.hDiv).css({display:"none"}); $($t.rows).each(function(j){ $("td:eq("+i+")",$t.rows[j]).css({display:"none"}); }); $t.grid.cols[i].style.width = 0; $t.grid.headers[i].width = 0; $t.grid.width -= w; this.hidden=true; fndh=true; } }); if(fndh===true) { gtw = Math.min($t.p._width,$t.grid.width); $("table:first",$t.grid.hDiv).width(gtw); $("table:first",$t.grid.bDiv).width(gtw); $($t.grid.hDiv).width(gtw); $($t.grid.bDiv).width(gtw); if($t.p.pager && $($t.p.pager).hasClass("scroll") ) { $($t.p.pager).width(gtw); } if($t.p.caption) {$($t.grid.cDiv).width(gtw);} if($t.p.toolbar[0]) {$($t.grid.uDiv).width(gtw);} $t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft; } }); }; $.fn.showCol = function(colname) { return this.each(function() { var $t = this, w = 0, fdns=false, gtw, ofl; if (!$t.grid ) {return;} if( typeof colname == 'string') {colname=[colname];} $($t.p.colModel).each(function(i) { if ($.inArray(this.name,colname) != -1 && this.hidden) { w = parseInt($("tr th:eq("+i+")",$t.grid.hDiv).css("width"),10); $("tr th:eq("+i+")",$t.grid.hDiv).css("display",""); $($t.rows).each(function(j){ $("td:eq("+i+")",$t.rows[j]).css("display","").width(w); }); this.hidden=false; $t.grid.cols[i].style.width = w; $t.grid.headers[i].width = w; $t.grid.width += w; fdns=true; } }); if(fdns===true) { gtw = Math.min($t.p._width,$t.grid.width); ofl = ($t.grid.width <= $t.p._width) ? "hidden" : "auto"; $("table:first",$t.grid.hDiv).width(gtw); $("table:first",$t.grid.bDiv).width(gtw); $($t.grid.hDiv).width(gtw); $($t.grid.bDiv).width(gtw).css("overflow-x",ofl); if($t.p.pager && $($t.p.pager).hasClass("scroll") ) { $($t.p.pager).width(gtw); } if($t.p.caption) {$($t.grid.cDiv).width(gtw);} if($t.p.toolbar[0]) {$($t.grid.uDiv).width(gtw);} $t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft; } }); }; $.fn.setGridWidth = function(nwidth, shrink) { return this.each(function(){ var $t = this, chw=0,w,cw,ofl; if (!$t.grid ) {return;} if(typeof shrink != 'boolean') {shrink=true;} var testdata = getScale(); if(shrink !== true) {testdata[0] = Math.min($t.p._width,$t.grid.width); testdata[2]=0;} else {testdata[2]= testdata[1]} $.each($t.p.colModel,function(i,v){ if(!this.hidden && this.name != 'cb' && this.name!='subgrid') { cw = shrink !== true ? $("tr:first th:eq("+i+")",$t.grid.hDiv).css("width") : this.width; w = Math.floor((IENum(nwidth)-IENum(testdata[2]))/IENum(testdata[0])*IENum(cw)); chw += w; $("table thead tr:first th:eq("+i+")",$t.grid.hDiv).css("width",w+"px"); $("table:first tbody tr:first td:eq("+i+")",$t.grid.bDiv).css("width",w+"px"); $t.grid.cols[i].style.width = w; $t.grid.headers[i].width = w; } if(this.name=='cb' || this.name == 'subgrid'){chw += IENum(this.width);} }); if(chw + testdata[1] <= nwidth || $t.p.forceFit === true){ ofl = "hidden"; tw = nwidth;} else { ofl= "auto"; tw = chw + testdata[1];} $("table:first",$t.grid.hDiv).width(tw); $("table:first",$t.grid.bDiv).width(tw); $($t.grid.hDiv).width(nwidth); $($t.grid.bDiv).width(nwidth).css("overflow-x",ofl); if($t.p.pager && $($t.p.pager).hasClass("scroll") ) { $($t.p.pager).width(nwidth); } if($t.p.caption) {$($t.grid.cDiv).width(nwidth);} if($t.p.toolbar[0]) {$($t.grid.uDiv).width(nwidth);} $t.p._width = nwidth; $t.grid.width = tw; if($.browser.safari || $.browser.opera ) { $("table tbody tr:eq(1) td",$t.grid.bDiv).each( function( k ) { $(this).css("width",$t.grid.headers[k].width+"px"); $t.grid.cols[k] = this; }); } $t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft; function IENum(val) { val = parseInt(val,10); return isNaN(val) ? 0 : val; } function getScale(){ var testcell = $("table tr:first th:eq(1)", $t.grid.hDiv); var addpix = IENum($(testcell).css("padding-left")) + IENum($(testcell).css("padding-right"))+ IENum($(testcell).css("border-left-width"))+ IENum($(testcell).css("border-right-width")); var w =0,ap=0; $.each($t.p.colModel,function(i,v){ if(!this.hidden) { w += parseInt(this.width); ap += addpix; } }); return [w,ap,0]; } }); }; $.fn.setGridHeight = function (nh) { return this.each(function (){ var ovfl, ovfl2, $t = this; if(!$t.grid) {return;} if($t.p.forceFit === true) { ovfl2='hidden'; } else {ovfl2=$($t.grid.bDiv).css("overflow-x");} ovfl = (isNaN(nh) && $.browser.mozilla && (nh.indexOf("%")!=-1 || nh=="auto")) ? "hidden" : "auto"; $($t.grid.bDiv).css({height: nh+(isNaN(nh)?"":"px"),"overflow-y":ovfl,"overflow-x": ovfl2}); $t.p.height = nh; }); }; $.fn.setCaption = function (newcap){ return this.each(function(){ this.p.caption=newcap; $("table:first th",this.grid.cDiv).html(newcap); $(this.grid.cDiv).show(); }); }; $.fn.setLabel = function(colname, nData, prop, attrp ){ return this.each(function(){ var $t = this, pos=-1; if(!$t.grid) {return;} if(isNaN(colname)) { $($t.p.colModel).each(function(i){ if (this.name == colname) { pos = i;return false; } }); } else {pos = parseInt(colname,10);} if(pos>=0) { var thecol = $("table:first th:eq("+pos+")",$t.grid.hDiv); if (nData){ $("div",thecol).html(nData); } if (prop) { if(typeof prop == 'string') {$(thecol).addClass(prop);} else {$(thecol).css(prop);} } if(typeof attrp == 'object') {$(thecol).attr(attrp);} } }); }; $.fn.setCell = function(rowid,colname,nData,cssp,attrp) { return this.each(function(){ var $t = this, pos =-1; if(!$t.grid) {return;} if(isNaN(colname)) { $($t.p.colModel).each(function(i){ if (this.name == colname) { pos = i;return false; } }); } else {pos = parseInt(colname,10);} if(pos>=0) { var ind = $($t).getInd($t.rows,rowid); if (ind>=0){ var tcell = $("td:eq("+pos+")",$t.rows[ind]); if(nData != "") { $t.formatter(tcell, $t.rows[ind], nData, pos,'edit'); } if (cssp){ if(typeof cssp == 'string') {$(tcell).addClass(cssp);} else {$(tcell).css(cssp);} } if(typeof attrp == 'object') {$(tcell).attr(attrp);} } } }); }; $.fn.getCell = function(rowid,col) { var ret = false; this.each(function(){ var $t=this, pos=-1; if(!$t.grid) {return;} if(isNaN(col)) { $($t.p.colModel).each(function(i){ if (this.name == col) { pos = i;return false; } }); } else {pos = parseInt(col,10);} if(pos>=0) { var ind = $($t).getInd($t.rows,rowid); if(ind>=0) { ret = $.htmlDecode($("td:eq("+pos+")",$t.rows[ind]).html()); } } }); return ret; }; $.fn.clearGridData = function() { return this.each(function(){ var $t = this; if(!$t.grid) {return;} $("tbody tr:gt(0)", $t.grid.bDiv).remove(); $t.p.selrow = null; $t.p.selarrrow= []; $t.p.savedRow = []; $t.p.records = '0';$t.p.page='0';$t.p.lastpage='0'; $t.updatepager(); }); }; $.fn.getInd = function(obj,rowid,rc){ var ret =false; $(obj).each(function(i){ if(this.id==rowid) { ret = rc===true ? this : i; return false; } }); return ret; }; $.htmlDecode = function(value){ if(value=='&nbsp;' || value=='&#160;') {value = "";} return !value ? value : String(value).replace(/&amp;/g, "&").replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"'); }; return this.each( function() { if(this.grid) {return;} this.p = p ; if(this.p.colNames.length === 0) { for (var i=0;i<this.p.colModel.length;i++){ this.p.colNames[i] = this.p.colModel[i].label || this.p.colModel[i].name; } } if( this.p.colNames.length !== this.p.colModel.length ) { alert($.jgrid.errors.model); return; } if(this.p.imgpath !== "" ) {this.p.imgpath += "/";} $("<div class='loadingui' id=lui_"+this.id+"><div class='msgbox'>"+this.p.loadtext+"</div></div>").insertBefore(this); $(this).attr({cellSpacing:"0",cellPadding:"0",border:"0"}); var ts = this, bSR = $.isFunction(this.p.beforeSelectRow) ? this.p.beforeSelectRow :false, onSelectRow = $.isFunction(this.p.onSelectRow) ? this.p.onSelectRow :false, ondblClickRow = $.isFunction(this.p.ondblClickRow) ? this.p.ondblClickRow :false, onSortCol = $.isFunction(this.p.onSortCol) ? this.p.onSortCol : false, loadComplete = $.isFunction(this.p.loadComplete) ? this.p.loadComplete : false, loadError = $.isFunction(this.p.loadError) ? this.p.loadError : false, loadBeforeSend = $.isFunction(this.p.loadBeforeSend) ? this.p.loadBeforeSend : false, onRightClickRow = $.isFunction(this.p.onRightClickRow) ? this.p.onRightClickRow : false, afterInsRow = $.isFunction(this.p.afterInsertRow) ? this.p.afterInsertRow : false, onHdCl = $.isFunction(this.p.onHeaderClick) ? this.p.onHeaderClick : false, beReq = $.isFunction(this.p.beforeRequest) ? this.p.beforeRequest : false, onSC = $.isFunction(this.p.onCellSelect) ? this.p.onCellSelect : false, sortkeys = ["shiftKey","altKey","ctrlKey"]; if ($.inArray(ts.p.multikey,sortkeys) == -1 ) {ts.p.multikey = false;} var IntNum = function(val,defval) { val = parseInt(val,10); if (isNaN(val)) { return (defval) ? defval : 0;} else {return val;} }; var formatCol = function (elem, pos){ var ral = ts.p.colModel[pos].align; if(ral) { $(elem).css("text-align",ral);} if(ts.p.colModel[pos].hidden) {$(elem).css("display","none");} }; var resizeFirstRow = function (t,er){ $("tbody tr:eq("+er+") td",t).each( function( k ) { $(this).css("width",grid.headers[k].width+"px"); grid.cols[k] = this; }); }; var addCell = function(t,row,cell,pos) { var td; td = document.createElement("td"); formatter($(td,t),row,cell,pos,'add'); row.appendChild(td); formatCol($(td,t), pos); }; var formatter = function (elem, row, cellval , colpos, act){ var cm = ts.p.colModel[colpos]; if(cm.formatter) { var opts= {rowId: row.id, colModel:cm,rowData:row}; if($.isFunction( cm.formatter ) ) { cm.formatter(elem,cellval,opts,act); } else if($.fmatter){ $(elem).fmatter(cm.formatter, cellval,opts, act); } else { $(elem).html(cellval || '&#160;'); } }else { $(elem).html(cellval || '&#160;'); } elem[0].title = elem[0].textContent || elem[0].innerText; }; var addMulti = function(t,row){ var cbid,td; td = document.createElement("td"); cbid = "jqg_"+row.id; $(td,t).html("<input type='checkbox'"+" id='"+cbid+"' class='cbox'/>"); formatCol($(td,t), 0); row.appendChild(td); }; var reader = function (datatype) { var field, f=[], j=0, i; for(i =0; i<ts.p.colModel.length; i++){ field = ts.p.colModel[i]; if (field.name !== 'cb' && field.name !=='subgrid') { f[j] = (datatype=="xml") ? field.xmlmap || field.name : field.jsonmap || field.name; j++; } } return f; }; var addXmlData = function addXmlData (xml,t, rcnt) { if(xml) { var fpos = ts.p.treeANode || 0; rcnt=rcnt ||0; if(fpos===0 && rcnt===0) {$("tbody tr:gt(0)", t).remove();} } else { return; } var v,row,gi=0,si=0,cbid,idn, getId,f=[],rd =[],cn=(ts.p.altRows === true) ? 'alt':''; if(!ts.p.xmlReader.repeatitems) {f = reader("xml");} if( ts.p.keyIndex===false) { idn = ts.p.xmlReader.id; if( idn.indexOf("[") === -1 ) { getId = function( trow, k) {return $(idn,trow).text() || k;}; } else { getId = function( trow, k) {return trow.getAttribute(idn.replace(/[\[\]]/g,"")) || k;}; } } else { getId = function(trow) { return (f.length - 1 >= ts.p.keyIndex) ? $(f[ts.p.keyIndex],trow).text() : $(ts.p.xmlReader.cell+":eq("+ts.p.keyIndex+")",trow).text(); }; } $(ts.p.xmlReader.page,xml).each(function() {ts.p.page = this.textContent || this.text ; }); $(ts.p.xmlReader.total,xml).each(function() {ts.p.lastpage = this.textContent || this.text ; } ); $(ts.p.xmlReader.records,xml).each(function() {ts.p.records = this.textContent || this.text ; } ); $(ts.p.xmlReader.userdata,xml).each(function() {ts.p.userData[this.getAttribute("name")]=this.textContent || this.text;}); $(ts.p.xmlReader.root+" "+ts.p.xmlReader.row,xml).each( function( j ) { row = document.createElement("tr"); row.id = getId(this,j+1); if(ts.p.multiselect) { addMulti(t,row); gi = 1; } if (ts.p.subGrid) { try {$(ts).addSubGrid(t,row,gi,this);} catch (e){} si= 1; } if(ts.p.xmlReader.repeatitems===true){ $(ts.p.xmlReader.cell,this).each( function (i) { v = this.textContent || this.text; addCell(t,row,v,i+gi+si); rd[ts.p.colModel[i+gi+si].name] = v; }); } else { for(var i = 0; i < f.length;i++) { v = $(f[i],this).text(); addCell(t, row, v , i+gi+si); rd[ts.p.colModel[i+gi+si].name] = v; } } if(j%2 == 1) {row.className = cn;} $(row).addClass("jqgrow"); if( ts.p.treeGrid === true) { try {$(ts).setTreeNode(rd,row);} catch (e) {} ts.p.treeANode = 0; } $(ts.rows[j+fpos+rcnt]).after(row); if(afterInsRow) {ts.p.afterInsertRow(row.id,rd,this);} rd=[]; }); if(isSafari || isOpera) {resizeFirstRow(t,1);} if(!ts.p.treeGrid && !ts.p.scroll) {ts.grid.bDiv.scrollTop = 0;} endReq(); updatepager(); }; var addJSONData = function(data,t, rcnt) { if(data) { var fpos = ts.p.treeANode || 0; rcnt = rcnt || 0; if(fpos===0 && rcnt===0) {$("tbody tr:gt(0)", t).remove();} } else { return; } var v,i,j,row,f=[],cur,gi=0,si=0,drows,idn,rd=[],cn=(ts.p.altRows===true) ? 'alt':''; ts.p.page = data[ts.p.jsonReader.page]; ts.p.lastpage= data[ts.p.jsonReader.total]; ts.p.records= data[ts.p.jsonReader.records]; ts.p.userData = data[ts.p.jsonReader.userdata] || {}; if(!ts.p.jsonReader.repeatitems) {f = reader("json");} if( ts.p.keyIndex===false ) { idn = ts.p.jsonReader.id; if(f.length>0 && !isNaN(idn)) {idn=f[idn];} } else { idn = f.length>0 ? f[ts.p.keyIndex] : ts.p.keyIndex; } drows = data[ts.p.jsonReader.root]; if (drows) { for (i=0;i<drows.length;i++) { cur = drows[i]; row = document.createElement("tr"); row.id = cur[idn] || ""; if(row.id === "") { if(f.length===0){ if(ts.p.jsonReader.cell){ var ccur = cur[ts.p.jsonReader.cell]; row.id = ccur[idn] || i+1; ccur=null; } else {row.id=i+1;} } else { row.id=i+1; } } if(ts.p.multiselect){ addMulti(t,row); gi = 1; } if (ts.p.subGrid) { try { $(ts).addSubGrid(t,row,gi,drows[i]);} catch (e){} si= 1; } if (ts.p.jsonReader.repeatitems === true) { if(ts.p.jsonReader.cell) {cur = cur[ts.p.jsonReader.cell];} for (j=0;j<cur.length;j++) { addCell(t,row,cur[j],j+gi+si); rd[ts.p.colModel[j+gi+si].name] = cur[j]; } } else { for (j=0;j<f.length;j++) { v=cur[f[j]]; if(v === undefined) { try { v = eval("cur."+f[j]);} catch (e) {} } addCell(t,row,v,j+gi+si); rd[ts.p.colModel[j+gi+si].name] = cur[f[j]]; } } if(i%2 == 1) {row.className = cn;} $(row).addClass("jqgrow"); if( ts.p.treeGrid === true) { try {$(ts).setTreeNode(rd,row);} catch (e) {} ts.p.treeANode = 0; } $(ts.rows[i+fpos+rcnt]).after(row); if(afterInsRow) {ts.p.afterInsertRow(row.id,rd,drows[i]);} rd=[]; } } if(isSafari || isOpera) {resizeFirstRow(t,1);} if(!ts.p.treeGrid && !ts.p.scroll) {ts.grid.bDiv.scrollTop = 0;} endReq(); updatepager(); }; var updatepager = function() { if(ts.p.pager) { var cp, last,imp = ts.p.imgpath; if (ts.p.loadonce) { cp = last = 1; ts.p.lastpage = ts.page =1; $(".selbox",ts.p.pager).attr("disabled",true); } else { cp = IntNum(ts.p.page); last = IntNum(ts.p.lastpage); $(".selbox",ts.p.pager).attr("disabled",false); } if(ts.p.pginput===true) { $('input.selbox',ts.p.pager).val(ts.p.page); } if (ts.p.viewrecords){ if(ts.p.pgtext) { $('#sp_1',ts.p.pager).html(ts.p.pgtext+"&#160;"+ts.p.lastpage ); } $('#sp_2',ts.p.pager).html(ts.p.records+"&#160;"+ts.p.recordtext+"&#160;"); } if(ts.p.pgbuttons===true) { if(cp<=0) {cp = last = 1;} if(cp==1) {$("#first",ts.p.pager).attr({src:imp+"off-"+ts.p.firstimg,disabled:true});} else {$("#first",ts.p.pager).attr({src:imp+ts.p.firstimg,disabled:false});} if(cp==1) {$("#prev",ts.p.pager).attr({src:imp+"off-"+ts.p.previmg,disabled:true});} else {$("#prev",ts.p.pager).attr({src:imp+ts.p.previmg,disabled:false});} if(cp==last) {$("#next",ts.p.pager).attr({src:imp+"off-"+ts.p.nextimg,disabled:true});} else {$("#next",ts.p.pager).attr({src:imp+ts.p.nextimg,disabled:false});} if(cp==last) {$("#last",ts.p.pager).attr({src:imp+"off-"+ts.p.lastimg,disabled:true});} else {$("#last",ts.p.pager).attr({src:imp+ts.p.lastimg,disabled:false});} } } if($.isFunction(ts.p.gridComplete)) {ts.p.gridComplete();} }; var populate = function () { if(!grid.hDiv.loading) { beginReq(); var gdata, prm = {nd: (new Date().getTime()), _search:ts.p.search}; prm[ts.p.prmNames.rows]= ts.p.rowNum; prm[ts.p.prmNames.page]= ts.p.page; prm[ts.p.prmNames.sort]= ts.p.sortname; prm[ts.p.prmNames.order]= ts.p.sortorder; gdata = $.extend(ts.p.postData,prm); if (ts.p.search ===true) {gdata =$.extend(gdata,ts.p.searchdata);} if ($.isFunction(ts.p.datatype)) {ts.p.datatype(gdata);endReq();} var rcnt = ts.p.scroll===false ? 0 : ts.rows.length-1; switch(ts.p.datatype) { case "json": $.ajax({url:ts.p.url,type:ts.p.mtype,dataType:"json",data: gdata, complete:function(JSON,st) { if(st=="success") {addJSONData(eval("("+JSON.responseText+")"),ts.grid.bDiv,rcnt); JSON=null;if(loadComplete) {loadComplete();}}}, error:function(xhr,st,err){if(loadError) {loadError(xhr,st,err);}endReq();}, beforeSend: function(xhr){if(loadBeforeSend) {loadBeforeSend(xhr);}}}); if( ts.p.loadonce || ts.p.treeGrid) {ts.p.datatype = "local";} break; case "xml": $.ajax({url:ts.p.url,type:ts.p.mtype,dataType:"xml",data: gdata , complete:function(xml,st) {if(st=="success") {addXmlData(xml.responseXML,ts.grid.bDiv,rcnt); xml=null;if(loadComplete) {loadComplete();}}}, error:function(xhr,st,err){if(loadError) {loadError(xhr,st,err);}endReq();}, beforeSend: function(xhr){if(loadBeforeSend) {loadBeforeSend(xhr);}}}); if( ts.p.loadonce || ts.p.treeGrid) {ts.p.datatype = "local";} break; case "xmlstring": addXmlData(stringToDoc(ts.p.datastr),ts.grid.bDiv); ts.p.datastr = null; ts.p.datatype = "local"; if(loadComplete) {loadComplete();} break; case "jsonstring": if(typeof ts.p.datastr == 'string') { ts.p.datastr = eval("("+ts.p.datastr+")");} addJSONData(ts.p.datastr,ts.grid.bDiv); ts.p.datastr = null; ts.p.datatype = "local"; if(loadComplete) {loadComplete();} break; case "local": case "clientSide": ts.p.datatype = "local"; sortArrayData(); break; } } }; var beginReq = function() { if(beReq) {ts.p.beforeRequest();} grid.hDiv.loading = true; switch(ts.p.loadui) { case "disable": break; case "enable": $("div.loading",grid.hDiv).fadeIn("fast"); break; case "block": $("#lui_"+ts.id).width($(grid.bDiv).width()).height(IntNum($(grid.bDiv).height())+IntNum(ts.p._height)).fadeIn("fast"); break; } }; var endReq = function() { grid.hDiv.loading = false; switch(ts.p.loadui) { case "disable": break; case "enable": $("div.loading",grid.hDiv).fadeOut("fast"); break; case "block": $("#lui_"+ts.id).fadeOut("fast"); break; } }; var stringToDoc = function (xmlString) { var xmlDoc; if(typeof xmlString !== 'string') return xmlString; try { var parser = new DOMParser(); xmlDoc = parser.parseFromString(xmlString,"text/xml"); } catch(e) { xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc["loadXM"+"L"](xmlString); } return (xmlDoc && xmlDoc.documentElement && xmlDoc.documentElement.tagName != 'parsererror') ? xmlDoc : null; }; var sortArrayData = function() { var stripNum = /[\$,%]/g; var rows=[], col=0, st, sv, findSortKey,newDir = (ts.p.sortorder == "asc") ? 1 :-1; $.each(ts.p.colModel,function(i,v){ if(this.index == ts.p.sortname || this.name == ts.p.sortname){ col = ts.p.lastsort= i; st = this.sorttype; return false; } }); if (st == 'float' || st== 'number' || st== 'currency') { findSortKey = function($cell) { var key = parseFloat($cell.replace(stripNum, '')); return isNaN(key) ? 0 : key; }; } else if (st=='int' || st=='integer') { findSortKey = function($cell) { return IntNum($cell.replace(stripNum, '')); }; } else if(st == 'date') { findSortKey = function($cell) { var fd = ts.p.colModel[col].datefmt || "Y-m-d"; return parseDate(fd,$cell).getTime(); }; } else { findSortKey = function($cell) { return $.trim($cell.toUpperCase()); }; } $.each(ts.rows, function(index, row) { if (index > 0) { try { sv = $.unformat($(row).children('td').eq(col),{colModel:ts.p.colModel[col]},col,true);} catch (_) { sv = $(row).children('td').eq(col).text(); } row.sortKey = findSortKey(sv); rows[index-1] = this; } }); if(ts.p.treeGrid) { $(ts).SortTree( newDir); } else { rows.sort(function(a, b) { if (a.sortKey < b.sortKey) {return -newDir;} if (a.sortKey > b.sortKey) {return newDir;} return 0; }); $.each(rows, function(index, row) { $('tbody',ts.grid.bDiv).append(row); row.sortKey = null; }); } if(isSafari || isOpera) {resizeFirstRow(ts.grid.bDiv,1);} if(ts.p.multiselect) { $("tbody tr:gt(0)", ts.grid.bDiv).removeClass("selected"); $("[id^=jqg_]",ts.rows).attr("checked",false); $("#cb_jqg",ts.grid.hDiv).attr("checked",false); ts.p.selarrrow = []; } if( ts.p.altRows === true ) { $("tbody tr:gt(0)", ts.grid.bDiv).removeClass("alt"); $("tbody tr:odd", ts.grid.bDiv).addClass("alt"); } ts.grid.bDiv.scrollTop = 0; endReq(); }; var parseDate = function(format, date) { var tsp = {m : 1, d : 1, y : 1970, h : 0, i : 0, s : 0}; format = format.toLowerCase(); date = date.split(/[\\\/:_;.\s-]/); format = format.split(/[\\\/:_;.\s-]/); for(var i=0;i<format.length;i++){ tsp[format[i]] = IntNum(date[i],tsp[format[i]]); } tsp.m = parseInt(tsp.m,10)-1; var ty = tsp.y; if (ty >= 70 && ty <= 99) {tsp.y = 1900+tsp.y;} else if (ty >=0 && ty <=69) {tsp.y= 2000+tsp.y;} return new Date(tsp.y, tsp.m, tsp.d, tsp.h, tsp.i, tsp.s,0); }; var setPager = function (){ var inpt = "<img class='pgbuttons' src='"+ts.p.imgpath+"spacer.gif'", pginp = (ts.p.pginput===true) ? "<input class='selbox' type='text' size='3' maxlength='5' value='0'/>" : "", pgl="", pgr="", str; if(ts.p.viewrecords===true) {pginp += "<span id='sp_1'></span>&#160;";} if(ts.p.pgbuttons===true) { pgl = inpt+" id='first'/>&#160;&#160;"+inpt+" id='prev'/>&#160;"; pgr = inpt+" id='next' />&#160;&#160;"+inpt+" id='last'/>"; } $(ts.p.pager).append(pgl+pginp+pgr); if(ts.p.rowList.length >0){ str="<SELECT class='selbox'>"; for(var i=0;i<ts.p.rowList.length;i++){ str +="<OPTION value="+ts.p.rowList[i]+((ts.p.rowNum == ts.p.rowList[i])?' selected':'')+">"+ts.p.rowList[i]; } str +="</SELECT>"; $(ts.p.pager).append("&#160;"+str+"&#160;<span id='sp_2'></span>"); $(ts.p.pager).find("select").bind('change',function() { ts.p.rowNum = this.value; if (typeof ts.p.onPaging =='function') {ts.p.onPaging('records');} populate(); ts.p.selrow = null; }); } else { $(ts.p.pager).append("&#160;<span id='sp_2'></span>");} if(ts.p.pgbuttons===true) { $(".pgbuttons",ts.p.pager).mouseover(function(e){ if($(this).attr('disabled') == 'true') { this.style.cursor='auto';} else {this.style.cursor= "pointer";} return false; }).mouseout(function(e) { this.style.cursor= "default"; return false; }); $("#first, #prev, #next, #last",ts.p.pager).click( function(e) { var cp = IntNum(ts.p.page), last = IntNum(ts.p.lastpage), selclick = false, fp=true, pp=true, np=true,lp=true; if(last ===0 || last===1) {fp=false;pp=false;np=false;lp=false; } else if( last>1 && cp >=1) { if( cp === 1) { fp=false; pp=false; } else if( cp>1 && cp <last){ } else if( cp===last){ np=false;lp=false; } } else if( last>1 && cp===0 ) { np=false;lp=false; cp=last-1;} if( this.id === 'first' && fp ) { ts.p.page=1; selclick=true;} if( this.id === 'prev' && pp) { ts.p.page=(cp-1); selclick=true;} if( this.id === 'next' && np) { ts.p.page=(cp+1); selclick=true;} if( this.id === 'last' && lp) { ts.p.page=last; selclick=true;} if(selclick) { if (typeof ts.p.onPaging =='function') {ts.p.onPaging(this.id);} populate(); ts.p.selrow = null; if(ts.p.multiselect) {ts.p.selarrrow =[];$('#cb_jqg',ts.grid.hDiv).attr("checked",false);} ts.p.savedRow = []; } e.stopPropagation(); return false; }); } if(ts.p.pginput===true) { $('input.selbox',ts.p.pager).keypress( function(e) { var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; if(key == 13) { ts.p.page = ($(this).val()>0) ? $(this).val():ts.p.page; if (typeof ts.p.onPaging =='function') {ts.p.onPaging( 'user');} populate(); ts.p.selrow = null; return false; } return this; }); } }; var sortData = function (index, idxcol,reload){ var imgs, so, scg, ls, iId; if(ts.p.savedRow.length > 0) {return;} if(!reload) { if( ts.p.lastsort === idxcol ) { if( ts.p.sortorder === 'asc') { ts.p.sortorder = 'desc'; } else if(ts.p.sortorder === 'desc') { ts.p.sortorder='asc';} } else { ts.p.sortorder='asc';} ts.p.page = 1; } imgs = (ts.p.sortorder==='asc') ? ts.p.sortascimg : ts.p.sortdescimg; imgs = "<img src='"+ts.p.imgpath+imgs+"'>"; var thd= $("thead:first",grid.hDiv).get(0); ls = ts.p.colModel[ts.p.lastsort].name.replace('.',"\\."); $("tr th div#jqgh_"+ls+" img",thd).remove(); $("tr th div#jqgh_"+ls,thd).parent().removeClass(ts.p.sortclass); iId = index.replace('.',"\\."); $("tr th div#"+iId,thd).append(imgs).parent().addClass(ts.p.sortclass); ts.p.lastsort = idxcol; index = index.substring(5); ts.p.sortname = ts.p.colModel[idxcol].index || index; so = ts.p.sortorder; if(onSortCol) {onSortCol(index,idxcol,so);} if(ts.p.datatype == "local") { if(ts.p.deselectAfterSort) {$(ts).resetSelection();} } else { ts.p.selrow = null; if(ts.p.multiselect){$("#cb_jqg",ts.grid.hDiv).attr("checked",false);} ts.p.selarrrow =[]; ts.p.savedRow =[]; } scg = ts.p.scroll; if(ts.p.scroll===true) {ts.p.scroll=false;} populate(); if(ts.p.sortname != index && idxcol) {ts.p.lastsort = idxcol;} setTimeout(function() {ts.p.scroll=scg;},500); }; var setColWidth = function () { var initwidth = 0; for(var l=0;l<ts.p.colModel.length;l++){ if(!ts.p.colModel[l].hidden){ initwidth += IntNum(ts.p.colModel[l].width); } } var tblwidth = ts.p.width ? ts.p.width : initwidth; for(l=0;l<ts.p.colModel.length;l++) { if(!ts.p.shrinkToFit){ ts.p.colModel[l].owidth = ts.p.colModel[l].width; } ts.p.colModel[l].width = Math.round(tblwidth/initwidth*ts.p.colModel[l].width); } }; var nextVisible= function(iCol) { var ret = iCol, j=iCol, i; for (i = iCol+1;i<ts.p.colModel.length;i++){ if(ts.p.colModel[i].hidden !== true ) { j=i; break; } } return j-ret; }; this.p.id = this.id; if(this.p.treeGrid === true) { this.p.subGrid = false; this.p.altRows =false; this.p.pgbuttons = false; this.p.pginput = false; this.p.multiselect = false; this.p.rowList = []; try { $(this).setTreeGrid(); this.p.treedatatype = this.p.datatype; $.each(this.p.treeReader,function(i,n){ if(n){ ts.p.colNames.push(n); ts.p.colModel.push({name:n,width:1,hidden:true,sortable:false,resizable:false,hidedlg:true,editable:true,search:false}); } }); } catch (_) {} } ts.p.keyIndex=false; for (var i=0; i<ts.p.colModel.length;i++) { if (ts.p.colModel[i].key===true) { ts.p.keyIndex = i; break; } } if(this.p.subGrid) { this.p.colNames.unshift(""); this.p.colModel.unshift({name:'subgrid',width:25,sortable: false,resizable:false,hidedlg:true,search:false}); } if(this.p.multiselect) { this.p.colNames.unshift("<input id='cb_jqg' class='cbox' type='checkbox'/>"); this.p.colModel.unshift({name:'cb',width:27,sortable:false,resizable:false,hidedlg:true,search:false}); } var xReader = { root: "rows", row: "row", page: "rows>page", total: "rows>total", records : "rows>records", repeatitems: true, cell: "cell", id: "[id]", userdata: "userdata", subgrid: {root:"rows", row: "row", repeatitems: true, cell:"cell"} }; var jReader = { root: "rows", page: "page", total: "total", records: "records", repeatitems: true, cell: "cell", id: "id", userdata: "userdata", subgrid: {root:"rows", repeatitems: true, cell:"cell"} }; if(ts.p.scroll===true){ ts.p.pgbuttons = false; ts.p.pginput=false; ts.p.pgtext = false; ts.p.rowList=[]; } ts.p.xmlReader = $.extend(xReader, ts.p.xmlReader); ts.p.jsonReader = $.extend(jReader, ts.p.jsonReader); $.each(ts.p.colModel, function(i){this.width= IntNum(this.width,150);}); if (ts.p.width) {setColWidth();} var thead = document.createElement("thead"); var trow = document.createElement("tr"); thead.appendChild(trow); var i=0, th, idn, thdiv; if(ts.p.shrinkToFit===true && ts.p.forceFit===true) { for (i=ts.p.colModel.length-1;i>=0;i--){ if(!ts.p.colModel[i].hidden) { ts.p.colModel[i].resizable=false; break; } } } for(i=0;i<this.p.colNames.length;i++){ th = document.createElement("th"); idn = ts.p.colModel[i].name; thdiv = document.createElement("div"); $(thdiv).html(ts.p.colNames[i]+"&#160;"); if (idn == ts.p.sortname) { var imgs = (ts.p.sortorder==='asc') ? ts.p.sortascimg : ts.p.sortdescimg; imgs = "<img src='"+ts.p.imgpath+imgs+"'>"; $(thdiv).append(imgs); ts.p.lastsort = i; $(th).addClass(ts.p.sortclass); } thdiv.id = "jqgh_"+idn; th.appendChild(thdiv); trow.appendChild(th); } if(this.p.multiselect) { var onSA = true; if(typeof ts.p.onSelectAll !== 'function') {onSA=false;} $('#cb_jqg',trow).click(function(){ var chk; if (this.checked) { $("[id^=jqg_]",ts.rows).attr("checked",true); $(ts.rows).slice(1).each(function(i) { if(!$(this).hasClass("subgrid")){ $(this).addClass("selected"); ts.p.selarrrow[i]= ts.p.selrow = this.id; } }); chk=true; } else { $("[id^=jqg_]",ts.rows).attr("checked",false); $(ts.rows).slice(1).each(function(i) { if(!$(this).hasClass("subgrid")){ $(this).removeClass("selected"); } }); ts.p.selarrrow = []; ts.p.selrow = null; chk=false; } if(onSA) {ts.p.onSelectAll(ts.p.selarrrow,chk);} }); } this.appendChild(thead); thead = $("thead:first",ts).get(0); var w, res, sort; $("tr:first th",thead).each(function ( j ) { w = ts.p.colModel[j].width; if(typeof ts.p.colModel[j].resizable === 'undefined') {ts.p.colModel[j].resizable = true;} res = document.createElement("span"); $(res).html("&#160;"); if(ts.p.colModel[j].resizable){ $(this).addClass(ts.p.resizeclass); $(res).mousedown(function (e) { if(ts.p.forceFit===true) {ts.p.nv= nextVisible(j);} grid.dragStart(j, e.clientX); e.preventDefault(); return false; }); } else {res="";} $(this).css("width",w+"px").prepend(res); if( ts.p.colModel[j].hidden) {$(this).css("display","none");} grid.headers[j] = { width: w, el: this }; sort = ts.p.colModel[j].sortable; if( typeof sort !== 'boolean') {sort = true;} if(sort) { $("div",this).css("cursor","pointer") .click(function(){sortData(this.id,j);return false;}); } }); var isMSIE = $.browser.msie ? true:false, isMoz = $.browser.mozilla ? true:false, isOpera = $.browser.opera ? true:false, isSafari = $.browser.safari ? true : false, td, ptr, gw=0,hdc=0, tbody = document.createElement("tbody"); trow = document.createElement("tr"); trow.id = "_empty"; tbody.appendChild(trow); for(i=0;i<ts.p.colNames.length;i++){ td = document.createElement("td"); trow.appendChild(td); } this.appendChild(tbody); $("tbody tr:first td",ts).each(function(ii) { w = ts.p.colModel[ii].width; $(this).css({width:w+"px",height:"0px"}); w += IntNum($(this).css("padding-left")) + IntNum($(this).css("padding-right"))+ IntNum($(this).css("border-left-width"))+ IntNum($(this).css("border-right-width")); if( ts.p.colModel[ii].hidden===true) { $(this).css("display","none"); hdc += w; } grid.cols[ii] = this; gw += w; }); if(isMoz) {$(trow).css({visibility:"collapse"});} else if( isSafari || isOpera ) {$(trow).css({display:"none"});} grid.width = IntNum(gw)-IntNum(hdc); ts.p._width = grid.width; grid.hTable = document.createElement("table"); $(grid.hTable).append(thead) .css({width:grid.width+"px"}) .attr({cellSpacing:"0",cellPadding:"0",border:"0"}) .addClass("scroll grid_htable"); grid.hDiv = document.createElement("div"); var hg = (ts.p.caption && ts.p.hiddengrid===true) ? true : false; $(grid.hDiv) .css({ width: grid.width+"px", overflow: "hidden"}) .prepend('<div class="loading">'+ts.p.loadtext+'</div>') .addClass("grid_hdiv") .append(grid.hTable) .bind("selectstart", function () { return false; }); if(hg) {$(grid.hDiv).hide(); ts.p.gridstate = 'hidden'} if(ts.p.pager){ if(typeof ts.p.pager == "string") {if(ts.p.pager.substr(0,1) !="#") ts.p.pager = "#"+ts.p.pager;} if( $(ts.p.pager).hasClass("scroll")) { $(ts.p.pager).css({ width: grid.width+"px", overflow: "hidden"}).show(); ts.p._height= parseInt($(ts.p.pager).height(),10); if(hg) {$(ts.p.pager).hide();}} setPager(); } if( ts.p.cellEdit === false) { $(ts).mouseover(function(e) { td = (e.target || e.srcElement); ptr = $(td,ts.rows).parents("tr:first"); if($(ptr).hasClass("jqgrow")) { $(ptr).addClass("over"); } return false; }).mouseout(function(e) { td = (e.target || e.srcElement); ptr = $(td,ts.rows).parents("tr:first"); $(ptr).removeClass("over"); return false; }); } var ri,ci; $(ts).before(grid.hDiv).css("width", grid.width+"px").click(function(e) { td = (e.target || e.srcElement); if (td.href) { return true; } var scb = $(td).hasClass("cbox"); ptr = $(td,ts.rows).parent("tr"); if($(ptr).length === 0 ){ ptr = $(td,ts.rows).parents("tr:first"); td = $(td).parents("td:first")[0]; } var cSel = true; if(bSR) { cSel = bSR(ptr.attr("id"));} if(cSel === true) { if(ts.p.cellEdit === true) { if(ts.p.multiselect && scb){ $(ts).setSelection(false,true,ptr); } else { ri = ptr[0].rowIndex; ci = td.cellIndex; try {$(ts).editCell(ri,ci,true,true);} catch (e) {} } } else if ( !ts.p.multikey ) { if(ts.p.multiselect && ts.p.multiboxonly) { if(scb){$(ts).setSelection(false,true,ptr);} } else { $(ts).setSelection(false,true,ptr); } } else { if(e[ts.p.multikey]) { $(ts).setSelection(false,true,ptr); } else if(ts.p.multiselect && scb) { scb = $("[id^=jqg_]",ptr).attr("checked"); $("[id^=jqg_]",ptr).attr("checked",!scb); } } if(onSC) { ri = ptr[0].id; ci = td.cellIndex; onSC(ri,ci,$(td).html()); } } e.stopPropagation(); }).bind('reloadGrid', function(e) { if(ts.p.treeGrid ===true) { ts.p.datatype = ts.p.treedatatype;} if(ts.p.datatype=="local"){ $(ts).resetSelection();} else if(!ts.p.treeGrid){ ts.p.selrow=null; if(ts.p.multiselect) {ts.p.selarrrow =[];$('#cb_jqg',ts.grid.hDiv).attr("checked",false);} if(ts.p.cellEdit) {ts.p.savedRow = []; } } populate(); }); if( ondblClickRow ) { $(this).dblclick(function(e) { td = (e.target || e.srcElement); ptr = $(td,ts.rows).parent("tr"); if($(ptr).length === 0 ){ ptr = $(td,ts.rows).parents("tr:first"); } ts.p.ondblClickRow($(ptr).attr("id")); return false; }); } if (onRightClickRow) { $(this).bind('contextmenu', function(e) { td = (e.target || e.srcElement); ptr = $(td,ts).parents("tr:first"); if($(ptr).length === 0 ){ ptr = $(td,ts.rows).parents("tr:first"); } if(!ts.p.multiselect) { $(ts).setSelection(false,true,ptr); } ts.p.onRightClickRow($(ptr).attr("id")); return false; }); } grid.bDiv = document.createElement("div"); var ofl2 = (isNaN(ts.p.height) && isMoz && (ts.p.height.indexOf("%")!=-1 || ts.p.height=="auto")) ? "hidden" : "auto"; $(grid.bDiv) .addClass("grid_bdiv") .scroll(function (e) {grid.scrollGrid();}) .css({ height: ts.p.height+(isNaN(ts.p.height)?"":"px"), padding: "0px", margin: "0px", overflow: ofl2,width: (grid.width)+"px"} ).css("overflow-x","hidden") .append(this); $("table:first",grid.bDiv).css({width:grid.width+"px"}); if( isMSIE ) { if( $("tbody",this).size() === 2 ) { $("tbody:first",this).remove();} if( ts.p.multikey) {$(grid.bDiv).bind("selectstart",function(){return false;});} if(ts.p.treeGrid) {$(grid.bDiv).css("position","relative");} } else { if( ts.p.multikey) {$(grid.bDiv).bind("mousedown",function(){return false;});} } if(hg) {$(grid.bDiv).hide();} grid.cDiv = document.createElement("div"); $(grid.cDiv).append("<table class='Header' cellspacing='0' cellpadding='0' border='0'><tr><td class='HeaderLeft'><img src='"+ts.p.imgpath+"spacer.gif' border='0' /></td><th>"+ts.p.caption+"</th>"+ ((ts.p.hidegrid===true) ? "<td class='HeaderButton'><img src='"+ts.p.imgpath+"up.gif' border='0'/></td>" :"") +"<td class='HeaderRight'><img src='"+ts.p.imgpath+"spacer.gif' border='0' /></td></tr></table>") .addClass("GridHeader").width(grid.width); $(grid.cDiv).insertBefore(grid.hDiv); if( ts.p.toolbar[0] ) { grid.uDiv = document.createElement("div"); if(ts.p.toolbar[1] == "top") {$(grid.uDiv).insertBefore(grid.hDiv);} else {$(grid.uDiv).insertAfter(grid.hDiv);} $(grid.uDiv).width(grid.width).addClass("userdata").attr("id","t_"+this.id); ts.p._height += parseInt($(grid.uDiv).height(),10); if(hg) {$(grid.uDiv).hide();} } if(ts.p.caption) { ts.p._height += parseInt($(grid.cDiv,ts).height(),10); var tdt = ts.p.datatype; if(ts.p.hidegrid===true) { $(".HeaderButton",grid.cDiv).toggle( function(){ if(ts.p.pager) {$(ts.p.pager).slideUp();} if(ts.p.toolbar[0]) {$(grid.uDiv,ts).slideUp();} $(grid.bDiv).hide(); $(grid.hDiv).slideUp(); $("img",this).attr("src",ts.p.imgpath+"down.gif"); ts.p.gridstate = 'hidden'; if(onHdCl) {if(!hg) {ts.p.onHeaderClick(ts.p.gridstate);}} }, function() { $(grid.hDiv).slideDown(); $(grid.bDiv).show(); if(ts.p.pager) {$(ts.p.pager).slideDown();} if(ts.p.toolbar[0]) {$(grid.uDiv).slideDown();} $("img",this).attr("src",ts.p.imgpath+"up.gif"); if(hg) {ts.p.datatype = tdt;populate();hg=false;} ts.p.gridstate = 'visible'; if(onHdCl) {ts.p.onHeaderClick(ts.p.gridstate)} } ); if(hg) { $(".HeaderButton",grid.cDiv).trigger("click"); ts.p.datatype="local";} } } else {$(grid.cDiv).hide();} ts.p._height += parseInt($(grid.hDiv,ts).height(),10); $(grid.hDiv).mousemove(function (e) {grid.dragMove(e.clientX); return false;}).after(grid.bDiv); $(document).mouseup(function (e) { if(grid.resizing) { grid.dragEnd(); if(grid.newWidth && ts.p.forceFit===false){ var gwdt = (grid.width <= ts.p._width) ? grid.width: ts.p._width; var overfl = (grid.width <= ts.p._width) ? "hidden" : "auto"; if(ts.p.pager && $(ts.p.pager).hasClass("scroll") ) { $(ts.p.pager).width(gwdt); } if(ts.p.caption) {$(grid.cDiv).width(gwdt);} if(ts.p.toolbar[0]) {$(grid.uDiv).width(gwdt);} $(grid.bDiv).width(gwdt).css("overflow-x",overfl); $(grid.hDiv).width(gwdt); } return false; } return true; }); ts.formatCol = function(a,b) {formatCol(a,b);}; ts.sortData = function(a,b,c){sortData(a,b,c);}; ts.updatepager = function(){updatepager();}; ts.formatter = function (elem, row, cellval , colpos, act){formatter(elem, row, cellval , colpos,act);}; $.extend(grid,{populate : function(){populate();}}); this.grid = grid; ts.addXmlData = function(d) {addXmlData(d,ts.grid.bDiv);}; ts.addJSONData = function(d) {addJSONData(d,ts.grid.bDiv);}; populate(); if (!ts.p.shrinkToFit) { ts.p.forceFit = false; $("tr:first th", thead).each(function(j){ var w = ts.p.colModel[j].owidth; var diff = w - ts.p.colModel[j].width; if (diff > 0 && !ts.p.colModel[j].hidden) { grid.headers[j].width = w; $(this).add(grid.cols[j]).width(w); $('table:first',grid.bDiv).add(grid.hTable).width(ts.grid.width); ts.grid.width += diff; grid.hDiv.scrollLeft = grid.bDiv.scrollLeft; } }); ofl2 = (grid.width <= ts.p._width) ? "hidden" : "auto"; $(grid.bDiv).css({"overflow-x":ofl2}); } $(window).unload(function () { $(this).unbind("*"); this.grid = null; this.p = null; }); }); }; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.base.js
JavaScript
gpl2
55,779
;(function($){ /** * jqGrid extension * Paul Tiseo ptiseo@wasteconsultants.com * * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ getPostData : function(){ var $t = this[0]; if(!$t.grid) { return; } return $t.p.postData; }, setPostData : function( newdata ) { var $t = this[0]; if(!$t.grid) { return; } // check if newdata is correct type if ( typeof(newdata) === 'object' ) { $t.p.postData = newdata; } else { alert("Error: cannot add a non-object postData value. postData unchanged."); } }, appendPostData : function( newdata ) { var $t = this[0]; if(!$t.grid) { return; } // check if newdata is correct type if ( typeof(newdata) === 'object' ) { $.extend($t.p.postData, newdata); } else { alert("Error: cannot append a non-object postData value. postData unchanged."); } }, setPostDataItem : function( key, val ) { var $t = this[0]; if(!$t.grid) { return; } $t.p.postData[key] = val; }, getPostDataItem : function( key ) { var $t = this[0]; if(!$t.grid) { return; } return $t.p.postData[key]; }, removePostDataItem : function( key ) { var $t = this[0]; if(!$t.grid) { return; } delete $t.p.postData[key]; }, getUserData : function(){ var $t = this[0]; if(!$t.grid) { return; } return $t.p.userData; }, getUserDataItem : function( key ) { var $t = this[0]; if(!$t.grid) { return; } return $t.p.userData[key]; } }); })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.postext.js
JavaScript
gpl2
1,601
;(function($){ /** * jqGrid German Translation * Version 1.0.0 (developed for jQuery Grid 3.3.1) * Olaf Klöppel opensource@blue-hit.de * http://blue-hit.de/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "Zeile(n)", loadtext: "Lädt...", pgtext : "/" }; $.jgrid.search = { caption: "Suche...", Find: "Finden", Reset: "Zurücksetzen", odata : ['gleich', 'ungleich', 'kleiner', 'kleiner oder gleich','größer','größer oder gleich', 'beginnt mit','endet mit','beinhaltet' ] }; $.jgrid.edit = { addCaption: "Datensatz hinzufügen", editCaption: "Datensatz bearbeiten", bSubmit: "Speichern", bCancel: "Abbrechen", bClose: "Schließen", processData: "Verarbeitung läuft...", msg: { required:"Feld ist erforderlich", number: "Bitte geben Sie eine Zahl ein", minValue:"Wert muss größer oder gleich sein, als ", maxValue:"Wert muss kleiner oder gleich sein, als ", email: "ist keine valide E-Mail Adresse", integer: "Bitte geben Sie eine Ganzzahl ein", date: "Please, enter valid date value" } }; $.jgrid.del = { caption: "Löschen", msg: "Ausgewählte Datensätze löschen?", bSubmit: "Löschen", bCancel: "Abbrechen", processData: "Verarbeitung läuft..." }; $.jgrid.nav = { edittext: " ", edittitle: "Ausgewählten Zeile editieren", addtext:" ", addtitle: "Neuen Zeile einfügen", deltext: " ", deltitle: "Ausgewählte Zeile löschen", searchtext: " ", searchtitle: "Datensatz finden", refreshtext: "", refreshtitle: "Tabelle neu laden", alertcap: "Warnung", alerttext: "Bitte Zeile auswählen" }; // setcolumns module $.jgrid.col ={ caption: "Spalten anzeigen/verbergen", bSubmit: "Speichern", bCancel: "Abbrechen" }; $.jgrid.errors = { errcap : "Fehler", nourl : "Keine URL angegeben", norecords: "Keine Datensätze zum verarbeiten", model : "Length of colNames <> colModel!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], AmPm : ["am","pm","AM","PM"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'}, srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'show' }; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-de.js
JavaScript
gpl2
3,620
;(function($){ /** * jqGrid Persian Translation * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "رديف", loadtext: "بارگزاري...", pgtext : "/" }; $.jgrid.search = { caption: "جستجو...", Find: "يافته ها", Reset: "نتايج", odata : ['مساوي', 'نا مساوي', 'کمتر از', 'کمتر يا مساوي','بزرگتر','بزرگتر يا مساوي', 'شروع با','خاتمه با','شامل' ] }; $.jgrid.edit = { addCaption: "اضافه کردن رکورد", editCaption: "ويرايش رکورد", bSubmit: "ثبت", bCancel: "انصراف", bClose: "بستن", processData: "پردازش...", msg: { required:"فيلدها بايد ختما پر شوند", number:"لطفا عدد وعتبر وارد کنيد", minValue:"مقدار وارد شده بايد بزرگتر يا مساوي با", maxValue:"مقدار وارد شده بايد کوچکتر يا مساوي", email: "پست الکترونيک وارد شده معتبر نيست", integer: "لطفا يک عدد صحيح وارد کنيد", date: "لطفا يک تاريخ معتبر وارد کنيد" } }; $.jgrid.del = { caption: "حذف", msg: "از حذف گزينه هاي انتخاب شده مطمئن هستيد؟", bSubmit: "حذف", bCancel: "ابطال", processData: "پردازش..." }; $.jgrid.nav = { edittext: " ", edittitle: "ويرايش رديف هاي انتخاب شده", addtext:" ", addtitle: "افزودن رديف جديد", deltext: " ", deltitle: "حذف ردبف هاي انتخاب شده", searchtext: " ", searchtitle: "جستجوي رديف", refreshtext: "", refreshtitle: "بازيابي مجدد صفحه", alertcap: "اخطار", alerttext: "لطفا يک رديف انتخاب کنيد" }; // setcolumns module $.jgrid.col ={ caption: "نمايش/عدم نمايش ستون", bSubmit: "ثبت", bCancel: "انصراف" }; $.jgrid.errors = { errcap : "خطا", nourl : "هيچ آدرسي تنظيم نشده است", norecords: "هيچ رکوردي براي پردازش موجود نيست", model : "طول نام ستون ها محالف ستون هاي مدل مي باشد!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "يک", "دو", "سه", "چهار", "پنج", "جمع", "شنب", "يکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "ژانويه", "فوريه", "مارس", "آوريل", "مه", "ژوئن", "ژوئيه", "اوت", "سپتامبر", "اکتبر", "نوامبر", "December" ], AmPm : ["ب.ظ","ب.ظ","ق.ظ","ق.ظ"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'}, srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'نمايش' }; // US // GB // CA // AU })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-fa.js
JavaScript
gpl2
4,083
;(function($){ /** * jqGrid Greek (el) Translation * Alex Cicovic * http://www.alexcicovic.com * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "Εγγραφές", loadtext: "Φόρτωση...", pgtext : "/" }; $.jgrid.search = { caption: "Αναζήτηση...", Find: "Εύρεση", Reset: "Επαναφορά", odata : ['ίσο', 'άνισο', 'μικρότερο από', 'μικρότερο ή ίσο','μεγαλύτερο από','μεγαλύτερο ή ίσο', 'ξεκινά με','τελειώνει με','εμπεριέχει' ] }; $.jgrid.edit = { addCaption: "Εισαγωγή Εγγραφής", editCaption: "Επεξεργασία Εγγραφής", bSubmit: "Καταχώρηση", bCancel: "Άκυρο", bClose: "Κλείσιμο", processData: "Υπό επεξεργασία...", msg: { required:"Το πεδίο είναι απαραίτητο", number:"Το πεδίο δέχεται μόνο αριθμούς", minValue:"Η τιμή πρέπει να είναι μεγαλύτερη ή ίση του ", maxValue:"Η τιμή πρέπει να είναι μικρότερη ή ίση του ", email: "Η διεύθυνση e-mail δεν είναι έγκυρη", integer: "Το πεδίο δέχεται μόνο ακέραιους αριθμούς", date: "Ή ημερομηνία δεν είναι έγκυρη" } }; $.jgrid.del = { caption: "Διαγραφή", msg: "Διαγραφή των επιλεγμένων εγγραφών;", bSubmit: "Ναι", bCancel: "Άκυρο", processData: "Υπό επεξεργασία..." }; $.jgrid.nav = { edittext: " ", edittitle: "Επεξεργασία επιλεγμένης εγγραφής", addtext:" ", addtitle: "Εισαγωγή νέας εγγραφής", deltext: " ", deltitle: "Διαγραφή επιλεγμένης εγγραφής", searchtext: " ", searchtitle: "Εύρεση Εγγραφών", refreshtext: "", refreshtitle: "Ανανέωση Πίνακα", alertcap: "Προσοχή", alerttext: "Δεν έχετε επιλέξει εγγραφή" }; // setcolumns module $.jgrid.col ={ caption: "Εμφάνιση / Απόκρυψη Στηλών", bSubmit: "ΟΚ", bCancel: "Άκυρο" }; $.jgrid.errors = { errcap : "Σφάλμα", nourl : "Δεν έχει δοθεί διεύθυνση χειρισμού για τη συγκεκριμένη ενέργεια", norecords: "Δεν υπάρχουν εγγραφές προς επεξεργασία", model : "Άνισος αριθμός πεδίων colNames/colModel!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ", "Κυριακή", "Δευτέρα", "Τρίτη", "Τετάρτη", "Πέμπτη", "Παρασκευή", "Σάββατο" ], monthNames: [ "Ιαν", "Φεβ", "Μαρ", "Απρ", "Μαι", "Ιουν", "Ιουλ", "Αυγ", "Σεπ", "Οκτ", "Νοε", "Δεκ", "Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος" ], AmPm : ["πμ","μμ","ΠΜ","ΜΜ"], S: function (j) {return j == 1 || j > 1 ? ['η'][Math.min((j - 1) % 10, 3)] : ''}, srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', // showlink showAction: 'show' // showlink }; // US // GB // CA // AU })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-el.js
JavaScript
gpl2
4,611
/* Transform a table to a jqGrid. Peter Romianowski <peter.romianowski@optivo.de> If the first column of the table contains checkboxes or radiobuttons then the jqGrid is made selectable. */ // Addition - selector can be a class or id function tableToGrid(selector) { $(selector).each(function() { if(this.grid) {return;} //Adedd from Tony Tomov // This is a small "hack" to make the width of the jqGrid 100% $(this).width("99%"); var w = $(this).width(); // Text whether we have single or multi select var inputCheckbox = $('input[type=checkbox]:first', $(this)); var inputRadio = $('input[type=radio]:first', $(this)); var selectMultiple = inputCheckbox.length > 0; var selectSingle = !selectMultiple && inputRadio.length > 0; var selectable = selectMultiple || selectSingle; var inputName = inputCheckbox.attr("name") || inputRadio.attr("name"); // Build up the columnModel and the data var colModel = []; var colNames = []; $('th', $(this)).each(function() { if (colModel.length == 0 && selectable) { colModel.push({ name: '__selection__', index: '__selection__', width: 0, hidden: true }); colNames.push('__selection__'); } else { colModel.push({ name: $(this).html(), index: $(this).html(), width: $(this).width() || 150 }); colNames.push($(this).html()); } }); var data = []; var rowIds = []; var rowChecked = []; $('tbody > tr', $(this)).each(function() { var row = {}; var rowPos = 0; data.push(row); $('td', $(this)).each(function() { if (rowPos == 0 && selectable) { var input = $('input', $(this)); var rowId = input.attr("value"); rowIds.push(rowId || data.length); if (input.attr("checked")) { rowChecked.push(rowId); } row[colModel[rowPos].name] = input.attr("value"); } else { row[colModel[rowPos].name] = $(this).html(); } rowPos++; }); }); // Clear the original HTML table $(this).empty(); // Mark it as jqGrid $(this).addClass("scroll"); $(this).jqGrid({ datatype: "local", width: w, colNames: colNames, colModel: colModel, multiselect: selectMultiple //inputName: inputName, //inputValueCol: imputName != null ? "__selection__" : null }); // Add data for (var a = 0; a < data.length; a++) { var id = null; if (rowIds.length > 0) { id = rowIds[a]; if (id && id.replace) { // We have to do this since the value of a checkbox // or radio button can be anything id = encodeURIComponent(id).replace(/[.\-%]/g, "_"); } } if (id == null) { id = a + 1; } $(this).addRowData(id, data[a]); } // Set the selection for (var a = 0; a < rowChecked.length; a++) { $(this).setSelection(rowChecked[a]); } }); };
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.tbltogrid.js
JavaScript
gpl2
2,719
;(function($){ /** * jqGrid extension for SubGrid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ addSubGrid : function(t,row,pos,rowelem) { return this.each(function(){ var ts = this; if (!ts.grid ) { return; } var td, res,_id, pID, nhc, bfsc; td = document.createElement("td"); $(td,t).html("<img src='"+ts.p.imgpath+"plus.gif'/>").addClass("sgcollapsed") .click( function(e) { if($(this).hasClass("sgcollapsed")) { pID = $("table:first",ts.grid.bDiv).attr("id"); res = $(this).parent(); var atd= pos==1?'<td></td>':''; _id = $(res).attr("id"); bfsc =true; if($.isFunction(ts.p.subGridBeforeExpand)) { bfsc = ts.p.subGridBeforeExpand(pID+"_"+_id,_id); } if(bfsc === false) {return false;} nhc = 0; $.each(ts.p.colModel,function(i,v){ if(this.hidden === true) { nhc++; } }); var subdata = "<tr class='subgrid'>"+atd+"<td><img src='"+ts.p.imgpath+"line3.gif'/></td><td colspan='"+parseInt(ts.p.colNames.length-1-nhc)+"'><div id="+pID+"_"+_id+" class='tablediv'>"; $(this).parent().after( subdata+ "</div></td></tr>" ); $(".tablediv",ts).css("width", ts.grid.width-20+"px"); if( $.isFunction(ts.p.subGridRowExpanded) ) { ts.p.subGridRowExpanded(pID+"_"+ _id,_id); } else { populatesubgrid(res); } $(this).html("<img src='"+ts.p.imgpath+"minus.gif'/>").removeClass("sgcollapsed").addClass("sgexpanded"); } else if($(this).hasClass("sgexpanded")) { bfsc = true; if( $.isFunction(ts.p.subGridRowColapsed)) { res = $(this).parent(); _id = $(res).attr("id"); bfsc = ts.p.subGridRowColapsed(pID+"_"+_id,_id ); }; if(bfsc===false) {return false;} $(this).parent().next().remove(".subgrid"); $(this).html("<img src='"+ts.p.imgpath+"plus.gif'/>").removeClass("sgexpanded").addClass("sgcollapsed"); } return false; }); row.appendChild(td); //------------------------- var populatesubgrid = function( rd ) { var res,sid,dp; sid = $(rd).attr("id"); dp = {id:sid, nd_: (new Date().getTime())}; if(!ts.p.subGridModel[0]) { return false; } if(ts.p.subGridModel[0].params) { for(var j=0; j < ts.p.subGridModel[0].params.length; j++) { for(var i=0; i<ts.p.colModel.length; i++) { if(ts.p.colModel[i].name == ts.p.subGridModel[0].params[j]) { dp[ts.p.colModel[i].name]= $("td:eq("+i+")",rd).text().replace(/\&nbsp\;/ig,''); } } } } if(!ts.grid.hDiv.loading) { ts.grid.hDiv.loading = true; $("div.loading",ts.grid.hDiv).fadeIn("fast"); if(!ts.p.subgridtype) ts.p.subgridtype = ts.p.datatype; if($.isFunction(ts.p.subgridtype)) { ts.p.subgridtype(dp); } switch(ts.p.subgridtype) { case "xml": $.ajax({ type:ts.p.mtype, url: ts.p.subGridUrl, dataType:"xml", data: dp, complete: function(sxml) { subGridXml(sxml.responseXML, sid); } }); break; case "json": $.ajax({ type:ts.p.mtype, url: ts.p.subGridUrl, dataType:"json", data: dp, complete: function(JSON) { subGridJson(eval("("+JSON.responseText+")"),sid); } }); break; } } return false; }; var subGridCell = function(trdiv,cell,pos){ var tddiv = document.createElement("div"); tddiv.className = "celldiv"; $(tddiv).html(cell); $(tddiv).width( ts.p.subGridModel[0].width[pos] || 80); trdiv.appendChild(tddiv); }; var subGridXml = function(sjxml, sbid){ var trdiv, tddiv,result = "", i,cur, sgmap, dummy = document.createElement("span"); trdiv = document.createElement("div"); trdiv.className="rowdiv"; for (i = 0; i<ts.p.subGridModel[0].name.length; i++) { tddiv = document.createElement("div"); tddiv.className = "celldivth"; $(tddiv).html(ts.p.subGridModel[0].name[i]); $(tddiv).width( ts.p.subGridModel[0].width[i]); trdiv.appendChild(tddiv); } dummy.appendChild(trdiv); if (sjxml){ sgmap = ts.p.xmlReader.subgrid; $(sgmap.root+">"+sgmap.row, sjxml).each( function(){ trdiv = document.createElement("div"); trdiv.className="rowdiv"; if(sgmap.repeatitems === true) { $(sgmap.cell,this).each( function(i) { subGridCell(trdiv, this.textContent || this.text || '&nbsp;',i); }); } else { var f = ts.p.subGridModel[0].mapping; if (f) { for (i=0;i<f.length;i++) { subGridCell(trdiv, $(f[i],this).text() || '&nbsp;',i); } } } dummy.appendChild(trdiv); }); var pID = $("table:first",ts.grid.bDiv).attr("id")+"_"; $("#"+pID+sbid).append($(dummy).html()); sjxml = null; ts.grid.hDiv.loading = false; $("div.loading",ts.grid.hDiv).fadeOut("fast"); } return false; }; var subGridJson = function(sjxml, sbid){ var trdiv, tddiv,result = "", i,cur, sgmap, dummy = document.createElement("span"); trdiv = document.createElement("div"); trdiv.className="rowdiv"; for (i = 0; i<ts.p.subGridModel[0].name.length; i++) { tddiv = document.createElement("div"); tddiv.className = "celldivth"; $(tddiv).html(ts.p.subGridModel[0].name[i]); $(tddiv).width( ts.p.subGridModel[0].width[i]); trdiv.appendChild(tddiv); } dummy.appendChild(trdiv); if (sjxml){ //sjxml = eval("("+sjxml.responseText+")"); sgmap = ts.p.jsonReader.subgrid; for (i=0;i<sjxml[sgmap.root].length;i++) { cur = sjxml[sgmap.root][i]; trdiv = document.createElement("div"); trdiv.className="rowdiv"; if(sgmap.repeatitems === true) { if(sgmap.cell) { cur=cur[sgmap.cell]; } for (var j=0;j<cur.length;j++) { subGridCell(trdiv, cur[j] || '&nbsp;',j); } } else { var f = ts.p.subGridModel[0].mapping; if(f.length) { for (var j=0;j<f.length;j++) { subGridCell(trdiv, cur[f[j]] || '&nbsp;',j); } } } dummy.appendChild(trdiv); } var pID = $("table:first",ts.grid.bDiv).attr("id")+"_"; $("#"+pID+sbid).append($(dummy).html()); sjxml = null; ts.grid.hDiv.loading = false; $("div.loading",ts.grid.hDiv).fadeOut("fast"); } return false; }; ts.subGridXml = function(xml,sid) {subGridXml(xml,sid);}; ts.subGridJson = function(json,sid) {subGridJson(json,sid);}; }); }, expandSubGridRow : function(rowid) { return this.each(function () { var $t = this; if(!$t.grid && !rowid) {return;} if($t.p.subGrid===true) { var rc = $(this).getInd($t.rows,rowid,true); if(rc) { var sgc = $("td.sgcollapsed",rc)[0]; if(sgc) { $(sgc).trigger("click"); } } } }); }, collapseSubGridRow : function(rowid) { return this.each(function () { var $t = this; if(!$t.grid && !rowid) {return;} if($t.p.subGrid===true) { var rc = $(this).getInd($t.rows,rowid,true); if(rc) { var sgc = $("td.sgexpanded",rc)[0]; if(sgc) { $(sgc).trigger("click"); } } } }); }, toggleSubGridRow : function(rowid) { return this.each(function () { var $t = this; if(!$t.grid && !rowid) {return;} if($t.p.subGrid===true) { var rc = $(this).getInd($t.rows,rowid,true); if(rc) { var sgc = $("td.sgcollapsed",rc)[0]; if(sgc) { $(sgc).trigger("click"); } else { sgc = $("td.sgexpanded",rc)[0]; if(sgc) { $(sgc).trigger("click"); } } } } }); } }); })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.subgrid.js
JavaScript
gpl2
7,827
/* * jqModal - Minimalist Modaling with jQuery * (http://dev.iceburg.net/jquery/jqModal/) * * Copyright (c) 2007,2008 Brice Burgess <bhb@iceburg.net> * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * $Version: 03/01/2009 +r14 */ (function($) { $.fn.jqm=function(o){ var p={ overlay: 50, overlayClass: 'jqmOverlay', closeClass: 'jqmClose', trigger: '.jqModal', ajax: F, ajaxText: '', target: F, modal: F, toTop: F, onShow: F, onHide: F, onLoad: F }; return this.each(function(){if(this._jqm)return H[this._jqm].c=$.extend({},H[this._jqm].c,o);s++;this._jqm=s; H[s]={c:$.extend(p,$.jqm.params,o),a:F,w:$(this).addClass('jqmID'+s),s:s}; if(p.trigger)$(this).jqmAddTrigger(p.trigger); });}; $.fn.jqmAddClose=function(e){return hs(this,e,'jqmHide');}; $.fn.jqmAddTrigger=function(e){return hs(this,e,'jqmShow');}; $.fn.jqmShow=function(t){return this.each(function(){t=t||window.event;$.jqm.open(this._jqm,t);});}; $.fn.jqmHide=function(t){return this.each(function(){t=t||window.event;$.jqm.close(this._jqm,t)});}; $.jqm = { hash:{}, open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(parseInt(h.w.css('z-index'))),z=(z>0)?z:3000,o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});if(h.a)return F;h.t=t;h.a=true;h.w.css('z-index',z); if(c.modal) {if(!A[0])L('bind');A.push(s);} else if(c.overlay > 0)h.w.jqmAddClose(o); else o=F; h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):F; if(ie6){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in {Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}} if(c.ajax) {var r=c.target||h.w,u=c.ajax,r=(typeof r == 'string')?$(r,h.w):$(r),u=(u.substr(0,1) == '@')?$(t).attr(u.substring(1)):u; r.html(c.ajaxText).load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});} else if(cc)h.w.jqmAddClose($(cc,h.w)); if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o); (c.onShow)?c.onShow(h):h.w.show();e(h);return F; }, close:function(s){var h=H[s];if(!h.a)return F;h.a=F; if(A[0]){A.pop();if(!A[0])L('unbind');} if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove(); if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();} return F; }, params:{}}; var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version == "6.0"),F=false, i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}), e=function(h){if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i); f(h);}, f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(_){}}, L=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);}, m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return !r;}, hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function() { if(!this[c]){this[c]=[];$(this).click(function(){for(var i in {jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return F;});}this[c].push(s);});});}; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/jqModal.js
JavaScript
gpl2
3,355
/** * Styleswitch stylesheet switcher built on jQuery * Under an Attribution, Share Alike License * By Kelvin Luck ( http://www.kelvinluck.com/ ) **/ /* $(document).ready(function() { $('.styleswitch').click(function() { switchStylestyle(this.getAttribute("rel")); return false; }); var c = readCookie('style'); if (c) switchStylestyle(c); }); */ function switchStylestyle(styleName) { $('link[rel*=style][title]').each(function(i) { this.disabled = true; if (this.getAttribute('title') == styleName) this.disabled = false; }); createCookie('style', styleName, 365); } // cookie functions http://www.quirksmode.org/js/cookies.html function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } // /cookie functions
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/styleswitch.js
JavaScript
gpl2
1,287
;(function ($) { $.fn.jqTree = function( url, p ) { p = $.extend({ useDblClicks : false, //not used yet saveNodesStateInCookies : true, expandedClassName : "", collapsedClassName: "collapsed", selectedClassName : "selected", plusMinusClassName : "plusminus", treeClass : "tree", imgpath: "", collapsedImage : "plus.gif", expandedImage : "minus.gif", noChildrenImage : "nochild.gif", defaultImage : "folder.png", xmlCaption : "caption", xmlUrl : "url", xmlId : "id", xmlRetreiveUrl : "retreiveUrl", xmlIcon : "icon", xmlExpanded : "expanded", loadingText : "Loading ...", onSelectNode : null, params: {} }, p || {}); return this.each( function( ) { Tree = function() {} /* Private members */ Tree.obj = null; Tree.instanceCount = 0; Tree.instancePrefix = "alder"; Tree.cookiePrefix = "alder"; Tree.dwnldQueue = new Array; Tree.dwnldCheckTimeout = 100; /* Interval handler. Ckecks for new nodes loaded. Adds loaded nodes to the tree. */ Tree.checkLoad = function () { var i, httpReq; for (i = 0; i<Tree.dwnldQueue.length; i++) if ((httpReq = Tree.dwnldQueue[i][0]).readyState == 4 /*COMPLETED*/) { var node = Tree.dwnldQueue[i][1]; // unqueue loaded item Tree.dwnldQueue.splice(i, 1); Tree.appendLoadedNode(httpReq, node); if ($t.p.saveNodesStateInCookies) Tree.openAllSaved(Tree.getId(node)); } // will call next time, not all nodes were loaded if (Tree.dwnldQueue.length != 0) window.setTimeout(Tree.checkLoad, Tree.dwnldCheckTimeout); } /* Adds loaded node to tree. */ Tree.appendLoadedNode = function (httpReq, node) { // create DomDocument from loaded text var xmlDoc = Tree.loadXml(httpReq.responseText); // create tree nodes from xml loaded var newNode = Tree.convertXml2NodeList(xmlDoc.documentElement); // Add loading error handling here must be added node.replaceChild(newNode, Tree.getNodeSpan(node)); } /* Event handler when node is clicked. Navigates node link, and makes node selected. */ Tree.NodeClick = function (node) { // var node = event.srcElement /*IE*/ || event.target /*DOM*/; // <li><a><img> - <img> is capturing the event // alert($(node).attr("id")) // if ($t.p.onSelectNode) $t.p.onSelectNode( $(node).attr("id"), $(node).attr("title"), node.parentNode.empty ) while (node.tagName != "A") node = node.parentNode; node.blur(); node = node.parentNode; Tree.obj = Tree.getObj(node); Tree.expandNode(node); Tree.selectNode(node); } /* Event handler when plus/minus icon is clicked. Desides whenever node should be expanded or collapsed. */ Tree.ExpandCollapseNode = function (event) { var anchorClicked = event.srcElement /*IE*/ || event.target /*DOM*/; // <li><a><img> - <img> is capturing the event while (anchorClicked.tagName != "A") anchorClicked = anchorClicked.parentNode; anchorClicked.blur(); var node = anchorClicked.parentNode; // node has no children, and cannot be expanded or collapsed if (node.empty) return; Tree.obj = Tree.getObj(node); if (Tree.isNodeCollapsed(node)) Tree.expandNode(node); else Tree.collapseNode(node); // cancelling the event to prevent navigation. if (event.preventDefault == undefined) { // IE event.cancelBubble = true; event.returnValue = false; } // if else { // DOM event.preventDefault(); event.cancelBubble = true; } // else } /* Determines if specified node is selected. */ Tree.isNodeSelected = function (node) { return (node.isSelected == true) || (Tree.obj.selectedNode == node); } /* Determines if specified node is expanded. */ Tree.isNodeExpanded = function (node) { return ($t.p.expandedClassName == node.className) || (node.expanded == true); } /* Determines if specified node is collapsed. */ Tree.isNodeCollapsed = function (node) { return ($t.p.collapsedClassName == node.className) || (node.collapsed == true); } /* Determines if node currently selected is at same level as node specified (has same root). */ Tree.isSelectedNodeAtSameLevel = function (node) { if (Tree.obj.selectedNode == null) // no node currently selected return false; var i, currentNode, children = node.parentNode.childNodes; // all nodes at same level (li->ul->childNodes) for (i = 0; i < children.length; i++) if ((currentNode = children[i]) != node && Tree.isNodeSelected(currentNode)) return true; return false; } /* Mark node as selected and unmark prevoiusly selected. Node is marked with attribute and <a> is marked with css style to avoid mark <li> twise with css style expanded and selected. */ Tree.selectNode = function (node) { if (Tree.isNodeSelected(node)) // already marked return; if (Tree.obj.selectedNode != null) {// unmark previously selected node. Tree.obj.selectedNode.isSelected = false; // remove css style from anchor $("A",Tree.obj.selectedNode).get(1).className = ""; } // if // collapse selected node if at same level if (Tree.isSelectedNodeAtSameLevel(node)) Tree.collapseNode(Tree.obj.selectedNode); // mark node as selected Tree.obj.selectedNode = node; node.isSelected = true; $("A",node).get(1).className = $t.p.selectedClassName; } /* Expand collapsed node. Loads children nodes if needed. */ Tree.expandNode = function (node, avoidSaving) { if (node.empty) return; $("IMG",node).get(0).src = $t.p.expandedImage; node.className = $t.p.expandedClassName; node.expanded = true; node.collapsed = false; if (Tree.getNodeSpan(node) != null) Tree.loadChildren(node); if ($t.p.saveNodesStateInCookies && !avoidSaving) Tree.saveOpenedNode(node); } /* Collapse expanded node. */ Tree.collapseNode = function (node, avoidSaving) { if (node.empty) return; $("IMG",node).get(0).src = $t.p.collapsedImage; node.className = $t.p.collapsedClassName; node.collapsed = true; node.expanded = false; if ($t.p.saveNodesStateInCookies && !avoidSaving) Tree.saveClosedNode(node); } /* Cancel loading children nodes. */ Tree.CancelLoad = function (event) { var i, node = event.srcElement /*IE*/ || event.target /*DOM*/; while (node.tagName != "LI") node = node.parentNode; // search node in queue for (i = 0; i<Tree.dwnldQueue.length; i++) if (Tree.dwnldQueue[i][1] == node) { // remove from queue Tree.dwnldQueue.splice(i, 1); // collapse node Tree.collapseNode(node); } // if } /* Loads text from url specified and returns it as result. */ Tree.loadUrl = function (purl, pasync) { var ret = $.ajax({async:pasync, type:"GET", url: purl, dataType:"xml", data:$t.p.params, error: function(req,err,x){ alert(req.responseText + " Error Type: "+err+":"+x ); } }); return pasync == true ? ret : ret.responseText; } /* Creates XmlDom document from xml text string. */ Tree.loadXml = function (xmlString) { var xmlDoc; if (window.DOMParser) /*Mozilla*/ xmlDoc = new DOMParser().parseFromString(xmlString, "text/xml"); else { if (document.implementation && document.implementation.createDocument) xmlDoc = document.implementation.createDocument("","", null); /*Konqueror*/ else xmlDoc = new ActiveXObject("Microsoft.XmlDom"); /*IE*/ xmlDoc.async = false; xmlDoc.loadXML(xmlString); } // else return xmlDoc; } /* Finds loading span for node. */ Tree.getNodeSpan = function (node) { var span = $("span",node); return (span.length > 0 && (span = span[0]).parentNode == node) ? span : null; } /* Enqueue load of children nodes for node specified. */ Tree.loadChildren = function (node) { // get url with children - Opera do not like # var url = $("A",node)[0].href url = url != null && url.length != 0 && url != "#" ? url : "javascript:void(0)"; // retreive xml text from url var httpReq = Tree.loadUrl(url, true); // enqueue node loading if (Tree.dwnldQueue.push(new Array (httpReq, node)) == 1){ window.setTimeout(Tree.checkLoad, Tree.dwnldCheckTimeout); } } /* Creates HTML nodes list from XML nodes. */ Tree.convertXml2NodeList = function (xmlElement) { var ul = document.createElement("UL"); var index = 0; $(xmlElement.childNodes).each(function () { if (this.nodeType == 1 ) /* ELEMENT_NODE */ { ul.appendChild(Tree.convertXml2Node(this)).nodeIndex = index++; } }); return ul; } /* Creates HTML tree node (<li>) from xml element. */ Tree.convertXml2Node = function (xmlElement) { var li = document.createElement("LI"); var a1 = document.createElement("A"); var a2 = document.createElement("A"); var i1 = document.createElement("IMG"); var i2 = document.createElement("IMG"); var hasChildNodes = false; $(xmlElement.childNodes).each(function () { if (this.nodeType === 1 ) {/* ELEMENT_NODE */ hasChildNodes = true; return false; } }); var retreiveUrl = $(xmlElement).attr($t.p.xmlRetreiveUrl); // plus/minus icon i1.className = $t.p.plusMinusClassName; a1.appendChild(i1); $(a1).click( function(e) {Tree.ExpandCollapseNode(e);} ) // plus/minus link a1.href = retreiveUrl != null && retreiveUrl.length != 0 && retreiveUrl != "#" ? retreiveUrl : "javascript:void(0)"; li.appendChild(a1); // node icon var icoimg = $.trim($(xmlElement).attr($t.p.xmlIcon)); if ( icoimg && icoimg.length !=0) { i2.src = $t.p.imgpath+icoimg; } else { i2.src = $t.p.defaultImage;} // i2.src = $(xmlElement).attr(p.xmlIcon) || p.defaultImage; a2.appendChild(i2); // node link var lnk = $(xmlElement).attr($t.p.xmlUrl); a2.href = lnk != null && lnk.length !=0 && lnk != "#" ? $(xmlElement).attr($t.p.xmlUrl) : "javascript:void(0)"; a2.id = $(xmlElement).attr($t.p.xmlId) || "none"; a2.title = $(xmlElement).attr($t.p.xmlCaption); a2.appendChild(document.createTextNode($(xmlElement).attr($t.p.xmlCaption))); $(a2).click( function(e) { var node = e.srcElement /*IE*/ || e.target; Tree.NodeClick(node); var isLeaf = false; if( this.parentNode.empty ) { isLeaf = true; } else { if(this.parentNode.childNodes[2].childNodes.length == 0 ) isLeaf = true; } if ($t.p.onSelectNode) $t.p.onSelectNode( $(this).attr("id"), $(this).attr("title"), isLeaf ); //alert(Tree.obj); }); li.appendChild(a2); // loading span if (!hasChildNodes && retreiveUrl != null && retreiveUrl.length != 0) { var span = document.createElement("SPAN"); $(span).html($t.p.loadingText); $(span).click( function(e) {Tree.CancelLoad(e);} ) li.appendChild(span); } // if // add children if (hasChildNodes) li.appendChild(Tree.convertXml2NodeList(xmlElement)); if (hasChildNodes || retreiveUrl != null && retreiveUrl.length != 0) { if ($(xmlElement).attr($t.p.xmlExpanded)=== "true") Tree.expandNode(li, true); else Tree.collapseNode(li, true); } // if else { i1.src = $t.p.noChildrenImage; // no children li.empty = true; } // else return li; } /* Retreives current tree object. */ Tree.getObj = function (node) { var obj = node; while (obj != null && obj.tagName != "DIV") obj = obj.parentNode; return obj; } Tree.getId = function (node) { var obj = Tree.getObj(node); if (obj) return obj.id; return ""; } /* Retreives unique id for tree node. */ Tree.getNodeId = function (node) { var id = ""; var obj = node; while (obj != null && obj.tagName != "DIV") { if (obj.tagName == "LI" && obj.nodeIndex != null) id = "_" + obj.nodeIndex + id; obj = obj.parentNode; } // while // if (obj != null && obj.tagName == "DIV") // id = obj.id + "_" + id; return id; } /* Saves node as opened for reload. */ Tree.saveOpenedNode = function (node) { var treeId = Tree.getId(node); var state = Tree.getAllNodesSavedState(treeId); var nodeState = Tree.getNodeId(node) + ","; if (state.indexOf(nodeState) == -1) { state += nodeState; Tree.setAllNodesSavedState(treeId, state); } // if } /* Saves node as closed for reload. */ Tree.saveClosedNode = function (node) { var treeId = Tree.getId(node); var state = Tree.getAllNodesSavedState(treeId); state = state.replace(new RegExp(Tree.getNodeId(node) + ",", "g"), ""); Tree.setAllNodesSavedState(treeId, state); } Tree.getAllNodesSavedState = function (treeId) { var state = Tree.getCookie(Tree.cookiePrefix + "_" + treeId); return state == null ? "" : state; } Tree.setAllNodesSavedState = function (treeId, state) { Tree.setCookie(Tree.cookiePrefix + "_" + treeId, state); } /* Enques list of all opened nodes */ Tree.openAllSaved = function(treeId) { var nodes = Tree.getAllNodesSavedState(treeId).split(","); var i; for (i=0; i<nodes.length; i++) { var node = Tree.getNodeById(treeId, nodes[i]); if (node && Tree.isNodeCollapsed(node)) Tree.expandNode(node); } // for } Tree.getNodeById = function(treeId, nodeId) { var node = document.getElementById(treeId); if (!node) return null; var path = nodeId.split("_"); var i; for (i=1; i<path.length; i++) { if (node != null) { node = node.firstChild; while (node != null && node.tagName != "UL") node = node.nextSibling; } // if if (node != null) node = node.childNodes[path[i]]; else break; } // for return node; } Tree.setCookie = function(sName, sValue) { document.cookie = sName + "=" + escape(sValue) + ";"; } Tree.getCookie = function(sName) { var a = document.cookie.split("; "); for (var i=0; i < a.length; i++) { var aa = a[i].split("="); if (sName == aa[0]) return unescape(aa[1]); } // for return null; } if(p.imgpath !== "" ) { p.collapsedImage = p.imgpath+p.collapsedImage; p.expandedImage = p.imgpath+p.expandedImage; p.noChildrenImage = p.imgpath+p.noChildrenImage; p.defaultImage = p.imgpath+p.defaultImage; } this.p = p; var $t = this; var div = document.createElement("DIV"); div.id = Tree.instancePrefix + this.id; //Tree.instanceCount++; div.className = $t.p.treeClass; //if(typeof $t.p.onSelectNode !== 'function') {$t.p.onSelectNode=false;} var xml = Tree.loadUrl(url, false); var xmlDoc = Tree.loadXml(xml); var newNode = Tree.convertXml2NodeList(xmlDoc.documentElement); xml = null; div.appendChild(newNode); if (this != undefined) { if (this.appendChild) // is node this.appendChild(div); else if ($(this)) // is node id $(this).appendChild(div); } // if if ($t.p.saveNodesStateInCookies) this.Tree.openAllSaved(div.id); $(window).unload( function() { this.Tree = null;} ) }); } })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/jquery.jqTree.js
JavaScript
gpl2
14,642
/* * jquery.splitter.js - two-pane splitter window plugin * * version 1.01 (01/05/2007) * * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html */ /** * The splitter() plugin implements a two-pane resizable splitter window. * The selected elements in the jQuery object are converted to a splitter; * each element should have two child elements which are used for the panes * of the splitter. The plugin adds a third child element for the splitbar. * * For more details see: http://methvin.com/jquery/splitter/ * * * @example $('#MySplitter').splitter(); * @desc Create a vertical splitter with default settings * * @example $('#MySplitter').splitter({direction: 'h', accessKey: 'M'}); * @desc Create a horizontal splitter resizable via Alt+Shift+M * * @name splitter * @type jQuery * @param String options Options for the splitter * @cat Plugins/Splitter * @return jQuery * @author Dave Methvin (dave.methvin@gmail.com) */ jQuery.fn.splitter = function(opts){ opts = jQuery.extend({ type: 'v', // v=vertical, h=horizontal split activeClass: 'active', // class name for active splitter pxPerKey: 5, // splitter px moved per keypress tabIndex: 0, // tab order indicator accessKey: '' // accelerator key for splitter // initA initB // initial A/B size (pick ONE) // minA maxA minB maxB // min/max pane sizes },{ v: { // Vertical splitters: keyGrowA: 39, // left arrow key keyShrinkA: 37, // right arrow key cursor: "e-resize", // double-arrow horizontal splitbarClass: "vsplitbar", eventPos: "pageX", set: "left", adjust: "width", offsetAdjust: "offsetWidth", adjSide1: "Left", adjSide2: "Right", fixed: "height", offsetFixed: "offsetHeight", fixSide1: "Top", fixSide2: "Bottom" }, h: { // Horizontal splitters: keyGrowA: 40, // down arrow key keyShrinkA: 38, // up arrow key cursor: "n-resize", // double-arrow vertical splitbarClass: "hsplitbar", eventPos: "pageY", set: "top", adjust: "height", offsetAdjust: "offsetHeight", adjSide1: "Top", adjSide2: "Bottom", fixed: "width", offsetFixed: "offsetWidth", fixSide1: "Left", fixSide2: "Right" } }[((opts||{}).type||'v').charAt(0).toLowerCase()], opts||{}); return this.each(function() { function startSplit(e) { splitbar.addClass(opts.activeClass); if ( e.type == "mousedown" ) { paneA._posAdjust = paneA[0][opts.offsetAdjust] - e[opts.eventPos]; jQuery(document) .bind("mousemove", doSplitMouse) .bind("mouseup", endSplit); } return true; // required??? } function doSplitKey(e) { var key = e.which || e.keyCode; var dir = key==opts.keyGrowA? 1 : key==opts.keyShrinkA? -1 : 0; if ( dir ) moveSplitter(paneA[0][opts.offsetAdjust]+dir*opts.pxPerKey); return true; // required??? } function doSplitMouse(e) { moveSplitter(paneA._posAdjust+e[opts.eventPos]); } function endSplit(e) { splitbar.removeClass(opts.activeClass); jQuery(document) .unbind("mousemove", doSplitMouse) .unbind("mouseup", endSplit); } function moveSplitter(np) { // Constrain new position to fit pane size limits; 16=scrollbar fudge factor // TODO: enforce group width in IE6 since it lacks min/max css properties? np = Math.max(paneA._min+paneA._padAdjust, group._adjust - (paneB._max||9999), 16, Math.min(np, paneA._max||9999, group._adjust - splitbar._adjust - Math.max(paneB._min+paneB._padAdjust, 16))); // Resize/position the two panes and splitbar splitbar.css(opts.set, np+"px"); paneA.css(opts.adjust, np-paneA._padAdjust+"px"); paneB.css(opts.set, np+splitbar._adjust+"px") .css(opts.adjust, group._adjust-splitbar._adjust-paneB._padAdjust-np+"px"); // IE fires resize for us; all others pay cash if ( !jQuery.browser.msie ) { paneA.trigger("resize"); paneB.trigger("resize"); } } function cssCache(jq, n, pf, m1, m2) { // IE backCompat mode thinks width/height includes border and padding jq[n] = jQuery.boxModel? (parseInt(jq.css(pf+m1))||0) + (parseInt(jq.css(pf+m2))||0) : 0; } function optCache(jq, pane) { // Opera returns -1px for min/max dimensions when they're not there! jq._min = Math.max(0, opts["min"+pane] || parseInt(jq.css("min-"+opts.adjust)) || 0); jq._max = Math.max(0, opts["max"+pane] || parseInt(jq.css("max-"+opts.adjust)) || 0); } // Create jQuery object closures for splitter group and both panes var group = jQuery(this).css({position: "relative"}); var divs = jQuery(">div", group).css({ position: "absolute", // positioned inside splitter container margin: "0", // remove any stylesheet margin or ... border: "0", // ... border added for non-script situations "-moz-user-focus": "ignore" // disable focusability in Firefox }); var paneA = jQuery(divs[0]); // left or top var paneB = jQuery(divs[1]); // right or bottom // Focuser element, provides keyboard support var focuser = jQuery('<a href="javascript:void(0)"></a>') .bind("focus", startSplit).bind("keydown", doSplitKey).bind("blur", endSplit) .attr({accessKey: opts.accessKey, tabIndex: opts.tabIndex}); // Splitbar element, displays actual splitter bar // The select-related properties prevent unintended text highlighting var splitbar = jQuery('<div></div>') .insertAfter(paneA).append(focuser) .attr({"class": opts.splitbarClass, unselectable: "on"}) .css({position: "absolute", "-khtml-user-select": "none", "-moz-user-select": "none", "user-select": "none"}) .bind("mousedown", startSplit); if ( /^(auto|default)$/.test(splitbar.css("cursor") || "auto") ) splitbar.css("cursor", opts.cursor); // Cache several dimensions for speed--assume these don't change splitbar._adjust = splitbar[0][opts.offsetAdjust]; cssCache(group, "_borderAdjust", "border", opts.adjSide1+"Width", opts.adjSide2+"Width"); cssCache(group, "_borderFixed", "border", opts.fixSide1+"Width", opts.fixSide2+"Width"); cssCache(paneA, "_padAdjust", "padding", opts.adjSide1, opts.adjSide2); cssCache(paneA, "_padFixed", "padding", opts.fixSide1, opts.fixSide2); cssCache(paneB, "_padAdjust", "padding", opts.adjSide1, opts.adjSide2); cssCache(paneB, "_padFixed", "padding", opts.fixSide1, opts.fixSide2); optCache(paneA, 'A'); optCache(paneB, 'B'); // Initial splitbar position as measured from left edge of splitter paneA._init = (opts.initA==true? parseInt(jQuery.curCSS(paneA[0],opts.adjust)) : opts.initA) || 0; paneB._init = (opts.initB==true? parseInt(jQuery.curCSS(paneB[0],opts.adjust)) : opts.initB) || 0; if ( paneB._init ) paneB._init = group[0][opts.offsetAdjust] - group._borderAdjust - paneB._init - splitbar._adjust; // Set up resize event handler and trigger immediately to set initial position group.bind("resize", function(e,size){ // Determine new width/height of splitter container group._fixed = group[0][opts.offsetFixed] - group._borderFixed; group._adjust = group[0][opts.offsetAdjust] - group._borderAdjust; // Bail if splitter isn't visible or content isn't there yet if ( group._fixed <= 0 || group._adjust <= 0 ) return; // Set the fixed dimension (e.g., height on a vertical splitter) paneA.css(opts.fixed, group._fixed-paneA._padFixed+"px"); paneB.css(opts.fixed, group._fixed-paneB._padFixed+"px"); splitbar.css(opts.fixed, group._fixed+"px"); // Re-divvy the adjustable dimension; maintain size of the preferred pane moveSplitter(size || (!opts.initB? paneA[0][opts.offsetAdjust] : group._adjust-paneB[0][opts.offsetAdjust]-splitbar._adjust)); }).trigger("resize" , [paneA._init || paneB._init || Math.round((group[0][opts.offsetAdjust] - group._borderAdjust - splitbar._adjust)/2)]); }); };
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/jquery.splitter.js
JavaScript
gpl2
7,873
;(function($){ /** * jqGrid Czech Translation * Pavel Jirak pavel.jirak@jipas.cz * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "Řádek(ů)", loadtext: "Načítám...", pgtext : "/" }; $.jgrid.search = { caption: "Vyhledávám...", Find: "Hledat", Reset: "Reset", odata : ['rovno', 'není rovno', 'menší', 'menší nebo rovno', 'větší', 'větší nebo rovno', 'začíná na', 'končí na', 'obsahuje' ] }; $.jgrid.edit = { addCaption: "Přidat záznam", editCaption: "Editace záznamu", bSubmit: "Uložit", bCancel: "Storno", bClose: "Zavřít", processData: "Zpracovávám...", msg: { required:"Pole je vyžadováno", number:"Prosím, vložte validní číslo", minValue:"hodnota musí být větší než nebo rovná ", maxValue:"hodnota musí být menší než nebo rovná ", email: "není validní e-mail", integer: "Prosím, vložte celé číslo", date: "Prosím, vložte validní datum" } }; $.jgrid.del = { caption: "Smazat", msg: "Smazat vybraný(é) záznam(y)?", bSubmit: "Smazat", bCancel: "Storno", processData: "Zpracovávám..." }; $.jgrid.nav = { edittext: " ", edittitle: "Editovat vybraný řádek", addtext:" ", addtitle: "Přidat nový řádek", deltext: " ", deltitle: "Smazat vybraný záznam ", searchtext: " ", searchtitle: "Najít záznamy", refreshtext: "", refreshtitle: "Obnovit tabulku", alertcap: "Varování", alerttext: "Prosím, vyberte řádek" }; // setcolumns module $.jgrid.col ={ caption: "Zobrazit/Skrýt sloupce", bSubmit: "Uložit", bCancel: "Storno" }; $.jgrid.errors = { errcap : "Chyba", nourl : "Není nastavena url", norecords: "Žádné záznamy ke zpracování", model : "Length colNames <> colModel!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Ne", "Po", "Út", "St", "Čt", "Pá", "So", "Neděle", "Pondělí", "Úterý", "Středa", "Čtvrtek", "Pátek", "Sobota" ], monthNames: [ "Led", "Úno", "Bře", "Dub", "Kvě", "Čer", "Čvc", "Srp", "Zář", "Říj", "Lis", "Pro", "Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec" ], AmPm : ["do","od","DO","OD"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'}, srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'show', addParam : '' }; // US // GB // CA // AU })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-cs.js
JavaScript
gpl2
3,579
;(function($) { /* ** * jqGrid extension - Tree Grid * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ setTreeNode : function(rd, row){ return this.each(function(){ var $t = this; if( !$t.grid || !$t.p.treeGrid ) { return; } var expCol=0,i=0; if(!$t.p.expColInd) { for (var key in $t.p.colModel){ if($t.p.colModel[key].name == $t.p.ExpandColumn) { expCol = i; $t.p.expColInd = expCol; break; } i++; } if(!$t.p.expColInd ) {$t.p.expColInd = expCol;} } else { expCol = $t.p.expColInd; } var expanded = $t.p.treeReader.expanded_field; var isLeaf = $t.p.treeReader.leaf_field; var level = $t.p.treeReader.level_field; row.level = rd[level]; if($t.p.treeGridModel == 'nested') { row.lft = rd[$t.p.treeReader.left_field]; row.rgt = rd[$t.p.treeReader.right_field]; if(!rd[isLeaf]) { // NS Model rd[isLeaf] = (parseInt(row.rgt,10) === parseInt(row.lft,10)+1) ? 'true' : 'false'; } } else { row.parent_id = rd[$t.p.treeReader.parent_id_field]; } var curExpand = (rd[expanded] && rd[expanded] == "true") ? true : false; var curLevel = parseInt(row.level,10); var ident,lftpos; if($t.p.tree_root_level === 0) { ident = curLevel+1; lftpos = curLevel; } else { ident = curLevel; lftpos = curLevel -1; } var twrap = document.createElement("div"); $(twrap).addClass("tree-wrap").width(ident*18); var treeimg = document.createElement("div"); $(treeimg).css("left",lftpos*18); twrap.appendChild(treeimg); if(rd[isLeaf] == "true") { $(treeimg).addClass("tree-leaf"); row.isLeaf = true; } else { if(rd[expanded] == "true") { $(treeimg).addClass("tree-minus treeclick"); row.expanded = true; } else { $(treeimg).addClass("tree-plus treeclick"); row.expanded = false; } } if(parseInt(rd[level],10) !== parseInt($t.p.tree_root_level,10)) { if(!$($t).isVisibleNode(row)){ $(row).css("display","none"); } } var mhtm = $("td:eq("+expCol+")",row).html(); var thecell = $("td:eq("+expCol+")",row).html("<span>"+mhtm+"</span>").prepend(twrap); $(".treeclick",thecell).click(function(e){ var target = e.target || e.srcElement; var ind =$(target,$t.rows).parents("tr:first")[0].rowIndex; if(!$t.rows[ind].isLeaf){ if($t.rows[ind].expanded){ $($t).collapseRow($t.rows[ind]); $($t).collapseNode($t.rows[ind]); } else { $($t).expandRow($t.rows[ind]); $($t).expandNode($t.rows[ind]); } } //e.stopPropagation(); return false; }); //if($t.p.ExpandColClick === true) { $("span", thecell).css("cursor","pointer").click(function(e){ var target = e.target || e.srcElement; var ind =$(target,$t.rows).parents("tr:first")[0].rowIndex; if(!$t.rows[ind].isLeaf){ if($t.rows[ind].expanded){ $($t).collapseRow($t.rows[ind]); $($t).collapseNode($t.rows[ind]); } else { $($t).expandRow($t.rows[ind]); $($t).expandNode($t.rows[ind]); } } $($t).setSelection($t.rows[ind].id); return false; }); //} }); }, setTreeGrid : function() { return this.each(function (){ var $t = this; if(!$t.p.treeGrid) { return; } $.extend($t.p,{treedatatype: null}); if($t.p.treeGridModel == 'nested') { $t.p.treeReader = $.extend({ level_field: "level", left_field:"lft", right_field: "rgt", leaf_field: "isLeaf", expanded_field: "expanded" },$t.p.treeReader); } else if($t.p.treeGridModel == 'adjacency') { $t.p.treeReader = $.extend({ level_field: "level", parent_id_field: "parent", leaf_field: "isLeaf", expanded_field: "expanded" },$t.p.treeReader ); } }); }, expandRow: function (record){ this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } var childern = $($t).getNodeChildren(record); //if ($($t).isVisibleNode(record)) { $(childern).each(function(i){ $(this).css("display",""); if(this.expanded) { $($t).expandRow(this); } }); //} }); }, collapseRow : function (record) { this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } var childern = $($t).getNodeChildren(record); $(childern).each(function(i){ $(this).css("display","none"); $($t).collapseRow(this); }); }); }, // NS ,adjacency models getRootNodes : function() { var result = []; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } switch ($t.p.treeGridModel) { case 'nested' : var level = $t.p.treeReader.level_field; $($t.rows).each(function(i){ if(parseInt(this[level],10) === parseInt($t.p.tree_root_level,10)) { result.push(this); } }); break; case 'adjacency' : $($t.rows).each(function(i){ if(this.parent_id.toLowerCase() == "null") { result.push(this); } }); break; } }); return result; }, getNodeDepth : function(rc) { var ret = null; this.each(function(){ var $t = this; if(!this.grid || !this.p.treeGrid) { return; } switch ($t.p.treeGridModel) { case 'nested' : ret = parseInt(rc.level,10) - parseInt(this.p.tree_root_level,10); break; case 'adjacency' : ret = $($t).getNodeAncestors(rc); break; } }); return ret; }, getNodeParent : function(rc) { var result = null; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } switch ($t.p.treeGridModel) { case 'nested' : var lft = parseInt(rc.lft,10), rgt = parseInt(rc.rgt,10), level = parseInt(rc.level,10); $(this.rows).each(function(){ if(parseInt(this.level,10) === level-1 && parseInt(this.lft) < lft && parseInt(this.rgt) > rgt) { result = this; return false; } }); break; case 'adjacency' : $(this.rows).each(function(){ if(this.id === rc.parent_id ) { result = this; return false; } }); break; } }); return result; }, getNodeChildren : function(rc) { var result = []; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } switch ($t.p.treeGridModel) { case 'nested' : var lft = parseInt(rc.lft,10), rgt = parseInt(rc.rgt,10), level = parseInt(rc.level,10); var ind = rc.rowIndex; $(this.rows).slice(1).each(function(i){ if(parseInt(this.level,10) === level+1 && parseInt(this.lft,10) > lft && parseInt(this.rgt,10) < rgt) { result.push(this); } }); break; case 'adjacency' : $(this.rows).slice(1).each(function(i){ if(this.parent_id == rc.id) { result.push(this); } }); break; } }); return result; }, // End NS, adjacency Model getNodeAncestors : function(rc) { var ancestors = []; this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } var parent = $(this).getNodeParent(rc); while (parent) { ancestors.push(parent); parent = $(this).getNodeParent(parent); } }); return ancestors; }, isVisibleNode : function(rc) { var result = true; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } var ancestors = $($t).getNodeAncestors(rc); $(ancestors).each(function(){ result = result && this.expanded; if(!result) {return false;} }); }); return result; }, isNodeLoaded : function(rc) { var result; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } if(rc.loaded !== undefined) { result = rc.loaded; } else if( rc.isLeaf || $($t).getNodeChildren(rc).length > 0){ result = true; } else { result = false; } }); return result; }, expandNode : function(rc) { return this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } if(!rc.expanded) { if( $(this).isNodeLoaded(rc) ) { rc.expanded = true; $("div.treeclick",rc).removeClass("tree-plus").addClass("tree-minus"); } else { rc.expanded = true; $("div.treeclick",rc).removeClass("tree-plus").addClass("tree-minus"); this.p.treeANode = rc.rowIndex; this.p.datatype = this.p.treedatatype; if(this.p.treeGridModel == 'nested') { $(this).setGridParam({postData:{nodeid:rc.id,n_left:rc.lft,n_right:rc.rgt,n_level:rc.level}}); } else { $(this).setGridParam({postData:{nodeid:rc.id,parentid:rc.parent_id,n_level:rc.level}}); } $(this).trigger("reloadGrid"); if(this.p.treeGridModel == 'nested') { $(this).setGridParam({postData:{nodeid:'',n_left:'',n_right:'',n_level:''}}); } else { $(this).setGridParam({postData:{nodeid:'',parentid:'',n_level:''}}); } } } }); }, collapseNode : function(rc) { return this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } if(rc.expanded) { rc.expanded = false; $("div.treeclick",rc).removeClass("tree-minus").addClass("tree-plus"); } }); }, SortTree : function( newDir) { return this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } var i, len, rec, records = [], roots = $(this).getRootNodes(); // Sorting roots roots.sort(function(a, b) { if (a.sortKey < b.sortKey) {return -newDir;} if (a.sortKey > b.sortKey) {return newDir;} return 0; }); // Sorting children for (i = 0, len = roots.length; i < len; i++) { rec = roots[i]; records.push(rec); $(this).collectChildrenSortTree(records, rec, newDir); } var $t = this; $.each(records, function(index, row) { $('tbody',$t.grid.bDiv).append(row); row.sortKey = null; }); }); }, collectChildrenSortTree : function(records, rec, newDir) { return this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } var i, len, child, children = $(this).getNodeChildren(rec); children.sort(function(a, b) { if (a.sortKey < b.sortKey) {return -newDir;} if (a.sortKey > b.sortKey) {return newDir;} return 0; }); for (i = 0, len = children.length; i < len; i++) { child = children[i]; records.push(child); $(this).collectChildrenSortTree(records, child,newDir); } }); }, // experimental setTreeRow : function(rowid, data) { var nm, success=false; this.each(function(){ var t = this; if(!t.grid || !t.p.treeGrid) { return; } success = $(t).setRowData(rowid,data); }); return success; }, delTreeNode : function (rowid) { return this.each(function () { var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } var rc = $($t).getInd($t.rows,rowid,true); if (rc) { var dr = $($t).getNodeChildren(rc); if(dr.length>0){ for (var i=0;i<dr.length;i++){ $($t).delRowData(dr[i].id); } } $($t).delRowData(rc.id); } }); } }); })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.treegrid.js
JavaScript
gpl2
11,535
;(function($){ /* ** * jqGrid extension for cellediting Grid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ /** * all events and options here are aded anonynous and not in the base grid * since the array is to big. Here is the order of execution. * From this point we use jQuery isFunction * formatCell * beforeEditCell, * onSelectCell (used only for noneditable cels) * afterEditCell, * beforeSaveCell, (called before validation of values if any) * beforeSubmitCell (if cellsubmit remote (ajax)) * afterSubmitCell(if cellsubmit remote (ajax)), * afterSaveCell, * errorCell, * Options * cellsubmit (remote,clientArray) (added in grid options) * cellurl * */ $.fn.extend({ editCell : function (iRow,iCol, ed, fg){ return this.each(function (){ var $t = this, nm, tmp,cc; if (!$t.grid || $t.p.cellEdit !== true) {return;} var currentFocus = null; // I HATE IE if ($.browser.msie && $.browser.version <=7 && ed===true && fg===true) { iCol = getAbsoluteIndex($t.rows[iRow],iCol); } iCol = parseInt(iCol,10); // select the row that can be used for other methods $t.p.selrow = $t.rows[iRow].id; if (!$t.p.knv) {$($t).GridNav();} // check to see if we have already edited cell if ($t.p.savedRow.length>0) { // prevent second click on that field and enable selects if (ed===true ) { if(iRow == $t.p.iRow && iCol == $t.p.iCol){ return; } } // if so check to see if the content is changed var vl = $("td:eq("+$t.p.savedRow[0].ic+")>#"+$t.p.savedRow[0].id+"_"+$t.p.savedRow[0].name.replace('.',"\\."),$t.rows[$t.p.savedRow[0].id]).val(); if ($t.p.savedRow[0].v != vl) { // save it $($t).saveCell($t.p.savedRow[0].id,$t.p.savedRow[0].ic) } else { // restore it $($t).restoreCell($t.p.savedRow[0].id,$t.p.savedRow[0].ic); } } else { window.setTimeout(function () { $("#"+$t.p.knv).attr("tabindex","-1").focus();},0); } nm = $t.p.colModel[iCol].name; if (nm=='subgrid') {return;} if ($t.p.colModel[iCol].editable===true && ed===true) { cc = $("td:eq("+iCol+")",$t.rows[iRow]); if(parseInt($t.p.iCol)>=0 && parseInt($t.p.iRow)>=0) { $("td:eq("+$t.p.iCol+")",$t.rows[$t.p.iRow]).removeClass("edit-cell"); $($t.rows[$t.p.iRow]).removeClass("selected-row"); } $(cc).addClass("edit-cell"); $($t.rows[iRow]).addClass("selected-row"); try { tmp = $.unformat(cc,{colModel:$t.p.colModel[iCol]},iCol); } catch (_) { tmp = $.htmlDecode($(cc).html()); } var opt = $.extend($t.p.colModel[iCol].editoptions || {} ,{id:iRow+"_"+nm,name:nm}); if (!$t.p.colModel[iCol].edittype) {$t.p.colModel[iCol].edittype = "text";} $t.p.savedRow[0] = {id:iRow,ic:iCol,name:nm,v:tmp}; if($.isFunction($t.p.formatCell)) { var tmp2 = $t.p.formatCell($t.rows[iRow].id,nm,tmp,iRow,iCol); if(tmp2) {tmp = tmp2;} } var elc = createEl($t.p.colModel[iCol].edittype,opt,tmp,cc); if ($.isFunction($t.p.beforeEditCell)) { $t.p.beforeEditCell($t.rows[iRow].id,nm,tmp,iRow,iCol); } $(cc).html("").append(elc); window.setTimeout(function () { $(elc).focus();},0); $("input, select, textarea",cc).bind("keydown",function(e) { if (e.keyCode === 27) {$($t).restoreCell(iRow,iCol);} //ESC if (e.keyCode === 13) {$($t).saveCell(iRow,iCol);}//Enter if (e.keyCode == 9) { if (e.shiftKey) {$($t).prevCell(iRow,iCol);} //Shift TAb else {$($t).nextCell(iRow,iCol);} //Tab } e.stopPropagation(); }); if ($.isFunction($t.p.afterEditCell)) { $t.p.afterEditCell($t.rows[iRow].id,nm,tmp,iRow,iCol); } } else { if (parseInt($t.p.iCol)>=0 && parseInt($t.p.iRow)>=0) { $("td:eq("+$t.p.iCol+")",$t.rows[$t.p.iRow]).removeClass("edit-cell"); $($t.rows[$t.p.iRow]).removeClass("selected-row"); } $("td:eq("+iCol+")",$t.rows[iRow]).addClass("edit-cell"); $($t.rows[iRow]).addClass("selected-row"); if ($.isFunction($t.p.onSelectCell)) { tmp = $("td:eq("+iCol+")",$t.rows[iRow]).html().replace(/\&nbsp\;/ig,''); $t.p.onSelectCell($t.rows[iRow].id,nm,tmp,iRow,iCol); } } $t.p.iCol = iCol; $t.p.iRow = iRow; // IE 6 bug function getAbsoluteIndex(t,relIndex) { var countnotvisible=0; var countvisible=0; for (i=0;i<t.cells.length;i++) { var cell=t.cells(i); if (cell.style.display=='none') countnotvisible++; else countvisible++; if (countvisible>relIndex) return i; } return i; } }); }, saveCell : function (iRow, iCol){ return this.each(function(){ var $t= this, nm, fr; if (!$t.grid || $t.p.cellEdit !== true) {return;} if ( $t.p.savedRow.length == 1) {fr = 0;} else {fr=null;} if(fr != null) { var cc = $("td:eq("+iCol+")",$t.rows[iRow]),v,v2; nm = $t.p.colModel[iCol].name; switch ($t.p.colModel[iCol].edittype) { case "select": v = $("#"+iRow+"_"+nm.replace('.',"\\.")+">option:selected",$t.rows[iRow]).val(); v2 = $("#"+iRow+"_"+nm.replace('.',"\\.")+">option:selected",$t.rows[iRow]).text(); break; case "checkbox": var cbv = ["Yes","No"]; if($t.p.colModel[iCol].editoptions){ cbv = $t.p.colModel[iCol].editoptions.value.split(":"); } v = $("#"+iRow+"_"+nm.replace('.',"\\."),$t.rows[iRow]).attr("checked") ? cbv[0] : cbv[1]; v2=v; break; case "password": case "text": case "textarea": v = htmlEncode($("#"+iRow+"_"+nm.replace('.',"\\."),$t.rows[iRow]).val()); v2=v; break; } // The common approach is if nothing changed do not do anything if (v2 != $t.p.savedRow[fr].v){ if ($.isFunction($t.p.beforeSaveCell)) { var vv = $t.p.beforeSaveCell($t.rows[iRow].id,nm, v, iRow,iCol); if (vv) {v = vv;} } var cv = checkValues(v,iCol,$t); if(cv[0] === true) { var addpost = {}; if ($.isFunction($t.p.beforeSubmitCell)) { addpost = $t.p.beforeSubmitCell($t.rows[iRow].id,nm, v, iRow,iCol); if (!addpost) {addpost={};} } if ($t.p.cellsubmit == 'remote') { if ($t.p.cellurl) { var postdata = {}; v = htmlEncode(v); v2 = htmlEncode(v2); postdata[nm] = v; postdata["id"] = $t.rows[iRow].id; postdata = $.extend(addpost,postdata); $.ajax({ url: $t.p.cellurl, data :postdata, type: "POST", complete: function (result, stat) { if (stat == 'success') { if ($.isFunction($t.p.afterSubmitCell)) { var ret = $t.p.afterSubmitCell(result,postdata.id,nm,v,iRow,iCol); if(ret[0] === true) { $(cc).empty(); $($t).setCell($t.rows[iRow].id, iCol, v2); $(cc).addClass("dirty-cell"); $($t.rows[iRow]).addClass("edited"); if ($.isFunction($t.p.afterSaveCell)) { $t.p.afterSaveCell($t.rows[iRow].id,nm, v, iRow,iCol); } $t.p.savedRow = []; } else { info_dialog($.jgrid.errors.errcap,ret[1],$.jgrid.edit.bClose, $t.p.imgpath); $($t).restoreCell(iRow,iCol); } } else { $(cc).empty(); $($t).setCell($t.rows[iRow].id, iCol, v2); $(cc).addClass("dirty-cell"); $($t.rows[iRow]).addClass("edited"); if ($.isFunction($t.p.afterSaveCell)) { $t.p.afterSaveCell($t.rows[iRow].id,nm, v, iRow,iCol); } $t.p.savedRow = []; } } }, error:function(res,stat){ if ($.isFunction($t.p.errorCell)) { $t.p.errorCell(res,stat); $($t).restoreCell(iRow,iCol); } else { info_dialog($.jgrid.errors.errcap,res.status+" : "+res.statusText+"<br/>"+stat,$.jgrid.edit.bClose, $t.p.imgpath); $($t).restoreCell(iRow,iCol); } } }); } else { try { info_dialog($.jgrid.errors.errcap,$.jgrid.errors.nourl,$.jgrid.edit.bClose, $t.p.imgpath); $($t).restoreCell(iRow,iCol); } catch (e) {} } } if ($t.p.cellsubmit == 'clientArray') { v = htmlEncode(v); v2 = htmlEncode(v2); $(cc).empty(); $($t).setCell($t.rows[iRow].id,iCol, v2); $(cc).addClass("dirty-cell"); $($t.rows[iRow]).addClass("edited"); if ($.isFunction($t.p.afterSaveCell)) { $t.p.afterSaveCell($t.rows[iRow].id,nm, v, iRow,iCol); } $t.p.savedRow = []; } } else { try { window.setTimeout(function(){info_dialog($.jgrid.errors.errcap,v+" "+cv[1],$.jgrid.edit.bClose, $t.p.imgpath)},100); $($t).restoreCell(iRow,iCol); } catch (e) {} } } else { $($t).restoreCell(iRow,iCol); } } if ($.browser.opera) { $("#"+$t.p.knv).attr("tabindex","-1").focus(); } else { window.setTimeout(function () { $("#"+$t.p.knv).attr("tabindex","-1").focus();},0); } }); }, restoreCell : function(iRow, iCol) { return this.each(function(){ var $t= this, nm, fr; if (!$t.grid || $t.p.cellEdit !== true ) {return;} if ( $t.p.savedRow.length == 1) {fr = 0;} else {fr=null;} if(fr != null) { var cc = $("td:eq("+iCol+")",$t.rows[iRow]); if($.isFunction($.fn['datepicker'])) { try { $.datepicker('hide'); } catch (e) { try { $.datepicker.hideDatepicker(); } catch (e) {} } } $(cc).empty(); $($t).setCell($t.rows[iRow].id, iCol, $t.p.savedRow[fr].v); $t.p.savedRow = []; } window.setTimeout(function () { $("#"+$t.p.knv).attr("tabindex","-1").focus();},0); }); }, nextCell : function (iRow,iCol) { return this.each(function (){ var $t = this, nCol=false, tmp; if (!$t.grid || $t.p.cellEdit !== true) {return;} // try to find next editable cell for (var i=iCol+1; i<$t.p.colModel.length; i++) { if ( $t.p.colModel[i].editable ===true) { nCol = i; break; } } if(nCol !== false) { $($t).saveCell(iRow,iCol); $($t).editCell(iRow,nCol,true); } else { if ($t.p.savedRow.length >0) { $($t).saveCell(iRow,iCol); } } }); }, prevCell : function (iRow,iCol) { return this.each(function (){ var $t = this, nCol=false, tmp; if (!$t.grid || $t.p.cellEdit !== true) {return;} // try to find next editable cell for (var i=iCol-1; i>=0; i--) { if ( $t.p.colModel[i].editable ===true) { nCol = i; break; } } if(nCol !== false) { $($t).saveCell(iRow,iCol); $($t).editCell(iRow,nCol,true); } else { if ($t.p.savedRow.length >0) { $($t).saveCell(iRow,iCol); } } }); }, GridNav : function() { return this.each(function () { var $t = this; if (!$t.grid || $t.p.cellEdit !== true ) {return;} // trick to process keydown on non input elements $t.p.knv = $("table:first",$t.grid.bDiv).attr("id") + "_kn"; var selection = $("<span style='width:0px;height:0px;background-color:black;' tabindex='0'><span tabindex='-1' style='width:0px;height:0px;background-color:grey' id='"+$t.p.knv+"'></span></span>"); $(selection).insertBefore($t.grid.cDiv); $("#"+$t.p.knv).focus(); $("#"+$t.p.knv).keydown(function (e){ switch (e.keyCode) { case 38: if ($t.p.iRow-1 >=1 ) { scrollGrid($t.p.iRow-1,$t.p.iCol,'vu'); $($t).editCell($t.p.iRow-1,$t.p.iCol,false); } break; case 40 : if ($t.p.iRow+1 <= $t.rows.length-1) { scrollGrid($t.p.iRow+1,$t.p.iCol,'vd'); $($t).editCell($t.p.iRow+1,$t.p.iCol,false); } break; case 37 : if ($t.p.iCol -1 >= 0) { var i = findNextVisible($t.p.iCol-1,'lft'); scrollGrid($t.p.iRow, i,'h'); $($t).editCell($t.p.iRow, i,false); } break; case 39 : if ($t.p.iCol +1 <= $t.p.colModel.length-1) { var i = findNextVisible($t.p.iCol+1,'rgt'); scrollGrid($t.p.iRow,i,'h'); $($t).editCell($t.p.iRow,i,false); } break; case 13: if (parseInt($t.p.iCol,10)>=0 && parseInt($t.p.iRow,10)>=0) { $($t).editCell($t.p.iRow,$t.p.iCol,true); } break; } return false; }); function scrollGrid(iR, iC, tp){ if (tp.substr(0,1)=='v') { var ch = $($t.grid.bDiv)[0].clientHeight, st = $($t.grid.bDiv)[0].scrollTop, nROT = $t.rows[iR].offsetTop+$t.rows[iR].clientHeight, pROT = $t.rows[iR].offsetTop; if(tp == 'vd') { if(nROT >= ch) { $($t.grid.bDiv)[0].scrollTop = $($t.grid.bDiv)[0].scrollTop + $t.rows[iR].clientHeight; } } if(tp == 'vu'){ if (pROT < st) { $($t.grid.bDiv)[0].scrollTop = $($t.grid.bDiv)[0].scrollTop - $t.rows[iR].clientHeight; } } } if(tp=='h') { var cw = $($t.grid.bDiv)[0].clientWidth, sl = $($t.grid.bDiv)[0].scrollLeft, nCOL = $t.rows[iR].cells[iC].offsetLeft+$t.rows[iR].cells[iC].clientWidth, pCOL = $t.rows[iR].cells[iC].offsetLeft; if(nCOL >= cw+parseInt(sl)) { $($t.grid.bDiv)[0].scrollLeft = $($t.grid.bDiv)[0].scrollLeft + $t.rows[iR].cells[iC].clientWidth; } else if (pCOL < sl) { $($t.grid.bDiv)[0].scrollLeft = $($t.grid.bDiv)[0].scrollLeft - $t.rows[iR].cells[iC].clientWidth; } } }; function findNextVisible(iC,act){ var ind, i; if(act == 'lft') { ind = iC+1; for (i=iC;i>=0;i--){ if ($t.p.colModel[i].hidden !== true) { ind = i; break; } } } if(act == 'rgt') { ind = iC-1; for (i=iC; i<$t.p.colModel.length;i++){ if ($t.p.colModel[i].hidden !== true) { ind = i; break; } } } return ind; }; }); }, getChangedCells : function (mthd) { var ret=[]; if (!mthd) {mthd='all';} this.each(function(){ var $t= this; if (!$t.grid || $t.p.cellEdit !== true ) {return;} $($t.rows).slice(1).each(function(j){ var res = {}; if ($(this).hasClass("edited")) { $('td',this).each( function(i) { nm = $t.p.colModel[i].name; if ( nm !== 'cb' && nm !== 'subgrid') { if (mthd=='dirty') { if ($(this).hasClass('dirty-cell')) { res[nm] = $.htmlDecode($(this).html()); } } else { res[nm] = $.htmlDecode($(this).html()); } } }); res["id"] = this.id; ret.push(res); } }) }); return ret; } /// end cell editing }); })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.celledit.js
JavaScript
gpl2
15,135
;(function($){ /** * jqGrid English Translation * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "Row(s)", loadtext: "Loading...", pgtext : "/" }; $.jgrid.search = { caption: "Search...", Find: "Find", Reset: "Reset", odata : ['equal', 'not equal', 'less', 'less or equal','greater','greater or equal', 'begins with','ends with','contains' ] }; $.jgrid.edit = { addCaption: "Add Record", editCaption: "Edit Record", bSubmit: "Submit", bCancel: "Cancel", bClose: "Close", processData: "Processing...", msg: { required:"Field is required", number:"Please, enter valid number", minValue:"value must be greater than or equal to ", maxValue:"value must be less than or equal to", email: "is not a valid e-mail", integer: "Please, enter valid integer value", date: "Please, enter valid date value" } }; $.jgrid.del = { caption: "Delete", msg: "Delete selected record(s)?", bSubmit: "Delete", bCancel: "Cancel", processData: "Processing..." }; $.jgrid.nav = { edittext: " ", edittitle: "Edit selected row", addtext:" ", addtitle: "Add new row", deltext: " ", deltitle: "Delete selected row", searchtext: " ", searchtitle: "Find records", refreshtext: "", refreshtitle: "Reload Grid", alertcap: "Warning", alerttext: "Please, select row" }; // setcolumns module $.jgrid.col ={ caption: "Show/Hide Columns", bSubmit: "Submit", bCancel: "Cancel" }; $.jgrid.errors = { errcap : "Error", nourl : "No url is set", norecords: "No records to process", model : "Length of colNames <> colModel!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], AmPm : ["am","pm","AM","PM"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'}, srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'show', addParam : '' }; // US // GB // CA // AU })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-en.js
JavaScript
gpl2
3,413
;(function($){ /** * jqGrid Russian Translation v1.1 21.01.2009 * Alexey Kanaev softcore@rambler.ru * http://softcore.com.ru * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "Записей", loadtext: "Загрузка...", pgtext : "/" }; $.jgrid.search = { caption: "Поиск...", Find: "Найти", Reset: "Сброс", odata : ['равно', 'не равно', 'меньше', 'меньше или равно','больше','больше или равно', 'начинается с','заканчивается на','содержит' ] }; $.jgrid.edit = { addCaption: "Добавить запись", editCaption: "Редактировать запись", bSubmit: "Сохранить", bCancel: "Отмена", bClose: "Закрыть", processData: "Обработка...", msg: { required:"Поле является обязательным", number:"Пожалуйста, введите правильное число", minValue:"значение должно быть больше либо равно", maxValue:"значение должно быть больше либо равно", email: "некорректное значение e-mail", integer: "Пожалуйста введите целое число", date: "Please, enter valid date value" } }; $.jgrid.del = { caption: "Удалить", msg: "Удалить выделенную запись(и)?", bSubmit: "Удвлить", bCancel: "Отмена", processData: "Обработка..." }; $.jgrid.nav = { edittext: " ", edittitle: "Редактировать выделенную запись", addtext:" ", addtitle: "Добавить новую запись", deltext: " ", deltitle: "Удалить выделенную запись", searchtext: " ", searchtitle: "Найти записи", refreshtext: "", refreshtitle: "Обновить таблицу", alertcap: "Внимание", alerttext: "Пожалуйста, выделите запись" }; // setcolumns module $.jgrid.col ={ caption: "Показать/скрыть столбцы", bSubmit: "Сохранить", bCancel: "Отмена" }; $.jgrid.errors = { errcap : "Ошибка", nourl : "URL не установлен", norecords: "Нет записей для обработки", model : "Число полей не соответствует числу столбцов таблицы!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Воскресение", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота" ], monthNames: [ "Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек", "Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь" ], AmPm : ["am","pm","AM","PM"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'}, srcformat: 'Y-m-d', newformat: 'd.m.Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n.j.Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y G:i:s", MonthDay: "F d", ShortTime: "G:i", LongTime: "G:i:s", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'show' }; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-ru.js
JavaScript
gpl2
4,343
;(function($){ /** * jqGrid Bulgarian Translation * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "запис(а)", loadtext: "Зареждам...", pgtext : "от" } $.jgrid.search = { caption: "Търсене...", Find: "Намери", Reset: "Изчисти", odata : ['равно', 'различно', 'по-малко', 'по-малко или=','по-голямо','по-голямо или =', 'започва с','завършва с','съдържа' ] }; $.jgrid.edit = { addCaption: "Нов Запис", editCaption: "Редакция Запис", bSubmit: "Запиши", bCancel: "Изход", bClose: "Затвори", processData: "Обработка...", msg: { required:"Полето е задължително", number:"Въведете валидно число!", minValue:"стойността трябва да е по-голяма или равна от", maxValue:"стойността трябва да е по-малка или равна от", email: "не е валиден ел. адрес", integer: "Въведете валидно цяло число", date: "Въведете валидна дата" } }; $.jgrid.del = { caption: "Изтриване", msg: "Да изтрия ли избраният запис?", bSubmit: "Изтрий", bCancel: "Отказ", processData: "Обработка..." }; $.jgrid.nav = { edittext: " ", edittitle: "Редакция избран запис", addtext:" ", addtitle: "Добавяне нов запис", deltext: " ", deltitle: "Изтриване избран запис", searchtext: " ", searchtitle: "Търсене запис(и)", refreshtext: "", refreshtitle: "Обнови таблица", alertcap: "Предупреждение", alerttext: "Моля, изберете запис" }; // set column module $.jgrid.col ={ caption: "Колони", bSubmit: "Запис", bCancel: "Изход" }; $.jgrid.errors = { errcap : "Грешка", nourl : "Няма посочен url адрес", norecords: "Няма запис за обработка", model : "Модела не съответства на имената!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: 0}, currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:" лв.", defaultValue: 0}, date : { dayNames: [ "Нед", "Пон", "Вт", "Ср", "Чет", "Пет", "Съб", "Неделя", "Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота" ], monthNames: [ "Ян", "Фев", "Март", "Апр", "Май", "Юни", "Юли", "Авг", "Сеп", "Окт", "Ноем", "Дек", "Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември" ], AmPm : ["","","",""], S: function (j) { if(j==7 || j==8 || j== 27 || j== 28) { return 'ми'; } return ['ви', 'ри', 'ти'][Math.min((j - 1) % 10, 2)]; }, srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'show' }; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-bg.js
JavaScript
gpl2
4,179
;(function($){ /** * jqGrid extension for form editing Grid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ var rp_ge = null; $.fn.extend({ searchGrid : function ( p ) { p = $.extend({ top : 0, left: 0, width: 360, height: 80, modal: false, drag: true, closeicon: 'ico-close.gif', dirty: false, sField:'searchField', sValue:'searchString', sOper: 'searchOper', processData: "", checkInput :false, beforeShowSearch: null, afterShowSearch : null, onInitializeSearch: null, closeAfterSearch : false, // translation // if you want to change or remove the order change it in sopt // ['bw','eq','ne','lt','le','gt','ge','ew','cn'] sopt: null }, $.jgrid.search, p || {}); return this.each(function(){ var $t = this; if( !$t.grid ) { return; } if(!p.imgpath) { p.imgpath= $t.p.imgpath; } var gID = $("table:first",$t.grid.bDiv).attr("id"); var IDs = { themodal:'srchmod'+gID,modalhead:'srchhead'+gID,modalcontent:'srchcnt'+gID }; if ( $("#"+IDs.themodal).html() != null ) { if( $.isFunction('beforeShowSearch') ) { p.beforeShowSearch($("#srchcnt"+gID)); } viewModal("#"+IDs.themodal,{modal: p.modal}); if( $.isFunction('afterShowSearch') ) { p.afterShowSearch($("#srchcnt"+gID)); } } else { var cM = $t.p.colModel; var cNames = "<select id='snames' class='search'>"; var nm, hc, sf; for(var i=0; i< cM.length;i++) { nm = cM[i].name; sf = (cM[i].search===false) ? false: true; if(cM[i].editrules && cM[i].editrules.searchhidden === true) { hc = true; } else { if(cM[i].hidden === true ) { hc = false; } else { hc = true; } } if( nm !== 'cb' && nm !== 'subgrid' && sf && hc===true ) { // add here condition for searchable var sname = (cM[i].index) ? cM[i].index : nm; cNames += "<option value='"+sname+"'>"+$t.p.colNames[i]+"</option>"; } } cNames += "</select>"; var getopt = p.sopt || ['bw','eq','ne','lt','le','gt','ge','ew','cn']; var sOpt = "<select id='sopt' class='search'>"; for(var i = 0; i<getopt.length;i++) { sOpt += getopt[i]=='eq' ? "<option value='eq'>"+p.odata[0]+"</option>" : ""; sOpt += getopt[i]=='ne' ? "<option value='ne'>"+p.odata[1]+"</option>" : ""; sOpt += getopt[i]=='lt' ? "<option value='lt'>"+p.odata[2]+"</option>" : ""; sOpt += getopt[i]=='le' ? "<option value='le'>"+p.odata[3]+"</option>" : ""; sOpt += getopt[i]=='gt' ? "<option value='gt'>"+p.odata[4]+"</option>" : ""; sOpt += getopt[i]=='ge' ? "<option value='ge'>"+p.odata[5]+"</option>" : ""; sOpt += getopt[i]=='bw' ? "<option value='bw'>"+p.odata[6]+"</option>" : ""; sOpt += getopt[i]=='ew' ? "<option value='ew'>"+p.odata[7]+"</option>" : ""; sOpt += getopt[i]=='cn' ? "<option value='cn'>"+p.odata[8]+"</option>" : ""; }; sOpt += "</select>"; // field and buttons var sField = "<input id='sval' class='search' type='text' size='20' maxlength='100'/>"; var bSearch = "<input id='sbut' class='buttonsearch' type='button' value='"+p.Find+"'/>"; var bReset = "<input id='sreset' class='buttonsearch' type='button' value='"+p.Reset+"'/>"; var cnt = $("<table width='100%'><tbody><tr style='display:none' id='srcherr'><td colspan='5'></td></tr><tr><td>"+cNames+"</td><td>"+sOpt+"</td><td>"+sField+"</td><td>"+bSearch+"</td><td>"+bReset+"</td></tr></tbody></table>"); createModal(IDs,cnt,p,$t.grid.hDiv,$t.grid.hDiv); if ( $.isFunction('onInitializeSearch') ) { p.onInitializeSearch( $("#srchcnt"+gID) ); }; if ( $.isFunction('beforeShowSearch') ) { p.beforeShowSearch($("#srchcnt"+gID)); }; viewModal("#"+IDs.themodal,{modal:p.modal}); if($.isFunction('afterShowSearch')) { p.afterShowSearch($("#srchcnt"+gID)); } if(p.drag) { DnRModal("#"+IDs.themodal,"#"+IDs.modalhead+" td.modaltext"); } $("#sbut","#"+IDs.themodal).click(function(){ if( $("#sval","#"+IDs.themodal).val() !="" ) { var es=[true,"",""]; $("#srcherr >td","#srchcnt"+gID).html("").hide(); $t.p.searchdata[p.sField] = $("option[selected]","#snames").val(); $t.p.searchdata[p.sOper] = $("option[selected]","#sopt").val(); $t.p.searchdata[p.sValue] = $("#sval","#"+IDs.modalcontent).val(); if(p.checkInput) { for(var i=0; i< cM.length;i++) { var sname = (cM[i].index) ? cM[i].index : nm; if (sname == $t.p.searchdata[p.sField]) { break; } } es = checkValues($t.p.searchdata[p.sValue],i,$t); } if (es[0]===true) { $t.p.search = true; // initialize the search // construct array of data which is passed in populate() see jqGrid if(p.dirty) { $(".no-dirty-cell",$t.p.pager).addClass("dirty-cell"); } $t.p.page= 1; $($t).trigger("reloadGrid"); if(p.closeAfterSearch === true) { hideModal("#"+IDs.themodal); } } else { $("#srcherr >td","#srchcnt"+gID).html(es[1]).show(); } } }); $("#sreset","#"+IDs.themodal).click(function(){ if ($t.p.search) { $("#srcherr >td","#srchcnt"+gID).html("").hide(); $t.p.search = false; $t.p.searchdata = {}; $t.p.page= 1; $("#sval","#"+IDs.themodal).val(""); if(p.dirty) { $(".no-dirty-cell",$t.p.pager).removeClass("dirty-cell"); } $($t).trigger("reloadGrid"); } }); } }); }, editGridRow : function(rowid, p){ p = $.extend({ top : 0, left: 0, width: 0, height: 0, modal: false, drag: true, closeicon: 'ico-close.gif', imgpath: '', url: null, mtype : "POST", closeAfterAdd : false, clearAfterAdd : true, closeAfterEdit : false, reloadAfterSubmit : true, onInitializeForm: null, beforeInitData: null, beforeShowForm: null, afterShowForm: null, beforeSubmit: null, afterSubmit: null, onclickSubmit: null, afterComplete: null, onclickPgButtons : null, afterclickPgButtons: null, editData : {}, recreateForm : false, addedrow : "first" }, $.jgrid.edit, p || {}); rp_ge = p; return this.each(function(){ var $t = this; if (!$t.grid || !rowid) { return; } if(!p.imgpath) { p.imgpath= $t.p.imgpath; } // I hate to rewrite code, but ... var gID = $("table:first",$t.grid.bDiv).attr("id"); var IDs = {themodal:'editmod'+gID,modalhead:'edithd'+gID,modalcontent:'editcnt'+gID}; var onBeforeShow = $.isFunction(rp_ge.beforeShowForm) ? rp_ge.beforeShowForm : false; var onAfterShow = $.isFunction(rp_ge.afterShowForm) ? rp_ge.afterShowForm : false; var onBeforeInit = $.isFunction(rp_ge.beforeInitData) ? rp_ge.beforeInitData : false; var onInitializeForm = $.isFunction(rp_ge.onInitializeForm) ? rp_ge.onInitializeForm : false; if (rowid=="new") { rowid = "_empty"; p.caption=p.addCaption; } else { p.caption=p.editCaption; }; var frmgr = "FrmGrid_"+gID; var frmtb = "TblGrid_"+gID; if(p.recreateForm===true && $("#"+IDs.themodal).html() != null) { $("#"+IDs.themodal).remove(); } if ( $("#"+IDs.themodal).html() != null ) { $(".modaltext","#"+IDs.modalhead).html(p.caption); $("#FormError","#"+frmtb).hide(); if(onBeforeInit) { onBeforeInit($("#"+frmgr)); } fillData(rowid,$t); if(rowid=="_empty") { $("#pData, #nData","#"+frmtb).hide(); } else { $("#pData, #nData","#"+frmtb).show(); } if(onBeforeShow) { onBeforeShow($("#"+frmgr)); } viewModal("#"+IDs.themodal,{modal:p.modal}); if(onAfterShow) { onAfterShow($("#"+frmgr)); } } else { var frm = $("<form name='FormPost' id='"+frmgr+"' class='FormGrid'></form>"); var tbl =$("<table id='"+frmtb+"' class='EditTable' cellspacing='0' cellpading='0' border='0'><tbody></tbody></table>"); $(frm).append(tbl); $(tbl).append("<tr id='FormError' style='display:none'><td colspan='2'>"+"&nbsp;"+"</td></tr>"); // set the id. // use carefull only to change here colproperties. if(onBeforeInit) { onBeforeInit($("#"+frmgr)); } var valref = createData(rowid,$t,tbl); // buttons at footer var imp = $t.p.imgpath; var bP ="<img id='pData' src='"+imp+$t.p.previmg+"'/>"; var bN ="<img id='nData' src='"+imp+$t.p.nextimg+"'/>"; var bS ="<input id='sData' type='button' class='EditButton' value='"+p.bSubmit+"'/>"; var bC ="<input id='cData' type='button' class='EditButton' value='"+p.bCancel+"'/>"; $(tbl).append("<tr id='Act_Buttons'><td class='navButton'>"+bP+"&nbsp;"+bN+"</td><td class='EditButton'>"+bS+"&nbsp;"+bC+"</td></tr>"); // beforeinitdata after creation of the form createModal(IDs,frm,p,$t.grid.hDiv,$t.grid.hDiv); // here initform - only once if(onInitializeForm) { onInitializeForm($("#"+frmgr)); } if( p.drag ) { DnRModal("#"+IDs.themodal,"#"+IDs.modalhead+" td.modaltext"); } if(rowid=="_empty") { $("#pData,#nData","#"+frmtb).hide(); } else { $("#pData,#nData","#"+frmtb).show(); } if(onBeforeShow) { onBeforeShow($("#"+frmgr)); } viewModal("#"+IDs.themodal,{modal:p.modal}); if(onAfterShow) { onAfterShow($("#"+frmgr)); } $("#sData", "#"+frmtb).click(function(e){ var postdata = {}, ret=[true,"",""], extpost={}; $("#FormError","#"+frmtb).hide(); // all depend on ret array //ret[0] - succes //ret[1] - msg if not succes //ret[2] - the id that will be set if reload after submit false var j =0; $(".FormElement", "#"+frmtb).each(function(i){ var suc = true; switch ($(this).get(0).type) { case "checkbox": if($(this).attr("checked")) { postdata[this.name]= $(this).val(); }else { var ofv = $(this).attr("offval"); postdata[this.name]= ofv; extpost[this.name] = ofv; } break; case "select-one": postdata[this.name]= $("option:selected",this).val(); extpost[this.name]= $("option:selected",this).text(); break; case "select-multiple": postdata[this.name]= $(this).val(); var selectedText = []; $("option:selected",this).each( function(i,selected){ selectedText[i] = $(selected).text(); } ); extpost[this.name]= selectedText.join(","); break; case "password": case "text": case "textarea": postdata[this.name] = $(this).val(); ret = checkValues(postdata[this.name],valref[i],$t); if(ret[0] === false) { suc=false; } else { postdata[this.name] = htmlEncode(postdata[this.name]); } break; } j++; if(!suc) { return false; } }); if(j==0) { ret[0] = false; ret[1] = $.jgrid.errors.norecords; } if( $.isFunction( rp_ge.onclickSubmit)) { rp_ge.editData = rp_ge.onclickSubmit(p) || {}; } if(ret[0]) { if( $.isFunction(rp_ge.beforeSubmit)) { ret = rp_ge.beforeSubmit(postdata,$("#"+frmgr)); } } var gurl = rp_ge.url ? rp_ge.url : $t.p.editurl; if(ret[0]) { if(!gurl) { ret[0]=false; ret[1] += " "+$.jgrid.errors.nourl; } } if(ret[0] === false) { $("#FormError>td","#"+frmtb).html(ret[1]); $("#FormError","#"+frmtb).show(); } else { if(!p.processing) { p.processing = true; $("div.loading","#"+IDs.themodal).fadeIn("fast"); $(this).attr("disabled",true); // we add to pos data array the action - the name is oper postdata.oper = postdata.id == "_empty" ? "add" : "edit"; postdata = $.extend(postdata,rp_ge.editData); $.ajax({ url:gurl, type: rp_ge.mtype, data:postdata, complete:function(data,Status){ if(Status != "success") { ret[0] = false; ret[1] = Status+" Status: "+data.statusText +" Error code: "+data.status; } else { // data is posted successful // execute aftersubmit with the returned data from server if( $.isFunction(rp_ge.afterSubmit) ) { ret = rp_ge.afterSubmit(data,postdata); } } if(ret[0] === false) { $("#FormError>td","#"+frmtb).html(ret[1]); $("#FormError","#"+frmtb).show(); } else { postdata = $.extend(postdata,extpost); // the action is add if(postdata.id=="_empty" ) { //id processing // user not set the id ret[2] if(!ret[2]) { ret[2] = parseInt($($t).getGridParam('records'))+1; } postdata.id = ret[2]; if(rp_ge.closeAfterAdd) { if(rp_ge.reloadAfterSubmit) { $($t).trigger("reloadGrid"); } else { $($t).addRowData(ret[2],postdata,p.addedrow); $($t).setSelection(ret[2]); } hideModal("#"+IDs.themodal); } else if (rp_ge.clearAfterAdd) { if(rp_ge.reloadAfterSubmit) { $($t).trigger("reloadGrid"); } else { $($t).addRowData(ret[2],postdata,p.addedrow); } $(".FormElement", "#"+frmtb).each(function(i){ switch ($(this).get(0).type) { case "checkbox": $(this).attr("checked",0); break; case "select-one": case "select-multiple": $("option",this).attr("selected",""); break; case "password": case "text": case "textarea": if(this.name =='id') { $(this).val("_empty"); } else { $(this).val(""); } break; } }); } else { if(rp_ge.reloadAfterSubmit) { $($t).trigger("reloadGrid"); } else { $($t).addRowData(ret[2],postdata,p.addedrow); } } } else { // the action is update if(rp_ge.reloadAfterSubmit) { $($t).trigger("reloadGrid"); if( !rp_ge.closeAfterEdit ) { $($t).setSelection(postdata.id); } } else { if($t.p.treeGrid === true) { $($t).setTreeRow(postdata.id,postdata); } else { $($t).setRowData(postdata.id,postdata); } } if(rp_ge.closeAfterEdit) { hideModal("#"+IDs.themodal); } } if($.isFunction(rp_ge.afterComplete)) { setTimeout(function(){rp_ge.afterComplete(data,postdata,$("#"+frmgr));},500); } } p.processing=false; $("#sData", "#"+frmtb).attr("disabled",false); $("div.loading","#"+IDs.themodal).fadeOut("fast"); } }); } } e.stopPropagation(); }); $("#cData", "#"+frmtb).click(function(e){ hideModal("#"+IDs.themodal); e.stopPropagation(); }); $("#nData", "#"+frmtb).click(function(e){ $("#FormError","#"+frmtb).hide(); var npos = getCurrPos(); npos[0] = parseInt(npos[0]); if(npos[0] != -1 && npos[1][npos[0]+1]) { if($.isFunction(p.onclickPgButtons)) { p.onclickPgButtons('next',$("#"+frmgr),npos[1][npos[0]]); } fillData(npos[1][npos[0]+1],$t); $($t).setSelection(npos[1][npos[0]+1]); if($.isFunction(p.afterclickPgButtons)) { p.afterclickPgButtons('next',$("#"+frmgr),npos[1][npos[0]+1]); } updateNav(npos[0]+1,npos[1].length-1); }; return false; }); $("#pData", "#"+frmtb).click(function(e){ $("#FormError","#"+frmtb).hide(); var ppos = getCurrPos(); if(ppos[0] != -1 && ppos[1][ppos[0]-1]) { if($.isFunction(p.onclickPgButtons)) { p.onclickPgButtons('prev',$("#"+frmgr),ppos[1][ppos[0]]); } fillData(ppos[1][ppos[0]-1],$t); $($t).setSelection(ppos[1][ppos[0]-1]); if($.isFunction(p.afterclickPgButtons)) { p.afterclickPgButtons('prev',$("#"+frmgr),ppos[1][ppos[0]-1]); } updateNav(ppos[0]-1,ppos[1].length-1); }; return false; }); }; var posInit =getCurrPos(); updateNav(posInit[0],posInit[1].length-1); function updateNav(cr,totr,rid){ var imp = $t.p.imgpath; if (cr==0) { $("#pData","#"+frmtb).attr("src",imp+"off-"+$t.p.previmg); } else { $("#pData","#"+frmtb).attr("src",imp+$t.p.previmg); } if (cr==totr) { $("#nData","#"+frmtb).attr("src",imp+"off-"+$t.p.nextimg); } else { $("#nData","#"+frmtb).attr("src",imp+$t.p.nextimg); } }; function getCurrPos() { var rowsInGrid = $($t).getDataIDs(); var selrow = $("#id_g","#"+frmtb).val(); var pos = $.inArray(selrow,rowsInGrid); return [pos,rowsInGrid]; }; function createData(rowid,obj,tb){ var nm, hc,trdata, tdl, tde, cnt=0,tmp, dc,elc, retpos=[]; $('#'+rowid+' td',obj.grid.bDiv).each( function(i) { nm = obj.p.colModel[i].name; // hidden fields are included in the form if(obj.p.colModel[i].editrules && obj.p.colModel[i].editrules.edithidden == true) { hc = false; } else { hc = obj.p.colModel[i].hidden === true ? true : false; } dc = hc ? "style='display:none'" : ""; if ( nm !== 'cb' && nm !== 'subgrid' && obj.p.colModel[i].editable===true) { if(nm == obj.p.ExpandColumn && obj.p.treeGrid === true) { tmp = $(this).text(); } else { try { tmp = $.unformat(this,{colModel:obj.p.colModel[i]},i); } catch (_) { tmp = $.htmlDecode($(this).html()); } } var opt = $.extend(obj.p.colModel[i].editoptions || {} ,{id:nm,name:nm}); if(!obj.p.colModel[i].edittype) obj.p.colModel[i].edittype = "text"; elc = createEl(obj.p.colModel[i].edittype,opt,tmp); $(elc).addClass("FormElement"); trdata = $("<tr "+dc+"></tr>").addClass("FormData").attr("id","tr_"+nm); tdl = $("<td></td>").addClass("CaptionTD"); tde = $("<td></td>").addClass("DataTD"); $(tdl).html(obj.p.colNames[i]+": "); $(tde).append(elc); trdata.append(tdl); trdata.append(tde); if(tb) { $(tb).append(trdata); } else { $(trdata).insertBefore("#Act_Buttons"); } retpos[cnt] = i; cnt++; }; }); if( cnt > 0) { var idrow = $("<tr class='FormData' style='display:none'><td class='CaptionTD'>"+"&nbsp;"+"</td><td class='DataTD'><input class='FormElement' id='id_g' type='text' name='id' value='"+rowid+"'/></td></tr>"); if(tb) { $(tb).append(idrow); } else { $(idrow).insertBefore("#Act_Buttons"); } } return retpos; }; function fillData(rowid,obj){ var nm, hc,cnt=0,tmp; $('#'+rowid+' td',obj.grid.bDiv).each( function(i) { nm = obj.p.colModel[i].name; // hidden fields are included in the form if(obj.p.colModel[i].editrules && obj.p.colModel[i].editrules.edithidden === true) { hc = false; } else { hc = obj.p.colModel[i].hidden === true ? true : false; } if ( nm !== 'cb' && nm !== 'subgrid' && obj.p.colModel[i].editable===true) { if(nm == obj.p.ExpandColumn && obj.p.treeGrid === true) { tmp = $(this).text(); } else { try { tmp = $.unformat(this,{colModel:obj.p.colModel[i]},i); } catch (_) { tmp = $.htmlDecode($(this).html()); } } nm= nm.replace('.',"\\."); switch (obj.p.colModel[i].edittype) { case "password": case "text": tmp = $.htmlDecode(tmp); $("#"+nm,"#"+frmtb).val(tmp); break; case "textarea": if(tmp == "&nbsp;" || tmp == "&#160;") {tmp='';} $("#"+nm,"#"+frmtb).val(tmp); break; case "select": $("#"+nm+" option","#"+frmtb).each(function(j){ if (!obj.p.colModel[i].editoptions.multiple && tmp == $(this).text() ){ this.selected= true; } else if (obj.p.colModel[i].editoptions.multiple){ if( $.inArray($(this).text(), tmp.split(",") ) > -1 ){ this.selected = true; }else{ this.selected = false; } } else { this.selected = false; } }); break; case "checkbox": if(tmp==$("#"+nm,"#"+frmtb).val()) { $("#"+nm,"#"+frmtb).attr("checked",true); $("#"+nm,"#"+frmtb).attr("defaultChecked",true); //ie } else { $("#"+nm,"#"+frmtb).attr("checked",false); $("#"+nm,"#"+frmtb).attr("defaultChecked",""); //ie } break; } if (hc) { $("#"+nm,"#"+frmtb).parents("tr:first").hide(); } cnt++; } }); if(cnt>0) { $("#id_g","#"+frmtb).val(rowid); } else { $("#id_g","#"+frmtb).val(""); } return cnt; }; }); }, delGridRow : function(rowids,p) { p = $.extend({ top : 0, left: 0, width: 240, height: 90, modal: false, drag: true, closeicon: 'ico-close.gif', imgpath: '', url : '', mtype : "POST", reloadAfterSubmit: true, beforeShowForm: null, afterShowForm: null, beforeSubmit: null, onclickSubmit: null, afterSubmit: null, onclickSubmit: null, delData: {} }, $.jgrid.del, p ||{}); return this.each(function(){ var $t = this; if (!$t.grid ) { return; } if(!rowids) { return; } if(!p.imgpath) { p.imgpath= $t.p.imgpath; } var onBeforeShow = typeof p.beforeShowForm === 'function' ? true: false; var onAfterShow = typeof p.afterShowForm === 'function' ? true: false; if (isArray(rowids)) { rowids = rowids.join(); } var gID = $("table:first",$t.grid.bDiv).attr("id"); var IDs = {themodal:'delmod'+gID,modalhead:'delhd'+gID,modalcontent:'delcnt'+gID}; var dtbl = "DelTbl_"+gID; if ( $("#"+IDs.themodal).html() != null ) { $("#DelData>td","#"+dtbl).text(rowids); $("#DelError","#"+dtbl).hide(); if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); } viewModal("#"+IDs.themodal,{modal:p.modal}); if(onAfterShow) { p.afterShowForm($("#"+dtbl)); } } else { var tbl =$("<table id='"+dtbl+"' class='DelTable'><tbody></tbody></table>"); // error data $(tbl).append("<tr id='DelError' style='display:none'><td >"+"&nbsp;"+"</td></tr>"); $(tbl).append("<tr id='DelData' style='display:none'><td >"+rowids+"</td></tr>"); $(tbl).append("<tr><td >"+p.msg+"</td></tr>"); // buttons at footer var bS ="<input id='dData' type='button' value='"+p.bSubmit+"'/>"; var bC ="<input id='eData' type='button' value='"+p.bCancel+"'/>"; $(tbl).append("<tr><td class='DelButton'>"+bS+"&nbsp;"+bC+"</td></tr>"); createModal(IDs,tbl,p,$t.grid.hDiv,$t.grid.hDiv); if( p.drag) { DnRModal("#"+IDs.themodal,"#"+IDs.modalhead+" td.modaltext"); } $("#dData","#"+dtbl).click(function(e){ var ret=[true,""]; var postdata = $("#DelData>td","#"+dtbl).text(); //the pair is name=val1,val2,... if( typeof p.onclickSubmit === 'function' ) { p.delData = p.onclickSubmit(p) || {}; } if( typeof p.beforeSubmit === 'function' ) { ret = p.beforeSubmit(postdata); } var gurl = p.url ? p.url : $t.p.editurl; if(!gurl) { ret[0]=false;ret[1] += " "+$.jgrid.errors.nourl;} if(ret[0] === false) { $("#DelError>td","#"+dtbl).html(ret[1]); $("#DelError","#"+dtbl).show(); } else { if(!p.processing) { p.processing = true; $("div.loading","#"+IDs.themodal).fadeIn("fast"); $(this).attr("disabled",true); var postd = $.extend({oper:"del", id:postdata},p.delData); $.ajax({ url:gurl, type: p.mtype, data:postd, complete:function(data,Status){ if(Status != "success") { ret[0] = false; ret[1] = Status+" Status: "+data.statusText +" Error code: "+data.status; } else { // data is posted successful // execute aftersubmit with the returned data from server if( typeof p.afterSubmit === 'function' ) { ret = p.afterSubmit(data,postdata); } } if(ret[0] === false) { $("#DelError>td","#"+dtbl).html(ret[1]); $("#DelError","#"+dtbl).show(); } else { if(p.reloadAfterSubmit) { if($t.p.treeGrid) { $($t).setGridParam({treeANode:0,datatype:$t.p.treedatatype}); } $($t).trigger("reloadGrid"); } else { var toarr = []; toarr = postdata.split(","); if($t.p.treeGrid===true){ try {$($t).delTreeNode(toarr[0])} catch(e){} } else { for(var i=0;i<toarr.length;i++) { $($t).delRowData(toarr[i]); } } $t.p.selrow = null; $t.p.selarrrow = []; } if($.isFunction(p.afterComplete)) { setTimeout(function(){p.afterComplete(data,postdata);},500); } } p.processing=false; $("#dData", "#"+dtbl).attr("disabled",false); $("div.loading","#"+IDs.themodal).fadeOut("fast"); if(ret[0]) { hideModal("#"+IDs.themodal); } } }); } } return false; }); $("#eData", "#"+dtbl).click(function(e){ hideModal("#"+IDs.themodal); return false; }); if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); } viewModal("#"+IDs.themodal,{modal:p.modal}); if(onAfterShow) { p.afterShowForm($("#"+dtbl)); } } }); }, navGrid : function (elem, o, pEdit,pAdd,pDel,pSearch) { o = $.extend({ edit: true, editicon: "row_edit.gif", add: true, addicon:"row_add.gif", del: true, delicon:"row_delete.gif", search: true, searchicon:"find.gif", refresh: true, refreshicon:"refresh.gif", refreshstate: 'firstpage', position : "left", closeicon: "ico-close.gif" }, $.jgrid.nav, o ||{}); return this.each(function() { var alertIDs = {themodal:'alertmod',modalhead:'alerthd',modalcontent:'alertcnt'}; var $t = this; if(!$t.grid) { return; } if ($("#"+alertIDs.themodal).html() == null) { var vwidth; var vheight; if (typeof window.innerWidth != 'undefined') { vwidth = window.innerWidth, vheight = window.innerHeight } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) { vwidth = document.documentElement.clientWidth, vheight = document.documentElement.clientHeight } else { vwidth=1024; vheight=768; } createModal(alertIDs,"<div>"+o.alerttext+"</div>",{imgpath:$t.p.imgpath,closeicon:o.closeicon,caption:o.alertcap,top:vheight/2-25,left:vwidth/2-100,width:200,height:50},$t.grid.hDiv,$t.grid.hDiv,true); DnRModal("#"+alertIDs.themodal,"#"+alertIDs.modalhead); } var navTbl = $("<table cellspacing='0' cellpadding='0' border='0' class='navtable'><tbody></tbody></table>").height(20); var trd = document.createElement("tr"); $(trd).addClass("nav-row"); var imp = $t.p.imgpath; var tbd; if (o.add) { tbd = document.createElement("td"); $(tbd).append("&nbsp;").css({border:"none",padding:"0px"}); trd.appendChild(tbd); tbd = document.createElement("td"); tbd.title = o.addtitle || ""; $(tbd).append("<table cellspacing='0' cellpadding='0' border='0' class='tbutton'><tr><td><img src='"+imp+o.addicon+"'/></td><td>"+o.addtext+"&nbsp;</td></tr></table>") .css("cursor","pointer") .addClass("nav-button") .click(function(){ if (typeof o.addfunc == 'function') { o.addfunc(); } else { $($t).editGridRow("new",pAdd || {}); } return false; }) .hover( function () { $(this).addClass("nav-hover"); }, function () { $(this).removeClass("nav-hover"); } ); trd.appendChild(tbd); tbd = null; } if (o.edit) { tbd = document.createElement("td"); $(tbd).append("&nbsp;").css({border:"none",padding:"0px"}); trd.appendChild(tbd); tbd = document.createElement("td"); tbd.title = o.edittitle || ""; $(tbd).append("<table cellspacing='0' cellpadding='0' border='0' class='tbutton'><tr><td><img src='"+imp+o.editicon+"'/></td><td valign='center'>"+o.edittext+"&nbsp;</td></tr></table>") .css("cursor","pointer") .addClass("nav-button") .click(function(){ var sr = $($t).getGridParam('selrow'); if (sr) { if(typeof o.editfunc == 'function') { o.editfunc(sr); } else { $($t).editGridRow(sr,pEdit || {}); } } else { viewModal("#"+alertIDs.themodal); } return false; }) .hover( function () { $(this).addClass("nav-hover"); }, function () { $(this).removeClass("nav-hover"); } ); trd.appendChild(tbd); tbd = null; } if (o.del) { tbd = document.createElement("td"); $(tbd).append("&nbsp;").css({border:"none",padding:"0px"}); trd.appendChild(tbd); tbd = document.createElement("td"); tbd.title = o.deltitle || ""; $(tbd).append("<table cellspacing='0' cellpadding='0' border='0' class='tbutton'><tr><td><img src='"+imp+o.delicon+"'/></td><td>"+o.deltext+"&nbsp;</td></tr></table>") .css("cursor","pointer") .addClass("nav-button") .click(function(){ var dr; if($t.p.multiselect) { dr = $($t).getGridParam('selarrrow'); if(dr.length==0) { dr = null; } } else { dr = $($t).getGridParam('selrow'); } if (dr) { $($t).delGridRow(dr,pDel || {}); } else { viewModal("#"+alertIDs.themodal); } return false; }) .hover( function () { $(this).addClass("nav-hover"); }, function () { $(this).removeClass("nav-hover"); } ); trd.appendChild(tbd); tbd = null; } if (o.search) { tbd = document.createElement("td"); $(tbd).append("&nbsp;").css({border:"none",padding:"0px"}); trd.appendChild(tbd); tbd = document.createElement("td"); if( $(elem)[0] == $t.p.pager[0] ) { pSearch = $.extend(pSearch,{dirty:true}); } tbd.title = o.searchtitle || ""; $(tbd).append("<table cellspacing='0' cellpadding='0' border='0' class='tbutton'><tr><td class='no-dirty-cell'><img src='"+imp+o.searchicon+"'/></td><td>"+o.searchtext+"&nbsp;</td></tr></table>") .css({cursor:"pointer"}) .addClass("nav-button") .click(function(){ $($t).searchGrid(pSearch || {}); return false; }) .hover( function () { $(this).addClass("nav-hover"); }, function () { $(this).removeClass("nav-hover"); } ); trd.appendChild(tbd); tbd = null; } if (o.refresh) { tbd = document.createElement("td"); $(tbd).append("&nbsp;").css({border:"none",padding:"0px"}); trd.appendChild(tbd); tbd = document.createElement("td"); tbd.title = o.refreshtitle || ""; var dirtycell = ($(elem)[0] == $t.p.pager[0] ) ? true : false; $(tbd).append("<table cellspacing='0' cellpadding='0' border='0' class='tbutton'><tr><td><img src='"+imp+o.refreshicon+"'/></td><td>"+o.refreshtext+"&nbsp;</td></tr></table>") .css("cursor","pointer") .addClass("nav-button") .click(function(){ $t.p.search = false; switch (o.refreshstate) { case 'firstpage': $t.p.page=1; $($t).trigger("reloadGrid"); break; case 'current': var sr = $t.p.multiselect===true ? selarrrow : $t.p.selrow; $($t).setGridParam({gridComplete: function() { if($t.p.multiselect===true) { if(sr.length>0) { for(var i=0;i<sr.length;i++){ $($t).setSelection(sr[i]); } } } else { if(sr) { $($t).setSelection(sr); } } }}); $($t).trigger("reloadGrid"); break; } if (dirtycell) { $(".no-dirty-cell",$t.p.pager).removeClass("dirty-cell"); } if(o.search) { var gID = $("table:first",$t.grid.bDiv).attr("id"); $("#sval",'#srchcnt'+gID).val(""); } return false; }) .hover( function () { $(this).addClass("nav-hover"); }, function () { $(this).removeClass("nav-hover"); } ); trd.appendChild(tbd); tbd = null; } if(o.position=="left") { $(navTbl).append(trd).addClass("nav-table-left"); } else { $(navTbl).append(trd).addClass("nav-table-right"); } $(elem).prepend(navTbl); }); }, navButtonAdd : function (elem, p) { p = $.extend({ caption : "newButton", title: '', buttonimg : '', onClickButton: null, position : "last" }, p ||{}); return this.each(function() { if( !this.grid) { return; } if( elem.indexOf("#") != 0) { elem = "#"+elem; } var findnav = $(".navtable",elem)[0]; if (findnav) { var tdb, tbd1; var tbd1 = document.createElement("td"); $(tbd1).append("&nbsp;").css({border:"none",padding:"0px"}); var trd = $("tr:eq(0)",findnav)[0]; if( p.position !='first' ) { trd.appendChild(tbd1); } tbd = document.createElement("td"); tbd.title = p.title; var im = (p.buttonimg) ? "<img src='"+p.buttonimg+"'/>" : "&nbsp;"; $(tbd).append("<table cellspacing='0' cellpadding='0' border='0' class='tbutton'><tr><td>"+im+"</td><td>"+p.caption+"&nbsp;</td></tr></table>") .css("cursor","pointer") .addClass("nav-button") .click(function(e){ if (typeof p.onClickButton == 'function') { p.onClickButton(); } e.stopPropagation(); return false; }) .hover( function () { $(this).addClass("nav-hover"); }, function () { $(this).removeClass("nav-hover"); } ); if(p.position != 'first') { trd.appendChild(tbd); } else { $(trd).prepend(tbd); $(trd).prepend(tbd1); } tbd=null;tbd1=null; } }); }, GridToForm : function( rowid, formid ) { return this.each(function(){ var $t = this; if (!$t.grid) { return; } var rowdata = $($t).getRowData(rowid); if (rowdata) { for(var i in rowdata) { if ( $("[name="+i+"]",formid).is("input:radio") ) { $("[name="+i+"]",formid).each( function() { if( $(this).val() == rowdata[i] ) { $(this).attr("checked","checked"); } else { $(this).attr("checked",""); } }); } else { // this is very slow on big table and form. $("[name="+i+"]",formid).val(rowdata[i]); } } } }); }, FormToGrid : function(rowid, formid){ return this.each(function() { var $t = this; if(!$t.grid) { return; } var fields = $(formid).serializeArray(); var griddata = {}; $.each(fields, function(i, field){ griddata[field.name] = field.value; }); $($t).setRowData(rowid,griddata); }); } }); })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.formedit.js
JavaScript
gpl2
35,767
;(function ($) { /* * jqGrid 3.3 - jQuery Grid * Copyright (c) 2008, Tony Tomov, tony@trirand.com * Dual licensed under the MIT and GPL licenses * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * Date: 2008-10-14 rev 64 */ $.fn.jqGrid = function( p ) { p = $.extend(true,{ url: "", height: 150, page: 1, rowNum: 20, records: 0, pager: "", pgbuttons: true, pginput: true, colModel: [], rowList: [], colNames: [], sortorder: "asc", sortname: "", datatype: "xml", mtype: "GET", imgpath: "", sortascimg: "sort_asc.gif", sortdescimg: "sort_desc.gif", firstimg: "first.gif", previmg: "prev.gif", nextimg: "next.gif", lastimg: "last.gif", altRows: true, selarrrow: [], savedRow: [], shrinkToFit: true, xmlReader: {}, jsonReader: {}, subGrid: false, subGridModel :[], lastpage: 0, lastsort: 0, selrow: null, onSelectRow: null, onSortCol: null, ondblClickRow: null, onRightClickRow: null, onPaging: null, onSelectAll: null, loadComplete: null, gridComplete: null, loadError: null, loadBeforeSend: null, afterInsertRow: null, beforeRequest: null, onHeaderClick: null, viewrecords: false, loadonce: false, multiselect: false, multikey: false, editurl: null, search: false, searchdata: {}, caption: "", hidegrid: true, hiddengrid: false, postData: {}, userData: {}, treeGrid : false, treeANode: 0, treedatatype: null, treeReader: {level_field: "level", left_field:"lft", right_field: "rgt", leaf_field: "isLeaf", expanded_field: "expanded" }, tree_root_level: 0, ExpandColumn: null, sortclass: "grid_sort", resizeclass: "grid_resize", forceFit : false, gridstate : "visible", cellEdit: false, cellsubmit: "remote", nv:0, loadui: "enable", toolbar: [false,""] }, $.jgrid.defaults, p || {}); var grid={ headers:[], cols:[], dragStart: function(i,x) { this.resizing = { idx: i, startX: x}; this.hDiv.style.cursor = "e-resize"; }, dragMove: function(x) { if(this.resizing) { var diff = x-this.resizing.startX; var h = this.headers[this.resizing.idx]; var newWidth = h.width + diff; var msie = $.browser.msie; if(newWidth > 25) { if(p.forceFit===true ){ var hn = this.headers[this.resizing.idx+p.nv]; var nWn = hn.width - diff; if(nWn >25) { h.el.style.width = newWidth+"px"; h.newWidth = newWidth; this.cols[this.resizing.idx].style.width = newWidth+"px"; hn.el.style.width = nWn +"px"; hn.newWidth = nWn; this.cols[this.resizing.idx+p.nv].style.width = nWn+"px"; this.newWidth = this.width; } } else { h.el.style.width = newWidth+"px"; h.newWidth = newWidth; this.cols[this.resizing.idx].style.width = newWidth+"px"; this.newWidth = this.width+diff; $('table:first',this.bDiv).css("width",this.newWidth +"px"); $('table:first',this.hDiv).css("width",this.newWidth +"px"); var scrLeft = this.bDiv.scrollLeft; this.hDiv.scrollLeft = this.bDiv.scrollLeft; if(msie) { if(scrLeft - this.hDiv.scrollLeft >= 5) {this.bDiv.scrollLeft = this.bDiv.scrollLeft - 17;} } } } } }, dragEnd: function() { this.hDiv.style.cursor = "default"; if(this.resizing) { var idx = this.resizing.idx; this.headers[idx].width = this.headers[idx].newWidth || this.headers[idx].width; this.cols[idx].style.width = this.headers[idx].newWidth || this.headers[idx].width; if(p.forceFit===true){ this.headers[idx+p.nv].width = this.headers[idx+p.nv].newWidth || this.headers[idx+p.nv].width; this.cols[idx+p.nv].style.width = this.headers[idx+p.nv].newWidth || this.headers[idx+p.nv].width; } if(this.newWidth) {this.width = this.newWidth;} this.resizing = false; } }, scrollGrid: function() { var scrollLeft = this.bDiv.scrollLeft; this.hDiv.scrollLeft = this.bDiv.scrollLeft; if(scrollLeft - this.hDiv.scrollLeft > 5) {this.bDiv.scrollLeft = this.bDiv.scrollLeft - 17;} } }; $.fn.getGridParam = function(pName) { var $t = this[0]; if (!$t.grid) {return;} if (!pName) { return $t.p; } else {return $t.p[pName] ? $t.p[pName] : null;} }; $.fn.setGridParam = function (newParams){ return this.each(function(){ if (this.grid && typeof(newParams) === 'object') {$.extend(true,this.p,newParams);} }); }; $.fn.getDataIDs = function () { var ids=[]; this.each(function(){ $(this.rows).slice(1).each(function(i){ ids[i]=this.id; }); }); return ids; }; $.fn.setSortName = function (newsort) { return this.each(function(){ var $t = this; for(var i=0;i< $t.p.colModel.length;i++){ if($t.p.colModel[i].name===newsort || $t.p.colModel[i].index===newsort){ $("tr th:eq("+$t.p.lastsort+") div img",$t.grid.hDiv).remove(); $t.p.lastsort = i; $t.p.sortname=newsort; break; } } }); }; $.fn.setSelection = function(selection,sd) { return this.each(function(){ var $t = this, stat,pt; if(selection===false) {pt = sd;} else { var ind = $($t).getInd($t.rows,selection); pt=$($t.rows[ind]);} selection = $(pt).attr("id"); if (!pt.html()) {return;} if(!$t.p.multiselect) { if($(pt).attr("class") !== "subgrid") { if( $t.p.selrow ) {$("tr#"+$t.p.selrow+":first",$t.grid.bDiv).removeClass("selected");} $t.p.selrow = selection; $(pt).addClass("selected"); if( $t.p.onSelectRow ) { $t.p.onSelectRow($t.p.selrow, true); } } } else { $t.p.selrow = selection; var ia = $.inArray($t.p.selrow,$t.p.selarrrow); if ( ia === -1 ){ if($(pt).attr("class") !== "subgrid") { $(pt).addClass("selected");} stat = true; $("#jqg_"+$t.p.selrow,$t.rows).attr("checked",stat); $t.p.selarrrow.push($t.p.selrow); if( $t.p.onSelectRow ) { $t.p.onSelectRow($t.p.selrow, stat); } } else { if($(pt).attr("class") !== "subgrid") { $(pt).removeClass("selected");} stat = false; $("#jqg_"+$t.p.selrow,$t.rows).attr("checked",stat); $t.p.selarrrow.splice(ia,1); if( $t.p.onSelectRow ) { $t.p.onSelectRow($t.p.selrow, stat); } var tpsr = $t.p.selarrrow[0]; $t.p.selrow = (tpsr=='undefined') ? null : tpsr; } } }); }; $.fn.resetSelection = function(){ return this.each(function(){ var t = this; if(!t.p.multiselect) { if(t.p.selrow) { $("tr#"+t.p.selrow+":first",t.grid.bDiv).removeClass("selected"); t.p.selrow = null; } } else { $(t.p.selarrrow).each(function(i,n){ var ind = $(t).getInd(t.rows,n); $(t.rows[ind]).removeClass("selected"); $("#jqg_"+n,t.rows[ind]).attr("checked",false); }); $("#cb_jqg",t.grid.hDiv).attr("checked",false); t.p.selarrrow = []; } }); }; $.fn.getRowData = function( rowid ) { var res = {}; if (rowid){ this.each(function(){ var $t = this,nm,ind; ind = $($t).getInd($t.rows,rowid); if (!ind) {return res;} $('td:nth-child',$t.rows[ind]).each( function(i) { nm = $t.p.colModel[i].name; if ( nm !== 'cb' && nm !== 'subgrid') { res[nm] = $(this).html().replace(/\&nbsp\;/ig,''); } }); }); } return res; }; $.fn.delRowData = function(rowid) { var success = false, rowInd; if(rowid) { this.each(function() { var $t = this; rowInd = $($t).getInd($t.rows,rowid); if(!rowInd) {return success;} else { $($t.rows[rowInd]).remove(); $t.p.records--; $t.updatepager(); success=true; } if(rowInd == 1 && success && ($.browser.opera || $.browser.safari)) { $($t.rows[1]).each( function( k ) { $(this).css("width",$t.grid.headers[k].width+"px"); $t.grid.cols[k] = this; }); } if( $t.p.altRows === true && success) { $($t.rows).slice(1).each(function(i){ if(i % 2 ==1) {$(this).addClass('alt');} else {$(this).removeClass('alt');} }); } }); } return success; }; $.fn.setRowData = function(rowid, data) { var nm, success=false; this.each(function(){ var t = this; if(!t.grid) {return false;} if( data ) { var ind = $(t).getInd(t.rows,rowid); if(!ind) {return success;} success=true; $(this.p.colModel).each(function(i){ nm = this.name; if(data[nm] !== 'undefined') { $("td:eq("+i+")",t.rows[ind]).html(data[nm]); success = true; } }); } }); return success; }; $.fn.addRowData = function(rowid,data,pos,src) { if(!pos) {pos = "last";} var success = false; var nm, row, td, gi=0, si=0,sind; if(data) { this.each(function() { var t = this; row = document.createElement("tr"); row.id = rowid || t.p.records+1; $(row).addClass("jqgrow"); if(t.p.multiselect) { td = $('<td></td>'); $(td[0],t.grid.bDiv).html("<input type='checkbox'"+" id='jqg_"+rowid+"' class='cbox'/>"); row.appendChild(td[0]); gi = 1; } if(t.p.subGrid ) { try {$(t).addSubGrid(t.grid.bDiv,row,gi);} catch(e){} si=1;} for(var i = gi+si; i < this.p.colModel.length;i++){ nm = this.p.colModel[i].name; td = $('<td></td>'); $(td[0]).html('&#160;'); if(data[nm] !== 'undefined') { $(td[0]).html(data[nm] || '&#160;'); } t.formatCol($(td[0],t.grid.bDiv),i); row.appendChild(td[0]); } switch (pos) { case 'last': $(t.rows[t.rows.length-1]).after(row); break; case 'first': $(t.rows[0]).after(row); break; case 'after': sind = $(t).getInd(t.rows,src); sind >= 0 ? $(t.rows[sind]).after(row): ""; break; case 'before': sind = $(t).getInd(t.rows,src); sind > 0 ? $(t.rows[sind-1]).after(row): ""; break; } t.p.records++; if($.browser.safari || $.browser.opera) { t.scrollLeft = t.scrollLeft; $("td",t.rows[1]).each( function( k ) { $(this).css("width",t.grid.headers[k].width+"px"); t.grid.cols[k] = this; }); } if( t.p.altRows === true ) { if (pos == "last") { if (t.rows.length % 2 == 1) {$(row).addClass('alt');} } else { $(t.rows).slice(1).each(function(i){ if(i % 2 ==1) {$(this).addClass('alt');} else {$(this).removeClass('alt');} }); } } try {t.p.afterInsertRow(row.id,data); } catch(e){} t.updatepager(); success = true; }); } return success; }; $.fn.hideCol = function(colname) { return this.each(function() { var $t = this,w=0, fndh=false; if (!$t.grid ) {return;} if( typeof colname == 'string') {colname=[colname];} $(this.p.colModel).each(function(i) { if ($.inArray(this.name,colname) != -1 && !this.hidden) { var w = parseInt($("tr th:eq("+i+")",$t.grid.hDiv).css("width"),10); $("tr th:eq("+i+")",$t.grid.hDiv).css({display:"none"}); $($t.rows).each(function(j){ $("td:eq("+i+")",$t.rows[j]).css({display:"none"}); }); $t.grid.cols[i].style.width = 0; $t.grid.headers[i].width = 0; $t.grid.width -= w; this.hidden=true; fndh=true; } }); if(fndh===true) { var gtw = Math.min($t.p._width,$t.grid.width); $("table:first",$t.grid.hDiv).width(gtw); $("table:first",$t.grid.bDiv).width(gtw); $($t.grid.hDiv).width(gtw); $($t.grid.bDiv).width(gtw); if($t.p.pager && $($t.p.pager).hasClass("scroll") ) { $($t.p.pager).width(gtw); } if($t.p.caption) {$($t.grid.cDiv).width(gtw);} if($t.p.toolbar[0]) {$($t.grid.uDiv).width(gtw);} $t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft; } }); }; $.fn.showCol = function(colname) { return this.each(function() { var $t = this; var w = 0, fdns=false; if (!$t.grid ) {return;} if( typeof colname == 'string') {colname=[colname];} $($t.p.colModel).each(function(i) { if ($.inArray(this.name,colname) != -1 && this.hidden) { var w = parseInt($("tr th:eq("+i+")",$t.grid.hDiv).css("width"),10); $("tr th:eq("+i+")",$t.grid.hDiv).css("display",""); $($t.rows).each(function(j){ $("td:eq("+i+")",$t.rows[j]).css("display","").width(w); }); this.hidden=false; $t.grid.cols[i].style.width = w; $t.grid.headers[i].width = w; $t.grid.width += w; fdns=true; } }); if(fdns===true) { var gtw = Math.min($t.p._width,$t.grid.width); var ofl = ($t.grid.width <= $t.p._width) ? "hidden" : "auto"; $("table:first",$t.grid.hDiv).width(gtw); $("table:first",$t.grid.bDiv).width(gtw); $($t.grid.hDiv).width(gtw); $($t.grid.bDiv).width(gtw).css("overflow-x",ofl); if($t.p.pager && $($t.p.pager).hasClass("scroll") ) { $($t.p.pager).width(gtw); } if($t.p.caption) {$($t.grid.cDiv).width(gtw);} if($t.p.toolbar[0]) {$($t.grid.uDiv).width(gtw);} $t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft; } }); }; $.fn.setGridWidth = function(nwidth, shrink) { return this.each(function(){ var $t = this, chw=0,w,cw,ofl; if (!$t.grid ) {return;} if(typeof shrink != 'boolean') {shrink=true;} var testdata = getScale(); if(shrink !== true) {testdata[0] = Math.min($t.p._width,$t.grid.width); testdata[2]=0;} else {testdata[2]= testdata[1]} $.each($t.p.colModel,function(i,v){ if(!this.hidden && this.name != 'cb' && this.name!='subgrid') { cw = shrink !== true ? $("tr:first th:eq("+i+")",$t.grid.hDiv).css("width") : this.width; w = Math.round((IENum(nwidth)-IENum(testdata[2]))/IENum(testdata[0])*IENum(cw)); chw += w; $("table thead tr:first th:eq("+i+")",$t.grid.hDiv).css("width",w+"px"); $("table:first tbody tr:first td:eq("+i+")",$t.grid.bDiv).css("width",w+"px"); $t.grid.cols[i].style.width = w; $t.grid.headers[i].width = w; } if(this.name=='cb' || this.name == 'subgrid'){chw += IENum(this.width);} }); if(chw + testdata[1] <= nwidth || $t.p.forceFit === true){ ofl = "hidden"; tw = nwidth;} else { ofl= "auto"; tw = chw + testdata[1];} $("table:first",$t.grid.hDiv).width(tw); $("table:first",$t.grid.bDiv).width(tw); $($t.grid.hDiv).width(nwidth); $($t.grid.bDiv).width(nwidth).css("overflow-x",ofl); if($t.p.pager && $($t.p.pager).hasClass("scroll") ) { $($t.p.pager).width(nwidth); } if($t.p.caption) {$($t.grid.cDiv).width(nwidth);} if($t.p.toolbar[0]) {$($t.grid.uDiv).width(nwidth);} $t.p._width = nwidth; $t.grid.width = tw; if($.browser.safari || $.browser.opera ) { $("table tbody tr:eq(1) td",$t.grid.bDiv).each( function( k ) { $(this).css("width",$t.grid.headers[k].width+"px"); $t.grid.cols[k] = this; }); } $t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft; function IENum(val) { val = parseInt(val,10); return isNaN(val) ? 0 : val; } function getScale(){ var testcell = $("table tr:first th:eq(1)", $t.grid.hDiv); var addpix = IENum($(testcell).css("padding-left")) + IENum($(testcell).css("padding-right"))+ IENum($(testcell).css("border-left-width"))+ IENum($(testcell).css("border-right-width")); var w =0,ap=0; $.each($t.p.colModel,function(i,v){ if(!this.hidden) { w += parseInt(this.width); ap += addpix; } }); return [w,ap,0]; } }); }; $.fn.setGridHeight = function (nh) { return this.each(function (){ var ovfl, ovfl2, $t = this; if(!$t.grid) {return;} if($t.p.forceFit === true) { ovfl2='hidden'; } else {ovfl2=$($t.grid.bDiv).css("overflow-x");} ovfl = (isNaN(nh) && $.browser.mozilla && (nh.indexOf("%")!=-1 || nh=="auto")) ? "hidden" : "auto"; $($t.grid.bDiv).css({height: nh+(isNaN(nh)?"":"px"),"overflow-y":ovfl,"overflow-x": ovfl2}); $t.p.height = nh; }); }; $.fn.setCaption = function (newcap){ return this.each(function(){ this.p.caption=newcap; $("table:first th",this.grid.cDiv).text(newcap); $(this.grid.cDiv).show(); }); }; $.fn.setLabel = function(colname, nData, prop ){ return this.each(function(){ var $t = this, pos=-1; if(!$t.grid) {return;} if(isNaN(colname)) { $($t.p.colModel).each(function(i){ if (this.name == colname) { pos = i;return false; } }); } else {pos = parseInt(colname,10);} if(pos>=0) { var thecol = $("table:first th:eq("+pos+")",$t.grid.hDiv); if (nData){ $("div",thecol).html(nData); } if (prop) { if(typeof prop == 'string') {$(thecol).addClass(prop);} else {$(thecol).css(prop);} } } }); }; $.fn.setCell = function(rowid,colname,nData,prop) { return this.each(function(){ var $t = this, pos =-1; if(!$t.grid) {return;} if(isNaN(colname)) { $($t.p.colModel).each(function(i){ if (this.name == colname) { pos = i;return false; } }); } else {pos = parseInt(colname,10);} if(pos>=0) { var ind = $($t).getInd($t.rows,rowid); if (ind){ var tcell = $("td:eq("+pos+")",$t.rows[ind]); if(nData) {$(tcell).html(nData);} if (prop){ if(typeof prop == 'string') {$(tcell).addClass(prop);} else {$(tcell).css(prop);} } } } }); }; $.fn.getCell = function(rowid,iCol) { var ret = false; this.each(function(){ var $t=this; if(!$t.grid) {return;} if(rowid && iCol>=0) { var ind = $($t).getInd($t.rows,rowid); if(ind) { ret = $("td:eq("+iCol+")",$t.rows[ind]).html().replace(/\&nbsp\;/ig,''); } } }); return ret; }; $.fn.clearGridData = function() { return this.each(function(){ var $t = this; if(!$t.grid) {return;} $("tbody tr:gt(0)", $t.grid.bDiv).remove(); $t.p.selrow = null; $t.p.selarrrow= []; $t.p.records = 0;$t.p.page=0;$t.p.lastpage=0; $t.updatepager(); }); }; $.fn.getInd = function(obj,rowid,rc){ var ret =false; $(obj).each(function(i){ if(this.id==rowid) { ret = rc===true ? this : i; return false; } }); return ret; }; return this.each( function() { if(this.grid) {return;} this.p = p ; if( this.p.colNames.length === 0 || this.p.colNames.length !== this.p.colModel.length ) { alert("Length of colNames <> colModel or 0!"); return; } if(this.p.imgpath !== "" ) {this.p.imgpath += "/";} var ts = this; $("<div class='loadingui' id=lui_"+this.id+"/>").insertBefore(this); $(this).attr({cellSpacing:"0",cellPadding:"0",border:"0"}); var onSelectRow = $.isFunction(this.p.onSelectRow) ? this.p.onSelectRow :false; var ondblClickRow = $.isFunction(this.p.ondblClickRow) ? this.p.ondblClickRow :false; var onSortCol = $.isFunction(this.p.onSortCol) ? this.p.onSortCol : false; var loadComplete = $.isFunction(this.p.loadComplete) ? this.p.loadComplete : false; var loadError = $.isFunction(this.p.loadError) ? this.p.loadError : false; var loadBeforeSend = $.isFunction(this.p.loadBeforeSend) ? this.p.loadBeforeSend : false; var onRightClickRow = $.isFunction(this.p.onRightClickRow) ? this.p.onRightClickRow : false; var afterInsRow = $.isFunction(this.p.afterInsertRow) ? this.p.afterInsertRow : false; var onHdCl = $.isFunction(this.p.onHeaderClick) ? this.p.onHeaderClick : false; var beReq = $.isFunction(this.p.beforeRequest) ? this.p.beforeRequest : false; var onSC = $.isFunction(this.p.onCellSelect) ? this.p.onCellSelect : false; var sortkeys = ["shiftKey","altKey","ctrlKey"]; if ($.inArray(ts.p.multikey,sortkeys) == -1 ) {ts.p.multikey = false;} var IntNum = function(val,defval) { val = parseInt(val,10); if (isNaN(val)) { return (defval) ? defval : 0;} else {return val;} }; var formatCol = function (elem, pos){ var rowalign1 = ts.p.colModel[pos].align || "left"; $(elem).css("text-align",rowalign1); if(ts.p.colModel[pos].hidden) {$(elem).css("display","none");} }; var resizeFirstRow = function (t,er){ $("tbody tr:eq("+er+") td",t).each( function( k ) { $(this).css("width",grid.headers[k].width+"px"); grid.cols[k] = this; }); }; var addCell = function(t,row,cell,pos) { var td; td = document.createElement("td"); $(td).html(cell); row.appendChild(td); formatCol($(td,t), pos); }; var addMulti = function(t,row){ var cbid,td; td = document.createElement("td"); cbid = "jqg_"+row.id; $(td,t).html("<input type='checkbox'"+" id='"+cbid+"' class='cbox'/>"); formatCol($(td,t), 0); row.appendChild(td); }; var reader = function (datatype) { var field, f=[], j=0; for(var i =0; i<ts.p.colModel.length; i++){ field = ts.p.colModel[i]; if (field.name !== 'cb' && field.name !=='subgrid') { f[j] = (datatype=="xml") ? field.xmlmap || field.name : field.jsonmap || field.name; j++; } } return f; }; var addXmlData = function addXmlData (xml,t) { if(xml) { var fpos = ts.p.treeANode; if(fpos===0) {$("tbody tr:gt(0)", t).remove();} } else { return; } var row,gi=0,si=0,cbid,idn, getId,f=[],rd =[],cn=(ts.p.altRows === true) ? 'alt':''; if(!ts.p.xmlReader.repeatitems) {f = reader("xml");} if( ts.p.keyIndex===false) { idn = ts.p.xmlReader.id; if( idn.indexOf("[") === -1 ) { getId = function( trow, k) {return $(idn,trow).text() || k;}; } else { getId = function( trow, k) {return trow.getAttribute(idn.replace(/[\[\]]/g,"")) || k;}; } } else { getId = function(trow) { return (f.length - 1 >= ts.p.keyIndex) ? $(f[ts.p.keyIndex],trow).text() : $(ts.p.xmlReader.cell+":eq("+ts.p.keyIndex+")",trow).text(); }; } $(ts.p.xmlReader.page,xml).each(function() {ts.p.page = this.textContent || this.text ; }); $(ts.p.xmlReader.total,xml).each(function() {ts.p.lastpage = this.textContent || this.text ; } ); $(ts.p.xmlReader.records,xml).each(function() {ts.p.records = this.textContent || this.text ; } ); $(ts.p.xmlReader.userdata,xml).each(function() {ts.p.userData[this.getAttribute("name")]=this.textContent || this.text;}); $(ts.p.xmlReader.root+" "+ts.p.xmlReader.row,xml).each( function( j ) { row = document.createElement("tr"); row.id = getId(this,j+1); if(ts.p.multiselect) { addMulti(t,row); gi = 1; } if (ts.p.subGrid) { try {$(ts).addSubGrid(t,row,gi,this);} catch (e){} si= 1; } var v; if(ts.p.xmlReader.repeatitems===true){ $(ts.p.xmlReader.cell,this).each( function (i) { v = this.textContent || this.text; addCell(t,row,v || '&#160;',i+gi+si); rd[ts.p.colModel[i+gi+si].name] = v; }); } else { for(var i = 0; i < f.length;i++) { v = $(f[i],this).text(); addCell(t, row, v || '&#160;', i+gi+si); rd[ts.p.colModel[i+gi+si].name] = v; } } if(j%2 == 1) {row.className = cn;} $(row).addClass("jqgrow"); if( ts.p.treeGrid === true) { try {$(ts).setTreeNode(rd,row);} catch (e) {} } $(ts.rows[j+fpos]).after(row); if(afterInsRow) {ts.p.afterInsertRow(row.id,rd,this);} rd=[]; }); xml = null; if(isSafari || isOpera) {resizeFirstRow(t,1);} if(!ts.p.treeGrid) {ts.grid.bDiv.scrollTop = 0;} endReq(); updatepager(); }; var addJSONData = function(data,t) { if(data) { var fpos = ts.p.treeANode; if(fpos===0) {$("tbody tr:gt(0)", t).remove();} } else { return; } var row,f=[],cur,gi=0,si=0,drows,idn,rd=[],cn=(ts.p.altRows===true) ? 'alt':''; ts.p.page = data[ts.p.jsonReader.page]; ts.p.lastpage= data[ts.p.jsonReader.total]; ts.p.records= data[ts.p.jsonReader.records]; ts.p.userData = data[ts.p.jsonReader.userdata] || {}; if(!ts.p.jsonReader.repeatitems) {f = reader("json");} if( ts.p.keyIndex===false ) { idn = ts.p.jsonReader.id; if(f.length>0 && !isNaN(idn)) {idn=f[idn];} } else { idn = f.length>0 ? f[ts.p.keyIndex] : ts.p.keyIndex; } drows = data[ts.p.jsonReader.root]; if (drows) { for (var i=0;i<drows.length;i++) { cur = drows[i]; row = document.createElement("tr"); row.id = cur[idn] || ""; if(row.id === "") { if(f.length===0){ if(ts.p.jsonReader.cell){ var ccur = cur[ts.p.jsonReader.cell]; row.id = ccur[idn] || i+1; ccur=null; } else {row.id=i+1;} } else { row.id=i+1; } } if(ts.p.multiselect){ addMulti(t,row); gi = 1; } if (ts.p.subGrid) { try { $(ts).addSubGrid(t,row,gi,drows[i]);} catch (e){} si= 1; } if (ts.p.jsonReader.repeatitems === true) { if(ts.p.jsonReader.cell) {cur = cur[ts.p.jsonReader.cell];} for (var j=0;j<cur.length;j++) { addCell(t,row,cur[j] || '&#160;',j+gi+si); rd[ts.p.colModel[j+gi+si].name] = cur[j]; } } else { for (var j=0;j<f.length;j++) { addCell(t,row,cur[f[j]] || '&#160;',j+gi+si); rd[ts.p.colModel[j+gi+si].name] = cur[f[j]]; } } if(i%2 == 1) {row.className = cn;} $(row).addClass("jqgrow"); if( ts.p.treeGrid === true) { try {$(ts).setTreeNode(rd,row);} catch (e) {} } $(ts.rows[i+fpos]).after(row); if(afterInsRow) {ts.p.afterInsertRow(row.id,rd,drows[i]);} rd=[]; } } data = null; if(isSafari || isOpera) {resizeFirstRow(t,1);} if(!ts.p.treeGrid) {ts.grid.bDiv.scrollTop = 0;} endReq(); updatepager(); }; var updatepager = function() { if(ts.p.pager) { var cp, last,imp = ts.p.imgpath; if (ts.p.loadonce) { cp = last = 1; ts.p.lastpage = ts.page =1; $(".selbox",ts.p.pager).attr("disabled",true); } else { cp = IntNum(ts.p.page); last = IntNum(ts.p.lastpage); $(".selbox",ts.p.pager).attr("disabled",false); } if(ts.p.pginput===true) { $('input.selbox',ts.p.pager).val(ts.p.page); } if (ts.p.viewrecords){ $('#sp_1',ts.p.pager).html(ts.p.pgtext+"&#160;"+ts.p.lastpage ); $('#sp_2',ts.p.pager).html(ts.p.records+"&#160;"+ts.p.recordtext+"&#160;"); } if(ts.p.pgbuttons===true) { if(cp<=0) {cp = last = 1;} if(cp==1) {$("#first",ts.p.pager).attr({src:imp+"off-"+ts.p.firstimg,disabled:true});} else {$("#first",ts.p.pager).attr({src:imp+ts.p.firstimg,disabled:false});} if(cp==1) {$("#prev",ts.p.pager).attr({src:imp+"off-"+ts.p.previmg,disabled:true});} else {$("#prev",ts.p.pager).attr({src:imp+ts.p.previmg,disabled:false});} if(cp==last) {$("#next",ts.p.pager).attr({src:imp+"off-"+ts.p.nextimg,disabled:true});} else {$("#next",ts.p.pager).attr({src:imp+ts.p.nextimg,disabled:false});} if(cp==last) {$("#last",ts.p.pager).attr({src:imp+"off-"+ts.p.lastimg,disabled:true});} else {$("#last",ts.p.pager).attr({src:imp+ts.p.lastimg,disabled:false});} } } if($.isFunction(ts.p.gridComplete)) {ts.p.gridComplete();} }; var populate = function () { if(!grid.hDiv.loading) { beginReq(); var gdata = $.extend(ts.p.postData,{page: ts.p.page, rows: ts.p.rowNum, sidx: ts.p.sortname, sord:ts.p.sortorder, nd: (new Date().getTime()), _search:ts.p.search}); if (ts.p.search ===true) {gdata =$.extend(gdata,ts.p.searchdata);} if ($.isFunction(ts.p.datatype)) {ts.p.datatype(gdata);endReq();} switch(ts.p.datatype) { case "json": $.ajax({url:ts.p.url,type:ts.p.mtype,dataType:"json",data: gdata, complete:function(JSON,st) { if(st=="success") {addJSONData(eval("("+JSON.responseText+")"),ts.grid.bDiv); if(loadComplete) {loadComplete();}}}, error:function(xhr,st,err){if(loadError) {loadError(xhr,st,err);}endReq();}, beforeSend: function(xhr){if(loadBeforeSend) {loadBeforeSend(xhr);}}}); if( ts.p.loadonce || ts.p.treeGrid) {ts.p.datatype = "local";} break; case "xml": $.ajax({url:ts.p.url,type:ts.p.mtype,dataType:"xml",data: gdata , complete:function(xml,st) {if(st=="success") {addXmlData(xml.responseXML,ts.grid.bDiv); if(loadComplete) {loadComplete();}}}, error:function(xhr,st,err){if(loadError) {loadError(xhr,st,err);}endReq();}, beforeSend: function(xhr){if(loadBeforeSend) {loadBeforeSend(xhr);}}}); if( ts.p.loadonce || ts.p.treeGrid) {ts.p.datatype = "local";} break; case "xmlstring": addXmlData(stringToDoc(ts.p.datastr),ts.grid.bDiv); ts.p.datastr = null; ts.p.datatype = "local"; if(loadComplete) {loadComplete();} break; case "jsonstring": addJSONData(eval("("+ts.p.datastr+")"),ts.grid.bDiv); ts.p.datastr = null; ts.p.datatype = "local"; if(loadComplete) {loadComplete();} break; case "local": case "clientSide": sortArrayData(); break; } } }; var beginReq = function() { if(beReq) {ts.p.beforeRequest();} grid.hDiv.loading = true; switch(ts.p.loadui) { case "disable": break; case "enable": $("div.loading",grid.hDiv).fadeIn("fast"); break; case "block": $("div.loading",grid.hDiv).fadeIn("fast"); $("#lui_"+ts.id).width($(grid.bDiv).width()).height(IntNum($(grid.bDiv).height())+IntNum(ts.p._height)).show(); break; } }; var endReq = function() { grid.hDiv.loading = false; switch(ts.p.loadui) { case "disable": break; case "enable": $("div.loading",grid.hDiv).fadeOut("fast"); break; case "block": $("div.loading",grid.hDiv).fadeOut("fast"); $("#lui_"+ts.id).hide(); break; } }; var stringToDoc = function (xmlString) { var xmlDoc; try { var parser = new DOMParser(); xmlDoc = parser.parseFromString(xmlString,"text/xml"); } catch(e) { xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc["loadXM"+"L"](xmlString); } return (xmlDoc && xmlDoc.documentElement && xmlDoc.documentElement.tagName != 'parsererror') ? xmlDoc : null; }; var sortArrayData = function() { var stripNum = /[\$,%]/g; var col=0,st,findSortKey,newDir = (ts.p.sortorder == "asc") ? 1 :-1; $.each(ts.p.colModel,function(i,v){ if(this.index == ts.p.sortname || this.name == ts.p.sortname){ col = ts.p.lastsort= i; st = this.sorttype; return false; } }); if (st == 'float') { findSortKey = function($cell) { var key = parseFloat($cell.text().replace(stripNum, '')); return isNaN(key) ? 0 : key; }; } else if (st=='int') { findSortKey = function($cell) { return IntNum($cell.text().replace(stripNum, '')); }; } else if(st == 'date') { findSortKey = function($cell) { var fd = ts.p.colModel[col].datefmt || "Y-m-d"; return parseDate(fd,$cell.text()).getTime(); }; } else { findSortKey = function($cell) { return $cell.text().toUpperCase(); }; } var rows=[]; $.each(ts.rows, function(index, row) { if (index > 0) { row.sortKey = findSortKey($(row).children('td').eq(col)); rows[index-1] = this; } }); if(ts.p.treeGrid) { $(ts).SortTree( newDir); } else { rows.sort(function(a, b) { if (a.sortKey < b.sortKey) {return -newDir;} if (a.sortKey > b.sortKey) {return newDir;} return 0; }); $.each(rows, function(index, row) { $('tbody',ts.grid.bDiv).append(row); row.sortKey = null; }); } if(isSafari || isOpera) {resizeFirstRow(ts.grid.bDiv,1);} if(ts.p.multiselect) { $("tbody tr:gt(0)", ts.grid.bDiv).removeClass("selected"); $("[@id^=jqg_]",ts.rows).attr("checked",false); $("#cb_jqg",ts.grid.hDiv).attr("checked",false); ts.p.selarrrow = []; } if( ts.p.altRows === true ) { $("tbody tr:gt(0)", ts.grid.bDiv).removeClass("alt"); $("tbody tr:odd", ts.grid.bDiv).addClass("alt"); } ts.grid.bDiv.scrollTop = 0; endReq(); }; var parseDate = function(format, date) { var tsp = {m : 1, d : 1, y : 1970, h : 0, i : 0, s : 0}; format = format.toLowerCase(); date = date.split(/[\\\/:_;.\s-]/); format = format.split(/[\\\/:_;.\s-]/); for(var i=0;i<format.length;i++){ tsp[format[i]] = IntNum(date[i],tsp[format[i]]); } tsp.m = parseInt(tsp.m,10)-1; var ty = tsp.y; if (ty >= 70 && ty <= 99) {tsp.y = 1900+tsp.y;} else if (ty >=0 && ty <=69) {tsp.y= 2000+tsp.y;} return new Date(tsp.y, tsp.m, tsp.d, tsp.h, tsp.i, tsp.s,0); }; var setPager = function (){ var inpt = "<img class='pgbuttons' src='"+ts.p.imgpath+"spacer.gif'"; var pginp = (ts.p.pginput===true) ? "<input class='selbox' type='text' size='3' maxlength='5' value='0'/>" : ""; if(ts.p.viewrecords===true) {pginp += "<span id='sp_1'></span>&#160;";} var pgl="", pgr=""; if(ts.p.pgbuttons===true) { pgl = inpt+" id='first'/>&#160;&#160;"+inpt+" id='prev'/>&#160;"; pgr = inpt+" id='next' />&#160;&#160;"+inpt+" id='last'/>"; } $(ts.p.pager).append(pgl+pginp+pgr); if(ts.p.rowList.length >0){ var str="<SELECT class='selbox'>"; for(var i=0;i<ts.p.rowList.length;i++){ str +="<OPTION value="+ts.p.rowList[i]+((ts.p.rowNum == ts.p.rowList[i])?' selected':'')+">"+ts.p.rowList[i]; } str +="</SELECT>"; $(ts.p.pager).append("&#160;"+str+"&#160;<span id='sp_2'></span>"); $(ts.p.pager).find("select").bind('change',function() { ts.p.rowNum = (this.value>0) ? this.value : ts.p.rowNum; if (typeof ts.p.onPaging =='function') {ts.p.onPaging('records');} populate(); ts.p.selrow = null; }); } else { $(ts.p.pager).append("&#160;<span id='sp_2'></span>");} if(ts.p.pgbuttons===true) { $(".pgbuttons",ts.p.pager).mouseover(function(e){ this.style.cursor= "pointer"; return false; }).mouseout(function(e) { this.style.cursor= "normal"; return false; }); $("#first, #prev, #next, #last",ts.p.pager).click( function(e) { var cp = IntNum(ts.p.page); var last = IntNum(ts.p.lastpage), selclick = false; var fp=true; var pp=true; var np=true; var lp=true; if(last ===0 || last===1) {fp=false;pp=false;np=false;lp=false; } else if( last>1 && cp >=1) { if( cp === 1) { fp=false; pp=false; } else if( cp>1 && cp <last){ } else if( cp===last){ np=false;lp=false; } } else if( last>1 && cp===0 ) { np=false;lp=false; cp=last-1;} if( this.id === 'first' && fp ) { ts.p.page=1; selclick=true;} if( this.id === 'prev' && pp) { ts.p.page=(cp-1); selclick=true;} if( this.id === 'next' && np) { ts.p.page=(cp+1); selclick=true;} if( this.id === 'last' && lp) { ts.p.page=last; selclick=true;} if(selclick) { if (typeof ts.p.onPaging =='function') {ts.p.onPaging(this.id);} populate(); ts.p.selrow = null; if(ts.p.multiselect) {ts.p.selarrrow =[];$('#cb_jqg',ts.grid.hDiv).attr("checked",false);} ts.p.savedRow = []; } e.stopPropagation(); return false; }); } if(ts.p.pginput===true) { $('input.selbox',ts.p.pager).keypress( function(e) { var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; if(key == 13) { ts.p.page = ($(this).val()>0) ? $(this).val():ts.p.page; if (typeof ts.p.onPaging =='function') {ts.p.onPaging( 'user');} populate(); ts.p.selrow = null; return false; } return this; }); } }; var sortData = function (index, idxcol,reload){ if(!reload) { if( ts.p.lastsort === idxcol ) { if( ts.p.sortorder === 'asc') { ts.p.sortorder = 'desc'; } else if(ts.p.sortorder === 'desc') { ts.p.sortorder='asc';} } else { ts.p.sortorder='asc';} ts.p.page = 1; } var imgs = (ts.p.sortorder==='asc') ? ts.p.sortascimg : ts.p.sortdescimg; imgs = "<img src='"+ts.p.imgpath+imgs+"'>"; var thd= $("thead:first",grid.hDiv).get(0); $("tr th div#jqgh_"+ts.p.colModel[ts.p.lastsort].name+" img",thd).remove(); $("tr th div#jqgh_"+ts.p.colModel[ts.p.lastsort].name,thd).parent().removeClass(ts.p.sortclass); $("tr th div#"+index,thd).append(imgs).parent().addClass(ts.p.sortclass); ts.p.lastsort = idxcol; index = index.substring(5); ts.p.sortname = ts.p.colModel[idxcol].index || index; var so = ts.p.sortorder; if(onSortCol) {onSortCol(index,idxcol,so);} if(ts.p.selrow && ts.p.datatype == "local" && !ts.p.multiselect){ $('#'+ts.p.selrow,grid.bDiv).removeClass("selected");} ts.p.selrow = null; if(ts.p.multiselect && ts.p.datatype !== "local"){ts.p.selarrrow =[]; $("#cb_jqg",ts.grid.hDiv).attr("checked",false);} ts.p.savedRow =[]; populate(); if(ts.p.sortname != index && idxcol) {ts.p.lastsort = idxcol;} }; var setColWidth = function () { var initwidth = 0; for(var l=0;l<ts.p.colModel.length;l++){ if(!ts.p.colModel[l].hidden){ initwidth += IntNum(ts.p.colModel[l].width); } } var tblwidth = ts.p.width ? ts.p.width : initwidth; for(l=0;l<ts.p.colModel.length;l++) { if(!ts.p.shrinkToFit){ ts.p.colModel[l].owidth = ts.p.colModel[l].width; } ts.p.colModel[l].width = Math.round(tblwidth/initwidth*ts.p.colModel[l].width); } }; var nextVisible= function(iCol) { var ret = iCol, j=iCol; for (var i = iCol+1;i<ts.p.colModel.length;i++){ if(ts.p.colModel[i].hidden !== true ) { j=i; break; } } return j-ret; }; this.p.id = this.id; if(this.p.treeGrid === true) { this.p.subGrid = false; this.p.altRows =false; this.p.pgbuttons = false; this.p.pginput = false; this.p.multiselect = false; this.p.rowList = []; this.p.treedatatype = this.p.datatype; $.each(this.p.treeReader,function(i,n){ if(n){ ts.p.colNames.push(n); ts.p.colModel.push({name:n,width:1,hidden:true,sortable:false,resizable:false,hidedlg:true,editable:true,search:false}); } }); } if(this.p.subGrid) { this.p.colNames.unshift(""); this.p.colModel.unshift({name:'subgrid',width:25,sortable: false,resizable:false,hidedlg:true,search:false}); } if(this.p.multiselect) { this.p.colNames.unshift("<input id='cb_jqg' class='cbox' type='checkbox'/>"); this.p.colModel.unshift({name:'cb',width:27,sortable:false,resizable:false,hidedlg:true,search:false}); } var xReader = { root: "rows", row: "row", page: "rows>page", total: "rows>total", records : "rows>records", repeatitems: true, cell: "cell", id: "[id]", userdata: "userdata", subgrid: {root:"rows", row: "row", repeatitems: true, cell:"cell"} }; var jReader = { root: "rows", page: "page", total: "total", records: "records", repeatitems: true, cell: "cell", id: "id", userdata: "userdata", subgrid: {root:"rows", repeatitems: true, cell:"cell"} }; ts.p.xmlReader = $.extend(xReader, ts.p.xmlReader); ts.p.jsonReader = $.extend(jReader, ts.p.jsonReader); $.each(ts.p.colModel, function(i){if(!this.width) {this.width=150;}}); if (ts.p.width) {setColWidth();} var thead = document.createElement("thead"); var trow = document.createElement("tr"); thead.appendChild(trow); var i=0, th, idn, thdiv; ts.p.keyIndex=false; for (var i=0; i<ts.p.colModel.length;i++) { if (ts.p.colModel[i].key===true) { ts.p.keyIndex = i; break; } } if(ts.p.shrinkToFit===true && ts.p.forceFit===true) { for (i=ts.p.colModel.length-1;i>=0;i--){ if(!ts.p.colModel[i].hidden) { ts.p.colModel[i].resizable=false; break; } } } for(i=0;i<this.p.colNames.length;i++){ th = document.createElement("th"); idn = ts.p.colModel[i].name; thdiv = document.createElement("div"); $(thdiv).html(ts.p.colNames[i]+"&#160;"); if (idn == ts.p.sortname) { var imgs = (ts.p.sortorder==='asc') ? ts.p.sortascimg : ts.p.sortdescimg; imgs = "<img src='"+ts.p.imgpath+imgs+"'>"; $(thdiv).append(imgs); ts.p.lastsort = i; $(th).addClass(ts.p.sortclass); } thdiv.id = "jqgh_"+idn; th.appendChild(thdiv); trow.appendChild(th); } if(this.p.multiselect) { var onSA = true; if(typeof ts.p.onSelectAll !== 'function') {onSA=false;} $('#cb_jqg',trow).click(function(){ var chk; if (this.checked) { $("[@id^=jqg_]",ts.rows).attr("checked",true); $(ts.rows).slice(1).each(function(i) { if(!$(this).hasClass("subgrid")){ $(this).addClass("selected"); ts.p.selarrrow[i]= ts.p.selrow = this.id; } }); chk=true; } else { $("[@id^=jqg_]",ts.rows).attr("checked",false); $(ts.rows).slice(1).each(function(i) { if(!$(this).hasClass("subgrid")){ $(this).removeClass("selected"); } }); ts.p.selarrrow = []; ts.p.selrow = null; chk=false; } if(onSA) {ts.p.onSelectAll(ts.p.selarrrow,chk);} }); } this.appendChild(thead); thead = $("thead:first",ts).get(0); var w, res, sort; $("tr:first th",thead).each(function ( j ) { w = ts.p.colModel[j].width; if(typeof ts.p.colModel[j].resizable === 'undefined') {ts.p.colModel[j].resizable = true;} res = document.createElement("span"); $(res).html("&#160;"); if(ts.p.colModel[j].resizable){ $(this).addClass(ts.p.resizeclass); $(res).mousedown(function (e) { if(ts.p.forceFit===true) {ts.p.nv= nextVisible(j);} grid.dragStart( j ,e.clientX); e.preventDefault(); return false; }); } else {$(res).css("cursor","default");} $(this).css("width",w+"px").prepend(res); if( ts.p.colModel[j].hidden) {$(this).css("display","none");} grid.headers[j] = { width: w, el: this }; sort = ts.p.colModel[j].sortable; if( typeof sort !== 'boolean') {sort = true;} if(sort) { $("div",this).css("cursor","pointer") .click(function(){sortData(this.id,j);return false;}); } }); var isMSIE = $.browser.msie ? true:false; var isMoz = $.browser.mozilla ? true:false; var isOpera = $.browser.opera ? true:false; var isSafari = $.browser.safari ? true : false; var tbody = document.createElement("tbody"); trow = document.createElement("tr"); trow.id = "_empty"; tbody.appendChild(trow); var td, ptr; for(i=0;i<ts.p.colNames.length;i++){ td = document.createElement("td"); trow.appendChild(td); } this.appendChild(tbody); var gw=0,hdc=0; $("tbody tr:first td",ts).each(function(ii) { w = ts.p.colModel[ii].width; $(this).css({width:w+"px",height:"0px"}); w += IntNum($(this).css("padding-left")) + IntNum($(this).css("padding-right"))+ IntNum($(this).css("border-left-width"))+ IntNum($(this).css("border-right-width")); if( ts.p.colModel[ii].hidden===true) { $(this).css("display","none"); hdc += w; } grid.cols[ii] = this; gw += w; }); if(isMoz) {$(trow).css({visibility:"collapse"});} else if( isSafari || isOpera ) {$(trow).css({display:"none"});} grid.width = IntNum(gw)-IntNum(hdc); ts.p._width = grid.width; grid.hTable = document.createElement("table"); grid.hTable.appendChild(thead); $(grid.hTable).addClass("scroll") .attr({cellSpacing:"0",cellPadding:"0",border:"0"}) .css({width:grid.width+"px"}); grid.hDiv = document.createElement("div"); var hg = (ts.p.caption && ts.p.hiddengrid===true) ? true : false; $(grid.hDiv) .css({ width: grid.width+"px", overflow: "hidden"}) .prepend('<div class="loading">'+ts.p.loadtext+'</div>') .append(grid.hTable) .bind("selectstart", function () { return false; }); if(hg) {$(grid.hDiv).hide(); ts.p.gridstate = 'hidden'} if(ts.p.pager){ if(typeof ts.p.pager == "string") {ts.p.pager = "#"+ts.p.pager;} if( $(ts.p.pager).hasClass("scroll")) { $(ts.p.pager).css({ width: grid.width+"px", overflow: "hidden"}).show(); ts.p._height= parseInt($(ts.p.pager).height(),10); if(hg) {$(ts.p.pager).hide();}} setPager(); } if( ts.p.cellEdit === false) { $(ts).mouseover(function(e) { td = (e.target || e.srcElement); ptr = $(td,ts.rows).parents("tr:first"); if($(ptr).hasClass("jqgrow")) { $(ptr).addClass("over"); if(!$(td).hasClass("editable")){ td.title = $(td).text(); } } return false; }).mouseout(function(e) { td = (e.target || e.srcElement); ptr = $(td,ts.rows).parents("tr:first"); $(ptr).removeClass("over"); if(!$(td).hasClass("editable")){ td.title = ""; } return false; }); } var ri,ci; $(ts).before(grid.hDiv).css("width", grid.width+"px").click(function(e) { td = (e.target || e.srcElement); var scb = $(td).hasClass("cbox"); ptr = $(td,ts.rows).parent("tr"); if($(ptr).length === 0 ){ ptr = $(td,ts.rows).parents("tr:first"); td = $(td).parents("td:first")[0]; } if(ts.p.cellEdit === true) { ri = ptr[0].rowIndex; ci = td.cellIndex; try {$(ts).editCell(ri,ci,true,true);} catch (e) {} } else if ( !ts.p.multikey ) { $(ts).setSelection(false,ptr); if(onSC) { ri = ptr[0].id; ci = td.cellIndex; onSC(ri,ci,$(td).html()); } } else { if(e[ts.p.multikey]) { $(ts).setSelection(false,ptr); } else if(ts.p.multiselect) { if(scb) { scb = $("[@id^=jqg_]",ptr).attr("checked"); $("[@id^=jqg_]",ptr).attr("checked",!scb); } } } e.stopPropagation(); }).bind('reloadGrid', function(e) { if(!ts.p.treeGrid) {ts.p.selrow=null;} if(ts.p.multiselect) {ts.p.selarrrow =[];$('#cb_jqg',ts.grid.hDiv).attr("checked",false);} if(ts.p.cellEdit) {ts.p.savedRow = []; } populate(); }); if( ondblClickRow ) { $(this).dblclick(function(e) { td = (e.target || e.srcElement); ptr = $(td,ts.rows).parent("tr"); if($(ptr).length === 0 ){ ptr = $(td,ts.rows).parents("tr:first"); } ts.p.ondblClickRow($(ptr).attr("id")); return false; }); } if (onRightClickRow) { $(this).bind('contextmenu', function(e) { td = (e.target || e.srcElement); ptr = $(td,ts).parents("tr:first"); if($(ptr).length === 0 ){ ptr = $(td,ts.rows).parents("tr:first"); } $(ts).setSelection(false,ptr); ts.p.onRightClickRow($(ptr).attr("id")); return false; }); } grid.bDiv = document.createElement("div"); var ofl2 = (isNaN(ts.p.height) && isMoz && (ts.p.height.indexOf("%")!=-1 || ts.p.height=="auto")) ? "hidden" : "auto"; $(grid.bDiv) .scroll(function (e) {grid.scrollGrid();}) .css({ height: ts.p.height+(isNaN(ts.p.height)?"":"px"), padding: "0px", margin: "0px", overflow: ofl2,width: (grid.width)+"px"} ).css("overflow-x","hidden") .append(this); $("table:first",grid.bDiv).css({width:grid.width+"px",marginRight:"20px"}); if( isMSIE ) { if( $("tbody",this).size() === 2 ) { $("tbody:first",this).remove();} if( ts.p.multikey) {$(grid.bDiv).bind("selectstart",function(){return false;});} if(ts.p.treeGrid) {$(grid.bDiv).css("position","relative");} } else { if( ts.p.multikey) {$(grid.bDiv).bind("mousedown",function(){return false;});} } if(hg) {$(grid.bDiv).hide();} grid.cDiv = document.createElement("div"); $(grid.cDiv).append("<table class='Header' cellspacing='0' cellpadding='0' border='0'><tr><td class='HeaderLeft'><img src='"+ts.p.imgpath+"spacer.gif' border='0' /></td><th>"+ts.p.caption+"</th>"+ ((ts.p.hidegrid===true) ? "<td class='HeaderButton'><img src='"+ts.p.imgpath+"up.gif' border='0'/></td>" :"") +"<td class='HeaderRight'><img src='"+ts.p.imgpath+"spacer.gif' border='0' /></td></tr></table>").addClass("GridHeader"); $(grid.cDiv).insertBefore(grid.hDiv); if( ts.p.toolbar[0] ) { grid.uDiv = document.createElement("div"); if(ts.p.toolbar[1] == "top") {$(grid.uDiv).insertBefore(grid.hDiv);} else {$(grid.uDiv).insertAfter(grid.hDiv);} $(grid.uDiv,ts).width(grid.width).addClass("userdata").attr("id","t_"+this.id); ts.p._height += parseInt($(grid.uDiv,ts).height(),10); if(hg) {$(grid.uDiv,ts).hide();} } if(ts.p.caption) { $(grid.cDiv,ts).width(grid.width).css("text-align","center").show("fast"); ts.p._height += parseInt($(grid.cDiv,ts).height(),10); var tdt = ts.p.datatype; if(ts.p.hidegrid===true) { $(".HeaderButton",grid.cDiv).toggle( function(){ if(ts.p.pager) {$(ts.p.pager).fadeOut("slow");} if(ts.p.toolbar[0]) {$(grid.uDiv,ts).fadeOut("slow");} $(grid.bDiv,ts).fadeOut("slow"); $(grid.hDiv,ts).fadeOut("slow"); $("img",this).attr("src",ts.p.imgpath+"down.gif"); ts.p.gridstate = 'hidden'; if(onHdCl) {if(!hg) {ts.p.onHeaderClick(ts.p.gridstate);}} }, function() { $(grid.hDiv ,ts).fadeIn("slow"); $(grid.bDiv,ts).fadeIn("slow"); if(ts.p.pager) {$(ts.p.pager).fadeIn("slow");} if(ts.p.toolbar[0]) {$(grid.uDiv).fadeIn("slow");} $("img",this).attr("src",ts.p.imgpath+"up.gif"); if(hg) {ts.p.datatype = tdt;populate();hg=false;} ts.p.gridstate = 'visible'; if(onHdCl) {ts.p.onHeaderClick(ts.p.gridstate)} } ); if(hg) { $(".HeaderButton",grid.cDiv).trigger("click"); ts.p.datatype="local";} } } ts.p._height += parseInt($(grid.hDiv,ts).height(),10); $(grid.hDiv).mousemove(function (e) {grid.dragMove(e.clientX); return false;}).after(grid.bDiv); $(document).mouseup(function (e) { if(grid.resizing) { grid.dragEnd(); if(grid.newWidth && ts.p.forceFit===false){ var gwdt = (grid.width <= ts.p._width) ? grid.width : ts.p._width; var overfl = (grid.width <= ts.p._width) ? "hidden" : "auto"; if(ts.p.pager && $(ts.p.pager).hasClass("scroll") ) { $(ts.p.pager).width(gwdt); } if(ts.p.caption) {$(grid.cDiv).width(gwdt);} if(ts.p.toolbar[0]) {$(grid.uDiv).width(gwdt);} $(grid.bDiv).width(gwdt).css("overflow-x",overfl); $(grid.hDiv).width(gwdt); } } return false; }); ts.formatCol = function(a,b) {formatCol(a,b);}; ts.sortData = function(a,b,c){sortData(a,b,c);}; ts.updatepager = function(){updatepager();}; this.grid = grid; ts.addXmlData = function(d) {addXmlData(d,ts.grid.bDiv);}; ts.addJSONData = function(d) {addJSONData(d,ts.grid.bDiv);}; populate(); if (!ts.p.shrinkToFit) { ts.p.forceFit = false; $("tr:first th", thead).each(function(j){ var w = ts.p.colModel[j].owidth; var diff = w - ts.p.colModel[j].width; if (diff > 0 && !ts.p.colModel[j].hidden) { grid.headers[j].width = w; $(this).add(grid.cols[j]).width(w); $('table:first',grid.bDiv).add(grid.hTable).width(ts.grid.width); ts.grid.width += diff; grid.hDiv.scrollLeft = grid.bDiv.scrollLeft; } }); ofl2 = (grid.width <= ts.p._width) ? "hidden" : "auto"; $(grid.bDiv).css({"overflow-x":ofl2}); } $(window).unload(function () { $(this).unbind("*"); this.grid = null; this.p = null; }); }); }; })(jQuery); /** * jqGrid common function * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ // Modal functions var showModal = function(h) { h.w.show(); }; var closeModal = function(h) { h.w.hide(); if(h.o) { h.o.remove(); } }; function createModal(aIDs, content, p, insertSelector, posSelector, appendsel) { var clicon = p.imgpath ? p.imgpath+p.closeicon : p.closeicon; var mw = document.createElement('div'); jQuery(mw).addClass("modalwin").attr("id",aIDs.themodal); var mh = jQuery('<div id="'+aIDs.modalhead+'"><table width="100%"><tbody><tr><td class="modaltext">'+p.caption+'</td> <td align="right"><a href="javascript:void(0);" class="jqmClose">'+(clicon!=''?'<img src="' + clicon + '" border="0"/>':'X') + '</a></td></tr></tbody></table> </div>').addClass("modalhead"); var mc = document.createElement('div'); jQuery(mc).addClass("modalcontent").attr("id",aIDs.modalcontent); jQuery(mc).append(content); mw.appendChild(mc); var loading = document.createElement("div"); jQuery(loading).addClass("loading").html(p.processData||""); jQuery(mw).prepend(loading); jQuery(mw).prepend(mh); jQuery(mw).addClass("jqmWindow"); if (p.drag) { jQuery(mw).append("<img class='jqResize' src='"+p.imgpath+"resize.gif'/>"); } if(appendsel===true) { jQuery('body').append(mw); } //append as first child in body -for alert dialog else { jQuery(mw).insertBefore(insertSelector); } if(p.left ==0 && p.top==0) { var pos = []; pos = findPos(posSelector) ; p.left = pos[0] + 4; p.top = pos[1] + 4; } if (p.width == 0 || !p.width) {p.width = 300;} if(p.height==0 || !p.width) {p.height =200;} if(!p.zIndex) {p.zIndex = 950;} jQuery(mw).css({top: p.top+"px",left: p.left+"px",width: p.width+"px",height: p.height+"px", zIndex:p.zIndex}); return false; }; function viewModal(selector,o){ o = jQuery.extend({ toTop: true, overlay: 10, modal: false, drag: true, onShow: showModal, onHide: closeModal }, o || {}); jQuery(selector).jqm(o).jqmShow(); return false; }; function DnRModal(modwin,handler){ jQuery(handler).css('cursor','move'); jQuery(modwin).jqDrag(handler).jqResize(".jqResize"); return false; }; function info_dialog(caption, content,c_b, pathimg) { var cnt = "<div id='info_id'>"; cnt += "<div align='center'><br />"+content+"<br /><br />"; cnt += "<input type='button' size='10' id='closedialog' class='jqmClose EditButton' value='"+c_b+"' />"; cnt += "</div></div>"; createModal({ themodal:'info_dialog', modalhead:'info_head', modalcontent:'info_content'}, cnt, { width:290, height:120,drag: false, caption:"<b>"+caption+"</b>", imgpath: pathimg, closeicon: 'ico-close.gif', left:250, top:170 }, '','',true ); viewModal("#info_dialog",{ onShow: function(h) { h.w.show(); }, onHide: function(h) { h.w.hide().remove(); if(h.o) { h.o.remove(); } }, modal :true }); }; //Helper functions function findPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) { do { curleft += obj.offsetLeft; curtop += obj.offsetTop; } while (obj = obj.offsetParent); //do not change obj == obj.offsetParent } return [curleft,curtop]; }; function isArray(obj) { if (obj.constructor.toString().indexOf("Array") == -1) { return false; } else { return true; } }; // Form Functions function createEl(eltype,options,vl,elm) { var elem = ""; switch (eltype) { case "textarea" : elem = document.createElement("textarea"); if(!options.cols && elm) {jQuery(elem).css("width","99%");} jQuery(elem).attr(options); jQuery(elem).val(vl); break; case "checkbox" : //what code for simple checkbox elem = document.createElement("input"); elem.type = "checkbox"; jQuery(elem).attr({id:options.id,name:options.name}); if( !options.value) { if(vl.toLowerCase() =='on') { elem.checked=true; elem.defaultChecked=true; elem.value = vl; } else { elem.value = "on"; } jQuery(elem).attr("offval","off"); } else { var cbval = options.value.split(":"); if(vl == cbval[0]) { elem.checked=true; elem.defaultChecked=true; } elem.value = cbval[0]; jQuery(elem).attr("offval",cbval[1]); } break; case "select" : var so = options.value.split(";"),sv, ov; elem = document.createElement("select"); var msl = options.multiple === true ? true : false; jQuery(elem).attr({id:options.id,name:options.name,size:Math.min(options.size,so.length), multiple:msl }); for(var i=0; i<so.length;i++){ sv = so[i].split(":"); ov = document.createElement("option"); ov.value = sv[0]; ov.innerHTML = sv[1]; if (!msl && sv[1]==vl) ov.selected ="selected"; if (msl && jQuery.inArray(sv[1],vl.split(","))>-1) ov.selected ="selected"; elem.appendChild(ov); } break; case "text" : elem = document.createElement("input"); elem.type = "text"; elem.value = vl; if(!options.size && elm) { jQuery(elem).css("width","99%"); } jQuery(elem).attr(options); break; case "password" : elem = document.createElement("input"); elem.type = "password"; elem.value = vl; if(!options.size && elm) { jQuery(elem).css("width","99%"); } jQuery(elem).attr(options); break; case "image" : elem = document.createElement("input"); elem.type = "image"; jQuery(elem).attr(options); break; } return elem; }; function checkValues(val, valref,g) { if(valref >=0) { var edtrul = g.p.colModel[valref].editrules; } if(edtrul) { if(edtrul.required == true) { if( val.match(/^s+$/) || val == "" ) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.required,""]; } if(edtrul.number == true) { if(isNaN(val)) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.number,""]; } if(edtrul.minValue && !isNaN(edtrul.minValue)) { if (parseFloat(val) < parseFloat(edtrul.minValue) ) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.minValue+" "+edtrul.minValue,""]; } if(edtrul.maxValue && !isNaN(edtrul.maxValue)) { if (parseFloat(val) > parseFloat(edtrul.maxValue) ) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.maxValue+" "+edtrul.maxValue,""]; } if(edtrul.email == true) { // taken from jquery Validate plugin var filter = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i; if(!filter.test(val)) {return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.email,""];} } if(edtrul.integer == true) { if(isNaN(val)) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.integer,""]; if ((val < 0) || (val % 1 != 0) || (val.indexOf('.') != -1)) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.integer,""]; } } return [true,"",""]; }; ;(function($){ /* ** * jqGrid extension for cellediting Grid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ /** * all events and options here are aded anonynous and not in the base grid * since the array is to big. Here is the order of execution. * From this point we use jQuery isFunction * formatCell * beforeEditCell, * onSelectCell (used only for noneditable cels) * afterEditCell, * beforeSaveCell, (called before validation of values if any) * beforeSubmitCell (if cellsubmit remote (ajax)) * afterSubmitCell(if cellsubmit remote (ajax)), * afterSaveCell, * errorCell, * Options * cellsubmit (remote,clientArray) (added in grid options) * cellurl * */ $.fn.extend({ editCell : function (iRow,iCol, ed, fg){ return this.each(function (){ var $t = this, nm, tmp,cc; if (!$t.grid || $t.p.cellEdit !== true) {return;} var currentFocus = null; // I HATE IE if ($.browser.msie && $.browser.version <=6 && ed===true && fg===true) { iCol = getAbsoluteIndex($t.rows[iRow],iCol); } // select the row that can be used for other methods $t.p.selrow = $t.rows[iRow].id; if (!$t.p.knv) {$($t).GridNav();} // check to see if we have already edited cell if ($t.p.savedRow.length>0) { // prevent second click on that field and enable selects if (ed===true ) { if(iRow == $t.p.iRow && iCol == $t.p.iCol){ return; } } // if so check to see if the content is changed var vl = $("td:eq("+$t.p.savedRow[0].ic+")>#"+$t.p.savedRow[0].id+"_"+$t.p.savedRow[0].name,$t.rows[$t.p.savedRow[0].id]).val(); if ($t.p.savedRow[0].v != vl) { // save it $($t).saveCell($t.p.savedRow[0].id,$t.p.savedRow[0].ic) } else { // restore it $($t).restoreCell($t.p.savedRow[0].id,$t.p.savedRow[0].ic); } } else { window.setTimeout(function () { $("#"+$t.p.knv).attr("tabindex","-1").focus();},0); } nm = $t.p.colModel[iCol].name; if (nm=='subgrid') {return;} if ($t.p.colModel[iCol].editable===true && ed===true) { cc = $("td:eq("+iCol+")",$t.rows[iRow]); if(parseInt($t.p.iCol)>=0 && parseInt($t.p.iRow)>=0) { $("td:eq("+$t.p.iCol+")",$t.rows[$t.p.iRow]).removeClass("edit-cell"); $($t.rows[$t.p.iRow]).removeClass("selected-row"); } $(cc).addClass("edit-cell"); $($t.rows[iRow]).addClass("selected-row"); tmp = $(cc).html().replace(/\&nbsp\;/ig,''); var opt = $.extend($t.p.colModel[iCol].editoptions || {} ,{id:iRow+"_"+nm,name:nm}); if (!$t.p.colModel[iCol].edittype) {$t.p.colModel[iCol].edittype = "text";} $t.p.savedRow.push({id:iRow,ic:iCol,name:nm,v:tmp}); if($.isFunction($t.p.formatCell)) { var tmp2 = $t.p.formatCell($t.rows[iRow].id,nm,tmp,iRow,iCol); if(tmp2) {tmp = tmp2;} } var elc = createEl($t.p.colModel[iCol].edittype,opt,tmp,cc); if ($.isFunction($t.p.beforeEditCell)) { $t.p.beforeEditCell($t.rows[iRow].id,nm,tmp,iRow,iCol); } $(cc).html("").append(elc); window.setTimeout(function () { $(elc).focus();},0); $("input, select, textarea",cc).bind("keydown",function(e) { if (e.keyCode === 27) {$($t).restoreCell(iRow,iCol);} //ESC if (e.keyCode === 13) {$($t).saveCell(iRow,iCol);}//Enter if (e.keyCode == 9) {$($t).nextCell(iRow,iCol);} //Tab e.stopPropagation(); }); if ($.isFunction($t.p.afterEditCell)) { $t.p.afterEditCell($t.rows[iRow].id,nm,tmp,iRow,iCol); } } else { if (parseInt($t.p.iCol)>=0 && parseInt($t.p.iRow)>=0) { $("td:eq("+$t.p.iCol+")",$t.rows[$t.p.iRow]).removeClass("edit-cell"); $($t.rows[$t.p.iRow]).removeClass("selected-row"); } $("td:eq("+iCol+")",$t.rows[iRow]).addClass("edit-cell"); $($t.rows[iRow]).addClass("selected-row"); if ($.isFunction($t.p.onSelectCell)) { tmp = $("td:eq("+iCol+")",$t.rows[iRow]).html().replace(/\&nbsp\;/ig,''); $t.p.onSelectCell($t.rows[iRow].id,nm,tmp,iRow,iCol); } } $t.p.iCol = iCol; $t.p.iRow = iRow; // IE 6 bug function getAbsoluteIndex(t,relIndex) { var countnotvisible=0; var countvisible=0; for (i=0;i<t.cells.length;i++) { var cell=t.cells(i); if (cell.style.display=='none') countnotvisible++; else countvisible++; if (countvisible>relIndex) return i; } return i; } }); }, saveCell : function (iRow, iCol){ return this.each(function(){ var $t= this, nm, fr=null; if (!$t.grid || $t.p.cellEdit !== true) {return;} for( var k=0;k<$t.p.savedRow.length;k++) { if ( $t.p.savedRow[k].id===iRow) {fr = k; break;} }; if(fr != null) { var cc = $("td:eq("+iCol+")",$t.rows[iRow]); nm = $t.p.colModel[iCol].name; var v,v2; switch ($t.p.colModel[iCol].edittype) { case "select": v = $("#"+iRow+"_"+nm+">option:selected",$t.rows[iRow]).val(); v2 = $("#"+iRow+"_"+nm+">option:selected",$t.rows[iRow]).text(); break; case "checkbox": var cbv = $t.p.colModel[iCol].editoptions.value.split(":") || ["Yes","No"]; v = $("#"+iRow+"_"+nm,$t.rows[iRow]).attr("checked") ? cbv[0] : cbv[1]; v2=v; break; case "password": case "text": case "textarea": v = $("#"+iRow+"_"+nm,$t.rows[iRow]).val(); v2=v; break; } // The common approach is if nothing changed do not do anything if (v2 != $t.p.savedRow[fr].v){ if ($.isFunction($t.p.beforeSaveCell)) { var vv = $t.p.beforeSaveCell($t.rows[iRow].id,nm, v, iRow,iCol); if (vv) {v = vv;} } var cv = checkValues(v,iCol,$t); if(cv[0] === true) { var addpost = {}; if ($.isFunction($t.p.beforeSubmitCell)) { addpost = $t.p.beforeSubmitCell($t.rows[iRow].id,nm, v, iRow,iCol); if (!addpost) {addpost={};} } if ($t.p.cellsubmit == 'remote') { if ($t.p.cellurl) { var postdata = {}; postdata[nm] = v; postdata["id"] = $t.rows[iRow].id; postdata = $.extend(addpost,postdata); $.ajax({ url: $t.p.cellurl, data :postdata, type: "POST", complete: function (result, stat) { if (stat == 'success') { if ($.isFunction($t.p.afterSubmitCell)) { var ret = $t.p.afterSubmitCell(result,postdata.id,nm,v,iRow,iCol); if(ret && ret[0] === true) { $(cc).empty().html(v2 || "&nbsp;"); $(cc).addClass("dirty-cell"); $($t.rows[iRow]).addClass("edited"); if ($.isFunction($t.p.afterSaveCell)) { $t.p.afterSaveCell($t.rows[iRow].id,nm, v, iRow,iCol); } $t.p.savedRow.splice(fr,1); } else { info_dialog($.jgrid.errors.errcap,ret[1],$.jgrid.edit.bClose, $t.p.imgpath); $($t).restoreCell(iRow,iCol); } } else { $(cc).empty().html(v2 || "&nbsp;"); $(cc).addClass("dirty-cell"); $($t.rows[iRow]).addClass("edited"); if ($.isFunction($t.p.afterSaveCell)) { $t.p.afterSaveCell($t.rows[iRow].id,nm, v, iRow,iCol); } $t.p.savedRow.splice(fr,1); } } }, error:function(res,stat){ if ($.isFunction($t.p.errorCell)) { $t.p.errorCell(res,stat); } else { info_dialog($.jgrid.errors.errcap,res.status+" : "+res.statusText+"<br/>"+stat,$.jgrid.edit.bClose, $t.p.imgpath); $($t).restoreCell(iRow,iCol); } } }); } else { try { info_dialog($.jgrid.errors.errcap,$.jgrid.errors.nourl,$.jgrid.edit.bClose, $t.p.imgpath); $($t).restoreCell(iRow,iCol); } catch (e) {} } } if ($t.p.cellsubmit == 'clientArray') { $(cc).empty().html(v2 || "&nbsp;"); $(cc).addClass("dirty-cell"); $($t.rows[iRow]).addClass("edited"); if ($.isFunction($t.p.afterSaveCell)) { $t.p.afterSaveCell($t.rows[iRow].id,nm, v, iRow,iCol); } $t.p.savedRow.splice(fr,1); } } else { try { window.setTimeout(function(){info_dialog($.jgrid.errors.errcap,v+" "+cv[1],$.jgrid.edit.bClose, $t.p.imgpath)},100); $($t).restoreCell(iRow,iCol); } catch (e) {} } } else { $($t).restoreCell(iRow,iCol); } } if ($.browser.opera) { $("#"+$t.p.knv).attr("tabindex","-1").focus(); } else { window.setTimeout(function () { $("#"+$t.p.knv).attr("tabindex","-1").focus();},0); } }); }, nextCell : function (iRow,iCol) { return this.each(function (){ var $t = this, nCol=false, tmp; if (!$t.grid || $t.p.cellEdit !== true) {return;} // try to find next editable cell for (var i=iCol+1; i<$t.p.colModel.length; i++) { if ( $t.p.colModel[i].editable ===true) { nCol = i; break; } } if(nCol !== false) { $($t).saveCell(iRow,iCol); $($t).editCell(iRow,nCol,true); } else { if ($t.p.savedRow.length >0) { $($t).saveCell(iRow,iCol); } } }); }, restoreCell : function(iRow, iCol) { return this.each(function(){ var $t= this, nm, fr=null; if (!$t.grid || $t.p.cellEdit !== true ) {return;} for( var k=0;k<$t.p.savedRow.length;k++) { if ( $t.p.savedRow[k].id===iRow) {fr = k; break;} } if(fr != null) { var cc = $("td:eq("+iCol+")",$t.rows[iRow]); if($.isFunction($.fn['datepicker'])) { try { $.datepicker('hide'); } catch (e) { try { $.datepicker.hideDatepicker(); } catch (e) {} } } $(":input",cc).unbind(); nm = $t.p.colModel[iCol].name; $(cc).empty() .html($t.p.savedRow[fr].v || "&nbsp;"); //$t.p.savedRow.splice(fr,1); $t.p.savedRow = []; } window.setTimeout(function () { $("#"+$t.p.knv).attr("tabindex","-1").focus();},0); }); }, GridNav : function() { return this.each(function () { var $t = this; if (!$t.grid || $t.p.cellEdit !== true ) {return;} // trick to process keydown on non input elements $t.p.knv = $("table:first",$t.grid.bDiv).attr("id") + "_kn"; var selection = $("<span style='width:0px;height:0px;background-color:black;' tabindex='0'><span tabindex='-1' style='width:0px;height:0px;background-color:grey' id='"+$t.p.knv+"'></span></span>"); $(selection).insertBefore($t.grid.cDiv); $("#"+$t.p.knv).focus(); $("#"+$t.p.knv).keydown(function (e){ switch (e.keyCode) { case 38: if ($t.p.iRow-1 >=1 ) { scrollGrid($t.p.iRow-1,$t.p.iCol,'vu'); $($t).editCell($t.p.iRow-1,$t.p.iCol,false); } break; case 40 : if ($t.p.iRow+1 <= $t.rows.length-1) { scrollGrid($t.p.iRow+1,$t.p.iCol,'vd'); $($t).editCell($t.p.iRow+1,$t.p.iCol,false); } break; case 37 : if ($t.p.iCol -1 >= 0) { var i = findNextVisible($t.p.iCol-1,'lft'); scrollGrid($t.p.iRow, i,'h'); $($t).editCell($t.p.iRow, i,false); } break; case 39 : if ($t.p.iCol +1 <= $t.p.colModel.length-1) { var i = findNextVisible($t.p.iCol+1,'rgt'); scrollGrid($t.p.iRow,i,'h'); $($t).editCell($t.p.iRow,i,false); } break; case 13: if (parseInt($t.p.iCol,10)>=0 && parseInt($t.p.iRow,10)>=0) { $($t).editCell($t.p.iRow,$t.p.iCol,true); } break; } return false; }); function scrollGrid(iR, iC, tp){ if (tp.substr(0,1)=='v') { var ch = $($t.grid.bDiv)[0].clientHeight; var st = $($t.grid.bDiv)[0].scrollTop; var nROT = $t.rows[iR].offsetTop+$t.rows[iR].clientHeight; var pROT = $t.rows[iR].offsetTop; if(tp == 'vd') { if(nROT >= ch) { $($t.grid.bDiv)[0].scrollTop = $($t.grid.bDiv)[0].scrollTop + $t.rows[iR].clientHeight; } } if(tp == 'vu'){ if (pROT < st) { $($t.grid.bDiv)[0].scrollTop = $($t.grid.bDiv)[0].scrollTop - $t.rows[iR].clientHeight; } } } if(tp=='h') { var cw = $($t.grid.bDiv)[0].clientWidth; var sl = $($t.grid.bDiv)[0].scrollLeft; var nCOL = $t.rows[iR].cells[iC].offsetLeft+$t.rows[iR].cells[iC].clientWidth; var pCOL = $t.rows[iR].cells[iC].offsetLeft; if(nCOL >= cw+parseInt(sl)) { $($t.grid.bDiv)[0].scrollLeft = $($t.grid.bDiv)[0].scrollLeft + $t.rows[iR].cells[iC].clientWidth; } else if (pCOL < sl) { $($t.grid.bDiv)[0].scrollLeft = $($t.grid.bDiv)[0].scrollLeft - $t.rows[iR].cells[iC].clientWidth; } } }; function findNextVisible(iC,act){ var ind; if(act == 'lft') { ind = iC+1; for (var i=iC;i>=0;i--){ if ($t.p.colModel[i].hidden !== true) { ind = i; break; } } } if(act == 'rgt') { ind = iC-1; for (var i=iC; i<$t.p.colModel.length;i++){ if ($t.p.colModel[i].hidden !== true) { ind = i; break; } } } return ind; }; }); }, getChangedCells : function (mthd) { var ret=[]; if (!mthd) {mthd='all';} this.each(function(){ var $t= this; if (!$t.grid || $t.p.cellEdit !== true ) {return;} $($t.rows).slice(1).each(function(j){ var res = {}; if ($(this).hasClass("edited")) { $('td',this).each( function(i) { nm = $t.p.colModel[i].name; if ( nm !== 'cb' && nm !== 'subgrid') { if (mthd=='dirty') { if ($(this).hasClass('dirty-cell')) { res[nm] = $(this).html().replace(/\&nbsp\;/ig,''); } } else { res[nm] = $(this).html().replace(/\&nbsp\;/ig,''); } } }); res["id"] = this.id; ret.push(res); } }) }); return ret; } /// end cell editing }); })(jQuery); ;(function($){ /** * jqGrid extension for form editing Grid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ var rp_ge = null; $.fn.extend({ searchGrid : function ( p ) { p = $.extend({ top : 0, left: 0, width: 360, height: 80, modal: false, drag: true, closeicon: 'ico-close.gif', dirty: false, sField:'searchField', sValue:'searchString', sOper: 'searchOper', processData: "", checkInput :false, beforeShowSearch: null, afterShowSearch : null, onInitializeSearch: null, // translation // if you want to change or remove the order change it in sopt // ['bw','eq','ne','lt','le','gt','ge','ew','cn'] sopt: null }, $.jgrid.search, p || {}); return this.each(function(){ var $t = this; if( !$t.grid ) { return; } if(!p.imgpath) { p.imgpath= $t.p.imgpath; } var gID = $("table:first",$t.grid.bDiv).attr("id"); var IDs = { themodal:'srchmod'+gID,modalhead:'srchhead'+gID,modalcontent:'srchcnt'+gID }; if ( $("#"+IDs.themodal).html() != null ) { if( $.isFunction('beforeShowSearch') ) { beforeShowSearch($("#srchcnt"+gID)); } viewModal("#"+IDs.themodal,{modal: p.modal}); if( $.isFunction('afterShowSearch') ) { afterShowSearch($("#srchcnt"+gID)); } } else { var cM = $t.p.colModel; var cNames = "<select id='snames' class='search'>"; var nm, hc, sf; for(var i=0; i< cM.length;i++) { nm = cM[i].name; hc = (cM[i].hidden===true) ? true : false; sf = (cM[i].search===false) ? false: true; if( nm !== 'cb' && nm !== 'subgrid' && sf && !hc ) { // add here condition for searchable var sname = (cM[i].index) ? cM[i].index : nm; cNames += "<option value='"+sname+"'>"+$t.p.colNames[i]+"</option>"; } } cNames += "</select>"; var getopt = p.sopt || ['bw','eq','ne','lt','le','gt','ge','ew','cn']; var sOpt = "<select id='sopt' class='search'>"; for(var i = 0; i<getopt.length;i++) { sOpt += getopt[i]=='eq' ? "<option value='eq'>"+p.odata[0]+"</option>" : ""; sOpt += getopt[i]=='ne' ? "<option value='ne'>"+p.odata[1]+"</option>" : ""; sOpt += getopt[i]=='lt' ? "<option value='lt'>"+p.odata[2]+"</option>" : ""; sOpt += getopt[i]=='le' ? "<option value='le'>"+p.odata[3]+"</option>" : ""; sOpt += getopt[i]=='gt' ? "<option value='gt'>"+p.odata[4]+"</option>" : ""; sOpt += getopt[i]=='ge' ? "<option value='ge'>"+p.odata[5]+"</option>" : ""; sOpt += getopt[i]=='bw' ? "<option value='bw'>"+p.odata[6]+"</option>" : ""; sOpt += getopt[i]=='ew' ? "<option value='ew'>"+p.odata[7]+"</option>" : ""; sOpt += getopt[i]=='cn' ? "<option value='cn'>"+p.odata[8]+"</option>" : ""; }; sOpt += "</select>"; // field and buttons var sField = "<input id='sval' class='search' type='text' size='20' maxlength='100'/>"; var bSearch = "<input id='sbut' class='buttonsearch' type='button' value='"+p.Find+"'/>"; var bReset = "<input id='sreset' class='buttonsearch' type='button' value='"+p.Reset+"'/>"; var cnt = $("<table width='100%'><tbody><tr style='display:none' id='srcherr'><td colspan='5'></td></tr><tr><td>"+cNames+"</td><td>"+sOpt+"</td><td>"+sField+"</td><td>"+bSearch+"</td><td>"+bReset+"</td></tr></tbody></table>"); createModal(IDs,cnt,p,$t.grid.hDiv,$t.grid.hDiv); if ( $.isFunction('onInitializeSearch') ) { onInitializeSearch( $("#srchcnt"+gID) ); }; if ( $.isFunction('beforeShowSearch') ) { beforeShowSearch($("#srchcnt"+gID)); }; viewModal("#"+IDs.themodal,{modal:p.modal}); if($.isFunction('afterShowSearch')) { afterShowSearch($("#srchcnt"+gID)); } if(p.drag) { DnRModal("#"+IDs.themodal,"#"+IDs.modalhead+" td.modaltext"); } $("#sbut","#"+IDs.themodal).click(function(){ if( $("#sval","#"+IDs.themodal).val() !="" ) { var es=[true,"",""]; $("#srcherr >td","#srchcnt"+gID).html("").hide(); $t.p.searchdata[p.sField] = $("option[@selected]","#snames").val(); $t.p.searchdata[p.sOper] = $("option[@selected]","#sopt").val(); $t.p.searchdata[p.sValue] = $("#sval","#"+IDs.modalcontent).val(); if(p.checkInput) { for(var i=0; i< cM.length;i++) { var sname = (cM[i].index) ? cM[i].index : nm; if (sname == $t.p.searchdata[p.sField]) { break; } } es = checkValues($t.p.searchdata[p.sValue],i,$t); } if (es[0]===true) { $t.p.search = true; // initialize the search // construct array of data which is passed in populate() see jqGrid if(p.dirty) { $(".no-dirty-cell",$t.p.pager).addClass("dirty-cell"); } $t.p.page= 1; $($t).trigger("reloadGrid"); } else { $("#srcherr >td","#srchcnt"+gID).html(es[1]).show(); } } }); $("#sreset","#"+IDs.themodal).click(function(){ if ($t.p.search) { $("#srcherr >td","#srchcnt"+gID).html("").hide(); $t.p.search = false; $t.p.searchdata = {}; $t.p.page= 1; $("#sval","#"+IDs.themodal).val(""); if(p.dirty) { $(".no-dirty-cell",$t.p.pager).removeClass("dirty-cell"); } $($t).trigger("reloadGrid"); } }); } }); }, editGridRow : function(rowid, p){ p = $.extend({ top : 0, left: 0, width: 0, height: 0, modal: false, drag: true, closeicon: 'ico-close.gif', imgpath: '', url: null, mtype : "POST", closeAfterAdd : false, clearAfterAdd : true, closeAfterEdit : false, reloadAfterSubmit : true, onInitializeForm: null, beforeInitData: null, beforeShowForm: null, afterShowForm: null, beforeSubmit: null, afterSubmit: null, onclickSubmit: null, editData : {}, recreateForm : false }, $.jgrid.edit, p || {}); rp_ge = p; return this.each(function(){ var $t = this; if (!$t.grid || !rowid) { return; } if(!p.imgpath) { p.imgpath= $t.p.imgpath; } // I hate to rewrite code, but ... var gID = $("table:first",$t.grid.bDiv).attr("id"); var IDs = {themodal:'editmod'+gID,modalhead:'edithd'+gID,modalcontent:'editcnt'+gID}; var onBeforeShow = $.isFunction(rp_ge.beforeShowForm) ? rp_ge.beforeShowForm : false; var onAfterShow = $.isFunction(rp_ge.afterShowForm) ? rp_ge.afterShowForm : false; var onBeforeInit = $.isFunction(rp_ge.beforeInitData) ? rp_ge.beforeInitData : false; var onInitializeForm = $.isFunction(rp_ge.onInitializeForm) ? rp_ge.onInitializeForm : false; if (rowid=="new") { rowid = "_empty"; p.caption=p.addCaption; } else { p.caption=p.editCaption; }; var frmgr = "FrmGrid_"+gID; var frmtb = "TblGrid_"+gID; if(p.recreateForm===true && $("#"+IDs.themodal).html() != null) { $("#"+IDs.themodal).remove(); } if ( $("#"+IDs.themodal).html() != null ) { $(".modaltext","#"+IDs.modalhead).html(p.caption); $("#FormError","#"+frmtb).hide(); if(onBeforeInit) { onBeforeInit($("#"+frmgr)); } fillData(rowid,$t); if(rowid=="_empty") { $("#pData, #nData","#"+frmtb).hide(); } else { $("#pData, #nData","#"+frmtb).show(); } if(onBeforeShow) { onBeforeShow($("#"+frmgr)); } viewModal("#"+IDs.themodal,{modal:p.modal}); if(onAfterShow) { onAfterShow($("#"+frmgr)); } } else { var frm = $("<form name='FormPost' id='"+frmgr+"' class='FormGrid'></form>"); var tbl =$("<table id='"+frmtb+"' class='EditTable' cellspacing='0' cellpading='0' border='0'><tbody></tbody></table>"); $(frm).append(tbl); $(tbl).append("<tr id='FormError' style='display:none'><td colspan='2'>"+"&nbsp;"+"</td></tr>"); // set the id. // use carefull only to change here colproperties. if(onBeforeInit) { onBeforeInit($("#"+frmgr)); } var valref = createData(rowid,$t,tbl); // buttons at footer var imp = $t.p.imgpath; var bP ="<img id='pData' src='"+imp+$t.p.previmg+"'/>"; var bN ="<img id='nData' src='"+imp+$t.p.nextimg+"'/>"; var bS ="<input id='sData' type='button' class='EditButton' value='"+p.bSubmit+"'/>"; var bC ="<input id='cData' type='button' class='EditButton' value='"+p.bCancel+"'/>"; $(tbl).append("<tr id='Act_Buttons'><td class='navButton'>"+bP+"&nbsp;"+bN+"</td><td class='EditButton'>"+bS+"&nbsp;"+bC+"</td></tr>"); // beforeinitdata after creation of the form createModal(IDs,frm,p,$t.grid.hDiv,$t.grid.hDiv); // here initform - only once if(onInitializeForm) { onInitializeForm($("#"+frmgr)); } if( p.drag ) { DnRModal("#"+IDs.themodal,"#"+IDs.modalhead+" td.modaltext"); } if(rowid=="_empty") { $("#pData,#nData","#"+frmtb).hide(); } else { $("#pData,#nData","#"+frmtb).show(); } if(onBeforeShow) { onBeforeShow($("#"+frmgr)); } viewModal("#"+IDs.themodal,{modal:p.modal}); if(onAfterShow) { onAfterShow($("#"+frmgr)); } $("#sData", "#"+frmtb).click(function(e){ var postdata = {}, ret=[true,"",""], extpost={}; $("#FormError","#"+frmtb).hide(); // all depend on ret array //ret[0] - succes //ret[1] - msg if not succes //ret[2] - the id that will be set if reload after submit false var j =0; $(".FormElement", "#"+frmtb).each(function(i){ var suc = true; switch ($(this).get(0).type) { case "checkbox": if($(this).attr("checked")) { postdata[this.name]= $(this).val(); }else { postdata[this.name]= ""; extpost[this.name] = $(this).attr("offval"); } break; case "select-one": postdata[this.name]= $("option:selected",this).val(); extpost[this.name]= $("option:selected",this).text(); break; case "select-multiple": postdata[this.name]= $(this).val(); var selectedText = []; $("option:selected",this).each( function(i,selected){ selectedText[i] = $(selected).text(); } ); extpost[this.name]= selectedText.join(","); break; case "password": case "text": case "textarea": postdata[this.name] = $(this).val(); ret = checkValues($(this).val(),valref[i],$t); if(ret[0] === false) { suc=false; } break; } j++; if(!suc) { return false; } }); if(j==0) { ret[0] = false; ret[1] = $.jgrid.errors.norecords; } if( $.isFunction( rp_ge.onclickSubmit)) { p.editData = rp_ge.onclickSubmit(p) || {}; } if(ret[0]) { if( $.isFunction(rp_ge.beforeSubmit)) { ret = rp_ge.beforeSubmit(postdata,$("#"+frmgr)); } } var gurl = p.url ? p.url : $t.p.editurl; if(ret[0]) { if(!gurl) { ret[0]=false; ret[1] += " "+$.jgrid.errors.nourl; } } if(ret[0] === false) { $("#FormError>td","#"+frmtb).html(ret[1]); $("#FormError","#"+frmtb).show(); } else { if(!p.processing) { p.processing = true; $("div.loading","#"+IDs.themodal).fadeIn("fast"); $(this).attr("disabled",true); // we add to pos data array the action - the name is oper postdata.oper = postdata.id == "_empty" ? "add" : "edit"; postdata = $.extend(postdata,p.editData); $.ajax({ url:gurl, type: p.mtype, data:postdata, complete:function(data,Status){ if(Status != "success") { ret[0] = false; ret[1] = Status+" Status: "+data.statusText +" Error code: "+data.status; } else { // data is posted successful // execute aftersubmit with the returned data from server if( $.isFunction(rp_ge.afterSubmit) ) { ret = rp_ge.afterSubmit(data,postdata); } } if(ret[0] === false) { $("#FormError>td","#"+frmtb).html(ret[1]); $("#FormError","#"+frmtb).show(); } else { postdata = $.extend(postdata,extpost); // the action is add if(postdata.id=="_empty" ) { //id processing // user not set the id ret[2] if(!ret[2]) { ret[2] = parseInt($($t).getGridParam('records'))+1; } postdata.id = ret[2]; if(p.closeAfterAdd) { if(rp_ge.reloadAfterSubmit) { $($t).trigger("reloadGrid"); } else { $($t).addRowData(ret[2],postdata,"first"); } $("#"+IDs.themodal).jqmHide(); } else if (rp_ge.clearAfterAdd) { if(rp_ge.reloadAfterSubmit) { $($t).trigger("reloadGrid"); } else { $($t).addRowData(ret[2],postdata,"first"); } $(".FormElement", "#"+frmtb).each(function(i){ switch ($(this).get(0).type) { case "checkbox": $(this).attr("checked",0); break; case "select-one": case "select-multiple": $("option",this).attr("selected",""); break; case "password": case "text": case "textarea": if(this.name =='id') { $(this).val("_empty"); } else { $(this).val(""); } break; } }); } else { if(rp_ge.reloadAfterSubmit) { $($t).trigger("reloadGrid"); } else { $($t).addRowData(ret[2],postdata,"first"); } } } else { // the action is update if(rp_ge.reloadAfterSubmit) { $($t).trigger("reloadGrid"); if( !rp_ge.closeAfterEdit ) { $($t).setSelection(postdata.id); } } else { if($t.p.treeGrid === true) { $($t).setTreeRow(postdata.id,postdata); } else { $($t).setRowData(postdata.id,postdata); } } if(rp_ge.closeAfterEdit) { $("#"+IDs.themodal).jqmHide(); } } } p.processing=false; $("#sData", "#"+frmtb).attr("disabled",false); $("div.loading","#"+IDs.themodal).fadeOut("fast"); } }); } } e.stopPropagation(); }); $("#cData", "#"+frmtb).click(function(e){ $("#"+IDs.themodal).jqmHide(); e.stopPropagation(); }); $("#nData", "#"+frmtb).click(function(e){ $("#FormError","#"+frmtb).hide(); var npos = getCurrPos(); npos[0] = parseInt(npos[0]); if(npos[0] != -1 && npos[1][npos[0]+1]) { fillData(npos[1][npos[0]+1],$t); $($t).setSelection(npos[1][npos[0]+1]); updateNav(npos[0]+1,npos[1].length-1); }; return false; }); $("#pData", "#"+frmtb).click(function(e){ $("#FormError","#"+frmtb).hide(); var ppos = getCurrPos(); if(ppos[0] != -1 && ppos[1][ppos[0]-1]) { fillData(ppos[1][ppos[0]-1],$t); $($t).setSelection(ppos[1][ppos[0]-1]); updateNav(ppos[0]-1,ppos[1].length-1); }; return false; }); }; var posInit =getCurrPos(); updateNav(posInit[0],posInit[1].length-1); function updateNav(cr,totr,rid){ var imp = $t.p.imgpath; if (cr==0) { $("#pData","#"+frmtb).attr("src",imp+"off-"+$t.p.previmg); } else { $("#pData","#"+frmtb).attr("src",imp+$t.p.previmg); } if (cr==totr) { $("#nData","#"+frmtb).attr("src",imp+"off-"+$t.p.nextimg); } else { $("#nData","#"+frmtb).attr("src",imp+$t.p.nextimg); } }; function getCurrPos() { var rowsInGrid = $($t).getDataIDs(); var selrow = $("#id_g","#"+frmtb).val(); var pos = $.inArray(selrow,rowsInGrid); return [pos,rowsInGrid]; }; function createData(rowid,obj,tb){ var nm, hc,trdata, tdl, tde, cnt=0,tmp, dc,elc, retpos=[]; $('#'+rowid+' td',obj.grid.bDiv).each( function(i) { nm = obj.p.colModel[i].name; // hidden fields are included in the form if(obj.p.colModel[i].editrules && obj.p.colModel[i].editrules.edithidden == true) { hc = false; } else { hc = obj.p.colModel[i].hidden === true ? true : false; } dc = hc ? "style='display:none'" : ""; if ( nm !== 'cb' && nm !== 'subgrid' && obj.p.colModel[i].editable===true) { if(nm == obj.p.ExpandColumn && obj.p.treeGrid === true) { tmp = $(this).text(); } else { tmp = $(this).html().replace(/\&nbsp\;/ig,''); } var opt = $.extend(obj.p.colModel[i].editoptions || {} ,{id:nm,name:nm}); if(!obj.p.colModel[i].edittype) obj.p.colModel[i].edittype = "text"; elc = createEl(obj.p.colModel[i].edittype,opt,tmp); $(elc).addClass("FormElement"); trdata = $("<tr "+dc+"></tr>").addClass("FormData"); tdl = $("<td></td>").addClass("CaptionTD"); tde = $("<td></td>").addClass("DataTD"); $(tdl).html(obj.p.colNames[i]+": "); $(tde).append(elc); trdata.append(tdl); trdata.append(tde); if(tb) { $(tb).append(trdata); } else { $(trdata).insertBefore("#Act_Buttons"); } retpos[cnt] = i; cnt++; }; }); if( cnt > 0) { var idrow = $("<tr class='FormData' style='display:none'><td class='CaptionTD'>"+"&nbsp;"+"</td><td class='DataTD'><input class='FormElement' id='id_g' type='text' name='id' value='"+rowid+"'/></td></tr>"); if(tb) { $(tb).append(idrow); } else { $(idrow).insertBefore("#Act_Buttons"); } } return retpos; }; function fillData(rowid,obj){ var nm, hc,cnt=0,tmp; $('#'+rowid+' td',obj.grid.bDiv).each( function(i) { nm = obj.p.colModel[i].name; // hidden fields are included in the form if(obj.p.colModel[i].editrules && obj.p.colModel[i].editrules.edithidden === true) { hc = false; } else { hc = obj.p.colModel[i].hidden === true ? true : false; } if ( nm !== 'cb' && nm !== 'subgrid' && obj.p.colModel[i].editable===true) { if(nm == obj.p.ExpandColumn && obj.p.treeGrid === true) { tmp = $(this).text(); } else { tmp = $(this).html().replace(/\&nbsp\;/ig,''); } switch (obj.p.colModel[i].edittype) { case "password": case "text": case "textarea": $("#"+nm,"#"+frmtb).val(tmp); break; case "select": $("#"+nm+" option","#"+frmtb).each(function(j){ if (!obj.p.colModel[i].editoptions.multiple && tmp == $(this).text() ){ this.selected= true; } else if (obj.p.colModel[i].editoptions.multiple){ if( $.inArray($(this).text(), tmp.split(",") ) > -1 ){ this.selected = true; }else{ this.selected = false; } } else { this.selected = false; } }); break; case "checkbox": if(tmp==$("#"+nm,"#"+frmtb).val()) { $("#"+nm,"#"+frmtb).attr("checked",true); $("#"+nm,"#"+frmtb).attr("defaultChecked",true); //ie } else { $("#"+nm,"#"+frmtb).attr("checked",false); $("#"+nm,"#"+frmtb).attr("defaultChecked",""); //ie } break; } if (hc) { $("#"+nm,"#"+frmtb).parents("tr:first").hide(); } cnt++; } }); if(cnt>0) { $("#id_g","#"+frmtb).val(rowid); } else { $("#id_g","#"+frmtb).val(""); } return cnt; }; }); }, delGridRow : function(rowids,p) { p = $.extend({ top : 0, left: 0, width: 240, height: 90, modal: false, drag: true, closeicon: 'ico-close.gif', imgpath: '', url : '', mtype : "POST", reloadAfterSubmit: true, beforeShowForm: null, afterShowForm: null, beforeSubmit: null, onclickSubmit: null, afterSubmit: null, onclickSubmit: null, delData: {} }, $.jgrid.del, p ||{}); return this.each(function(){ var $t = this; if (!$t.grid ) { return; } if(!rowids) { return; } if(!p.imgpath) { p.imgpath= $t.p.imgpath; } var onBeforeShow = typeof p.beforeShowForm === 'function' ? true: false; var onAfterShow = typeof p.afterShowForm === 'function' ? true: false; if (isArray(rowids)) { rowids = rowids.join(); } var gID = $("table:first",$t.grid.bDiv).attr("id"); var IDs = {themodal:'delmod'+gID,modalhead:'delhd'+gID,modalcontent:'delcnt'+gID}; var dtbl = "DelTbl_"+gID; if ( $("#"+IDs.themodal).html() != null ) { $("#DelData>td","#"+dtbl).text(rowids); $("#DelError","#"+dtbl).hide(); if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); } viewModal("#"+IDs.themodal,{modal:p.modal}); if(onAfterShow) { p.afterShowForm($("#"+dtbl)); } } else { var tbl =$("<table id='"+dtbl+"' class='DelTable'><tbody></tbody></table>"); // error data $(tbl).append("<tr id='DelError' style='display:none'><td >"+"&nbsp;"+"</td></tr>"); $(tbl).append("<tr id='DelData' style='display:none'><td >"+rowids+"</td></tr>"); $(tbl).append("<tr><td >"+p.msg+"</td></tr>"); // buttons at footer var bS ="<input id='dData' type='button' value='"+p.bSubmit+"'/>"; var bC ="<input id='eData' type='button' value='"+p.bCancel+"'/>"; $(tbl).append("<tr><td class='DelButton'>"+bS+"&nbsp;"+bC+"</td></tr>"); createModal(IDs,tbl,p,$t.grid.hDiv,$t.grid.hDiv); if( p.drag) { DnRModal("#"+IDs.themodal,"#"+IDs.modalhead+" td.modaltext"); } $("#dData","#"+dtbl).click(function(e){ var ret=[true,""]; var postdata = $("#DelData>td","#"+dtbl).text(); //the pair is name=val1,val2,... if( typeof p.onclickSubmit === 'function' ) { p.delData = p.onclickSubmit(p) || {}; } if( typeof p.beforeSubmit === 'function' ) { ret = p.beforeSubmit(postdata); } var gurl = p.url ? p.url : $t.p.editurl; if(!gurl) { ret[0]=false;ret[1] += " "+$.jgrid.errors.nourl;} if(ret[0] === false) { $("#DelError>td","#"+dtbl).html(ret[1]); $("#DelError","#"+dtbl).show(); } else { if(!p.processing) { p.processing = true; $("div.loading","#"+IDs.themodal).fadeIn("fast"); $(this).attr("disabled",true); var postd = $.extend({oper:"del", id:postdata},p.delData); $.ajax({ url:gurl, type: p.mtype, data:postd, complete:function(data,Status){ if(Status != "success") { ret[0] = false; ret[1] = Status+" Status: "+data.statusText +" Error code: "+data.status; } else { // data is posted successful // execute aftersubmit with the returned data from server if( typeof p.afterSubmit === 'function' ) { ret = p.afterSubmit(data,postdata); } } if(ret[0] === false) { $("#DelError>td","#"+dtbl).html(ret[1]); $("#DelError","#"+dtbl).show(); } else { if(p.reloadAfterSubmit) { if($t.p.treeGrid) { $($t).setGridParam({treeANode:0,datatype:$t.p.treedatatype}); } $($t).trigger("reloadGrid"); } else { var toarr = []; toarr = postdata.split(","); if($t.p.treeGrid===true){ try {$($t).delTreeNode(toarr[0])} catch(e){} } else { for(var i=0;i<toarr.length;i++) { $($t).delRowData(toarr[i]); } } $t.p.selrow = null; $t.p.selarrrow = []; } } p.processing=false; $("#dData", "#"+dtbl).attr("disabled",false); $("div.loading","#"+IDs.themodal).fadeOut("fast"); if(ret[0]) { $("#"+IDs.themodal).jqmHide(); } } }); } } return false; }); $("#eData", "#"+dtbl).click(function(e){ $("#"+IDs.themodal).jqmHide(); return false; }); if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); } viewModal("#"+IDs.themodal,{modal:p.modal}); if(onAfterShow) { p.afterShowForm($("#"+dtbl)); } } }); }, navGrid : function (elem, o, pEdit,pAdd,pDel,pSearch) { o = $.extend({ edit: true, editicon: "row_edit.gif", add: true, addicon:"row_add.gif", del: true, delicon:"row_delete.gif", search: true, searchicon:"find.gif", refresh: true, refreshicon:"refresh.gif", refreshstate: 'firstpage', position : "left", closeicon: "ico-close.gif" }, $.jgrid.nav, o ||{}); return this.each(function() { var alertIDs = {themodal:'alertmod',modalhead:'alerthd',modalcontent:'alertcnt'}; var $t = this; if(!$t.grid) { return; } if ($("#"+alertIDs.themodal).html() == null) { var vwidth; var vheight; if (typeof window.innerWidth != 'undefined') { vwidth = window.innerWidth, vheight = window.innerHeight } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) { vwidth = document.documentElement.clientWidth, vheight = document.documentElement.clientHeight } else { vwidth=1024; vheight=768; } createModal(alertIDs,"<div>"+o.alerttext+"</div>",{imgpath:$t.p.imgpath,closeicon:o.closeicon,caption:o.alertcap,top:vheight/2-25,left:vwidth/2-100,width:200,height:50},$t.grid.hDiv,$t.grid.hDiv,true); DnRModal("#"+alertIDs.themodal,"#"+alertIDs.modalhead); } var navTbl = $("<table cellspacing='0' cellpadding='0' border='0' class='navtable'><tbody></tbody></table>").height(20); var trd = document.createElement("tr"); $(trd).addClass("nav-row"); var imp = $t.p.imgpath; var tbd; if (o.edit) { tbd = document.createElement("td"); $(tbd).append("&nbsp;").css({border:"none",padding:"0px"}); trd.appendChild(tbd); tbd = document.createElement("td"); tbd.title = o.edittitle || ""; $(tbd).append("<table cellspacing='0' cellpadding='0' border='0' class='tbutton'><tr><td><img src='"+imp+o.editicon+"'/></td><td valign='center'>"+o.edittext+"&nbsp;</td></tr></table>") .css("cursor","pointer") .addClass("nav-button") .click(function(){ var sr = $($t).getGridParam('selrow'); if (sr) { $($t).editGridRow(sr,pEdit || {}); } else { viewModal("#"+alertIDs.themodal); } return false; }) .hover( function () { $(this).addClass("nav-hover"); }, function () { $(this).removeClass("nav-hover"); } ); trd.appendChild(tbd); tbd = null; } if (o.add) { tbd = document.createElement("td"); $(tbd).append("&nbsp;").css({border:"none",padding:"0px"}); trd.appendChild(tbd); tbd = document.createElement("td"); tbd.title = o.addtitle || ""; $(tbd).append("<table cellspacing='0' cellpadding='0' border='0' class='tbutton'><tr><td><img src='"+imp+o.addicon+"'/></td><td>"+o.addtext+"&nbsp;</td></tr></table>") .css("cursor","pointer") .addClass("nav-button") .click(function(){ if (typeof o.addfunc == 'function') { o.addfunc(); } else { $($t).editGridRow("new",pAdd || {}); } return false; }) .hover( function () { $(this).addClass("nav-hover"); }, function () { $(this).removeClass("nav-hover"); } ); trd.appendChild(tbd); tbd = null; } if (o.del) { tbd = document.createElement("td"); $(tbd).append("&nbsp;").css({border:"none",padding:"0px"}); trd.appendChild(tbd); tbd = document.createElement("td"); tbd.title = o.deltitle || ""; $(tbd).append("<table cellspacing='0' cellpadding='0' border='0' class='tbutton'><tr><td><img src='"+imp+o.delicon+"'/></td><td>"+o.deltext+"&nbsp;</td></tr></table>") .css("cursor","pointer") .addClass("nav-button") .click(function(){ var dr; if($t.p.multiselect) { dr = $($t).getGridParam('selarrrow'); if(dr.length==0) { dr = null; } } else { dr = $($t).getGridParam('selrow'); } if (dr) { $($t).delGridRow(dr,pDel || {}); } else { viewModal("#"+alertIDs.themodal); } return false; }) .hover( function () { $(this).addClass("nav-hover"); }, function () { $(this).removeClass("nav-hover"); } ); trd.appendChild(tbd); tbd = null; } if (o.search) { tbd = document.createElement("td"); $(tbd).append("&nbsp;").css({border:"none",padding:"0px"}); trd.appendChild(tbd); tbd = document.createElement("td"); if( $(elem)[0] == $t.p.pager[0] ) { pSearch = $.extend(pSearch,{dirty:true}); } tbd.title = o.searchtitle || ""; $(tbd).append("<table cellspacing='0' cellpadding='0' border='0' class='tbutton'><tr><td class='no-dirty-cell'><img src='"+imp+o.searchicon+"'/></td><td>"+o.searchtext+"&nbsp;</td></tr></table>") .css({cursor:"pointer"}) .addClass("nav-button") .click(function(){ $($t).searchGrid(pSearch || {}); return false; }) .hover( function () { $(this).addClass("nav-hover"); }, function () { $(this).removeClass("nav-hover"); } ); trd.appendChild(tbd); tbd = null; } if (o.refresh) { tbd = document.createElement("td"); $(tbd).append("&nbsp;").css({border:"none",padding:"0px"}); trd.appendChild(tbd); tbd = document.createElement("td"); tbd.title = o.refreshtitle || ""; var dirtycell = ($(elem)[0] == $t.p.pager[0] ) ? true : false; $(tbd).append("<table cellspacing='0' cellpadding='0' border='0' class='tbutton'><tr><td><img src='"+imp+o.refreshicon+"'/></td><td>"+o.refreshtext+"&nbsp;</td></tr></table>") .css("cursor","pointer") .addClass("nav-button") .click(function(){ $t.p.search = false; switch (o.refreshstate) { case 'firstpage': $t.p.page=1; $($t).trigger("reloadGrid"); break; case 'current': var sr = $t.p.multiselect===true ? selarrrow : $t.p.selrow; $($t).setGridParam({gridComplete: function() { if($t.p.multiselect===true) { if(sr.length>0) { for(var i=0;i<sr.length;i++){ $($t).setSelection(sr[i]); } } } else { if(sr) { $($t).setSelection(sr); } } }}); $($t).trigger("reloadGrid"); break; } if (dirtycell) { $(".no-dirty-cell",$t.p.pager).removeClass("dirty-cell"); } if(o.search) { var gID = $("table:first",$t.grid.bDiv).attr("id"); $("#sval",'#srchcnt'+gID).val(""); } return false; }) .hover( function () { $(this).addClass("nav-hover"); }, function () { $(this).removeClass("nav-hover"); } ); trd.appendChild(tbd); tbd = null; } if(o.position=="left") { $(navTbl).append(trd).addClass("nav-table-left"); } else { $(navTbl).append(trd).addClass("nav-table-right"); } $(elem).prepend(navTbl); }); }, navButtonAdd : function (elem, p) { p = $.extend({ caption : "newButton", title: '', buttonimg : '', onClickButton: null, position : "last" }, p ||{}); return this.each(function() { if( !this.grid) { return; } if( elem.indexOf("#") != 0) { elem = "#"+elem; } var findnav = $(".navtable",elem)[0]; if (findnav) { var tdb, tbd1; var tbd1 = document.createElement("td"); $(tbd1).append("&nbsp;").css({border:"none",padding:"0px"}); var trd = $("tr:eq(0)",findnav)[0]; if( p.position !='first' ) { trd.appendChild(tbd1); } tbd = document.createElement("td"); tbd.title = p.title; var im = (p.buttonimg) ? "<img src='"+p.buttonimg+"'/>" : "&nbsp;"; $(tbd).append("<table cellspacing='0' cellpadding='0' border='0' class='tbutton'><tr><td>"+im+"</td><td>"+p.caption+"&nbsp;</td></tr></table>") .css("cursor","pointer") .addClass("nav-button") .click(function(e){ if (typeof p.onClickButton == 'function') { p.onClickButton(); } e.stopPropagation(); return false; }) .hover( function () { $(this).addClass("nav-hover"); }, function () { $(this).removeClass("nav-hover"); } ); if(p.position != 'first') { trd.appendChild(tbd); } else { $(trd).prepend(tbd); $(trd).prepend(tbd1); } tbd=null;tbd1=null; } }); }, GridToForm : function( rowid, formid ) { return this.each(function(){ var $t = this; if (!$t.grid) { return; } var rowdata = $($t).getRowData(rowid); if (rowdata) { for(var i in rowdata) { if ( $("[name="+i+"]",formid).is("input:radio") ) { $("[name="+i+"]",formid).each( function() { if( $(this).val() == rowdata[i] ) { $(this).attr("checked","checked"); } else { $(this).attr("checked",""); } }); } else { // this is very slow on big table and form. $("[name="+i+"]",formid).val(rowdata[i]); } } } }); }, FormToGrid : function(rowid, formid){ return this.each(function() { var $t = this; if(!$t.grid) { return; } var fields = $(formid).serializeArray(); var griddata = {}; $.each(fields, function(i, field){ griddata[field.name] = field.value; }); $($t).setRowData(rowid,griddata); }); } }); })(jQuery); ;(function($){ /** * jqGrid extension for manipulating Grid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ //Editing editRow : function(rowid,keys,oneditfunc,succesfunc, url, extraparam, aftersavefunc,errorfunc) { return this.each(function(){ var $t = this, nm, tmp, editable, cnt=0, focus=null, svr=[]; if (!$t.grid ) { return; } var sz, ml,hc; if( !$t.p.multiselect ) { editable = $("#"+rowid,$t.grid.bDiv).attr("editable") || "0"; if (editable == "0") { $('#'+rowid+' td',$t.grid.bDiv).each( function(i) { nm = $t.p.colModel[i].name; hc = $t.p.colModel[i].hidden===true ? true : false; tmp = $(this).html().replace(/\&nbsp\;/ig,''); svr[nm]=tmp; if ( nm !== 'cb' && nm !== 'subgrid' && $t.p.colModel[i].editable===true && !hc) { if(focus===null) { focus = i; } $(this).html(""); var opt = $.extend($t.p.colModel[i].editoptions || {} ,{id:rowid+"_"+nm,name:nm}); if(!$t.p.colModel[i].edittype) { $t.p.colModel[i].edittype = "text"; } var elc = createEl($t.p.colModel[i].edittype,opt,tmp,$(this)); $(elc).addClass("editable"); $(this).append(elc); //Agin IE if($t.p.colModel[i].edittype == "select" && $t.p.colModel[i].editoptions.multiple===true && $.browser.msie) { $(elc).width($(elc).width()); } cnt++; } }); if(cnt > 0) { svr['id'] = rowid; $t.p.savedRow.push(svr); $('#'+rowid,$t.grid.bDiv).attr("editable","1"); $('#'+rowid+" td:eq("+focus+") input",$t.grid.bDiv).focus(); if(keys===true) { $('#'+rowid,$t.grid.bDiv).bind("keydown",function(e) { if (e.keyCode === 27) { $($t).restoreRow(rowid); } if (e.keyCode === 13) { $($t).saveRow(rowid,succesfunc, url, extraparam, aftersavefunc,errorfunc); } e.stopPropagation(); }); } if( typeof oneditfunc === "function") { oneditfunc(rowid); } } } } }); }, saveRow : function(rowid, succesfunc, url, extraparam, aftersavefunc,errorfunc) { return this.each(function(){ var $t = this, nm, tmp={}, tmp2, editable, fr; if (!$t.grid ) { return; } editable = $('#'+rowid,$t.grid.bDiv).attr("editable"); url = url ? url : $t.p.editurl; if (editable==="1" && url) { $('#'+rowid+" td",$t.grid.bDiv).each(function(i) { nm = $t.p.colModel[i].name; if ( nm !== 'cb' && nm !== 'subgrid' && $t.p.colModel[i].editable===true) { if( $t.p.colModel[i].hidden===true) { tmp[nm] = $(this).html(); } else { switch ($t.p.colModel[i].edittype) { case "checkbox": tmp[nm]= $("input",this).attr("checked") ? 1 : 0; break; case 'text': case 'password': tmp[nm]= $("input",this).val(); break; case 'textarea': tmp[nm]= $("textarea",this).val(); break; case 'select': if(!$t.p.colModel[i].editoptions.multiple) { tmp[nm] = $("select>option:selected",this).val(); } else { var sel = $("select",this); tmp[nm] = $(sel).val(); } break; } } } }); if(tmp) { tmp["id"] = rowid; if(extraparam) { $.extend(tmp,extraparam);} } if(!$t.grid.hDiv.loading) { $t.grid.hDiv.loading = true; $("div.loading",$t.grid.hDiv).fadeIn("fast"); $.ajax({url:url, data: tmp, type: "POST", complete: function(res,stat){ if (stat === "success"){ var ret; if( typeof succesfunc === "function") { ret = succesfunc(res); } else ret = true; if (ret===true) { $('#'+rowid+" td",$t.grid.bDiv).each(function(i) { nm = $t.p.colModel[i].name; if ( nm !== 'cb' && nm !== 'subgrid' && $t.p.colModel[i].editable===true) { switch ($t.p.colModel[i].edittype) { case "select": if(!$t.p.colModel[i].editoptions.multiple) { tmp2 = $("select>option:selected", this).text(); } else if( $t.p.colModel[i].editoptions.multiple ===true) { var selectedText = []; $("select > option:selected",this).each( function(i,selected){ selectedText[i] = $(selected).text(); } ); tmp2= selectedText.join(","); } break; case "checkbox": var cbv = $t.p.colModel[i].editoptions.value.split(":") || ["Yes","No"]; tmp2 = $("input",this).attr("checked") ? cbv[0] : cbv[1]; break; case "password": case "text": case "textarea": tmp2 = $("input, textarea", this).val(); break; } $(this).empty(); $(this).html(tmp2 || "&nbsp;"); } }); $('#'+rowid,$t.grid.bDiv).attr("editable","0"); for( var k=0;k<$t.p.savedRow.length;k++) { if( $t.p.savedRow[k].id===rowid) {fr = k; break;} }; if(fr >= 0) { $t.p.savedRow.splice(fr,1); } if( typeof aftersavefunc === "function") { aftersavefunc(rowid,res.responseText); } } else { $($t).restoreRow(rowid); } } }, error:function(res,stat){ if(typeof errorfunc == "function") { errorfunc(res,stat) } else { alert("Error Row: "+rowid+" Result: " +res.status+":"+res.statusText+" Status: "+stat); } } }); $t.grid.hDiv.loading = false; $("div.loading",$t.grid.hDiv).fadeOut("fast"); $("#"+rowid,$t.grid.bDiv).unbind("keydown"); } } }); }, restoreRow : function(rowid) { return this.each(function(){ var $t= this, nm, fr; if (!$t.grid ) { return; } for( var k=0;k<$t.p.savedRow.length;k++) { if( $t.p.savedRow[k].id===rowid) {fr = k; break;} }; if(fr >= 0) { $('#'+rowid+" td",$t.grid.bDiv).each(function(i) { nm = $t.p.colModel[i].name; if ( nm !== 'cb' && nm !== 'subgrid') { $(this).empty(); $(this).html($t.p.savedRow[fr][nm] || "&nbsp;"); } }); $('#'+rowid,$t.grid.bDiv).attr("editable","0"); $t.p.savedRow.splice(fr,1); } }); } //end inline edit }); })(jQuery); ;(function($){ /** * jqGrid extension for custom methods * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ getColProp : function(colname){ var ret ={}, $t = this[0]; if ( !$t.grid ) { return; } var cM = $t.p.colModel; for ( var i =0;i<cM.length;i++ ) { if ( cM[i].name == colname ) { ret = cM[i]; break; } }; return ret; }, setColProp : function(colname, obj){ //do not set width will not work return this.each(function(){ if ( this.grid ) { if ( obj ) { var cM = this.p.colModel; for ( var i =0;i<cM.length;i++ ) { if ( cM[i].name == colname ) { $.extend(this.p.colModel[i],obj); break; } } } } }); }, sortGrid : function(colname,reload){ return this.each(function(){ var $t=this,idx=-1; if ( !$t.grid ) { return;} if ( !colname ) { colname = $t.p.sortname; } for ( var i=0;i<$t.p.colModel.length;i++ ) { if ( $t.p.colModel[i].index == colname || $t.p.colModel[i].name==colname ) { idx = i; break; } } if ( idx!=-1 ){ var sort = $t.p.colModel[idx].sortable; if ( typeof sort !== 'boolean' ) { sort = true; } if ( typeof reload !=='boolean' ) { reload = false; } if ( sort ) { $t.sortData(colname, idx, reload); } } }); }, GridDestroy : function () { return this.each(function(){ if ( this.grid ) { if ( this.p.pager ) { $(this.p.pager).remove(); } $("#lui_"+this.id).remove(); $(this.grid.bDiv).remove(); $(this.grid.hDiv).remove(); $(this.grid.cDiv).remove(); if(this.p.toolbar[0]) { $(this.grid.uDiv).remove(); } this.p = null; this.grid =null; } }); }, GridUnload : function(){ return this.each(function(){ if ( !this.grid ) {return;} var defgrid = {id: $(this).attr('id'),cl: $(this).attr('class')}; if (this.p.pager) { $(this.p.pager).empty(); } var newtable = document.createElement('table'); $(newtable).attr({id:defgrid['id']}); newtable.className = defgrid['cl']; $("#lui_"+this.id).remove(); if(this.p.toolbar[0]) { $(this.grid.uDiv).remove(); } $(this.grid.cDiv).remove(); $(this.grid.bDiv).remove(); $(this.grid.hDiv).before(newtable).remove(); this.p = null; this.grid =null; }); }, filterGrid : function(gridid,p){ p = $.extend({ gridModel : false, gridNames : false, gridToolbar : false, filterModel: [], // label/name/stype/defval/surl/sopt formtype : "horizontal", // horizontal/vertical autosearch: true, // if set to false a serch button should be enabled. formclass: "filterform", tableclass: "filtertable", buttonclass: "filterbutton", searchButton: "Search", clearButton: "Clear", enableSearch : false, enableClear: false, beforeSearch: null, afterSearch: null, beforeClear: null, afterClear: null, url : '', marksearched: true },p || {}); return this.each(function(){ var self = this; this.p = p; if(this.p.filterModel.length == 0 && this.p.gridModel===false) { alert("No filter is set"); return;} if( !gridid) {alert("No target grid is set!"); return;} this.p.gridid = gridid.indexOf("#") != -1 ? gridid : "#"+gridid; var gcolMod = $(this.p.gridid).getGridParam('colModel'); if(gcolMod) { if( this.p.gridModel === true) { var thegrid = $(this.p.gridid)[0]; // we should use the options search, edittype, editoptions // additionally surl and defval can be added in grid colModel $.each(gcolMod, function (i,n) { var tmpFil = []; this.search = this.search ===false ? false : true; if( this.search === true && !this.hidden) { if(self.p.gridNames===true) { tmpFil.label = thegrid.p.colNames[i]; } else { tmpFil.label = ''; } tmpFil.name = this.name; tmpFil.index = this.index || this.name; // we support only text and selects, so all other to text tmpFil.stype = this.edittype || 'text'; if(tmpFil.stype != 'select' || tmpFil.stype != 'select') { tmpFil.stype = 'text'; } tmpFil.defval = this.defval || ''; tmpFil.surl = this.surl || ''; tmpFil.sopt = this.editoptions || {}; tmpFil.width = this.width; self.p.filterModel.push(tmpFil); } }); } else { $.each(self.p.filterModel,function(i,n) { for(var j=0;j<gcolMod.length;j++) { if(this.name == gcolMod[j].name) { this.index = gcolMod[j].index || this.name; break; } } if(!this.index) { this.index = this.name; } }); } } else { alert("Could not get grid colModel"); return; } var triggerSearch = function() { var sdata={}, j=0, v; var gr = $(self.p.gridid)[0]; if($.isFunction(self.p.beforeSearch)){self.p.beforeSearch();} $.each(self.p.filterModel,function(i,n){ switch (this.stype) { case 'select' : v = $("select[@name="+this.name+"]",self).val(); if(v) { sdata[this.index] = v; if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell"); } j++; } else { if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell"); } // remove from postdata try { delete gr.p.postData[this.index]; } catch(e) {} } break; default: v = $("input[@name="+this.name+"]",self).val(); if(v) { sdata[this.index] = v; if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell"); } j++; } else { if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell"); } // remove from postdata try { delete gr.p.postData[this.index]; } catch (e) {} } } }); var sd = j>0 ? true : false; gr.p.postData = $.extend(gr.p.postData,sdata); var saveurl; if(self.p.url) { saveurl = $(gr).getGridParam('url'); $(gr).setGridParam({url:self.p.url}); } $(gr).setGridParam({search:sd,page:1}).trigger("reloadGrid"); if(saveurl) {$(gr).setGridParam({url:saveurl});} if($.isFunction(self.p.afterSearch)){self.p.afterSearch();} }; var clearSearch = function(){ var sdata={}, v, j=0; var gr = $(self.p.gridid)[0]; if($.isFunction(self.p.beforeClear)){self.p.beforeClear();} $.each(self.p.filterModel,function(i,n){ v = (this.defval) ? this.defval : ""; if(!this.stype){this.stype=='text';} switch (this.stype) { case 'select' : $("select[@name="+this.name+"]",self).val(v); if(v) { sdata[this.index] = v; if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell"); } j++; } else { if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell"); } // remove from postdata try { delete gr.p.postData[this.index]; } catch(e) {} } break; case 'text': $("input[@name="+this.name+"]",self).val(v); if(v) { sdata[this.index] = v; if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell"); } j++; } else { if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell"); } // remove from postdata try { delete gr.p.postData[this.index]; } catch(e) {} } } }); var sd = j>0 ? true : false; gr.p.postData = $.extend(gr.p.postData,sdata); var saveurl; if(self.p.url) { saveurl = $(gr).getGridParam('url'); $(gr).setGridParam({url:self.p.url}); } $(gr).setGridParam({search:sd,page:1}).trigger("reloadGrid"); if(saveurl) {$(gr).setGridParam({url:saveurl});} if($.isFunction(self.p.afterClear)){self.p.afterClear();} }; var formFill = function(){ var tr = document.createElement("tr"); var tr1, sb, cb,tl,td, td1; if(self.p.formtype=='horizontal'){ $(tbl).append(tr); } $.each(self.p.filterModel,function(i,n){ tl = document.createElement("td"); $(tl).append("<label for='"+this.name+"'>"+this.label+"</label>"); td = document.createElement("td"); var $t=this; if(!this.stype) { this.stype='text';} switch (this.stype) { case "select": if(this.surl) { // data returned should have already constructed html select $(td).load(this.surl,function(){ if($t.defval) $("select",this).val($t.defval); $("select",this).attr({name:$t.name, id: "sg_"+$t.name}); if($t.sopt) $("select",this).attr($t.sopt); if(self.p.gridToolbar===true && $t.width) { $("select",this).width($t.width); } if(self.p.autosearch===true){ $("select",this).change(function(e){ triggerSearch(); return false; }); } }); } else { // sopt to construct the values if($t.sopt.value) { var so = $t.sopt.value.split(";"), sv, ov; var elem = document.createElement("select"); $(elem).attr({name:$t.name, id: "sg_"+$t.name}).attr($t.sopt); for(var k=0; k<so.length;k++){ sv = so[k].split(":"); ov = document.createElement("option"); ov.value = sv[0]; ov.innerHTML = sv[1]; if (sv[1]==$t.defval) ov.selected ="selected"; elem.appendChild(ov); } if(self.p.gridToolbar===true && $t.width) { $(elem).width($t.width); } $(td).append(elem); if(self.p.autosearch===true){ $(elem).change(function(e){ triggerSearch(); return false; }); } } } break; case 'text': var df = this.defval ? this.defval: ""; $(td).append("<input type='text' name='"+this.name+"' id='sg_"+this.name+"' value='"+df+"'/>"); if($t.sopt) $("input",td).attr($t.sopt); if(self.p.gridToolbar===true && $t.width) { if($.browser.msie) { $("input",td).width($t.width-4); } else { $("input",td).width($t.width-2); } } if(self.p.autosearch===true){ $("input",td).keypress(function(e){ var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; if(key == 13){ triggerSearch(); return false; } return this; }); } break; } if(self.p.formtype=='horizontal'){ if(self.p.grodToolbar===true && self.p.gridNames===false) { $(tr).append(td); } else { $(tr).append(tl).append(td); } $(tr).append(td); } else { tr1 = document.createElement("tr"); $(tr1).append(tl).append(td); $(tbl).append(tr1); } }); td = document.createElement("td"); if(self.p.enableSearch === true){ sb = "<input type='button' id='sButton' class='"+self.p.buttonclass+"' value='"+self.p.searchButton+"'/>"; $(td).append(sb); $("input#sButton",td).click(function(){ triggerSearch(); return false; }); } if(self.p.enableClear === true) { cb = "<input type='button' id='cButton' class='"+self.p.buttonclass+"' value='"+self.p.clearButton+"'/>"; $(td).append(cb); $("input#cButton",td).click(function(){ clearSearch(); return false; }); } if(self.p.enableClear === true || self.p.enableSearch === true) { if(self.p.formtype=='horizontal') { $(tr).append(td); } else { tr1 = document.createElement("tr"); $(tr1).append("<td>&nbsp;</td>").append(td); $(tbl).append(tr1); } } }; var frm = $("<form name='SearchForm' style=display:inline;' class='"+this.p.formclass+"'></form>"); var tbl =$("<table class='"+this.p.tableclass+"' cellspacing='0' cellpading='0' border='0'><tbody></tbody></table>"); $(frm).append(tbl); formFill(); $(this).append(frm); this.triggerSearch = function () {triggerSearch();}; this.clearSearch = function () {clearSearch();}; }); } }); })(jQuery); ;(function($){ /** * jqGrid extension * Paul Tiseo ptiseo@wasteconsultants.com * * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ getPostData : function(){ var $t = this[0]; if(!$t.grid) { return; } return $t.p.postData; }, setPostData : function( newdata ) { var $t = this[0]; if(!$t.grid) { return; } // check if newdata is correct type if ( typeof(newdata) === 'object' ) { $t.p.postData = newdata; } else { alert("Error: cannot add a non-object postData value. postData unchanged."); } }, appendPostData : function( newdata ) { var $t = this[0]; if(!$t.grid) { return; } // check if newdata is correct type if ( typeof(newdata) === 'object' ) { $.extend($t.p.postData, newdata); } else { alert("Error: cannot append a non-object postData value. postData unchanged."); } }, setPostDataItem : function( key, val ) { var $t = this[0]; if(!$t.grid) { return; } $t.p.postData[key] = val; }, getPostDataItem : function( key ) { var $t = this[0]; if(!$t.grid) { return; } return $t.p.postData[key]; }, removePostDataItem : function( key ) { var $t = this[0]; if(!$t.grid) { return; } delete $t.p.postData[key]; }, getUserData : function(){ var $t = this[0]; if(!$t.grid) { return; } return $t.p.userData; }, getUserDataItem : function( key ) { var $t = this[0]; if(!$t.grid) { return; } return $t.p.userData[key]; } }); })(jQuery); ;(function($){ /** * jqGrid extension for manipulating columns properties * Piotr Roznicki roznicki@o2.pl * http://www.roznicki.prv.pl * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ setColumns : function(p) { p = $.extend({ top : 0, left: 0, width: 200, height: 195, modal: false, drag: true, closeicon: 'ico-close.gif', beforeShowForm: null, afterShowForm: null, afterSubmitForm: null }, $.jgrid.col, p ||{}); return this.each(function(){ var $t = this; if (!$t.grid ) { return; } var onBeforeShow = typeof p.beforeShowForm === 'function' ? true: false; var onAfterShow = typeof p.afterShowForm === 'function' ? true: false; var onAfterSubmit = typeof p.afterSubmitForm === 'function' ? true: false; if(!p.imgpath) { p.imgpath= $t.p.imgpath; } // Added From Tony Tomov var gID = $("table:first",$t.grid.bDiv).attr("id"); var IDs = {themodal:'colmod'+gID,modalhead:'colhd'+gID,modalcontent:'colcnt'+gID}; var dtbl = "ColTbl_"+gID; if ( $("#"+IDs.themodal).html() != null ) { if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); } viewModal("#"+IDs.themodal,{modal:p.modal}); if(onAfterShow) { p.afterShowForm($("#"+dtbl)); } } else { var tbl =$("<table id='"+dtbl+"' class='ColTable'><tbody></tbody></table>"); for(i=0;i<this.p.colNames.length;i++){ if(!$t.p.colModel[i].hidedlg) { // added from T. Tomov $(tbl).append("<tr><td ><input type='checkbox' id='col_" + this.p.colModel[i].name + "' class='cbox' value='T' " + ((this.p.colModel[i].hidden==undefined)?"checked":"") + "/>" + "<label for='col_" + this.p.colModel[i].name + "'>" + this.p.colNames[i] + "(" + this.p.colModel[i].name + ")</label></td></tr>"); } } var bS ="<input id='dData' type='button' value='"+p.bSubmit+"'/>"; var bC ="<input id='eData' type='button' value='"+p.bCancel+"'/>"; $(tbl).append("<tr><td class='ColButton'>"+bS+"&nbsp;"+bC+"</td></tr>"); createModal(IDs,tbl,p,$t.grid.hDiv,$t.grid.hDiv); if( p.drag) { DnRModal("#"+IDs.themodal,"#"+IDs.modalhead+" td.modaltext"); } $("#dData","#"+dtbl).click(function(e){ for(i=0;i<$t.p.colModel.length;i++){ if(!$t.p.colModel[i].hidedlg) { // added from T. Tomov if($("#col_" + $t.p.colModel[i].name).attr("checked")) { $($t).showCol($t.p.colModel[i].name); $("#col_" + $t.p.colModel[i].name).attr("defaultChecked",true); // Added from T. Tomov IE BUG } else { $($t).hideCol($t.p.colModel[i].name); $("#col_" + $t.p.colModel[i].name).attr("defaultChecked",""); // Added from T. Tomov IE BUG } } } $("#"+IDs.themodal).jqmHide(); if (onAfterSubmit) { p.afterSubmitForm($("#"+dtbl)); } return false; }); $("#eData", "#"+dtbl).click(function(e){ $("#"+IDs.themodal).jqmHide(); return false; }); if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); } viewModal("#"+IDs.themodal,{modal:p.modal}); if(onAfterShow) { p.afterShowForm($("#"+dtbl)); } } }); } }); })(jQuery); ;(function($){ /** * jqGrid extension for SubGrid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.addSubGrid = function(t,row,pos,rowelem) { return this.each(function(){ var ts = this; if (!ts.grid ) { return; } var td, res,_id, pID; td = document.createElement("td"); $(td,t).html("<img src='"+ts.p.imgpath+"plus.gif'/>") .toggle( function(e) { $(this).html("<img src='"+ts.p.imgpath+"minus.gif'/>"); pID = $("table:first",ts.grid.bDiv).attr("id"); res = $(this).parent(); var atd= pos==1?'<td></td>':''; _id = $(res).attr("id"); var nhc = 0; $.each(ts.p.colModel,function(i,v){ if(this.hidden === true) {nhc++;} }); var subdata = "<tr class='subgrid'>"+atd+"<td><img src='"+ts.p.imgpath+"line3.gif'/></td><td colspan='"+parseInt(ts.p.colNames.length-1-nhc)+"'><div id="+pID+"_"+_id+" class='tablediv'>"; $(this).parent().after( subdata+ "</div></td></tr>" ); $(".tablediv",ts).css("width", ts.grid.width-20+"px"); if( typeof ts.p.subGridRowExpanded === 'function') { ts.p.subGridRowExpanded(pID+"_"+ _id,_id); } else { populatesubgrid(res); } }, function(e) { if( typeof ts.p.subGridRowColapsed === 'function') { res = $(this).parent(); _id = $(res).attr("id"); ts.p.subGridRowColapsed(pID+"_"+_id,_id ); }; $(this).parent().next().remove(".subgrid"); $(this).html("<img src='"+ts.p.imgpath+"plus.gif'/>"); }); row.appendChild(td); //------------------------- var populatesubgrid = function( rd ) { var res,sid,dp; sid = $(rd).attr("id"); dp = {id:sid}; if(!ts.p.subGridModel[0]) { return false; } if(ts.p.subGridModel[0].params) { for(var j=0; j < ts.p.subGridModel[0].params.length; j++) { for(var i=0; i<ts.p.colModel.length; i++) { if(ts.p.colModel[i].name == ts.p.subGridModel[0].params[j]) { dp[ts.p.colModel[i].name]= $("td:eq("+i+")",rd).text().replace(/\&nbsp\;/ig,''); } } } } if(!ts.grid.hDiv.loading) { ts.grid.hDiv.loading = true; $("div.loading",ts.grid.hDiv).fadeIn("fast"); switch(ts.p.datatype) { case "xml": $.ajax({type:ts.p.mtype, url: ts.p.subGridUrl, dataType:"xml",data: dp, complete: function(sxml) { subGridJXml(sxml.responseXML, sid); } }); break; case "json": $.ajax({type:ts.p.mtype, url: ts.p.subGridUrl, dataType:"json",data: dp, complete: function(JSON) { res = subGridJXml(JSON,sid); } }); break; } } return false; }; var subGridCell = function(trdiv,cell,pos){ var tddiv; tddiv = document.createElement("div"); tddiv.className = "celldiv"; $(tddiv).html(cell); $(tddiv).width( ts.p.subGridModel[0].width[pos] || 80); trdiv.appendChild(tddiv); }; var subGridJXml = function(sjxml, sbid){ var trdiv, tddiv,result = "", i,cur, sgmap; var dummy = document.createElement("span"); trdiv = document.createElement("div"); trdiv.className="rowdiv"; for (i = 0; i<ts.p.subGridModel[0].name.length; i++) { tddiv = document.createElement("div"); tddiv.className = "celldivth"; $(tddiv).html(ts.p.subGridModel[0].name[i]); $(tddiv).width( ts.p.subGridModel[0].width[i]); trdiv.appendChild(tddiv); } dummy.appendChild(trdiv); if (sjxml){ if(ts.p.datatype === "xml") { sgmap = ts.p.xmlReader.subgrid; $(sgmap.root+">"+sgmap.row, sjxml).each( function(){ trdiv = document.createElement("div"); trdiv.className="rowdiv"; if(sgmap.repeatitems === true) { $(sgmap.cell,this).each( function(i) { subGridCell(trdiv, this.textContent || this.text || '&nbsp;',i); }); } else { var f = ts.p.subGridModel[0].mapping; if (f) { for (i=0;i<f.length;i++) { subGridCell(trdiv, $(f[i],this).text() || '&nbsp;',i); } } } dummy.appendChild(trdiv); }); } else { sjxml = eval("("+sjxml.responseText+")"); sgmap = ts.p.jsonReader.subgrid; for (i=0;i<sjxml[sgmap.root].length;i++) { cur = sjxml[sgmap.root][i]; trdiv = document.createElement("div"); trdiv.className="rowdiv"; if(sgmap.repeatitems === true) { if(sgmap.cell) { cur=cur[sgmap.cell]; } for (var j=0;j<cur.length;j++) { subGridCell(trdiv, cur[j] || '&nbsp;',j); } } else { var f = ts.p.subGridModel[0].mapping; if(f.length) { for (var j=0;j<f.length;j++) { subGridCell(trdiv, cur[f[j]] || '&nbsp;',j); } } } dummy.appendChild(trdiv); } } var pID = $("table:first",ts.grid.bDiv).attr("id")+"_"; $("#"+pID+sbid).append($(dummy).html()); sjxml = null; ts.grid.hDiv.loading = false; $("div.loading",ts.grid.hDiv).fadeOut("fast"); } return false; } }); }; })(jQuery); /* Transform a table to a jqGrid. Peter Romianowski <peter.romianowski@optivo.de> If the first column of the table contains checkboxes or radiobuttons then the jqGrid is made selectable. */ // Addition - selector can be a class or id function tableToGrid(selector) { $(selector).each(function() { if(this.grid) {return;} //Adedd from Tony Tomov // This is a small "hack" to make the width of the jqGrid 100% $(this).width("99%"); var w = $(this).width(); // Text whether we have single or multi select var inputCheckbox = $('input[type=checkbox]:first', $(this)); var inputRadio = $('input[type=radio]:first', $(this)); var selectMultiple = inputCheckbox.length > 0; var selectSingle = !selectMultiple && inputRadio.length > 0; var selectable = selectMultiple || selectSingle; var inputName = inputCheckbox.attr("name") || inputRadio.attr("name"); // Build up the columnModel and the data var colModel = []; var colNames = []; $('th', $(this)).each(function() { if (colModel.length == 0 && selectable) { colModel.push({ name: '__selection__', index: '__selection__', width: 0, hidden: true }); colNames.push('__selection__'); } else { colModel.push({ name: $(this).html(), index: $(this).html(), width: $(this).width() || 150 }); colNames.push($(this).html()); } }); var data = []; var rowIds = []; var rowChecked = []; $('tbody > tr', $(this)).each(function() { var row = {}; var rowPos = 0; data.push(row); $('td', $(this)).each(function() { if (rowPos == 0 && selectable) { var input = $('input', $(this)); var rowId = input.attr("value"); rowIds.push(rowId || data.length); if (input.attr("checked")) { rowChecked.push(rowId); } row[colModel[rowPos].name] = input.attr("value"); } else { row[colModel[rowPos].name] = $(this).html(); } rowPos++; }); }); // Clear the original HTML table $(this).empty(); // Mark it as jqGrid $(this).addClass("scroll"); $(this).jqGrid({ datatype: "local", width: w, colNames: colNames, colModel: colModel, multiselect: selectMultiple //inputName: inputName, //inputValueCol: imputName != null ? "__selection__" : null }); // Add data for (var a = 0; a < data.length; a++) { var id = null; if (rowIds.length > 0) { id = rowIds[a]; if (id && id.replace) { // We have to do this since the value of a checkbox // or radio button can be anything id = encodeURIComponent(id).replace(/[.\-%]/g, "_"); } } if (id == null) { id = a + 1; } $(this).addRowData(id, data[a]); } // Set the selection for (var a = 0; a < rowChecked.length; a++) { $(this).setSelection(rowChecked[a]); } }); }; ;(function($) { /* ** * jqGrid extension - Tree Grid * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ setTreeNode : function(rd, row){ return this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } var expCol=0,i=0; if(!$t.p.expColInd) { for (var key in $t.p.colModel){ if($t.p.colModel[key].name == $t.p.ExpandColumn) { expCol = i; $t.p.expColInd = expCol; break; } i++; } if(!$t.p.expColInd ) {$t.p.expColInd = expCol;} } else { expCol = $t.p.expColInd; } var level = $t.p.treeReader.level_field; var expanded = $t.p.treeReader.expanded_field; var isLeaf = $t.p.treeReader.leaf_field; row.lft = rd[$t.p.treeReader.left_field]; row.rgt = rd[$t.p.treeReader.right_field]; row.level = rd[level]; if(!rd[isLeaf]) { // NS Model rd[isLeaf] = (parseInt(row.rgt,10) === parseInt(row.lft,10)+1) ? 'true' : 'false'; } var curExpand = (rd[expanded] && rd[expanded] == "true") ? true : false; var curLevel = parseInt(row.level,10); var ident,lftpos; if($t.p.tree_root_level === 0) { ident = curLevel+1; lftpos = curLevel; } else { ident = curLevel; lftpos = curLevel -1; } var twrap = document.createElement("div"); $(twrap).addClass("tree-wrap").width(ident*18); var treeimg = document.createElement("div"); $(treeimg).css("left",lftpos*18); twrap.appendChild(treeimg); if(rd[isLeaf] == "true") { $(treeimg).addClass("tree-leaf"); row.isLeaf = true; } else { if(rd[expanded] == "true") { $(treeimg).addClass("tree-minus treeclick"); row.expanded = true; } else { $(treeimg).addClass("tree-plus treeclick"); row.expanded = false; } } if(parseInt(rd[level],10) !== parseInt($t.p.tree_root_level,10)) { if(!$($t).isVisibleNode(row)){ $(row).css("display","none"); } } var mhtm = $("td:eq("+expCol+")",row).html(); var thecell = $("td:eq("+expCol+")",row).html("<span>"+mhtm+"</span>").prepend(twrap); $(".treeclick",thecell).click(function(e){ var target = e.target || e.srcElement; var ind =$(target,$t.rows).parents("tr:first")[0].rowIndex; if(!$t.rows[ind].isLeaf){ if($t.rows[ind].expanded){ $($t).collapseRow($t.rows[ind]); $($t).collapseNode($t.rows[ind]); } else { $($t).expandRow($t.rows[ind]); $($t).expandNode($t.rows[ind]); } } e.stopPropagation(); }); }); }, expandRow: function (record){ this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } var childern = $($t).getNodeChildren(record); //if ($($t).isVisibleNode(record)) { $(childern).each(function(i){ $(this).css("display",""); if(this.expanded) { $($t).expandRow(this); } }); //} }); }, collapseRow : function (record) { this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } var childern = $($t).getNodeChildren(record); $(childern).each(function(i){ $(this).css("display","none"); $($t).collapseRow(this); }); }); }, // NS model getRootNodes : function() { var result = []; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } $($t.rows).each(function(i){ if(parseInt(this.level,10) === parseInt($t.p.tree_root_level,10)) { result.push(this); } }); }); return result; }, getNodeDepth : function(rc) { var ret = null; this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } ret = parseInt(rc.level,10) - parseInt(this.p.tree_root_level,10); }); return ret; }, getNodeParent : function(rc) { var result = null; this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } var lft = parseInt(rc.lft,10), rgt = parseInt(rc.rgt,10), level = parseInt(rc.level,10); $(this.rows).each(function(){ if(parseInt(this.level,10) === level-1 && parseInt(this.lft) < lft && parseInt(this.rgt) > rgt) { result = this; return false; } }); }); return result; }, getNodeChildren : function(rc) { var result = []; this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } var lft = parseInt(rc.lft,10), rgt = parseInt(rc.rgt,10), level = parseInt(rc.level,10); var ind = rc.rowIndex; $(this.rows).slice(1).each(function(i){ if(parseInt(this.level,10) === level+1 && parseInt(this.lft,10) > lft && parseInt(this.rgt,10) < rgt) { result.push(this); } }); }); return result; }, // End NS Model getNodeAncestors : function(rc) { var ancestors = []; this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } var parent = $(this).getNodeParent(rc); while (parent) { ancestors.push(parent); parent = $(this).getNodeParent(parent); } }); return ancestors; }, isVisibleNode : function(rc) { var result = true; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } var ancestors = $($t).getNodeAncestors(rc); $(ancestors).each(function(){ result = result && this.expanded; if(!result) {return false;} }); }); return result; }, isNodeLoaded : function(rc) { var result; this.each(function(){ var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } if(rc.loaded !== undefined) { result = rc.loaded; } else if( rc.isLeaf || $($t).getNodeChildren(rc).length > 0){ result = true; } else { result = false; } }); return result; }, expandNode : function(rc) { return this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } if(!rc.expanded) { if( $(this).isNodeLoaded(rc) ) { rc.expanded = true; $("div.treeclick",rc).removeClass("tree-plus").addClass("tree-minus"); } else { rc.expanded = true; $("div.treeclick",rc).removeClass("tree-plus").addClass("tree-minus"); this.p.treeANode = rc.rowIndex; this.p.datatype = this.p.treedatatype; $(this).setGridParam({postData:{nodeid:rc.id,n_left:rc.lft,n_right:rc.rgt,n_level:rc.level}}); $(this).trigger("reloadGrid"); this.treeANode = 0; $(this).setGridParam({postData:{nodeid:'',n_left:'',n_right:'',n_level:''}}) } } }); }, collapseNode : function(rc) { return this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } if(rc.expanded) { rc.expanded = false; $("div.treeclick",rc).removeClass("tree-minus").addClass("tree-plus"); } }); }, SortTree : function( newDir) { return this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } var i, len, rec, records = [], roots = $(this).getRootNodes(); // Sorting roots roots.sort(function(a, b) { if (a.sortKey < b.sortKey) {return -newDir;} if (a.sortKey > b.sortKey) {return newDir;} return 0; }); // Sorting children for (i = 0, len = roots.length; i < len; i++) { rec = roots[i]; records.push(rec); $(this).collectChildrenSortTree(records, rec, newDir); } var $t = this; $.each(records, function(index, row) { $('tbody',$t.grid.bDiv).append(row); row.sortKey = null; }); }); }, collectChildrenSortTree : function(records, rec, newDir) { return this.each(function(){ if(!this.grid || !this.p.treeGrid) { return; } var i, len, child, children = $(this).getNodeChildren(rec); children.sort(function(a, b) { if (a.sortKey < b.sortKey) {return -newDir;} if (a.sortKey > b.sortKey) {return newDir;} return 0; }); for (i = 0, len = children.length; i < len; i++) { child = children[i]; records.push(child); $(this).collectChildrenSortTree(records, child,newDir); } }); }, // experimental setTreeRow : function(rowid, data) { var nm, success=false; this.each(function(){ var t = this; if(!t.grid || !t.p.treeGrid) { return false; } if( data ) { var ind = $(t).getInd(t.rows,rowid); if(!ind) {return success;} success=true; $(this.p.colModel).each(function(i){ nm = this.name; if(data[nm] !== 'undefined') { if(nm == t.p.ExpandColumn && t.p.treeGrid===true) { $("td:eq("+i+") > span:first",t.rows[ind]).html(data[nm]); } else { $("td:eq("+i+")",t.rows[ind]).html(data[nm]); } success = true; } }); } }); return success; }, delTreeNode : function (rowid) { return this.each(function () { var $t = this; if(!$t.grid || !$t.p.treeGrid) { return; } var rc = $($t).getInd($t.rows,rowid,true); if (rc) { var dr = $($t).getNodeChildren(rc); if(dr.length>0){ for (var i=0;i<dr.length;i++){ $($t).delRowData(dr[i].id); } } $($t).delRowData(rc.id); } }); } }); })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/gridall.js
JavaScript
gpl2
148,966
;(function($){ /** * jqGrid (fi) Finnish Translation * Jukka Inkeri awot.fi * http://awot.fi * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "Rivej&auml;", loadtext: "Haetaan...", pgtext : "/" }; $.jgrid.search = { caption: "Etsi...", Find: "Etsi", Reset: "Tyhj&auml;&auml;", odata : ['=', '<>', '<', '<=','>','>=', 'alkaa','loppuu','sis&auml;t&auml;&auml;' ] }; $.jgrid.edit = { addCaption: "Uusi rivi", editCaption: "Muokkaa rivi", bSubmit: "OK", bCancel: "Peru", bClose: "Sulje", processData: "Suoritetaan...", msg: { required:"pakollinen", number:"Anna kelvollinen nro", minValue:"arvo oltava >= ", maxValue:"arvo oltava <= ", email: "virheellinen sposti ", integer: "Anna kelvollinen kokonaisluku", date: "Anna kelvollinen pvm" } }; $.jgrid.del = { caption: "Poista", msg: "Poista valitut rivi(t)?", bSubmit: "Poista", bCancel: "Peru", processData: "Suoritetaan..." }; $.jgrid.nav = { edittext: " ", edittitle: "Muokkaa valittu rivi", addtext:" ", addtitle: "Uusi rivi", deltext: " ", deltitle: "Poista valittu rivi", searchtext: " ", searchtitle: "Etsi tietoja", refreshtext: "", refreshtitle: "Lataa uudelleen", alertcap: "Varoitus", alerttext: "Valitse rivi" }; // setcolumns module $.jgrid.col ={ caption: "Nayta/Piilota sarakkeet", bSubmit: "OK", bCancel: "Peru" }; $.jgrid.errors = { errcap : "Virhe", nourl : "url asettamatta", norecords: "Ei muokattavia tietoja", model : "Pituus colNames <> colModel!" }; $.jgrid.formatter = { integer : {thousandsSeparator: "", defaulValue: 0}, number : {decimalSeparator:",", thousandsSeparator: "", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:",", thousandsSeparator: "", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Su", "Ma", "Ti", "Ke", "To", "Pe", "La", "Sunnuntai", "Maanantai", "Tiista", "Keskiviikko", "Torstai", "Perjantai", "Lauantai" ], monthNames: [ "Tam", "Hel", "Maa", "Huh", "Tou", "Kes", "Hei", "Elo", "Syy", "Lok", "Mar", "Jou", "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kes&auml;kuu", "Hein&auml;kuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu" ], AmPm : ["am","pm","AM","PM"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'}, srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "d.m.Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'nayta' }; // FI })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-fi.js
JavaScript
gpl2
3,287
function jqGridInclude() { var pathtojsfiles = "js/"; // need to be ajusted // set include to false if you do not want some modules to be included var combineIntoOne = false; var combinedInclude = new Array(); var combinedIncludeURL = "combine.php?type=javascript&files="; var minver = true; var modules = [ { include: true, incfile:'grid.locale-en.js',minfile: 'min/grid.locale-en-min.js'}, // jqGrid translation /* { include: true, incfile:'grid.pack.js',minfile: ''}, */ // jqGrid all packecd { include: true, incfile:'grid.base.js',minfile: 'min/grid.base-min.js'}, // jqGrid base { include: true, incfile:'grid.common.js',minfile: 'min/grid.common-min.js' }, // jqGrid common for editing { include: true, incfile:'grid.formedit.js',minfile: 'min/grid.formedit-min.js' }, // jqGrid Form editing { include: true, incfile:'grid.inlinedit.js',minfile: 'min/grid.inlinedit-min.js' }, // jqGrid inline editing { include: true, incfile:'grid.celledit.js',minfile: 'min/grid.celledit-min.js' }, // jqGrid cell editing { include: true, incfile:'grid.subgrid.js',minfile: 'min/grid.subgrid-min.js'}, //jqGrid subgrid { include: true, incfile:'grid.treegrid.js',minfile: 'min/grid.treegrid-min.js'}, //jqGrid treegrid { include: true, incfile:'grid.custom.js',minfile: 'min/grid.custom-min.js'}, //jqGrid custom { include: true, incfile:'grid.postext.js',minfile: 'min/grid.postext-min.js'}, //jqGrid postext { include: true, incfile:'grid.tbltogrid.js',minfile: 'min/grid.tbltogrid-min.js'}, //jqGrid table to grid { include: true, incfile:'grid.setcolumns.js',minfile: 'min/grid.setcolumns-min.js'}, //jqGrid setcolumns { include: true, incfile:'grid.import.js',minfile: 'min/grid.import-min.js'}, //jqGrid import { include: true, incfile:'jquery.fmatter.js',minfile: 'min/jquery.fmatter-min.js'}, //jqGrid formater { include: true, incfile:'json2.js',minfile: 'min/json2-min.js'}, //json utils { include: true, incfile:'JsonXml.js',minfile: 'min/JsonXml-min.js'} //xmljson utils ]; var filename; for(var i=0;i<modules.length; i++) { if(modules[i].include === true) { if (minver !== true) filename = pathtojsfiles+modules[i].incfile; else filename = pathtojsfiles+modules[i].minfile; if (combineIntoOne !== true) { if(jQuery.browser.safari || jQuery.browser.msie ) { jQuery.ajax({url:filename,dataType:'script', async:false, cache: true}); } else { IncludeJavaScript(filename); } } else { combinedInclude[combinedInclude.length] = filename; } } } if ((combineIntoOne === true) && (combinedInclude.length>0) ) { var fileList = implode(",",combinedInclude); IncludeJavaScript(combinedIncludeURL+fileList); } function implode( glue, pieces ) { // http://kevin.vanzonneveld.net //original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) //example 1: implode(' ', ['Kevin', 'van', 'Zonneveld']); //returns 1: 'Kevin van Zonneveld' return ( ( pieces instanceof Array ) ? pieces.join ( glue ) : pieces ); }; function IncludeJavaScript(jsFile) { var oHead = document.getElementsByTagName('head')[0]; var oScript = document.createElement('script'); oScript.type = 'text/javascript'; oScript.src = jsFile; oHead.appendChild(oScript); }; }; jqGridInclude();
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/jquery.jqGrid.js
JavaScript
gpl2
3,633
/* jQuery UI Date Picker v3.0 - previously jQuery Calendar Written by Marc Grabanski (m@marcgrabanski.com) and Keith Wood (kbwood@iprimus.com.au). Copyright (c) 2007 Marc Grabanski (http://marcgrabanski.com/code/ui-datepicker) Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. Date: 09-03-2007 */ /* Date picker manager. Use the singleton instance of this class, $.datepicker, to interact with the date picker. Settings for (groups of) date pickers are maintained in an instance object (DatepickerInstance), allowing multiple different settings on the same page. */ (function($) { // hide the namespace function Datepicker() { this.debug = false; // Change this to true to start debugging this._nextId = 0; // Next ID for a date picker instance this._inst = []; // List of instances indexed by ID this._curInst = null; // The current instance in use this._disabledInputs = []; // List of date picker inputs that have been disabled this._datepickerShowing = false; // True if the popup picker is showing , false if not this._inDialog = false; // True if showing within a "dialog", false if not this.regional = []; // Available regional settings, indexed by language code this.regional[''] = { // Default regional settings clearText: 'Clear', // Display text for clear link closeText: 'Close', // Display text for close link prevText: '&lt;Prev', // Display text for previous month link nextText: 'Next&gt;', // Display text for next month link currentText: 'Today', // Display text for current month link dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Names of days starting at Sunday dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], weekHeader: 'Wk', // Header for the week of the year column monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], monthNames: ['January','February','March','April','May','June', 'July','August','September','October','November','December'], // Names of months dateFormat: 'mm/dd/yy', // See format options on parseDate firstDay: 0 // The first day of the week, Sun = 0, Mon = 1, ... }; this._defaults = { // Global defaults for all the date picker instances showOn: 'focus', // 'focus' for popup on focus, // 'button' for trigger button, or 'both' for either defaultDate: null, // Used when field is blank: actual date, // +/-number for offset from today, null for today appendText: '', // Display text following the input box, e.g. showing the format buttonText: '...', // Text for trigger button buttonImage: '', // URL for trigger button image buttonImageOnly: false, // True if the image appears alone, false if it appears on a button closeAtTop: true, // True to have the clear/close at the top, // false to have them at the bottom hideIfNoPrevNext: false, // True to hide next/previous month links // if not applicable, false to just disable them changeMonth: true, // True if month can be selected directly, false if only prev/next changeYear: true, // True if year can be selected directly, false if only prev/next yearRange: '-10:+10', // Range of years to display in drop-down, // either relative to current year (-nn:+nn) or absolute (nnnn:nnnn) changeFirstDay: true, // True to click on day name to change, false to remain as set showOtherMonths: false, // True to show dates in other months, false to leave blank showWeeks: false, // True to show week of the year, false to omit calculateWeek: this.iso8601Week, // How to calculate the week of the year, // takes a Date and returns the number of the week for it shortYearCutoff: '+10', // Short year values < this are in the current century, // > this are in the previous century, // string value starting with '+' for current year + value minDate: null, // The earliest selectable date, or null for no limit maxDate: null, // The latest selectable date, or null for no limit speed: 'xfast', // Speed of display/closure beforeShowDay: null, // Function that takes a date and returns an array with // [0] = true if selectable, false if not, // [1] = custom CSS class name(s) or '', e.g. $.datepicker.noWeekends beforeShow: null, // Function that takes an input field and // returns a set of custom settings for the date picker onSelect: null, // Define a callback function when a date is selected numberOfMonths: 1, // Number of months to show at a time stepMonths: 1, // Number of months to step back/forward rangeSelect: false, // Allows for selecting a date range on one date picker rangeSeparator: ' - ' // Text between two dates in a range }; $.extend(this._defaults, this.regional['']); this._datepickerDiv = $('<div id="datepicker_div"></div>'); } $.extend(Datepicker.prototype, { /* Class name added to elements to indicate already configured with a date picker. */ markerClassName: 'hasDatepicker', /* Debug logging (if enabled). */ log: function () { if (this.debug) { console.log.apply('', arguments); } }, /* Register a new date picker instance - with custom settings. */ _register: function(inst) { var id = this._nextId++; this._inst[id] = inst; return id; }, /* Retrieve a particular date picker instance based on its ID. */ _getInst: function(id) { return this._inst[id] || id; }, /* Override the default settings for all instances of the date picker. @param settings object - the new settings to use as defaults (anonymous object) @return the manager object */ setDefaults: function(settings) { extendRemove(this._defaults, settings || {}); return this; }, /* Handle keystrokes. */ _doKeyDown: function(e) { var inst = $.datepicker._getInst(this._calId); if ($.datepicker._datepickerShowing) { switch (e.keyCode) { case 9: $.datepicker.hideDatepicker(''); break; // hide on tab out case 13: $.datepicker._selectDay(inst, inst._selectedMonth, inst._selectedYear, $('td.datepicker_daysCellOver', inst._datepickerDiv)[0]); break; // select the value on enter case 27: $.datepicker.hideDatepicker(inst._get('speed')); break; // hide on escape case 33: $.datepicker._adjustDate(inst, (e.ctrlKey ? -1 : -inst._get('stepMonths')), (e.ctrlKey ? 'Y' : 'M')); break; // previous month/year on page up/+ ctrl case 34: $.datepicker._adjustDate(inst, (e.ctrlKey ? +1 : +inst._get('stepMonths')), (e.ctrlKey ? 'Y' : 'M')); break; // next month/year on page down/+ ctrl case 35: if (e.ctrlKey) $.datepicker._clearDate(inst); break; // clear on ctrl+end case 36: if (e.ctrlKey) $.datepicker._gotoToday(inst); break; // current on ctrl+home case 37: if (e.ctrlKey) $.datepicker._adjustDate(inst, -1, 'D'); break; // -1 day on ctrl+left case 38: if (e.ctrlKey) $.datepicker._adjustDate(inst, -7, 'D'); break; // -1 week on ctrl+up case 39: if (e.ctrlKey) $.datepicker._adjustDate(inst, +1, 'D'); break; // +1 day on ctrl+right case 40: if (e.ctrlKey) $.datepicker._adjustDate(inst, +7, 'D'); break; // +1 week on ctrl+down } } else if (e.keyCode == 36 && e.ctrlKey) { // display the date picker on ctrl+home $.datepicker.showFor(this); } }, /* Filter entered characters - based on date format. */ _doKeyPress: function(e) { var inst = $.datepicker._getInst(this._calId); var chars = $.datepicker._possibleChars(inst._get('dateFormat')); var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode); return (chr < ' ' || !chars || chars.indexOf(chr) > -1); }, /* Attach the date picker to an input field. */ _connectDatepicker: function(target, inst) { var input = $(target); if (this._hasClass(input, this.markerClassName)) { return; } var appendText = inst._get('appendText'); if (appendText) { input.after('<span class="datepicker_append">' + appendText + '</span>'); } var showOn = inst._get('showOn'); if (showOn == 'focus' || showOn == 'both') { // pop-up date picker when in the marked field input.focus(this.showFor); } if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked var buttonText = inst._get('buttonText'); var buttonImage = inst._get('buttonImage'); var buttonImageOnly = inst._get('buttonImageOnly'); var trigger = $(buttonImageOnly ? '<img class="datepicker_trigger" src="' + buttonImage + '" alt="' + buttonText + '" title="' + buttonText + '"/>' : '<button type="button" class="datepicker_trigger">' + (buttonImage != '' ? '<img src="' + buttonImage + '" alt="' + buttonText + '" title="' + buttonText + '"/>' : buttonText) + '</button>'); input.wrap('<span class="datepicker_wrap"></span>').after(trigger); trigger.click(this.showFor); } input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress); input[0]._calId = inst._id; }, /* Attach an inline date picker to a div. */ _inlineDatepicker: function(target, inst) { var input = $(target); if (this._hasClass(input, this.markerClassName)) { return; } input.addClass(this.markerClassName).append(inst._datepickerDiv); input[0]._calId = inst._id; this._updateDatepicker(inst); inst._datepickerDiv.resize(function() { $.datepicker._inlineShow(inst); }); }, /* Tidy up after displaying the date picker. */ _inlineShow: function(inst) { var numMonths = inst._get('numberOfMonths'); // fix width for dynamic number of date pickers numMonths = (numMonths == null ? 1 : (typeof numMonths == 'number' ? numMonths : numMonths[1])); inst._datepickerDiv.width(numMonths * $('.datepicker', inst._datepickerDiv[0]).width()); }, /* Does this element have a particular class? */ _hasClass: function(element, className) { var classes = element.attr('class'); return (classes && classes.indexOf(className) > -1); }, /* Pop-up the date picker in a "dialog" box. @param dateText string - the initial date to display (in the current format) @param onSelect function - the function(dateText) to call when a date is selected @param settings object - update the dialog date picker instance's settings (anonymous object) @param pos int[2] - coordinates for the dialog's position within the screen or event - with x/y coordinates or leave empty for default (screen centre) @return the manager object */ dialogDatepicker: function(dateText, onSelect, settings, pos) { var inst = this._dialogInst; // internal instance if (!inst) { inst = this._dialogInst = new DatepickerInstance({}, false); this._dialogInput = $('<input type="text" size="1" style="position: absolute; top: -100px;"/>'); this._dialogInput.keydown(this._doKeyDown); $('body').append(this._dialogInput); this._dialogInput[0]._calId = inst._id; } extendRemove(inst._settings, settings || {}); this._dialogInput.val(dateText); this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null); if (!this._pos) { var viewportWidth; var viewportHeight; if (window.innerWidth) { // Mozilla/Netscape/Opera/IE7 viewportWidth = window.innerWidth, viewportHeight = window.innerHeight } else if (document.documentElement && document.documentElement.clientWidth && document.documentElement.clientWidth != 0) { // IE6 standards compliant viewportWidth = document.documentElement.clientWidth, viewportHeight = document.documentElement.clientHeight } else { // older IE viewportWidth = document.getElementsByTagName('body')[0].clientWidth, viewportHeight = document.getElementsByTagName('body')[0].clientHeight } this._pos = // should use actual width/height below [(viewportWidth / 2) - 100, (viewportHeight / 2) - 150]; this._pos[0] += // add the browser scroll position to the x-coord (document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); this._pos[1] += // add the browser scroll position to the y-coord (document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); } // move input on screen for focus, but hidden behind dialog this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px'); inst._settings.onSelect = onSelect; this._inDialog = true; this._datepickerDiv.addClass('datepicker_dialog'); this.showFor(this._dialogInput[0]); if ($.blockUI) { $.blockUI(this._datepickerDiv); } return this; }, /* Enable the input field(s) for entry. @param inputs element - single input field or string - the ID or other jQuery selector of the input field(s) or object - jQuery collection of input fields @return the manager object */ enableFor: function(inputs) { inputs = (inputs.jquery ? inputs : $(inputs)); inputs.each(function() { this.disabled = false; $(this).siblings('button.datepicker_trigger').each(function() { this.disabled = false; }); $(this).siblings('img.datepicker_trigger').css({opacity: '1.0', cursor: ''}); var $this = this; $.datepicker._disabledInputs = $.map($.datepicker._disabledInputs, function(value) { return (value == $this ? null : value); }); // delete entry }); return this; }, /* Disable the input field(s) from entry. @param inputs element - single input field or string - the ID or other jQuery selector of the input field(s) or object - jQuery collection of input fields @return the manager object */ disableFor: function(inputs) { inputs = (inputs.jquery ? inputs : $(inputs)); inputs.each(function() { this.disabled = true; $(this).siblings('button.datepicker_trigger').each(function() { this.disabled = true; }); $(this).siblings('img.datepicker_trigger').css({opacity: '0.5', cursor: 'default'}); var $this = this; $.datepicker._disabledInputs = $.map($.datepicker._disabledInputs, function(value) { return (value == $this ? null : value); }); // delete entry $.datepicker._disabledInputs[$.datepicker._disabledInputs.length] = this; }); return this; }, /* Is the input field disabled? @param input element - single input field or string - the ID or other jQuery selector of the input field or object - jQuery collection of input field @return boolean - true if disabled, false if enabled */ isDisabled: function(input) { input = (input.jquery ? input[0] : (typeof input == 'string' ? $(input)[0] : input)); for (var i = 0; i < $.datepicker._disabledInputs.length; i++) { if ($.datepicker._disabledInputs[i] == input) { return true; } } return false; }, /* Update the settings for a date picker attached to an input field or division. @param control element - the input field or div/span attached to the date picker or string - the ID or other jQuery selector of the input field or object - jQuery object for input field or div/span @param settings object - the new settings to update @return the manager object */ reconfigureFor: function(control, settings) { control = (control.jquery ? control[0] : (typeof control == 'string' ? $(control)[0] : control)); var inst = this._getInst(control._calId); if (inst) { extendRemove(inst._settings, settings || {}); this._updateDatepicker(inst); } return this; }, /* Set the date for a date picker attached to an input field or division. @param control element - the input field or div/span attached to the date picker or string - the ID or other jQuery selector of the input field or object - jQuery object for input field or div/span @param date Date - the new date @param endDate Date - the new end date for a range (optional) @return the manager object */ setDateFor: function(control, date, endDate) { control = (control.jquery ? control[0] : (typeof control == 'string' ? $(control)[0] : control)); var inst = this._getInst(control._calId); if (inst) { inst._setDate(date, endDate); this._updateDatepicker(inst); } return this; }, /* Retrieve the date for a date picker attached to an input field or division. @param control element - the input field or div/span attached to the date picker or string - the ID or other jQuery selector of the input field or object - jQuery object for input field or div/span @return Date - the current date or Date[2] - the current dates for a range*/ getDateFor: function(control) { control = (control.jquery ? control[0] : (typeof control == 'string' ? $(control)[0] : control)); var inst = this._getInst(control._calId); return (inst ? inst._getDate() : null); }, /* Pop-up the date picker for a given input field. @param control element - the input field attached to the date picker or string - the ID or other jQuery selector of the input field or object - jQuery object for input field @return the manager object */ showFor: function(control) { control = (control.jquery ? control[0] : (typeof control == 'string' ? $(control)[0] : control)); var input = (control.nodeName && control.nodeName.toLowerCase() == 'input' ? control : this); if (input.nodeName.toLowerCase() != 'input') { // find from button/image trigger input = $('input', input.parentNode)[0]; } if ($.datepicker._lastInput == input) { // already here return; } if ($.datepicker.isDisabled(input)) { return; } var inst = $.datepicker._getInst(input._calId); var beforeShow = inst._get('beforeShow'); extendRemove(inst._settings, (beforeShow ? beforeShow(input) : {})); $.datepicker.hideDatepicker(''); $.datepicker._lastInput = input; inst._setDateFromField(input); if ($.datepicker._inDialog) { // hide cursor input.value = ''; } if (!$.datepicker._pos) { // position below input $.datepicker._pos = $.datepicker._findPos(input); $.datepicker._pos[1] += input.offsetHeight; // add the height } inst._datepickerDiv.css('position', ($.datepicker._inDialog && $.blockUI ? 'static' : 'absolute')). css('left', $.datepicker._pos[0] + 'px').css('top', $.datepicker._pos[1] + 'px'); $.datepicker._pos = null; $.datepicker._showDatepicker(inst); return this; }, /* Construct and display the date picker. */ _showDatepicker: function(id) { var inst = this._getInst(id); inst._rangeStart = null; this._updateDatepicker(inst); if (!inst._inline) { var speed = inst._get('speed'); var postProcess = function() { $.datepicker._datepickerShowing = true; $.datepicker._afterShow(inst); }; inst._datepickerDiv.show(speed, postProcess); if (speed == '') { postProcess(); } if (inst._input[0].type != 'hidden') { inst._input[0].focus(); } this._curInst = inst; } }, /* Generate the date picker content. */ _updateDatepicker: function(inst) { inst._datepickerDiv.empty().append(inst._generateDatepicker()); if (inst._get('numberOfMonths') != 1) { inst._datepickerDiv.addClass('datepicker_multi'); } else { inst._datepickerDiv.removeClass('datepicker_multi'); } if (inst._input && inst._input[0].type != 'hidden') { inst._input[0].focus(); } return false; }, /* Tidy up after displaying the date picker. */ _afterShow: function(inst) { var numMonths = inst._get('numberOfMonths'); // fix width for dynamic number of date pickers numMonths = (numMonths == null ? 1 : (typeof numMonths == 'number' ? numMonths : numMonths[1])); inst._datepickerDiv.width(numMonths * $('.datepicker', inst._datepickerDiv[0]).width()); if ($.browser.msie) { // fix IE < 7 select problems $('#datepicker_cover').css({width: inst._datepickerDiv.width() + 4, height: inst._datepickerDiv.height() + 4}); } // re-position on screen if necessary var pos = $.datepicker._findPos(inst._input[0]); browserWidth = $(window).width(); if (document.documentElement && (document.documentElement.scrollLeft)) { browserX = document.documentElement.scrollLeft; } else { browserX = document.body.scrollLeft; } // reposition date picker if outside the browser window if ((inst._datepickerDiv.offset().left + inst._datepickerDiv.width()) > (browserWidth + browserX)) { inst._datepickerDiv.css('left', (pos[0] + $(inst._input[0]).width() - inst._datepickerDiv.width()) + 'px'); } browserHeight = $(window).height(); if (document.documentElement && (document.documentElement.scrollTop)) { browserTopY = document.documentElement.scrollTop; } else { browserTopY = document.body.scrollTop; } // reposition date picker if outside the browser window if ((inst._datepickerDiv.offset().top + inst._datepickerDiv.height()) > (browserTopY + browserHeight) ) { inst._datepickerDiv.css('top', (pos[1] - (this._inDialog ? 0 : inst._datepickerDiv.height())) + 'px'); } }, /* Find an object's position on the screen. */ _findPos: function(obj) { while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) { obj = obj.nextSibling; } var curleft = curtop = 0; if (obj && obj.offsetParent) { curleft = obj.offsetLeft; curtop = obj.offsetTop; while (obj = obj.offsetParent) { var origcurleft = curleft; curleft += obj.offsetLeft; if (curleft < 0) { curleft = origcurleft; } curtop += obj.offsetTop; } } return [curleft,curtop]; }, /* Hide the date picker from view. @param speed string - the speed at which to close the date picker @return void */ hideDatepicker: function(speed) { var inst = this._curInst; if (!inst) { return; } var rangeSelect = inst._get('rangeSelect'); if (rangeSelect && this._stayOpen) { this._selectDate(inst, inst._formatDate( inst._currentDay, inst._currentMonth, inst._currentYear)); } this._stayOpen = false; if (this._datepickerShowing) { speed = (speed != null ? speed : inst._get('speed')); inst._datepickerDiv.hide(speed, function() { $.datepicker._tidyDialog(inst); }); if (speed == '') { this._tidyDialog(inst); } this._datepickerShowing = false; this._lastInput = null; inst._settings.prompt = null; if (this._inDialog) { this._dialogInput.css('position', 'absolute'). css('left', '0px').css('top', '-100px'); if ($.blockUI) { $.unblockUI(); $('body').append(this._datepickerDiv); } } this._inDialog = false; } this._curInst = null; }, /* Tidy up after a dialog display. */ _tidyDialog: function(inst) { inst._datepickerDiv.removeClass('datepicker_dialog'); $('.datepicker_prompt', inst._datepickerDiv).remove(); }, /* Close date picker if clicked elsewhere. */ _checkExternalClick: function(event) { if (!$.datepicker._curInst) { return; } var target = $(event.target); if ((target.parents("#datepicker_div").length == 0) && (target.attr('class') != 'datepicker_trigger') && $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) { $.datepicker.hideDatepicker(''); } }, /* Adjust one of the date sub-fields. */ _adjustDate: function(id, offset, period) { var inst = this._getInst(id); inst._adjustDate(offset, period); this._updateDatepicker(inst); }, /* Action for current link. */ _gotoToday: function(id) { var date = new Date(); var inst = this._getInst(id); inst._selectedDay = date.getDate(); inst._selectedMonth = date.getMonth(); inst._selectedYear = date.getFullYear(); this._adjustDate(inst); }, /* Action for selecting a new month/year. */ _selectMonthYear: function(id, select, period) { var inst = this._getInst(id); inst._selectingMonthYear = false; inst[period == 'M' ? '_selectedMonth' : '_selectedYear'] = select.options[select.selectedIndex].value - 0; this._adjustDate(inst); }, /* Restore input focus after not changing month/year. */ _clickMonthYear: function(id) { var inst = this._getInst(id); if (inst._input && inst._selectingMonthYear && !$.browser.msie) { inst._input[0].focus(); } inst._selectingMonthYear = !inst._selectingMonthYear; }, /* Action for changing the first week day. */ _changeFirstDay: function(id, a) { var inst = this._getInst(id); var dayNames = inst._get('dayNames'); var value = a.firstChild.nodeValue; for (var i = 0; i < 7; i++) { if (dayNames[i] == value) { inst._settings.firstDay = i; break; } } this._updateDatepicker(inst); }, /* Action for selecting a day. */ _selectDay: function(id, month, year, td) { if (this._hasClass($(td), 'datepicker_unselectable')) { return; } var inst = this._getInst(id); var rangeSelect = inst._get('rangeSelect'); if (rangeSelect) { if (!this._stayOpen) { $('.datepicker td').removeClass('datepicker_currentDay'); $(td).addClass('datepicker_currentDay'); } this._stayOpen = !this._stayOpen; } inst._currentDay = $('a', td).html(); inst._currentMonth = month; inst._currentYear = year; this._selectDate(id, inst._formatDate( inst._currentDay, inst._currentMonth, inst._currentYear)); if (this._stayOpen) { inst._endDay = inst._endMonth = inst._endYear = null; inst._rangeStart = new Date(inst._currentYear, inst._currentMonth, inst._currentDay); this._updateDatepicker(inst); } else if (rangeSelect) { if (inst._inline) { inst._endDay = inst._currentDay; inst._endMonth = inst._currentMonth; inst._endYear = inst._currentYear; inst._selectedDay = inst._currentDay = inst._rangeStart.getDate(); inst._selectedMonth = inst._currentMonth = inst._rangeStart.getMonth(); inst._selectedYear = inst._currentYear = inst._rangeStart.getFullYear(); inst._rangeStart = null; this._updateDatepicker(inst); } else { inst._rangeStart = null; } } }, /* Erase the input field and hide the date picker. */ _clearDate: function(id) { var inst = this._getInst(id); this._stayOpen = false; inst._rangeStart = null; this._selectDate(inst, ''); }, /* Update the input field with the selected date. */ _selectDate: function(id, dateStr) { var inst = this._getInst(id); dateStr = (dateStr != null ? dateStr : inst._formatDate()); if (inst._rangeStart) { dateStr = inst._formatDate(inst._rangeStart) + inst._get('rangeSeparator') + dateStr; } if (inst._input) { inst._input.val(dateStr); } var onSelect = inst._get('onSelect'); if (onSelect) { onSelect(dateStr, inst); // trigger custom callback } else { inst._input.trigger('change'); // fire the change event } if (inst._inline) { this._updateDatepicker(inst); } else { if (!this._stayOpen) { this.hideDatepicker(inst._get('speed')); } } }, /* Set as beforeShowDay function to prevent selection of weekends. @param date Date - the date to customise @return [boolean, string] - is this date selectable?, what is its CSS class? */ noWeekends: function(date) { var day = date.getDay(); return [(day > 0 && day < 6), '']; }, /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. @param date Date - the date to get the week for @return number - the number of the week within the year that contains this date */ iso8601Week: function(date) { var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()); var firstMon = new Date(checkDate.getFullYear(), 1 - 1, 4); // First week always contains 4 Jan var firstDay = firstMon.getDay() || 7; // Day of week: Mon = 1, ..., Sun = 7 firstMon.setDate(firstMon.getDate() + 1 - firstDay); // Preceding Monday if (firstDay < 4 && checkDate < firstMon) { // Adjust first three days in year if necessary checkDate.setDate(checkDate.getDate() - 3); // Generate for previous year return $.datepicker.iso8601Week(checkDate); } else if (checkDate > new Date(checkDate.getFullYear(), 12 - 1, 28)) { // Check last three days in year firstDay = new Date(checkDate.getFullYear() + 1, 1 - 1, 4).getDay() || 7; if (firstDay > 4 && (checkDate.getDay() || 7) < firstDay - 3) { // Adjust if necessary checkDate.setDate(checkDate.getDate() + 3); // Generate for next year return $.datepicker.iso8601Week(checkDate); } } return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date }, /* Parse a string value into a date object. The format can be combinations of the following: d - day of month (no leading zero) dd - day of month (two digit) D - day name short DD - day name long m - month of year (no leading zero) mm - month of year (two digit) M - month name short MM - month name long y - year (two digit) yy - year (four digit) '...' - literal text '' - single quote @param format String - the expected format of the date @param value String - the date in the above format @param shortYearCutoff Number - the cutoff year for determining the century (optional) @param dayNamesShort String[7] - abbreviated names of the days from Sunday (optional) @param dayNames String[7] - names of the days from Sunday (optional) @param monthNamesShort String[12] - abbreviated names of the months (optional) @param monthNames String[12] - names of the months (optional) @return Date - the extracted date value or null if value is blank */ parseDate: function (format, value, shortYearCutoff, dayNamesShort, dayNames, monthNamesShort, monthNames) { if (format == null || value == null) { throw 'Invalid arguments'; } // format = dateFormats[format] || format; value = (typeof value == 'object' ? value.toString() : value + ''); if (value == '') { return null; } dayNamesShort = dayNamesShort || this._defaults.dayNamesShort; dayNames = dayNames || this._defaults.dayNames; monthNamesShort = monthNamesShort || this._defaults.monthNamesShort; monthNames = monthNames || this._defaults.monthNames; var year = -1; var month = -1; var day = -1; var literal = false; // Check whether a format character is doubled var lookAhead = function(match) { var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); if (matches) { iFormat++; } return matches; }; // Extract a number from the string value var getNumber = function(match) { lookAhead(match); var size = (match == 'y' ? 4 : 2); var num = 0; while (size > 0 && iValue < value.length && value.charAt(iValue) >= '0' && value.charAt(iValue) <= '9') { num = num * 10 + (value.charAt(iValue++) - 0); size--; } if (size == (match == 'y' ? 4 : 2)) { throw 'Missing number at position ' + iValue; } return num; }; // Extract a name from the string value and convert to an index var getName = function(match, shortNames, longNames) { var names = (lookAhead(match) ? longNames : shortNames); var size = 0; for (var j = 0; j < names.length; j++) { size = Math.max(size, names[j].length); } var name = ''; var iInit = iValue; while (size > 0 && iValue < value.length) { name += value.charAt(iValue++); for (var i = 0; i < names.length; i++) { if (name == names[i]) { return i + 1; } } size--; } throw 'Unknown name at position ' + iInit; }; // Confirm that a literal character matches the string value var checkLiteral = function() { if (value.charAt(iValue) != format.charAt(iFormat)) { throw 'Unexpected literal at position ' + iValue; } iValue++; } var iValue = 0; for (var iFormat = 0; iFormat < format.length; iFormat++) { if (literal) { if (format.charAt(iFormat) == '\'' && !lookAhead('\'')) { literal = false; } else { checkLiteral(); } } else { switch (format.charAt(iFormat)) { case 'd': day = getNumber('d'); break; case 'D': getName('D', dayNamesShort, dayNames); break; case 'm': month = getNumber('m'); break; case 'M': month = getName('M', monthNamesShort, monthNames); break; case 'y': year = getNumber('y'); break; case '\'': if (lookAhead('\'')) { checkLiteral(); } else { literal = true; } break; default: checkLiteral(); } } } if (year < 100) { year += new Date().getFullYear() - new Date().getFullYear() % 100 + (year <= shortYearCutoff ? 0 : -100); } var date = new Date(year, month - 1, day) if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day) { throw 'Invalid date'; // E.g. 31/02/* } return date; }, /* Format a date object into a string value. The format can be combinations of the following: d - day of month (no leading zero) dd - day of month (two digit) D - day name short DD - day name long m - month of year (no leading zero) mm - month of year (two digit) M - month name short MM - month name long y - year (two digit) yy - year (four digit) '...' - literal text '' - single quote @param format String - the desired format of the date @param date Date - the date value to format @param dayNamesShort String[7] - abbreviated names of the days from Sunday (optional) @param dayNames String[7] - names of the days from Sunday (optional) @param monthNamesShort String[12] - abbreviated names of the months (optional) @param monthNames String[12] - names of the months (optional) @return String - the date in the above format */ formatDate: function (format, date, dayNamesShort, dayNames, monthNamesShort, monthNames) { if (!date) { return ''; } // format = dateFormats[format] || format; date = date ? new Date(date) : new Date(); dayNamesShort = dayNamesShort || this._defaults.dayNamesShort; dayNames = dayNames || this._defaults.dayNames; monthNamesShort = monthNamesShort || this._defaults.monthNamesShort; monthNames = monthNames || this._defaults.monthNames; // Check whether a format character is doubled var lookAhead = function(match) { var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); if (matches) { iFormat++; } return matches; }; // Format a number, with leading zero if necessary var formatNumber = function(match, value) { return (lookAhead(match) && value < 10 ? '0' : '') + value; }; // Format a name, short or long as requested var formatName = function(match, value, shortNames, longNames) { return (lookAhead(match) ? longNames[value] : shortNames[value]); }; var output = ''; var literal = false; if (date) { for (var iFormat = 0; iFormat < format.length; iFormat++) { if (literal) { if (format.charAt(iFormat) == '\'' && !lookAhead('\'')) { literal = false; } else { output += format.charAt(iFormat); } } else { switch (format.charAt(iFormat)) { case 'd': output += formatNumber('d', date.getDate()); break; case 'D': output += formatName('D', date.getDay(), dayNamesShort, dayNames); break; case 'm': output += formatNumber('m', date.getMonth() + 1); break; case 'M': output += formatName('M', date.getMonth(), monthNamesShort, monthNames); break; case 'y': output += (lookAhead('y') ? date.getFullYear() : (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100); break; case '\'': if (lookAhead('\'')) { output += '\''; } else { literal = true; } break; default: output += format.charAt(iFormat); } } } } return output; }, /* Extract all possible characters from the date format. */ _possibleChars: function (format) { // format = dateFormats[format] || format; var chars = ''; var literal = false; for (var iFormat = 0; iFormat < format.length; iFormat++) { if (literal) { if (format.charAt(iFormat) == '\'' && !lookAhead('\'')) { literal = false; } else { chars += format.charAt(iFormat); } } else { switch (format.charAt(iFormat)) { case 'd': case 'm': case 'y': chars += '0123456789'; break; case 'D': case 'M': return null; // Accept anything case '\'': if (lookAhead('\'')) { chars += '\''; } else { literal = true; } break; default: chars += format.charAt(iFormat); } } } return chars; } }); /* Individualised settings for date picker functionality applied to one or more related inputs. Instances are managed and manipulated through the Datepicker manager. */ function DatepickerInstance(settings, inline) { this._id = $.datepicker._register(this); this._selectedDay = 0; this._selectedMonth = 0; // 0-11 this._selectedYear = 0; // 4-digit year this._input = null; // The attached input field this._inline = inline; // True if showing inline, false if used in a popup this._datepickerDiv = (!inline ? $.datepicker._datepickerDiv : $('<div id="datepicker_div_' + this._id + '" class="datepicker_inline"></div>')); // customise the date picker object - uses manager defaults if not overridden this._settings = extendRemove({}, settings || {}); // clone if (inline) { this._setDate(this._getDefaultDate()); } } $.extend(DatepickerInstance.prototype, { /* Get a setting value, defaulting if necessary. */ _get: function(name) { return (this._settings[name] != null ? this._settings[name] : $.datepicker._defaults[name]); }, /* Parse existing date and initialise date picker. */ _setDateFromField: function(input) { this._input = $(input); var dateFormat = this._get('dateFormat'); var dates = this._input.val().split(this._get('rangeSeparator')); this._endDay = this._endMonth = this._endYear = null; var shortYearCutoff = this._get('shortYearCutoff'); shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff : new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)); var date = this._getDefaultDate(); if (dates.length > 0) { var dayNamesShort = this._get('dayNamesShort'); var dayNames = this._get('dayNames'); var monthNamesShort = this._get('monthNamesShort'); var monthNames = this._get('monthNames'); if (dates.length > 1) { date = $.datepicker.parseDate(dateFormat, dates[1], shortYearCutoff, dayNamesShort, dayNames, monthNamesShort, monthNames) || this._getDefaultDate(); this._endDay = date.getDate(); this._endMonth = date.getMonth(); this._endYear = date.getFullYear(); } try { date = $.datepicker.parseDate(dateFormat, dates[0], shortYearCutoff, dayNamesShort, dayNames, monthNamesShort, monthNames) || this._getDefaultDate(); } catch (e) { $.datepicker.log(e); date = this._getDefaultDate(); } } this._selectedDay = this._currentDay = date.getDate(); this._selectedMonth = this._currentMonth = date.getMonth(); this._selectedYear = this._currentYear = date.getFullYear(); this._adjustDate(); }, /* Retrieve the default date shown on opening. */ _getDefaultDate: function() { var offsetDate = function(offset) { var date = new Date(); date.setDate(date.getDate() + offset); return date; }; var defaultDate = this._get('defaultDate'); return (defaultDate == null ? new Date() : (typeof defaultDate == 'number' ? offsetDate(defaultDate) : defaultDate)); }, /* Set the date(s) directly. */ _setDate: function(date, endDate) { this._selectedDay = this._currentDay = date.getDate(); this._selectedMonth = this._currentMonth = date.getMonth(); this._selectedYear = this._currentYear = date.getFullYear(); if (this._get('rangeSelect')) { if (endDate) { this._endDay = endDate.getDate(); this._endMonth = endDate.getMonth(); this._endYear = endDate.getFullYear(); } else { this._endDay = this._currentDay; this._endMonth = this._currentMonth; this._endYear = this._currentYear; } } this._adjustDate(); }, /* Retrieve the date(s) directly. */ _getDate: function() { var startDate = (!this._currentYear ? null : new Date(this._currentYear, this._currentMonth, this._currentDay)); if (this._get('rangeSelect')) { return [startDate, new Date(this._endYear, this._endMonth, this._endDay)]; } else { return startDate; } }, /* Generate the HTML for the current state of the date picker. */ _generateDatepicker: function() { var today = new Date(); today = new Date(today.getFullYear(), today.getMonth(), today.getDate()); // clear time // build the date picker HTML var controls = '<div class="datepicker_control">' + '<div class="datepicker_clear"><a onclick="jQuery.datepicker._clearDate(' + this._id + ');">' + this._get('clearText') + '</a></div>' + '<div class="datepicker_close"><a onclick="jQuery.datepicker.hideDatepicker();">' + this._get('closeText') + '</a></div></div>'; var prompt = this._get('prompt'); var closeAtTop = this._get('closeAtTop'); var hideIfNoPrevNext = this._get('hideIfNoPrevNext'); var numMonths = this._get('numberOfMonths'); var stepMonths = this._get('stepMonths'); var isMultiMonth = (numMonths != 1); numMonths = (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths)); // controls and links var html = (prompt ? '<div class="datepicker_prompt">' + prompt + '</div>' : '') + (closeAtTop && !this._inline ? controls : '') + '<div class="datepicker_links"><div class="datepicker_prev">' + (this._canAdjustMonth(-1) ? '<a onclick="jQuery.datepicker._adjustDate(' + this._id + ', -' + stepMonths + ', \'M\');">' + this._get('prevText') + '</a>' : (hideIfNoPrevNext ? '' : '<label>' + this._get('prevText') + '</label>')) + '</div>' + (this._isInRange(today) ? '<div class="datepicker_current"><a ' + 'onclick="jQuery.datepicker._gotoToday(' + this._id + ');">' + this._get('currentText') + '</a></div>' : '') + '<div class="datepicker_next">' + (this._canAdjustMonth(+1) ? '<a onclick="jQuery.datepicker._adjustDate(' + this._id + ', +' + stepMonths + ', \'M\');">' + this._get('nextText') + '</a>' : (hideIfNoPrevNext ? '' : '<label>' + this._get('nextText') + '</label>')) + '</div></div>'; var minDate = this._getMinDate(); var maxDate = this._get('maxDate'); var drawMonth = this._selectedMonth; var drawYear = this._selectedYear; var showWeeks = this._get('showWeeks'); for (var row = 0; row < numMonths[0]; row++) { for (var col = 0; col < numMonths[1]; col++) { var selectedDate = new Date(drawYear, drawMonth, this._selectedDay); html += '<div class="datepicker_oneMonth' + (col == 0 ? ' datepicker_newRow' : '') + '">' + this._generateMonthYearHeader(drawMonth, drawYear, minDate, maxDate, selectedDate, row > 0 || col > 0) + // draw month headers '<table class="datepicker" cellpadding="0" cellspacing="0"><thead>' + '<tr class="datepicker_titleRow">' + (showWeeks ? '<td>' + this._get('weekHeader') + '</td>' : ''); var firstDay = this._get('firstDay'); var changeFirstDay = this._get('changeFirstDay'); var dayNamesMin = this._get('dayNamesMin'); var dayNames = this._get('dayNames'); for (var dow = 0; dow < 7; dow++) { // days of the week var day = (dow + firstDay) % 7; html += '<td>' + (!changeFirstDay ? '<span' : '<a onclick="jQuery.datepicker._changeFirstDay(' + this._id + ', this);"') + ' title="' + dayNames[day] + '">' + dayNamesMin[day] + (changeFirstDay ? '</a>' : '</span>') + '</td>'; } html += '</tr></thead><tbody>'; var daysInMonth = this._getDaysInMonth(drawYear, drawMonth); this._selectedDay = Math.min(this._selectedDay, daysInMonth); var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7; var currentDate = new Date(this._currentYear, this._currentMonth, this._currentDay); var endDate = this._endDay ? new Date(this._endYear, this._endMonth, this._endDay) : currentDate; var printDate = new Date(drawYear, drawMonth, 1 - leadDays); var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate var beforeShowDay = this._get('beforeShowDay'); var showOtherMonths = this._get('showOtherMonths'); var calculateWeek = this._get('calculateWeek') || $.datepicker.iso8601Week; for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows html += '<tr class="datepicker_daysRow">' + (showWeeks ? '<td class="datepicker_weekCol">' + calculateWeek(printDate) + '</td>' : ''); for (var dow = 0; dow < 7; dow++) { // create date picker days var daySettings = (beforeShowDay ? beforeShowDay(printDate) : [true, '']); var otherMonth = (printDate.getMonth() != drawMonth); var unselectable = otherMonth || !daySettings[0] || (minDate && printDate < minDate) || (maxDate && printDate > maxDate); html += '<td class="datepicker_daysCell' + ((dow + firstDay + 6) % 7 >= 5 ? ' datepicker_weekEndCell' : '') + // highlight weekends (otherMonth ? ' datepicker_otherMonth' : '') + // highlight days from other months (printDate.getTime() == selectedDate.getTime() && drawMonth == this._selectedMonth ? ' datepicker_daysCellOver' : '') + // highlight selected day (unselectable ? ' datepicker_unselectable' : '') + // highlight unselectable days (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates (printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range ' datepicker_currentDay' : // highlight selected day (printDate.getTime() == today.getTime() ? ' datepicker_today' : ''))) + '"' + // highlight today (if different) (unselectable ? '' : ' onmouseover="jQuery(this).addClass(\'datepicker_daysCellOver\');"' + ' onmouseout="jQuery(this).removeClass(\'datepicker_daysCellOver\');"' + ' onclick="jQuery.datepicker._selectDay(' + this._id + ',' + drawMonth + ',' + drawYear + ', this);"') + '>' + // actions (otherMonth ? (showOtherMonths ? printDate.getDate() : '&nbsp;') : // display for other months (unselectable ? printDate.getDate() : '<a>' + printDate.getDate() + '</a>')) + '</td>'; // display for this month printDate.setDate(printDate.getDate() + 1); } html += '</tr>'; } drawMonth++; if (drawMonth > 11) { drawMonth = 0; drawYear++; } html += '</tbody></table></div>'; } } html += (!closeAtTop && !this._inline ? controls : '') + '<div style="clear: both;"></div>' + (!$.browser.msie ? '' : '<!--[if lte IE 6.5]><iframe src="javascript:false;" class="datepicker_cover"></iframe><![endif]-->'); return html; }, /* Generate the month and year header. */ _generateMonthYearHeader: function(drawMonth, drawYear, minDate, maxDate, selectedDate, secondary) { minDate = (this._rangeStart && minDate && selectedDate < minDate ? selectedDate : minDate); var html = '<div class="datepicker_header">'; // month selection var monthNames = this._get('monthNames'); if (secondary || !this._get('changeMonth')) { html += monthNames[drawMonth] + '&nbsp;'; } else { var inMinYear = (minDate && minDate.getFullYear() == drawYear); var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear); html += '<select class="datepicker_newMonth" ' + 'onchange="jQuery.datepicker._selectMonthYear(' + this._id + ', this, \'M\');" ' + 'onclick="jQuery.datepicker._clickMonthYear(' + this._id + ');">'; for (var month = 0; month < 12; month++) { if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) { html += '<option value="' + month + '"' + (month == drawMonth ? ' selected="selected"' : '') + '>' + monthNames[month] + '</option>'; } } html += '</select>'; } // year selection if (secondary || !this._get('changeYear')) { html += drawYear; } else { // determine range of years to display var years = this._get('yearRange').split(':'); var year = 0; var endYear = 0; if (years.length != 2) { year = drawYear - 10; endYear = drawYear + 10; } else if (years[0].charAt(0) == '+' || years[0].charAt(0) == '-') { year = drawYear + parseInt(years[0], 10); endYear = drawYear + parseInt(years[1], 10); } else { year = parseInt(years[0], 10); endYear = parseInt(years[1], 10); } year = (minDate ? Math.max(year, minDate.getFullYear()) : year); endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); html += '<select class="datepicker_newYear" ' + 'onchange="jQuery.datepicker._selectMonthYear(' + this._id + ', this, \'Y\');" ' + 'onclick="jQuery.datepicker._clickMonthYear(' + this._id + ');">'; for (; year <= endYear; year++) { html += '<option value="' + year + '"' + (year == drawYear ? ' selected="selected"' : '') + '>' + year + '</option>'; } html += '</select>'; } html += '</div>'; // Close datepicker_header return html; }, /* Adjust one of the date sub-fields. */ _adjustDate: function(offset, period) { var year = this._selectedYear + (period == 'Y' ? offset : 0); var month = this._selectedMonth + (period == 'M' ? offset : 0); var day = Math.min(this._selectedDay, this._getDaysInMonth(year, month)) + (period == 'D' ? offset : 0); var date = new Date(year, month, day); // ensure it is within the bounds set var minDate = this._getMinDate(); var maxDate = this._get('maxDate'); date = (minDate && date < minDate ? minDate : date); date = (maxDate && date > maxDate ? maxDate : date); this._selectedDay = date.getDate(); this._selectedMonth = date.getMonth(); this._selectedYear = date.getFullYear(); }, /* Determine the current minimum date - may be overridden for a range. */ _getMinDate: function() { return this._get('minDate') || this._rangeStart; }, /* Find the number of days in a given month. */ _getDaysInMonth: function(year, month) { return 32 - new Date(year, month, 32).getDate(); }, /* Find the day of the week of the first of a month. */ _getFirstDayOfMonth: function(year, month) { return new Date(year, month, 1).getDay(); }, /* Determines if we should allow a "next/prev" month display change. */ _canAdjustMonth: function(offset) { var date = new Date(this._selectedYear, this._selectedMonth + offset, 1); if (offset < 0) { date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); } return this._isInRange(date); }, /* Is the given date in the accepted range? */ _isInRange: function(date) { // during range selection, use minimum of selected date and range start var newMinDate = (!this._rangeStart ? null : new Date(this._selectedYear, this._selectedMonth, this._selectedDay)); newMinDate = (newMinDate && this._rangeStart < newMinDate ? this._rangeStart : newMinDate); var minDate = newMinDate || this._get('minDate'); var maxDate = this._get('maxDate'); return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate)); }, /* Format the given date for display. */ _formatDate: function(day, month, year) { if (!day) { this._currentDay = this._selectedDay; this._currentMonth = this._selectedMonth; this._currentYear = this._selectedYear; } var date = (day ? (typeof day == 'object' ? day : new Date(year, month, day)) : new Date(this._currentYear, this._currentMonth, this._currentDay)); return $.datepicker.formatDate(this._get('dateFormat'), date, this._get('dayNamesShort'), this._get('dayNames'), this._get('monthNamesShort'), this._get('monthNames')); } }); /* jQuery extend now ignores nulls! */ function extendRemove(target, props) { $.extend(target, props); for (var name in props) { if (props[name] == null) { target[name] = null; } } return target; } /* Attach the date picker to a jQuery selection. @param settings object - the new settings to use for this date picker instance (anonymous) @return jQuery object - for chaining further calls */ $.fn.datepicker = function(settings) { return this.each(function() { // check for settings on the control itself - in namespace 'date:' var inlineSettings = null; for (attrName in $.datepicker._defaults) { var attrValue = this.getAttribute('date:' + attrName); if (attrValue) { inlineSettings = inlineSettings || {}; try { inlineSettings[attrName] = eval(attrValue); } catch (err) { inlineSettings[attrName] = attrValue; } } } var nodeName = this.nodeName.toLowerCase(); if (nodeName == 'input') { var instSettings = (inlineSettings ? $.extend($.extend({}, settings || {}), inlineSettings || {}) : settings); // clone and customise var inst = (inst && !inlineSettings ? inst : new DatepickerInstance(instSettings, false)); $.datepicker._connectDatepicker(this, inst); } else if (nodeName == 'div' || nodeName == 'span') { var instSettings = $.extend($.extend({}, settings || {}), inlineSettings || {}); // clone and customise var inst = new DatepickerInstance(instSettings, true); $.datepicker._inlineDatepicker(this, inst); } }); }; /* Initialise the date picker. */ $(document).ready(function() { $.datepicker = new Datepicker(); // singleton instance $(document.body).append($.datepicker._datepickerDiv). mousedown($.datepicker._checkExternalClick); }); })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/ui.datepicker.js
JavaScript
gpl2
54,151
;(function($){ /** * jqGrid Swedish Translation * Anders Nyberg anders.nyberg@alecta.com * http://wwww.alecta.com * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "post(er)", loadtext: "Laddar...", pgtext : "/" }; $.jgrid.search = { caption: "Sök...", Find: "Hitta", Reset: "Återställ", odata : ['lika', 'ej lika', 'mindre', 'mindre eller lika','större','större eller lika', 'börjar med','slutar med','innehåller' ] }; $.jgrid.edit = { addCaption: "Skapa post", editCaption: "Ändra post", bSubmit: "Utför", bCancel: "Avbryt", bClose: "Stäng", processData: "Processar...", msg: { required:"Fält är obligatoriskt", number:"Välj korrekt nummer", minValue:"värdet måste vara större än eller lika med", maxValue:"värdet måste vara mindre än eller lika med", email: "är inte korrekt e-mail adress", integer: "Var god ange korrekt heltal", date: "Var god att ange korrekt datum" } }; $.jgrid.del = { caption: "Ta bort", msg: "Ta bort vald post(er)?", bSubmit: "Utför", bCancel: "Avbryt", processData: "Processing..." }; $.jgrid.nav = { edittext: " ", edittitle: "Ändra vald rad", addtext:" ", addtitle: "Skapa ny rad", deltext: " ", deltitle: "Ta bort vald rad", searchtext: " ", searchtitle: "Hitta poster", refreshtext: "", refreshtitle: "Ladda om Grid", alertcap: "Varning", alerttext: "Var god välj rad" }; // setcolumns module $.jgrid.col ={ caption: "Visa/Göm kolumner", bSubmit: "Utför", bCancel: "Avbryt" }; $.jgrid.errors = { errcap : "Fel", nourl : "Ingen URL är definierad", norecords: "Inga poster att processa", model : "Längden av colNames <> colModel!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör", "Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec", "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December" ], AmPm : ["fm","em","FM","EM"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'}, srcformat: 'Y-m-d', newformat: 'Y-m-d', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'show', addParam : '' }; // SV })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-sv.js
JavaScript
gpl2
3,446
;(function($){ /** * jqGrid extension for custom methods * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ getColProp : function(colname){ var ret ={}, $t = this[0]; if ( !$t.grid ) { return; } var cM = $t.p.colModel; for ( var i =0;i<cM.length;i++ ) { if ( cM[i].name == colname ) { ret = cM[i]; break; } }; return ret; }, setColProp : function(colname, obj){ //do not set width will not work return this.each(function(){ if ( this.grid ) { if ( obj ) { var cM = this.p.colModel; for ( var i =0;i<cM.length;i++ ) { if ( cM[i].name == colname ) { $.extend(this.p.colModel[i],obj); break; } } } } }); }, sortGrid : function(colname,reload){ return this.each(function(){ var $t=this,idx=-1; if ( !$t.grid ) { return;} if ( !colname ) { colname = $t.p.sortname; } for ( var i=0;i<$t.p.colModel.length;i++ ) { if ( $t.p.colModel[i].index == colname || $t.p.colModel[i].name==colname ) { idx = i; break; } } if ( idx!=-1 ){ var sort = $t.p.colModel[idx].sortable; if ( typeof sort !== 'boolean' ) { sort = true; } if ( typeof reload !=='boolean' ) { reload = false; } if ( sort ) { $t.sortData(colname, idx, reload); } } }); }, GridDestroy : function () { return this.each(function(){ if ( this.grid ) { if ( this.p.pager ) { $(this.p.pager).remove(); } var gid = this.id; $("#lui_"+gid).remove(); try { $("#editmod"+gid).remove(); $("#delmod"+gid).remove(); $("#srchmod"+gid).remove(); } catch (_) {} $(this.grid.bDiv).remove(); $(this.grid.hDiv).remove(); $(this.grid.cDiv).remove(); if(this.p.toolbar[0]) { $(this.grid.uDiv).remove(); } this.p = null; this.grid =null; } }); }, GridUnload : function(){ return this.each(function(){ if ( !this.grid ) {return;} var defgrid = {id: $(this).attr('id'),cl: $(this).attr('class')}; if (this.p.pager) { $(this.p.pager).empty(); } var newtable = document.createElement('table'); $(newtable).attr({id:defgrid['id']}); newtable.className = defgrid['cl']; var gid = this.id; $("#lui_"+gid).remove(); try { $("#editmod"+gid).remove(); $("#delmod"+gid).remove(); $("#srchmod"+gid).remove(); } catch (_) {} if(this.p.toolbar[0]) { $(this.grid.uDiv).remove(); } $(this.grid.cDiv).remove(); $(this.grid.bDiv).remove(); $(this.grid.hDiv).before(newtable).remove(); // here code to remove modals of form editing this.p = null; this.grid =null; }); }, filterGrid : function(gridid,p){ p = $.extend({ gridModel : false, gridNames : false, gridToolbar : false, filterModel: [], // label/name/stype/defval/surl/sopt formtype : "horizontal", // horizontal/vertical autosearch: true, // if set to false a serch button should be enabled. formclass: "filterform", tableclass: "filtertable", buttonclass: "filterbutton", searchButton: "Search", clearButton: "Clear", enableSearch : false, enableClear: false, beforeSearch: null, afterSearch: null, beforeClear: null, afterClear: null, url : '', marksearched: true },p || {}); return this.each(function(){ var self = this; this.p = p; if(this.p.filterModel.length == 0 && this.p.gridModel===false) { alert("No filter is set"); return;} if( !gridid) {alert("No target grid is set!"); return;} this.p.gridid = gridid.indexOf("#") != -1 ? gridid : "#"+gridid; var gcolMod = $(this.p.gridid).getGridParam('colModel'); if(gcolMod) { if( this.p.gridModel === true) { var thegrid = $(this.p.gridid)[0]; var sh; // we should use the options search, edittype, editoptions // additionally surl and defval can be added in grid colModel $.each(gcolMod, function (i,n) { var tmpFil = []; this.search = this.search === false ? false : true; if(this.editrules && this.editrules.searchhidden === true) { sh = true; } else { if(this.hidden === true ) { sh = false; } else { sh = true; } } if( this.search === true && sh === true) { if(self.p.gridNames===true) { tmpFil.label = thegrid.p.colNames[i]; } else { tmpFil.label = ''; } tmpFil.name = this.name; tmpFil.index = this.index || this.name; // we support only text and selects, so all other to text tmpFil.stype = this.edittype || 'text'; if(tmpFil.stype != 'select' || tmpFil.stype != 'select') { tmpFil.stype = 'text'; } tmpFil.defval = this.defval || ''; tmpFil.surl = this.surl || ''; tmpFil.sopt = this.editoptions || {}; tmpFil.width = this.width; self.p.filterModel.push(tmpFil); } }); } else { $.each(self.p.filterModel,function(i,n) { for(var j=0;j<gcolMod.length;j++) { if(this.name == gcolMod[j].name) { this.index = gcolMod[j].index || this.name; break; } } if(!this.index) { this.index = this.name; } }); } } else { alert("Could not get grid colModel"); return; } var triggerSearch = function() { var sdata={}, j=0, v; var gr = $(self.p.gridid)[0]; if($.isFunction(self.p.beforeSearch)){self.p.beforeSearch();} $.each(self.p.filterModel,function(i,n){ switch (this.stype) { case 'select' : v = $("select[name="+this.name+"]",self).val(); if(v) { sdata[this.index] = v; if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell"); } j++; } else { if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell"); } // remove from postdata try { delete gr.p.postData[this.index]; } catch(e) {} } break; default: v = $("input[name="+this.name+"]",self).val(); if(v) { sdata[this.index] = v; if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell"); } j++; } else { if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell"); } // remove from postdata try { delete gr.p.postData[this.index]; } catch (e) {} } } }); var sd = j>0 ? true : false; gr.p.postData = $.extend(gr.p.postData,sdata); var saveurl; if(self.p.url) { saveurl = $(gr).getGridParam('url'); $(gr).setGridParam({url:self.p.url}); } $(gr).setGridParam({search:sd,page:1}).trigger("reloadGrid"); if(saveurl) {$(gr).setGridParam({url:saveurl});} if($.isFunction(self.p.afterSearch)){self.p.afterSearch();} }; var clearSearch = function(){ var sdata={}, v, j=0; var gr = $(self.p.gridid)[0]; if($.isFunction(self.p.beforeClear)){self.p.beforeClear();} $.each(self.p.filterModel,function(i,n){ v = (this.defval) ? this.defval : ""; if(!this.stype){this.stype=='text';} switch (this.stype) { case 'select' : if(v) { var v1; $("select[name="+this.name+"] option",self).each(function (){ if ($(this).text() == v) { this.selected = true; v1 = $(this).val(); return false; } }); // post the key and not the text sdata[this.index] = v1 || ""; if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell"); } j++; } else { if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell"); } // remove from postdata try { delete gr.p.postData[this.index]; } catch(e) {} } break; case 'text': $("input[name="+this.name+"]",self).val(v); if(v) { sdata[this.index] = v; if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell"); } j++; } else { if(self.p.marksearched){ $("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell"); } // remove from postdata try { delete gr.p.postData[this.index]; } catch(e) {} } } }); var sd = j>0 ? true : false; gr.p.postData = $.extend(gr.p.postData,sdata); var saveurl; if(self.p.url) { saveurl = $(gr).getGridParam('url'); $(gr).setGridParam({url:self.p.url}); } $(gr).setGridParam({search:sd,page:1}).trigger("reloadGrid"); if(saveurl) {$(gr).setGridParam({url:saveurl});} if($.isFunction(self.p.afterClear)){self.p.afterClear();} }; var formFill = function(){ var tr = document.createElement("tr"); var tr1, sb, cb,tl,td, td1; if(self.p.formtype=='horizontal'){ $(tbl).append(tr); } $.each(self.p.filterModel,function(i,n){ tl = document.createElement("td"); $(tl).append("<label for='"+this.name+"'>"+this.label+"</label>"); td = document.createElement("td"); var $t=this; if(!this.stype) { this.stype='text';} switch (this.stype) { case "select": if(this.surl) { // data returned should have already constructed html select $(td).load(this.surl,function(){ if($t.defval) $("select",this).val($t.defval); $("select",this).attr({name:$t.name, id: "sg_"+$t.name}); if($t.sopt) $("select",this).attr($t.sopt); if(self.p.gridToolbar===true && $t.width) { $("select",this).width($t.width); } if(self.p.autosearch===true){ $("select",this).change(function(e){ triggerSearch(); return false; }); } }); } else { // sopt to construct the values if($t.sopt.value) { var so = $t.sopt.value.split(";"), sv, ov; var elem = document.createElement("select"); $(elem).attr({name:$t.name, id: "sg_"+$t.name}).attr($t.sopt); for(var k=0; k<so.length;k++){ sv = so[k].split(":"); ov = document.createElement("option"); ov.value = sv[0]; ov.innerHTML = sv[1]; if (sv[1]==$t.defval) ov.selected ="selected"; elem.appendChild(ov); } if(self.p.gridToolbar===true && $t.width) { $(elem).width($t.width); } $(td).append(elem); if(self.p.autosearch===true){ $(elem).change(function(e){ triggerSearch(); return false; }); } } } break; case 'text': var df = this.defval ? this.defval: ""; $(td).append("<input type='text' name='"+this.name+"' id='sg_"+this.name+"' value='"+df+"'/>"); if($t.sopt) $("input",td).attr($t.sopt); if(self.p.gridToolbar===true && $t.width) { if($.browser.msie) { $("input",td).width($t.width-4); } else { $("input",td).width($t.width-2); } } if(self.p.autosearch===true){ $("input",td).keypress(function(e){ var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; if(key == 13){ triggerSearch(); return false; } return this; }); } break; } if(self.p.formtype=='horizontal'){ if(self.p.grodToolbar===true && self.p.gridNames===false) { $(tr).append(td); } else { $(tr).append(tl).append(td); } $(tr).append(td); } else { tr1 = document.createElement("tr"); $(tr1).append(tl).append(td); $(tbl).append(tr1); } }); td = document.createElement("td"); if(self.p.enableSearch === true){ sb = "<input type='button' id='sButton' class='"+self.p.buttonclass+"' value='"+self.p.searchButton+"'/>"; $(td).append(sb); $("input#sButton",td).click(function(){ triggerSearch(); return false; }); } if(self.p.enableClear === true) { cb = "<input type='button' id='cButton' class='"+self.p.buttonclass+"' value='"+self.p.clearButton+"'/>"; $(td).append(cb); $("input#cButton",td).click(function(){ clearSearch(); return false; }); } if(self.p.enableClear === true || self.p.enableSearch === true) { if(self.p.formtype=='horizontal') { $(tr).append(td); } else { tr1 = document.createElement("tr"); $(tr1).append("<td>&nbsp;</td>").append(td); $(tbl).append(tr1); } } }; var frm = $("<form name='SearchForm' style=display:inline;' class='"+this.p.formclass+"'></form>"); var tbl =$("<table class='"+this.p.tableclass+"' cellspacing='0' cellpading='0' border='0'><tbody></tbody></table>"); $(frm).append(tbl); formFill(); $(this).append(frm); this.triggerSearch = function () {triggerSearch();}; this.clearSearch = function () {clearSearch();}; }); } }); })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.custom.js
JavaScript
gpl2
13,651
;(function($){ /** * jqGrid French Translation * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "Ligne(s)", loadtext: "Chargement...", pgtext : "/" }; $.jgrid.search = { caption: "Recherche...", Find: "Chercher", Reset: "Annuler", odata : ['égal', 'différent', 'inférieur', 'inférieur ou égal','supérieur','supérieur ou égal', 'débute par','termine par','contient'] }; $.jgrid.edit = { addCaption: "Ajouter", editCaption: "Editer", bSubmit: "Valider", bCancel: "Annuler", bClose: "Fermer", processData: "Traitement...", msg: { required:"Champ obligatoire", number:"Saisissez un nombre valide", minValue:"La valeur doit être supérieure ou égal à 0 ", maxValue:"La valeur doit être inférieure ou égal à 0", email: "n'est pas un email valide", integer: "Saisissez un entier valide", date: "Saisissez une date valide" } }; $.jgrid.del = { caption: "Supprimer", msg: "Supprimer les enregistrements sélectionnés ?", bSubmit: "Supprimer", bCancel: "Annuler", processData: "Traitement..." }; $.jgrid.nav = { edittext: " ", edittitle: "Editer la ligne sélectionnée", addtext:" ", addtitle: "Ajouter une ligne", deltext: " ", deltitle: "Supprimer la ligne sélectionnée", searchtext: " ", searchtitle: "Chercher un enregistrement", refreshtext: "", refreshtitle: "Recharger le tableau", alertcap: "Avertissement", alerttext: "Veuillez sélectionner une ligne" }; // setcolumns module $.jgrid.col ={ caption: "Afficher/Masquer les colonnes", bSubmit: "Valider", bCancel: "Annuler" }; $.jgrid.errors = { errcap : "Erreur", nourl : "Aucune url paramétrée", norecords: "Aucun enregistrement à traiter", model : "Nombre de titres (colNames) <> Nombre de données (colModel)!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" ], monthNames: [ "Jan", "Fev", "Mar", "Avr", "Mai", "Jui", "Jul", "Aou", "Sep", "Oct", "Nov", "Dec", "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Saptembre", "Octobre", "Novembre", "Décembre" ], AmPm : ["am","pm","AM","PM"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'}, /* // Original version srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, */ srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"d-m-Y H:i:s", ISO8601Short:"d-m-Y", ShortDate: "j/n/Y", LongDate: "l d F Y", FullDateTime: "l d F Y, G:i:s", MonthDay: "d F", ShortTime: "G:i", LongTime: "G:i:s", SortableDateTime: "d-m-Y\\TH:i:s", UniversalSortableDateTime: "d-m-Y H:i:sO", YearMonth: "F Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'show' }; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-fr.js
JavaScript
gpl2
4,125
/* * jqDnR - Minimalistic Drag'n'Resize for jQuery. * * Copyright (c) 2007 Brice Burgess <bhb@iceburg.net>, http://www.iceburg.net * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php * * $Version: 2007.08.19 +r2 */ (function($){ $.fn.jqDrag=function(h){return i(this,h,'d');}; $.fn.jqResize=function(h){return i(this,h,'r');}; $.jqDnR={ dnr:{}, e:0, drag:function(v){ if(M.k == 'd')E.css({left:M.X+v.pageX-M.pX,top:M.Y+v.pageY-M.pY}); else E.css({width:Math.max(v.pageX-M.pX+M.W,0),height:Math.max(v.pageY-M.pY+M.H,0)}); return false; }, stop:function(){ //E.css('opacity',M.o); $().unbind('mousemove',J.drag).unbind('mouseup',J.stop); } }; var J=$.jqDnR,M=J.dnr,E=J.e, i=function(e,h,k){ return e.each(function(){ h=(h)?$(h,e):e; h.bind('mousedown',{e:e,k:k},function(v){ var d=v.data,p={};E=d.e; // attempt utilization of dimensions plugin to fix IE issues if(E.css('position') != 'relative'){try{E.position(p);}catch(e){}} M={ X:p.left||f('left')||0, Y:p.top||f('top')||0, W:f('width')||E[0].scrollWidth||0, H:f('height')||E[0].scrollHeight||0, pX:v.pageX, pY:v.pageY, k:d.k //o:E.css('opacity') }; //E.css({opacity:0.8}); $().mousemove($.jqDnR.drag).mouseup($.jqDnR.stop); return false; }); }); }, f=function(k){return parseInt(E.css(k))||false;}; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/jqDnR.js
JavaScript
gpl2
1,463
;(function($){ /** * jqGrid Spanish Translation * Traduccion jqGrid en Espa�ol por Yamil Bracho * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "Fila(s)", loadtext: "Cargando...", pgtext : "/" }; $.jgrid.search = { caption: "Busqueda...", Find: "Buscar", Reset: "Limpiar", odata : ['igual', 'no igual', 'menor', 'menor o igual', 'mayor', 'mayor o igual', 'comienza con', 'termina con','contiene' ] }; $.jgrid.edit = { addCaption: "Agregar Registro", editCaption: "Modificar Registro", bSubmit: "Enviar", bCancel: "Cancelar", bClose: "Cerrar", processData: "Procesando...", msg: { required:"Campo es requerido", number:"Por favor, introduzca un numero", minValue:"El valor debe ser mayor o igual que ", maxValue:"El valor debe ser menor o igual a", email: "no es un direccion de correo valida", integer: "Por favor, introduzca un entero", date: "Please, enter valid date value" } }; $.jgrid.del = { caption: "Eliminar", msg: "¿ Desea eliminar los registros seleccionados ?", bSubmit: "Eliminar", bCancel: "Cancelar", processData: "Procesando..." }; $.jgrid.nav = { edittext: " ", edittitle: "Modificar fila seleccionada", addtext:" ", addtitle: "Agregar nueva fila", deltext: " ", deltitle: "Eliminar fila seleccionada", searchtext: " ", searchtitle: "Buscar información", refreshtext: "", refreshtitle: "Refrescar Rejilla", alertcap: "Aviso", alerttext: "Por favor, seleccione una fila" }; // setcolumns module $.jgrid.col ={ caption: "Mostrar/Ocultar Columnas", bSubmit: "Enviar", bCancel: "Cancelar" }; $.jgrid.errors = { errcap : "Error", nourl : "No se ha especificado una url", norecords: "No hay datos para procesar", model : "Length of colNames <> colModel!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], AmPm : ["am","pm","AM","PM"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'}, srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'show' }; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-sp.js
JavaScript
gpl2
3,500
/** * jqGrid common function * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ // Modal functions var showModal = function(h) { h.w.show(); }; var closeModal = function(h) { h.w.hide(); if(h.o) { h.o.remove(); } }; function createModal(aIDs, content, p, insertSelector, posSelector, appendsel) { var clicon = p.imgpath ? p.imgpath+p.closeicon : p.closeicon; var mw = document.createElement('div'); jQuery(mw).addClass("modalwin").attr("id",aIDs.themodal); var mh = jQuery('<div id="'+aIDs.modalhead+'"><table width="100%"><tbody><tr><td class="modaltext">'+p.caption+'</td> <td style="text-align:right" ><a href="javascript:void(0);" class="jqmClose">'+(clicon!=''?'<img src="' + clicon + '" border="0"/>':'X') + '</a></td></tr></tbody></table> </div>').addClass("modalhead"); var mc = document.createElement('div'); jQuery(mc).addClass("modalcontent").attr("id",aIDs.modalcontent); jQuery(mc).append(content); mw.appendChild(mc); var loading = document.createElement("div"); jQuery(loading).addClass("loading").html(p.processData||""); jQuery(mw).prepend(loading); jQuery(mw).prepend(mh); jQuery(mw).addClass("jqmWindow"); if (p.drag) { jQuery(mw).append("<img class='jqResize' src='"+p.imgpath+"resize.gif'/>"); } if(appendsel===true) { jQuery('body').append(mw); } //append as first child in body -for alert dialog else { jQuery(mw).insertBefore(insertSelector); } if(p.left ==0 && p.top==0) { var pos = []; pos = findPos(posSelector) ; p.left = pos[0] + 4; p.top = pos[1] + 4; } if (p.width == 0 || !p.width) {p.width = 300;} if(p.height==0 || !p.width) {p.height =200;} if(!p.zIndex) {p.zIndex = 950;} jQuery(mw).css({top: p.top+"px",left: p.left+"px",width: p.width+"px",height: p.height+"px", zIndex:p.zIndex}); return false; }; function viewModal(selector,o){ o = jQuery.extend({ toTop: true, overlay: 10, modal: false, onShow: showModal, onHide: closeModal }, o || {}); jQuery(selector).jqm(o).jqmShow(); return false; }; function hideModal(selector) { jQuery(selector).jqmHide(); } function DnRModal(modwin,handler){ jQuery(handler).css('cursor','move'); jQuery(modwin).jqDrag(handler).jqResize(".jqResize"); return false; }; function info_dialog(caption, content,c_b, pathimg) { var cnt = "<div id='info_id'>"; cnt += "<div align='center'><br />"+content+"<br /><br />"; cnt += "<input type='button' size='10' id='closedialog' class='jqmClose EditButton' value='"+c_b+"' />"; cnt += "</div></div>"; createModal({ themodal:'info_dialog', modalhead:'info_head', modalcontent:'info_content'}, cnt, { width:290, height:120,drag: false, caption:"<b>"+caption+"</b>", imgpath: pathimg, closeicon: 'ico-close.gif', left:250, top:170 }, '','',true ); viewModal("#info_dialog",{ onShow: function(h) { h.w.show(); }, onHide: function(h) { h.w.hide().remove(); if(h.o) { h.o.remove(); } }, modal :true }); }; //Helper functions function findPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) { do { curleft += obj.offsetLeft; curtop += obj.offsetTop; } while (obj = obj.offsetParent); //do not change obj == obj.offsetParent } return [curleft,curtop]; }; function isArray(obj) { if (obj.constructor.toString().indexOf("Array") == -1) { return false; } else { return true; } }; // Form Functions function createEl(eltype,options,vl,elm) { var elem = ""; switch (eltype) { case "textarea" : elem = document.createElement("textarea"); if(!options.cols && elm) {jQuery(elem).css("width","99%");} jQuery(elem).attr(options); if(vl == "&nbsp;" || vl == "&#160;") {vl='';} // comes from grid if empty jQuery(elem).val(vl); break; case "checkbox" : //what code for simple checkbox elem = document.createElement("input"); elem.type = "checkbox"; jQuery(elem).attr({id:options.id,name:options.name}); if( !options.value) { vl=vl.toLowerCase(); if(vl.search(/(false|0|no|off|undefined)/i)<0 && vl!=="") { elem.checked=true; elem.defaultChecked=true; elem.value = vl; } else { elem.value = "on"; } jQuery(elem).attr("offval","off"); } else { var cbval = options.value.split(":"); if(vl == cbval[0]) { elem.checked=true; elem.defaultChecked=true; } elem.value = cbval[0]; jQuery(elem).attr("offval",cbval[1]); } break; case "select" : elem = document.createElement("select"); var msl = options.multiple==true ? true : false; if(options.value) { var ovm = []; if(msl) {jQuery(elem).attr({multiple:"multiple"}); ovm = vl.split(","); ovm = jQuery.map(ovm,function(n){return jQuery.trim(n)});} if(typeof options.size === 'undefined') {options.size =1;} if(typeof options.value == 'string') { var so = options.value.split(";"),sv, ov; jQuery(elem).attr({id:options.id,name:options.name,size:Math.min(options.size,so.length)}); for(var i=0; i<so.length;i++){ sv = so[i].split(":"); ov = document.createElement("option"); ov.value = sv[0]; ov.innerHTML = jQuery.htmlDecode(sv[1]); if (!msl && sv[1]==vl) ov.selected ="selected"; if (msl && jQuery.inArray(jQuery.trim(sv[1]), ovm)>-1) {ov.selected ="selected";} elem.appendChild(ov); } } else if (typeof options.value == 'object') { var oSv = options.value; var i=0; for ( var key in oSv) { i++; ov = document.createElement("option"); ov.value = key; ov.innerHTML = jQuery.htmlDecode(oSv[key]); if (!msl && oSv[key]==vl) {ov.selected ="selected";} if (msl && jQuery.inArray(jQuery.trim(oSv[key]),ovm)>-1) {ov.selected ="selected";} elem.appendChild(ov); } jQuery(elem).attr({id:options.id,name:options.name,size:Math.min(options.size,i) }); } } break; case "text" : elem = document.createElement("input"); elem.type = "text"; vl = jQuery.htmlDecode(vl); elem.value = vl; if(!options.size && elm) { jQuery(elem).css({width:"98%"}); } jQuery(elem).attr(options); break; case "password" : elem = document.createElement("input"); elem.type = "password"; vl = jQuery.htmlDecode(vl); elem.value = vl; if(!options.size && elm) { jQuery(elem).css("width","99%"); } jQuery(elem).attr(options); break; case "image" : elem = document.createElement("input"); elem.type = "image"; jQuery(elem).attr(options); break; } return elem; }; function checkValues(val, valref,g) { if(valref >=0) { var edtrul = g.p.colModel[valref].editrules; } if(edtrul) { if(edtrul.required === true) { if( val.match(/^s+$/) || val == "" ) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.required,""]; } // force required var rqfield = edtrul.required === false ? false : true; if(edtrul.number === true) { if( !(rqfield === false && isEmpty(val)) ) { if(isNaN(val)) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.number,""]; } } if(edtrul.minValue && !isNaN(edtrul.minValue)) { if (parseFloat(val) < parseFloat(edtrul.minValue) ) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.minValue+" "+edtrul.minValue,""]; } if(edtrul.maxValue && !isNaN(edtrul.maxValue)) { if (parseFloat(val) > parseFloat(edtrul.maxValue) ) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.maxValue+" "+edtrul.maxValue,""]; } if(edtrul.email === true) { if( !(rqfield === false && isEmpty(val)) ) { // taken from jquery Validate plugin var filter = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i; if(!filter.test(val)) {return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.email,""];} } } if(edtrul.integer === true) { if( !(rqfield === false && isEmpty(val)) ) { if(isNaN(val)) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.integer,""]; if ((val % 1 != 0) || (val.indexOf('.') != -1)) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.integer,""]; } } if(edtrul.date === true) { if( !(rqfield === false && isEmpty(val)) ) { var dft = g.p.colModel[valref].datefmt || "Y-m-d"; if(!checkDate (dft, val)) return [false,g.p.colNames[valref]+": "+jQuery.jgrid.edit.msg.date+" - "+dft,""]; } } } return [true,"",""]; }; // Date Validation Javascript function checkDate (format, date) { var tsp = {}; var result = false; var sep; format = format.toLowerCase(); //we search for /,-,. for the date separator if(format.indexOf("/") != -1) { sep = "/"; } else if(format.indexOf("-") != -1) { sep = "-"; } else if(format.indexOf(".") != -1) { sep = "."; } else { sep = "/"; } format = format.split(sep); date = date.split(sep); if (date.length != 3) return false; var j=-1,yln, dln=-1, mln=-1; for(var i=0;i<format.length;i++){ var dv = isNaN(date[i]) ? 0 : parseInt(date[i],10); tsp[format[i]] = dv; yln = format[i]; if(yln.indexOf("y") != -1) { j=i; } if(yln.indexOf("m") != -1) {mln=i} if(yln.indexOf("d") != -1) {dln=i} } if (format[j] == "y" || format[j] == "yyyy") { yln=4; } else if(format[j] =="yy"){ yln = 2; } else { yln = -1; } var daysInMonth = DaysArray(12); var strDate; if (j === -1) { return false; } else { strDate = tsp[format[j]].toString(); if(yln == 2 && strDate.length == 1) {yln = 1;} if (strDate.length != yln || tsp[format[j]]==0 ){ return false; } } if(mln === -1) { return false; } else { strDate = tsp[format[mln]].toString(); if (strDate.length<1 || tsp[format[mln]]<1 || tsp[format[mln]]>12){ return false; } } if(dln === -1) { return false; } else { strDate = tsp[format[dln]].toString(); if (strDate.length<1 || tsp[format[dln]]<1 || tsp[format[dln]]>31 || (tsp[format[mln]]==2 && tsp[format[dln]]>daysInFebruary(tsp[format[j]])) || tsp[format[dln]] > daysInMonth[tsp[format[mln]]]){ return false; } } return true; } function daysInFebruary (year){ // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); } function DaysArray(n) { for (var i = 1; i <= n; i++) { this[i] = 31; if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;} if (i==2) {this[i] = 29;} } return this; } function isEmpty(val) { if (val.match(/^s+$/) || val == "") { return true; } else { return false; } } function htmlEncode (value){ return !value ? value : String(value).replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;"); }
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.common.js
JavaScript
gpl2
11,967
/* The below work is licensed under Creative Commons GNU LGPL License. Original work: License: http://creativecommons.org/licenses/LGPL/2.1/ Author: Stefan Goessner/2006 Web: http://goessner.net/ Modifications made: Version: 0.9-p5 Description: Restructured code, JSLint validated (no strict whitespaces), added handling of empty arrays, empty strings, and int/floats values. Author: Michael Schøler/2008-01-29 Web: http://michael.hinnerup.net/blog/2008/01/26/converting-json-to-xml-and-xml-to-json/ Description: json2xml added support to convert functions as CDATA so it will be easy to write characters that cause some problems when convert Author: Tony Tomov */ /*global alert */ var xmlJsonClass = { // Param "xml": Element or document DOM node. // Param "tab": Tab or indent string for pretty output formatting omit or use empty string "" to supress. // Returns: JSON string xml2json: function(xml, tab) { if (xml.nodeType === 9) { // document node xml = xml.documentElement; } var nws = this.removeWhite(xml); var obj = this.toObj(nws); var json = this.toJson(obj, xml.nodeName, "\t"); return "{\n" + tab + (tab ? json.replace(/\t/g, tab) : json.replace(/\t|\n/g, "")) + "\n}"; }, // Param "o": JavaScript object // Param "tab": tab or indent string for pretty output formatting omit or use empty string "" to supress. // Returns: XML string json2xml: function(o, tab) { var toXml = function(v, name, ind) { var xml = ""; var i, n; if (v instanceof Array) { if (v.length === 0) { xml += ind + "<"+name+">__EMPTY_ARRAY_</"+name+">\n"; } else { for (i = 0, n = v.length; i < n; i += 1) { var sXml = ind + toXml(v[i], name, ind+"\t") + "\n"; xml += sXml; } } } else if (typeof(v) === "object") { var hasChild = false; xml += ind + "<" + name; var m; for (m in v) if (v.hasOwnProperty(m)) { if (m.charAt(0) === "@") { xml += " " + m.substr(1) + "=\"" + v[m].toString() + "\""; } else { hasChild = true; } } xml += hasChild ? ">" : "/>"; if (hasChild) { for (m in v) if (v.hasOwnProperty(m)) { if (m === "#text") { xml += v[m]; } else if (m === "#cdata") { xml += "<![CDATA[" + v[m] + "]]>"; } else if (m.charAt(0) !== "@") { xml += toXml(v[m], m, ind+"\t"); } } xml += (xml.charAt(xml.length - 1) === "\n" ? ind : "") + "</" + name + ">"; } } else if (typeof(v) === "function") { xml += ind + "<" + name + ">" + "<![CDATA[" + v + "]]>" + "</" + name + ">"; } else { if (v.toString() === "\"\"" || v.toString().length === 0) { xml += ind + "<" + name + ">__EMPTY_STRING_</" + name + ">"; } else { xml += ind + "<" + name + ">" + v.toString() + "</" + name + ">"; } } return xml; }; var xml = ""; var m; for (m in o) if (o.hasOwnProperty(m)) { xml += toXml(o[m], m, ""); } return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, ""); }, // Added by Tony Tomov // parses xml string and convert it to xml Document parseXml : function (xmlString) { var xmlDoc; try { var parser = new DOMParser(); xmlDoc = parser.parseFromString(xmlString,"text/xml"); } catch(e) { xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc["loadXM"+"L"](xmlString); } return (xmlDoc && xmlDoc.documentElement && xmlDoc.documentElement.tagName != 'parsererror') ? xmlDoc : null; }, // Internal methods toObj: function(xml) { var o = {}; var FuncTest = /function/i; if (xml.nodeType === 1) { // element node .. if (xml.attributes.length) { // element with attributes .. var i; for (i = 0; i < xml.attributes.length; i += 1) { o["@" + xml.attributes[i].nodeName] = (xml.attributes[i].nodeValue || "").toString(); } } if (xml.firstChild) { // element has child nodes .. var textChild = 0, cdataChild = 0, hasElementChild = false; var n; for (n = xml.firstChild; n; n = n.nextSibling) { if (n.nodeType === 1) { hasElementChild = true; } else if (n.nodeType === 3 && n.nodeValue.match(/[^ \f\n\r\t\v]/)) { // non-whitespace text textChild += 1; } else if (n.nodeType === 4) { // cdata section node cdataChild += 1; } } if (hasElementChild) { if (textChild < 2 && cdataChild < 2) { // structured element with evtl. a single text or/and cdata node .. this.removeWhite(xml); for (n = xml.firstChild; n; n = n.nextSibling) { if (n.nodeType === 3) { // text node o["#text"] = this.escape(n.nodeValue); } else if (n.nodeType === 4) { // cdata node if (FuncTest.test(n.nodeValue)) { o[n.nodeName] = [o[n.nodeName], n.nodeValue]; } else { o["#cdata"] = this.escape(n.nodeValue); } } else if (o[n.nodeName]) { // multiple occurence of element .. if (o[n.nodeName] instanceof Array) { o[n.nodeName][o[n.nodeName].length] = this.toObj(n); } else { o[n.nodeName] = [o[n.nodeName], this.toObj(n)]; } } else { // first occurence of element .. o[n.nodeName] = this.toObj(n); } } } else { // mixed content if (!xml.attributes.length) { o = this.escape(this.innerXml(xml)); } else { o["#text"] = this.escape(this.innerXml(xml)); } } } else if (textChild) { // pure text if (!xml.attributes.length) { o = this.escape(this.innerXml(xml)); if (o === "__EMPTY_ARRAY_") { o = "[]"; } else if (o === "__EMPTY_STRING_") { o = ""; } } else { o["#text"] = this.escape(this.innerXml(xml)); } } else if (cdataChild) { // cdata if (cdataChild > 1) { o = this.escape(this.innerXml(xml)); } else { for (n = xml.firstChild; n; n = n.nextSibling) { if(FuncTest.test(xml.firstChild.nodeValue)) { o = xml.firstChild.nodeValue; break; } else { o["#cdata"] = this.escape(n.nodeValue); } } } } } if (!xml.attributes.length && !xml.firstChild) { o = null; } } else if (xml.nodeType === 9) { // document.node o = this.toObj(xml.documentElement); } else { alert("unhandled node type: " + xml.nodeType); } return o; }, toJson: function(o, name, ind) { var json = name ? ("\"" + name + "\"") : ""; if (o === "[]") { json += (name ? ":[]" : "[]"); } else if (o instanceof Array) { var n, i; for (i = 0, n = o.length; i < n; i += 1) { o[i] = this.toJson(o[i], "", ind + "\t"); } json += (name ? ":[" : "[") + (o.length > 1 ? ("\n" + ind + "\t" + o.join(",\n" + ind + "\t") + "\n" + ind) : o.join("")) + "]"; } else if (o === null) { json += (name && ":") + "null"; } else if (typeof(o) === "object") { var arr = []; var m; for (m in o) if (o.hasOwnProperty(m)) { arr[arr.length] = this.toJson(o[m], m, ind + "\t"); } json += (name ? ":{" : "{") + (arr.length > 1 ? ("\n" + ind + "\t" + arr.join(",\n" + ind + "\t") + "\n" + ind) : arr.join("")) + "}"; } else if (typeof(o) === "string") { var objRegExp = /(^-?\d+\.?\d*$)/; var FuncTest = /function/i; o = o.toString(); if (objRegExp.test(o) || FuncTest.test(o) || o==="false" || o==="true") { // int or float json += (name && ":") + o; } else { json += (name && ":") + "\"" + o + "\""; } } else { json += (name && ":") + o.toString(); } return json; }, innerXml: function(node) { var s = ""; if ("innerHTML" in node) { s = node.innerHTML; } else { var asXml = function(n) { var s = "", i; if (n.nodeType === 1) { s += "<" + n.nodeName; for (i = 0; i < n.attributes.length; i += 1) { s += " " + n.attributes[i].nodeName + "=\"" + (n.attributes[i].nodeValue || "").toString() + "\""; } if (n.firstChild) { s += ">"; for (var c = n.firstChild; c; c = c.nextSibling) { s += asXml(c); } s += "</" + n.nodeName + ">"; } else { s += "/>"; } } else if (n.nodeType === 3) { s += n.nodeValue; } else if (n.nodeType === 4) { s += "<![CDATA[" + n.nodeValue + "]]>"; } return s; }; for (var c = node.firstChild; c; c = c.nextSibling) { s += asXml(c); } } return s; }, escape: function(txt) { return txt.replace(/[\\]/g, "\\\\").replace(/[\"]/g, '\\"').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r'); }, removeWhite: function(e) { e.normalize(); var n; for (n = e.firstChild; n; ) { if (n.nodeType === 3) { // text node if (!n.nodeValue.match(/[^ \f\n\r\t\v]/)) { // pure whitespace text node var nxt = n.nextSibling; e.removeChild(n); n = nxt; } else { n = n.nextSibling; } } else if (n.nodeType === 1) { // element node this.removeWhite(n); n = n.nextSibling; } else { // any other node n = n.nextSibling; } } return e; } };
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/JsonXml.js
JavaScript
gpl2
9,659
(function($) { /* * jquery.layout 1.1.1 * * Copyright (c) 2008 * Fabrizio Balliano (http://www.fabrizioballiano.net) * Kevin Dalman (http://allpro.net) * * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html) * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses. * * $Date: 2008-12-01 00:23:11 +0100 (lun, 01 dic 2008) $ * $Rev: 187 $ * * NOTE: For best code readability, view this with a fixed-space font and tabs equal to 4-chars */ $.fn.layout = function (opts) { /* * ########################### * WIDGET CONFIG & OPTIONS * ########################### */ // DEFAULTS for options var prefix = "ui-layout-" // prefix for ALL selectors and classNames , defaults = { // misc default values paneClass: prefix+"pane" // ui-layout-pane , resizerClass: prefix+"resizer" // ui-layout-resizer , togglerClass: prefix+"toggler" // ui-layout-toggler , togglerInnerClass: prefix+"" // ui-layout-open / ui-layout-closed , buttonClass: prefix+"button" // ui-layout-button , contentSelector: "."+prefix+"content"// ui-layout-content , contentIgnoreSelector: "."+prefix+"ignore" // ui-layout-mask } ; // DEFAULT PANEL OPTIONS - CHANGE IF DESIRED var options = { name: "" // FUTURE REFERENCE - not used right now , defaults: { // default options for 'all panes' - will be overridden by 'per-pane settings' applyDefaultStyles: false // apply basic styles directly to resizers & buttons? If not, then stylesheet must handle it , closable: true // pane can open & close , resizable: true // when open, pane can be resized , slidable: true // when closed, pane can 'slide' open over other panes - closes on mouse-out //, paneSelector: [ ] // MUST be pane-specific! , contentSelector: defaults.contentSelector // INNER div/element to auto-size so only it scrolls, not the entire pane! , contentIgnoreSelector: defaults.contentIgnoreSelector // elem(s) to 'ignore' when measuring 'content' , paneClass: defaults.paneClass // border-Pane - default: 'ui-layout-pane' , resizerClass: defaults.resizerClass // Resizer Bar - default: 'ui-layout-resizer' , togglerClass: defaults.togglerClass // Toggler Button - default: 'ui-layout-toggler' , buttonClass: defaults.buttonClass // CUSTOM Buttons - default: 'ui-layout-button-toggle/-open/-close/-pin' , resizerDragOpacity: 1 // option for ui.draggable , minSize: 0 // when manually resizing a pane , maxSize: 0 // ditto, 0 = no limit , spacing_open: 6 // space between pane and adjacent panes - when pane is 'open' , spacing_closed: 6 // ditto - when pane is 'closed' , togglerLength_open: 50 // Length = WIDTH of toggler button on north/south edges - HEIGHT on east/west edges , togglerLength_closed: 50 // 100% OR -1 means 'full height/width of resizer bar' - 0 means 'hidden' , togglerAlign_open: "center" // top/left, bottom/right, center, OR... , togglerAlign_closed: "center" // 1 => nn = offset from top/left, -1 => -nn == offset from bottom/right , togglerTip_open: "Close" // Toggler tool-tip (title) , togglerTip_closed: "Open" // ditto , resizerTip: "Resize" // Resizer tool-tip (title) , sliderTip: "Slide Open" // resizer-bar triggers 'sliding' when pane is closed , sliderCursor: "pointer" // cursor when resizer-bar will trigger 'sliding' , slideTrigger_open: "click" // click, dblclick, mouseover , slideTrigger_close: "mouseout" // click, mouseout , hideTogglerOnSlide: false // when pane is slid-open, should the toggler show? , togglerContent_open: "" // text or HTML to put INSIDE the toggler , togglerContent_closed: "" // ditto , showOverflowOnHover: false // will bind allowOverflow() utility to pane.onMouseOver , enableCursorHotkey: true // enabled 'cursor' hotkeys , customHotkeyModifier: "SHIFT" // either 'SHIFT', 'CTRL' or 'CTRL+SHIFT' - NOT 'ALT' , initClosed: false // true = init pane as 'closed' , initHidden: false // true = init pane as 'hidden' - no resizer or spacing , fxName: "slide" // ('none' or blank), slide, drop, scale , fxSpeed: "normal" // slow, normal, fast, 200, nnn , fxSettings: {} // can be passed, eg: { duration: 500, easing: "bounceInOut" } /* DO NOT set 'default' values for these options - but is OK if user passes them , size: 100 // inital size of pane when layout 'created' */ /* these options MUST be set 'by pane' , paneSelector: "" // MUST be pane-specific! , resizerCursor: "" // cursor when over resizer-bar , customHotkey: "" // EITHER a charCode OR a character , onopen: "" // CALLBACK when pane is Opened , onclose: "" // CALLBACK when pane is Closed , onresize: "" // CALLBACK when pane is Manually Resized */ } , north: { paneSelector: "."+prefix+"north" // default = .ui-layout-north , size: "auto" , resizerCursor: "n-resize" } , south: { paneSelector: "."+prefix+"south" // default = .ui-layout-south , size: "auto" , resizerCursor: "s-resize" } , east: { paneSelector: "."+prefix+"east" // default = .ui-layout-east , size: 200 , resizerCursor: "e-resize" } , west: { paneSelector: "."+prefix+"west" // default = .ui-layout-west , size: 200 , resizerCursor: "w-resize" } , center: { paneSelector: "."+prefix+"center" // default = .ui-layout-center } }; // STATIC, INTERNAL CONFIG - DO NOT CHANGE THIS! var config = { allPanes: "north,south,east,west,center" , borderPanes: "north,south,east,west" , zIndex: { // set z-index values here resizer_normal: 1 // normal z-index for resizer-bars , pane_normal: 2 // normal z-index for panes , sliding: 100 // applied to both the pane and its resizer when a pane is 'slid open' , resizing: 10000 // applied to the CLONED resizer-bar when being 'dragged' , animation: 10000 // applied to the pane when being animated - not applied to the resizer } , fxDefaults: { // LIST *ALL PREDEFINED FX* HERE, even if has no settings slide: { all: {} , north: { direction: "up" } , south: { direction: "down" } , east: { direction: "right" } , west: { direction: "left" } } , drop: { all: {} , north: { direction: "up" } , south: { direction: "down" } , east: { direction: "right" } , west: { direction: "left" } } , scale: {} } , resizers: { cssReq: { position: "absolute" , padding: 0 , margin: 0 , fontSize: "1px" , textAlign: "left" // to counter-act "center" alignment! , overflow: "hidden" // keep toggler button from overflowing , zIndex: 1 } , cssDef: { // DEFAULT CSS - applied if: options.PANE.applyDefaultStyles=true background: "#DDD" , border: "none" } } , togglers: { cssReq: { position: "absolute" , display: "block" , padding: 0 , margin: 0 , overflow: "hidden" , textAlign: "center" , fontSize: "1px" , cursor: "pointer" , zIndex: 1 } , cssDef: { // DEFAULT CSS - applied if: options.PANE.applyDefaultStyles=true background: "#AAA" } } , content: { cssReq: { overflow: "auto" } , cssDef: {} } , defaults: { // defaults for ALL panes - overridden by 'per-pane settings' below cssReq: { position: "absolute" , margin: 0 , zIndex: 2 } , cssDef: { padding: "10px" , background: "#FFF" , border: "1px solid #BBB" , overflow: "auto" } } , north: { edge: "top" , sizeType: "height" , dir: "horz" , cssReq: { top: 0 , bottom: "auto" , left: 0 , right: 0 , width: "auto" // height: DYNAMIC } } , south: { edge: "bottom" , sizeType: "height" , dir: "horz" , cssReq: { top: "auto" , bottom: 0 , left: 0 , right: 0 , width: "auto" // height: DYNAMIC } } , east: { edge: "right" , sizeType: "width" , dir: "vert" , cssReq: { left: "auto" , right: 0 , top: "auto" // DYNAMIC , bottom: "auto" // DYNAMIC , height: "auto" // width: DYNAMIC } } , west: { edge: "left" , sizeType: "width" , dir: "vert" , cssReq: { left: 0 , right: "auto" , top: "auto" // DYNAMIC , bottom: "auto" // DYNAMIC , height: "auto" // width: DYNAMIC } } , center: { dir: "center" , cssReq: { left: "auto" // DYNAMIC , right: "auto" // DYNAMIC , top: "auto" // DYNAMIC , bottom: "auto" // DYNAMIC , height: "auto" , width: "auto" } } }; // DYNAMIC DATA var state = { // generate random 'ID#' to identify layout - used to create global namespace for timers id: Math.floor(Math.random() * 10000) , container: {} , north: {} , south: {} , east: {} , west: {} , center: {} }; var altEdge = { top: "bottom" , bottom: "top" , left: "right" , right: "left" } , altSide = { north: "south" , south: "north" , east: "west" , west: "east" } ; /* * ########################### * INTERNAL HELPER FUNCTIONS * ########################### */ /** * isStr * * Returns true if passed param is EITHER a simple string OR a 'string object' - otherwise returns false */ var isStr = function (o) { if (typeof o == "string") return true; else if (typeof o == "object") { try { var match = o.constructor.toString().match(/string/i); return (match !== null); } catch (e) {} } return false; }; /** * str * * Returns a simple string if the passed param is EITHER a simple string OR a 'string object', * else returns the original object */ var str = function (o) { if (typeof o == "string" || isStr(o)) return $.trim(o); // trim converts 'String object' to a simple string else return o; }; /** * min / max * * Alias for Math.min/.max to simplify coding */ var min = function (x,y) { return Math.min(x,y); }; var max = function (x,y) { return Math.max(x,y); }; /** * transformData * * Processes the options passed in and transforms them into the format used by layout() * Missing keys are added, and converts the data if passed in 'flat-format' (no sub-keys) * In flat-format, pane-specific-settings are prefixed like: north__optName (2-underscores) * To update config.fxDefaults, options MUST use nested-keys format, with a fxDefaults key * * @callers initOptions() * @params JSON d Data/options passed by user - may be a single level or nested levels * @returns JSON Creates a data struture that perfectly matches 'options', ready to be imported */ var transformData = function (d) { var json = { defaults:{}, north:{}, south:{}, east:{}, west:{}, center:{} }; d = d || {}; if (d.fxDefaults || d.defaults || d.north || d.south || d.west || d.east || d.center) return $.extend( json, d ); // already in json format, but add any missing keys // convert 'flat' to 'nest-keys' format - also handles 'empty' user-options $.each( d, function (key,val) { a = key.split("__"); json[ a[1] ? a[0] : "defaults" ][ a[1] ? a[1] : a[0] ] = val; }); return json; }; /** * setFlowCallback * * Set an INTERNAL callback to avoid simultaneous animation * Runs only if needed and only if all callbacks are not 'already set'! * * @param String action Either 'open' or 'close' * @pane String pane A valid border-pane name, eg 'west' * @pane Boolean param Extra param for callback (optional) */ var setFlowCallback = function (action, pane, param) { var cb = action +","+ pane +","+ (param ? 1 : 0) , cP, cbPane ; $.each(c.borderPanes.split(","), function (i,p) { if (c[p].isMoving) { bindCallback(p); // TRY to bind a callback return false; // BREAK } }); function bindCallback (p, test) { cP = c[p]; if (!cP.doCallback) { cP.doCallback = true; cP.callback = cb; } else { // try to 'chain' this callback cpPane = cP.callback.split(",")[1]; // 2nd param is 'pane' if (cpPane != p && cpPane != pane) // callback target NOT 'itself' and NOT 'this pane' bindCallback (cpPane, true); // RECURSE } } }; /** * execFlowCallback * * RUN the INTERNAL callback for this pane - if one exists * * @param String action Either 'open' or 'close' * @pane String pane A valid border-pane name, eg 'west' * @pane Boolean param Extra param for callback (optional) */ var execFlowCallback = function (pane) { var cP = c[pane]; // RESET flow-control flaGs c.isLayoutBusy = false; cP.isMoving = false; if (!cP.doCallback || !cP.callback) return; cP.doCallback = false; // RESET logic flag // EXECUTE the callback var cb = cP.callback.split(",") , param = (cb[2] > 0 ? true : false) ; if (cb[0] == "open") open( cb[1], param ); else if (cb[0] == "close") close( cb[1], param ); if (!cP.doCallback) cP.callback = null; // RESET - unless callback above enabled it again! }; /** * execUserCallback * * Executes a Callback function after a trigger event, like resize, open or close * * @param String pane This is passed only so we can pass the 'pane object' to the callback * @param String v_fn Accepts a function name, OR a comma-delimited array: [0]=function name, [1]=argument */ var execUserCallback = function (pane, v_fn) { if (!v_fn) return; var fn; try { if (typeof v_fn == "function") fn = v_fn; else if (typeof v_fn != "string") return; else if (v_fn.indexOf(",") > 0) { // function name cannot contain a comma, so must be a function name AND a 'name' parameter var args = v_fn.split(",") , fn = eval(args[0]) ; if (typeof fn=="function" && args.length > 1) fn(args[1]); // pass the argument parsed from 'list' return; } else // just the name of an external function? fn = eval(v_fn); if (typeof fn=="function") // pass back data: pane-name, pane-element, pane-state, pane-options, and layout-name fn( pane, $Ps[pane], $.extend({},state[pane]), $.extend({},options[pane]), options.name ); } catch (ex) {} }; /** * cssNum * * Returns the 'current CSS value' for an element - returns 0 if property does not exist * * @callers Called by many methods * @param jQuery $Elem Must pass a jQuery object - first element is processed * @param String property The name of the CSS property, eg: top, width, etc. * @returns Variant Usually is used to get an integer value for position (top, left) or size (height, width) */ var cssNum = function ($E, prop) { var val = 0 , hidden = false , visibility = "" ; if (!$.browser.msie) { // IE CAN read dimensions of 'hidden' elements - FF CANNOT if ($.curCSS($E[0], "display", true) == "none") { hidden = true; visibility = $.curCSS($E[0], "visibility", true); // SAVE current setting $E.css({ display: "block", visibility: "hidden" }); // show element 'invisibly' so we can measure it } } val = parseInt($.curCSS($E[0], prop, true), 10) || 0; if (hidden) { // WAS hidden, so put back the way it was $E.css({ display: "none" }); if (visibility && visibility != "hidden") $E.css({ visibility: visibility }); // reset 'visibility' } return val; }; /** * cssW / cssH / cssSize * * Contains logic to check boxModel & browser, and return the correct width/height for the current browser/doctype * * @callers initPanes(), sizeMidPanes(), initHandles(), sizeHandles() * @param Variant elem Can accept a 'pane' (east, west, etc) OR a DOM object OR a jQuery object * @param Integer outerWidth/outerHeight (optional) Can pass a width, allowing calculations BEFORE element is resized * @returns Integer Returns the innerHeight of the elem by subtracting padding and borders * * @TODO May need to add additional logic to handle more browser/doctype variations? */ var cssW = function (e, outerWidth) { var $E; if (isStr(e)) { e = str(e); $E = $Ps[e]; } else $E = $(e); // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed if (outerWidth <= 0) return 0; else if (!(outerWidth>0)) outerWidth = isStr(e) ? getPaneSize(e) : $E.outerWidth(); if (!$.boxModel) return outerWidth; else // strip border and padding size from outerWidth to get CSS Width return outerWidth - cssNum($E, "paddingLeft") - cssNum($E, "paddingRight") - ($.curCSS($E[0], "borderLeftStyle", true) == "none" ? 0 : cssNum($E, "borderLeftWidth")) - ($.curCSS($E[0], "borderRightStyle", true) == "none" ? 0 : cssNum($E, "borderRightWidth")) ; }; var cssH = function (e, outerHeight) { var $E; if (isStr(e)) { e = str(e); $E = $Ps[e]; } else $E = $(e); // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed if (outerHeight <= 0) return 0; else if (!(outerHeight>0)) outerHeight = (isStr(e)) ? getPaneSize(e) : $E.outerHeight(); if (!$.boxModel) return outerHeight; else // strip border and padding size from outerHeight to get CSS Height return outerHeight - cssNum($E, "paddingTop") - cssNum($E, "paddingBottom") - ($.curCSS($E[0], "borderTopStyle", true) == "none" ? 0 : cssNum($E, "borderTopWidth")) - ($.curCSS($E[0], "borderBottomStyle", true) == "none" ? 0 : cssNum($E, "borderBottomWidth")) ; }; var cssSize = function (pane, outerSize) { if (pane=="north" || pane=="south") return cssH(pane, outerSize); else // pane = east or west return cssW(pane, outerSize); }; /** * getPaneSize * * Calculates the current 'size' (width or height) of a border-pane - optionally with 'pane spacing' added * * @returns Integer Returns EITHER Width for east/west panes OR Height for north/south panes - adjusted for boxModel & browser */ var getPaneSize = function (pane, inclSpace) { var $P = $Ps[pane] , o = options[pane] , s = state[pane] , oSp = (inclSpace ? o.spacing_open : 0) , cSp = (inclSpace ? o.spacing_closed : 0) ; if (!$P || s.isHidden) return 0; else if (s.isClosed || (s.isSliding && inclSpace)) return cSp; else if (c[pane].dir == "horz") return $P.outerHeight() + oSp; else // dir == "vert" return $P.outerWidth() + oSp; }; var setPaneMinMaxSizes = function (pane) { var d = cDims , edge = c[pane].edge , dir = c[pane].dir , o = options[pane] , s = state[pane] , $P = $Ps[pane] , $altPane = $Ps[ altSide[pane] ] , paneSpacing = o.spacing_open , altPaneSpacing = options[ altSide[pane] ].spacing_open , altPaneSize = (!$altPane ? 0 : (dir=="horz" ? $altPane.outerHeight() : $altPane.outerWidth())) , containerSize = (dir=="horz" ? d.innerHeight : d.innerWidth) // limitSize prevents this pane from 'overlapping' opposite pane - even if opposite pane is currently closed , limitSize = containerSize - paneSpacing - altPaneSize - altPaneSpacing , minSize = s.minSize || 0 , maxSize = Math.min(s.maxSize || 9999, limitSize) , minPos, maxPos // used to set resizing limits ; switch (pane) { case "north": minPos = d.offsetTop + minSize; maxPos = d.offsetTop + maxSize; break; case "west": minPos = d.offsetLeft + minSize; maxPos = d.offsetLeft + maxSize; break; case "south": minPos = d.offsetTop + d.innerHeight - maxSize; maxPos = d.offsetTop + d.innerHeight - minSize; break; case "east": minPos = d.offsetLeft + d.innerWidth - maxSize; maxPos = d.offsetLeft + d.innerWidth - minSize; break; } // save data to pane-state $.extend(s, { minSize: minSize, maxSize: maxSize, minPosition: minPos, maxPosition: maxPos }); }; /** * getPaneDims * * Returns data for setting the size/position of center pane. Date is also used to set Height for east/west panes * * @returns JSON Returns a hash of all dimensions: top, bottom, left, right, (outer) width and (outer) height */ var getPaneDims = function () { var d = { top: getPaneSize("north", true) // true = include 'spacing' value for p , bottom: getPaneSize("south", true) , left: getPaneSize("west", true) , right: getPaneSize("east", true) , width: 0 , height: 0 }; with (d) { width = cDims.innerWidth - left - right; height = cDims.innerHeight - bottom - top; // now add the 'container border/padding' to get final positions - relative to the container top += cDims.top; bottom += cDims.bottom; left += cDims.left; right += cDims.right; } return d; }; /** * getElemDims * * Returns data for setting size of an element (container or a pane). * * @callers create(), onWindowResize() for container, plus others for pane * @returns JSON Returns a hash of all dimensions: top, bottom, left, right, outerWidth, innerHeight, etc */ var getElemDims = function ($E) { var d = {} // dimensions hash , e, b, p // edge, border, padding ; $.each("Left,Right,Top,Bottom".split(","), function () { e = str(this); b = d["border" +e] = cssNum($E, "border"+e+"Width"); p = d["padding"+e] = cssNum($E, "padding"+e); d["offset" +e] = b + p; // total offset of content from outer edge // if BOX MODEL, then 'position' = PADDING (ignore borderWidth) if ($E == $Container) d[e.toLowerCase()] = ($.boxModel ? p : 0); }); d.innerWidth = d.outerWidth = $E.outerWidth(); d.innerHeight = d.outerHeight = $E.outerHeight(); if ($.boxModel) { d.innerWidth -= (d.offsetLeft + d.offsetRight); d.innerHeight -= (d.offsetTop + d.offsetBottom); } return d; } var setTimer = function (pane, action, fn, ms) { var Layout = window.layout = window.layout || {} , Timers = Layout.timers = Layout.timers || {} , name = "layout_"+ state.id +"_"+ pane +"_"+ action // UNIQUE NAME for every layout-pane-action ; if (Timers[name]) return; // timer already set! else Timers[name] = setTimeout(fn, ms); }; var clearTimer = function (pane, action) { var Layout = window.layout = window.layout || {} , Timers = Layout.timers = Layout.timers || {} , name = "layout_"+ state.id +"_"+ pane +"_"+ action // UNIQUE NAME for every layout-pane-action ; if (Timers[name]) { clearTimeout( Timers[name] ); delete Timers[name]; return true; } else return false; }; /* * ########################### * INITIALIZATION METHODS * ########################### */ /** * create * * Initialize the layout - called automatically whenever an instance of layout is created * * @callers NEVER explicity called * @returns An object pointer to the instance created */ var create = function () { var isBodyContainer = false; try { // format html/body if this is a full page layout if ($Container[0].tagName == "BODY") { isBodyContainer = true; $("html").css({ height: "100%" , overflow: "hidden" }); $("body").css({ position: "relative" , height: "100%" , overflow: "hidden" , margin: 0 , padding: 0 // TODO: test whether body-padding could be handled? , border: "none" // a body-border creates problems because it cannot be measured! }); } } catch (ex) {} // initialize config/options initOptions(); // get layout-container dimensions (updated when necessary) cDims = state.container = getElemDims( $Container ); // update data-pointer too // initialize all objects initPanes(); // size & position all panes initHandles(); // create and position all resize bars & togglers buttons initResizable(); // activate resizing on all panes where resizable=true sizeContent("all"); // AFTER panes & handles have been initialized, size 'content' divs // bind keyDown to capture hotkeys, if option enabled for ANY pane $.each(c.borderPanes.split(","), function (i,pane) { var o = options[pane]; if (o.enableCursorHotkey || o.customHotkey) { $(document).keydown( keyDown ); return false; // BREAK } }); // bind resizeAll() for 'this layout instance' to window.resize event $(window).resize(function () { var timerID = "timerLayout_"+state.id; if (window[timerID]) clearTimeout(window[timerID]); window[timerID] = null; if ($.browser.msie) // use a delay for IE because the resize event fires repeatly window[timerID] = setTimeout(resizeAll, 100); else // most other browsers have a built-in delay before firing the resize event resizeAll(); // resize all layout elements NOW! }); }; /** * initOptions * * Build final CONFIG and OPTIONS data * * @callers create() */ var initOptions = function () { // simplify logic by making sure passed 'opts' var has basic keys opts = transformData( opts ); // see if a 'layout name' was specified options.name = opts.name || opts.defaults.name || ""; // remove default options that should be set 'per-pane' - and remove 'name' if exists $.each("name,paneSelector,resizerCursor,customHotkey,onopen,onclose,onresize".split(","), function (idx,key) { delete opts.defaults[key]; } // is OK if key does not exist ); // update fxDefaults, if case user passed some var fx = c.fxDefaults; // alias if (opts.fxDefaults) $.extend( fx, opts.fxDefaults ); // first merge all config & options for the 'center' pane c.center = $.extend( true, {}, c.defaults, c.center ); $.extend( options.center, opts.center ); // Most 'default options' do not apply to 'center', so add only those that do var o_Center = $.extend( true, {}, options.defaults, opts.defaults, options.center ); // TEMP data $.each("paneClass,contentSelector,contentIgnoreSelector,applyDefaultStyles,showOverflowOnHover".split(","), function (idx,key) { options.center[key] = o_Center[key]; } ); // loop to create/import a COMPLETE set of options for EACH border-pane $.each(c.borderPanes.split(","), function(i,pane) { // apply 'pane-defaults' to CONFIG.PANE c[pane] = $.extend( true, {}, c.defaults, c[pane] ); // apply 'pane-defaults' + user-options to OPTIONS.PANE var o = options[pane] = $.extend( true, {}, options.defaults, options[pane], opts.defaults, opts[pane] ); // make sure we have base-classes if (!o.paneClass) o.paneClass = defaults.paneClass; if (!o.resizerClass) o.resizerClass = defaults.resizerClass; if (!o.togglerClass) o.togglerClass = defaults.togglerClass; $.each("onopen,onclose,onresize".split(","), function (idx,key) { if (o[key] == undefined) o[key] = ""; }); // create FINAL & UNIQUE fx options for 'each pane', ie: options.PANE.fxName/fxSpeed/fxSettings var fxName = o.fxName; if (fxName != "none") { if (!fxName || !$.effects || !$.effects[fxName] || (!fx[fxName] && !o.fxSettings)) o.fxName = "none"; // effect not loaded, OR undefined FX AND fxSettings not passed else if (fx[fxName]) // ADD 'missing keys' to s.fxSettings from config.fxSettings o.fxSettings = $.extend( {}, fx[fxName].all, fx[fxName][pane], o.fxSettings ); } }); // LAST, update options.defaults so they are saved and can be read from outside $.extend( options.defaults, opts.defaults ); }; /** * initPanes * * Initialize module objects, styling, size and position for all panes * * @callers create() */ var initPanes = function () { // NOTE: do north & south FIRST so we can measure their height - do center LAST $.each(c.allPanes.split(","), function() { var pane = str(this) , o = options[pane] , s = state[pane] , fx = s.fx , dir = c[pane].dir // if o.size is not > 0, then we will use MEASURE the pane and use that as it's 'size' , size = o.size=="auto" || isNaN(o.size) ? 0 : o.size , minSize = o.minSize || 1 , maxSize = o.maxSize || 9999 , spacing = o.spacing_open || 0 , isIE6 = ($.browser.msie && $.browser.version < 7) , CSS = {} , $P, $C ; $Cs[pane] = false; // init $P = $Ps[pane] = $Container.children(o.paneSelector); if (!$P.length) { $Ps[pane] = false; // logic return true; // SKIP to next } // add basic classes & attributes $P .attr("pane", pane) // add pane-identifier .addClass( o.paneClass +" "+ o.paneClass+"-"+pane ) // default = "ui-layout-pane ui-layout-pane-west" - may be a dupe of 'paneSelector' ; // init pane-logic vars, etc. if (pane != "center") { s.isClosed = false; // true = pane is closed s.isSliding = false; // true = pane is currently open by 'sliding' over adjacent panes s.isResizing= false; // true = pane is in process of being resized s.isHidden = false; // true = pane is hidden - no spacing, resizer or toggler is visible! s.noRoom = false; // true = pane 'automatically' hidden due to insufficient room - will unhide automatically // create special keys for internal use c[pane].pins = []; // used to track and sync 'pin-buttons' for border-panes } CSS = $.extend({ visibility: "visible", display: "block" }, c.defaults.cssReq, c[pane].cssReq ); if (o.applyDefaultStyles) $.extend( CSS, c.defaults.cssDef, c[pane].cssDef ); // cosmetic defaults $P.css(CSS); // add base-css BEFORE 'measuring' to calc size & position CSS = {}; // reset var // set css-position to account for container borders & padding switch (pane) { case "north": CSS.top = cDims.top; CSS.left = cDims.left; CSS.right = cDims.right; break; case "south": CSS.bottom = cDims.bottom; CSS.left = cDims.left; CSS.right = cDims.right; break; case "west": CSS.left = cDims.left; // top, bottom & height set by sizeMidPanes() break; case "east": CSS.right = cDims.right; // ditto break; case "center": // top, left, width & height set by sizeMidPanes() } if (dir == "horz") { // north or south pane if (size === 0 || size == "auto") { $P.css({ height: "auto" }); size = $P.outerHeight(); } size = max(size, minSize); size = min(size, maxSize); size = min(size, cDims.innerHeight - spacing); CSS.height = max(1, cssH(pane, size)); s.size = size; // update state // make sure minSize is sufficient to avoid errors s.maxSize = maxSize; // init value s.minSize = max(minSize, size - CSS.height + 1); // = pane.outerHeight when css.height = 1px // handle IE6 //if (isIE6) CSS.width = cssW($P, cDims.innerWidth); $P.css(CSS); // apply size & position } else if (dir == "vert") { // east or west pane if (size === 0 || size == "auto") { $P.css({ width: "auto", float: "left" }); // float = FORCE pane to auto-size size = $P.outerWidth(); $P.css({ float: "none" }); // RESET } size = max(size, minSize); size = min(size, maxSize); size = min(size, cDims.innerWidth - spacing); CSS.width = max(1, cssW(pane, size)); s.size = size; // update state s.maxSize = maxSize; // init value // make sure minSize is sufficient to avoid errors s.minSize = max(minSize, size - CSS.width + 1); // = pane.outerWidth when css.width = 1px $P.css(CSS); // apply size - top, bottom & height set by sizeMidPanes sizeMidPanes(pane, null, true); // true = onInit } else if (pane == "center") { $P.css(CSS); // top, left, width & height set by sizeMidPanes... sizeMidPanes("center", null, true); // true = onInit } // close or hide the pane if specified in settings if (o.initClosed && o.closable) { $P.hide().addClass("closed"); s.isClosed = true; } else if (o.initHidden || o.initClosed) { hide(pane, true); // will be completely invisible - no resizer or spacing s.isHidden = true; } else $P.addClass("open"); // check option for auto-handling of pop-ups & drop-downs if (o.showOverflowOnHover) $P.hover( allowOverflow, resetOverflow ); /* * see if this pane has a 'content element' that we need to auto-size */ if (o.contentSelector) { $C = $Cs[pane] = $P.children(o.contentSelector+":first"); // match 1-element only if (!$C.length) { $Cs[pane] = false; return true; // SKIP to next } $C.css( c.content.cssReq ); if (o.applyDefaultStyles) $C.css( c.content.cssDef ); // cosmetic defaults // NO PANE-SCROLLING when there is a content-div $P.css({ overflow: "hidden" }); } }); }; /** * initHandles * * Initialize module objects, styling, size and position for all resize bars and toggler buttons * * @callers create() */ var initHandles = function () { // create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV $.each(c.borderPanes.split(","), function() { var pane = str(this) , o = options[pane] , s = state[pane] , rClass = o.resizerClass , tClass = o.togglerClass , $P = $Ps[pane] ; $Rs[pane] = false; // INIT $Ts[pane] = false; if (!$P || (!o.closable && !o.resizable)) return; // pane does not exist - skip var edge = c[pane].edge , isOpen = $P.is(":visible") , spacing = (isOpen ? o.spacing_open : o.spacing_closed) , _side = "-"+ pane // used for classNames , _state = (isOpen ? "-open" : "-closed") // used for classNames , $R, $T ; // INIT RESIZER BAR $R = $Rs[pane] = $("<span></span>"); if (isOpen && o.resizable) ; // this is handled by initResizable else if (!isOpen && o.slidable) $R.attr("title", o.sliderTip).css("cursor", o.sliderCursor); $R // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "paneLeft-resizer" .attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-resizer" : "")) .attr("resizer", pane) // so we can read this from the resizer .css(c.resizers.cssReq) // add base/required styles // POSITION of resizer bar - allow for container border & padding .css(edge, cDims[edge] + getPaneSize(pane)) // ADD CLASSNAMES - eg: class="resizer resizer-west resizer-open" .addClass( rClass +" "+ rClass+_side +" "+ rClass+_state +" "+ rClass+_side+_state ) .appendTo($Container) // append DIV to container ; // ADD VISUAL STYLES if (o.applyDefaultStyles) $R.css(c.resizers.cssDef); if (o.closable) { // INIT COLLAPSER BUTTON $T = $Ts[pane] = $("<div></div>"); $T // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "paneLeft-toggler" .attr("id", (o.paneSelector.substr(0,1)=="#" ? o.paneSelector.substr(1) + "-toggler" : "")) .css(c.togglers.cssReq) // add base/required styles .attr("title", (isOpen ? o.togglerTip_open : o.togglerTip_closed)) .click(function(evt){ toggle(pane); evt.stopPropagation(); }) .mouseover(function(evt){ evt.stopPropagation(); }) // prevent resizer event // ADD CLASSNAMES - eg: class="toggler toggler-west toggler-west-open" .addClass( tClass +" "+ tClass+_side +" "+ tClass+_state +" "+ tClass+_side+_state ) .appendTo($R) // append SPAN to resizer DIV ; // ADD INNER-SPANS TO TOGGLER if (o.togglerContent_open) // ui-layout-open $("<span>"+ o.togglerContent_open +"</span>") .addClass("content content-open") .css("display", s.isClosed ? "none" : "block") .appendTo( $T ) ; if (o.togglerContent_closed) // ui-layout-closed $("<span>"+ o.togglerContent_closed +"</span>") .addClass("content content-closed") .css("display", s.isClosed ? "block" : "none") .appendTo( $T ) ; // ADD BASIC VISUAL STYLES if (o.applyDefaultStyles) $T.css(c.togglers.cssDef); if (!isOpen) bindStartSlidingEvent(pane, true); // will enable if state.PANE.isSliding = true } }); // SET ALL HANDLE SIZES & LENGTHS sizeHandles("all", true); // true = onInit }; /** * initResizable * * Add resize-bars to all panes that specify it in options * * @dependancies $.fn.resizable - will abort if not found * @callers create() */ var initResizable = function () { var draggingAvailable = (typeof $.fn.draggable == "function") , minPosition, maxPosition, edge // set in start() ; $.each(c.borderPanes.split(","), function() { var pane = str(this) , o = options[pane] , s = state[pane] ; if (!draggingAvailable || !$Ps[pane] || !o.resizable) { o.resizable = false; return true; // skip to next } var rClass = o.resizerClass // 'drag' classes are applied to the ORIGINAL resizer-bar while dragging is in process , dragClass = rClass+"-drag" // resizer-drag , dragPaneClass = rClass+"-"+pane+"-drag" // resizer-north-drag // 'dragging' class is applied to the CLONED resizer-bar while it is being dragged , draggingClass = rClass+"-dragging" // resizer-dragging , draggingPaneClass = rClass+"-"+pane+"-dragging" // resizer-north-dragging , draggingClassSet = false // logic var , $P = $Ps[pane] , $R = $Rs[pane] ; if (!s.isClosed) $R .attr("title", o.resizerTip) .css("cursor", o.resizerCursor) // n-resize, s-resize, etc ; $R.draggable({ containment: $Container[0] // limit resizing to layout container , axis: (c[pane].dir=="horz" ? "y" : "x") // limit resizing to horz or vert axis , delay: 200 , distance: 3 // basic format for helper - style it using class: .ui-draggable-dragging , helper: "clone" , opacity: o.resizerDragOpacity , zIndex: c.zIndex.resizing , start: function (e, ui) { s.isResizing = true; // prevent pane from closing while resizing clearTimer(pane, "closeSlider"); // just in case already triggered $R.addClass( dragClass +" "+ dragPaneClass ); // add drag classes draggingClassSet = false; // reset logic var - see drag() // SET RESIZING LIMITS - used in drag() var resizerWidth = (pane=="east" || pane=="south" ? o.spacing_open : 0); setPaneMinMaxSizes(pane); // update pane-state s.minPosition -= resizerWidth; s.maxPosition -= resizerWidth; edge = (c[pane].dir=="horz" ? "top" : "left"); } , drag: function (e, ui) { if (!draggingClassSet) { // can only add classes after clone has been added to the DOM $(".ui-draggable-dragging") .addClass( draggingClass +" "+ draggingPaneClass ) // add dragging classes .children().css("visibility","hidden") // hide toggler inside dragged resizer-bar ; draggingClassSet = true; // draggable bug!? RE-SET zIndex to prevent E/W resize-bar showing through N/S pane! if (s.isSliding) $Ps[pane].css("zIndex", c.zIndex.sliding); } // CONTAIN RESIZER-BAR TO RESIZING LIMITS if (ui.position[edge] < s.minPosition) ui.position[edge] = s.minPosition; else if (ui.position[edge] > s.maxPosition) ui.position[edge] = s.maxPosition; } , stop: function (e, ui) { var dragPos = ui.position , resizerPos , newSize ; $R.removeClass( dragClass +" "+ dragPaneClass ); // remove drag classes switch (pane) { case "north": resizerPos = dragPos.top; break; case "west": resizerPos = dragPos.left; break; case "south": resizerPos = cDims.outerHeight - dragPos.top - $R.outerHeight(); break; case "east": resizerPos = cDims.outerWidth - dragPos.left - $R.outerWidth(); break; } // remove container margin from resizer position to get the pane size newSize = resizerPos - cDims[ c[pane].edge ]; sizePane(pane, newSize); s.isResizing = false; } }); }); }; /* * ########################### * ACTION METHODS * ########################### */ /** * hide / show * * Completely 'hides' a pane, including its spacing - as if it does not exist * The pane is not actually 'removed' from the source, so can use 'show' to un-hide it * * @param String pane The pane being hidden, ie: north, south, east, or west */ var hide = function (pane, onInit) { var s = state[pane] , $P = $Ps[pane] , $R = $Rs[pane] ; if (!$P) return; // pane does not exist else if (s.isHidden) return; // already hidden! else s.isHidden = true; // set logic var s.isSliding = false; // just in case // now hide the elements if ($R) $R.hide(); if (onInit) { $P.hide(); // no animation when loading page s.isClosed = true; // to trigger open-animation on show() } else close(pane, true); // adjust all panes to fit }; var show = function (pane, openPane) { var o = options[pane] , s = state[pane] , $P = $Ps[pane] , $R = $Rs[pane] ; if (!$P) return; // pane does not exist else if (!s.isHidden) return; // not hidden! else s.isHidden = false; // set logic var s.isSliding = false; // just in case // now show the elements if ($R && o.spacing_open > 0) $R.show(); if (openPane === false) close(pane, true); // true = force else open(pane); // adjust all panes to fit }; /** * toggle * * Toggles a pane open/closed by calling either open or close * * @param String pane The pane being toggled, ie: north, south, east, or west */ var toggle = function (pane) { var s = state[pane]; if (s.isHidden) show(pane); // will call 'open' after unhiding it else if (s.isClosed) open(pane); else close(pane); }; /** * close * * Close the specified pane (animation optional), and resize all other panes as needed * * @param String pane The pane being closed, ie: north, south, east, or west */ var close = function (pane, force) { var $P = $Ps[pane] , $R = $Rs[pane] , $T = $Ts[pane] , o = options[pane] , s = state[pane] , doFX = (o.fxName != "none") && !s.isClosed , edge = c[pane].edge , rClass = o.resizerClass , tClass = o.togglerClass , _side = "-"+ pane // used for classNames , _open = "-open" , _sliding= "-sliding" , _closed = "-closed" , cP ; if (!$P || (!o.resizable && !o.closable)) return; // invalid request else if (!force && s.isClosed) return; // already closed if (c.isLayoutBusy) { // layout is 'busy' - probably with an animation setFlowCallback("close", pane, force); // set a callback for this action, if possible return; // ABORT } else { // SET flow-control flags cP = c[pane]; cP.isMoving = true; c.isLayoutBusy = true; } s.isClosed = true; // logic // sync any 'pin buttons' syncPinBtns(pane, false); // resize panes adjacent to this one if (!s.isSliding) sizeMidPanes(c[pane].dir == "horz" ? "all" : "center"); // if this pane has a resizer bar, move it now if ($R) { $R .css(edge, cDims[edge]) // move the resizer bar .removeClass( rClass+_open +" "+ rClass+_side+_open ) .removeClass( rClass+_sliding +" "+ rClass+_side+_sliding ) .addClass( rClass+_closed +" "+ rClass+_side+_closed ) ; // DISABLE 'resizing' when closed - do this BEFORE bindStartSlidingEvent if (o.resizable) $R .draggable("disable") .css("cursor", "default") .attr("title","") ; // if pane has a toggler button, adjust that too if ($T) { $T .removeClass( tClass+_open +" "+ tClass+_side+_open ) .addClass( tClass+_closed +" "+ tClass+_side+_closed ) .attr("title", o.togglerTip_closed) // may be blank ; } sizeHandles(); // resize 'length' and position togglers for adjacent panes } // ANIMATE 'CLOSE' - if no animation, then was ALREADY shown above if (doFX) { lockPaneForFX(pane, true); // need to set left/top so animation will work $P.hide( o.fxName, o.fxSettings, o.fxSpeed, function () { lockPaneForFX(pane, false); // undo if (!s.isClosed) return; // pane was opened before animation finished! close_2(); }); } else { $P.hide(); // just hide pane NOW close_2(); } // SUBROUTINE function close_2 () { bindStartSlidingEvent(pane, true); // will enable if state.PANE.isSliding = true // see if there is a callback for this pane execUserCallback(pane, o.onclose); // see if there is a callback for this pane // CHECK FOR internal flow-control callback execFlowCallback(pane); } }; /** * open * * Open the specified pane (animation optional), and resize all other panes as needed * * @param String pane The pane being opened, ie: north, south, east, or west */ var open = function (pane, slide) { var $P = $Ps[pane] , $R = $Rs[pane] , $T = $Ts[pane] , o = options[pane] , s = state[pane] , doFX = (o.fxName != "none") && s.isClosed , edge = c[pane].edge , rClass = o.resizerClass , tClass = o.togglerClass , _side = "-"+ pane // used for classNames , _open = "-open" , _closed = "-closed" , _sliding= "-sliding" , cP ; if (!$P || (!o.resizable && !o.closable)) return; // invalid request else if (!s.isClosed && !s.isSliding) return; // already open if (c.isLayoutBusy) { // layout is 'busy' - probably with an animation setFlowCallback("open", pane, slide); // set a callback for this action, if possible return; // ABORT } else { // SET flow-control flags cP = c[pane]; cP.isMoving = true; c.isLayoutBusy = true; } // 'PIN PANE' - stop sliding if (s.isSliding && !slide) // !slide = 'open pane normally' - NOT sliding bindStopSlidingEvents(pane, false); // will set isSliding=false s.isClosed = false; // logic s.isHidden = false; // logic // Container size may have changed - shrink the pane if now 'too big' setPaneMinMaxSizes(pane); // update pane-state if (s.size > s.maxSize) // pane is too big! resize it before opening $P.css( c[pane].sizeType, max(1, cssSize(pane, s.maxSize)) ); bindStartSlidingEvent(pane, false); // remove trigger event from resizer-bar if (doFX) { // ANIMATE lockPaneForFX(pane, true); // need to set left/top so animation will work $P.show( o.fxName, o.fxSettings, o.fxSpeed, function() { lockPaneForFX(pane, false); // undo if (s.isClosed) return; // pane was closed before animation finished! open_2(); // continue }); } else {// no animation $P.show(); // just show pane and... open_2(); // continue } // SUBROUTINE function open_2 () { // NOTE: if isSliding, then other panes are NOT 'resized' if (!s.isSliding) // resize all panes adjacent to this one sizeMidPanes(c[pane].dir=="vert" ? "center" : "all"); // if this pane has a toggler, move it now if ($R) { $R .css(edge, cDims[edge] + getPaneSize(pane)) // move the toggler .removeClass( rClass+_closed +" "+ rClass+_side+_closed ) .addClass( rClass+_open +" "+ rClass+_side+_open ) .addClass( !s.isSliding ? "" : rClass+_sliding +" "+ rClass+_side+_sliding ) ; if (o.resizable) $R .draggable("enable") .css("cursor", o.resizerCursor) .attr("title", o.resizerTip) ; else $R.css("cursor", "default"); // n-resize, s-resize, etc // if pane also has a toggler button, adjust that too if ($T) { $T .removeClass( tClass+_closed +" "+ tClass+_side+_closed ) .addClass( tClass+_open +" "+ tClass+_side+_open ) .attr("title", o.togglerTip_open) // may be blank ; } sizeHandles("all"); // resize resizer & toggler sizes for all panes } // resize content every time pane opens - to be sure sizeContent(pane); // sync any 'pin buttons' syncPinBtns(pane, !s.isSliding); // see if there is a callback for this pane execUserCallback(pane, o.onopen); // CHECK FOR internal flow-control callback execFlowCallback(pane); } }; /** * lockPaneForFX * * Must set left/top on East/South panes so animation will work properly * * @param String pane The pane to lock, 'east' or 'south' - any other is ignored! * @param Boolean doLock true = set left/top, false = remove */ var lockPaneForFX = function (pane, doLock) { var $P = $Ps[pane]; if (doLock) { $P.css({ zIndex: c.zIndex.animation }); // overlay all elements during animation if (pane=="south") $P.css({ top: cDims.top + cDims.innerHeight - $P.outerHeight() }); else if (pane=="east") $P.css({ left: cDims.left + cDims.innerWidth - $P.outerWidth() }); } else { if (!state[pane].isSliding) $P.css({ zIndex: c.zIndex.pane_normal }); if (pane=="south") $P.css({ top: "auto" }); else if (pane=="east") $P.css({ left: "auto" }); } }; /** * bindStartSlidingEvent * * Toggle sliding functionality of a specific pane on/off by adding removing 'slide open' trigger * * @callers open(), close() * @param String pane The pane to enable/disable, 'north', 'south', etc. * @param Boolean enable Enable or Disable sliding? */ var bindStartSlidingEvent = function (pane, enable) { var o = options[pane] , $R = $Rs[pane] , trigger = o.slideTrigger_open ; if (!$R || !o.slidable) return; // make sure we have a valid event if (trigger != "click" && trigger != "dblclick" && trigger != "mouseover") trigger = "click"; $R // add or remove trigger event [enable ? "bind" : "unbind"](trigger, slideOpen) // set the appropriate cursor & title/tip .css("cursor", (enable ? o.sliderCursor: "default")) .attr("title", (enable ? o.sliderTip : "")) ; }; /** * bindStopSlidingEvents * * Add or remove 'mouseout' events to 'slide close' when pane is 'sliding' open or closed * Also increases zIndex when pane is sliding open * See bindStartSlidingEvent for code to control 'slide open' * * @callers slideOpen(), slideClosed() * @param String pane The pane to process, 'north', 'south', etc. * @param Boolean isOpen Is pane open or closed? */ var bindStopSlidingEvents = function (pane, enable) { var o = options[pane] , s = state[pane] , trigger = o.slideTrigger_close , action = (enable ? "bind" : "unbind") // can't make 'unbind' work! - see disabled code below , $P = $Ps[pane] , $R = $Rs[pane] ; s.isSliding = enable; // logic clearTimer(pane, "closeSlider"); // just in case // raise z-index when sliding $P.css({ zIndex: (enable ? c.zIndex.sliding : c.zIndex.pane_normal) }); $R.css({ zIndex: (enable ? c.zIndex.sliding : c.zIndex.resizer_normal) }); // make sure we have a valid event if (trigger != "click" && trigger != "mouseout") trigger = "mouseout"; // when trigger is 'mouseout', must cancel timer when mouse moves between 'pane' and 'resizer' if (enable) { // BIND trigger events $P.bind(trigger, slideClosed ); $R.bind(trigger, slideClosed ); if (trigger = "mouseout") { $P.bind("mouseover", cancelMouseOut ); $R.bind("mouseover", cancelMouseOut ); } } else { // UNBIND trigger events // TODO: why does unbind of a 'single function' not work reliably? //$P[action](trigger, slideClosed ); $P.unbind(trigger); $R.unbind(trigger); if (trigger = "mouseout") { //$P[action]("mouseover", cancelMouseOut ); $P.unbind("mouseover"); $R.unbind("mouseover"); clearTimer(pane, "closeSlider"); } } // SUBROUTINE for mouseout timer clearing function cancelMouseOut (evt) { clearTimer(pane, "closeSlider"); evt.stopPropagation(); } }; var slideOpen = function () { var pane = $(this).attr("resizer"); // attr added by initHandles if (state[pane].isClosed) { // skip if already open! bindStopSlidingEvents(pane, true); // pane is opening, so BIND trigger events to close it open(pane, true); // true = slide - ie, called from here! } }; var slideClosed = function () { var $E = $(this) , pane = $E.attr("pane") || $E.attr("resizer") , o = options[pane] , s = state[pane] ; if (s.isClosed || s.isResizing) return; // skip if already closed OR in process of resizing else if (o.slideTrigger_close == "click") close_NOW(); // close immediately onClick else // trigger = mouseout - use a delay setTimer(pane, "closeSlider", close_NOW, 300); // .3 sec delay // SUBROUTINE for timed close function close_NOW () { bindStopSlidingEvents(pane, false); // pane is being closed, so UNBIND trigger events if (!s.isClosed) close(pane); // skip if already closed! } }; /** * sizePane * * @callers initResizable.stop() * @param String pane The pane being resized - usually west or east, but potentially north or south * @param Integer newSize The new size for this pane - will be validated */ var sizePane = function (pane, size) { // TODO: accept "auto" as size, and size-to-fit pane content var edge = c[pane].edge , dir = c[pane].dir , o = options[pane] , s = state[pane] , $P = $Ps[pane] , $R = $Rs[pane] ; // calculate 'current' min/max sizes setPaneMinMaxSizes(pane); // update pane-state // compare/update calculated min/max to user-options s.minSize = max(s.minSize, o.minSize); if (o.maxSize > 0) s.maxSize = min(s.maxSize, o.maxSize); // validate passed size size = max(size, s.minSize); size = min(size, s.maxSize); s.size = size; // update state // move the resizer bar and resize the pane $R.css( edge, size + cDims[edge] ); $P.css( c[pane].sizeType, max(1, cssSize(pane, size)) ); // resize all the adjacent panes, and adjust their toggler buttons if (!s.isSliding) sizeMidPanes(dir=="horz" ? "all" : "center"); sizeHandles(); sizeContent(pane); execUserCallback(pane, o.onresize); }; /** * sizeMidPanes * * @callers create(), open(), close(), onWindowResize() */ var sizeMidPanes = function (panes, overrideDims, onInit) { if (!panes || panes == "all") panes = "east,west,center"; var d = getPaneDims(); if (overrideDims) $.extend( d, overrideDims ); $.each(panes.split(","), function() { if (!$Ps[this]) return; // NO PANE - skip var pane = str(this) , o = options[pane] , s = state[pane] , $P = $Ps[pane] , $R = $Rs[pane] , hasRoom = true , CSS = {} ; if (pane == "center") { d = getPaneDims(); // REFRESH Dims because may have just 'unhidden' East or West pane after a 'resize' CSS = $.extend( {}, d ); // COPY ALL of the paneDims CSS.width = max(1, cssW(pane, CSS.width)); CSS.height = max(1, cssH(pane, CSS.height)); hasRoom = (CSS.width > 1 && CSS.height > 1); /* * Extra CSS for IE6 or IE7 in Quirks-mode - add 'width' to NORTH/SOUTH panes * Normally these panes have only 'left' & 'right' positions so pane auto-sizes */ if ($.browser.msie && (!$.boxModel || $.browser.version < 7)) { if ($Ps.north) $Ps.north.css({ width: cssW($Ps.north, cDims.innerWidth) }); if ($Ps.south) $Ps.south.css({ width: cssW($Ps.south, cDims.innerWidth) }); } } else { // for east and west, set only the height CSS.top = d.top; CSS.bottom = d.bottom; CSS.height = max(1, cssH(pane, d.height)); hasRoom = (CSS.height > 1); } if (hasRoom) { $P.css(CSS); if (s.noRoom) { s.noRoom = false; if (s.isHidden) return; if (!s.isClosed) $P.show(); // in case was previously hidden due to NOT hasRoom if ($R) $R.show(); } if (!onInit) { sizeContent(pane); execUserCallback(pane, o.onresize); } } else if (!s.noRoom) { // no room for pane, so just hide it (if not already) s.noRoom = true; if (s.isHidden) return; $P.hide(); if ($R) $R.hide(); } }); }; var sizeContent = function (panes) { if (!panes || panes == "all") panes = c.allPanes; $.each(panes.split(","), function() { if (!$Cs[this]) return; // NO CONTENT - skip var pane = str(this) , ignore = options[pane].contentIgnoreSelector , $P = $Ps[pane] , $C = $Cs[pane] , e_C = $C[0] // DOM element , height = cssH($P); // init to pane.innerHeight ; $P.children().each(function() { if (this == e_C) return; // Content elem - skip var $E = $(this); if (!ignore || !$E.is(ignore)) height -= $E.outerHeight(); }); if (height > 0) height = cssH($C, height); if (height < 1) $C.hide(); // no room for content! else $C.css({ height: height }).show(); }); }; /** * sizeHandles * * Called every time a pane is opened, closed, or resized to slide the togglers to 'center' and adjust their length if necessary * * @callers initHandles(), open(), close(), resizeAll() */ var sizeHandles = function (panes, onInit) { if (!panes || panes == "all") panes = c.borderPanes; $.each(panes.split(","), function() { var pane = str(this) , o = options[pane] , s = state[pane] , $P = $Ps[pane] , $R = $Rs[pane] , $T = $Ts[pane] ; if (!$P || !$R || (!o.resizable && !o.closable)) return; // skip var dir = c[pane].dir , _state = (s.isClosed ? "_closed" : "_open") , spacing = o["spacing"+ _state] , togAlign = o["togglerAlign"+ _state] , togLen = o["togglerLength"+ _state] , paneLen , offset , CSS = {} ; if (spacing == 0) { $R.hide(); return; } else if (!s.noRoom && !s.isHidden) // skip if resizer was hidden for any reason $R.show(); // in case was previously hidden // Resizer Bar is ALWAYS same width/height of pane it is attached to if (dir == "horz") { // north/south paneLen = $P.outerWidth(); $R.css({ width: max(1, cssW($R, paneLen)) // account for borders & padding , height: max(1, cssH($R, spacing)) // ditto , left: cssNum($P, "left") }); } else { // east/west paneLen = $P.outerHeight(); $R.css({ height: max(1, cssH($R, paneLen)) // account for borders & padding , width: max(1, cssW($R, spacing)) // ditto , top: cDims.top + getPaneSize("north", true) //, top: cssNum($Ps["center"], "top") }); } if ($T) { if (togLen == 0 || (s.isSliding && o.hideTogglerOnSlide)) { $T.hide(); // always HIDE the toggler when 'sliding' return; } else $T.show(); // in case was previously hidden if (!(togLen > 0) || togLen == "100%" || togLen > paneLen) { togLen = paneLen; offset = 0; } else { // calculate 'offset' based on options.PANE.togglerAlign_open/closed if (typeof togAlign == "string") { switch (togAlign) { case "top": case "left": offset = 0; break; case "bottom": case "right": offset = paneLen - togLen; break; case "middle": case "center": default: offset = Math.floor((paneLen - togLen) / 2); // 'default' catches typos } } else { // togAlign = number var x = parseInt(togAlign); // if (togAlign >= 0) offset = x; else offset = paneLen - togLen + x; // NOTE: x is negative! } } var $TC_o = (o.togglerContent_open ? $T.children(".content-open") : false) , $TC_c = (o.togglerContent_closed ? $T.children(".content-closed") : false) , $TC = (s.isClosed ? $TC_c : $TC_o) ; if ($TC_o) $TC_o.css("display", s.isClosed ? "none" : "block"); if ($TC_c) $TC_c.css("display", s.isClosed ? "block" : "none"); if (dir == "horz") { // north/south var width = cssW($T, togLen); $T.css({ width: max(0, width) // account for borders & padding , height: max(1, cssH($T, spacing)) // ditto , left: offset // TODO: VERIFY that toggler positions correctly for ALL values }); if ($TC) // CENTER the toggler content SPAN $TC.css("marginLeft", Math.floor((width-$TC.outerWidth())/2)); // could be negative } else { // east/west var height = cssH($T, togLen); $T.css({ height: max(0, height) // account for borders & padding , width: max(1, cssW($T, spacing)) // ditto , top: offset // POSITION the toggler }); if ($TC) // CENTER the toggler content SPAN $TC.css("marginTop", Math.floor((height-$TC.outerHeight())/2)); // could be negative } } // DONE measuring and sizing this resizer/toggler, so can be 'hidden' now if (onInit && o.initHidden) { $R.hide(); if ($T) $T.hide(); } }); }; /** * resizeAll * * @callers window.onresize(), callbacks or custom code */ var resizeAll = function () { var oldW = cDims.innerWidth , oldH = cDims.innerHeight ; cDims = state.container = getElemDims($Container); // UPDATE container dimensions var checkH = (cDims.innerHeight < oldH) , checkW = (cDims.innerWidth < oldW) , s, dir ; if (checkH || checkW) // NOTE special order for sizing: S-N-E-W $.each(["south","north","east","west"], function(i,pane) { s = state[pane]; dir = c[pane].dir; if (!s.isClosed && ((checkH && dir=="horz") || (checkW && dir=="vert"))) { setPaneMinMaxSizes(pane); // update pane-state // shrink pane if 'too big' to fit if (s.size > s.maxSize) sizePane(pane, s.maxSize); } }); sizeMidPanes("all"); sizeHandles("all"); // reposition the toggler elements }; /** * keyDown * * Capture keys when enableCursorHotkey - toggle pane if hotkey pressed * * @callers document.keydown() */ function keyDown (evt) { if (!evt) return true; var code = evt.keyCode; if (code < 33) return true; // ignore special keys: ENTER, TAB, etc var PANE = { 38: "north" // Up Cursor , 40: "south" // Down Cursor , 37: "west" // Left Cursor , 39: "east" // Right Cursor } , isCursorKey = (code >= 37 && code <= 40) , ALT = evt.altKey // no worky! , SHIFT = evt.shiftKey , CTRL = evt.ctrlKey , pane = false , s, o, k, m, el ; if (!CTRL && !SHIFT) return true; // no modifier key - abort else if (isCursorKey && o[PANE[code]].enableCursorHotkey) // valid cursor-hotkey pane = PANE[code]; else // check to see if this matches a custom-hotkey $.each(c.borderPanes.split(","), function(i,p) { // loop each pane to check its hotkey o = options[p]; k = o.customHotkey; m = o.customHotkeyModifier; // if missing or invalid, treated as "CTRL+SHIFT" if ((SHIFT && m=="SHIFT") || (CTRL && m=="CTRL") || (CTRL && SHIFT)) { // Modifier matches if (k && code == (isNaN(k) || k <= 9 ? k.toUpperCase().charCodeAt(0) : k)) { // Key matches pane = p; return false; // BREAK } } }); if (!pane) return true; // no hotkey - abort // validate pane o = options[pane]; // get pane options s = state[pane]; // get pane options if (!o.enableCursorHotkey || s.isHidden || !$Ps[pane]) return true; // see if user is in a 'form field' because may be 'selecting text'! el = evt.target || evt.srcElement; if (el && SHIFT && isCursorKey && (el.tagName=="TEXTAREA" || (el.tagName=="INPUT" && (code==37 || code==39)))) return true; // allow text-selection // SYNTAX NOTES // use "returnValue=false" to abort keystroke but NOT abort function - can run another command afterwards // use "return false" to abort keystroke AND abort function toggle(pane); evt.stopPropagation(); evt.returnValue = false; // CANCEL key return false; }; /* * ########################### * UTILITY METHODS * called externally only * ########################### */ function allowOverflow (elem) { if (this && this.tagName) elem = this; // BOUND to element var $P; if (typeof elem=="string") $P = $Ps[elem]; else { if ($(elem).attr("pane")) $P = $(elem); else $P = $(elem).parents("div[pane]:first"); } if (!$P.length) return; // INVALID var pane = $P.attr("pane") , s = state[pane] ; // if pane is already raised, then reset it before doing it again! // this would happen if allowOverflow is attached to BOTH the pane and an element if (s.cssSaved) resetOverflow(pane); // reset previous CSS before continuing // if pane is raised by sliding or resizing, or it's closed, then abort if (s.isSliding || s.isResizing || s.isClosed) { s.cssSaved = false; return; } var newCSS = { zIndex: (c.zIndex.pane_normal + 1) } , curCSS = {} , of = $P.css("overflow") , ofX = $P.css("overflowX") , ofY = $P.css("overflowY") ; // determine which, if any, overflow settings need to be changed if (of != "visible") { curCSS.overflow = of; newCSS.overflow = "visible"; } if (ofX && ofX != "visible" && ofX != "auto") { curCSS.overflowX = ofX; newCSS.overflowX = "visible"; } if (ofY && ofY != "visible" && ofY != "auto") { curCSS.overflowY = ofX; newCSS.overflowY = "visible"; } // save the current overflow settings - even if blank! s.cssSaved = curCSS; // apply new CSS to raise zIndex and, if necessary, make overflow 'visible' $P.css( newCSS ); // make sure the zIndex of all other panes is normal $.each(c.allPanes.split(","), function(i, p) { if (p != pane) resetOverflow(p); }); }; function resetOverflow (elem) { if (this && this.tagName) elem = this; // BOUND to element var $P; if (typeof elem=="string") $P = $Ps[elem]; else { if ($(elem).hasClass("ui-layout-pane")) $P = $(elem); else $P = $(elem).parents("div[pane]:first"); } if (!$P.length) return; // INVALID var pane = $P.attr("pane") , s = state[pane] , CSS = s.cssSaved || {} ; // reset the zIndex if (!s.isSliding && !s.isResizing) $P.css("zIndex", c.zIndex.pane_normal); // reset Overflow - if necessary $P.css( CSS ); // clear var s.cssSaved = false; }; /** * getBtn * * Helper function to validate params received by addButton utilities * * @param String selector jQuery selector for button, eg: ".ui-layout-north .toggle-button" * @param String pane Name of the pane the button is for: 'north', 'south', etc. * @returns If both params valid, the element matching 'selector' in a jQuery wrapper - otherwise 'false' */ function getBtn(selector, pane, action) { var $E = $(selector) , err = "Error Adding Button \n\nInvalid " ; if (!$E.length) // element not found alert(err+"selector: "+ selector); else if (c.borderPanes.indexOf(pane) == -1) // invalid 'pane' sepecified alert(err+"pane: "+ pane); else { // VALID var btn = options[pane].buttonClass +"-"+ action; $E.addClass( btn +" "+ btn +"-"+ pane ); return $E; } return false; // INVALID }; /** * addToggleBtn * * Add a custom Toggler button for a pane * * @param String selector jQuery selector for button, eg: ".ui-layout-north .toggle-button" * @param String pane Name of the pane the button is for: 'north', 'south', etc. */ function addToggleBtn (selector, pane) { var $E = getBtn(selector, pane, "toggle"); if ($E) $E .attr("title", state[pane].isClosed ? "Open" : "Close") .click(function (evt) { toggle(pane); evt.stopPropagation(); }) ; }; /** * addOpenBtn * * Add a custom Open button for a pane * * @param String selector jQuery selector for button, eg: ".ui-layout-north .open-button" * @param String pane Name of the pane the button is for: 'north', 'south', etc. */ function addOpenBtn (selector, pane) { var $E = getBtn(selector, pane, "open"); if ($E) $E .attr("title", "Open") .click(function (evt) { open(pane); evt.stopPropagation(); }) ; }; /** * addCloseBtn * * Add a custom Close button for a pane * * @param String selector jQuery selector for button, eg: ".ui-layout-north .close-button" * @param String pane Name of the pane the button is for: 'north', 'south', etc. */ function addCloseBtn (selector, pane) { var $E = getBtn(selector, pane, "close"); if ($E) $E .attr("title", "Close") .click(function (evt) { close(pane); evt.stopPropagation(); }) ; }; /** * addPinBtn * * Add a custom Pin button for a pane * * Four classes are added to the element, based on the paneClass for the associated pane... * Assuming the default paneClass and the pin is 'up', these classes are added for a west-pane pin: * - ui-layout-pane-pin * - ui-layout-pane-west-pin * - ui-layout-pane-pin-up * - ui-layout-pane-west-pin-up * * @param String selector jQuery selector for button, eg: ".ui-layout-north .ui-layout-pin" * @param String pane Name of the pane the pin is for: 'north', 'south', etc. */ function addPinBtn (selector, pane) { var $E = getBtn(selector, pane, "pin"); if ($E) { var s = state[pane]; $E.click(function (evt) { setPinState($(this), pane, (s.isSliding || s.isClosed)); if (s.isSliding || s.isClosed) open( pane ); // change from sliding to open else close( pane ); // slide-closed evt.stopPropagation(); }); // add up/down pin attributes and classes setPinState ($E, pane, (!s.isClosed && !s.isSliding)); // add this pin to the pane data so we can 'sync it' automatically // PANE.pins key is an array so we can store multiple pins for each pane c[pane].pins.push( selector ); // just save the selector string } }; /** * syncPinBtns * * INTERNAL function to sync 'pin buttons' when pane is opened or closed * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes * * @callers open(), close() * @params pane These are the params returned to callbacks by layout() * @params doPin True means set the pin 'down', False means 'up' */ function syncPinBtns (pane, doPin) { $.each(c[pane].pins, function (i, selector) { setPinState($(selector), pane, doPin); }); }; /** * setPinState * * Change the class of the pin button to make it look 'up' or 'down' * * @callers addPinBtn(), syncPinBtns() * @param Element $Pin The pin-span element in a jQuery wrapper * @param Boolean doPin True = set the pin 'down', False = set it 'up' * @param String pinClass The root classname for pins - will add '-up' or '-down' suffix */ function setPinState ($Pin, pane, doPin) { var updown = $Pin.attr("pin"); if (updown && doPin == (updown=="down")) return; // already in correct state var root = options[pane].buttonClass , class1 = root +"-pin" , class2 = class1 +"-"+ pane , UP1 = class1 + "-up" , UP2 = class2 + "-up" , DN1 = class1 + "-down" , DN2 = class2 + "-down" ; $Pin .attr("pin", doPin ? "down" : "up") // logic .attr("title", doPin ? "Un-Pin" : "Pin") .removeClass( doPin ? UP1 : DN1 ) .removeClass( doPin ? UP2 : DN2 ) .addClass( doPin ? DN1 : UP1 ) .addClass( doPin ? DN2 : UP2 ) ; }; /* * ########################### * CREATE/RETURN BORDER-LAYOUT * ########################### */ // init global vars var $Container = $(this).css({ overflow: "hidden" }) // Container elem , $Ps = {} // Panes x4 - set in initPanes() , $Cs = {} // Content x4 - set in initPanes() , $Rs = {} // Resizers x4 - set in initHandles() , $Ts = {} // Togglers x4 - set in initHandles() // object aliases , c = config // alias for config hash , cDims = state.container // alias for easy access to 'container dimensions' ; // create the border layout NOW create(); // return object pointers to expose data & option Properties, and primary action Methods return { options: options // property - options hash , state: state // property - dimensions hash , panes: $Ps // property - object pointers for ALL panes: panes.north, panes.center , toggle: toggle // method - pass a 'pane' ("north", "west", etc) , open: open // method - ditto , close: close // method - ditto , hide: hide // method - ditto , show: show // method - ditto , resizeContent: sizeContent // method - ditto , sizePane: sizePane // method - pass a 'pane' AND a 'size' in pixels , resizeAll: resizeAll // method - no parameters , addToggleBtn: addToggleBtn // utility - pass element selector and 'pane' , addOpenBtn: addOpenBtn // utility - ditto , addCloseBtn: addCloseBtn // utility - ditto , addPinBtn: addPinBtn // utility - ditto , allowOverflow: allowOverflow // utility - pass calling element , resetOverflow: resetOverflow // utility - ditto , cssWidth: cssW , cssHeight: cssH }; } })( jQuery );
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/jquery.layout.js
JavaScript
gpl2
74,446
;(function($){ /** * jqGrid extension for manipulating columns properties * Piotr Roznicki roznicki@o2.pl * http://www.roznicki.prv.pl * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ setColumns : function(p) { p = $.extend({ top : 0, left: 0, width: 200, height: 195, modal: false, drag: true, closeicon: 'ico-close.gif', beforeShowForm: null, afterShowForm: null, afterSubmitForm: null }, $.jgrid.col, p ||{}); return this.each(function(){ var $t = this; if (!$t.grid ) { return; } var onBeforeShow = typeof p.beforeShowForm === 'function' ? true: false; var onAfterShow = typeof p.afterShowForm === 'function' ? true: false; var onAfterSubmit = typeof p.afterSubmitForm === 'function' ? true: false; if(!p.imgpath) { p.imgpath= $t.p.imgpath; } // Added From Tony Tomov var gID = $("table:first",$t.grid.bDiv).attr("id"); var IDs = {themodal:'colmod'+gID,modalhead:'colhd'+gID,modalcontent:'colcnt'+gID}; var dtbl = "ColTbl_"+gID; if ( $("#"+IDs.themodal).html() != null ) { if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); } viewModal("#"+IDs.themodal,{modal:p.modal}); if(onAfterShow) { p.afterShowForm($("#"+dtbl)); } } else { var tbl =$("<table id='"+dtbl+"' class='ColTable'><tbody></tbody></table>"); for(i=0;i<this.p.colNames.length;i++){ if(!$t.p.colModel[i].hidedlg) { // added from T. Tomov $(tbl).append("<tr><td ><input type='checkbox' id='col_" + this.p.colModel[i].name + "' class='cbox' value='T' " + ((this.p.colModel[i].hidden==undefined)?"checked":"") + "/>" + "<label for='col_" + this.p.colModel[i].name + "'>" + this.p.colNames[i] + "(" + this.p.colModel[i].name + ")</label></td></tr>"); } } var bS ="<input id='dData' type='button' value='"+p.bSubmit+"'/>"; var bC ="<input id='eData' type='button' value='"+p.bCancel+"'/>"; $(tbl).append("<tr><td class='ColButton'>"+bS+"&nbsp;"+bC+"</td></tr>"); createModal(IDs,tbl,p,$t.grid.hDiv,$t.grid.hDiv); if( p.drag) { DnRModal("#"+IDs.themodal,"#"+IDs.modalhead+" td.modaltext"); } $("#dData","#"+dtbl).click(function(e){ for(i=0;i<$t.p.colModel.length;i++){ if(!$t.p.colModel[i].hidedlg) { // added from T. Tomov if($("#col_" + $t.p.colModel[i].name).attr("checked")) { $($t).showCol($t.p.colModel[i].name); $("#col_" + $t.p.colModel[i].name).attr("defaultChecked",true); // Added from T. Tomov IE BUG } else { $($t).hideCol($t.p.colModel[i].name); $("#col_" + $t.p.colModel[i].name).attr("defaultChecked",""); // Added from T. Tomov IE BUG } } } $("#"+IDs.themodal).jqmHide(); if (onAfterSubmit) { p.afterSubmitForm($("#"+dtbl)); } return false; }); $("#eData", "#"+dtbl).click(function(e){ $("#"+IDs.themodal).jqmHide(); return false; }); if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); } viewModal("#"+IDs.themodal,{modal:p.modal}); if(onAfterShow) { p.afterShowForm($("#"+dtbl)); } } }); } }); })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.setcolumns.js
JavaScript
gpl2
3,251
;(function($){ /** * jqGrid Italian Translation * Vincenzo Solomita vincenzosolomita@gmail.com * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "Record", loadtext: "Caricamento...", pgtext : "/" }; $.jgrid.search = { caption: "Ricerca...", Find: "Cerca", Reset: "Pulisci", odata : ['uguale', 'diverso', 'minore', 'minore o uguale','maggiore','maggiore o uguale', 'inizia con','finisce con','contiene' ] }; $.jgrid.edit = { addCaption: "Aggiungi Record", editCaption: "Modifica Record", bSubmit: "Invia", bCancel: "Annulla", bClose: "Chiudi", processData: "In elaborazione...", msg: { required:"Campo richiesto", number:"Per favore, inserisci un valore valido", minValue:"il valore deve essere maggiore o uguale a ", maxValue:"il valore deve essere minore o uguale a", email: "e-mail non corretta", integer: "Please, enter valid integer value", date: "Please, enter valid date value" } }; $.jgrid.del = { caption: "Cancella", msg: "Cancellare record selezionato/i?", bSubmit: "Cancella", bCancel: "Annulla", processData: "In elaborazione..." }; $.jgrid.nav = { edittext: " ", edittitle: "Modifica record selezionato", addtext:" ", addtitle: "Aggiungi nuovo record", deltext: " ", deltitle: "Cancella record selezionato", searchtext: " ", searchtitle: "Ricerca record", refreshtext: "", refreshtitle: "Aggiorna griglia", alertcap: "Attenzione", alerttext: "Per favore, seleziona un record" }; // setcolumns module $.jgrid.col ={ caption: "Mostra/Nascondi Colonne", bSubmit: "Invia", bCancel: "Annulla" }; $.jgrid.errors = { errcap : "Errore", nourl : "Url non settata", norecords: "Nessun record da elaborare", model : "Length of colNames <> colModel!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], AmPm : ["am","pm","AM","PM"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'}, srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'show' }; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-it.js
JavaScript
gpl2
3,474
// we make it simple as possible function jqGridInclude() { var pathtojsfiles = "js/"; // need to be ajusted // if you do not want some module to be included // set include to false. // by default all modules are included. var minver = false; var modules = [ { include: true, incfile:'grid.locale-en.js',minfile: 'min/grid.locale-en-min.js'}, // jqGrid translation { include: true, incfile:'grid.base.js',minfile: 'min/grid.base-min.js'}, // jqGrid base { include: false, incfile:'grid.common.js',minfile: 'min/grid.inlinedit-min.js' }, // jqGrid common for editing { include: false, incfile:'grid.formedit.js',minfile: 'min/grid.formedit-min.js' }, // jqGrid Form editing { include: false, incfile:'grid.inlinedit.js',minfile: 'min/grid.inlinedit-min.js' }, // jqGrid inline editing { include: false, incfile:'grid.celledit.js',minfile: 'min/grid.inlinedit-min.js' }, // jqGrid cell editing { include: false, incfile:'grid.subgrid.js',minfile: 'min/grid.subgrid-min.js'}, //jqGrid subgrid { include: false, incfile:'grid.treegrid.js',minfile: 'min/grid.subgrid-min.js'}, //jqGrid treegrid { include: false, incfile:'grid.custom.js',minfile: 'min/grid.custom-min.js'}, //jqGrid custom { include: false, incfile:'grid.postext.js',minfile: 'min/grid.postext-min.js'}, //jqGrid postext { include: false, incfile:'grid.tbltogrid.js',minfile: 'min/grid.tbltogrid-min.js'}, //jqGrid custom { include: false, incfile:'grid.setcolumns.js',minfile: 'min/grid.setcolumns-min.js'} //jqGrid postext ]; var filename; for(var i=0;i<modules.length; i++) { if(modules[i].include === true) { if (minver !== true) { filename = pathtojsfiles+modules[i].incfile; } else { filename = pathtojsfiles+modules[i].minfile; } //try { IncludeJavaScript(filename); } catch(e) { alert(e)}; $.ajax({url:filename,async:false,dataType: 'script', cache: true}); } } function IncludeJavaScript(jsFile) { var oHead = document.getElementsByTagName('head')[0]; var oScript = document.createElement('script'); oScript.type = 'text/javascript'; oScript.encoding = 'UTF-8'; oScript.src = jsFile; oHead.appendChild(oScript); } }; jqGridInclude();
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/jquery.jqGrid2.js
JavaScript
gpl2
2,399
;(function($){ /* * jqGrid extension for constructing Grid Data from external file * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ jqGridImport : function(o) { o = $.extend({ imptype : "xml", // xml, json, xmlstring, jsonstring impstring: "", impurl: "", mtype: "GET", impData : {}, xmlGrid :{ config : "roots>grid", data: "roots>rows" }, jsonGrid :{ config : "grid", data: "data" } }, o || {}); return this.each(function(){ var $t = this; var XmlConvert = function (xml,o) { var cnfg = $(o.xmlGrid.config,xml)[0]; var xmldata = $(o.xmlGrid.data,xml)[0]; if(xmlJsonClass.xml2json && JSON.parse) { var jstr = xmlJsonClass.xml2json(cnfg," "); var jstr = JSON.parse(jstr); for(var key in jstr) { var jstr1=jstr[key];} if(xmldata) { // save the datatype var svdatatype = jstr.grid.datatype; jstr.grid.datatype = 'xmlstring'; jstr.grid.datastr = xml; $($t).jqGrid( jstr1 ).setGridParam({datatype:svdatatype}); } else { $($t).jqGrid( jstr1 ); } jstr = null;jstr1=null; } else { alert("xml2json or json.parse are not present"); } }; var JsonConvert = function (jsonstr,o){ if (jsonstr && typeof jsonstr == 'string' && JSON.parse) { var json = JSON.parse(jsonstr); var gprm = json[o.jsonGrid.config]; var jdata = json[o.jsonGrid.data]; if(jdata) { var svdatatype = gprm.datatype; gprm.datatype = 'jsonstring'; gprm.datastr = jdata; $($t).jqGrid( gprm ).setGridParam({datatype:svdatatype}); } else { $($t).jqGrid( gprm ); } } }; switch (o.imptype){ case 'xml': $.ajax({ url:o.impurl, type:o.mtype, data: o.impData, dataType:"xml", complete: function(xml,stat) { if(stat == 'success') { XmlConvert(xml.responseXML,o); xml=null; } } }); break; case 'xmlstring' : // we need to make just the conversion and use the same code as xml if(o.impstring && typeof o.impstring == 'string') { var xmld = xmlJsonClass.parseXml(o.impstring); if(xmld) { XmlConvert(xmld,o); xmld = null; } } break; case 'json': $.ajax({ url:o.impurl, type:o.mtype, data: o.impData, dataType:"json", complete: function(json,stat) { if(stat == 'success') { JsonConvert(json.responseText,o ); json=null; } } }); break; case 'jsonstring' : if(o.impstring && typeof o.impstring == 'string') { JsonConvert(o.impstring,o ); } break; } }); }, jqGridExport : function(o) { o = $.extend({ exptype : "xmlstring" }, o || {}); var ret = null; this.each(function () { if(!this.grid) { return;} var gprm = $(this).getGridParam(); switch (o.exptype) { case 'xmlstring' : ret = xmlJsonClass.json2xml(gprm," "); break; case 'jsonstring' : ret = JSON.stringify(gprm); break; } }); return ret; } }); })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.import.js
JavaScript
gpl2
5,524
/** * TableDnD plug-in for JQuery, allows you to drag and drop table rows * You can set up various options to control how the system will work * Copyright (c) Denis Howlett <denish@isocra.com> * Licensed like jQuery, see http://docs.jquery.com/License. * * Configuration options: * * onDragStyle * This is the style that is assigned to the row during drag. There are limitations to the styles that can be * associated with a row (such as you can't assign a border--well you can, but it won't be * displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as * a map (as used in the jQuery css(...) function). * onDropStyle * This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations * to what you can do. Also this replaces the original style, so again consider using onDragClass which * is simply added and then removed on drop. * onDragClass * This class is added for the duration of the drag and then removed when the row is dropped. It is more * flexible than using onDragStyle since it can be inherited by the row cells and other content. The default * is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your * stylesheet. * onDrop * Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table * and the row that was dropped. You can work out the new order of the rows by using * table.rows. * onDragStart * Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the * table and the row which the user has started to drag. * onAllowDrop * Pass a function that will be called as a row is over another row. If the function returns true, allow * dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under * the cursor. It returns a boolean: true allows the drop, false doesn't allow it. * scrollAmount * This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the * window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2, * FF3 beta * dragHandle * This is the name of a class that you assign to one or more cells in each row that is draggable. If you * specify this class, then you are responsible for setting cursor: move in the CSS and only these cells * will have the drag behaviour. If you do not specify a dragHandle, then you get the old behaviour where * the whole row is draggable. * * Other ways to control behaviour: * * Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows * that you don't want to be draggable. * * Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form * <tableID>[]=<rowID1>&<tableID>[]=<rowID2> so that you can send this back to the server. The table must have * an ID as must all the rows. * * Other methods: * * $("...").tableDnDUpdate() * Will update all the matching tables, that is it will reapply the mousedown method to the rows (or handle cells). * This is useful if you have updated the table rows using Ajax and you want to make the table draggable again. * The table maintains the original configuration (so you don't have to specify it again). * * $("...").tableDnDSerialize() * Will serialize and return the serialized string as above, but for each of the matching tables--so it can be * called from anywhere and isn't dependent on the currentTable being set up correctly before calling * * Known problems: * - Auto-scoll has some problems with IE7 (it scrolls even when it shouldn't), work-around: set scrollAmount to 0 * * Version 0.2: 2008-02-20 First public version * Version 0.3: 2008-02-07 Added onDragStart option * Made the scroll amount configurable (default is 5 as before) * Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes * Added onAllowDrop to control dropping * Fixed a bug which meant that you couldn't set the scroll amount in both directions * Added serialize method * Version 0.5: 2008-05-16 Changed so that if you specify a dragHandle class it doesn't make the whole row * draggable * Improved the serialize method to use a default (and settable) regular expression. * Added tableDnDupate() and tableDnDSerialize() to be called when you are outside the table */ jQuery.tableDnD = { /** Keep hold of the current table being dragged */ currentTable : null, /** Keep hold of the current drag object if any */ dragObject: null, /** The current mouse offset */ mouseOffset: null, /** Remember the old value of Y so that we don't do too much processing */ oldY: 0, /** Actually build the structure */ build: function(options) { // Set up the defaults if any this.each(function() { // This is bound to each matching table, set up the defaults and override with user options this.tableDnDConfig = jQuery.extend({ onDragStyle: null, onDropStyle: null, // Add in the default class for whileDragging onDragClass: "tDnD_whileDrag", onDrop: null, onDragStart: null, scrollAmount: 5, serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs serializeParamName: null, // If you want to specify another parameter name instead of the table ID dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable }, options || {}); // Now make the rows draggable jQuery.tableDnD.makeDraggable(this); }); // Now we need to capture the mouse up and mouse move event // We can use bind so that we don't interfere with other event handlers jQuery(document) .bind('mousemove', jQuery.tableDnD.mousemove) .bind('mouseup', jQuery.tableDnD.mouseup); // Don't break the chain return this; }, /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */ makeDraggable: function(table) { var config = table.tableDnDConfig; if (table.tableDnDConfig.dragHandle) { // We only need to add the event to the specified cells var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table); cells.each(function() { // The cell is bound to "this" jQuery(this).mousedown(function(ev) { jQuery.tableDnD.dragObject = this.parentNode; jQuery.tableDnD.currentTable = table; jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev); if (config.onDragStart) { // Call the onDrop method if there is one config.onDragStart(table, this); } return false; }); }) } else { // For backwards compatibility, we add the event to the whole row var rows = jQuery("tr", table); // get all the rows as a wrapped set rows.each(function() { // Iterate through each row, the row is bound to "this" var row = jQuery(this); if (! row.hasClass("nodrag")) { row.mousedown(function(ev) { if (ev.target.tagName == "TD") { jQuery.tableDnD.dragObject = this; jQuery.tableDnD.currentTable = table; jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev); if (config.onDragStart) { // Call the onDrop method if there is one config.onDragStart(table, this); } return false; } }).css("cursor", "move"); // Store the tableDnD object } }); } }, updateTables: function() { this.each(function() { // this is now bound to each matching table if (this.tableDnDConfig) { jQuery.tableDnD.makeDraggable(this); } }) }, /** Get the mouse coordinates from the event (allowing for browser differences) */ mouseCoords: function(ev){ if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, y:ev.clientY + document.body.scrollTop - document.body.clientTop }; }, /** Given a target element and a mouse event, get the mouse offset from that element. To do this we need the element's position and the mouse position */ getMouseOffset: function(target, ev) { ev = ev || window.event; var docPos = this.getPosition(target); var mousePos = this.mouseCoords(ev); return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y}; }, /** Get the position of an element by going up the DOM tree and adding up all the offsets */ getPosition: function(e){ var left = 0; var top = 0; /** Safari fix -- thanks to Luis Chato for this! */ if (e.offsetHeight == 0) { /** Safari 2 doesn't correctly grab the offsetTop of a table row this is detailed here: http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/ the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild. note that firefox will return a text node as a first child, so designing a more thorough solution may need to take that into account, for now this seems to work in firefox, safari, ie */ e = e.firstChild; // a table cell } if (e && e.offsetParent) { while (e.offsetParent){ left += e.offsetLeft; top += e.offsetTop; e = e.offsetParent; } left += e.offsetLeft; top += e.offsetTop; } return {x:left, y:top}; }, mousemove: function(ev) { if (jQuery.tableDnD.dragObject == null) { return; } var dragObj = jQuery(jQuery.tableDnD.dragObject); var config = jQuery.tableDnD.currentTable.tableDnDConfig; var mousePos = jQuery.tableDnD.mouseCoords(ev); var y = mousePos.y - jQuery.tableDnD.mouseOffset.y; //auto scroll the window var yOffset = window.pageYOffset; if (document.all) { // Windows version //yOffset=document.body.scrollTop; if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') { yOffset = document.documentElement.scrollTop; } else if (typeof document.body != 'undefined') { yOffset=document.body.scrollTop; } } if (mousePos.y-yOffset < config.scrollAmount) { window.scrollBy(0, -config.scrollAmount); } else { var windowHeight = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight; if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) { window.scrollBy(0, config.scrollAmount); } } if (y != jQuery.tableDnD.oldY) { // work out if we're going up or down... var movingDown = y > jQuery.tableDnD.oldY; // update the old value jQuery.tableDnD.oldY = y; // update the style to show we're dragging if (config.onDragClass) { dragObj.addClass(config.onDragClass); } else { dragObj.css(config.onDragStyle); } // If we're over a row then move the dragged row to there so that the user sees the // effect dynamically var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y); if (currentRow) { // TODO worry about what happens when there are multiple TBODIES if (movingDown && jQuery.tableDnD.dragObject != currentRow) { jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling); } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) { jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow); } } } return false; }, /** We're only worried about the y position really, because we can only move rows up and down */ findDropTargetRow: function(draggedRow, y) { var rows = jQuery.tableDnD.currentTable.rows; for (var i=0; i<rows.length; i++) { var row = rows[i]; var rowY = this.getPosition(row).y; var rowHeight = parseInt(row.offsetHeight)/2; if (row.offsetHeight == 0) { rowY = this.getPosition(row.firstChild).y; rowHeight = parseInt(row.firstChild.offsetHeight)/2; } // Because we always have to insert before, we need to offset the height a bit if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) { // that's the row we're over // If it's the same as the current row, ignore it if (row == draggedRow) {return null;} var config = jQuery.tableDnD.currentTable.tableDnDConfig; if (config.onAllowDrop) { if (config.onAllowDrop(draggedRow, row)) { return row; } else { return null; } } else { // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic) var nodrop = jQuery(row).hasClass("nodrop"); if (! nodrop) { return row; } else { return null; } } return row; } } return null; }, mouseup: function(e) { if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) { var droppedRow = jQuery.tableDnD.dragObject; var config = jQuery.tableDnD.currentTable.tableDnDConfig; // If we have a dragObject, then we need to release it, // The row will already have been moved to the right place so we just reset stuff if (config.onDragClass) { jQuery(droppedRow).removeClass(config.onDragClass); } else { jQuery(droppedRow).css(config.onDropStyle); } jQuery.tableDnD.dragObject = null; if (config.onDrop) { // Call the onDrop method if there is one config.onDrop(jQuery.tableDnD.currentTable, droppedRow); } jQuery.tableDnD.currentTable = null; // let go of the table too } }, serialize: function() { if (jQuery.tableDnD.currentTable) { return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable); } else { return "Error: No Table id set, you need to set an id on your table and every row"; } }, serializeTable: function(table) { var result = ""; var tableId = table.id; var rows = table.rows; for (var i=0; i<rows.length; i++) { if (result.length > 0) result += "&"; var rowId = rows[i].id; if (rowId && rowId && table.tableDnDConfig && table.tableDnDConfig.serializeRegexp) { rowId = rowId.match(table.tableDnDConfig.serializeRegexp)[0]; } result += tableId + '[]=' + rowId; } return result; }, serializeTables: function() { var result = ""; this.each(function() { // this is now bound to each matching table result += jQuery.tableDnD.serializeTable(this); }); return result; } } jQuery.fn.extend( { tableDnD : jQuery.tableDnD.build, tableDnDUpdate : jQuery.tableDnD.updateTables, tableDnDSerialize: jQuery.tableDnD.serializeTables } );
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/jquery.tablednd.js
JavaScript
gpl2
16,709
(function ($) { $.fn.jqDynTabs = function( p ) { p = $.extend({ tabcontrol:"", tabcontent:"", side: "left", orientation: "top", imgpath: "", onClickTab : null }, p || {}); this.CreateTab = function(tabName, closable, purl, content,params) { var thisg = this.get(0); var clicktab = this; var tabID = thisg.Name + 'Tab' + thisg.tabNumber; var panelID = thisg.Name + 'Panel' + thisg.tabNumber; if (closable == null || typeof closable != "boolean" ) { closable = true }; var panel = document.createElement('div'); panel.style.left = '0px'; panel.style.top = '0px'; panel.style.width = '100%'; panel.style.height = '100%'; panel.style.display = 'none'; panel.tabNum = thisg.tabNumber; panel.id = panelID; if(thisg.panelContainer.insertAdjacentElement == null) thisg.panelContainer.appendChild(panel) else thisg.panelContainer.insertAdjacentElement("beforeEnd",panel); //Internet Explorer var sidenum=1; if (p.side == "right") sidenum =0 else p.side = "left"; if (purl) { if (purl.indexOf('?') == -1) purl +='?'; $.ajax({ url:purl, type:"GET", data: $.extend({_nd:new Date().getTime()},params), dataType:"html", complete: function(req,stat) { if(stat=="success") $(panel).html(req.responseText); }, error: function( req, errortype) { // replace this if outside ACCPress if (typeof view_error == 'function') view_error(req.status+" : "+req.statusText+"<br/>"+req.responseText,errortype); else alert(req.status+" : "+req.statusText+" "+req.responseText,errortype) //clicktab.TabCloseEl(panel.tabNum); //alert(errortype); } }); } else { if (content) $(panel).html(content); } var cell = thisg.tabContainer.insertCell(thisg.tabContainer.cells.length - parseInt(sidenum) ); cell.id = tabID; cell.className = 'lowTab'; cell.tabNum = thisg.tabNumber; cell.closable = closable; cell.tabName = tabName; $(cell).click( function(e) { var el = (e.target || e.srcElement); clicktab.TabClickEl(el); if (p.onClickTab != null && typeof p.onClickTab == "function") { p.onClickTab( tabName, panel )} }); if (closable ) { cell.innerHTML = '&nbsp;' + tabName+ '&nbsp;' + "<img src='"+p.imgpath+"tab_close.gif'/><span>&nbsp;</span>"; } else { cell.innerHTML = '&nbsp;' + tabName+ '&nbsp;'+'&nbsp;'; } this.TabClickEl(cell); if (closable ) $("img",cell).click(function(){ clicktab.TabCloseEl(cell); }).hover(function() { this.src= p.imgpath+"tab_close-on1.gif"; }, function(){ this.src= p.imgpath+"tab_close.gif"; }); thisg.tabNumber++; return panel; } this.TabClickEl = function (element) { var $t = this.get(0); if($t.currentHighTab == element) return; if($t.currentHighTab != null) { $t.currentHighTab.className = $t.lowTabStyle; if ($t.currentHighTab.closable) { $("img",$t.currentHighTab).hide();} //attr({src:p.imgpath+"tab_close.gif"}).unbind('click')} } if($t.currentHighPanel != null) $t.currentHighPanel.style.display = 'none'; $t.currentHighPanel = null; $t.currentHighTab = null; if(element == null) return; $t.currentHighTab = element; $t.currentHighPanel = document.getElementById($t.Name + 'Panel' + $t.currentHighTab.tabNum); if($t.currentHighPanel == null) { $t.currentHighTab = null return; } $t.currentHighTab.className = $t.highTabStyle; $t.currentHighPanel.style.display = ''; if (element.closable) { $("img",element).show(); //attr({src:p.imgpath+"tab_close-on1.gif"}) } } this.TabCloseEl = function(element) { if(element == null) return; var thisg = this.get(0); var tabLength = thisg.tabContainer.cells.length; if ( tabLength == 1) return; var isNumber = false, isHighTab=false, elemIndex, i, panel; if ( typeof element === 'number' && element >= 0 ) { isNumber = true; for(i = 0; i<= tabLength-1; i++) { if(thisg.tabContainer.cells[i].cellIndex==element) { elemIndex = thisg.tabContainer.cells[i].cellIndex; if (p.side=="right") { elemIndex++; element = thisg.tabContainer.cells[i+1].tabNum; } else { element = thisg.tabContainer.cells[i].tabNum; } break; } } panel = document.getElementById(thisg.Name + 'Panel' + element); if (panel.tabNum == thisg.currentHighTab.tabNum) isHighTab = true; } if(element == thisg.currentHighTab || isHighTab) { i = -1; if(tabLength > 2) { i = isHighTab ? elemIndex: element.cellIndex; if(i == tabLength- 2) i--; else i++; if(p.side=="right") { if(i===0) i=2; else if( i === tabLength) i=i-2; } if(i >= 0) this.TabClickEl(thisg.tabContainer.cells[i]); else this.TabClickEl(null); } } if ( isNumber ) { thisg.tabContainer.deleteCell(elemIndex); } else { panel = document.getElementById(thisg.Name + 'Panel' + element.tabNum); $("*",element).unbind(); $(element).remove(); //thisg.tabContainer.deleteCell(element.cellIndex); } if(panel != null) { $("*",panel).unbind(); $(panel).remove(); //thisg.panelContainer.removeChild(panel); //panel = null; } } this.getTabIndex = function () { return this.get(0).tabContainer.cells.length - 1; } this.tabExists = function (tabName) { for( var i=0;i<= this.get(0).tabContainer.cells.length-1;i++){ if( this.get(0).tabContainer.cells[i].tabName == tabName) { this.TabClickEl(this.get(0).tabContainer.cells[i]); return true; } } return false; } return this.each( function() { if (p.tabcontrol == null && p.tabcontrol.length ==0 && p.tabcontent == null && p.tabcontent.length == 0) { return; } else { p.tabcontrol = p.tabcontrol.get(0); p.tabcontent = p.tabcontent.get(0); } this.Name = 'jqDynTabs'+ Math.round(100*Math.random()); this.tabNumber = 0; this.currentHighPanel = null; this.currentHighTab = null; this.panelContainer = p.tabcontent; this.tabContainer = p.tabcontrol; this.lowTabStyle = 'lowTab'; if(p.position=="bottom") this.highTabStyle = 'highTabBottom'; else this.highTabStyle = 'highTab'; }); }; $.fn.jqStaticTabs = function(p) { p = $.extend({ tabcontent:"", onClickTab : null, selected : null }, p || {}); return this.each(function() { if (this.stattabs) return; this.p = p; var $t = this; if(!this.p.selected) this.p.selected = 0; $("li>a",this).each(function(i){ if($t.p.selected == i ) { $(this).addClass("selected"); var selid = $(this).attr("rel"); $("div.tabcell",$t.p.tabcontent).hide(); $("#"+selid,$t.p.tabcontent).show(); //return false; } }); $("li>a",this).click(function() { if(!$(this).is(".selected")) { $("li>a",$(this).parents("ul:first")).removeClass("selected"); var cntID = $(this).attr("rel"); var cont = $("#"+cntID).parent("div"); $("div.tabcell",cont).hide(); $(this).addClass("selected"); $("#"+cntID,cont).show(); } return false; }); }); }; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/jquery.jqDynTabs.js
JavaScript
gpl2
6,828
/* ** * formatter for values but most of the values if for jqGrid * Some of this was inspired and based on how YUI does the table datagrid but in jQuery fashion * we are trying to keep it as light as possible * Joshua Burnett josh@9ci.com * http://www.greenbill.com * * Changes from Tony Tomov tony@trirand.com * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * **/ ;(function($) { $.fmatter = {}; //opts can be id:row id for the row, rowdata:the data for the row, colmodel:the column model for this column //example {id:1234,} $.fn.fmatter = function(formatType, cellval, opts, act) { //debug(this); //debug(cellval); // build main options before element iteration opts = $.extend({}, $.jgrid.formatter, opts); return this.each(function() { //debug("in the each"); $this = $(this); //for the metaplugin if it exists var o = $.meta ? $.extend({}, opts, $this.data()) : opts; //debug("firing formatter"); fireFormatter($this,formatType,cellval, opts, act); }); }; $.fmatter.util = { // Taken from YAHOO utils NumberFormat : function(nData,opts) { if(!isNumber(nData)) { nData *= 1; } if(isNumber(nData)) { var bNegative = (nData < 0); var sOutput = nData + ""; var sDecimalSeparator = (opts.decimalSeparator) ? opts.decimalSeparator : "."; var nDotIndex; if(isNumber(opts.decimalPlaces)) { // Round to the correct decimal place var nDecimalPlaces = opts.decimalPlaces; var nDecimal = Math.pow(10, nDecimalPlaces); sOutput = Math.round(nData*nDecimal)/nDecimal + ""; nDotIndex = sOutput.lastIndexOf("."); if(nDecimalPlaces > 0) { // Add the decimal separator if(nDotIndex < 0) { sOutput += sDecimalSeparator; nDotIndex = sOutput.length-1; } // Replace the "." else if(sDecimalSeparator !== "."){ sOutput = sOutput.replace(".",sDecimalSeparator); } // Add missing zeros while((sOutput.length - 1 - nDotIndex) < nDecimalPlaces) { sOutput += "0"; } } } if(opts.thousandsSeparator) { var sThousandsSeparator = opts.thousandsSeparator; nDotIndex = sOutput.lastIndexOf(sDecimalSeparator); nDotIndex = (nDotIndex > -1) ? nDotIndex : sOutput.length; var sNewOutput = sOutput.substring(nDotIndex); var nCount = -1; for (var i=nDotIndex; i>0; i--) { nCount++; if ((nCount%3 === 0) && (i !== nDotIndex) && (!bNegative || (i > 1))) { sNewOutput = sThousandsSeparator + sNewOutput; } sNewOutput = sOutput.charAt(i-1) + sNewOutput; } sOutput = sNewOutput; } // Prepend prefix sOutput = (opts.prefix) ? opts.prefix + sOutput : sOutput; // Append suffix sOutput = (opts.suffix) ? sOutput + opts.suffix : sOutput; return sOutput; } else { return nData; } }, // Tony Tomov // PHP implementation. Sorry not all options are supported. // Feel free to add them if you want DateFormat : function (format, date, newformat, opts) { var token = /\\.|[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g, timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, timezoneClip = timezoneClip = /[^-+\dA-Z]/g, pad = function (value, length) { value = String(value); length = parseInt(length) || 2; while (value.length < length) value = '0' + value; return value; }, ts = {m : 1, d : 1, y : 1970, h : 0, i : 0, s : 0}, timestamp=0, dateFormat=["i18n"]; // Internationalization strings dateFormat["i18n"] = { dayNames: opts.dayNames, monthNames: opts.monthNames }; format = format.toLowerCase(); date = date.split(/[\\\/:_;.tT\s-]/); format = format.split(/[\\\/:_;.tT\s-]/); // !!!!!!!!!!!!!!!!!!!!!! // Here additional code to parse for month names // !!!!!!!!!!!!!!!!!!!!!! for(var i=0;i<format.length;i++){ ts[format[i]] = parseInt(date[i],10); } ts.m = parseInt(ts.m)-1; var ty = ts.y; if (ty >= 70 && ty <= 99) ts.y = 1900+ts.y; else if (ty >=0 && ty <=69) ts.y= 2000+ts.y; timestamp = new Date(ts.y, ts.m, ts.d, ts.h, ts.i, ts.s,0); if( opts.masks.newformat ) { newformat = opts.masks.newformat; } else if ( !newformat ) { newformat = 'Y-m-d'; } var G = timestamp.getHours(), i = timestamp.getMinutes(), j = timestamp.getDate(), n = timestamp.getMonth() + 1, o = timestamp.getTimezoneOffset(), s = timestamp.getSeconds(), u = timestamp.getMilliseconds(), w = timestamp.getDay(), Y = timestamp.getFullYear(), N = (w + 6) % 7 + 1, z = (new Date(Y, n - 1, j) - new Date(Y, 0, 1)) / 86400000, flags = { // Day d: pad(j), D: dateFormat.i18n.dayNames[w], j: j, l: dateFormat.i18n.dayNames[w + 7], N: N, S: opts.S(j), //j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th', w: w, z: z, // Week W: N < 5 ? Math.floor((z + N - 1) / 7) + 1 : Math.floor((z + N - 1) / 7) || ((new Date(Y - 1, 0, 1).getDay() + 6) % 7 < 4 ? 53 : 52), // Month F: dateFormat.i18n.monthNames[n - 1 + 12], m: pad(n), M: dateFormat.i18n.monthNames[n - 1], n: n, t: '?', // Year L: '?', o: '?', Y: Y, y: String(Y).substring(2), // Time a: G < 12 ? opts.AmPm[0] : opts.AmPm[1], A: G < 12 ? opts.AmPm[2] : opts.AmPm[3], B: '?', g: G % 12 || 12, G: G, h: pad(G % 12 || 12), H: pad(G), i: pad(i), s: pad(s), u: u, // Timezone e: '?', I: '?', O: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4), P: '?', T: (String(timestamp).match(timezone) || [""]).pop().replace(timezoneClip, ""), Z: '?', // Full Date/Time c: '?', r: '?', U: Math.floor(timestamp / 1000) }; return newformat.replace(token, function ($0) { return $0 in flags ? flags[$0] : $0.substring(1); }); } }; $.fn.fmatter.defaultFormat = function(el, cellval, opts) { $(el).html((isValue(cellval) && cellval!=="" ) ? cellval : "&#160;"); }; $.fn.fmatter.email = function(el, cellval, opts) { if(!isEmpty(cellval)) { $(el).html("<a href=\"mailto:" + cellval + "\">" + cellval + "</a>"); }else { $.fn.fmatter.defaultFormat(el, cellval); } }; $.fn.fmatter.checkbox =function(el,cval,opts) { cval=cval+""; cval=cval.toLowerCase(); var bchk = cval.search(/(false|0|no|off)/i)<0 ? " checked=\"checked\"" : ""; $(el).html("<input type=\"checkbox\"" + bchk + " value=\""+ cval+"\" offval=\"no\" disabled/>"); }, $.fn.fmatter.link = function(el,cellval,opts) { if(!isEmpty(cellval)) { $(el).html("<a href=\"" + cellval + "\">" + cellval + "</a>"); }else { $(el).html(isValue(cellval) ? cellval : ""); } }; $.fn.fmatter.showlink = function(el,cellval,opts) { var op = {baseLinkUrl: opts.baseLinkUrl,showAction:opts.showAction, addParam: opts.addParam }; if(!isUndefined(opts.colModel.formatoptions)) { op = $.extend({},op,opts.colModel.formatoptions); } idUrl = op.baseLinkUrl+op.showAction + '?id='+opts.rowId+op.addParam; if(isString(cellval)) { //add this one even if its blank string $(el).html("<a href=\"" + idUrl + "\">" + cellval + "</a>"); }else { $.fn.fmatter.defaultFormat(el, cellval); } }; $.fn.fmatter.integer = function(el,cellval,opts) { var op = $.extend({},opts.integer); if(!isUndefined(opts.colModel.formatoptions)) { op = $.extend({},op,opts.colModel.formatoptions); } if(isEmpty(cellval)) { cellval = op.defaultValue || 0; } $(el).html($.fmatter.util.NumberFormat(cellval,op)); }; $.fn.fmatter.number = function (el,cellval, opts) { var op = $.extend({},opts.number); if(!isUndefined(opts.colModel.formatoptions)) { op = $.extend({},op,opts.colModel.formatoptions); } if(isEmpty(cellval)) { cellval = op.defaultValue || 0; } $(el).html($.fmatter.util.NumberFormat(cellval,op)); }; $.fn.fmatter.currency = function (el,cellval, opts) { var op = $.extend({},opts.currency); if(!isUndefined(opts.colModel.formatoptions)) { op = $.extend({},op,opts.colModel.formatoptions); } if(isEmpty(cellval)) { cellval = op.defaultValue || 0; } $(el).html($.fmatter.util.NumberFormat(cellval,op)); }; $.fn.fmatter.date = function (el, cellval, opts, act) { var op = $.extend({},opts.date); if(!isUndefined(opts.colModel.formatoptions)) { op = $.extend({},op,opts.colModel.formatoptions); } if(!op.reformatAfterEdit && act=='edit'){ $.fn.fmatter.defaultFormat(el,cellval); } else if(!isEmpty(cellval)) { var ndf = $.fmatter.util.DateFormat(op.srcformat,cellval,op.newformat,op); $(el).html(ndf); } else { $.fn.fmatter.defaultFormat(el,cellval); } }; $.fn.fmatter.select = function (el, cellval,opts, act) { // jqGrid specific if(act=='edit') { $.fn.fmatter.defaultFormat(el,cellval); } else if (!isEmpty(cellval)) { var oSelect = false; if(!isUndefined(opts.colModel.editoptions)){ oSelect= opts.colModel.editoptions.value; } if (oSelect) { var ret = []; var msl = opts.colModel.editoptions.multiple === true ? true : false; var scell = []; if(msl) { scell = cellval.split(","); scell = $.map(scell,function(n){return $.trim(n);})} if (isString(oSelect)) { // mybe here we can use some caching with care ???? var so = oSelect.split(";"), j=0; for(var i=0; i<so.length;i++){ sv = so[i].split(":"); if(msl) { if(jQuery.inArray(sv[0],scell)>-1) { ret[j] = sv[1]; j++; } } else if($.trim(sv[0])==$.trim(cellval)) { ret[0] = sv[1]; break; } } } else if(isObject(oSelect)) { // this is quicker if(msl) { ret = jQuery.map(scel, function(n, i){ return oSelect[n]; }); } ret[0] = oSelect[cellval] || ""; } $(el).html(ret.join(", ")); } else { $.fn.fmatter.defaultFormat(el,cellval); } } }; $.unformat = function (cellval,options,pos,cnt) { // specific for jqGrid only var ret, formatType = options.colModel.formatter, op =options.colModel.formatoptions || {}; if(formatType !== 'undefined' && isString(formatType) ) { var opts = $.jgrid.formatter || {}, stripTag; switch(formatType) { case 'link' : case 'showlink' : case 'email' : ret= $(cellval).text(); break; case 'integer' : op = $.extend({},opts.integer,op); stripTag = eval("/"+op.thousandsSeparator+"/g"); ret = $(cellval).text().replace(stripTag,''); break; case 'number' : op = $.extend({},opts.number,op); stripTag = eval("/"+op.thousandsSeparator+"/g"); ret = $(cellval).text().replace(op.decimalSeparator,'.').replace(stripTag,""); break; case 'currency': op = $.extend({},opts.currency,op); stripTag = eval("/"+op.thousandsSeparator+"/g"); ret = $(cellval).text().replace(op.decimalSeparator,'.').replace(op.prefix,'').replace(op.suffix,'').replace(stripTag,''); break; case 'checkbox' : var cbv = (options.colModel.editoptions) ? options.colModel.editoptions.value.split(":") : ["Yes","No"]; ret = $('input',cellval).attr("checked") ? cbv[0] : cbv[1]; break; } } //else { // Here aditional code to run custom unformater //} return ret ? ret : cnt===true ? $(cellval).text() : $.htmlDecode($(cellval).html()); }; function fireFormatter(el,formatType,cellval, opts, act) { //debug("in formatter with " +formatType); formatType = formatType.toLowerCase(); switch (formatType) { case 'link': $.fn.fmatter.link(el, cellval, opts); break; case 'showlink': $.fn.fmatter.showlink(el, cellval, opts); break; case 'email': $.fn.fmatter.email(el, cellval, opts); break; case 'currency': $.fn.fmatter.currency(el, cellval, opts); break; case 'date': $.fn.fmatter.date(el, cellval, opts, act); break; case 'number': $.fn.fmatter.number(el, cellval, opts) ; break; case 'integer': $.fn.fmatter.integer(el, cellval, opts) ; break; case 'checkbox': $.fn.fmatter.checkbox(el, cellval, opts); break; case 'select': $.fn.fmatter.select(el, cellval, opts,act); break; //case 'textbox': s.transparent = false; break; } }; //private methods and data function debug($obj) { if (window.console && window.console.log) window.console.log($obj); }; /** * A convenience method for detecting a legitimate non-null value. * Returns false for null/undefined/NaN, true for other values, * including 0/false/'' * --taken from the yui.lang */ isValue= function(o) { return (isObject(o) || isString(o) || isNumber(o) || isBoolean(o)); }; isBoolean= function(o) { return typeof o === 'boolean'; }; isNull= function(o) { return o === null; }; isNumber= function(o) { return typeof o === 'number' && isFinite(o); }; isString= function(o) { return typeof o === 'string'; }; /** * check if its empty trim it and replace \&nbsp and \&#160 with '' and check if its empty ==="" * if its is not a string but has a value then it returns false, Returns true for null/undefined/NaN essentailly this provdes a way to see if it has any value to format for things like links */ isEmpty= function(o) { if(!isString(o) && isValue(o)) { return false; }else if (!isValue(o)){ return true; } o = $.trim(o).replace(/\&nbsp\;/ig,'').replace(/\&#160\;/ig,''); return o===""; }; isUndefined= function(o) { return typeof o === 'undefined'; }; isObject= function(o) { return (o && (typeof o === 'object' || isFunction(o))) || false; }; isFunction= function(o) { return typeof o === 'function'; }; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/jquery.fmatter.js
JavaScript
gpl2
14,494
;(function($){ /** * jqGrid Polish Translation * Piotr Roznicki roznicki@o2.pl * http://www.roznicki.prv.pl * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "Wiersz(y)", loadtext: "Ładowanie...", pgtext : "/" }; $.jgrid.search = { caption: "Wyszukiwanie...", Find: "Szukaj", Reset: "Czyść", odata : ['dokładnie', 'różne od', 'mniejsze od', 'mniejsze lub różne','większe od','większe lub różne', 'zacznij od','zakończ na','zawiera' ] }; $.jgrid.edit = { addCaption: "Dodaj rekord", editCaption: "Edytuj rekord", bSubmit: "Zapisz", bCancel: "Anuluj", bClose: "Zamknij", processData: "Przetwarzanie...", msg: { required:"Pole jest wymagane", number:"Proszę wpisać poprawną liczbę", minValue:"wartość musi być większa lub równa", maxValue:"wartość musi być mniejsza od", email: "nie jest adresem e-mail", integer: "Proszę wpisać poprawną liczbę", date: "Please, enter valid date value" } }; $.jgrid.del = { caption: "Usuwanie", msg: "Usuń wybrany rekord(y)?", bSubmit: "Usuń", bCancel: "Anuluj", processData: "Przetwarzanie..." }; $.jgrid.nav = { edittext: " ", edittitle: "Edytuj wybrany wiersz", addtext:" ", addtitle: "Dodaj nowy wiersz", deltext: " ", deltitle: "Usuń wybrany wiersz", searchtext: " ", searchtitle: "Wyszukaj rekord", refreshtext: "", refreshtitle: "Przeładuj", alertcap: "Uwaga", alerttext: "Proszę wybrać wiersz" }; // setcolumns module $.jgrid.col ={ caption: "Pokaż/Ukryj kolumny", bSubmit: "Zatwierdź", bCancel: "Anuluj" }; $.jgrid.errors = { errcap : "Błąd", nourl : "Brak adresu url", norecords: "Brak danych", model : "Length of colNames <> colModel!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], AmPm : ["am","pm","AM","PM"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'}, srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'show' }; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-pl.js
JavaScript
gpl2
3,444
;(function($){ /** * jqGrid extension for manipulating Grid Data * Tony Tomov tony@trirand.com * http://trirand.com/blog/ * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.fn.extend({ //Editing editRow : function(rowid,keys,oneditfunc,succesfunc, url, extraparam, aftersavefunc,errorfunc) { return this.each(function(){ var $t = this, nm, tmp, editable, cnt=0, focus=null, svr=[], ind; if (!$t.grid ) { return; } var sz, ml,hc; if( !$t.p.multiselect ) { ind = $($t).getInd($t.rows,rowid); if( ind === false ) {return;} editable = $($t.rows[ind]).attr("editable") || "0"; if (editable == "0") { $('td',$t.rows[ind]).each( function(i) { nm = $t.p.colModel[i].name; hc = $t.p.colModel[i].hidden===true ? true : false; try { tmp = $.unformat(this,{colModel:$t.p.colModel[i]},i); } catch (_) { tmp = $.htmlDecode($(this).html()); } svr[nm]=tmp; if ( nm !== 'cb' && nm !== 'subgrid' && $t.p.colModel[i].editable===true && !hc) { if(focus===null) { focus = i; } $(this).html(""); var opt = $.extend($t.p.colModel[i].editoptions || {} ,{id:rowid+"_"+nm,name:nm}); if(!$t.p.colModel[i].edittype) { $t.p.colModel[i].edittype = "text"; } var elc = createEl($t.p.colModel[i].edittype,opt,tmp,$(this)); $(elc).addClass("editable"); $(this).append(elc); //Agin IE if($t.p.colModel[i].edittype == "select" && $t.p.colModel[i].editoptions.multiple===true && $.browser.msie) { $(elc).width($(elc).width()); } cnt++; } }); if(cnt > 0) { svr['id'] = rowid; $t.p.savedRow.push(svr); $($t.rows[ind]).attr("editable","1"); $("td:eq("+focus+") input",$t.rows[ind]).focus(); if(keys===true) { $($t.rows[ind]).bind("keydown",function(e) { if (e.keyCode === 27) { $($t).restoreRow(rowid);} if (e.keyCode === 13) { $($t).saveRow(rowid,succesfunc, url, extraparam, aftersavefunc,errorfunc); return false; } e.stopPropagation(); }); } if( $.isFunction(oneditfunc)) { oneditfunc(rowid); } } } } }); }, saveRow : function(rowid, succesfunc, url, extraparam, aftersavefunc,errorfunc) { return this.each(function(){ var $t = this, nm, tmp={}, tmp2={}, editable, fr, cv, ms, ind; if (!$t.grid ) { return; } ind = $($t).getInd($t.rows,rowid); if(ind === false) {return;} editable = $($t.rows[ind]).attr("editable"); url = url ? url : $t.p.editurl; if (editable==="1" && url) { $("td",$t.rows[ind]).each(function(i) { nm = $t.p.colModel[i].name; if ( nm !== 'cb' && nm !== 'subgrid' && $t.p.colModel[i].editable===true) { if( $t.p.colModel[i].hidden===true) { tmp[nm] = $(this).html(); } else { switch ($t.p.colModel[i].edittype) { case "checkbox": var cbv = ["Yes","No"]; if($t.p.colModel[i].editoptions ) { cbv = $t.p.colModel[i].editoptions.value.split(":"); } tmp[nm]= $("input",this).attr("checked") ? cbv[0] : cbv[1]; break; case 'text': case 'password': case 'textarea': tmp[nm]= htmlEncode($("input, textarea",this).val()); break; case 'select': if(!$t.p.colModel[i].editoptions.multiple) { tmp[nm] = $("select>option:selected",this).val(); tmp2[nm] = $("select>option:selected", this).text(); } else { var sel = $("select",this); tmp[nm] = $(sel).val(); var selectedText = []; $("select > option:selected",this).each( function(i,selected){ selectedText[i] = $(selected).text(); } ); tmp2[nm] = selectedText.join(","); } break; } cv = checkValues(tmp[nm],i,$t); if(cv[0] === false) { cv[1] = tmp[nm] + " " + cv[1]; return false; } } } }); if (cv[0] === false){ try { info_dialog($.jgrid.errors.errcap,cv[1],$.jgrid.edit.bClose, $t.p.imgpath); } catch (e) { alert(cv[1]); } return; } if(tmp) { tmp["id"] = rowid; if(extraparam) { tmp = $.extend({},tmp,extraparam);} } if(!$t.grid.hDiv.loading) { $t.grid.hDiv.loading = true; $("div.loading",$t.grid.hDiv).fadeIn("fast"); if (url == 'clientArray') { tmp = $.extend({},tmp, tmp2); $($t).setRowData(rowid,tmp); $($t.rows[ind]).attr("editable","0"); for( var k=0;k<$t.p.savedRow.length;k++) { if( $t.p.savedRow[k].id===rowid) {fr = k; break;} } if(fr >= 0) { $t.p.savedRow.splice(fr,1); } if( $.isFunction(aftersavefunc) ) { aftersavefunc(rowid,res.responseText); } } else { $.ajax({url:url, data: tmp, type: "POST", complete: function(res,stat){ if (stat === "success"){ var ret; if( $.isFunction(succesfunc)) { ret = succesfunc(res);} else ret = true; if (ret===true) { tmp = $.extend({},tmp, tmp2); $($t).setRowData(rowid,tmp); $($t.rows[ind]).attr("editable","0"); for( var k=0;k<$t.p.savedRow.length;k++) { if( $t.p.savedRow[k].id===rowid) {fr = k; break;} }; if(fr >= 0) { $t.p.savedRow.splice(fr,1); } if( $.isFunction(aftersavefunc) ) { aftersavefunc(rowid,res.responseText); } } else { $($t).restoreRow(rowid); } } }, error:function(res,stat){ if($.isFunction(errorfunc) ) { errorfunc(res,stat); } else { alert("Error Row: "+rowid+" Result: " +res.status+":"+res.statusText+" Status: "+stat); } } }); } $t.grid.hDiv.loading = false; $("div.loading",$t.grid.hDiv).fadeOut("fast"); $($t.rows[ind]).unbind("keydown"); } } }); }, restoreRow : function(rowid) { return this.each(function(){ var $t= this, nm, fr,ind; if (!$t.grid ) { return; } ind = $($t).getInd($t.rows,rowid); if(ind === false) {return;} for( var k=0;k<$t.p.savedRow.length;k++) { if( $t.p.savedRow[k].id===rowid) {fr = k; break;} } if(fr >= 0) { $($t).setRowData(rowid,$t.p.savedRow[fr]); $($t.rows[ind]).attr("editable","0"); $t.p.savedRow.splice(fr,1); } }); } //end inline edit }); })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.inlinedit.js
JavaScript
gpl2
6,601
/* org: 'http://www.JSON.org', copyright: '(c)2005 JSON.org', license: 'http://www.crockford.com/JSON/license.html', Some modifications and additions from Tony Tomov Added parse function to prevent JSON Hijacking Read below */ var JSON = { stringify: function stringify(arg) { var c, i, l, s = '', v; switch (typeof arg) { case 'object': if (arg) { if (arg.constructor == Array) { for (i = 0; i < arg.length; ++i) { v = stringify(arg[i]); if (s) { s += ','; } s += v; } return '[' + s + ']'; } else if (typeof arg.toString != 'undefined') { for (i in arg) { v = stringify(arg[i]); if (typeof v != 'function') { if (s) { s += ','; } s += stringify(i) + ':' + v; } } return '{' + s + '}'; } } return 'null'; case 'number': return isFinite(arg) ? String(arg) : 'null'; case 'string': l = arg.length; s = '"'; for (i = 0; i < l; i += 1) { c = arg.charAt(i); if (c >= ' ') { if (c == '\\' || c == '"') { s += '\\'; } s += c; } else { switch (c) { case '\b': s += '\\b'; break; case '\f': s += '\\f'; break; case '\n': s += '\\n'; break; case '\r': s += '\\r'; break; case '\t': s += '\\t'; break; default: c = c.charCodeAt(); s += '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); } } } return s + '"'; case 'boolean': return String(arg); case 'function' : // Added for use of jqGrid T. Tomov return arg.toString(); default: return 'null'; } }, // Read this if you want to protect your json return string // http://safari.oreilly.com/9780596514839/recipe-1107 // // 1.The while(1); construct, located at the beginning of JSON text, // 2.Comments at the beginning and end of the text. // JSON data providers are encouraged to use one or both of these methods // to prevent data execution. Such JSON response may then look like this: // while(1);/*{[ // {"name":"safe value 1"}, // {"name":"safe value 2"}, // ... // ]}*/ parse : function(jsonString) { // filter out while statement var js = jsonString; if (js.substr(0,9) == "while(1);") { js = js.substr(9); } if (js.substr(0,2) == "/*") { js = js.substr(2,js.length-4); } return eval('('+js+')'); } }
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/json2.js
JavaScript
gpl2
3,537
;(function($){ /** * jqGrid Turkish Translation * H.İbrahim Yılmaz ibrahim.yilmaz@karmabilisim.net * http://www.arkeoloji.web.tr * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "Satır(lar)", loadtext: "Yükleniyor...", pgtext : "/" }; $.jgrid.search = { caption: "Arama...", Find: "Bul", Reset: "Temizle", odata : ['eşittir', 'eşit değildir', 'küçük', 'küçük veya eşit','büyük','büyük veya eşit', 'ile başlayan','ile biten','içeren' ] }; $.jgrid.edit = { addCaption: "Kayıt Ekle", editCaption: "Kayıt Düzenle", bSubmit: "Gönder", bCancel: "İptal", bClose: "Kapat", processData: "İşlem yapılıyor...", msg: { required:"Alan gerekli", number:"Lütfen bir numara giriniz", minValue:"girilen değer daha büyük ya da buna eşit olmalıdır", maxValue:"girilen değer daha küçük ya da buna eşit olmalıdır", email: "geçerli bir e-posta adresi değildir", integer: "Lütfen bir tamsayı giriniz", date: "Please, enter valid date value" } }; $.jgrid.del = { caption: "Sil", msg: "Seçilen kayıtlar silinsin mi?", bSubmit: "Sil", bCancel: "İptal", processData: "İşlem yapılıyor..." }; $.jgrid.nav = { edittext: " ", edittitle: "Seçili satırı düzenle", addtext:" ", addtitle: "Yeni satır ekle", deltext: " ", deltitle: "Seçili satırı sil", searchtext: " ", searchtitle: "Kayıtları bul", refreshtext: "", refreshtitle: "Tabloyu yenile", alertcap: "Uyarı", alerttext: "Lütfen bir satır seçiniz" }; // setcolumns module $.jgrid.col ={ caption: "Sütunları göster/gizle", bSubmit: "Gönder", bCancel: "İptal" }; $.jgrid.errors = { errcap : "Hata", nourl : "Bir url yapılandırılmamış", norecords: "İşlem yapılacak bir kayıt yok", model : "Length of colNames <> colModel!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], AmPm : ["am","pm","AM","PM"], S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'}, srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "n/j/Y", LongDate: "l, F d, Y", FullDateTime: "l, F d, Y g:i:s A", MonthDay: "F d", ShortTime: "g:i A", LongTime: "g:i:s A", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F, Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'show' }; })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-tr.js
JavaScript
gpl2
3,557
;(function($){ /** * jqGrid Danish Translation * Kaare Rasmussen kjs@jasonic.dk * http://jasonic.dk/blog * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html **/ $.jgrid = {}; $.jgrid.defaults = { recordtext: "Række(r)", loadtext: "Indlæser...", pgtext : "/" }; $.jgrid.search = { caption: "Søg...", Find: "Find", Reset: "Nulstil", odata : ['lig med', 'forskellig fra', 'mindre end', 'mindre end eller lig med','større end',' større end eller lig med', 'starter med','slutter med','indeholder' ] }; $.jgrid.edit = { addCaption: "Tilføj", editCaption: "Ret", bSubmit: "Send", bCancel: "Annuller", bClose: "Luk", processData: "Behandler...", msg: { required:"Felt er nødvendigt", number:"Indtast venligst et validt tal", minValue:"værdi skal være større end eller lig med", maxValue:"værdi skal være mindre end eller lig med", email: "er ikke en valid email", integer: "Indtast venligst et validt heltalt", date: "Indtast venligst en valid datoværdi" } }; $.jgrid.del = { caption: "Slet", msg: "Slet valgte række(r)?", bSubmit: "Slet", bCancel: "Annuller", processData: "Behandler..." }; $.jgrid.nav = { edittext: " ", edittitle: "Rediger valgte række", addtext:" ", addtitle: "Tilføj ny række", deltext: " ", deltitle: "Slet valgte række", searchtext: " ", searchtitle: "Find poster", refreshtext: "", refreshtitle: "Indlæs igen", alertcap: "Advarsel", alerttext: "Vælg venligst række" }; // setcolumns module $.jgrid.col ={ caption: "Vis/skjul kolonner", bSubmit: "Send", bCancel: "Annuller" }; $.jgrid.errors = { errcap : "Fejl", nourl : "Ingel url valgt", norecords: "Ingen poster at behandle", model : "colNames og colModel har ikke samme længde!" }; $.jgrid.formatter = { integer : {thousandsSeparator: " ", defaulValue: 0}, number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaulValue: 0}, currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaulValue: 0}, date : { dayNames: [ "Søn", "Man", "Tirs", "Ons", "Tors", "Fre", "Lør", "Søndag", "Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag" ], monthNames: [ "Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec", "Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December" ], AmPm : ["","","",""], S: function (j) {return '.'}, srcformat: 'Y-m-d', newformat: 'd/m/Y', masks : { ISO8601Long:"Y-m-d H:i:s", ISO8601Short:"Y-m-d", ShortDate: "j/n/Y", LongDate: "l d. F Y", FullDateTime: "l d F Y G:i:s", MonthDay: "d. F", ShortTime: "G:i", LongTime: "G:i:s", SortableDateTime: "Y-m-d\\TH:i:s", UniversalSortableDateTime: "Y-m-d H:i:sO", YearMonth: "F Y" }, reformatAfterEdit : false }, baseLinkUrl: '', showAction: 'show' }; // DK })(jQuery);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/js/grid.locale-dk.js
JavaScript
gpl2
3,363
<?php include("dbconfig.php"); $examp = $_REQUEST["q"]; //query number $page = $_REQUEST['page']; // get the requested page $limit = $_REQUEST['rows']; // get how many rows we want to have into the grid $sidx = $_REQUEST['sidx']; // get index row - i.e. user click to sort $sord = $_REQUEST['sord']; // get the direction if(!$sidx) $sidx =1; // search options // IMPORTANT NOTE!!!!!!!!!!!!!!!!!!!!!!!!!!!! // this type of constructing is not recommendet // it is only for demonstration //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $wh = ""; $searchOn = Strip($_REQUEST['_search']); if($searchOn=='true') { $fld = Strip($_REQUEST['searchField']); if( $fld=='id' || $fld =='invdate' || $fld=='name' || $fld=='amount' || $fld=='tax' || $fld=='total' || $fld=='note' || $fld=='closed' || $fld=='ship_via') { $fldata = Strip($_REQUEST['searchString']); $foper = Strip($_REQUEST['searchOper']); // costruct where $wh .= " AND ".$fld; switch ($foper) { case "bw": $fldata .= "%"; $wh .= " LIKE '".$fldata."'"; break; case "eq": if(is_numeric($fldata)) { $wh .= " = ".$fldata; } else { $wh .= " = '".$fldata."'"; } break; case "ne": if(is_numeric($fldata)) { $wh .= " <> ".$fldata; } else { $wh .= " <> '".$fldata."'"; } break; case "lt": if(is_numeric($fldata)) { $wh .= " < ".$fldata; } else { $wh .= " < '".$fldata."'"; } break; case "le": if(is_numeric($fldata)) { $wh .= " <= ".$fldata; } else { $wh .= " <= '".$fldata."'"; } break; case "gt": if(is_numeric($fldata)) { $wh .= " > ".$fldata; } else { $wh .= " > '".$fldata."'"; } break; case "ge": if(is_numeric($fldata)) { $wh .= " >= ".$fldata; } else { $wh .= " >= '".$fldata."'"; } break; case "ew": $wh .= " LIKE '%".$fldata."'"; break; case "ew": $wh .= " LIKE '%".$fldata."%'"; break; default : $wh = ""; } } } // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); switch ($examp) { case 1: $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id ".$wh); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) if ($start<0) $start = 0; $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note,a.closed,a.ship_via FROM invheader a, clients b WHERE a.client_id=b.client_id".$wh." ORDER BY ".$sidx." ". $sord." LIMIT ".$start." , ".$limit; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) { header("Content-type: application/xhtml+xml;charset=utf-8"); } else { header("Content-type: text/xml;charset=utf-8"); } $et = ">"; $s = "<?xml version='1.0' encoding='utf-8'?$et\n"; $s .= "<rows>"; $s .= "<page>".$page."</page>"; $s .= "<total>".$total_pages."</total>"; $s .= "<records>".$count."</records>"; // be sure to put text data in CDATA while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $s .= "<row id='". $row[id]."'>"; $s .= "<cell>". $row[id]."</cell>"; $s .= "<cell>". $row[invdate]."</cell>"; $s .= "<cell><![CDATA[". $row[name]."]]></cell>"; $s .= "<cell>". $row[amount]."</cell>"; $s .= "<cell>". $row[tax]."</cell>"; $s .= "<cell>". $row[total]."</cell>"; $s .= "<cell>". $row[closed]."</cell>"; if( $row[ship_via] == 'TN') $s .= "<cell>TNT</cell>"; else if( $row[ship_via] == 'FE') $s .= "<cell>FedEx</cell>"; else $s .= "<cell></cell>"; $s .= "<cell><![CDATA[". $row[note]."]]></cell>"; $s .= "</row>"; } $s .= "</rows>"; echo $s; break; } mysql_close($db); function Strip($value) { if(get_magic_quotes_gpc() != 0) { if(is_array($value)) if ( array_is_associative($value) ) { foreach( $value as $k=>$v) $tmp_val[$k] = stripslashes($v); $value = $tmp_val; } else for($j = 0; $j < sizeof($value); $j++) $value[$j] = stripslashes($value[$j]); else $value = stripslashes($value); } return $value; } function array_is_associative ($array) { if ( is_array($array) && ! empty($array) ) { for ( $iterator = count($array) - 1; $iterator; $iterator-- ) { if ( ! array_key_exists($iterator, $array) ) { return true; } } return ! array_key_exists(0, $array); } return false; } ?>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/editing.php
PHP
gpl2
5,017
<div> This example demonstrates using a subgrid with JSON Data. To the subgrid url is passed the id of the row.<br/> If there is a need to pass another parameters to subgrid url that are part of the grid data a params array <br> can be constructed. Example: if we want to pass the date too - the subGridModel can look like this: <br> ... <br> subGridModel: [{ name : ['No','Item','Qty','Unit','Line Total'], <br> width : [55,200,80,80,80], <br> params: ['invdate']} <br> ... <br> where the 'invdate' is a valid name from colModel. And a parameter invdate='xxxxx' is constructed<br> </div> <br /> <table id="list14" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager14" class="scroll" style="text-align:center;"></div> <script src="jsubgrid.js" type="text/javascript"> </script> <br /> <b> HTML </b> <XMP> ... <table id="list14" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager14" class="scroll" style="text-align:center;"></div> <script src="jsubgrid.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#list14").jqGrid({ url:'server.php?q=2', datatype: "json", height: 200, colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pager14'), sortname: 'id', viewrecords: true, sortorder: "desc", multiselect: false, subGrid : true, subGridUrl: 'subgrid.php?q=3', subGridModel: [{ name : ['No','Item','Qty','Unit','Line Total'], width : [55,200,80,80,80], params:['invdate']} ] , caption: "Subgrid with JSON Data" }).navGrid('#pager14',{edit:false,add:false,del:false}); </XMP> <b>PHP with MySQL Master</b> <XMP> ... // coment the above lines if php 5 include("JSON.php"); $json = new Services_JSON(); // end comment $examp = $_GET["q"]; //query number $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) if ($start<0) $start = 0; $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn’t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo $json->encode($responce); // coment if php 5 //echo json_encode($responce); </XMP> <b>PHP with MySQL Subgrid</b> <XMP> $examp = $_GET["q"]; //query number $id = $_GET['id']; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $SQL = "SELECT num, item, qty, unit FROM invlines WHERE id=".$id." ORDER BY item"; $result = mysql_query( $SQL ) or die("Couldn’t execute query.".mysql_error()); $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[num]; $responce->rows[$i]['cell']=array($row[num],$row[item],$row[qty],$row[unit],number_format($row[qty]*$row[unit],2,'.',' ')); $i++; } echo $json->encode($responce); //echo json_encode($responce); </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/jsubgrid.html
HTML
gpl2
4,685
<div> This example demonstartes new methods. Try to click on pager buttons. </div> <b>Response:</b> <span id="resp"></span> <br/> <br/> <table id="method" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pmethod" class="scroll" style="text-align:center;"></div> <br /> <a href="javascript:void(0)" id="sm1">Get number of record</a> <br /> <a href="javascript:void(0)" id="sm2">Set a onSelectRow Method</a> <br /> <a href="javascript:void(0)" id="sm3" >Reset selected Rows</a> <span> << Select some rows and then click me </span> <script src="methods.js" type="text/javascript"> </script> <br /> <br /> <b> HTML </b> <XMP> ... <b>Response:</b> <span id="resp"></span> <br/> <br/> <table id="method" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pmethod" class="scroll" style="text-align:center;"></div> <br /> <a href="javascript:void(0)" id="sm1">Get number of record</a> <br /> <a href="javascript:void(0)" id="sm2">Set a onSelectRow Method</a> <br /> <a href="javascript:void(0)" id="sm3" >Reset selected Rows</a> <span> << Select some rows and then click me </span> <script src="methods.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#method").jqGrid({ url:'server.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pmethod'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"New Methods", multiselect: true, onPaging : function(but) { alert("Button: "+but + " is clicked"); } }).navGrid('#pmethod',{edit:false,add:false,del:false}); jQuery("#sm1").click( function() { alert($("#method").getGridParam("records")); }); jQuery("#sm2").click( function() { $("#method").setGridParam({ onSelectRow : function(id) { $("#resp").html("I'm row number: "+id +" and setted dynamically").css("color","red"); } }); alert("Try to select row"); }); jQuery("#sm3").click( function() { $("#method").resetSelection(); }); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn’t execute query.".mysql_error()); if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) { header("Content-type: application/xhtml+xml;charset=utf-8"); } else { header("Content-type: text/xml;charset=utf-8"); } $et = ">"; echo "<?xml version='1.0' encoding='utf-8'?$et\n"; echo "<rows>"; echo "<page>".$page."</page>"; echo "<total>".$total_pages."</total>"; echo "<records>".$count."</records>"; // be sure to put text data in CDATA while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { echo "<row id='". $row[id]."'>"; echo "<cell>". $row[id]."</cell>"; echo "<cell>". $row[invdate]."</cell>"; echo "<cell><![CDATA[". $row[name]."]]></cell>"; echo "<cell>". $row[amount]."</cell>"; echo "<cell>". $row[tax]."</cell>"; echo "<cell>". $row[total]."</cell>"; echo "<cell><![CDATA[". $row[note]."]]></cell>"; echo "</row>"; } echo "</rows>"; ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/methods.html
HTML
gpl2
4,572
$("#cnvxml").click(function(){ $("#xmlist1").jqGridImport({impurl:"testxml.xml"}); $(this).hide(); });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/xmlimp.js
JavaScript
gpl2
107
jQuery("#list4").jqGrid({ datatype: "local", height: 250, colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:60, sorttype:"int"}, {name:'invdate',index:'invdate', width:90, sorttype:"date"}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right",sorttype:"float"}, {name:'tax',index:'tax', width:80, align:"right",sorttype:"float"}, {name:'total',index:'total', width:80,align:"right",sorttype:"float"}, {name:'note',index:'note', width:150, sortable:false} ], imgpath: gridimgpath, multiselect: true, caption: "Manipulating Array Data" }); var mydata = [ {id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"}, {id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"}, {id:"3",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}, {id:"4",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"}, {id:"5",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"}, {id:"6",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}, {id:"7",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"}, {id:"8",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"}, {id:"9",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"} ]; for(var i=0;i<=mydata.length;i++) jQuery("#list4").addRowData(i+1,mydata[i]);
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/localex.js
JavaScript
gpl2
1,745
jQuery("#navgrid2").jqGrid({ scrollrows : true, url:'editing.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Closed','Ship via','Notes'], colModel:[ {name:'id',index:'id', width:55,editable:false,editoptions:{readonly:true,size:10},formatter: 'integer', formatoptions:{thousandsSeparator:","}}, {name:'invdate',index:'invdate', width:80,editable:true,editoptions:{size:10},formatter:'date', formatoptions: {srcformat:'Y-m-d',newformat:'Y/m/d'}}, {name:'name',index:'name', width:90,editable:true,editoptions:{size:25}}, {name:'amount',index:'amount', width:60, align:"right",editable:true,formatter:'currency',formatoptions:{thousandsSeparator:" ", decimalSeparator:",", prefix:"€"}}, {name:'tax',index:'tax', width:60, align:"right",editable:true,editoptions:{size:10}}, {name:'total',index:'total', width:60,align:"right",editable:true,editoptions:{size:10}}, {name:'closed',index:'closed',width:55,align:'center',editable:true,edittype:"checkbox",editoptions:{value:"Yes:No"}}, {name:'ship_via',index:'ship_via',width:70, editable: true,edittype:"select",editoptions:{value:"FE:FedEx;TN:TNT"}}, {name:'note',index:'note', width:100, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"20"}} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pagernav2'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Navigator Example", editurl:"someurl.php", height:150 }).navGrid('#pagernav2', {add:false}, //options {height:280,reloadAfterSubmit:false}, // edit options {}, // add options {reloadAfterSubmit:false}, // del options {} // search options );
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/navgrid2.js
JavaScript
gpl2
1,781
<?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpassword = ''; $database = ''; ?>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/dbconfig.php
PHP
gpl2
94
<div> This example show the new Cell editing feature of jqGrid. Select some cell. <br> The fields date, amout and tax are editable. When select a cell you can <br> navigate with left, right, up and down keys. The Enter key save the content. The esc does not save the content.<br> Try to change the values of amount or tax and see that the total changes.<br> To enable cell editing you should just set cellEdit: true and ajust the colModel in appropriate way. </div> <br /> <table id="celltbl" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pcelltbl" class="scroll" style="text-align:center;"></div> <script src="celledit.js" type="text/javascript"> </script> <br /> <b> HTML </b> <XMP> ... <table id="celltbl" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pcelltbl" class="scroll" style="text-align:center;"></div> <script src="celledit.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#celltbl").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90,editable:true}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right",editable:true,editrules:{number:true}}, {name:'tax',index:'tax', width:80, align:"right",editable:true,editrules:{number:true}}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pcelltbl'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Cell Edit Example", forceFit : true, cellEdit: true, cellsubmit: 'clientArray', afterEditCell: function (id,name,val,iRow,iCol){ if(name=='invdate') { jQuery("#"+iRow+"_invdate","#celltbl").datepicker({dateFormat:"yy-mm-dd"}); } }, afterSaveCell : function(rowid,name,val,iRow,iCol) { if(name == 'amount') { var taxval = jQuery("#celltbl").getCell(rowid,iCol+1); jQuery("#celltbl").setRowData(rowid,{total:parseFloat(val)+parseFloat(taxval)}); } if(name == 'tax') { var amtval = jQuery("#celltbl").getCell(rowid,iCol-1); jQuery("#celltbl").setRowData(rowid,{total:parseFloat(val)+parseFloat(amtval)}); } } }).navGrid('#pgwidth',{edit:false,add:false,del:false}); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo json_encode($responce); ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/celledit.html
HTML
gpl2
4,064
<div> This example demonstartes a setCell and setLabel methods. We can change the contents <br/> and style of the particular header and cell. Again with this we use a loadui option <br/> to disable interaction when the data is loaded </div> <br/> <br/> <table id="method32" class="scroll"></table> <div id="pmethod32" class="scroll" style="text-align:center;"></div> <br /> <a href="javascript:void(0)" id="shc">Change the content of header Tax</a> <br /> <a href="javascript:void(0)" id="scc">Cahnge the tax of row 12</a> <br /> <a href="javascript:void(0)" id="cdat">Clear the currently loaded data</a> <br /> <script src="methods32.js" type="text/javascript"> </script> <br /> <br /> <b> HTML </b> <XMP> ... <br/> <br/> <table id="method32" class="scroll"></table> <div id="pmethod32" class="scroll" style="text-align:center;"></div> <br /> <a href="javascript:void(0)" id="shc">Change the content of header Tax</a> <br /> <a href="javascript:void(0)" id="scc">Cahnge the tax of row 12</a> <br /> <a href="javascript:void(0)" id="cdat">Clear the currently loaded data</a> <br /> <script src="methods32.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#method32").jqGrid({ url:'server.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pmethod32'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"New Methods", multiselect: true, loadui: "block" }).navGrid('#pmethod32',{edit:false,add:false,del:false}); jQuery("#shc").click( function() { $("#method32").setLabel("tax","Tax Amt",{'font-weight': 'bold','font-style': 'italic'}); }); jQuery("#scc").click( function() { $("#method32").setCell("12","tax","",{'font-weight': 'bold',color: 'red','text-align':'center'}); }); jQuery("#cdat").click( function() { $("#method32").clearGridData(); }); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn’t execute query.".mysql_error()); if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) { header("Content-type: application/xhtml+xml;charset=utf-8"); } else { header("Content-type: text/xml;charset=utf-8"); } $et = ">"; echo "<?xml version='1.0' encoding='utf-8'?$et\n"; echo "<rows>"; echo "<page>".$page."</page>"; echo "<total>".$total_pages."</total>"; echo "<records>".$count."</records>"; // be sure to put text data in CDATA while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { echo "<row id='". $row[id]."'>"; echo "<cell>". $row[id]."</cell>"; echo "<cell>". $row[invdate]."</cell>"; echo "<cell><![CDATA[". $row[name]."]]></cell>"; echo "<cell>". $row[amount]."</cell>"; echo "<cell>". $row[tax]."</cell>"; echo "<cell>". $row[total]."</cell>"; echo "<cell><![CDATA[". $row[note]."]]></cell>"; echo "</row>"; } echo "</rows>"; ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/methods32.html
HTML
gpl2
4,471
<div> This example demostrates the set methods in grid. The set methods in most cases<br> are combined with .trigger('relodGrid') </div> <br /> <table id="list7" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager7" class="scroll" style="text-align:center;"></div> <br /> <a href="javascript:void(0)" id="s1">Set new url</a> <br /> <a href="javascript:void(0)" id="s2">Set Sort to amount column</a> <br /> <a href="javascript:void(0)" id="s3" >Set Sort new Order</a> <br /> <a href="javascript:void(0)" id="s4">Set to view second Page</a> <br /> <a href="javascript:void(0)" id="s5">Set new Number of Rows(15)</a> <br /> <a href="javascript:void(0)" id="s6" >Set Data Type from json to xml</a> <br /> <a href="javascript:void(0)" id="s7" >Set new Caption</a> <br /> <a href="javascript:void(0)" id="s8" >Sort by Client</a> <script src="setex.js" type="text/javascript"> </script> <br /> <br /> <b> HTML </b> <XMP> ... <table id="list7" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager7" class="scroll" style="text-align:center;"></div> <br /> <a href="javascript:void(0)" id="s1">Set new url</a> <br /> <a href="javascript:void(0)" id="s2">Set Sort to amount column</a> <br /> <a href="javascript:void(0)" id="s3" >Set Sort new Order</a> <br /> <a href="javascript:void(0)" id="s4">Set to view second Page</a> <br /> <a href="javascript:void(0)" id="s5">Set new Number of Rows(15)</a> <br /> <a href="javascript:void(0)" id="s6" >Set Data Type from json to xml</a> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#list7").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pager7'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Set Methods Example", hidegrid: false, height: 210 }); jQuery("#list7").navGrid('#pager7',{edit:false,add:false,del:false,refresh:false,searchtext:"Find"}); jQuery("#s1").click( function() { jQuery("#list7").setGridParam({url:"server.php?q=2"}).trigger("reloadGrid") }); jQuery("#s2").click( function() { jQuery("#list7").setGridParam({sortname:"amount",sortorder:"asc"}).trigger("reloadGrid"); }); jQuery("#s3").click( function() { var so = jQuery("#list7").getGridParam('sortorder'); so = so=="asc"?"desc":"asc"; jQuery("#list7").setGridParam({sortorder:so}).trigger("reloadGrid"); }); jQuery("#s4").click( function() { jQuery("#list7").setGridParam({page:2}).trigger("reloadGrid"); }); jQuery("#s5").click( function() { jQuery("#list7").setGridParam({rowNum:15}).trigger("reloadGrid"); }); jQuery("#s6").click( function() { jQuery("#list7").setGridParam({url:"server.php?q=1",datatype:"xml"}).trigger("reloadGrid"); }); jQuery("#s7").click( function() { jQuery("#list7").setCaption("New Caption"); }); jQuery("#s8").click( function() { jQuery("#list7").sortGrid("name",false); }); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo json_encode($responce); ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/setex.html
HTML
gpl2
4,995
<div> From version 3.2 we can hide and show group of columns at once. <br/> These methods can accept array as argument as single string too. Try to resize the grid to see how <br/> these method works <br/> </div> <br /> <table id="hideshow" class="scroll"></table> <div id="phideshow" class="scroll" style="text-align:center;"></div> <br /> <a href="javascript:void(0)" id="hcg">Hide column Amount and Tax</a><br/> <a href="javascript:void(0)" id="scg">Show column Amount and Tax</a> <script src="hideshow.js" type="text/javascript"> </script> <br /> <br /> <b> HTML </b> <XMP> ... <table id="hideshow" class="scroll"></table> <div id="phideshow" class="scroll" style="text-align:center;"></div> <br /> <a href="javascript:void(0)" id="hcg">Hide column Amount and Tax</a><br/> <a href="javascript:void(0)" id="scg">Show column Amount and Tax</a> <script src="hideshow.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#hideshow").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#phideshow'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Dynamic hide/show column groups" }).navGrid("#phideshow",{edit:false,add:false,del:false}); jQuery("#hcg").click( function() { jQuery("#hideshow").hideCol(["amount","tax"]); }); jQuery("#scg").click( function() { jQuery("#hideshow").showCol(["amount","tax"]); }); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo json_encode($responce); ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/hideshow.html
HTML
gpl2
3,544
<?php include("dbconfig.php"); // coment the above lines if php 5 include("JSON.php"); $json = new Services_JSON(); // end comment $examp = $_REQUEST["q"]; //query number $page = $_REQUEST['page']; // get the requested page $limit = $_REQUEST['rows']; // get how many rows we want to have into the grid $sidx = $_REQUEST['sidx']; // get index row - i.e. user click to sort $sord = $_REQUEST['sord']; // get the direction if(!$sidx) $sidx =1; $wh = ""; $searchOn = Strip($_REQUEST['_search']); if($searchOn=='true') { $sarr = Strip($_REQUEST); foreach( $sarr as $k=>$v) { switch ($k) { case 'id': case 'invdate': case 'name': case 'note': $wh .= " AND ".$k." LIKE '".$v."%'"; break; case 'amount': case 'tax': case 'total': $wh .= " AND ".$k." = ".$v; break; } } } //echo $wh; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); switch ($examp) { case 1: $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id".$wh); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) if ($start<0) $start = 0; $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id".$wh." ORDER BY ".$sidx." ".$sord. " LIMIT ".$start." , ".$limit; $result = mysql_query( $SQL ) or die("Could not execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo $json->encode($responce); // coment if php 5 //echo json_encode($responce); break; case 3: } mysql_close($db); function Strip($value) { if(get_magic_quotes_gpc() != 0) { if(is_array($value)) if ( array_is_associative($value) ) { foreach( $value as $k=>$v) $tmp_val[$k] = stripslashes($v); $value = $tmp_val; } else for($j = 0; $j < sizeof($value); $j++) $value[$j] = stripslashes($value[$j]); else $value = stripslashes($value); } return $value; } function array_is_associative ($array) { if ( is_array($array) && ! empty($array) ) { for ( $iterator = count($array) - 1; $iterator; $iterator-- ) { if ( ! array_key_exists($iterator, $array) ) { return true; } } return ! array_key_exists(0, $array); } return false; } ?>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/search.php
PHP
gpl2
3,128
<div> This example show the new scrolling grid feature. The data is loaded when you scroll <br> the grid. Try to scroll and see what is happen. This method can be improwed when we <br> want to load relative big data. Note the automatic disabling of pager elements. </div> <br /> <table id="scrgrid" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pscrgrid" class="scroll" style="text-align:center;"></div> <script src="scrgrid.js" type="text/javascript"> </script> <br /> <b> HTML </b> <XMP> ... <table id="jsonopt" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pjopt" class="scroll" style="text-align:center;"></div> <script src="jsonopt.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#scrgrid").jqGrid({ scroll: true, url:'server.php?q=5', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:5, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pscrgrid'), sortname: 'id', viewrecords: true, sortorder: "desc", jsonReader: { repeatitems : true, cell:"", id: "0" }, caption: "Data Optimization", height: 80 }); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) if ($start<0) $start = 0; $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn’t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]=$responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo $json->encode($responce); // coment if php 5 //echo json_encode($responce); ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/scrgrid.html
HTML
gpl2
3,223
<div> This example demonstartes a form search of multi search<br> Just click on search button. </div> <br /> <table id="s2list" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="s2pager" class="scroll" style="text-align:center;"></div> <div id="filter" style="margin-left:30%;display:none">Search Invoices</div> <script src="search2.js" type="text/javascript"> </script> <br /> <b> HTML </b> <XMP> <table id="s2list" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="s2pager" class="scroll" style="text-align:center;"></div> <div id="filter" style="margin-left:30%;display:none">Search Invoices</div> <script src="search2.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#s2list").jqGrid({ url:'search.php?q=1', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:65}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right", edittype:'select', editoptions:{value:":All;0.00:0.00;12:12.00;20:20.00;40:40.00;60:60.00;120:120.00"}}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, mtype: "POST", rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#s2pager'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Multiple Form Search Example", onHeaderClick: function (stat) { if(stat == 'visible' ){ jQuery("#filter").css("display","none"); } } }) .navGrid('#s2pager',{edit:false,add:false,del:false,search:false,refresh:false}) .navButtonAdd("#s2pager",{caption:"Search",title:"Toggle Search",buttonimg:gridimgpath+'/find.gif', onClickButton:function(){ if(jQuery("#filter").css("display")=="none") { jQuery(".HeaderButton").trigger("click"); jQuery("#filter").show(); } } }) .navButtonAdd("#s2pager",{caption:"Clear",title:"Clear Search",buttonimg:gridimgpath+'/refresh.gif', onClickButton:function(){ var stat = jQuery("#s2list").getGridParam('search'); if(stat) { var cs = jQuery("#filter")[0]; cs.clearSearch(); } } }); jQuery("#filter").filterGrid("s2list", { gridModel:true, gridNames:true, formtype:"vertical", enableSearch:true, enableClear:false, autosearch: false, afterSearch : function() { jQuery(".HeaderButton").trigger("click"); jQuery("#filter").css("display","none"); } } ); jQuery("#sg_invdate","#filter").datepicker({dateFormat:"yy-mm-dd"}); </XMP> <b>PHP with MySQL</b> <XMP> See prevoious example. </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/search2.html
HTML
gpl2
2,863
<div> This example show how we can load array data. In this case we use a addRowData method. </div> <br /> <table id="list4" class="scroll" cellpadding="0" cellspacing="0"></table> <script src="localex.js" type="text/javascript"></script> <br /> <b> HTML </b> <XMP> ... <table id="list4" class="scroll" cellpadding="0" cellspacing="0"></table> </XMP> <b>Java Scrpt code</b> <XMP> jQuery("#list4").jqGrid({ datatype: "local", height: 250, colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:60, sorttype:"int"}, {name:'invdate',index:'invdate', width:90, sorttype:"date"}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right",sorttype:"float"}, {name:'tax',index:'tax', width:80, align:"right",sorttype:"float"}, {name:'total',index:'total', width:80,align:"right",sorttype:"float"}, {name:'note',index:'note', width:150, sortable:false} ], imgpath: gridimgpath, multiselect: true, caption: "Manipulating Array Data" }); var mydata = [ {id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"}, {id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"}, {id:"3",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}, {id:"4",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"}, {id:"5",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"}, {id:"6",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}, {id:"7",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"}, {id:"8",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"}, {id:"9",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"} ]; for(var i=0;i<=mydata.length;i++) jQuery("#list4").addRowData(i+1,mydata[i]); </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/localex.html
HTML
gpl2
2,159
<div> This example demonstartes the new multi serach feature of jqGrid.<br> The search fields are in the toolbar. Click on search button to toggle the search and enjoy </div> <br /> <table id="s1list" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="s1pager" class="scroll" style="text-align:center;"></div> <script src="search1.js" type="text/javascript"> </script> <br /> <b> HTML </b> <XMP> ... <table id="s1list" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="s1pager" class="scroll" style="text-align:center;"></div> <script src="search1.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#s1list").jqGrid({ url:'search.php?q=1', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:65}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right", edittype:'select', editoptions:{value:":All;0.00:0.00;12:12.00;20:20.00;40:40.00;60:60.00;120:120.00"}}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, mtype: "POST", rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#s1pager'), sortname: 'id', viewrecords: true, toolbar : [true,"top"], sortorder: "desc", caption:"Multiple Toolbar Search Example" }); jQuery("#t_s1list").height(25).hide().filterGrid("s1list",{gridModel:true,gridToolbar:true}); jQuery("#sg_invdate").datepicker({dateFormat:"yy-mm-dd"}); jQuery("#s1list").navGrid('#s1pager',{edit:false,add:false,del:false,search:false,refresh:false}) .navButtonAdd("#s1pager",{caption:"Search",title:"Toggle Search",buttonimg:gridimgpath+'/find.gif', onClickButton:function(){ if(jQuery("#t_s1list").css("display")=="none") { jQuery("#t_s1list").css("display",""); } else { jQuery("#t_s1list").css("display","none"); } } }); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_REQUEST['page']; // get the requested page $limit = $_REQUEST['rows']; // get how many rows we want to have into the grid $sidx = $_REQUEST['sidx']; // get index row - i.e. user click to sort $sord = $_REQUEST['sord']; // get the direction if(!$sidx) $sidx =1; $wh = ""; $searchOn = Strip($_REQUEST['_search']); if($searchOn=='true') { $sarr = Strip($_REQUEST); foreach( $sarr as $k=>$v) { switch ($k) { case 'id': case 'invdate': case 'name': case 'note': $wh .= " AND ".$k." LIKE '".$v."%'"; break; case 'amount': case 'tax': case 'total': $wh .= " AND ".$k." = ".$v; break; } } } //echo $wh; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); switch ($examp) { case 1: $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id".$wh); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) if ($start<0) $start = 0; $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id".$wh." ORDER BY ".$sidx." ".$sord. " LIMIT ".$start." , ".$limit; $result = mysql_query( $SQL ) or die("Could not execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo $json->encode($responce); // coment if php 5 //echo json_encode($responce); break; case 3: } mysql_close($db); ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/search1.html
HTML
gpl2
4,407
jQuery("#list10").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pager10'), sortname: 'id', viewrecords: true, sortorder: "desc", multiselect: false, caption: "Invoice Header", onSelectRow: function(ids) { if(ids == null) { ids=0; if(jQuery("#list10_d").getGridParam('records') >0 ) { jQuery("#list10_d").setGridParam({url:"subgrid.php?q=1&id="+ids,page:1}) .setCaption("Invoice Detail: "+ids) .trigger('reloadGrid'); } } else { jQuery("#list10_d").setGridParam({url:"subgrid.php?q=1&id="+ids,page:1}) .setCaption("Invoice Detail: "+ids) .trigger('reloadGrid'); } } }).navGrid('#pager10',{add:false,edit:false,del:false}); jQuery("#list10_d").jqGrid({ height: 100, url:'subgrid.php?q=1&id=0', datatype: "json", colNames:['No','Item', 'Qty', 'Unit','Line Total'], colModel:[ {name:'num',index:'num', width:55}, {name:'item',index:'item', width:180}, {name:'qty',index:'qty', width:80, align:"right"}, {name:'unit',index:'unit', width:80, align:"right"}, {name:'linetotal',index:'linetotal', width:80,align:"right", sortable:false, search:false} ], rowNum:5, rowList:[5,10,20], imgpath: gridimgpath, pager: jQuery('#pager10_d'), sortname: 'item', viewrecords: true, sortorder: "asc", multiselect: true, caption:"Invoice Detail" }).navGrid('#pager10_d',{add:false,edit:false,del:false}); jQuery("#ms1").click( function() { var s; s = jQuery("#list10_d").getMultiRow(); alert(s); });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/masterex.js
JavaScript
gpl2
2,143
<?php // Include the information needed for the connection to // MySQL data base server. include("dbconfig.php"); //since we want to use a JSON data we should include //encoder and decoder for JSON notation //If you use a php >= 5 this file is not needed include("JSON.php"); // create a JSON service $json = new Services_JSON(); // to the url parameter are added 4 parameter // we shuld get these parameter to construct the needed query // for the pager // get the requested page $page = $_REQUEST['page']; // get how many rows we want to have into the grid // rowNum parameter in the grid $limit = $_REQUEST['rows']; // get index row - i.e. user click to sort // at first time sortname parameter - after that the index from colModel $sidx = $_REQUEST['sidx']; // sorting order - at first time sortorder $sord = $_REQUEST['sord']; // if we not pass at first time index use the first column for the index if(!$sidx) $sidx =1; // connect to the MySQL database server $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); // select the database mysql_select_db($database) or die("Error conecting to db."); // calculate the number of rows for the query. We need this to paging the result $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; // calculation of total pages for the query if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } // if for some reasons the requested page is greater than the total // set the requested page to total page if ($page > $total_pages) $page=$total_pages; // calculate the starting position of the rows $start = $limit*$page - $limit; // do not put $limit*($page - 1) // if for some reasons start position is negative set it to 0 // typical case is that the user type 0 for the requested page if($start <0) $start = 0; // the actual query for the grid data $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); // constructing a JSON $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } // return the formated data echo $json->encode($responce); ?>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/example.php
PHP
gpl2
2,739
<div> This example demonstartes the new option hiddengrid. If set to true the grid initially is hidden. The data is not loaded <br/> (no request is made) and only the caption layer is shown. When click to show grid (first time only) <br/> the data is loaded and grid is shown. From this point we have a regular grid. This option work <br/> only if the caption option is set and hidegrid option is set to true. Try to click on caption button. </div> <br/> <br/> <table id="hidengrid" class="scroll"></table> <div id="phidengrid" class="scroll" style="text-align:center;"></div> <script src="hiddengrid.js" type="text/javascript"> </script> <br /> <br /> <b> HTML </b> <XMP> ... <table id="hidengrid" class="scroll"></table> <div id="phidengrid" class="scroll" style="text-align:center;"></div> <script src="hiddengrid.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#hidengrid").jqGrid({ url:'server.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#phidengrid'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Initial Hidden Grid", multiselect: false, hiddengrid: true }).navGrid('#phidengrid',{edit:false,add:false,del:false}); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn’t execute query.".mysql_error()); if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) { header("Content-type: application/xhtml+xml;charset=utf-8"); } else { header("Content-type: text/xml;charset=utf-8"); } $et = ">"; echo "<?xml version='1.0' encoding='utf-8'?$et\n"; echo "<rows>"; echo "<page>".$page."</page>"; echo "<total>".$total_pages."</total>"; echo "<records>".$count."</records>"; // be sure to put text data in CDATA while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { echo "<row id='". $row[id]."'>"; echo "<cell>". $row[id]."</cell>"; echo "<cell>". $row[invdate]."</cell>"; echo "<cell><![CDATA[". $row[name]."]]></cell>"; echo "<cell>". $row[amount]."</cell>"; echo "<cell>". $row[tax]."</cell>"; echo "<cell>". $row[total]."</cell>"; echo "<cell><![CDATA[". $row[note]."]]></cell>"; echo "</row>"; } echo "</rows>"; ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/hiddengrid.html
HTML
gpl2
3,828
<div> This example show how we can load JSON data with custom data type functon <br> i.e. the data is obtained not with the url parameter but with custom function. </div> <br /> <table id="listdt" class="scroll" ></table> <div id="pagerdt" class="scroll" style="text-align:center;"></div> <script src="datatype.js" type="text/javascript"> </script> <br /> <b> HTML </b> <XMP> ... <table id="listdt" class="scroll"></table> <div id="pagerdt" class="scroll" style="text-align:center;"></div> <script src="datatype.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#listdt").jqGrid({ //url:'server.php?q=2', datatype : function (pdata) { $.ajax({ url:'server.php?q=2', data:pdata, dataType:"json", complete: function(jsondata,stat){ if(stat=="success") { var thegrid = jQuery("#listdt")[0]; thegrid.addJSONData(eval("("+jsondata.responseText+")")) } } }); }, colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right", editable:true,editrules:{number:true,minValue:100,maxValue:350}}, {name:'tax',index:'tax', width:80, align:"right",editable:true,edittype:"select",editoptions:{value:"IN:InTime;TN:TNT;AR:ARAMEX"}}, {name:'total',index:'total', width:80,align:"right",editable: true,edittype:"checkbox",editoptions: {value:"Yes:No"} }, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pagerdt'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Data type as function Example", cellEdit: true }).navGrid('#pagerdt',{edit:false,add:false,del:false}); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo json_encode($responce); ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/datatype.html
HTML
gpl2
3,508
<div> This example demonstrates dynamic resizing of grid. It is known that <br> the width of grid is sum of the width of the columns. We can overwrite<br> this by setting the grid width. In this case the column width are <br> scaled to the new width.<br> With setting the height to 100% we can scale the height of the grid.<br> Try to go on next page. </div> <br /> <table id="list12" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager12" class="scroll" style="text-align:center;"></div> <script src="resizeex.js" type="text/javascript"> </script> <br /> <br /> <b> HTML </b> <XMP> ... <table id="list12" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager12" class="scroll" style="text-align:center;"></div> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#list12").jqGrid({ url:'server.php?q=2', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pager12'), sortname: 'id', viewrecords: true, sortorder: "desc", multiselect: false, width: 500, height: "100%", caption: "Auto height example" }).navGrid('#pager12',{add:false,edit:false,del:false}); </XMP> <b>PHP with MySQL</b> <XMP> ... $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[id]; $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]); $i++; } echo json_encode($responce); ... </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/resizeex.html
HTML
gpl2
3,202
jQuery("#editgrid").jqGrid({ url:'editing.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Closed','Ship via','Notes'], colModel:[ {name:'id',index:'id', width:55,editable:false,editoptions:{readonly:true,size:10}}, {name:'invdate',index:'invdate', width:80,editable:true,editoptions:{size:10}}, {name:'name',index:'name', width:90,editable:true,editoptions:{size:25}}, {name:'amount',index:'amount', width:60, align:"right",editable:true,editoptions:{size:10}}, {name:'tax',index:'tax', width:60, align:"right",editable:true,editoptions:{size:10}}, {name:'total',index:'total', width:60,align:"right",editable:true,editoptions:{size:10}}, {name:'closed',index:'closed',width:55,align:'center',editable:true,edittype:"checkbox",editoptions:{value:"Yes:No"}}, {name:'ship_via',index:'ship_via',width:70, editable: true,edittype:"select",editoptions:{value:"FE:FedEx;TN:TNT"}}, {name:'note',index:'note', width:100, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"20"}} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pagered'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Editing Example", editurl:"someurl.php" }); $("#bedata").click(function(){ var gr = jQuery("#editgrid").getGridParam('selrow'); if( gr != null ) jQuery("#editgrid").editGridRow(gr,{height:280,reloadAfterSubmit:false}); else alert("Please Select Row"); });
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/editing.js
JavaScript
gpl2
1,577
<div> From now jqGrid can accept XML and JSON data with arbitrary structure. In this release we introduce a xmlReader and jsonReader.<br> This way we can analyze and display a wide range of data structures. More information will be<br> available in the upcoming documentation.<br> <a href="books.xml" target="_blank"> View the book.xml file </a> </div> <br /> <table id="list19" class="scroll" cellpadding="0" cellspacing="0"></table> <script src="xmlmap.js" type="text/javascript"> </script> <br /> <b> HTML </b> <XMP> ... <table id="list19" class="scroll" cellpadding="0" cellspacing="0"></table> <script src="xmlmap.js" type="text/javascript"> </script> </XMP> <b>Java Scrpt code</b> <XMP> ... jQuery("#list19").jqGrid({ url: 'books.xml', datatype: "xml", colNames:["Author","Title", "Price", "Published Date"], colModel:[ {name:"Author",index:"Author", width:120, xmlmap:"ItemAttributes>Author"}, {name:"Title",index:"Title", width:180,xmlmap:"ItemAttributes>Title"}, {name:"Price",index:"Manufacturer", width:100, align:"right",xmlmap:"ItemAttributes>Price", sorttype:"float"}, {name:"DatePub",index:"ProductGroup", width:130,xmlmap:"ItemAttributes>DatePub",sorttype:"date"} ], height:250, rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, viewrecords: true, loadonce: true, xmlReader: { root : "Items", row: "Item", repeatitems: false, id: "ASIN" }, caption: "XML Mapping example" }); </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/xmlmap.html
HTML
gpl2
1,519
jQuery("#jsonopt").jqGrid({ url:'server.php?q=5', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pjopt'), sortname: 'id', viewrecords: true, sortorder: "desc", jsonReader: { repeatitems : true, cell:"", id: "0" }, caption: "Data Optimization", height: 210 }).navGrid('#pjopt',{edit:false,add:false,del:false});
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/jsonopt.js
JavaScript
gpl2
901
jQuery("#list14").jqGrid({ url:'server.php?q=2', datatype: "json", height: 200, colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pager14'), sortname: 'id', viewrecords: true, sortorder: "desc", multiselect: false, subGrid : true, subGridUrl: 'subgrid.php?q=3', subGridModel: [{ name : ['No','Item','Qty','Unit','Line Total'], width : [55,200,80,80,80], params:['invdate']} ] , caption: "Subgrid with JSON Data" }).navGrid('#pager14',{edit:false,add:false,del:false});
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/jsubgrid.js
JavaScript
gpl2
1,064
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jqGrid Demo</title> <style> html, body { margin: 0; /* Remove body margin/padding */ padding: 0; overflow: auto; /* Remove scroll bars on browser window */ font: 12px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana; } </style> <!-- In head section we should include the style sheet for the grid --> <link rel="stylesheet" type="text/css" media="screen" href="themes/sand/grid.css" /> <!-- Of course we should load the jquery library --> <script src="js/jquery.js" type="text/javascript"></script> <!-- and at end the jqGrid Java Script file --> <script src="js/jquery.jqGrid.js" type="text/javascript"></script> <script type="text/javascript"> // We use a document ready jquery function. jQuery(document).ready(function(){ jQuery("#list2").jqGrid({ // the url parameter tells from where to get the data from server // adding ?nd='+new Date().getTime() prevent IE caching url:'example.php?nd='+new Date().getTime(), // datatype parameter defines the format of data returned from the server // in this case we use a JSON data datatype: "json", // colNames parameter is a array in which we describe the names // in the columns. This is the text that apper in the head of the grid. colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], // colModel array describes the model of the column. // name is the name of the column, // index is the name passed to the server to sort data // note that we can pass here nubers too. // width is the width of the column // align is the align of the column (default is left) // sortable defines if this column can be sorted (default true) colModel:[ {name:'id',index:'id', width:55}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name asc, invdate', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right"}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], // pager parameter define that we want to use a pager bar // in this case this must be a valid html element. // note that the pager can have a position where you want pager: jQuery('#pager2'), // rowNum parameter describes how many records we want to // view in the grid. We use this in example.php to return // the needed data. rowNum:10, // rowList parameter construct a select box element in the pager //in wich we can change the number of the visible rows rowList:[10,20,30], // path to mage location needed for the grid imgpath: 'themes/sand/images', // sortname sets the initial sorting column. Can be a name or number. // this parameter is added to the url sortname: 'id', //viewrecords defines the view the total records from the query in the pager //bar. The related tag is: records in xml or json definitions. viewrecords: true, //sets the sorting order. Default is asc. This parameter is added to the url sortorder: "desc", caption: "Demo" }); }); </script> </head> <body> <!-- the grid definition in html is a table tag with class 'scroll' --> <table id="list2" class="scroll" cellpadding="0" cellspacing="0"></table> <!-- pager definition. class scroll tels that we want to use the same theme as grid --> <div id="pager2" class="scroll" style="text-align:center;"></div> </body> </html>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/example.html
HTML
gpl2
3,818
jQuery("#s2list").jqGrid({ url:'search.php?q=1', datatype: "json", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'], colModel:[ {name:'id',index:'id', width:65}, {name:'invdate',index:'invdate', width:90}, {name:'name',index:'name', width:100}, {name:'amount',index:'amount', width:80, align:"right"}, {name:'tax',index:'tax', width:80, align:"right", edittype:'select', editoptions:{value:":All;0.00:0.00;12:12.00;20:20.00;40:40.00;60:60.00;120:120.00"}}, {name:'total',index:'total', width:80,align:"right"}, {name:'note',index:'note', width:150, sortable:false} ], rowNum:10, mtype: "POST", rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#s2pager'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Multiple Form Search Example", onHeaderClick: function (stat) { if(stat == 'visible' ){ jQuery("#filter").css("display","none"); } } }) .navGrid('#s2pager',{edit:false,add:false,del:false,search:false,refresh:false}) .navButtonAdd("#s2pager",{caption:"Search",title:"Toggle Search",buttonimg:gridimgpath+'/find.gif', onClickButton:function(){ if(jQuery("#filter").css("display")=="none") { jQuery(".HeaderButton").trigger("click"); jQuery("#filter").show(); } } }) .navButtonAdd("#s2pager",{caption:"Clear",title:"Clear Search",buttonimg:gridimgpath+'/refresh.gif', onClickButton:function(){ var stat = jQuery("#s2list").getGridParam('search'); if(stat) { var cs = jQuery("#filter")[0]; cs.clearSearch(); } } }); jQuery("#filter").filterGrid("s2list", { gridModel:true, gridNames:true, formtype:"vertical", enableSearch:true, enableClear:false, autosearch: false, afterSearch : function() { jQuery(".HeaderButton").trigger("click"); jQuery("#filter").css("display","none"); } } ); jQuery("#sg_invdate","#filter").datepicker({dateFormat:"yy-mm-dd"});
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/search2.js
JavaScript
gpl2
2,027
<div> This example show how we can add dialog for adding data.<br/> See below for all available options. <br/> Note: The data is not saved to the server<br/> </div> <br /> <table id="addgrid" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pagerad" class="scroll" style="text-align:center;"></div> <input type="BUTTON" id="badata" value="Add" /> <script src="adding.js" type="text/javascript"> </script> <br /><br /> <b> Description </b> <br /> This method uses <b>colModel</b> and <b>editurl</b> parameters from jqGrid <br/> <code> Calling: jQuery("#grid_id").editGridRow( the_row_id, options ); </code> <br/> <b>the_row_id</b> when in add mode the special value must be set - "new" <br/> <b> options </b> <br/> <b>top : 0</b> the initial top position of edit dialog<br/> <b>left: 0</b> the initinal left position of edit dialog<br/> If the left and top positions are not set the dialog apper on<br/> upper left corner of the grid <br/> <b>width: 0</b>, the width of edit dialog - default 300<br/> <b>height: 0</b>, the height of edit dialog default 200<br/> <b>modal: false</b>, determine if the dialog should be in modal mode default is false<br/> <b>drag: true</b>,determine if the dialog is dragable default true<br/> <b>addCaption: "Add Record"</b>,the caption of the dialog if the mode is adding<br/> <b>editCaption: "Edit Record"</b>,the caption of the dialog if the mode is editing<br/> <b>bSubmit: "Submit"</b>, the text of the button when you click to data default Submit<br/> <b>bCancel: "Cancel"</b>,the text of the button when you click to close dialog default Cancel<br/> <b>url: </b>, url where to post data. If set replace the editurl <br/> <b>processData: "Processing..."</b>, Indicator when posting data<br/> <b>closeAfterAdd : false</b>, when add mode closes the dialog after add record - default false<br/> <b>clearAfterAdd : true</b>, when add mode clears the data after adding data - default true<br/> <b>closeAfterEdit : false</b>, when in edit mode closes the dialog after editing - default false<br/> <b>reloadAfterSubmit : true</b> reloads grid data after posting default is true <br/> // <i>Events</i> <br/> <b>intializeForm: null</b> fires only once when creating the data for editing and adding.<br/> Paramter passed to the event is the id of the constructed form.<br/> <b>beforeInitData: null</b> fires before initialize the form data.<br/> Paramter passed to the event is the id of the constructed form.<br/> <b>beforeShowForm: null</b> fires before showing the form data.<br/> Paramter passed to the event is the id of the constructed form.<br/> <b>afterShowForm: null</b> fires after the form is shown.<br/> Paramter passed to the event is the id of the constructed form.<br/> <b>beforeSubmit: null</b> fires before the data is submitted to the server<br/> Paramter is array of type name:value. When called the event can return array <br/> where the first parameter can be true or false and the second is the message of the error if any<br/> Example: [false,"The value is not valid"]<br/> <b>afterSubmit: null</b> fires after the data is posted to the server. Typical this <br/> event is used to recieve status form server if the data is posted with success.<br/> Parameters to this event are the returned data from the request and array of the<br/> posted values of type name:value<br/> <br/> <b> HTML </b> <XMP> ... <<table id="editgrid" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pagered" class="scroll" style="text-align:center;"></div> <input type="BUTTON" id="bedata" value="Edit Selected" /> </XMP> <b>Java Scrpt code</b> <XMP> jQuery("#editgrid").jqGrid({ url:'editing.php?q=1', datatype: "xml", colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Closed','Ship via','Notes'], colModel:[ {name:'id',index:'id', width:55,editable:false,editoptions:{readonly:true,size:10}}, {name:'invdate',index:'invdate', width:80,editable:true,editoptions:{size:10}}, {name:'name',index:'name', width:90,editable:true,editoptions:{size:25}}, {name:'amount',index:'amount', width:60, align:"right",editable:true,editoptions:{size:10}}, {name:'tax',index:'tax', width:60, align:"right",editable:true,editoptions:{size:10}}, {name:'total',index:'total', width:60,align:"right",editable:true,editoptions:{size:10}}, {name:'closed',index:'closed',width:55,align:'center',editable:true,edittype:"checkbox",editoptions:{value:"Yes:No"}}, {name:'ship_via',index:'ship_via',width:70, editable: true,edittype:"select",editoptions:{value:"FE:FedEx;TN:TNT"}}, {name:'note',index:'note', width:100, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"20"}} ], rowNum:10, rowList:[10,20,30], imgpath: gridimgpath, pager: jQuery('#pagered'), sortname: 'id', viewrecords: true, sortorder: "desc", caption:"Search Example", editurl:"someurl.php" }); $("#bedata").click(function(){ var gr = jQuery("#editgrid").getSelectedRow(); if( gr != null ) jQuery("#editgrid").editGridRow(gr,{height:280,reloadAfterSubmit:false}); else alert("Please Select Row"); }); </XMP>
zzyn125-bench
BigMelon/Backup/jslib_backup/jqgrid_demo/adding.html
HTML
gpl2
5,281