From 7a58f0b354a07fbb6614fd77a6d4a5357fa52cd9 Mon Sep 17 00:00:00 2001 From: paramvir Date: Mon, 19 Oct 2015 12:06:10 +0530 Subject: [PATCH] v2.0.4 --- ChangeLog.txt | 214 +- README.md | 32 +- array.htm | 64 + bower.json | 6 +- images/horiz-bg.png | Bin 0 -> 230 bytes images/horiz-slider-bg.png | Bin 0 -> 210 bytes images/loading.gif | Bin 0 -> 771 bytes images/sprite.png | Bin 0 -> 1668 bytes images/square_dirty.gif | Bin 0 -> 76 bytes images/vert-bg.png | Bin 0 -> 216 bytes images/vert-slider-bg.png | Bin 0 -> 201 bytes index.htm | 4 +- json.htm | 65 + localize/pq-localize-en.js | 25 + localize/pq-localize-ja.js | 49 +- localize/pq-localize-pl.js | 26 + localize/pq-localize-pt.js | 25 + localize/pq-localize-tr.js | 25 + pqGridCrud.js | 175 - pqgrid.dev.css | 1132 +- pqgrid.dev.js | 16260 ++++++++++++++++++------ pqgrid.jquery.json | 11 +- pqgrid.min.css | 9 + pqgrid.min.js | 9 + themes/Office/images/header-hover.gif | Bin 0 -> 205 bytes themes/Office/pqgrid.css | 131 +- themes/peach/pq-grid.css | 109 - 27 files changed, 13246 insertions(+), 5125 deletions(-) create mode 100644 array.htm create mode 100644 images/horiz-bg.png create mode 100644 images/horiz-slider-bg.png create mode 100644 images/loading.gif create mode 100644 images/sprite.png create mode 100644 images/square_dirty.gif create mode 100644 images/vert-bg.png create mode 100644 images/vert-slider-bg.png create mode 100644 json.htm create mode 100644 localize/pq-localize-en.js create mode 100644 localize/pq-localize-pl.js create mode 100644 localize/pq-localize-pt.js create mode 100644 localize/pq-localize-tr.js delete mode 100644 pqGridCrud.js create mode 100644 pqgrid.min.css create mode 100644 pqgrid.min.js create mode 100644 themes/Office/images/header-hover.gif delete mode 100644 themes/peach/pq-grid.css diff --git a/ChangeLog.txt b/ChangeLog.txt index a905ef9..683fed4 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,76 +1,138 @@ -Version: 1.1.3 - -1) Improved support for JSON: dataIndx can be int or String -2) flexWidth fix for IE10 -3) Correction in camelCase cellKeyDown and cellEditKeyDown - -Version: 1.1.2 - -Grouping bug fix. - -Version: 1.1.1 - -Options: bottomVisible, oddRowsHighlight, roundCorners, rowBorders -Methods: getEditCell -Events: cellEditKeyDown, cellKeyDown, rowDblClick - -Version: 1.1.0 - -internationalization and localization - -Version: 1.0.9 - -ThemeRoller ready. - -Version: 1.0.8 - -1) Method: createTable -2) Events: refresh - -Version: 1.0.7 - -1) Page scroll till bottom. -2) removal of $.browser -3) jQuery 1.9 compatibility. -4) Option: topVisible. -5) Change adapter namespace to paramquery. - -Version: 1.0.6 - -1) FlexHeight, FlexWidth & ScrollModel > horizontal -2) Added new scrollbar look. - -Version: 1.0.5 - -Edit field and dataIndx bug fixes - -Version: 1.0.4 - -1) Header background css -2) Nested colModels for grouped columns. -3) Name of column > saveCell callback changed to column > getEditCellData -4) dataIndx introduced to bind colModel > columns with data columns explicitly. -5) Events: cellSave, cellClick, cellDblClick, cellSelect, cellUnSelect, rowClick, rowSelect, rowUnSelect -6) Options: column > dataIndx, column > sortable, customData, editModel, hoverMode, selectionModel -7) Methods: getColIndxFromDataIndx, getCell, getEditCellData, getRow, isEditableCell, refreshCell, refreshColumn, refreshRow, selection -8) getSelection method removed. - -Version: 1.0.3 - -1) Added beforeTableView event -2) Added DataModel > error method -3) Added classes pq-row-select,pq-cell-select,pq-grid-row, pq-grid-row-hover -4) Added scrollPace option - -Version: 1.0.2 - -1) Added render event. -2) Absolute address with paging made possible with setSelection and getSelection. -3) Support for adding toolbar. - -Version: 1.0.1 - -1) Added refresh button in pager. -2) Added public methods: editCell,saveEditCell & quitEditMode. - - +Version 2.0.4 (10/19/2015) + +Addition: + +filter conditions: between, range, regexp, lte, gte, notbegin, notend +stringify +updateRow, getData +selectionModel: all, cbAll, cbHeader +scrollModel: theme + +Changes: + +rowSelect, rowUnSelect, cellSelect, cellUnSelect, pq-sb-vert, pq-sb-horiz + + +New features: +Nested grids & detail View (rowExpand,rowCollapse,rowInvalidate,detailModel) +multiple Selections with mouse drag. + +Fixes: +IE7: group title, DnD headers, resizable handles. +Firefox: DnD headers (droppable areas) + +Migration steps: +Move paging properties from dataModel to pageModel. + + +editModel +editor +validation +quitEditMode missing keys added +isValid +isDirty +getRowsByClass +getRowIndx +getCellIndices change from $td to {$td:$td} +refreshView +column.validations +column.editModel + +Migration steps: +View needs to be refreshed manually + + +Fixes: +_refreshWidths +_refreshWidthsAutoFit +isEditableCell: +_pKeyNav._decrEditIndx +_editCell +_getEditCellData +getCell +saveEditCell +getRowIndx +_refreshSortingDataAndView +exportToExcel +rollback +commit +getChanges +_refreshResizeColumnStop + + +Version: 1.1.3 + +1) Improved support for JSON: dataIndx can be int or String +2) flexWidth fix for IE10 +3) Correction in camelCase cellKeyDown and cellEditKeyDown + +Version: 1.1.2 + +Grouping bug fix. + +Version: 1.1.1 + +Options: bottomVisible, oddRowsHighlight, roundCorners, rowBorders +Methods: getEditCell +Events: cellEditKeyDown, cellKeyDown, rowDblClick + +Version: 1.1.0 + +internationalization and localization + +Version: 1.0.9 + +ThemeRoller ready. + +Version: 1.0.8 + +1) Method: createTable +2) Events: refresh + +Version: 1.0.7 + +1) Page scroll till bottom. +2) removal of $.browser +3) jQuery 1.9 compatibility. +4) Option: topVisible. +5) Change adapter namespace to paramquery. + +Version: 1.0.6 + +1) FlexHeight, FlexWidth & ScrollModel > horizontal +2) Added new scrollbar look. + +Version: 1.0.5 + +Edit field and dataIndx bug fixes + +Version: 1.0.4 + +1) Header background css +2) Nested colModels for grouped columns. +3) Name of column > saveCell callback changed to column > getEditCellData +4) dataIndx introduced to bind colModel > columns with data columns explicitly. +5) Events: cellSave, cellClick, cellDblClick, cellSelect, cellUnSelect, rowClick, rowSelect, rowUnSelect +6) Options: column > dataIndx, column > sortable, customData, editModel, hoverMode, selectionModel +7) Methods: getColIndxFromDataIndx, getCell, getEditCellData, getRow, isEditableCell, refreshCell, refreshColumn, refreshRow, selection +8) getSelection method removed. + +Version: 1.0.3 + +1) Added beforeTableView event +2) Added DataModel > error method +3) Added classes pq-row-select,pq-cell-select,pq-grid-row, pq-grid-row-hover +4) Added scrollPace option + +Version: 1.0.2 + +1) Added render event. +2) Absolute address with paging made possible with setSelection and getSelection. +3) Support for adding toolbar. + +Version: 1.0.1 + +1) Added refresh button in pager. +2) Added public methods: editCell,saveEditCell & quitEditMode. + + diff --git a/README.md b/README.md index ec27924..d893abf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ jQuery grid plugin based on jQueryui widget design ================================================== -[ParamQuery Grid](http://paramquery.com) a.k.a. pqGrid v1.1 +[ParamQuery Grid](http://paramquery.com) a.k.a. pqGrid v2.0 Copyright (c) 2012-2015 Paramvir Dhindsa @@ -22,34 +22,36 @@ ParamQuery grid is a lightweight jQuery grid plugin inspired by MS Excel and Goo ### Features: ``` -It's designed on jQueryui widget pattern so it has all the advantages of it e.g. changing any -option during runtime, methods like enable, disable, destroy, etc. -Sorting for common data formats like Integer, real numbers, Strings, etc. +Local, remote and custom sorting for common data formats like Integer, real numbers, Strings, etc. -Support for custom sorting through callback function. +Local and remote filtering with header filtering row interface. Paging with local (Browser) or remote (Ajax) data in any format. -Freeze any number of Columns like Excel. +Column and row grouping and fixed summary row. -Connect to any data source format like HTML, Array, XML, JSON, etc locally or remotely through Ajax. +Frozen rows & columns like Excel. -Can be used with any server side framework e.g. ASP.NET, MVC3, JSP, JSF, PHP, etc. +Export to Excel & CSV format. + +Nesting of grids and row details. -Minimal impact on performance with increase in number of records thanks to Virtual Scrolling and Rendering. +Virtual Scrolling and Rendering with unlimited rows and columns support. -Inline Editing of cells with support to plugin custom editors. +Inline Editing: Batch editing, row editing, custom editors, multiline editing, validations. -Resizable columns. +Hide/ show columns, resizable and reorderable columns through drag and drop. -Resizable height and width. +Theme support. -Customizable theme. +i18n. -Hiding / Showing columns. +Consistent look and functionality across all major browsers IE(8+), Firefox, Chrome, Opera, etc -Consistent look and functionality across all major browsers IE(6+), Firefox, Chrome, Opera, etc +Display any data source format like HTML, Array, XML, JSON, etc locally or remotely through Ajax. + +Can be used with any server side framework e.g. ASP.NET, MVC3, JSP, JSF, PHP, etc. Many more... ``` diff --git a/array.htm b/array.htm new file mode 100644 index 0000000..6c80264 --- /dev/null +++ b/array.htm @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + +
+ + + diff --git a/bower.json b/bower.json index 03910ec..6b2e428 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "pqGrid", - "description": "Data grid inspired by MS Excel, provides sorting, paging, grouping, rows and cell selections, frozen rows, frozen columns, Add, delete, update, search, can display HTML, JSON, Array, XML, inline editing, virtual rendering, virtual scrolling, cross browser, cross platform, Themeroller ready with 24 ready to use themes.", - "version": "1.1.3", + "description": "Data grid inspired by MS Excel, provides sorting, filtering, paging, grouping, nesting, rows and cell selections, frozen rows, frozen columns, Add, delete, update, search, can display HTML, JSON, Array, XML, inline editing, validations, virtual rendering, virtual scrolling, cross browser, cross platform, Themeroller ready with 24 ready to use themes.", + "version": "2.0.4", "author": { "name": "Paramvir Singh Dhindsa", "email": "pdhindsa@paramquery.com", @@ -31,6 +31,6 @@ "bugs": "https://github.com/paramquery/grid/issues", "dependencies": { "jquery": ">=1.7.0", - "jqueryui": ">=1.9.1" + "jqueryui": ">=1.9.2" } } diff --git a/images/horiz-bg.png b/images/horiz-bg.png new file mode 100644 index 0000000000000000000000000000000000000000..7d697da3688b413e36f84d418f1081b42e6031a8 GIT binary patch literal 230 zcmeAS@N?(olHy`uVBq!ia0vp^+(0bI!3JVI47&}a*pj^6T^Rm@;DWu&Cj&(|3p^r= zf%3v2%*Zfnjs#GUy~NYkmHiGkJ0Cl5h2st#ppa~dYeb22er|4RUI~M9QEFmIYKlU6 zW=V!ZNJgrHyQgo!`xMnYph7QC7srr_TU#fd)i8o&8e(7z!%cejg3s RlLeZ};OXk;vd$@?2>@>tOa=e| literal 0 HcmV?d00001 diff --git a/images/horiz-slider-bg.png b/images/horiz-slider-bg.png new file mode 100644 index 0000000000000000000000000000000000000000..0acf4ff41db3bc620411d0c8169bbed30c2e21d3 GIT binary patch literal 210 zcmeAS@N?(olHy`uVBq!ia0vp^j6f{N!2~2HFAQ`AQk(@Ik;M!Q+`=Ht$S`Y;1W=H@ z#M9T6{Vp?ykc9O2Jr|Dxg=9-yBTAg}b8}PkN*J7rQWHy3QxwWGOEMHfGEx=XJ$(b- zr>N!u6?%BOIEGZ*Vm;`{)u15Y5cpF~)Z@asUH?yZ6_`6-R4P4ouUP5P_v+%~GYzs! z{xVdoGFv0{vg(AZrt8m5LQFn|DKi)QzklWOgnfUMq7SdU!y=%W44$rjF6*2UngEZz BLh%3q literal 0 HcmV?d00001 diff --git a/images/loading.gif b/images/loading.gif new file mode 100644 index 0000000000000000000000000000000000000000..e846e1d6c58796558015ffee1fdec546bc207ee8 GIT binary patch literal 771 zcmZ?wbhEHb6krfw*v!MQYQ=(yeQk4RPu{+D?cCXuwr^cCp}%d_ius2R?!0jBXnAQ) zOH<|l|Nj|aK=D7fpKD04vtxj(k)8oFBT!uNCkrbB0}q1^NDatX1{VJbCr|b)oWWMT zS%hVC ~NwO_yO%;SvZ5MdNYf|QNy-I*%yJaj+uTdt+qbZ z4E`Fzb8m}I&!N8OKmWEcCmrLs^Hs&3i)mt@hQVdcqghkaBs*D}tG_lKew4?rTjzIZ z9tSone1TS+TR7tu^CunG)Y7Jg#sw#)sG9C!c0I%LEzP)9;hqRf&)s$D8d5Db{TBs% zgl0~5QQ91luq4Q9tJgt4QLbaxZvAaKeCM9!oy85dg4k>TdBSVqjHub_PG=PO&J-rx z7oYTuF+kH|tG-UK+EkUhDjYx?zW?T|lx>+aOQm zzL$v$zBLo4Cj=G&tw{H}dW?tlTkS)SY4<#NS92z*EY-MMB6Ftp`R=*=*Ev7cS+X%W zMCur^FdlokL}1Y+&aasU2J4#EOuNlnb9CmqgLCGTSY!1BD42pkHY^XidQ5=>YQx%` z*%Pm9D!CkBu&tMWm(%-ejACVWGS2RX5=QOJ$1*tr7F}F+*-OA+Ly&Isg|AEuUYicA z#%IG6kPXkHt{zk2M6zK@Vu^4Q(1zE$?yY6M!^&jQ+2^E?!p7{g*|X6}vuRC3p@jk0 W117c83?+LXEZI4G$p&LV25SKE>nb+@ literal 0 HcmV?d00001 diff --git a/images/sprite.png b/images/sprite.png new file mode 100644 index 0000000000000000000000000000000000000000..f0e95bafb34be5087fd04a316e0d36f2b0bfdf83 GIT binary patch literal 1668 zcmV-~27CF5P)I&VsFmYjG#Q317Kws0& z%zgaMIWBHHotZm*3>w18$rXCLN60DL(cV)n1~QrO7ZOTE%WP>+xPXH>}=Hl z@W(H|ZfkpH;rs?6B>*rpGvo?BGBYz03jnR;&0GDaFMJ&?Q!A3$^o{^K;WW(T8sdrA zqDLS8;k&PDM!vlUVho8VVv8Sn5yP2Cq0AV5eZW!a+ZHojYz zNQHwD?NlOd8#>P%d$TN4RS;2%D8L!Y+Pv{ki4KCKNI8Rw;+c zW@z8kT#hgjC}f6-U7Ts#YbR0wV2}VnN+DVBgm|kUn_vH+>#bKya#00AWY!D-2APSY z{(sZd-b0rGpr_}v)vKPKS|^7)GV3=Vsgl8sYa&|}2pJ_Q9=qo&Gu!H%v4YKp0Dz?+ zC5u-bMMB$i;NtFWE5~9Y2qO_eI1<;2xr+Z!b!tKjyN(x+&z!l^x^~6X$vS&vYsLi=lQ1OT*FmR6G?rFQ7_7pt3}tbz>-O+J1Ea&Eg@+b4xw%}Wrp|YFNvRDI z8~ST-#4}_9bUhP`Ddy=LlM|=j4e#@K$tXh%lIs~3#$ee#J#q3f0E9AR1_1(zr$AcQ zt|--P6!Clv0t`n2Bt(w-Fc=ZNf-98NUsk4-l08sGp+2>oL9sq#d&Z8e| zD=}?FpWT=)%M>DpLPlaj_S}MJ2n~9kArQWy#yL*Kj59~0}KrnmM&?Wovi!w=50HfoL`@;D)9RHIahn%scBE>aUBk)=cdB7 zl>(L`mC%NmNgK4Jlvb?n&%V31lL)a|kyK;D<*V0=57<+i?Ico7X#l7hVYqbldRTyM z$C=%j-oCG=YW#;MH`ZD`GypKToku^>Ix+p9O-FdgVhnt;GT&2L!2xN?GiEBiObAE1aYF-J0b5UwyNotBh zd1gt5LP$ocg1e`0!21-{JfK1wPZ!6Kid%PkHu5$Y2poCCt?`@Rvzg^2+mecnjH1)l zeL8vX`o}lX?hPzkr@4vbs5seroZ5e;P{{5<`b5^qGPaWnp*PbP0l+XkK D)n-AZ literal 0 HcmV?d00001 diff --git a/images/vert-slider-bg.png b/images/vert-slider-bg.png new file mode 100644 index 0000000000000000000000000000000000000000..6bb10f1ae422813e62746c2f6a70fdea2aea4bbc GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^fFVdQ&MBb@0RBfqVE_OC literal 0 HcmV?d00001 diff --git a/index.htm b/index.htm index ab8f098..3415ed5 100644 --- a/index.htm +++ b/index.htm @@ -1,10 +1,10 @@ - + - + diff --git a/json.htm b/json.htm new file mode 100644 index 0000000..d41ac04 --- /dev/null +++ b/json.htm @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + +
+ + + diff --git a/localize/pq-localize-en.js b/localize/pq-localize-en.js new file mode 100644 index 0000000..e7680a3 --- /dev/null +++ b/localize/pq-localize-en.js @@ -0,0 +1,25 @@ +/** + * @author pdhindsa + */ +jQuery.paramquery.pqGrid.regional['en'] = { + strAdd: "Add", + strDelete: "Delete", + strEdit: "Edit", + strLoading: "Loading", + strNextResult: "Next Result", + strNoRows: "No rows to display.", + strNothingFound: "Nothing found", + strPrevResult: "Previous Result", + strSearch: "Search", + strSelectedmatches: "Selected {0} of {1} match(es)" +}; +jQuery.paramquery.pqPager.regional['en']={ + strDisplay:"Displaying {0} to {1} of {2} items.", + strFirstPage:"First Page", + strLastPage:"Last Page", + strNextPage:"Next Page", + strPage:"Page {0} of {1}", + strPrevPage:"Previous Page", + strRefresh:"Refresh", + strRpp:"Records per page: {0}" +}; \ No newline at end of file diff --git a/localize/pq-localize-ja.js b/localize/pq-localize-ja.js index 3ad0ad4..d216634 100644 --- a/localize/pq-localize-ja.js +++ b/localize/pq-localize-ja.js @@ -1,24 +1,25 @@ -/** - * @author pdhindsa - */ -$.paramquery.pqGrid.regional['ja'] = { - strLoading: "読込中", - strAdd: "追加", - strEdit: "編集", - strDelete: "削除", - strSearch: "検索", - strNothingFound: "データが見つかりませんでした", - strSelectedmatches:"前の結果", - strPrevResult: "次の結果", - strNextResult: "データがありません" -} -$.paramquery.pqPager.regional['ja']={ - strPage:" {0} / {1} ページ", - strFirstPage:"先頭ページ", - strPrevPage:"前ページ", - strNextPage:"次ページ", - strLastPage:"最終ページ", - strRefresh:"再読み込み", - strRpp:"1ページの件数:", - strDisplay:"{2} 件中 {0}-{1}件" -} +/** + * @author pdhindsa + */ +$.paramquery.pqGrid.regional['ja'] = { + strLoading: "積載", + strAdd: "", + strEdit: "", + strDelete: "", + strSearch: "", + strNothingFound: "", + strSelectedmatches:"", + strPrevResult: "", + strNextResult: "", + strNoRows: "表示するには行ません." +}; +$.paramquery.pqPager.regional['ja']={ + strPage:"{1} の {0} ページ", + strFirstPage:"最初", + strPrevPage:"前", + strNextPage:"次", + strLastPage:"最後", + strRefresh:"リフレッシュ", + strRpp:"ページあたりのレコード: {0}", + strDisplay:"表示 {0} から {1} {2} 項目の" +}; diff --git a/localize/pq-localize-pl.js b/localize/pq-localize-pl.js new file mode 100644 index 0000000..e78061d --- /dev/null +++ b/localize/pq-localize-pl.js @@ -0,0 +1,26 @@ +/** + * @author bdwebdesign.pl + */ +jQuery.paramquery.pqGrid.regional['pl'] = { + strAdd: "Dodaj", + strDelete: "Usu?", + strEdit: "Edytuj", + strLoading: "?adowanie...", + strNextResult: "Nast?pny wynik", + strNoRows: "Brak wynikw do wy?wietlenia.", + strNothingFound: "Nic nie znaleziono", + strPrevResult: "Poprzedni wynik", + strSearch: "Szukaj", + strSelectedmatches: "Zaznaczone {0} z {1} pasuj?cych" +}; +jQuery.paramquery.pqPager.regional['pl'] = { + strDisplay: "Wy?wietlanie {0} do {1} z {2} elementw.", + strFirstPage: "Pierwsza strona", + strLastPage: "Ostatnia strona", + strNextPage: "Nast?pna strona", + strPage: "Strona {0} z {1}", + strPrevPage: "Poprzednia strona", + strRefresh: "Od?wie?", + strRpp: "Wierszy na stron?: {0}" +}; + diff --git a/localize/pq-localize-pt.js b/localize/pq-localize-pt.js new file mode 100644 index 0000000..2834f3e --- /dev/null +++ b/localize/pq-localize-pt.js @@ -0,0 +1,25 @@ +/** + * @author pdhindsa + */ +$.paramquery.pqGrid.regional['pt'] = { + strAdd: "Adicionar", + strDelete: "Excluir", + strEdit: "Editar", + strLoading: "Carregamento", + strNextResult: "Próximo resultado", + strNoRows: "Não há linhas para mostrar.", + strNothingFound: "Nada foi encontrado", + strPrevResult: "Resultado anterior", + strSearch: "Pesquisar", + strSelectedmatches: "Selecionado {0} de {1} match (es)" +}; +$.paramquery.pqPager.regional['pt'] = { + strDisplay:"Exibindo {0} para {1} de {2} itens.", + strFirstPage:"Primeira Página", + strLastPage:"Última Página", + strNextPage:"Página Seguinte", + strPage:"Página {0} de {1}", + strPrevPage:"Página Anterior", + strRefresh:"Refrescar", + strRpp:"Registros por página: {0}" +}; diff --git a/localize/pq-localize-tr.js b/localize/pq-localize-tr.js new file mode 100644 index 0000000..9ea18e4 --- /dev/null +++ b/localize/pq-localize-tr.js @@ -0,0 +1,25 @@ +/* + * @author Brkhn + */ +$.paramquery.pqGrid.regional['tr'] = { + strLoading: "Yükleniyor", + strNoRows: "Gösterilecek Satır Yok.", + strAdd: "Ekle", + strEdit: "Düzenle", + strDelete: "Sil", + strSearch: "Ara", + strNothingFound: "Sonuç Bunulamadı", + strSelectedmatches: "{0} seçilen arasında {1} eşleşen", + strPrevResult: "Önceki Kayıt", + strNextResult: "Sonraki Kayıt" +}; +$.paramquery.pqPager.regional['tr'] = { + strPage: "{1} Sayfadan {0} gösteriliyor", + strFirstPage: "İlk Sayfa", + strPrevPage: "Önceki Sayfa", + strNextPage: "Sonraki Sayfa", + strLastPage: "Son Sayfa", + strRefresh: "Yenile", + strRpp: "Gösterilecek Kayıt: {0}", + strDisplay: "{2} Kayıttan {0} ile {1} arası görüntüleniyor." +}; \ No newline at end of file diff --git a/pqGridCrud.js b/pqGridCrud.js deleted file mode 100644 index 96fb77c..0000000 --- a/pqGridCrud.js +++ /dev/null @@ -1,175 +0,0 @@ -/** -* Copyright 2012-2013, Paramvir Dhindsa -* Released under GPL license -* http://www.paramquery.com/license -* Last Modified: Dec 10, 2013 -*/ -$(function () { - var fn = {}; - fn.options = {}; - fn._create = function () { - var that = this; - - $(this.element).on("pqgridcrudload", function (evt, ui) { - //debugger; - that._onLoad(); - }); - //set getUrl to default - this._setUrl(); - - this._super.apply(this); - - //this.colModel is available after call to parent _create. - var colModel = this.colModel; - - this.pqGridCrud = {}; //to store instance variables - - var strPopup = ""; - this.$crudPopup = $(strPopup).appendTo(document); - this.$crudForm = this.$crudPopup.find("form"); - //create popup dialog. - this.$crudPopup.dialog({ width: 440, modal: true, - open: function () { $(".ui-dialog").position({ of: this.element }); }, - autoOpen: false - }); - //create toolbar - var $toolbar = $("
").appendTo($(".pq-grid-top", this.element)); - - $("Add").appendTo($toolbar).button({ icons: { primary: "ui-icon-circle-plus"} }).click(function (evt) { - that.addRow(); - }); - $("Edit").appendTo($toolbar).button({ icons: { primary: "ui-icon-pencil"} }).click(function (evt) { - that.editRow(); - }); - $("Delete").appendTo($toolbar).button({ icons: { primary: "ui-icon-circle-minus"} }).click(function () { - that.deleteRow(); - }); - $toolbar.disableSelection(); - //debugger; - this.refresh(); //to update the DOM - } - fn._setUrl = function (queryStr) { - this.options.dataModel.getUrl = function () { - //debugger; - return { url: this.url + ((queryStr != null) ? queryStr : "") }; - } - } - fn._getRowIndx = function () { - var arr = this.selection({ type: 'row', method: 'getSelection' }); - if (arr && arr.length > 0) { - var rowIndx = arr[0].rowIndx; - return rowIndx; - } - else { - alert("Select a row."); - return null; - } - } - - fn.addRow = function () { - var DM = this.options.dataModel, - data = DM.data, - that = this; - - var $frm = this.$crudForm; - $frm.find("input").val(""); - - this.$crudPopup.dialog({ title: "Add Record", buttons: { - Add: function () { - var serializedData = $frm.serialize(); - that._setUrl("?" + serializedData); - that.refreshDataAndView(); - $(this).dialog("close"); - }, - Cancel: function () { - $(this).dialog("close"); - } - } - }); - this.$crudPopup.dialog("open"); - } - fn.editRow = function () { - var rowIndx = this._getRowIndx(); - if (rowIndx != null) { - //debugger; - //this.pqGridCrud.rowIndx = rowIndx; - var that = this, - DM = this.options.dataModel, - data = DM.data, - colModel = this.colModel, - rowData = data[rowIndx]; - //this.pqGridCrud.recId = data[rowIndx][0]; - - var $frm = this.$crudForm; - $frm.find("input[name='recId']").val(rowData['recId']); - for(var i=0;i td{ + border-bottom:1px solid #333; +} +.pq-grid tr.pq-detail-master > td{ + border-bottom-width:0px; +} +.pq-grid td.pq-detail-child{ + padding:3px 30px; +} +div.pq-grid-disable{ + height:100%;width:100%;position:absolute;left:0px;top:0px;background:#ccc; + z-index:3; +} +div.pq-loading{ + height:100%;width:100%;position:absolute;left:0px;top:0px; + display:none; +} +div.pq-loading div.pq-loading-bg{ + background:#ccc; + height:100%;width:100%;position:absolute;left:0px;top:0px; + z-index:10; +} +div.pq-loading-mask{ + width:100px;height:25px; + z-index:6; + padding:5px; + position:absolute;left:50%;top:50%; + margin-left:-50px; + margin-top:-13px; +} +.pq-grid div.pq-loading-mask div{ + padding-top:0px; + padding-right:6px; + padding-left:29px; + line-height:23px; + background-image:url("images/loading.gif"); + background-position:6px center; + background-repeat:no-repeat; +} +div.pq-vscroll{ + height:150px; + position:absolute; + right:0px; + bottom:17px; + z-index:4; +} +div.pq-hscroll{ + height:17px; + border:0px solid blue; + position:absolute; + right:17px; + bottom:0px; + z-index:4; +} +div.pq-hvscroll-square{ + height:17px; + width:17px; + border:0px solid blue; + position:absolute; + right:0px; + bottom:0px; +} +.pq-tree-icon-container{ + position:relative;float:left;height:16px; +} +.pq-tree-icon{ + cursor:pointer;position:absolute;width:18px;height:16px;right:0px;top:-2px; +} +tr.pq-grid-row-hover td +{ +} +tr.pq-row-select{ +} +tr.pq-row-select td +{ +} +div.pq-grid tr td.pq-grid-cell-hover +{ + border-width:0px; +} +tr td.pq-grid-number-cell +{ +} +div.pq-grid tr td.pq-cell-select +{ + border-top-width:0px; + border-left-width:0px; +} +span.ui-sortable-placeholder{ +} +tr.pq-group-row{ + cursor:pointer; +} +tr.pq-group-row td.pq-grid-cell{ +} +tr.pq-group-row td span{ + float:left;margin-top:-2px;margin-right:3px; +} +.pq-pager{ + padding:2px 5px 13px; + overflow:hidden; + vertical-align:middle; +} +.pq-pager *{ + vertical-align:middle; +} +.pq-grid span.pq-separator{ + height:18px; + border-left:1px solid #ccc; + display:inline-block; +} +.pq-pager input{ + padding:0px 1px; + text-align:center; + width:35px; + margin-right:5px; + height:16px; + border-width:1px; +} +div.pq-pager span,div.pq-pager select{ + margin-right:5px; + border-width:1px; +} +.pq-pager .pq-page-placeholder{ + vertical-align:top; + margin-right:0px; +} +.pq-grid button.ui-button-icon-only{ + width:22px; + margin-right:5px; + padding:0.4em 0em; +} +.pq-sb-vert-wt{ + display:block; + width:17px; + background:#efefef url(images/vert-bg.png); +} +.pq-sb-horiz-wt{ + display:block; + height:17px; + background:#efefef url(images/horiz-bg.png); +} +.pq-sb-vert-wt *{ + padding:0px; + margin:0px; +} +.pq-sb-horiz-wt *{ + padding:0px; + margin:0px; +} +.pq-sb-btn{ + width:17px; + height:17px; + position:absolute; +} +.pq-sb-vert-wt div.top-btn{ + left:0px; + top:0px; + background:url(images/sprite.png); +} +.pq-sb-horiz-wt div.left-btn{ + left:0px; + top:0px; + background:url(images/sprite.png) -34px; +} +.pq-sb-vert-wt div.bottom-btn{ + left:0px; + bottom:0px; + background:url(images/sprite.png) -17px; +} +.pq-sb-horiz-wt div.right-btn{ + top:0px; + right:0px; + background:url(images/sprite.png) -51px; +} +.pq-sb-slider{ + position:absolute; +} +.pq-sb-vert-wt .pq-sb-slider *{ + background:url(images/sprite.png); +} +.pq-sb-slider-h{ + position:absolute; +} +.pq-sb-horiz-wt .pq-sb-slider-h *{ + display:inline-block; + background:url(images/sprite.png); +} +.pq-sb-slider .vert-slider-top{ + width:17px; + height:3px; + overflow:hidden; + background-position: 17px -8px; +} +.pq-sb-slider-h .horiz-slider-left{ + height:17px; + width:3px; + overflow:hidden; + background-position: -68px 0px; +} +.pq-sb-vert-wt .pq-sb-slider .vert-slider-bg{ + width:17px; + overflow:hidden; + background:#B6CEFB url(images/vert-slider-bg.png); +} +.pq-sb-horiz-wt .pq-sb-slider-h .horiz-slider-bg{ + height:17px; + overflow:hidden; + background:#B6CEFB url(images/horiz-slider-bg.png); +} +.pq-sb-slider .vert-slider-center{ + width:17px; + height:8px; + overflow:hidden; + background-position: 17px 0px; +} +.pq-sb-slider-h .horiz-slider-center{ + height:17px; + width:8px; + overflow:hidden; + background-position: -74px 0px; +} +.pq-sb-slider .vert-slider-bottom{ + width:17px; + height:3px; + overflow:hidden; + background-position: 17px -11px; +} +.pq-sb-slider-h .horiz-slider-right{ + height:17px; + width:3px; + overflow:hidden; + background-position: -71px 0px; +} +.pq-sb-vert-t{ + display:block; + width:17px; + background:#efefef url(images/vert-bg.png); +} +.pq-sb-horiz-t{ + display:block; + height:17px; + background:#efefef url(images/horiz-bg.png); +} +.pq-sb-vert-t *{ + padding:0px; + margin:0px; +} +.pq-sb-horiz-t *{ + padding:0px; + margin:0px; +} +.pq-sb-vert-t .pq-sb-btn{ + width:15px; + height:15px; + position:absolute; +} +.pq-sb-horiz-t .pq-sb-btn{ + width:15px; + height:15px; +} +.pq-sb-vert-t div.top-btn{ + left:0px; + top:0px; +} +.pq-sb-horiz-t div.left-btn{ + left:0px; + top:0px; +} +.pq-sb-horiz-t div.left-btn .ui-icon{ + margin-top:-1px; +} +.pq-sb-vert-t div.bottom-btn{ + left:0px; + bottom:0px; +} +.pq-sb-vert-t div.bottom-btn .ui-icon{ + margin-left:-1px; +} +.pq-sb-horiz-t div.right-btn{ + top:0px; + right:0px; +} +.pq-sb-horiz-t div.right-btn .ui-icon{ + margin-top:-1px; + margin-left:-1px; +} +.pq-sb-vert-t .pq-sb-slider{ + position:absolute; + width:13px; + left:1px; +} +.pq-sb-horiz-t .pq-sb-slider-h{ + position:absolute; + top:1px; + height:13px; +} +.pq-arrow-up{ + position:absolute;z-index:200; +} +.pq-arrow-down{ + position:absolute;z-index:200; +} +div.pq-grid div.pq-g-ficon{ + position:absolute; + top:0px; + width:16px; + cursor:pointer; + border-width:0px; + vertical-align:middle; +} +.pq-g-ficon-shadow{ + -moz-box-shadow: 0px 3px 8px rgba(0,0,0,0.5); + -webkit-box-shadow: 0px 3px 8px rgba(0,0,0,0.5); + box-shadow: 0px 3px 8px rgba(0,0,0,0.5); +} +div.pq-g-ficon .ui-icon{ + position: absolute; + height:16px; + top:50%; + margin-top:-8px; +} +div.pq-filter-dialog{ + padding:1px 5px 4px 3px; + -moz-box-shadow: 0 4px 8px rgba(0,0,0,0.5); + -webkit-box-shadow: 0 4px 8px rgba(0,0,0,0.5); + box-shadow: 0 4px 8px rgba(0,0,0,0.5); +} +div.pq-filter-dialog input{ + padding:0px 4px; + border-width:1px; + line-height: 16px; +} +div.pq-filter-dialog button.ui-button span{ + padding:0px 2px; +} +div.pq-filter-dialog *{ + margin:2px 4px; +} \ No newline at end of file diff --git a/pqgrid.dev.js b/pqgrid.dev.js index e2934c3..34e95dc 100644 --- a/pqgrid.dev.js +++ b/pqgrid.dev.js @@ -1,4204 +1,12056 @@ -/** - * ParamQuery Grid a.k.a. pqGrid v1.1.3 - * - * Copyright (c) 2012-2015 Paramvir Dhindsa - * Released under GPL v3 license - * http://paramquery.com/license - * - */ -(function($){ - "use strict"; - $.paramquery=($.paramquery==null)?{}:$.paramquery; - $.paramquery.xmlToArray=function(data,obj){ - var itemParent=obj.itemParent; - var itemNames=obj.itemNames; - var arr=[]; - var $items=$(data).find(itemParent); - $items.each(function(i,item){ - var $item=$(item); - var arr2=[]; - $(itemNames).each(function(j,itemName){ - arr2.push($item.find(itemName).text()); - }); - arr.push(arr2); - }); - return arr; - }; - $.paramquery.tableToArray=function(tbl){ - var $tbl=$(tbl); - var colModel=[]; - var data=[]; - var cols=[]; - var widths=[]; - var $trfirst=$tbl.find("tr:first"); - var $trsecond=$tbl.find("tr:eq(1)"); - $trfirst.find("th,td").each(function(i,td){ - var $td=$(td); - var title=$td.html(); - var width=$td.width(); - var dataType="string"; - var $tdsec=$trsecond.find("td:eq("+i+")"); - var val=$tdsec.text(); - var align=$tdsec.attr("align"); - val=val.replace(/,/g,""); - if(parseInt(val)==val && (parseInt(val)+"").length == val.length){ - dataType="integer"; - } - else if(parseFloat(val)==val ){ - dataType="float"; - } - var obj={title:title,width:width,dataType:dataType,align:align,dataIndx:i}; - colModel.push(obj); - }); - $tbl.find("tr").each(function(i,tr){ - if(i==0)return; - var $tr=$(tr); - var arr2=[]; - $tr.find("td").each(function(j,td){ - arr2.push($.trim($(td).html())); - }); - data.push(arr2); - }); - return {data:data,colModel:colModel}; - }; - $.paramquery.formatCurrency=function(val) { - val = Math.round(val * 10) / 10; - val = val + ""; - if (val.indexOf(".") == -1) { - val = val + ".0"; - } - var len = val.length; - var fp=val.substring(0,len-2), - lp=val.substring(len-2,len), - arr=fp.match(/\d/g).reverse(), - arr2=[]; - for(var i=0;i0 && i%3==0){ - arr2.push(","); - } - arr2.push(arr[i]); - } - arr2=arr2.reverse(); - fp=arr2.join(""); - return fp+lp; - }; -})(jQuery); -/** - * ParamQuery Pager a.k.a. pqPager - */ -(function($){ - "use strict"; -var fnPG={}; -fnPG.options={ - currentPage:0, - totalPages:0, - totalRecords:0, - msg:"", - rPPOptions:[10,20,30,40,50,100], - rPP:20 -}; -fnPG._regional={ - strPage:"Page {0} of {1}", - strFirstPage:"First Page", - strPrevPage:"Previous Page", - strNextPage:"Next Page", - strLastPage:"Last Page", - strRefresh:"Refresh", - strRpp:"Records per page:", - strDisplay:"Displaying {0} to {1} of {2} items." -}; -$.extend(fnPG.options,fnPG._regional); -fnPG._create=function(){ - var that=this, - thisOptions=this.options; - this.element.addClass("pq-pager").css({}); - this.first = $( "", { - }) - .appendTo( this.element ) - .button({ - icons: { - primary:"pq-page-first" - },text:false - }).bind("click.paramquery",function(evt){ - if(that.options.currentPage>1){ - if ( that._trigger( "change", evt, { - curPage: 1 - } ) !== false ) { - that.option( {currentPage:1} ); - } - } - }); - this.prev=$( "") - .appendTo( this.element ) - .button({icons:{primary:"pq-page-prev"},text:false}).bind("click",function(evt){ - if(that.options.currentPage>1){ - var currentPage=that.options.currentPage-1; - if ( that._trigger( "change", evt,{ - curPage: currentPage - } ) !== false ) { - that.option( {currentPage:currentPage} ); - } - } - }); - $("").appendTo(this.element); - this.pagePlaceHolder=$("") - .appendTo(this.element); - $("").appendTo(this.element); - this.next=$( "") - .appendTo( this.element ) - .button({icons:{primary:"pq-page-next"},text:false}).bind("click",function(evt){ - var val=that.options.currentPage+1; - if ( that._trigger( "change", evt, {curPage: val} ) !== false ) { - that.option( {currentPage:val} ); - } - }); - this.last=$( "") - .appendTo( this.element ) - .button({icons:{primary:"pq-page-last"},text:false}).bind("click",function(evt){ - var val=that.options.totalPages; - if ( that._trigger( "change", evt, {curPage: val} ) !== false ) { - that.option( {currentPage:val} ); - } - }); - $("").appendTo(this.element); - this.$strRpp = $(""+this.options.strRpp+" ") - .appendTo(this.element); - this.$rPP=$("") - .appendTo(this.element) - .change(function(evt){ - var val=$(this).val(); - if (that._trigger("change", evt,{rPP: val}) !== false) { - that.options.rPP=val; - } - }); - $("").appendTo(this.element); - this.$refresh=$("") - .appendTo(this.element) - .button({icons:{primary:"pq-refresh"},text:false}).bind("click",function(evt){ - if ( that._trigger( "refresh", evt ) !== false ) { - } - }); - $("").appendTo(this.element); - this.$msg=$("") - .appendTo( this.element ); - this._refresh(); -}; -fnPG._refreshPage=function(){ - var that=this; - this.pagePlaceHolder.empty(); - var strPage=this.options.strPage; - var arr=strPage.split(" "); - var str=""; - $(arr).each(function(i,ele){ - str+=""+ele+""; - }); - strPage=str.replace("{0}",""); - strPage=strPage.replace("{1}", ""); - var $temp=$( strPage ).appendTo(this.pagePlaceHolder); - this.page=$( "") - .replaceAll("span.textbox", $temp) - .bind("change",function(evt){ - var $this=$(this); - var val=$this.val(); - if(isNaN(val)||val<1){ - $this.val(that.options.currentPage); - return false; - } - val=parseInt(val); - if(val>that.options.totalPages){ - $this.val(that.options.currentPage); - return false; - } - if ( that._trigger( "change", evt, { - curPage: val - }) !== false ) { - that.option( {currentPage:val} ); - } - else{ - $this.val(that.options.currentPage); - return false; - } - }); - this.$total=$temp.filter("span.total"); -}; -fnPG._refresh=function(){ - this._refreshPage(); - var sel=(this.$rPP); - var thisOptions=this.options; - this.$strRpp.text(thisOptions.strRpp); - this.first.attr("title",thisOptions.strFirstPage); - this.prev.attr("title",thisOptions.strPrevPage); - this.next.attr("title",thisOptions.strNextPage); - this.last.attr("title",thisOptions.strLastPage); - this.$refresh.attr("title",thisOptions.strRefresh); - sel.empty(); - var opts = this.options.rPPOptions; - for(var i=0;i=this.options.totalPages){ - this.next.button({disabled:true}); - this.last.button({disabled:true}); - } - else{ - this.next.button({disabled:false}); - this.last.button({disabled:false}); - } - if(this.options.currentPage<=1){ - this.first.button({disabled:true}); - this.prev.button({disabled:true}); - } - else{ - this.first.button({disabled:false}); - this.prev.button({disabled:false}); - } - this.page.val(this.options.currentPage); - this.$total.text(this.options.totalPages); - if(this.options.totalRecords>0){ - var rPP = this.options.rPP; - var currentPage = this.options.currentPage; - var totalRecords = this.options.totalRecords; - var begIndx = (currentPage-1)*rPP; - var endIndx = currentPage*rPP; - if(endIndx>totalRecords){ - endIndx = totalRecords; - } - var strDisplay=this.options.strDisplay; - strDisplay=strDisplay.replace("{0}",begIndx+1); - strDisplay=strDisplay.replace("{1}",endIndx); - strDisplay=strDisplay.replace("{2}",totalRecords); - this.$msg.html(strDisplay); - } - else{ - this.$msg.html(""); - } -}; -fnPG._destroy=function(){ - this.element.empty().removeClass("pq-pager").enableSelection(); -}; -fnPG._setOption=function(key,value){ - if(key=="currentPage"||key=="totalPages")value=parseInt(value); - $.Widget.prototype._setOption.call( this, key, value ); -}; -fnPG._setOptions=function(){ - $.Widget.prototype._setOptions.apply( this, arguments ); - this._refresh(); -}; - $.widget("paramquery.pqPager",fnPG); - $.paramquery.pqPager.regional={}; - $.paramquery.pqPager.regional['en']=fnPG._regional; - $.paramquery.pqPager.setDefaults=function(obj){ - for(var key in obj){ - fnPG.options[key]=obj[key]; - } - $.widget("paramquery.pqPager",fnPG); - $(".pq-pager").each(function(i,pager){ - $(pager).pqPager("option",obj); - }); - }; -})(jQuery); -/** - * ParamQuery Scrollbar a.k.a. pqScrollBar - */ -(function($){ - "use strict"; -var fnSB={}; -fnSB.options={ - length:200, - num_eles:3, - cur_pos:0, - timeout:350, - pace:'optimum', - direction:'vertical' -}; -fnSB._destroy=function(){ - this.element.removeClass("pq-scrollbar-vert").enableSelection().removeClass("pq-scrollbar-horiz").unbind('click.pq-scrollbar').empty(); - this.element.removeData(); -}; -fnSB._create=function(){ - this.length=this.options.length; - this.direction=this.options.direction; - this.num_eles=this.options.num_eles; - var that=this; - var ele=this.element.empty(); - if(this.direction=="vertical"){ - ele.addClass("pq-scrollbar-vert"); - ele.html("
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
"); - } - else{ - ele.addClass("pq-scrollbar-horiz"); - ele.width(this.width); - ele.html("
\ -
\ - \ -
\ -
"); - } - this.element.disableSelection().bind('click.pq-scrollbar',function(evt){ - if(that.options.disabled)return; - if(that.$slider.is(":hidden"))return; - if(that.direction=="vertical"){ - var clickY=evt.pageY; - var top_this=that.element.offset().top; - var bottom_this=top_this+that.length; - var topSlider= that.$slider.offset().top; - var botSlider=topSlider+ that.$slider.height(); - if(clickYtop_this+17 ){ - var new_top = clickY-top_this; - that.$slider.css("top",new_top); - that._updateCurPosAndTrigger(evt); - } - else if(clickY>botSlider && clickYbotSlider){ - that.$slider.css("left",top-that.element.offset().left-that.$slider.width()); - that._updateCurPosAndTrigger(evt); - } - } - }); - var axis='x'; - if(this.direction=="vertical")axis='y'; - this.$slider = $("div.pq-sb-slider",this.element).draggable({axis:axis, - helper: function(evt, ui){ - that._setDragLimits(); - return this; - }, - start:function(evt){ - that.topWhileDrag=null; - }, - drag:function(evt){ - that.dragging=true; - var pace=that.options.pace; - if(pace=="optimum") - that._setNormalPace(evt); - else if(pace=="fast") - that._updateCurPosAndTrigger(evt); - }, - stop:function(evt){ - that._updateCurPosAndTrigger(evt); - that.dragging=false; - that._refresh(); - } - }); - function decr_cur_pos(evt){ - if (that.options.cur_pos > 0) { - that.options.cur_pos--; - that.updateSliderPos(); - that.scroll(evt); - } - } - this.$top_btn = $("div.top-btn,div.left-btn",this.element).click(function(evt){ - if(that.options.disabled)return; - decr_cur_pos(evt); - evt.preventDefault(); - return false; - }).mousedown(function(evt){ - if(that.options.disabled)return; - that.mousedownTimeout=window.setTimeout(function(){ - that.mousedownInterval = window.setInterval(function(){ - decr_cur_pos(evt) - },50); - },that.options.timeout) - }).bind('mouseup mouseout',function(evt){ - if(that.options.disabled)return; - that._mouseup(evt); - }); - function incr_cur_pos(evt){ - if (that.options.cur_pos < that.num_eles - 1) { - that.options.cur_pos++; - } - that.updateSliderPos(); - that.scroll(evt); - } - this.$bottom_btn = $("div.bottom-btn,div.right-btn",this.element).click(function(evt){ - if(that.options.disabled)return; - incr_cur_pos(evt); - evt.preventDefault(); - return false; - }).mousedown(function(evt){ - if(that.options.disabled)return; - that.mousedownTimeout=window.setTimeout(function(){ - that.mousedownInterval = window.setInterval(function(){ - incr_cur_pos(evt) - },50); - },that.options.timeout) - }).bind('mouseup mouseout',function(evt){ - if(that.options.disabled)return; - that._mouseup(evt); - }); - this._refresh(); -} -fnSB._mouseup=function(evt){ - if(this.options.disabled)return; - var that=this; - window.clearTimeout(that.mousedownTimeout); - that.mousedownTimeout=null; - window.clearInterval(that.mousedownInterval); - that.mousedownInterval=null; -} -fnSB._setDragLimits=function(){ - if (this.direction == "vertical") { - var top = this.element.offset().top+17; - var bot = (top + this.length - 34 - this.slider_length); - this.$slider.draggable("option","containment",[0,top,0,bot]); - } - else{ - var top = this.element.offset().left+17; - var bot = (top + this.length - 34 - this.slider_length); - this.$slider.draggable("option","containment",[top,0,bot,0]); - } -} -fnSB._refresh=function(){ - if(this.options.num_eles<=1){ - this.element.css("display","none"); - } - else{ - this.element.css("display",""); - } - this.num_eles=this.options.num_eles; - this.length=this.options.length; - this._validateCurPos(); - this.$slider.css("display",""); - if(this.direction=="vertical"){ - this.element.height(this.length); - this._setSliderBgLength(); - this.scroll_space =this.length-34-this.slider_length; - if(this.scroll_space<4 ||this.num_eles<=1){ - this.$slider.css("display","none"); - } - this.updateSliderPos(this.options.cur_pos); - } - else{ - this.element.width(this.length); - this._setSliderBgLength(); - this.scroll_space =this.length-34-this.slider_length; - if(this.scroll_space<4 ||this.num_eles<=1){ - this.$slider.css("display","none"); - } - this.updateSliderPos(this.options.cur_pos); - } -} -fnSB._setSliderBgLength=function(){ - var outerHeight=this.length; - var innerHeight=this.num_eles*40+outerHeight; - var avail_space = outerHeight-34; - var slider_height = avail_space* outerHeight/innerHeight; - var slider_bg_ht=Math.round((slider_height-(8+3+3))/2); - if(slider_bg_ht<1){ - slider_bg_ht=1 - } - this.slider_length=8+3+3+2*slider_bg_ht; - if(this.direction=="vertical"){ - $("div.vert-slider-bg",this.element).height(slider_bg_ht); - this.$slider.height(this.slider_length); - } - else{ - $(".horiz-slider-bg",this.element).width(slider_bg_ht); - this.$slider.width(this.slider_length); - } -} -fnSB._updateCurPosAndTrigger = function(evt,top){ - var that=this; - var $slider=that.$slider; - if(top==null){ - top=(that.direction=="vertical")?parseInt($slider[0].style.top):parseInt($slider[0].style.left); - } - var scroll_space =that.length-34-((that.direction=="vertical")?$slider[0].offsetHeight:$slider[0].offsetWidth); - var cur_pos = (top-17)*(that.num_eles-1)/scroll_space; - cur_pos=Math.round(cur_pos); - if(that.options.cur_pos!=cur_pos){ - if(this.dragging){ - if(this.topWhileDrag!=null){ - if(this.topWhileDrag < top && that.options.cur_pos>cur_pos){ - return; - } - else if(this.topWhileDrag > top && that.options.cur_pos=this.num_eles){ - this.options.cur_pos=this.num_eles-1; - } - if(this.options.cur_pos<0){ - this.options.cur_pos=0; - } -} -fnSB.updateSliderPos=function(){ - var sT=(this.scroll_space*(this.options.cur_pos))/(this.num_eles-1); - if(this.direction=="vertical") - this.$slider.css("top",17+sT); - else - this.$slider.css("left",17+sT); -} -fnSB.scroll=function(evt){ - var thisOptions=this.options; - this._trigger("scroll",evt, {cur_pos: thisOptions.cur_pos, num_eles: thisOptions.num_eles}); -} -fnSB._setOption=function(key,value){ - if(key=="disabled"){ - if(value==true) - this.$slider.draggable("disable"); - else - this.$slider.draggable("enable"); - } - $.Widget.prototype._setOption.call( this, key, value ); -} -fnSB._setOptions=function(){ - $.Widget.prototype._setOptions.apply( this, arguments ); - this._refresh(); -} - $.widget("paramquery.pqScrollBar",fnSB); -})(jQuery); -/** - * ParamQuery Grid a.k.a. pqGrid*/ -(function($) { - "use strict"; - var cCreateTable = function(that) { - this.that = that; - }; - var _pG = cCreateTable.prototype; - _pG._generateTables = function(objP) { - var that = this.that, - thisColModel = that.colModel, - noColumns = thisColModel.length, - thisOptions = that.options, - columnBorders = thisOptions.columnBorders, - rowBorders = thisOptions.rowBorders, - SM = thisOptions.scrollModel, - outerWidths = that.outerWidths; - that._bufferObj_calcInitFinal(); - var row = (objP) ? 0 : that.init, - finalRow = (objP) ? objP.data.length - 1 : that["final"], - data = (objP && objP.data) ? objP.data : that.data, - offset = that.getRowIndxOffset(); - if (!objP && (row == null || finalRow == null)) { - that.$cont.empty(); - that.$tbl = null; - return; - } - if (!objP) { - that._trigger("beforeTableView", null, { - data: that.data, - curPos: row, - finalPos: finalRow, - curPage: that.dataModel.curPage - }); - } - var const_cls = "pq-grid-cell "; - if (!thisOptions.wrap || objP) - const_cls += "pq-wrap-text "; - var tblClass = 'pq-grid-table '; - if (columnBorders) - tblClass += "pq-grid-td-border-right "; - if (rowBorders) - tblClass += "pq-grid-td-border-bottom "; - var buffer = [""]; - var hidearrHS1 = []; - if (1 == 1) - { - buffer.push(""); - if (that.numberCell) { - var wd = that.numberCellWidth + 1; - buffer.push(""); - } - for (var col = 0; col < noColumns; col++) { - var column = thisColModel[col]; - if (column.hidden) { - continue; - } else if (that.hidearrHS[col]) { - hidearrHS1.push(col); - continue; - } - var wd = outerWidths[col]; - buffer.push(""); - } - for (var k = 0; k < hidearrHS1.length; k++) { - var col = hidearrHS1[k]; - var column = thisColModel[col]; - var wd = outerWidths[col]; - buffer.push(""); - } - buffer.push(""); - } - this.offsetRow = null; - do { - var rowObj = data[row], - rowData = rowObj, - rowIndx = row, - hidden = rowData.hidden, - row_str = ""; - if (hidden) { - if (row == finalRow) { - break; - } - row++; - continue; - } - if (this.offsetRow == null && rowIndx != null) { - this.offsetRow = (row - rowIndx); - } - this._generateRow(rowData, rowIndx, thisColModel, noColumns, hidearrHS1, offset, const_cls, buffer, objP); - if (SM.scrollTillLastRow) { - } - else { - if (row == finalRow) { - break; - } - row++; - } - } - while (1 == 1); - that.scrollMode = false; - if (!SM.scrollTillLastRow) { - $.measureTime(function() { - buffer.push("
"); - var str = buffer.join(""); - if (objP) { - objP.$cont.empty(); - var $tbl = $(str); - objP.$cont.append($tbl); - if (!that.tables) - that.tables = []; - var indx = -1; - for (var l = 0; l < that.tables.length; l++) { - var cont = that.tables[l].cont; - if (cont == objP.$cont[0]) { - indx = l; - } - } - if (indx == -1) { - that.tables.push({$tbl: $tbl, cont: objP.$cont[0]}); - } - else { - that.tables[indx].$tbl = $tbl; - } - } - else { - if (that.$tbl == undefined) { - that.$tbl = $(str); - that.$cont.append(that.$tbl); - } else { - if (that.$td_edit != null) { - that.quitEditMode(); - } - that.$cont.empty(); - that.$tbl = $(str); - that.$cont.append(that.$tbl); - } - } - }, 'append stuff inside _generateTable'); - } - if (!objP) - window.setTimeout(function() { - that._fixTableViewPort(); - that._trigger("refresh", null, { - dataModel: that.dataModel, - data: that.data, - initV: that.init, - initH: that.initH - }); - }, 0); - }; - _pG._renderCell = function(objP) { - var that = this.that, - rowIndxPage = objP.rowIndxPage, - rowIndx = objP.rowIndx, - rowData = objP.rowData, - colIndx = objP.colIndx, - $td = objP.$td, - column = objP.column, - dataIndx = column.dataIndx, - wrap = objP.wrap, - customData = objP.customData; - var dataCell; - if (column.render) { - dataCell = column.render({ - data: that.data, - dataModel: that.dataModel, - rowData: rowData, - rowIndxPage: rowIndxPage, - rowIndx: rowIndx, - colIndx: colIndx, - column: column, - dataIndx: dataIndx, - customData: customData - }); - } - else { - dataCell = rowData[dataIndx]; - } - if (dataCell === "" || dataCell == undefined) - dataCell = " "; - var cls = "pq-td-div"; - if (wrap == false) - cls += " pq-wrap-text"; - var str = "
" + dataCell + "
"; - if ($td != undefined) { - $td.html(str); - } - return str; - } - _pG._generateRow = function(rowData, rowIndx, thisColModel, noColumns, hidearrHS1, offset, const_cls, buffer, objP) { - var row_cls = "pq-grid-row"; - var that = this.that, - thisOptions = that.options, - columnBorders = thisOptions.columnBorders, - wrap = thisOptions.wrap, - customData = thisOptions.customData; - var objRender = {rowIndx: rowIndx + offset, rowIndxPage: rowIndx, rowData: rowData, wrap: wrap, customData: customData}; - if (thisOptions.oddRowsHighlight && (rowIndx / 2 == parseInt(rowIndx / 2))) - row_cls += " pq-grid-oddRow"; - if (rowData.selectedRow) { - row_cls += " pq-row-select ui-state-highlight"; - } - buffer.push(""); - if (that.numberCell) { - buffer.push("\ -
" + ((objP) ? " " : (rowIndx + 1)) + "
"); - } - for (var col = 0; col < noColumns; col++) { - var column = thisColModel[col], - dataIndx = column.dataIndx; - objRender.column = column; - objRender.colIndx = col; - var cellSelection = false; - { - var selectedDataIndices = rowData.selectedDataIndices; - if (selectedDataIndices) { - cellSelection = selectedDataIndices[dataIndx]; - } - } - if (column.hidden) { - continue; - } - else if (that.hidearrHS[col]) { - continue; - } - var strStyle = ""; - var cls = const_cls; - if (column.align == "right") { - cls += ' pq-align-right'; - } else if (column.align == "center") { - cls += ' pq-align-center'; - } - if (col == that.freezeCols - 1 && columnBorders) { - cls += " pq-last-freeze-col"; - } - if (column.className) { - cls = cls + " " + column.className; - } - if (cellSelection) { - cls = cls + " pq-cell-select ui-state-highlight"; - } - var indxStr = "pq-col-indx='" + col + "'"; - if (objP) { - indxStr += " pq-dataIndx='" + dataIndx + "'"; - } - var str = "\ - " + this._renderCell(objRender) + ""; - buffer.push(str) - } - for (var k = 0; k < hidearrHS1.length; k++) { - var col = hidearrHS1[k]; - var column = thisColModel[col], - dataIndx = column.dataIndx; - objRender.column = column; - objRender.colIndx = col; - var strStyle = ""; - strStyle += "visibility:hidden;"; - var cls = const_cls; - if (column.align == "right") { - cls += ' pq-align-right'; - } else if (column.align == "center") { - cls += ' pq-align-center'; - } - var indxStr = "pq-col-indx='" + col + "'"; - if (objP) { - indxStr += " pq-dataIndx='" + dataIndx + "'"; - } - var str = "\ - " + this._renderCell(objRender) + ""; - buffer.push(str) - } - buffer.push(""); - return buffer; - } - var cRows = function(that) { - this.that = that; - this.options = that.options; - this.selectedRows = []; - this.isDirty = false; - } - var _p = cRows.prototype; - _p._addToData = function(objP) { - var location = this.options.dataModel.location; - var data = (location == "remote") ? this.that.data : this.options.dataModel.data, - indx = (location == "remote") ? objP.rowIndxPage : objP.rowIndx, - rowData = data[indx]; - rowData.selectedRow = true; - } - _p.setDirty = function() { - if (this.selectedRows.length > 0) { - this.isDirty = true; - } - } - _p.removeAll = function(objP) { - if (this.isDirty) { - this.refresh(); - } - var raiseEvent = objP.raiseEvent, - that = this.that, - offset = (objP.offset == null) ? that.getRowIndxOffset() : obj.offset; - var selectedRows = this.selectedRows.slice(0); - for (var i = 0; i < selectedRows.length; i++) { - var selR = selectedRows[i]; - var rowIndx = selR.rowIndx; - this.remove({rowIndx: rowIndx, offset: offset}); - } - } - _p.refresh = function() { - this.selectedRows = []; - var data = this.options.dataModel.data; - if (!data) - return; - for (var i = 0, len = data.length; i < len; i++) { - var rowData = data[i]; - if (rowData.selectedRow) { - this.selectedRows.push({rowIndx: i}); - } - } - this.isDirty = false; - } - _p.replace = function(obj) { - if (this.isDirty) { - this.refresh(); - } - var rowIndx = obj.rowIndx, - offset = obj.offset = (obj.offset == null) ? this.that.getRowIndxOffset() : obj.offset, - rowIndxPage = obj.rowIndxPage = rowIndx - offset, - $tr = obj.$tr, - evt = obj.evt; - this.removeAll({raiseEvent: true}); - this.add(obj); - } - _p.add = function(objP) { - if (this.isDirty) { - this.refresh(); - } - var rowIndx = objP.rowIndx, - that = this.that, - offset = (objP.offset == null) ? that.getRowIndxOffset() : objP.offset, - rowIndxPage = objP.rowIndxPage = rowIndx - offset, - $tr = objP.$tr, - evt = objP.evt, - selectedRows = this.selectedRows, - isSelected = this.isSelected(objP); - if (isSelected == null) { - return false; - } - else if (this.isSelected(objP) == false) { - var ret = this._boundRow(objP), - $tr = ret; - selectedRows.push({rowIndx: rowIndx}); - this._addToData(objP); - that._trigger("rowSelect", evt, { - rowIndx: rowIndx, - rowIndxPage: rowIndxPage, - data: that.data, - dataModel: that.dataModel, - $tr: $tr - }); - } - else { - var indx = this.indexOf(objP); - var arr2 = this.selectedRows.splice(indx, 1); - this.selectedRows = this.selectedRows.concat(arr2); - } - } - _p.remove = function(objP) { - if (this.isDirty) { - this.refresh(); - } - var rowIndx = objP.rowIndx, - that = this.that, - offset = (objP.offset == null) ? that.getRowIndxOffset() : objP.offset, - rowIndxPage = objP.rowIndxPage = rowIndx - offset, - evt = objP.evt, - init = (that.init + offset - that.offsetRow), - finall = (that['final'] + offset - that.offsetRow); - if (this.isSelected(objP)) { - var $tr = that.getRow({rowIndxPage: rowIndxPage}); - if ($tr) - $tr.removeClass("pq-row-select ui-state-highlight"); - that._trigger("rowUnSelect", evt, { - rowIndx: rowIndx, - dataModel: that.dataModel, - $tr: $tr - }); - this._removeFromData(objP); - } - var indx = this.indexOf(objP); - if (indx != -1) { - this.selectedRows.splice(indx, 1); - } - } - _p.indexOf = function(obj) { - if (this.isDirty) { - this.refresh(); - } - var rowIndx = obj.rowIndx, - selectedRows = this.selectedRows; - for (var i = 0; i < selectedRows.length; i++) { - if (selectedRows[i].rowIndx == rowIndx) { - return i; - } - } - return -1; - } - _p.isSelected = function(objP) { - if (this.isDirty) { - this.refresh(); - } - var location = this.options.dataModel.location; - var data = (location == "remote") ? this.that.data : this.options.dataModel.data, - indx = (location == "remote") ? objP.rowIndxPage : objP.rowIndx, - rowData = data[indx]; - return (rowData) ? ((rowData.selectedRow == null) ? false : rowData.selectedRow) : null; - } - _p.getSelection = function() { - if (this.isDirty) { - this.refresh(); - } - return this.selectedRows; - } - _p._removeFromData = function(objP) { - var location = this.options.dataModel.location; - var data = (location == "remote") ? this.that.data : this.options.dataModel.data, - indx = (location == "remote") ? objP.rowIndxPage : objP.rowIndx, - rowData = data[indx]; - rowData.selectedRow = false; - } - _p._boundRow = function(obj) { - var rowIndxPage = obj.rowIndxPage, - rowIndx = obj.rowIndx, - that = this.that, - $tr = (obj.$tr == null) ? that.getRow({rowIndxPage: rowIndxPage}) : obj.$tr; - if ($tr == null || $tr.length == 0) { - return false; - } - $tr.addClass("pq-row-select ui-state-highlight"); - return $tr; - } - var cCells = function(that) { - this.options = that.options, - this.that = that, - this.selectedCells = []; - } - var _pC = cCells.prototype; - _pC._addToData = function(objP) { - var location = this.options.dataModel.location; - var data = (location == "remote") ? this.that.data : this.options.dataModel.data, - indx = (location == "remote") ? objP.rowIndxPage : objP.rowIndx, - rowData = data[indx]; - if (!rowData.selectedDataIndices) { - rowData.selectedDataIndices = {}; - } - rowData.selectedDataIndices[objP.dataIndx] = true; - } - _pC._removeFromData = function(objP) { - var location = this.options.dataModel.location; - var data = (location == "remote") ? this.that.data : this.options.dataModel.data, - indx = (location == "remote") ? objP.rowIndxPage : objP.rowIndx, - rowData = data[indx]; - if (rowData && rowData.selectedDataIndices) { - rowData.selectedDataIndices[objP.dataIndx] = false; - } - } - _pC.setDirty = function() { - if (this.selectedCells.length > 0) { - this.isDirty = true; - } - } - _pC.removeAll = function(objP) { - if (this.isDirty) { - this.refresh(); - } - var raiseEvent = objP.raiseEvent, - that = this.that, - offset = (objP.offset == null) ? that.getRowIndxOffset() : obj.offset; - var selectedCells = this.selectedCells.slice(0); - for (var i = 0; i < selectedCells.length; i++) { - var selC = selectedCells[i]; - var rowIndx = selC.rowIndx, - dataIndx = selC.dataIndx; - this.remove({rowIndx: rowIndx, offset: offset, dataIndx: dataIndx}); - } - } - _pC.isSelected = function(objP) { - if (this.isDirty) { - this.refresh(); - } - var location = this.options.dataModel.location; - var that = this.that, - data = (location == "remote") ? that.data : this.options.dataModel.data, - indx = (location == "remote") ? objP.rowIndxPage : objP.rowIndx, - dataIndx = (objP.dataIndx == null) ? that.colModel[objP.colIndx].dataIndx : objP.dataIndx, - rowData = data[indx]; - if (rowData == null) { - return null; - } - if (rowData.selectedDataIndices) { - if (rowData.selectedDataIndices[dataIndx]) { - return true; - } - } - return false; - } - _pC.refresh = function() { - this.selectedCells = []; - var data = this.options.dataModel.data; - if (!data) - return; - for (var i = 0, len = data.length; i < len; i++) { - var rowData = data[i]; - if (rowData.selectedIndices && rowData.selectedDataIndices[dataIndx]) { - this.selectedCells.push({rowIndx: i, dataIndx: dataIndx}); - } - } - this.isDirty = false; - } - _pC.replace = function(obj) { - if (this.isDirty) { - this.refresh(); - } - var rowIndx = obj.rowIndx, - colIndx = obj.colIndx, - offset = obj.offset = (obj.offset == null) ? this.that.getRowIndxOffset() : obj.offset, - rowIndxPage = obj.rowIndxPage = rowIndx - offset, - $td = obj.$td, - evt = obj.evt; - this.removeAll({raiseEvent: true}); - this.add(obj); - } - _pC.add = function(objP) { - if (this.isDirty) { - this.refresh(); - } - var rowIndx = objP.rowIndx, - that = this.that, - offset = (objP.offset == null) ? that.getRowIndxOffset() : objP.offset, - rowIndxPage = objP.rowIndxPage = rowIndx - offset, - colIndx = objP.colIndx = (objP.colIndx == null) ? that.getColIndxFromDataIndx(objP.dataIndx) : objP.colIndx, - dataIndx = objP.dataIndx = (objP.dataIndx == null) ? that.colModel[colIndx].dataIndx : objP.dataIndx, - evt = objP.evt, - selectedCells = this.selectedCells, - isSelected = this.isSelected(objP); - if (isSelected == null) { - return false; - } - else if (isSelected == false) { - var $td = that.getCell({rowIndxPage: rowIndxPage, colIndx: colIndx}); - if ($td) - $td.addClass("pq-cell-select ui-state-highlight"); - selectedCells.push({rowIndx: rowIndx, dataIndx: dataIndx}); - this._addToData(objP); - that._trigger("cellSelect", evt, { - rowIndx: rowIndx, - rowIndxPage: rowIndxPage, - colIndx: colIndx, - dataIndx: dataIndx, - data: that.data, - dataModel: that.dataModel, - $td: $td - }); - } - else { - var indx = this.indexOf(objP); - var arr2 = this.selectedCells.splice(indx, 1); - this.selectedCells = this.selectedCells.concat(arr2); - } - } - _pC.remove = function(objP) { - if (this.isDirty) { - this.refresh(); - } - var rowIndx = objP.rowIndx, - that = this.that, - dataIndx = (objP.dataIndx == null) ? that.colModel[objP.colIndx].dataIndx : objP.dataIndx, - colIndx = (objP.colIndx == null) ? that.getColIndxFromDataIndx(dataIndx) : objP.colIndx, - offset = (objP.offset == null) ? that.getRowIndxOffset() : objP.offset, - rowIndxPage = objP.rowIndxPage = rowIndx - offset, - evt = objP.evt, - init = (that.init + offset), - finall = (that['final'] + offset); - if (this.isSelected(objP)) { - var $td = that.getCell({rowIndxPage: rowIndxPage, colIndx: colIndx}); - if ($td) - $td.removeClass("pq-cell-select ui-state-highlight"); - that._trigger("cellUnSelect", evt, { - rowIndx: rowIndx, - colIndx: colIndx, - dataIndx: dataIndx, - dataModel: that.dataModel, - $td: $td - }); - this._removeFromData(objP); - } - var indx = this.indexOf(objP); - if (indx != -1) { - this.selectedCells.splice(indx, 1); - } - } - _pC.indexOf = function(obj) { - if (this.isDirty) { - this.refresh(); - } - var rowIndx = obj.rowIndx, - that = this.that, - dataIndx = obj.dataIndx = (obj.dataIndx == null) ? that.colModel[obj.colIndx].dataIndx : obj.dataIndx; - var selectedCells = this.selectedCells; - for (var i = 0; i < selectedCells.length; i++) { - var sCell = selectedCells[i]; - if (sCell.rowIndx == rowIndx && sCell.dataIndx == dataIndx) { - return i; - } - } - return -1; - } - _pC.getSelection = function() { - if (this.isDirty) { - this.refresh(); - } - return this.selectedCells; - } - var fn = {}; - fn.options = { - bottomVisible: true, - colModel: null, - columnBorders: true, - customData: null, - dataModel: { - cache: false, - curPage: 0, - totalPages: 0, - rPP: 10, - location: "local", - sorting: "local", - sortDir: "up", - method: "GET", - rPPOptions: [10, 20, 50, 100] - }, - direction: "", - draggable: false, - editable: true, - editModel: {clicksToEdit: 1, saveKey: ''}, - flexHeight: false, - flexWidth: false, - freezeCols: 0, - getDataIndicesFromColIndices: true, - height: 400, - hoverMode: 'row', - minWidth: 50, - numberCell: true, - numberCellWidth: 50, - oddRowsHighlight: true, - resizable: false, - roundCorners: true, - rowBorders: true, - scrollModel: {pace: "fast", horizontal: true}, - selectionModel: {type: 'row', mode: 'range'}, - sortable: true, - title: " ", - topVisible: true, - treeViewModel: null, - width: 600, - wrap: true - } - fn._regional = { - strLoading: "Loading", - strAdd: "Add", - strEdit: "Edit", - strDelete: "Delete", - strSearch: "Search", - strNothingFound: "Nothing found", - strSelectedmatches: "Selected {0} of {1} match(es)", - strPrevResult: "Previous Result", - strNextResult: "Next Result" - } - $.extend(fn.options, fn._regional); - fn._destroyResizable = function() { - if (this.element.data("resizable")) - this.element.resizable('destroy'); - } - fn._destroyDraggable = function() { - if (this.element.data("draggable")) - this.element.draggable('destroy'); - } - fn._disable = function() { - if (this.$disable == null) - this.$disable = $("
").css("opacity", 0.2).appendTo(this.element); - } - fn._enable = function() { - if (this.$disable) { - this.element[0].removeChild(this.$disable[0]); - this.$disable = null; - } - } - fn._destroy = function() { - this._destroyResizable(); - this._destroyDraggable(); - this.element.empty(); - this.element.css('height', ""); - this.element.css('width', ""); - this.element.removeClass('pq-grid ui-widget ui-widget-content ui-corner-all').removeData(); - } - fn._findCellFromEvtCoords = function(evt) { - if (this.$tbl == null) { - return { - $td: null, - rowIndxPage: null, - colIndx: null - }; - } - var top = evt.pageY - this.$cont.offset().top; - var left = evt.pageX - this.$cont.offset().left; - var $trs = this.$tbl.find("tr"); - var indx = 0, - rowIndxPage = 0, - colIndx = 0; - for (var i = 1; i < $trs.length; i++) { - if ($trs[i].offsetTop > top) { - break; - } else { - indx++; - } - } - var $tr = $($trs[indx]); - rowIndxPage = parseInt($tr.attr('pq-row-indx')); - var $tds = $tr.find("td"); - indx = 0; - for (var i = 1; i < $tds.length; i++) { - if ($tds[i].offsetLeft > left) { - break; - } else { - indx++; - } - } - var $td = $($tds[indx]); - if ($td[0].nodeName.toUpperCase() != "TD") { - $td = $(evt.target).parent("td"); - } - colIndx = parseInt($td.attr('pq-col-indx')) - return { - $td: $td, - rowIndxPage: rowIndxPage, - colIndx: colIndx - }; - } - fn._rangeSelectRow = function(initRowIndx, finalRowIndx, evt) { - var that = this, - rowSelection = that.sRows.getSelection(), - rowSelection2 = rowSelection.slice(0); - for (var i = 0; i < rowSelection2.length; i++) { - var rowS = rowSelection2[i], row = rowS.rowIndx; - if (row < initRowIndx || row > finalRowIndx) { - that.sRows.remove({rowIndx: row}); - } - } - for (var row = initRowIndx; row <= finalRowIndx; row++) { - that.sRows.add({rowIndx: rowIndx}); - } - } - fn._rangeSelect = function(initRowIndx, initColIndx, finalRowIndx, finalColIndx, evt) { - var that = this, - cellSelection = that.sCells.getSelection(), - cellSelection2 = cellSelection.slice(0); - for (var i = 0; i < cellSelection2.length; i++) { - var cellS = cellSelection2[i], - row = cellS.rowIndx, - dataIndx = cellS.dataIndx, - col = this.getColIndxFromDataIndx(dataIndx); - if (row < initRowIndx || row > finalRowIndx) { - that.sCells.remove({rowIndx: row, colIndx: col, dataIndx: dataIndx}); - } - else if (row == initRowIndx && col < initColIndx) { - that.sCells.remove({rowIndx: row, colIndx: col, dataIndx: dataIndx}); - } - else if (row == finalRowIndx && col > finalColIndx) { - that.sCells.remove({rowIndx: row, colIndx: col, dataIndx: dataIndx}); - } - } - for (var col = 0; col < that.colModel.length; col++) { - var column = that.colModel[col]; - if (column.hidden) { - continue; - } - var dataIndx = column.dataIndx; - var row = initRowIndx; - do { - if (row == initRowIndx && col < initColIndx) { - } - else if (row == finalRowIndx && col > finalColIndx) { - break; - } - else { - that.sCells.add({rowIndx: row, colIndx: col, dataIndx: dataIndx}); - } - row++; - } while (row <= finalRowIndx); - } - }; - fn._blockSelect = function(initRowIndx, initColIndx, finalRowIndx, finalColIndx, evt) { - var that = this, - cellSelection = that.sCells.getSelection(), - cellSelection2 = cellSelection.slice(0); - for (var i = 0; i < cellSelection2.length; i++) { - var cellS = cellSelection2[i], - row = cellS.rowIndx, - dataIndx = cellS.dataIndx, - col = this.getColIndxFromDataIndx(dataIndx); - if (col < initColIndx || col > finalColIndx) { - that.sCells.remove({rowIndx: row, dataIndx: dataIndx, colIndx: col}); - } - else if (row < initRowIndx || row > finalRowIndx) { - that.sCells.remove({rowIndx: row, dataIndx: dataIndx, colIndx: col}); - } - } - for (var col = initColIndx; col <= finalColIndx; col++) { - var column = that.colModel[col]; - var dataIndx = column.dataIndx; - if (column.hidden) { - continue; - } - var row = initRowIndx; - do { - that.sCells.add({rowIndx: row, colIndx: col, dataIndx: dataIndx}); - row++; - } while (row <= finalRowIndx); - } - }; - fn._create = function() { - this.cTable = new cCreateTable(this); - this.minWidth = this.options.minWidth; - this.cols = []; - this.dataModel = this.options.dataModel; - this.widths = []; - this.outerWidths = []; - this.rowHeight = 22; - this.hidearr = []; - this.hidearrHS = []; - this.numberCell = this.options.numberCell; - this.numberCellWidth = this.options.numberCellWidth; - this.freezeCols = this.options.freezeCols; - this.tables = []; - var that = this; - this.$tbl = null; - this._refreshHeader(); - this._refreshWidths(); - this._computeOuterWidths(); - this.element.empty().addClass('pq-grid ui-widget ui-widget-content' + (this.options.roundCorners ? ' ui-corner-all' : '')) - .append("
\ -
 
\ -
\ -
\ - \ -
\ -
\ -
\ -
\ -
\ -
\ - \ -
"); - if (this.options.direction == "rtl") { - this.element.addClass("pq-rtl"); - } - this._trigger("render", null, { - dataModel: this.options.dataModel, - colModel: this.colModel - }); - this.$top = $("div.pq-grid-top", this.element); - this.$title = $("div.pq-grid-title", this.element); - this.$toolbar = $("div.pq-grid-toolbar", this.element); - this.$grid_inner = $("div.pq-grid-inner", this.element); - this.$grid_right = $(".pq-grid-right", this.element); - this.$header_o = $("div.pq-header-outer", this.$grid_right); - if (!this.options.topVisible) { - this.$top.css("display", "none"); - } - this.$header = $(".pq-grid-header", this.$grid_right); - this.$header_left = $(this.$header[0]); - this.$header_right = $(this.$header[1]); - this.$bottom = $("div.pq-grid-bottom", this.element); - if (!this.options.bottomVisible) { - this.$bottom.css("display", "none"); - } - this.$footer = $("div.pq-grid-footer", this.element); - this.$cont_o = $("div.pq-cont-right", this.$grid_right); - this.$cont_fixed = $("div.pq-cont-fixed", this.$grid_right); - this.$cont = $("div.pq-cont", this.$grid_right); - this.$cont.on("click", function(evt) { - return that._onClickCont(evt); - }); - this.$cont.on("click", ".pq-tree-expand-icon", function(evt) { - return that.cTreeView._onClickTreeExpandIcon(evt); - }); - this.$cont.on("click", "td.pq-grid-cell", function(evt) { - return that._onClickCell(evt); - }); - this.$cont.on("click", "tr.pq-grid-row", function(evt) { - return that._onClickRow(evt); - }); - this.$cont.on("dblclick", "td.pq-grid-cell", function(evt) { - return that._onDblClickCell(evt); - }); - this.$cont.on("dblclick", "tr.pq-grid-row", function(evt) { - return that._onDblClickRow(evt); - }); - this.$cont.on("mouseenter", "td.pq-grid-cell", function(evt) { - var $td = $(this); - if (that._trigger("cellMouseEnter", evt, { - $td: $td, - dataModel: that.options.dataModel - }) == false) { - return false; - } - ; - if (that.options.hoverMode == 'cell') { - that.highlightCell($td); - } - }); - this.$cont.on("mouseenter", "tr.pq-grid-row", function(evt) { - var $tr = $(this); - if (that._trigger("rowMouseEnter", evt, { - $tr: $tr, - dataModel: that.options.dataModel - }) == false) { - return false; - } - ; - if (that.options.hoverMode == 'row') { - that.highlightRow($tr); - } - }); - this.$cont.on("mouseleave", "td.pq-grid-cell", function(evt) { - var $td = $(this); - if (that._trigger("cellMouseLeave", evt, { - $td: $td, - dataModel: that.options.dataModel - }) == false) { - return false; - } - ; - if (that.options.hoverMode == 'cell') { - that.unHighlightCell($td); - } - }); - this.$cont.on("mouseleave", "tr.pq-grid-row", function(evt) { - var $tr = $(this); - if (that._trigger("rowMouseLeave", evt, { - $tr: $tr, - dataModel: that.options.dataModel - }) == false) { - return false; - } - ; - if (that.options.hoverMode == 'row') { - that.unHighlightRow($tr); - } - }); - this.$cont.bind('mousewheel DOMMouseScroll', function(evt) { - return that._onMouseWheel(evt); - }) - var prevVScroll = 0; - this.$hvscroll = $("
").appendTo(this.$grid_inner); - this.$vscroll = $("
").appendTo(this.$grid_inner); - this.prevVScroll = 0; - this.$vscroll.pqScrollBar({ - pace: that.options.scrollModel.pace, - direction: "vertical", - cur_pos: 0, - scroll: function(evt, obj) { - that.scrollMode = true; - that.selectCellRowCallback(function() { - that.cTable._generateTables(); - }); - $.measureTime(function() { - var num_eles; - if (evt.originalEvent && evt.originalEvent.type == "drag") { - num_eles = that._setScrollVNumEles(); - } - else { - num_eles = that._setScrollVNumEles(true); - } - if (num_eles <= 1) - that._setScrollHLength(); - }, 'scrollBar setNumEles stuff') - } - }); - var prevHScroll = 0; - this.$hscroll = $("
").appendTo(this.$grid_inner); - this.$hscroll.pqScrollBar({ - direction: "horizontal", - pace: that.options.scrollModel.pace, - cur_pos: 0, - scroll: function(evt, obj) { - that._bufferObj_calcInitFinalH(); - that._refreshHideArrHS(); - that.scrollMode = true; - that.selectCellRowCallback(function() { - that._createHeader(); - that._refreshHeaderSortIcons(); - that.cTable._generateTables(); - that._refreshOtherTables(); - }); - } - }) - this.element.width(this.options.width).height(this.options.height); - this.element.width(this.element.width()); - this.disableSelection(); - if (window.opera) { - this.$grid_inner.bind("keypress.pq-grid", { - that: this - }, function(evt) { - that.keyPressDown(evt); - }) - } else { - this.$grid_inner.bind("keydown.pq-grid", { - that: this - }, function(evt) { - that.keyPressDown(evt); - }) - } - this._refreshOptions(); - this._refreshTitle(); - var DM = this.options.dataModel; - if (DM.sortIndx != null && DM.sorting == "local" && DM.location == "local") { - this._refreshDataIndices(); - var colIndx = this.getColIndxFromDataIndx(DM.sortIndx); - this._sortLocalData(DM.sortIndx, DM.sortDir, this.colModel[colIndx].dataType, DM.data); - } - this._initData(); - this._createSelectedRowsObject(); - this._createSelectedCellsObject(); - this._refresh(); - }; - fn._onMouseWheel = function(evt) { - var that = this; - var num = 0; - var evt = evt.originalEvent; - if (evt.wheelDelta) { - num = evt.wheelDelta / 120; - } else if (evt.detail) { - num = evt.detail * -1 / 3; - } - var cur_pos = parseInt(that.$vscroll.pqScrollBar('option', 'cur_pos')); - var new_pos = cur_pos - num; - if (new_pos >= 0) { - that.$vscroll.pqScrollBar('option', 'cur_pos', cur_pos - num).pqScrollBar('scroll'); - } - return false; - }; - fn._onDblClickCell = function(evt) { - var that = this; - var $td = $(evt.currentTarget); - var obj = that.getCellIndices($td); - var rowIndxPage = obj.rowIndxPage, - offset = that.getRowIndxOffset(), - rowIndx = rowIndxPage + offset, - colIndx = obj.colIndx; - if (that._trigger("cellDblClick", evt, { - $td: $td, - dataModel: that.options.dataModel, - rowIndxPage: rowIndxPage, - rowIndx: rowIndx, - colIndx: colIndx - }) == false) { - return false; - } - if (this.isEditableCell({colIndx: colIndx}) && that.options.editModel.clicksToEdit > 1) { - that._setSelection(null); - if (that.options.selectionModel.type == 'cell') { - that._setSelection({rowIndx: rowIndx, colIndx: colIndx}); - } - else if (that.options.selectionModel.type == 'row') { - that._setSelection({rowIndx: rowIndx}); - } - that._editCell($td); - } - }; - fn._onClickCont = function(evt) { - var that = this; - if (that.$td_edit) { - if (!that._isEditCell(evt)) { - that.quitEditMode(evt); - } - } - } - fn._onClickRow = function(evt) { - var that = this; - var $tr = $(evt.currentTarget); - var rowIndxPage = parseInt($tr.attr("pq-row-indx")), - offset = that.getRowIndxOffset(), - rowIndx = rowIndxPage + offset; - var objP = {rowIndx: rowIndx, evt: evt}; - if (that._trigger("rowClick", evt, { - $tr: $tr, - rowIndxPage: rowIndxPage, - rowIndx: rowIndx, - dataModel: that.options.dataModel - }) == false) { - return false; - } - ; - var selectionModel = that.options.selectionModel; - if (selectionModel.type == 'row') { - var rowSelection = that.sRows.getSelection(); - if (rowSelection.length > 0) { - if (evt.ctrlKey && selectionModel.mode != 'single') { - if (that.sRows.indexOf(objP) != -1) { - that.sRows.remove(objP); - } - else { - that._setSelection(objP); - } - } - else if (evt.shiftKey && selectionModel.mode != 'single') { - var rowS = rowSelection[rowSelection.length - 1], - rowIndx1 = rowS.rowIndx, - initRowIndx = rowIndx1, - finalRowIndx = rowIndx; - if (rowIndx1 > rowIndx) { - initRowIndx = rowIndx; - finalRowIndx = rowIndx1; - } - var rowSelection2 = rowSelection.slice(0); - for (var i = 0; i < rowSelection2.length; i++) { - var rSel = rowSelection2[i], - row = rSel.rowIndx; - if (row < initRowIndx || row > finalRowIndx) { - that.sRows.remove({rowIndx: row, evt: evt}); - } - } - for (var row = initRowIndx; row <= finalRowIndx; row++) { - that.sRows.add({rowIndx: row, evt: evt}); - } - that._setSelection(objP); - } - else { - that.sRows.removeAll({raiseEvent: true}); - that._setSelection(objP); - } - } - else { - that._setSelection(objP); - } - } - } - fn._onDblClickRow = function(evt) { - var that = this; - var $tr = $(evt.currentTarget); - var rowIndxPage = parseInt($tr.attr("pq-row-indx")), - offset = that.getRowIndxOffset(), - rowIndx = rowIndxPage + offset; - var objP = {rowIndx: rowIndx, evt: evt}; - if (that._trigger("rowDblClick", evt, { - $tr: $tr, - rowIndxPage: rowIndxPage, - rowIndx: rowIndx, - dataModel: that.options.dataModel - }) == false) { - return false; - } - ; - } - fn.isEditableCell = function(obj) { - var colIndx = obj.colIndx, - column = (obj.column == null) ? (this.colModel[colIndx]) : obj.column, - editable = true; - if (this.options.editable == false) { - editable = false; - } - if (column.editable == false) { - editable = false; - } - return editable; - } - fn._getRowPQData = function(rowIndxPage, key, rowData) { - var rowData = (rowData == null) ? this.data[rowIndxPage] : rowData; - return rowData ? rowData[key] : null; - } - fn._setRowPQData = function(rowIndxPage, objP, rowData) { - var rowData = (rowData == null) ? this.data[rowIndxPage] : rowData; - if (!rowData) - return; - for (var key in objP) { - rowData[key] = objP[key]; - } - } - fn._onClickCell = function(evt) { - var that = this, - thisOptions = this.options, - selectionModel = thisOptions.selectionModel; - ; - var $td = $(evt.currentTarget); - var objP = that.getCellIndices($td); - var rowIndxPage = objP.rowIndxPage, - offset = that.getRowIndxOffset(), - rowIndx = objP.rowIndx = rowIndxPage + offset, - colIndx = objP.colIndx, - dataIndx = objP.dataIndx = this.colModel[colIndx].dataIndx, - column = that.colModel[colIndx]; - objP.evt = evt; - if (that._trigger("cellClick", evt, { - $td: $td, - rowIndxPage: rowIndxPage, - rowIndx: rowIndx, - colIndx: colIndx, - dataIndx: dataIndx, - column: column, - dataModel: that.options.dataModel - }) == false) { - return false; - } - ; - if (that.$td_edit) { - that.quitEditMode(evt); - } - if (this.isEditableCell({column: column}) && thisOptions.editModel.clicksToEdit == '1') { - that._setSelection(null); - if (selectionModel.type == 'cell') { - that._setSelection(objP); - } - else { - that.bringRowIntoView({rowIndxPage: rowIndxPage}); - $td = that._bringCellIntoView({rowIndxPage: rowIndxPage, colIndx: colIndx}); - } - window.setTimeout(function() { - that.editCell(objP); - }, 0) - return; - } - if (selectionModel.type == 'cell') { - var cellSelection = that.sCells.getSelection(); - if (cellSelection.length > 0) { - if (evt.ctrlKey && selectionModel.mode != 'single') { - if (that.sCells.isSelected(objP)) { - that.sCells.remove(objP); - } - else { - that._setSelection(objP); - } - } - else if (evt.shiftKey && selectionModel.mode != 'single') { - var cellS = cellSelection[cellSelection.length - 1], - rowIndx1 = cellS.rowIndx, - colIndx1 = that.getColIndxFromDataIndx(cellS.dataIndx), - initRowIndx = rowIndx1, - finalRowIndx = rowIndx, - initColIndx = colIndx1, - finalColIndx = colIndx; - if (rowIndx1 > rowIndx) { - initRowIndx = rowIndx; - finalRowIndx = rowIndx1; - } - if (that.options.selectionModel.mode == 'range') { - if (rowIndx1 > rowIndx) { - initColIndx = colIndx; - finalColIndx = colIndx1; - } - if (rowIndx == rowIndx1 && colIndx < colIndx1) { - initColIndx = colIndx; - finalColIndx = colIndx1; - } - that._rangeSelect(initRowIndx, initColIndx, finalRowIndx, finalColIndx, evt); - } - else if (that.options.selectionModel.mode == 'block') { - if (colIndx1 > colIndx) { - initColIndx = colIndx; - finalColIndx = colIndx1; - } - that._blockSelect(initRowIndx, initColIndx, finalRowIndx, finalColIndx, evt); - } - that._setSelection(objP); - } - else { - that.sCells.removeAll({raiseEvent: true}); - that._setSelection(objP); - } - } - else { - that._setSelection(objP); - } - } - } - fn.highlightCell = function($td) { - $td.addClass("pq-grid-cell-hover ui-state-hover"); - } - fn.unHighlightCell = function($td) { - $td.removeClass("pq-grid-cell-hover ui-state-hover"); - } - fn.highlightRow = function($tr) { - $tr.addClass("pq-grid-row-hover ui-state-hover"); - } - fn.unHighlightRow = function($tr) { - $tr.removeClass("pq-grid-row-hover ui-state-hover"); - } - fn._createSelectedRowsObject = function() { - this.sRows = new cRows(this); - } - fn._createSelectedCellsObject = function() { - this.sCells = new cCells(this); - } - fn._getCreateEventData = function() { - return { - dataModel: this.options.dataModel, - data: this.data, - colModel: this.options.colModel - }; - } - fn._refreshOptions = function() { - this._refreshDataOptions(); - } - fn._refreshDataOptions = function() { - } - fn.enableSelection = function() { - this.$grid_inner.enableSelection(); - } - fn.disableSelection = function() { - this.$grid_inner.disableSelection(); - } - fn._isEditCell = function(evt) { - var $targ = $(evt.target); - var $div = $targ.closest("div.pq-cell-selected-border-edit"); - if ($div && $div.length > 0) { - return true; - } - return false; - } - fn._findCellFromEvt = function(evt) { - var $targ = $(evt.target); - var $td = $targ.closest(".pq-grid-cell"); - if ($td == null || $td.length == 0) { - return {rowIndxPage: null, colIndx: null, $td: null}; - } - else { - var obj = this.getCellIndices($td); - obj.$td = $td; - return obj; - } - } - fn._initPager = function() { - var DM = this.options.dataModel; - var that = this; - var obj2 = { - rPP: DM.rPP, - rPPOptions: DM.rPPOptions, - change: function(evt, obj) { - var DM = that.options.dataModel; - if (obj.curPage != undefined) { - DM.prevPage = DM.curPage; - DM.curPage = obj.curPage; - } - if (obj.rPP != undefined) - DM.rPP = obj.rPP; - if (DM.paging == "remote") - that.remoteRequest(); - else { - that.$td_edit = null; - that._refreshDataFromDataModel(); - that._refresh(); - } - }, - refresh: function(evt) { - that.refreshDataAndView(); - } - }; - if (DM.paging) { - this.$footer.pqPager(obj2); - } else { - } - } - fn._initData = function() { - var that = this; - var dataModel = this.options.dataModel; - if (dataModel == undefined) { - throw ("dataModel not found."); - } - this._initPager(); - if (dataModel.location == "remote") { - var that = this; - this.generateLoading(); - this.remoteRequest(); - } else { - this._refreshDataFromDataModel(); - } - } - fn._refreshHideArrHS = function() { - var that = this; - for (var i = 0; i < that.colModel.length; i++) { - that.hidearrHS[i] = false; - } - if (that.initH > 0) { - var indx = that.freezeCols - 1 + that.initH; - for (var i = that.freezeCols; i <= indx; i++) { - if (that.colModel[i].hidden) { - continue; - } - that.hidearrHS[i] = true; - } - } else { - } - } - fn.generateLoading = function() { - if (this.$loading) - this.$loading.remove(); - this.$loading = $("
").appendTo(this.element) - $("
" + this.options.strLoading + "...
").appendTo(this.$loading); - this.$loading.find("div.pq-loading-bg").css("opacity", 0.2); - } - fn.showLoading = function() { - this.element.find("div.pq-loading").show(); - } - fn.hideLoading = function() { - this.element.find("div.pq-loading").hide(); - } - fn._refreshDataFromDataModel = function() { - var thisOptions = this.options, - DM = thisOptions.dataModel; - if (DM.data == null || DM.data.length == 0) { - if (DM.paging) { - DM.curPage = 0; - DM.totalPages = 0; - DM.totalRecords = 0; - } - return; - } - if (DM.paging && DM.paging == 'local') { - DM.totalRecords = DM.data.length; - DM.totalPages = Math.ceil(DM.data.length / DM.rPP); - if (DM.curPage > DM.totalPages) { - DM.curPage = DM.totalPages; - } - if (DM.curPage < 1 && DM.totalPages > 0) { - DM.curPage = 1; - } - var begIndx = (DM.curPage - 1) * DM.rPP; - var endIndx = DM.curPage * DM.rPP; - if (endIndx > DM.data.length) { - endIndx = DM.data.length; - } - this.data = DM.data.slice(begIndx, endIndx); - } else { - this.data = DM.data; - } - } - fn.remoteRequest = function(callback_fn) { - if (this.loading) { - this.xhr.abort(); - } - var that = this; - var url = ""; - var dataURL = ""; - var DM = this.options.dataModel; - if (typeof DM.getUrl == "function") { - var objURL = DM.getUrl(); - if (objURL && objURL.url) - url = objURL.url; - if (objURL && objURL.data) - dataURL = objURL.data; - } - if (!url) { - return; - } - this.loading = true; - this.showLoading(); - this.xhr = $.ajax({ - url: url, - dataType: DM.dataType, - async: true, - cache: DM.cache, - type: DM.method, - data: dataURL, - beforeSend: function(jqXHR, settings) { - if (typeof DM.beforeSend == "function") { - return DM.beforeSend(jqXHR, settings); - } - }, - success: function(responseObj, textStatus, jqXHR) { - var dataLoaded = false; - if (typeof DM.getData == "function") { - var retObj = DM.getData(responseObj, textStatus, jqXHR); - DM.data = retObj.data; - if (DM.paging) { - if (DM.paging == "remote") { - if (retObj.curPage) - DM.curPage = retObj.curPage; - if (retObj.totalRecords) { - DM.totalRecords = retObj.totalRecords; - DM.totalPages = Math.ceil(DM.totalRecords / DM.rPP); - } - } - } - that._refreshDataFromDataModel(); - if (DM.sorting == "local" && DM.sortIndx != undefined) { - that._refreshSortingDataAndView({sorting: true}); - } else { - that._refreshViewAfterDataSort(); - } - } else { - throw ("getData callback not found!"); - } - that.hideLoading(); - that.loading = false; - that._trigger("load", null, { - dataModel: that.options.dataModel, - data: that.data - }); - if (typeof callback_fn == "function") - callback_fn(); - }, - error: function(jqXHR, textStatus, errorThrown) { - that.hideLoading(); - that.loading = false; - if (typeof DM.error == "function") { - DM.error(jqXHR, textStatus, errorThrown); - } - } - }); - } - fn._fixFireFoxContentEditableIssue = function() { - if (window.postMessage) { - this.$grid_inner.focus(); - } - } - fn.selectCellRowCallback = function(fn) { - var rowIndx, colIndx; - if (this.$td_edit) { - this.quitEditMode(); - } - var that = this; - $.measureTime(function() { - fn.call(that); - }, '_generateTables'); - if (this.options.flexHeight) { - this.setGridHeightFromTable(); - } - if (this.options.flexWidth) { - this._setGridWidthFromTable(); - } - } - fn._refreshTitle = function() { - this.$title.html(this.options.title); - } - fn._refreshDraggable = function() { - if (this.options.draggable) { - this.$title.addClass('draggable'); - this.element.draggable({ - handle: this.$title, - start: function(evt, ui) { - } - }); - } else { - this._destroyDraggable(); - } - } - fn._refreshResizable = function() { - var that = this; - if (this.options.resizable) { - this.element.resizable({ - helper: "ui-state-highlight", - delay: 0, - start: function(evt, ui) { - $(ui.helper).css({ - opacity: 0.5, - background: "#ccc", - border: "1px solid steelblue" - }); - }, - resize: function(evt, ui) { - }, - stop: function(evt, ui) { - that.options.height = that.element.height(); - that.options.width = that.element.width(); - that._refresh(); - that.element.css("position", "relative"); - } - }); - } else { - this._destroyResizable(); - } - } - fn.refresh = function() { - this._refresh(); - } - fn._refreshDataIndices = function() { - if (this.options.getDataIndicesFromColIndices == false) { - return; - } - var thisColModel = this.colModel; - for (var i = 0; i < thisColModel.length; i++) - { - var column = thisColModel[i]; - if (column.dataIndx == null) { - column.dataIndx = i; - } - } - } - fn._refresh = function() { - var that = this; - this._refreshDataIndices(); - this._refreshResizable(); - this._refreshDraggable(); - this._setScrollHNumEles(); - this._bufferObj_calcInitFinalH(); - this._refreshHideArrHS(); - this._computeOuterWidths(true); - this._createHeader(); - this._refreshHeaderSortIcons(); - this._setInnerGridHeight(); - this._setRightGridHeight(); - this.selectCellRowCallback(function() { - that.cTable._generateTables(); - that._computeOuterWidths(); - }); - this._setScrollHLength(); - this._setScrollVLength(); - this._setScrollVNumEles(true); - this._setScrollHLength(); - this._refreshPager(); - } - fn._refreshPager = function() { - var DM = this.options.dataModel; - if (DM.paging) { - this.$footer.pqPager("option", { - currentPage: DM.curPage, - totalPages: DM.totalPages, - totalRecords: DM.totalRecords, - rPP: DM.rPP, - rPPOptions: DM.rPPOptions - }); - } - } - fn._refreshViewAfterDataSort = function() { - this.selectCellRowCallback(function() { - this.cTable._generateTables(); - this._computeOuterWidths(); - }) - this._refreshHeaderSortIcons(); - this._setRightGridHeight(); - this._setScrollVLength(); - this._setScrollVNumEles(true); - this._setScrollHLength(); - this._refreshPager(); - } - fn.refreshSortingDataAndView = function() { - this._refreshSortingDataAndView({ - sorting: true - }); - } - fn.refreshDataAndView = function(keepSelection) { - this.data = null; - this.sRows.setDirty(); - this.sCells.setDirty(); - var DM = this.options.dataModel; - if (DM.location == "remote") { - DM.data = null; - this.remoteRequest(); - } else { - this._refreshSortingDataAndView({keepSelection: keepSelection, sorting: true}); - } - } - fn.getColIndxFromDataIndx = function(dataIndx) { - var thisColModel = this.colModel; - for (var i = 0; i < thisColModel.length; i++) { - if (thisColModel[i].dataIndx == dataIndx) { - return i; - } - } - } - fn._refreshSortingDataAndView = function(obj) { - var sorting = obj.sorting, - fn = obj.fn, - keepSelection = obj.keepSelection; - if (!keepSelection) { - this.sRows.removeAll({ - raiseEvent: true - }); - this.sCells.removeAll({raiseEvent: true}); - } - var DM = this.options.dataModel, - thisColModel = this.colModel, - indx = DM.sortIndx, - colIndx = this.getColIndxFromDataIndx(indx); - if (indx == null || colIndx == null) { - sorting = false; - } - var dir = DM.sortDir; - var that = this; - if (sorting == true) { - if (DM.sorting == "remote") { - this.remoteRequest(fn); - } else { - var column = thisColModel[colIndx]; - var dataType = column.dataType; - this._sortLocalData(indx, dir, dataType, DM.data); - this.sRows.setDirty(); - this.sCells.setDirty(); - this._refreshDataFromDataModel(); - that._refreshViewAfterDataSort(); - if (typeof fn == "function") - fn(); - } - } else if (DM.location == "remote") { - this.remoteRequest(fn); - } else { - if (this.data == null) { - this._refreshDataFromDataModel(); - } - that._refreshViewAfterDataSort(); - if (typeof fn == "function") - fn(); - } - } - fn._computeOuterWidths = function(basedOnWidthsOnly) { - var options = this.options, - columnBorders = options.columnBorders, - thisColModel = this.colModel, - thisColModelLength = thisColModel.length; - for (var i = 0; i < thisColModelLength; i++) { - var column = thisColModel[i]; - this.outerWidths[i] = parseInt(column.width) + ((columnBorders) ? 1 : 0); - } - this.numberCell_outerWidth = this.numberCellWidth + 1; - return; - } - fn._setOption = function(key, value) { - this.refreshRequired = true; - if (key == "height") { - this.element.height(value); - $.Widget.prototype._setOption.call(this, key, value); - } else if (key == "width") { - this.element.width(value); - $.Widget.prototype._setOption.call(this, key, value); - } else if (key == "title") { - $.Widget.prototype._setOption.call(this, key, value); - this._refreshTitle(); - } else if (key == "roundCorners") { - if (value) { - this.element.addClass("ui-corner-all"); - this.$top.addClass("ui-corner-top"); - this.$bottom.addClass("ui-corner-bottom"); - } - else { - this.element.removeClass("ui-corner-all"); - this.$top.removeClass("ui-corner-top"); - this.$bottom.removeClass("ui-corner-bottom"); - } - this.refreshRequired = false; - } else if (key == "freezeCols") { - if (!isNaN(value) && value >= 0 && parseInt(value) <= this.colModel.length - 2) { - this.options.freezeCols = this.freezeCols = parseInt(value); - this._setScrollHLength(); - $.Widget.prototype._setOption.call(this, key, value); - } - } else if (key == "resizable") { - $.Widget.prototype._setOption.call(this, key, value); - } else if (key == "scrollModel") { - var obj = value; - for (var key in obj) { - this.options.scrollModel[key] = obj[key]; - } - } else if (key == "dataModel") { - $.Widget.prototype._setOption.call(this, key, value); - var paging = value["paging"]; - if (this.$footer.hasClass('pq-pager') == false && (paging == "local" || paging == "remote")) { - this._initPager(); - } - else if (this.$footer.hasClass('pq-pager') && (paging != "local" && paging != "remote")) { - this.$footer.pqPager('destroy'); - this.$footer.html(" "); - } - this.refreshDataAndView(); - } - else if (key == "selectionModel") { - var obj = value; - for (var key in obj) { - this.options.selectionModel[key] = obj[key]; - } - this.refreshRequired = false; - } - else if (key == "colModel") { - $.Widget.prototype._setOption.call(this, key, value); - this._refreshHeader(); - this._refreshWidths(); - this._refreshDataIndices(); - } - else if (key == "disabled") { - if (value == true) { - this._disable(); - } - else { - this._enable(); - } - this.refreshRequired = false; - } - else if (key == "numberCell") { - this.numberCell = value; - $.Widget.prototype._setOption.call(this, key, value); - } - else if (key == "numberCellWidth") { - this.numberCellWidth = value; - $.Widget.prototype._setOption.call(this, key, value); - } - else if (key == "customData") { - $.Widget.prototype._setOption.call(this, key, value); - this.refreshRequired = false; - } - else if (key == "strLoading") { - $.Widget.prototype._setOption.call(this, key, value); - this.generateLoading(); - this.refreshRequired = false; - } - else if (key == "topVisible") { - if (value == true) - this.$top.css("display", ""); - else - this.$top.css("display", "none"); - } - else if (key == "bottomVisible") { - if (value == true) - this.$bottom.css("display", ""); - else - this.$bottom.css("display", "none"); - } - else { - $.Widget.prototype._setOption.call(this, key, value); - } - } - fn._setOptions = function() { - $.Widget.prototype._setOptions.apply(this, arguments); - if (this.refreshRequired) { - this._refresh(); - } - this.refreshRequired = true; - } - fn._generateCellRowOutline = function(obj) { - var $td = obj.$td, - $tr = obj.$tr, - that = this; - if ($tr) { - var wd = that._calcRightEdgeCol(that.colModel.length - 1); - wd -= 4; - var ht = $tr[0].offsetHeight - 4; - var $table = $($tr[0].offsetParent); - var offsetParent = $table[0].offsetParent; - var lft = $tr[0].offsetLeft + $table[0].offsetLeft; - var top = $tr[0].offsetTop + $table[0].offsetTop; - that._generateCellHighlighter(offsetParent, lft, top, wd, ht); - } - else if ($td) { - var $table = $($td[0].offsetParent); - var offsetParent = $table[0].offsetParent; - var wd = $td[0].offsetWidth - 4; - var ht = $td[0].offsetHeight - 4; - var lft = $td[0].offsetLeft + $table[0].offsetLeft; - var top = $td[0].offsetTop + $table[0].offsetTop; - that._generateCellHighlighter(offsetParent, lft, top, wd, ht); - } - } - fn._removeCellRowOutline = function() { - if (this.$div_focus) { - this._fixFireFoxContentEditableIssue(); - this.$div_focus.remove(); - this.$div_focus = null; - } - } - fn._generateCellHighlighter = function(offsetParent, lft, top, wd, ht) { - if (this.$div_focus && this.$div_focus[0].offsetParent == offsetParent) { - if (this.$td_edit != null) { - this._fixFireFoxContentEditableIssue(); - this.$div_focus.empty().removeClass('pq-cell-selected-border-edit'); - this.$td_edit = null; - } - this.$div_focus.css({ - left: lft, - top: top, - height: ht, - width: wd - }); - } else { - if (this.$div_focus) - this.$div_focus.remove(); - this.$div_focus = $("
") - .appendTo(offsetParent); - this.$div_focus.css({ - left: lft, - top: top, - height: ht, - width: wd - }); - } - } - fn._selectRow = function(rowIndx, evt) { - this.selectRow(rowIndx, evt) - } - fn._findfirstUnhiddenColIndx = function() { - for (var i = 0; i < this.colModel.length; i++) { - if (!this.colModel[i].hidden) { - return i - } - } - } - fn.selectRow = function(obj) { - var rowIndx = obj.rowIndx, - evt = obj.evt, - offset = obj.offset; - if (evt && (evt.type == "keydown" || evt.type == "keypress")) { - if (this.sRows.replace(obj) == false) { - return false; - } - } - else if (this.sRows.add(obj) == false) { - return false; - } - if (evt != null) - this._setGridFocus(); - return true; - } - fn.scrollY = function(rowIndx) { - this.$vscroll.pqScrollBar("option", "cur_pos", rowIndx).pqScrollBar("scroll"); - } - fn.bringRowIntoView = function(obj) { - var rowIndxPage = obj.rowIndxPage; - var init = this.init - this.offsetRow; - var calcCurPos = this._calcCurPosFromRowIndxPage(rowIndxPage); - if (calcCurPos < this.scrollCurPos) { - this.$vscroll.pqScrollBar("option", "cur_pos", calcCurPos).pqScrollBar("scroll"); - } - var $tr = this.$tbl.find("tr[pq-row-indx=" + rowIndxPage + "]"); - if ($tr[0] == undefined) { - this.$vscroll.pqScrollBar("option", "cur_pos", calcCurPos).pqScrollBar("scroll"); - } else { - var td_bottom = $tr[0].offsetTop + $tr[0].offsetHeight, - htCont = this.$cont[0].offsetHeight, - htSB = this._getScollBarHorizontalHeight(); - if (td_bottom > htCont - htSB) { - var diff = td_bottom - (htCont - htSB); - var $trs = this.$tbl.children().children("tr"); - var ht = 0, - indx = 0; - $trs.each(function(i, tr) { - ht += tr.offsetHeight; - if (ht >= diff) { - indx = i; - return false; - } - }) - var cur_pos = this.scrollCurPos + indx; - var num_eles = this.$vscroll.pqScrollBar("option", "num_eles"); - if (num_eles < cur_pos + 1) { - num_eles = cur_pos + 1; - } - this.$vscroll.pqScrollBar("option", {num_eles: num_eles, cur_pos: cur_pos}).pqScrollBar("scroll"); - } - } - } - fn._bringCellIntoView = function(obj) { - var rowIndxPage = obj.rowIndxPage, - colIndx = obj.colIndx, - tdneedsRefresh = false; - var $td; - if (this.hidearrHS[colIndx]) { - this.hidearrHS[colIndx] = false; - var cur_pos = colIndx - this.freezeCols - this._calcNumHiddenUnFrozens(colIndx); - this.$hscroll.pqScrollBar("option", "cur_pos", cur_pos).pqScrollBar("scroll"); - tdneedsRefresh = true; - } else { - var $td = this.$tbl.find("tr[pq-row-indx=" + rowIndxPage + "]>td[pq-col-indx=" + colIndx + "]"); - if ($td.length == 0) { - return false; - } - var td_right = this._calcRightEdgeCol(colIndx).width; - var wd_scrollbar = 17; - if (this.$vscroll.css("visibility") == "hidden" || this.$vscroll.css("display") == "none") { - wd_scrollbar = 0; - } - if (td_right > this.$cont[0].offsetWidth - wd_scrollbar) { - var diff = this._calcWidthCols(colIndx) - (this.$cont[0].offsetWidth - wd_scrollbar); - var $tds = $td.parent("tr").children("td"); - var data_length = this.colModel.length; - var wd = 0, - initH = 0; - for (var i = this.freezeCols; i < data_length; i++) { - if (!this.colModel[i].hidden) { - wd += this.outerWidths[i]; - } - if (i == colIndx) { - initH = i - this.freezeCols - this._calcNumHiddenUnFrozens(i); - break; - } else if (wd >= diff) { - initH = i - this.freezeCols - this._calcNumHiddenUnFrozens(i) + 1; - break; - } - } - this.$hscroll.pqScrollBar("option", "cur_pos", initH).pqScrollBar("scroll"); - tdneedsRefresh = true; - } - } - if (tdneedsRefresh) { - var $td = this.$tbl.find("tr[pq-row-indx=" + rowIndxPage + "]>td[pq-col-indx=" + colIndx + "]"); - return $td; - } - else { - return $td; - } - } - fn.selection = function(obj) { - var rowIndx = obj.rowIndx, - colIndx = obj.colIndx, - method = obj.method, - type = obj.type; - if (type == 'row') { - return this['sRows'][method](obj); - } - else if (type == 'cell') { - return this['sCells'][method](obj); - } - return; - } - fn.setSelection = function(obj) { - if (obj == null || obj.rowIndx == null) { - this.sRows.removeAll({raiseEvent: true}); - this.sCells.removeAll({raiseEvent: true}); - return; - } - this._bringPageIntoView(obj); - return this._setSelection(obj); - } - fn._bringPageIntoView = function(obj) { - var rowIndx = obj.rowIndx, that = this; - var DM = this.options.dataModel; - if (DM.paging == "local" && rowIndx >= 0) { - var curPage = DM.curPage; - var rPP = DM.rPP; - var begIndx = (curPage - 1) * rPP; - var endIndx = curPage * rPP; - if (rowIndx >= begIndx && rowIndx < endIndx) { - } - else { - DM.curPage = Math.ceil((rowIndx + 1) / rPP); - this._refreshDataFromDataModel(); - this._refreshViewAfterDataSort(); - } - } - } - fn._setSelection = function(obj) { - if (obj == null) { - this.sRows.removeAll({raiseEvent: true}); - this.sCells.removeAll({raiseEvent: true}); - return false; - } - var offset = obj.offset = (obj.offset == null) ? this.getRowIndxOffset() : obj.offset, - rowIndx = obj.rowIndx = (obj.rowIndx == null) ? obj.rowIndxPage + offset : obj.rowIndx, - rowIndxPage = obj.rowIndxPage = (obj.rowIndxPage == null) ? obj.rowIndx - offset : obj.rowIndxPage, - colIndx = obj.colIndx, - evt = obj.evt; - if (rowIndxPage < 0 || colIndx < 0) { - return false; - } - if (this.data == null || this.data.length == 0) { - return false; - } - if (rowIndxPage >= this.data.length || colIndx >= this.colModel.length) { - return false; - } - this.bringRowIntoView({rowIndxPage: rowIndxPage}); - if (colIndx == null) { - return this.selectRow({rowIndx: rowIndx, evt: evt}); - } - this._bringCellIntoView({rowIndxPage: rowIndxPage, colIndx: colIndx}); - return this.selectCell({rowIndx: rowIndx, colIndx: colIndx, evt: evt}); - } - fn.saveEditCell = function() { - if (this.$td_edit == null) - return; - var $td = this.$td_edit, - obj = this.getCellIndices($td), - offset = this.getRowIndxOffset(), - colIndx = obj.colIndx, - rowIndxPage = obj.rowIndxPage, - rowIndx = obj.rowIndx = rowIndxPage + offset, - thisColModel = this.colModel, - column = obj.column = thisColModel[colIndx], - dataIndx = obj.dataIndx = column.dataIndx, - prevVal = this.data[rowIndxPage][dataIndx]; - if (rowIndxPage != null) { - var dataCell = this._getEditCellData(obj); - if (dataCell != prevVal) { - this.data[rowIndxPage][dataIndx] = dataCell; - obj.data = this.data; - if (this._trigger("cellSave", null, obj) == false) { - return; - } - this.refreshRow(obj); - this._fixTableViewPort(); - var that = this; - if (that.options.flexHeight) { - that.setGridHeightFromTable(); - that._fixIEFooterIssue(); - } else { - that.bringRowIntoView({rowIndxPage: rowIndxPage}); - } - } - } - } - fn._fixTableViewPort = function() { - var cont = this.$cont[0]; - cont.scrollTop = 0; - cont.scrollLeft = 0; - } - fn._fixIEFooterIssue = function() { - $(".pq-grid-footer").css({position: "absolute"}); - $(".pq-grid-footer").css({position: "relative"}); - } - fn.refreshColumn = function(obj) { - var customData = this.options.customData, - colIndx = obj.colIndx = (obj.colIndx == null) ? this.getColIndxFromDataIndx(obj.dataIndx) : obj.colIndx, - offset = this.getRowIndxOffset(); - for (var row = this.init; row <= this["final"]; row++) { - var rowIndxPage = obj.rowIndxPage = row; - obj.rowIndx = rowIndxPage + offset; - var column = obj.column = this.colModel[colIndx]; - obj.$td = this.getCell(obj); - obj.rowData = this.data[rowIndxPage]; - obj.customData = customData; - this.cTable._renderCell(obj); - } - } - fn.refreshCell = function(obj) { - if (!this.data) - return; - var offset = obj.offset = (obj.offset == null) ? this.getRowIndxOffset() : obj.offset, - rowIndx = obj.rowIndx = (obj.rowIndx == null) ? obj.rowIndxPage + offset : obj.rowIndx, - rowIndxPage = obj.rowIndxPage = (obj.rowIndxPage == null) ? obj.rowIndx - offset : obj.rowIndxPage, - dataIndx = obj.dataIndx, - colIndx = obj.colIndx = (obj.colIndx == null) ? this.getColIndxFromDataIndx(dataIndx) : obj.colIndx, - $td = obj.$td = (obj.$td == null) ? this.getCell(obj) : obj.$td, - column = obj.column = this.colModel[colIndx], - rowData = this.data[rowIndxPage]; - if (!rowData) - return; - var objRender = obj; - objRender.rowData = rowData; - objRender.customData = this.options.customData; - if ($td && $td.length > 0) - this.cTable._renderCell(objRender); - } - fn.refreshRow = function(obj) { - if (!this.data) - return; - var thisOptions = this.options, - offset = obj.offset = (obj.offset == null) ? this.getRowIndxOffset() : obj.offset, - rowIndx = obj.rowIndx = (obj.rowIndx == null) ? obj.rowIndxPage + offset : obj.rowIndx, - rowIndxPage = obj.rowIndxPage = (obj.rowIndxPage == null) ? obj.rowIndx - offset : obj.rowIndxPage, - $tr = (obj.$tr == null) ? this.getRow(obj) : obj.$tr, - thisColModel = this.colModel, - rowData = this.data[rowIndxPage]; - if (!rowData) - return; - var objRender = {rowIndx: rowIndx, rowIndxPage: rowIndxPage, rowData: rowData, - customData: thisOptions.customData}; - for (var colIndx = 0; colIndx < thisColModel.length; colIndx++) { - var column = thisColModel[colIndx]; - var $td = $tr.find("td[pq-col-indx=" + colIndx + "]"); - objRender.$td = $td; - objRender.colIndx = colIndx; - objRender.column = column; - if ($td && $td.length > 0) - this.cTable._renderCell(objRender); - } - } - fn.quitEditMode = function(evt) { - if (this.$td_edit) { - var $td = this.$td_edit; - this.disableSelection(); - this._setGridFocus(); - this._trigger("quitEditMode", evt, { - $td: $td, - dataModel: this.options.dataModel - }); - this._removeCellRowOutline(); - this.$td_edit = null; - } - } - fn.getData = function() { - return this.data; - } - fn.getViewPortRowsIndx = function() { - return {beginIndx: this.init, endIndx: this['final']}; - } - fn.getRowIndxOffset = function() { - var DM = this.options.dataModel, - paging = DM.paging, - offset = 0; - if (paging == "local" || paging == "remote") { - var curPage = DM.curPage; - var rPP = DM.rPP; - offset = (rPP * (curPage - 1)); - } - return offset; - } - fn.getRowOffset = function() { - return this.offsetRow; - } - fn._cellblurred = function() { - this.$div_focus.remove(); - this.$div_focus = null; - this.$td_focus = null; - this.$tr_focus = null; - } - fn.selectCell = function(obj) { - var rowIndx = obj.rowIndx, - colIndx = obj.colIndx, - evt = obj.evt; - if (evt && (evt.type == "keydown" || evt.type == "keypress")) { - if (this.sCells.replace(obj) == false) { - return false; - } - } - else { - if (this.sCells.add(obj) == false) { - return false; - } - } - if (evt != null) - this._setGridFocus(); - return true; - } - fn._setGridFocus = function() { - var that = this; - window.setTimeout(function() { - if (that.$td_edit == null) { - that.$grid_inner.focus(); - } - }, 0) - } - fn.getEditCell = function() { - if (this.$td_edit) { - return {$td: this.$td_edit, $cell: this.$div_focus}; - } - else { - return null; - } - } - fn.editCell = function(obj) { - var $td = this.getCell(obj); - if ($td != null && $td.length == 1) { - if (this.$td_edit && this.$td_edit[0] != $td[0]) - { - this.quitEditMode(); - } - this._editCell($td); - return $td; - } - } - fn.getFirstEditableColIndx = function() { - if (!this.options.editable) { - return -1; - } - var colModel = this.colModel; - for (var i = 0; i < colModel.length; i++) { - var column = colModel[i]; - if (column.editable == false) { - continue; - } - return i; - } - return -1; - } - fn._editFirstCellInRow = function(obj) { - var colIndx = this.getFirstEditableColIndx(); - if (colIndx != -1) { - var rowIndxPage = obj.rowIndxPage; - obj.colIndx = colIndx; - this.bringRowIntoView(obj); - var $td = this._bringCellIntoView(obj); - if ($td && $td.length > 0) - this._editCell($td); - } - } - fn._editCell = function($td) { - var that = this; - var obj = that.getCellIndices($td); - var rowIndxPage = obj.rowIndxPage, - offset = this.getRowIndxOffset(), - rowIndx = rowIndxPage + offset, - colIndx = obj.colIndx, - column = this.colModel[colIndx], - dataIndx = column.dataIndx; - if (this.$td_edit && this.$td_edit[0] == $td[0]) { - return false; - } - this.$td_edit = $td; - this.enableSelection(); - this._removeCellRowOutline(); - this._generateCellRowOutline({$td: $td}); - var $cell = this.$div_focus.addClass('pq-cell-selected-border-edit'); - if (column.align == "right") { - $cell.css("text-align", "right"); - } else if (column.align == "center") { - $cell.css("text-align", "center"); - } else { - $cell.css("text-align", "left"); - } - if (column.editor) { - column.editor({ - $cell: $cell, - data: this.data, - dataModel: this.dataModel, - rowIndx: rowIndx, - rowIndxPage: rowIndxPage, - colIndx: dataIndx - }); - } else { - $cell.html("
"); - var that = this; - $cell.children().html(that.data[rowIndxPage][dataIndx]); - } - var that = this; - window.setTimeout(function() { - if (that.$td_edit != null) { - var $cell = that.$div_focus; - $cell.children().focus(); - } - }, 0) - } - fn.getRow = function(obj) { - var rowIndxPage = obj.rowIndxPage; - var $tr; - if (this.$tbl != undefined) - $tr = this.$tbl.find("tr[pq-row-indx=" + rowIndxPage + "]"); - return $tr; - } - fn.getCell = function(obj) { - var rowIndxPage = (obj.rowIndxPage == null) ? (obj.rowIndx - this.getRowIndxOffset()) : obj.rowIndxPage, - colIndx = obj.colIndx; - var $td; - if (this.$tbl != undefined) - $td = this.$tbl.find("tr[pq-row-indx=" + rowIndxPage + "]>td[pq-col-indx=" + colIndx + "]"); - return $td; - } - fn.getEditCellData = function() { - if (this.$td_edit) { - var obj = this.getCellIndices(this.$td_edit); - return this._getEditCellData(obj); - } - else { - return null; - } - } - fn._getEditCellData = function(obj) { - var colIndx = obj.colIndx, - rowIndxPage = obj.rowIndxPage, - rowIndx = (obj.rowIndx != null) ? obj.rowIndx : rowIndxPage + this.getRowIndxOffset(), - column = (obj.column) ? obj.column : this.colModel[colIndx], - $cell = (obj.$cell) ? obj.$cell : this.$div_focus; - if (column.getEditCellData) { - var dataCell = column.getEditCellData({ - $cell: $cell, - data: this.data, - dataIndx: column.dataIndx, - dataModel: this.dataModel, - rowIndx: rowIndx, - rowIndxPage: rowIndxPage, - colIndx: colIndx - }); - } else { - var dataCell = $cell.children().html(); - } - return dataCell; - } - fn.getCellIndices = function($td) { - if ($td == null || $td.length == 0) - return { - rowIndxPage: null, - colIndx: null - }; - var $tr = $td.parent("tr"); - var $tbl = $tr.parent("tbody"); - var rowIndxPage = parseInt($tr.attr("pq-row-indx")); - var colIndx = parseInt($td.attr("pq-col-indx")); - return { - rowIndxPage: rowIndxPage, - colIndx: colIndx - } - } - fn._incrRowIndx = function(rowIndxPage, noRows) { - var newRowIndx = rowIndxPage, - noRows = (noRows == null) ? 1 : noRows, - counter = 0; - for (var i = rowIndxPage + 1, len = this.data.length; i < len; i++) { - var hidden = this._getRowPQData(i, "hidden"); - if (!hidden) { - counter++; - newRowIndx = i; - if (counter == noRows) { - return newRowIndx; - } - } - } - return newRowIndx; - } - fn._decrRowIndx = function(rowIndxPage, noRows) { - var newRowIndx = rowIndxPage, - noRows = (noRows == null) ? 1 : noRows, - counter = 0; - for (var i = rowIndxPage - 1; i >= 0; i--) { - var hidden = this._getRowPQData(i, "hidden"); - if (!hidden) { - counter++; - newRowIndx = i; - if (counter == noRows) { - return newRowIndx; - } - } - } - return newRowIndx; - } - fn._incrIndx = function(rowIndxPage, colIndx) { - var that = this; - if (colIndx == null) { - if (rowIndxPage == this._getLastVisibleRowIndxPage(this.data)) { - return null; - } - rowIndxPage = this._incrRowIndx(rowIndxPage); - return {rowIndxPage: rowIndxPage}; - } - var column; - do { - colIndx++; - if (colIndx >= that.colModel.length) { - if (rowIndxPage == this._getLastVisibleRowIndxPage(this.data)) { - return null; - } - rowIndxPage = this._incrRowIndx(rowIndxPage); - colIndx = 0; - } - column = that.colModel[colIndx]; - } while (column && column.hidden); - return {rowIndxPage: rowIndxPage, colIndx: colIndx}; - } - fn._decrIndx = function(rowIndxPage, colIndx) { - var that = this; - if (colIndx == null) { - if (rowIndxPage == this._getFirstVisibleRowIndxPage(this.data)) { - return null; - } - rowIndxPage = this._decrRowIndx(rowIndxPage); - return {rowIndxPage: rowIndxPage}; - } - var column; - do { - colIndx--; - if (colIndx < 0) { - if (rowIndxPage == this._getFirstVisibleRowIndxPage(this.data)) { - return null; - } - rowIndxPage = this._decrRowIndx(rowIndxPage); - colIndx = that.colModel.length - 1; - } - column = that.colModel[colIndx]; - } while (column && column.hidden); - return {rowIndxPage: rowIndxPage, colIndx: colIndx}; - } - fn._incrEditIndx = function(rowIndxPage, colIndx) { - var that = this; - var column; - do { - colIndx++; - if (colIndx >= that.colModel.length) { - if (rowIndxPage == this._getLastVisibleRowIndxPage(this.data)) { - return null; - } - rowIndxPage = this._incrRowIndx(rowIndxPage); - colIndx = 0; - } - column = that.colModel[colIndx]; - } while (column && (column.hidden || column.editable === false)); - return {rowIndxPage: rowIndxPage, colIndx: colIndx}; - } - fn._decrEditIndx = function(rowIndxPage, colIndx) { - var that = this; - var column; - do { - colIndx--; - if (colIndx < 0) { - if (rowIndxPage == this._getFirstVisibleRowIndxPage(this.data)) { - return null; - } - rowIndxPage = this._decrRowIndx(rowIndxPage); - colIndx = that.colModel.length - 1; - } - column = that.colModel[colIndx]; - } while (column && (column.hidden || column.editable === false)); - return {rowIndxPage: rowIndxPage, colIndx: colIndx}; - } - fn.addColumn = function(column, columnData) { - var thisOptions = this.options, - thisOptionsColModel = thisOptions.colModel, - data = thisOptions.dataModel.data; - thisOptionsColModel.push(column); - this._refreshHeader(); - for (var i = 0; i < data.length; i++) { - var rowData = data[i]; - rowData.push(""); - } - } - fn.keyPressDown = function(evt) { - var that = this, - selectedCells = this.sCells.getSelection(), - selectedRows = this.sRows.getSelection(), - offset = that.getRowIndxOffset(), - selectionModel = that.options.selectionModel, - rowIndx, colIndx; - var keyCodes = { - left: 37, - up: 38, - right: 39, - down: 40, - tab: 9, - enter: 13, - pageDown: 34, - pageUp: 33, - spaceBar: 32, - esc: 27, - home: 36, - end: 35 - } - if (that.$td_edit) { - var $td = $(that.$td_edit[0]); - var obj = that.getCellIndices($td), - rowIndxPage = obj.rowIndxPage, - rowIndx = rowIndxPage + offset, - colIndx = obj.colIndx, - column = this.colModel[colIndx], - colSaveKey = (column.editModel) ? column.editModel.saveKey : null; - if (that._trigger("cellEditKeyDown", evt, { - dataModel: this.dataModel, - $cell: this.$div_focus, - rowIndx: rowIndx, - rowIndxPage: rowIndxPage, - colIndx: colIndx, - $td: $td, - column: that.colModel[colIndx] - }) == false) { - return false; - } - ; - if (evt.keyCode == keyCodes.tab) { - var obj; - if (evt.shiftKey) { - obj = that._decrEditIndx(rowIndxPage, colIndx); - } else { - obj = that._incrEditIndx(rowIndxPage, colIndx); - } - that.saveEditCell(); - if (obj == null) { - evt.preventDefault(); - return false; - } - that.quitEditMode(evt); - if (this.options.selectionModel.type == 'row') { - if (obj.rowIndxPage != rowIndxPage) { - that._setSelection(null); - that._setSelection({ - rowIndxPage: obj.rowIndxPage - }); - } - that._bringCellIntoView({rowIndxPage: obj.rowIndxPage, colIndx: obj.colIndx}); - } - else - if ((obj.rowIndxPage != rowIndxPage || obj.colIndx != colIndx) && this.options.selectionModel.type == 'cell') { - that._setSelection(null); - that._setSelection({ - rowIndxPage: obj.rowIndxPage, - colIndx: obj.colIndx - }); - } - rowIndxPage = obj.rowIndxPage; - colIndx = obj.colIndx; - var $td2 = this.getCell({rowIndxPage: obj.rowIndxPage, colIndx: obj.colIndx}); - if ($td2 && $td2.length > 0) - this._editCell($td2); - evt.preventDefault(); - return false; - } else if (evt.keyCode == colSaveKey) { - that.saveEditCell(); - that.quitEditMode(evt); - } else if (colSaveKey == null && evt.keyCode == this.options.editModel.saveKey) { - that.saveEditCell(); - that.quitEditMode(evt); - } else if (evt.keyCode == keyCodes.esc) { - that.quitEditMode(evt); - evt.preventDefault(); - return false; - } - else if (evt.keyCode == keyCodes.pageUp || evt.keyCode == keyCodes.pageDown) { - evt.preventDefault(); - return false; - } - return; - } - else if (selectedRows.length > 0 && selectionModel.type == 'row') { - var obj = selectedRows[selectedRows.length - 1], - rowIndx = obj.rowIndx, rowIndxPage = rowIndx - offset; - } - else { - if (selectedCells.length > 0 && selectionModel.type == 'cell') { - var obj = selectedCells[selectedCells.length - 1], - rowIndx = obj.rowIndx, - rowIndxPage = rowIndx - offset, - dataIndx = obj.dataIndx, - colIndx = this.getColIndxFromDataIndx(dataIndx); - if (rowIndx == null || colIndx == null) - return; - that._trigger("cellKeyDown", evt, { - dataModel: this.dataModel, - rowIndx: rowIndx, - colIndx: colIndx, - $td: obj.$td, - column: that.colModel[colIndx] - }); - if (evt.cancelBubble) { - return; - } - } - else { - return; - } - } - if (evt.keyCode == keyCodes.left) { - var obj = that._decrIndx(rowIndxPage, colIndx); - if (obj) - that._setSelection({rowIndxPage: obj.rowIndxPage, colIndx: obj.colIndx, evt: evt}); - evt.preventDefault(); - return; - } else if (evt.keyCode == keyCodes.right) { - var obj = that._incrIndx(rowIndxPage, colIndx); - if (obj) - that._setSelection({rowIndxPage: obj.rowIndxPage, colIndx: obj.colIndx, evt: evt}); - evt.preventDefault(); - return; - } else if (evt.keyCode == keyCodes.tab) { - var obj; - if (evt.shiftKey) { - obj = that._decrIndx(rowIndxPage, colIndx); - } else { - obj = that._incrIndx(rowIndxPage, colIndx); - } - if (obj) - that._setSelection({rowIndxPage: obj.rowIndxPage, colIndx: obj.colIndx, evt: evt}); - evt.preventDefault(); - return; - } else if (evt.keyCode == keyCodes.up) { - rowIndxPage = that._decrRowIndx(rowIndxPage); - if (obj) - that._setSelection({rowIndxPage: rowIndxPage, colIndx: colIndx, evt: evt}); - evt.preventDefault(); - return; - } else if (evt.keyCode == keyCodes.down) { - rowIndxPage = that._incrRowIndx(rowIndxPage); - if (obj) - that._setSelection({rowIndxPage: rowIndxPage, colIndx: colIndx, evt: evt}); - evt.preventDefault(); - return; - } else if (evt.keyCode == keyCodes.pageDown || evt.keyCode == keyCodes.spaceBar) { - var rowIndx = this._incrRowIndx(rowIndxPage, this.pageSize + 1) + offset; - that._setSelection({rowIndx: rowIndx, colIndx: colIndx, evt: evt}); - evt.preventDefault(); - return; - } else if (evt.keyCode == keyCodes.pageUp) { - var rowIndx = this._decrRowIndx(rowIndxPage, this.pageSize + 1) + offset; - that._setSelection({rowIndx: rowIndx, colIndx: colIndx, evt: evt}); - evt.preventDefault(); - return; - } else if (evt.keyCode == keyCodes.home) { - rowIndx = 0 + offset; - that._setSelection({rowIndx: rowIndx, colIndx: colIndx, evt: evt}); - evt.preventDefault(); - return; - } else if (evt.keyCode == keyCodes.end) { - rowIndx = that.data.length - 1 + offset; - that._setSelection({rowIndx: rowIndx, colIndx: colIndx, evt: evt}); - evt.preventDefault(); - return; - } else if (evt.keyCode == keyCodes.enter) { - if (this.options.selectionModel.type == 'row') { - var $tr, $td; - if (selectedRows.length > 0) { - that._editFirstCellInRow({rowIndxPage: rowIndxPage}); - } - } - else { - if (selectedCells.length > 0) { - var $td = this.getCell({rowIndxPage: rowIndxPage, colIndx: colIndx}); - if ($td && $td.length > 0) { - if (this.isEditableCell({colIndx: colIndx})) { - that._editCell($td); - } - } - } - } - evt.preventDefault(); - return; - } else { - } - } - fn._calcNumHiddenFrozens = function() { - var num_hidden = 0; - for (var i = 0; i < this.freezeCols; i++) { - if (this.colModel[i].hidden) { - num_hidden++; - } - } - return num_hidden; - } - fn._calcNumHiddenUnFrozens = function(colIndx) { - var num_hidden = 0; - var len = (colIndx != null) ? colIndx : this.colModel.length; - for (var i = this.freezeCols; i < len; i++) { - if (this.colModel[i].hidden) { - num_hidden++; - } - } - return num_hidden; - } - fn._setScrollHLength = function() { - if (!this.options.scrollModel.horizontal) { - this.$hscroll.css("visibility", "hidden"); - this.$hvscroll.css("visibility", "hidden"); - return; - } - else { - this.$hscroll.css("visibility", ""); - this.$hvscroll.css("visibility", ""); - } - var wd = this.$cont[0].offsetWidth; - if (this.numberCell) { - wd -= this.numberCell_outerWidth; - } - var thisColModel = this.colModel; - for (var i = 0; i < this.freezeCols; i++) { - var column = thisColModel[i]; - if (!column.hidden) { - wd -= this.outerWidths[i]; - } - } - var wdSB = this._getScollBarVerticalWidth(); - if (wdSB == 0) { - this.$hscroll.css("right", 0); - } else { - this.$hscroll.css("right", ""); - } - wd -= wdSB; - this.$hscroll.pqScrollBar("option", "length", wd); - } - fn._setScrollHNumEles = function() { - var data_length = this.colModel.length - this.freezeCols - this._calcNumHiddenUnFrozens(); - this.$hscroll.pqScrollBar("option", "num_eles", (data_length)); - } - fn._getScollBarHorizontalHeight = function() { - var htSB = 17; - if (this.$hscroll.css("visibility") == "hidden" || this.options.scrollModel.horizontal == false - || this.$hscroll.css("display") == "none") { - htSB = 0; - } - return htSB; - } - fn._getScollBarVerticalWidth = function() { - var wdSB = 17; - if (this.$vscroll.css("visibility") == "hidden" || this.options.flexHeight - || this.$vscroll.css("display") == "none") { - wdSB = 0; - } - return wdSB; - } - fn._setScrollVNumEles = function(fullRefresh) { - var that = this, - $vscroll = this.$vscroll, - options = $vscroll.pqScrollBar("option"), - num_eles = parseInt(options.num_eles), - cur_pos = parseInt(options.cur_pos); - var htSB = this._getScollBarHorizontalHeight(); - var data = this.data; - var totalVisibleRows = data ? this._getTotalVisibleRows(data) : 0; - var htCont = this.$cont[0].offsetHeight; - var htTbl = (this.$tbl) ? this.$tbl[0].offsetHeight : 0; - if (htTbl > 0 && htTbl > htCont - htSB) { - var $trs = this.$tbl.children().children("tr"); - var ht = 0, - visibleRows = 0; - $trs.each(function(i, tr) { - ht += tr.offsetHeight; - if (ht >= htCont - htSB) { - visibleRows = (i > 1) ? (i - 1) : 0; - return false; - } - }); - num_eles = totalVisibleRows - visibleRows + 1; - } - else { - num_eles = cur_pos + 1; - } - if (num_eles < cur_pos + 1) { - num_eles = cur_pos + 1; - } - if (fullRefresh) { - that.$vscroll.pqScrollBar("option", "num_eles", num_eles); - } - else { - that.$vscroll.pqScrollBar("setNumEles", num_eles); - } - return num_eles; - } - fn._getFirstVisibleRowIndxPage = function(data) { - for (var i = 0, len = data.length; i < len; i++) { - var hidden = this._getRowPQData(i, "hidden"); - if (!hidden) { - return i; - } - } - } - fn._getLastVisibleRowIndxPage = function(data) { - for (var i = data.length - 1; i >= 0; i--) { - var hidden = this._getRowPQData(i, "hidden"); - if (!hidden) { - return i; - } - } - } - fn._getTotalVisibleRows = function(data) { - if (this.options.treeViewModel) { - var noRows = 0; - for (var i = 0, len = data.length; i < len; i++) { - var hidden = this._getRowPQData(i, "hidden"); - if (!hidden) { - noRows++; - } - } - return noRows; - } - else { - return data.length; - } - }; - fn._setScrollVLength = function() { - var cont_ht = this.$cont.height(); - var htSB = this._getScollBarHorizontalHeight(); - this.$vscroll.css("bottom", htSB); - var len = (cont_ht - htSB); - this.$vscroll.pqScrollBar("option", "length", len); - return; - }; - fn._setInnerGridHeight = function() { - if (this.options.flexHeight) - return; - var ht = (this.element.height() - - ((this.options.topVisible) ? this.$top[0].offsetHeight : 0) - - ((this.options.bottomVisible) ? this.$bottom[0].offsetHeight : 0) - ); - this.$grid_inner.height(ht + "px"); - }; - fn._setRightGridHeight = function() { - this.$header_o.height(this.$header_left.height() - 2); - if (this.options.flexHeight) - return; - this.$vscroll.css("visibility", ""); - if (this.$tbl) - this.$tbl.css("marginBottom", 0); - var ht = (this.element.height() - this.$header_o[0].offsetHeight - - ((this.options.topVisible) ? this.$top[0].offsetHeight : 0) - - ((this.options.bottomVisible) ? this.$bottom[0].offsetHeight : 0)); - var ht_contFixed = 0; - this.$cont.height((ht - ht_contFixed) + "px"); - }; - fn.setGridHeightFromTable = function() { - var htTbl = 0; - var htSB = this._getScollBarHorizontalHeight(); - if (this.$tbl) { - htTbl = (this.$tbl[0].offsetHeight - 1); - this.$tbl.css("marginBottom", htSB); - } - else { - htTbl = 22; - } - var htCombined = htTbl + htSB; - this.$cont.height(""); - this.element.height(""); - this.$grid_inner.height(""); - this.$vscroll.css("visibility", "hidden"); - }; - fn._setGridWidthFromTable = function() { - var wdSB = 17; - if (this.$vscroll.css("visibility") == "hidden" || this.$vscroll.css("display") == "none") { - wdSB = 0; - } - if (this.$tbl) { - this.element.width((this.$tbl[0].scrollWidth + wdSB) + "px"); - } - else { - var wd_tbl = this.$header_left.find("table")[0].scrollWidth; - this.element.width((wd_tbl) + "px"); - } - }; - fn._setRightGridWidth = function() { - }; - fn._bufferObj_getInit = function() { - return this.init; - }; - fn._bufferObj_getFinal = function() { - return this["final"]; - }; - fn._bufferObj_minRowsPerGrid = function() { - var ht = this.$cont[0].offsetHeight; - return Math.ceil(ht / this.rowHeight); - }; - fn._calcCurPosFromRowIndxPage = function(rowIndxPage) { - if (!this.options.treeViewModel) { - return rowIndxPage; - } - var cur_pos = 0; - for (var i = 0, len = this.data.length; i < len; i++) { - if (i == rowIndxPage) { - break; - } - var hidden = this._getRowPQData(i, "hidden"); - if (!hidden) { - cur_pos++; - } - } - return cur_pos; - }; - fn._bufferObj_calcInitFinal = function() { - var data = this.data; - if (data == null || data.length == 0) { - this['final'] = this['init'] = null; - } - else if (this.options.flexHeight) { - this.init = 0; - this['final'] = data.length - 1; - } - else { - var cur_pos = parseInt(this.$vscroll.pqScrollBar("option", "cur_pos")); - this.scrollCurPos = parseInt(cur_pos); - if (isNaN(cur_pos) || cur_pos < 0) { - this.init = 0; - } - else { - this.init = cur_pos; - } - if (this.init + 1 > data.length) { - this.init = data.length - 1; - } - var noRows = this._bufferObj_minRowsPerGrid(); - this.pageSize = noRows; - this['final'] = this.init + noRows; - if (this['final'] + 1 > data.length) { - this['final'] = data.length - 1; - } - } - }; - fn._bufferObj_calcInitFinalH = function() { - var cur_pos = parseInt(this.$hscroll.pqScrollBar("option", "cur_pos")); - var initH = 0; - var indx = 0, - thisColModel = this.colModel; - for (var i = this.freezeCols, len = thisColModel.length; i < len; i++) { - if (thisColModel[i].hidden) { - initH++; - } else if (indx == cur_pos) { - break; - } else { - initH++; - indx++; - } - } - this.initH = initH; - } - fn._calcWidthCols = function(colIndx) { - var wd = 0; - if (this.numberCell) { - wd += this.numberCell_outerWidth; - } - for (var i = 0; i <= colIndx; i++) { - if (!this.colModel[i].hidden) - wd += this.outerWidths[i]; - } - return wd; - } - fn._calcRightEdgeCol = function(colIndx) { - var wd = 0, - cols = 0; - if (this.numberCell) { - wd += this.numberCell_outerWidth; - cols++; - } - for (var i = 0; i <= colIndx; i++) { - if (!this.colModel[i].hidden && this.hidearrHS[i] == false) { - wd += this.outerWidths[i]; - cols++; - } - } - return {width: wd, cols: cols}; - } - fn._getDragHelper = function(evt) { - var $target = $(evt.currentTarget); - this.$cl = $("
").appendTo(this.$grid_inner); - this.$clleft = $("
").appendTo(this.$grid_inner); - var indx = parseInt($target.attr("pq-grid-col-indx")); - var ht = this.$grid_inner.outerHeight(); - this.$cl.height(ht); - this.$clleft.height(ht); - var ele = $("td[pq-grid-col-indx=" + indx + "]", this.$header)[0]; - var lft = ele.offsetLeft + ((indx > this.options.freezeCols) ? parseInt(this.$header[1].style.left) : 0); - this.$clleft.css({ - left: lft - }); - lft = lft + ele.offsetWidth; - this.$cl.css({ - left: lft - }); - } - fn._setDragLimits = function(indx) { - var that = this; - var $head = that.$header_left; - if (indx >= this.options.freezeCols) { - $head = that.$header_right; - } - var $pQuery_drag = $head.find("div.pq-grid-col-resize-handle[pq-grid-col-indx=" + indx + "]"); - var $pQuery_col = $head.find("td.pq-grid-col[pq-grid-col-indx=" + indx + "]"); - var cont_left = $pQuery_col.offset().left + that.minWidth; - var wdSB = 17; - if (this.options.flexHeight || this.$vscroll.css("visibility") == "hidden") { - wdSB = 0; - } - var cont_right = that.$cont.offset().left + that.$cont[0].offsetWidth - wdSB + 20; - $pQuery_drag.draggable("option", 'containment', [cont_left, 0, cont_right, 0]); - } - fn._getOrderIndx = function(indx) { - var columnOrder = this.options.columnOrder; - if (columnOrder != null) { - return columnOrder[indx]; - } - else { - return indx; - } - } - fn.nestedCols = function(colMarr, _depth, _hidden) { - var len = colMarr.length; - var arr = []; - if (_depth == null) - _depth = 1; - var new_depth = _depth, colSpan = 0, width = 0, childCount = 0; - for (var i = 0; i < len; i++) { - var colM = colMarr[i]; - if (_hidden == true) { - colM.hidden = _hidden; - } - if (colM.colModel != null) { - var obj = this.nestedCols(colM.colModel, _depth + 1, colM.hidden); - arr = arr.concat(obj.colModel); - if (obj.colSpan > 0) { - if (obj.depth > new_depth) { - new_depth = obj.depth; - } - colM.colSpan = obj.colSpan; - colSpan += obj.colSpan; - } - else { - colM.colSpan = 0; - colM.hidden = true; - } - colM.childCount = obj.childCount; - childCount += obj.childCount; - } - else { - if (colM.hidden) { - colM.colSpan = 0; - } - else { - colM.colSpan = 1; - colSpan++; - } - colM.childCount = 0; - childCount++; - arr.push(colM); - } - } - return {depth: new_depth, colModel: arr, colSpan: colSpan, width: width, childCount: childCount}; - }; - fn.getHeadersCells = function() { - var optColModel = this.options.colModel, - thisColModelLength = this.colModel.length, - depth = this.depth; - var arr = []; - for (var row = 0; row < depth; row++) { - arr[row] = []; - var k = 0; - var colSpanSum = 0, childCountSum = 0; - for (var col = 0; col < thisColModelLength; col++) { - var colModel; - if (row == 0) { - colModel = optColModel[k]; - } - else { - var parentColModel = arr[row - 1][col]; - var children = parentColModel.colModel; - if (children == null) { - colModel = parentColModel; - } - else { - var diff = (col - parentColModel.leftPos); - var colSpanSum2 = 0, childCountSum2 = 0; - var tt = 0; - for (var t = 0; t < children.length; t++) { - childCountSum2 += (children[t].childCount > 0) ? children[t].childCount : 1; - if (diff < childCountSum2) { - tt = t; - break; - } - } - colModel = children[tt]; - } - } - var childCount = (colModel.childCount) ? colModel.childCount : 1; - if (col == childCountSum) { - colModel.leftPos = col; - arr[row][col] = colModel; - childCountSum += childCount; - if (optColModel[k + 1]) { - k++; - } - } - else { - arr[row][col] = arr[row][col - 1]; - } - } - } - this.headerCells = arr; - return arr; - } - fn.assignRowSpan = function() { - var optColModel = this.options.colModel, - thisColModelLength = this.colModel.length, - headerCells = this.headerCells, - depth = this.depth; - for (var col = 0; col < thisColModelLength; col++) { - for (var row = 0; row < depth; row++) { - var colModel = headerCells[row][col]; - if (col > 0 && colModel == headerCells[row][col - 1]) { - continue; - } - else if (row > 0 && colModel == headerCells[row - 1][col]) { - continue; - } - var rowSpan = 1; - for (var row2 = row + 1; row2 < depth; row2++) { - var colModel2 = headerCells[row2][col]; - if (colModel == colModel2) { - rowSpan++; - } - } - colModel.rowSpan = rowSpan; - } - } - return headerCells; - } - fn._refreshHeader = function() { - var obj = this.nestedCols(this.options.colModel); - this.colModel = obj.colModel; - this.depth = obj.depth; - this.getHeadersCells(); - this.assignRowSpan(); - } - fn._refreshWidths = function() { - var that = this; - $(this.colModel).each(function(i, col) { - if (col.width != undefined) { - var wd = parseInt(col.width) - if (wd < that.minWidth) { - wd = that.minWidth; - col.width = wd; - } - } else { - col.width = that.minWidth; - } - }); - } - fn._createHeader = function() { - var that = this; - var str = ""; - var hidearrHS1 = []; - var thisOptions = this.options, - optColModel = thisOptions.colModel, - optColModelLength = optColModel.length, - thisColModel = this.colModel, - thisColModelLength = thisColModel.length, - depth = this.depth, - columnBorders = thisOptions.columnBorders, - headerCells = this.headerCells; - if (depth >= 1) { - str += ""; - if (this.numberCell) { - str += ""; - } - for (var col = 0; col < thisColModelLength; col++) { - var column = thisColModel[col]; - if (column.hidden) { - continue; - } - var wd = parseInt(column.width) + ((columnBorders) ? 1 : 0); - str += ""; - } - str += ""; - } - for (var row = 0; row < depth; row++) { - str += ""; - if (row == 0 && this.numberCell) { - str += ""; - } - for (var col = 0; col < thisColModelLength; col++) { - var column = headerCells[row][col]; - var colSpan = column.colSpan; - if (row > 0 && column == headerCells[row - 1][col]) { - continue; - } - else if (col > 0 && column == headerCells[row][col - 1]) { - continue; - } - if (column.hidden) { - continue; - } - var cls = "pq-grid-col"; - if (column.align == "right") { - cls += ' pq-align-right'; - } - else - if (column.align == "center") { - cls += ' pq-align-center'; - } - if (col == that.freezeCols - 1 && depth == 1) { - cls += " pq-last-freeze-col"; - } - var colIndx = "", dataIndx = ""; - if (column.colModel == null) { - colIndx = "pq-grid-col-indx='" + col + "'"; - } - str += ""; - } - str += ""; - } - str += "
\ -
 
\ -
" + - column.title + - " 
"; - this.$header.empty(); - this.$header.append(str); - var $header_left = $(this.$header[0]); - var $header_right = $(this.$header[1]); - var freezeCols = parseInt(this.options.freezeCols); - var wd = this._calcWidthCols(freezeCols - 1); - $header_left.css({width: wd, zIndex: 1}); - var lft = 0; - for (var i = freezeCols; i < (this.initH + freezeCols); i++) { - var column = thisColModel[i]; - if (column.hidden) { - continue; - } - var oW = this.outerWidths[i]; - if (oW == null) { - throw("Assert: unknown width"); - } - lft += oW; - } - $header_right.css({left: "-" + lft + "px"}); - this.$header.find("td").click(function() { - if (!that.options.sortable) { - return; - } - var colIndx = $(this).attr("pq-grid-col-indx"); - if (colIndx == null) { - return; - } - var column = that.colModel[colIndx]; - if (column.sortable == false) { - return; - } - var dataIndx = column.dataIndx; - if (that._trigger("beforeSort", null, { - dataModel: that.dataModel, - data: that.data, - sortIndx: dataIndx - }) == false) { - return; - } - var dir = "up"; - var DM = that.options.dataModel; - if (DM.sortIndx == dataIndx) { - dir = (DM.sortDir == "up") ? "down" : "up"; - } - DM.sortIndx = dataIndx; - DM.sortDir = dir; - that._refreshSortingDataAndView({ - sorting: true, - keepSelection: true, - fn: function() { - that._trigger("sort", null, { - dataModel: that.dataModel, - data: that.data - }); - } - }); - }) - var lft = 0; - var hd_ht = that.$header[0].offsetHeight; - var direction = this.options.direction; - for (var i = 0; i < this.colModel.length; i++) { - var colModel = that.colModel[i]; - if (that.hidearrHS[i]) { - continue; - } else if (colModel.hidden) { - continue; - } - if (colModel.resizable != undefined && colModel.resizable == false) { - continue; - } - var $head = that.$header_left; - if (i >= that.options.freezeCols) { - $head = that.$header_right; - } - var $handle = $("
 
") - .appendTo($head); - var pq_col = that.$header_right.find("td[pq-grid-col-indx=" + i + "]")[0]; - lft = parseInt(pq_col.offsetLeft) + parseInt((direction == "rtl") ? 0 : (pq_col.offsetWidth - 10)); - $handle.css({ - left: lft, - height: hd_ht - }); - } - var drag_left, drag_new_left, cl_left; - var $pQuery_handles = that.$header.find(".pq-grid-col-resize-handle").draggable({ - axis: 'x', - helper: function(evt, ui) { - var $target = $(evt.target) - var indx = parseInt($target.attr("pq-grid-col-indx")); - that._setDragLimits(indx); - that._getDragHelper(evt, ui); - return $target; - }, - start: function(evt, ui) { - drag_left = ui.position.left; - cl_left = parseInt(that.$cl[0].style.left); - }, - drag: function(evt, ui) { - drag_new_left = ui.position.left; - var dx = (drag_new_left - drag_left); - that.$cl[0].style.left = cl_left + dx + "px"; - }, - stop: function(evt, ui) { - that.$clleft.remove(); - that.$cl.remove(); - drag_new_left = ui.position.left; - var dx = (drag_new_left - drag_left); - var $target = $(ui.helper); - var colIndx = parseInt($target.attr("pq-grid-col-indx")); - var column = that.colModel[colIndx]; - column.width = parseInt(column.width) + dx; - that._computeOuterWidths(true); - that._refresh(); - for (var i = 0; i < that.tables.length; i++) { - var $tbl = that.tables[i].$tbl; - $tbl.find("td[pq-top-col-indx='" + colIndx + "']").width(that.outerWidths[colIndx]); - } - } - }); - } - fn._refreshHeaderSortIcons = function() { - var DM = this.options.dataModel; - if (DM.sortIndx == undefined) - return; - var $pQuery_cols = this.$header.find(".pq-grid-col"); - $pQuery_cols.removeClass("pq-col-sort-asc pq-col-sort-desc ui-state-active"); - var sortIndx = DM.sortIndx; - var colIndx = this.getColIndxFromDataIndx(sortIndx); - var addClass = "ui-state-active pq-col-sort-" + (DM.sortDir == "up" ? "asc" : "desc") - this.$header.find(".pq-grid-col[pq-grid-col-indx=" + colIndx + "]").addClass(addClass) - } - fn._generateSummaryRow = function(rowData, rowIndx, thisColModel, noColumns, hidearrHS1, offset, const_cls, buffer) { - var row_cls = "pq-summary-row", - row_str = "", - columnBorders = this.options.columBorders; - row_str += "" - buffer.push(row_str); - if (this.numberCell) { - buffer.push("\ -
") - } - var objRender = {rowIndx: rowIndx + offset, rowIndxPage: rowIndx, rowData: rowData, summaryCell: true}; - for (var col = 0; col < noColumns; col++) { - var column = thisColModel[col], - dataIndx = column.dataIndx; - objRender.column = column; - objRender.colIndx = col; - { - var cellSelection = false; - var selectedDataIndices = rowData.selectedDataIndices; - if (selectedDataIndices) { - cellSelection = selectedDataIndices[dataIndx]; - } - } - if (column.hidden) { - continue; - } - else if (this.hidearrHS[col]) { - continue; - } - var strStyle = ""; - var cls = const_cls; - if (column.align == "right") { - cls += ' pq-align-right'; - } else if (column.align == "center") { - cls += ' pq-align-center'; - } - if (col == this.freezeCols - 1 && columnBorders) { - cls += " pq-last-freeze-col"; - } - if (column.className) { - cls = cls + " " + column.className; - } - if (cellSelection) { - cls = cls + " pq-cell-select"; - } - var valCell = (rowData[dataIndx] == null) ? "" : rowData[dataIndx]; - var str = "\ -
" + valCell + "
"; - buffer.push(str) - } - for (var k = 0; k < hidearrHS1.length; k++) { - var col = hidearrHS1[k]; - var column = thisColModel[col], - dataIndx = column.dataIndx; - ; - objRender.column = column; - objRender.colIndx = col; - var strStyle = ""; - strStyle += "visibility:hidden;"; - var cls = const_cls; - if (column.align == "right") { - cls += ' pq-align-right'; - } else if (column.align == "center") { - cls += ' pq-align-center'; - } - var valCell = (rowData[dataIndx] == null) ? "" : rowData[dataIndx]; - var str = "\ -
" + valCell + "
"; - buffer.push(str) - } - buffer.push(""); - return buffer; - } - fn.createTable = function(objP) { - this.cTable._generateTables(objP); - } - fn._refreshOtherTables = function() { - return; - var thisColModel = this.colModel, - noColumns = thisColModel.length, - columnBorders = this.options.columBorders; - for (var i = 0; i < this.tables.length; i++) { - var tblObj = this.tables[i]; - var $tbl = tblObj.$tbl, - $tr = $tbl.find("tr:first"); - for (var col = 0; col < noColumns; col++) { - var column = thisColModel[col], - dataIndx = column.dataIndx; - if (column.hidden) { - var $td = $tr.find("td[pq-dataIndx='" + dataIndx + "']"); - if ($td.length > 1) { - var $tds = $tbl.find("td[pq-dataIndx='" + dataIndx + "']").remove(); - tblObj.$tds.add($tds); - } - } - else if (this.hidearrHS[col]) { - var $td = $tr.find("td[pq-dataIndx='" + dataIndx + "']"); - if ($td.css("visibility") != "hidden") { - } - } - var strStyle = ""; - var cls = const_cls; - if (column.align == "right") { - cls += ' pq-align-right'; - } else if (column.align == "center") { - cls += ' pq-align-center'; - } - if (col == this.freezeCols - 1 && columnBorders) { - cls += " pq-last-freeze-col"; - } - if (column.className) { - cls = cls + " " + column.className; - } - if (cellSelection) { - cls = cls + " pq-cell-select"; - } - var str = "\ - " + this.cTable._renderCell(objRender) + ""; - buffer.push(str) - } - for (var k = 0; k < hidearrHS1.length; k++) { - var col = hidearrHS1[k]; - var column = thisColModel[col]; - objRender.column = column; - objRender.colIndx = col; - var strStyle = ""; - strStyle += "visibility:hidden;"; - var cls = const_cls; - if (column.align == "right") { - cls += ' pq-align-right'; - } else if (column.align == "center") { - cls += ' pq-align-center'; - } - var str = "\ - " + this.cTable._renderCell(objRender) + ""; - buffer.push(str); - } - } - }; - fn._sortLocalData = function(dataIndx, dir, dataType, data) { - var m_sort_dir = dir, - that = this; - if (data == null || data.length == 0) { - return; - } - function innerSort() { - function sort_integer(obj1, obj2) { - var val1 = obj1[dataIndx]; - var val2 = obj2[dataIndx]; - val1 = val1 ? parseInt(val1) : 0; - val2 = val2 ? parseInt(val2) : 0; - return (val1 - val2); - } - function sort_custom(obj1, obj2) { - var val1 = obj1[dataIndx]; - var val2 = obj2[dataIndx]; - return dataType(val1, val2); - } - function sort_float(obj1, obj2) { - var val1 = (obj1[dataIndx] + "").replace(/,/g, ""); - var val2 = (obj2[dataIndx] + "").replace(/,/g, ""); - val1 = val1 ? parseFloat(val1) : 0; - val2 = val2 ? parseFloat(val2) : 0; - return (val1 - val2); - } - var iter = 0; - function sort_string(obj1, obj2) { - iter++; - var val1 = obj1[dataIndx]; - var val2 = obj2[dataIndx]; - val1 = val1 ? val1 : ""; - val2 = val2 ? val2 : ""; - if (val1 > val2) { - return 1; - } else if (val1 < val2) { - return -1; - } - return 0; - } - if (dataType == "integer") { - data = data.sort(sort_integer) - } else if (dataType == "float") { - data = data.sort(sort_float) - } else if (typeof dataType == "function") { - data = data.sort(sort_custom); - } else { - data = data.sort(sort_string) - } - if (m_sort_dir == "down") { - data = data.reverse(); - } - } - $.measureTime(innerSort, "innerSort"); - } - $.widget("paramquery.pqGrid", fn); - $.paramquery.pqGrid.regional = {}; - $.paramquery.pqGrid.regional['en'] = fn._regional; - $.paramquery.pqGrid.setDefaults = function(obj) { - for (var key in obj) { - fn.options[key] = obj[key]; - } - $.widget("paramquery.pqGrid", fn); - $(".pq-grid").each(function(i, grid) { - $(grid).pqGrid("option", obj); - }) - } - $.measureTime = function(fn, nameofFunc) { - var initTime = (new Date()).getTime(); - fn(); - var finalTime = (new Date()).getTime(); - var cnt = finalTime - initTime; - } -})(jQuery); +/** + * ParamQuery Pro v2.0.4 + * + * Copyright (c) 2012-2015 Paramvir Dhindsa (http://paramquery.com) + * Released under GPL v3 license + * http://paramquery.com/license + * + */ +(function($) { + $.paramquery = $.paramquery || {}; + $.paramquery.pqgrid = $.paramquery.pqgrid || {}; + $.paramquery.xmlToArray = function(data, obj) { + var itemParent = obj.itemParent; + var itemNames = obj.itemNames; + var arr = []; + var $items = $(data).find(itemParent); + $items.each(function(i, item) { + var $item = $(item); + var arr2 = []; + $(itemNames).each(function(j, itemName) { + arr2.push($item.find(itemName).text()) + }); + arr.push(arr2) + }); + return arr + }; + $.paramquery.xmlToJson = function(data, obj) { + var itemParent = obj.itemParent; + var itemNames = obj.itemNames; + var arr = []; + var $items = $(data).find(itemParent); + $items.each(function(i, item) { + var $item = $(item); + var arr2 = {}; + for (var j = 0, len = itemNames.length; j < len; j++) { + var itemName = itemNames[j]; + arr2[itemName] = $item.find(itemName).text() + } + arr.push(arr2) + }); + return arr + }; + $.paramquery.tableToArray = function(tbl) { + var $tbl = $(tbl); + var colModel = []; + var data = []; + var cols = []; + var widths = []; + var $trfirst = $tbl.find("tr:first"); + var $trsecond = $tbl.find("tr:eq(1)"); + $trfirst.find("th,td").each(function(i, td) { + var $td = $(td); + var title = $td.html(); + var width = $td.width(); + var dataType = "string"; + var $tdsec = $trsecond.find("td:eq(" + i + ")"); + var val = $tdsec.text(); + var align = $tdsec.attr("align"); + val = val.replace(/,/g, ""); + if (parseInt(val) == val && (parseInt(val) + "").length == val.length) { + dataType = "integer" + } else { + if (parseFloat(val) == val) { + dataType = "float" + } + } + var obj = { + title: title, + width: width, + dataType: dataType, + align: align, + dataIndx: i + }; + colModel.push(obj) + }); + $tbl.find("tr").each(function(i, tr) { + if (i == 0) { + return + } + var $tr = $(tr); + var arr2 = []; + $tr.find("td").each(function(j, td) { + arr2.push($.trim($(td).html())) + }); + data.push(arr2) + }); + return { + data: data, + colModel: colModel + } + }; + $.paramquery.formatCurrency = function(val) { + val = Math.round(val * 10) / 10; + val = val + ""; + if (val.indexOf(".") == -1) { + val = val + ".0" + } + var len = val.length; + var fp = val.substring(0, len - 2), + lp = val.substring(len - 2, len), + arr = fp.match(/\d/g).reverse(), + arr2 = []; + for (var i = 0; i < arr.length; i++) { + if (i > 0 && i % 3 == 0) { + arr2.push(",") + } + arr2.push(arr[i]) + } + arr2 = arr2.reverse(); + fp = arr2.join(""); + return fp + lp + }; + $.paramquery.validation = { + is: function(type, val) { + if (type == "string" || !type) { + return true + } + type = type.substring(0, 1).toUpperCase() + type.substring(1, type.length); + return this["is" + type](val) + }, + isFloat: function(val) { + var pf = parseFloat(val); + if (!isNaN(pf) && pf == val) { + return true + } else { + return false + } + }, + isInteger: function(val) { + var pi = parseInt(val); + if (!isNaN(pi) && pi == val) { + return true + } else { + return false + } + }, + isDate: function(val) { + var pd = Date.parse(val); + if (!isNaN(pd)) { + return true + } else { + return false + } + } + } +})(jQuery); +(function($) { + var fnPG = {}; + fnPG.options = { + curPage: 0, + totalPages: 0, + totalRecords: 0, + msg: "", + rPPOptions: [10, 20, 30, 40, 50, 100], + rPP: 20 + }; + fnPG._regional = { + strDisplay: "Displaying {0} to {1} of {2} items.", + strFirstPage: "First Page", + strLastPage: "Last Page", + strNextPage: "Next Page", + strPage: "Page {0} of {1}", + strPrevPage: "Previous Page", + strRefresh: "Refresh", + strRpp: "Records per page:{0}" + }; + $.extend(fnPG.options, fnPG._regional); + fnPG._create = function() { + var that = this, + options = this.options; + this.element.addClass("pq-pager"); + this.first = $("", {}).appendTo(this.element).button({ + icons: { + primary: "ui-icon-seek-first" + }, + text: false + }).bind("click.paramquery", function(evt) { + if (that.options.curPage > 1) { + if (that._trigger("change", evt, { + curPage: 1 + }) !== false) { + that.option({ + curPage: 1 + }) + } + } + }); + this.prev = $("").appendTo(this.element).button({ + icons: { + primary: "ui-icon-seek-prev" + }, + text: false + }).bind("click", function(evt) { + if (that.options.curPage > 1) { + var curPage = that.options.curPage - 1; + if (that._trigger("change", evt, { + curPage: curPage + }) !== false) { + that.option({ + curPage: curPage + }) + } + } + }); + $("").appendTo(this.element); + this.pageHolder = $("").appendTo(this.element); + $("").appendTo(this.element); + this.next = $("").appendTo(this.element).button({ + icons: { + primary: "ui-icon-seek-next" + }, + text: false + }).bind("click", function(evt) { + var val = that.options.curPage + 1; + if (that._trigger("change", evt, { + curPage: val + }) !== false) { + that.option({ + curPage: val + }) + } + }); + this.last = $("").appendTo(this.element).button({ + icons: { + primary: "ui-icon-seek-end" + }, + text: false + }).bind("click", function(evt) { + var val = that.options.totalPages; + if (that._trigger("change", evt, { + curPage: val + }) !== false) { + that.option({ + curPage: val + }) + } + }); + $("").appendTo(this.element); + this.rPPHolder = $("").appendTo(this.element); + this.$refresh = $("").appendTo(this.element).button({ + icons: { + primary: "ui-icon-refresh" + }, + text: false + }).bind("click", function(evt) { + if (that._trigger("refresh", evt) !== false) {} + }); + $("").appendTo(this.element); + this.$msg = $("").appendTo(this.element); + this._refresh() + }; + fnPG._refreshPage = function() { + var that = this; + this.pageHolder.empty(); + var options = this.options, + strPage = options.strPage, + arr = strPage.split(" "), + str = []; + for (var i = 0, len = arr.length; i < len; i++) { + var ele = arr[i]; + if (ele == "{0}") { + str.push("") + } else { + if (ele == "{1}") { + str.push("") + } else { + str.push("", ele, "") + } + } + } + var str2 = str.join(""); + var $temp = $(str2).appendTo(this.pageHolder); + this.page = $temp.filter("input").bind("change", function(evt) { + var $this = $(this), + val = $this.val(); + if (isNaN(val) || val < 1) { + $this.val(options.curPage); + return false + } + val = parseInt(val); + if (val > options.totalPages) { + $this.val(options.curPage); + return false + } + if (that._trigger("change", evt, { + curPage: val + }) !== false) { + that.option({ + curPage: val + }) + } else { + $this.val(options.curPage); + return false + } + }); + this.$total = $temp.filter("span.total") + }; + fnPG._refresh = function() { + this._refreshPage(); + var $rPP = this.$rPP, + that = this, + options = this.options; + this.first.attr("title", options.strFirstPage); + this.prev.attr("title", options.strPrevPage); + this.next.attr("title", options.strNextPage); + this.last.attr("title", options.strLastPage); + this.$refresh.attr("title", options.strRefresh); + this.rPPHolder.empty(); + if (options.strRpp) { + var opts = options.rPPOptions, + strRpp = options.strRpp; + if (strRpp.indexOf("{0}") != -1) { + var selectArr = [""); + var selectStr = selectArr.join(""); + strRpp = strRpp.replace("{0}", "" + selectStr); + strRpp = "" + strRpp + "" + } else { + strRpp = "" + strRpp + "" + } + this.$rPP = $(strRpp).appendTo(this.rPPHolder).filter("select").val(options.rPP).change(function(evt) { + var val = $(this).val(); + if (that._trigger("change", evt, { + rPP: val + }) !== false) { + that.options.rPP = val; + return false + } + }) + } + if (options.curPage >= options.totalPages) { + this.next.button({ + disabled: true + }); + this.last.button({ + disabled: true + }) + } else { + this.next.button({ + disabled: false + }); + this.last.button({ + disabled: false + }) + } if (options.curPage <= 1) { + this.first.button({ + disabled: true + }); + this.prev.button({ + disabled: true + }) + } else { + this.first.button({ + disabled: false + }); + this.prev.button({ + disabled: false + }) + } + this.page.val(options.curPage); + this.$total.text(options.totalPages); + if (this.options.totalRecords > 0) { + var rPP = options.rPP; + var curPage = options.curPage; + var totalRecords = options.totalRecords; + var begIndx = (curPage - 1) * rPP; + var endIndx = curPage * rPP; + if (endIndx > totalRecords) { + endIndx = totalRecords + } + var strDisplay = options.strDisplay; + strDisplay = strDisplay.replace("{0}", begIndx + 1); + strDisplay = strDisplay.replace("{1}", endIndx); + strDisplay = strDisplay.replace("{2}", totalRecords); + this.$msg.html(strDisplay) + } else { + this.$msg.html("") + } + }; + fnPG._destroy = function() { + this.element.empty().removeClass("pq-pager").enableSelection() + }; + fnPG._setOption = function(key, value) { + if (key == "curPage" || key == "totalPages") { + value = parseInt(value) + } + $.Widget.prototype._setOption.call(this, key, value) + }; + fnPG._setOptions = function() { + $.Widget.prototype._setOptions.apply(this, arguments); + this._refresh() + }; + $.widget("paramquery.pqPager", fnPG); + $.paramquery.pqPager.regional = {}; + $.paramquery.pqPager.regional.en = fnPG._regional; + $.paramquery.pqPager.setDefaults = function(obj) { + for (var key in obj) { + fnPG.options[key] = obj[key] + } + $.widget("paramquery.pqPager", fnPG); + $(".pq-pager").each(function(i, pager) { + $(pager).pqPager("option", obj) + }) + } +})(jQuery); +(function($) { + var fnSB = {}; + fnSB.options = { + length: 200, + num_eles: 3, + cur_pos: 0, + timeout: 350, + pace: "optimum", + direction: "vertical", + theme: false + }; + fnSB._destroy = function() { + this.element.removeClass("pq-sb-vert pq-sb-vert-t pq-sb-vert-wt").enableSelection().removeClass("pq-sb-horiz pq-sb-horiz-t pq-sb-horiz-wt").unbind("click.pq-scrollbar").empty(); + this.element.removeData() + }; + fnSB._create = function() { + this._createLayout() + }; + fnSB._createLayout = function() { + var that = this, + options = this.options, + direction = options.direction, + theme = options.theme; + var ele = this.element.empty(); + if (direction == "vertical") { + ele.removeClass("pq-sb-vert-t pq-sb-vert-wt").addClass("pq-sb-vert"); + if (theme) { + ele.addClass("pq-sb-vert-t"); + ele.html(["
", "
", "
", "
", "
", "
"].join("")) + } else { + ele.addClass("pq-sb-vert-wt"); + ele.html(["
", "
", "
", "
", "
", "
", "
", "
", "
"].join("")) + } + } else { + ele.removeClass("pq-sb-horiz-t pq-sb-horiz-wt").addClass("pq-sb-horiz"); + if (theme) { + ele.addClass("pq-sb-horiz-t"); + ele.html(["
", "
", "
", "
", "
", "
"].join("")) + } else { + ele.addClass("pq-sb-horiz-wt"); + ele.width(this.width); + ele.html(["
", "
", "", "", "", "", "", "
", "
"].join("")) + } + } + ele.disableSelection().on("mouseup.pq-scrollbar", function(evt) { + that.sbmouseup = true + }).on("mousedown.pq-scrollbar", function(evt) { + that.sbmouseup = false; + if (options.disabled) { + return + } + if (that.$slider.is(":hidden")) { + return + } + if (direction == "vertical") { + var clickY = evt.pageY, + top_this = that.element.offset().top, + bottom_this = top_this + options.length, + $slider = that.$slider, + topSlider = $slider.offset().top, + heightSlider = $slider.height(), + botSlider = topSlider + heightSlider; + if (clickY < topSlider && clickY > top_this + 17) { + that.mousedownInterval = window.setInterval(function() { + if (that.sbmouseup || (clickY >= $slider.offset().top)) { + window.clearInterval(that.mousedownInterval); + that.mousedownInterval = null + } else { + that._pageUp(evt) + } + }, 0) + } else { + if (clickY > botSlider && clickY < bottom_this - 17) { + that.mousedownInterval = window.setInterval(function() { + if (that.sbmouseup || (clickY <= $slider.offset().top + heightSlider)) { + window.clearInterval(that.mousedownInterval); + that.mousedownInterval = null + } else { + that._pageDown(evt) + } + }, 0) + } + } + } else { + var clickX = evt.pageX, + top_this = that.element.offset().left, + bottom_this = top_this + options.length, + topSlider = that.$slider.offset().left, + botSlider = topSlider + that.$slider.width(); + if (clickX < topSlider && clickX > top_this + 17) { + that.$slider.css("left", clickX - that.element.offset().left); + that._updateCurPosAndTrigger(evt) + } else { + if (clickX > botSlider && clickX < bottom_this - 17) { + that.$slider.css("left", clickX - that.element.offset().left - that.$slider.width()); + that._updateCurPosAndTrigger(evt) + } + } + } + }); + var $slider = this.$slider = $("div.pq-sb-slider", this.element); + if (theme) { + $slider.attr("tabindex", "0") + } + this._bindSliderEvents($slider); + this.$top_btn = $("div.top-btn,div.left-btn", this.element).click(function(evt) { + if (that.options.disabled) { + return + } + that.decr_cur_pos(evt); + evt.preventDefault(); + return false + }).mousedown(function(evt) { + if (that.options.disabled) { + return + } + that.mousedownTimeout = window.setTimeout(function() { + that.mousedownInterval = window.setInterval(function() { + that.decr_cur_pos(evt) + }, 0) + }, that.options.timeout) + }).bind("mouseup mouseout", function(evt) { + if (that.options.disabled) { + return + } + that._mouseup(evt) + }); + this.$bottom_btn = $("div.bottom-btn,div.right-btn", this.element).click(function(evt) { + if (that.options.disabled) { + return + } + that.incr_cur_pos(evt); + evt.preventDefault(); + return false + }).mousedown(function(evt) { + if (that.options.disabled) { + return + } + that.mousedownTimeout = window.setTimeout(function() { + that.mousedownInterval = window.setInterval(function() { + that.incr_cur_pos(evt) + }, 0) + }, that.options.timeout) + }).bind("mouseup mouseout", function(evt) { + if (that.options.disabled) { + return + } + that._mouseup(evt) + }); + this._refresh() + }; + fnSB._bindSliderEvents = function($slider) { + var that = this, + direction = this.options.direction, + axis = "x"; + if (direction == "vertical") { + axis = "y" + } + $slider.draggable({ + axis: axis, + helper: function(evt, ui) { + that._setDragLimits(); + return this + }, + start: function(evt) { + that.topWhileDrag = null + }, + drag: function(evt) { + that.dragging = true; + var pace = that.options.pace; + if (pace == "optimum") { + that._setNormalPace(evt) + } else { + if (pace == "fast") { + that._updateCurPosAndTrigger(evt) + } + } + }, + stop: function(evt) { + that._updateCurPosAndTrigger(evt); + that.dragging = false; + that._refresh() + } + }).on("keydown", function(evt) { + var keyCode = evt.keyCode, + options = that.options, + cur_pos = options.cur_pos, + num_eles = options.num_eles, + KC = $.ui.keyCode; + if (that.keydownTimeout == null) { + that.keydownTimeout = window.setTimeout(function() { + if (keyCode == KC.DOWN || keyCode == KC.RIGHT) { + that.incr_cur_pos(evt) + } else { + if (keyCode == KC.UP || keyCode == KC.LEFT) { + that.decr_cur_pos(evt) + } else { + if (keyCode == KC.HOME) { + if (cur_pos > 0) { + options.cur_pos = 0; + that.updateSliderPos(); + that.scroll(evt) + } + } else { + if (keyCode == KC.END) { + if (cur_pos < num_eles) { + options.cur_pos = num_eles; + that.updateSliderPos(); + that.scroll(evt) + } + } else { + if (options.direction == "vertical") { + if (keyCode == KC.PAGE_DOWN) { + that._pageDown(evt) + } else { + if (keyCode == KC.PAGE_UP) { + that._pageUp(evt) + } + } + } + } + } + } + } + that.keydownTimeout = null + }, 0) + } + if (keyCode == KC.DOWN || keyCode == KC.RIGHT || keyCode == KC.UP || keyCode == KC.LEFT || keyCode == KC.PAGE_DOWN || keyCode == KC.PAGE_UP || keyCode == KC.HOME || keyCode == KC.END) { + evt.preventDefault(); + return false + } + }) + }; + fnSB.decr_cur_pos = function(evt) { + var that = this, + options = that.options; + if (options.cur_pos > 0) { + options.cur_pos--; + that.updateSliderPos(); + that.scroll(evt) + } + }; + fnSB.incr_cur_pos = function(evt) { + var that = this, + options = that.options; + if (options.cur_pos < options.num_eles - 1) { + options.cur_pos++ + } + that.updateSliderPos(); + that.scroll(evt) + }; + fnSB._mouseup = function(evt) { + if (this.options.disabled) { + return + } + var that = this; + window.clearTimeout(that.mousedownTimeout); + that.mousedownTimeout = null; + window.clearInterval(that.mousedownInterval); + that.mousedownInterval = null + }; + fnSB._setDragLimits = function() { + var thisOptions = this.options; + if (thisOptions.direction == "vertical") { + var top = this.element.offset().top + 17; + var bot = (top + thisOptions.length - 34 - this.slider_length); + this.$slider.draggable("option", "containment", [0, top, 0, bot]) + } else { + top = this.element.offset().left + 17; + bot = (top + thisOptions.length - 34 - this.slider_length); + this.$slider.draggable("option", "containment", [top, 0, bot, 0]) + } + }; + fnSB._refresh = function() { + var thisOptions = this.options; + if (thisOptions.num_eles <= 1) { + this.element.css("display", "none") + } else { + this.element.css("display", "") + } + this._validateCurPos(); + this.$slider.css("display", ""); + if (thisOptions.direction == "vertical") { + this.element.height(thisOptions.length); + this._setSliderBgLength(); + this.scroll_space = thisOptions.length - 34 - this.slider_length; + if (this.scroll_space < 4 || thisOptions.num_eles <= 1) { + this.$slider.css("display", "none") + } + this.updateSliderPos(thisOptions.cur_pos) + } else { + this.element.width(thisOptions.length); + this._setSliderBgLength(); + this.scroll_space = thisOptions.length - 34 - this.slider_length; + if (this.scroll_space < 4 || thisOptions.num_eles <= 1) { + this.$slider.css("display", "none") + } + this.updateSliderPos(thisOptions.cur_pos) + } + }; + fnSB._setSliderBgLength = function() { + var thisOptions = this.options, + theme = thisOptions.theme, + outerHeight = thisOptions.length, + innerHeight = thisOptions.num_eles * 40 + outerHeight, + avail_space = outerHeight - 34, + slider_height = avail_space * outerHeight / innerHeight, + slider_bg_ht = Math.round((slider_height - (8 + 3 + 3)) / 2); + if (slider_bg_ht < 1) { + slider_bg_ht = 1 + } + this.slider_length = 8 + 3 + 3 + 2 * slider_bg_ht; + if (thisOptions.direction == "vertical") { + if (theme) { + this.$slider.height(this.slider_length - 2) + } else { + $("div.vert-slider-bg", this.element).height(slider_bg_ht); + this.$slider.height(this.slider_length) + } + } else { + if (theme) { + this.$slider.width(this.slider_length - 2) + } else { + $(".horiz-slider-bg", this.element).width(slider_bg_ht); + this.$slider.width(this.slider_length) + } + } + }; + fnSB._updateCurPosAndTrigger = function(evt, top) { + var that = this, + thisOptions = this.options, + direction = thisOptions.direction, + $slider = that.$slider; + if (top == null) { + top = (direction == "vertical") ? parseInt($slider[0].style.top, 10) : parseInt($slider[0].style.left, 10) + } + var scroll_space = thisOptions.length - 34 - ((direction == "vertical") ? $slider[0].offsetHeight : $slider[0].offsetWidth); + var cur_pos = (top - 17) * (thisOptions.num_eles - 1) / scroll_space; + cur_pos = Math.round(cur_pos); + if (thisOptions.cur_pos != cur_pos) { + if (this.dragging) { + if (this.topWhileDrag != null) { + if (this.topWhileDrag < top && thisOptions.cur_pos > cur_pos) { + return + } else { + if (this.topWhileDrag > top && thisOptions.cur_pos < cur_pos) { + return + } + } + } + this.topWhileDrag = top + } + that.options.cur_pos = cur_pos; + this.scroll(evt) + } + }; + fnSB._setNormalPace = function(evt) { + if (this.timer) { + window.clearInterval(this.timer); + this.timer = null + } + var that = this, + thisOptions = this.options, + direction = thisOptions.direction; + that.timer = window.setInterval(function() { + var $slider = that.$slider; + var top = (direction == "vertical") ? parseInt($slider[0].style.top, 10) : parseInt($slider[0].style.left, 10); + if (that.prev_top == top) { + that._updateCurPosAndTrigger(evt, top); + window.clearInterval(that.timer); + that.timer = null + } + that.prev_top = top + }, 20) + }; + fnSB.setNumEles = function(num_eles) { + this.options.num_eles = num_eles; + this.updateSliderPos() + }; + fnSB._validateCurPos = function() { + var thisOptions = this.options; + if (thisOptions.cur_pos >= thisOptions.num_eles) { + thisOptions.cur_pos = thisOptions.num_eles - 1 + } + if (thisOptions.cur_pos < 0) { + thisOptions.cur_pos = 0 + } + }; + fnSB.updateSliderPos = function() { + var thisOptions = this.options; + var sT = (this.scroll_space * (thisOptions.cur_pos)) / (thisOptions.num_eles - 1); + if (thisOptions.direction == "vertical") { + this.$slider.css("top", 17 + sT) + } else { + this.$slider.css("left", 17 + sT) + } + }; + fnSB.scroll = function(evt) { + var thisOptions = this.options; + this._trigger("scroll", evt, { + cur_pos: thisOptions.cur_pos, + num_eles: thisOptions.num_eles + }) + }; + fnSB._pageDown = function(evt) { + this._trigger("pageDown", evt, null) + }; + fnSB._pageUp = function(evt) { + this._trigger("pageUp", evt, null) + }; + fnSB._setOption = function(key, value) { + $.Widget.prototype._setOption.call(this, key, value); + if (key == "disabled") { + if (value == true) { + this.$slider.draggable("disable") + } else { + this.$slider.draggable("enable") + } + } else { + if (key == "theme") { + this._createLayout() + } + } + }; + fnSB._setOptions = function() { + $.Widget.prototype._setOptions.apply(this, arguments); + this._refresh() + }; + $.widget("paramquery.pqScrollBar", fnSB) +})(jQuery); +(function($) { + $("body").delegate(".pq-editor-focus", "focus", function() { + $(".pq-grid").find(".pq-cont").enableSelection() + }); + $("body").delegate(".pq-editor-focus", "blur", function() { + $(".pq-grid").find(".pq-cont").disableSelection() + }); + var cClass = function() {}; + cClass.prototype.belongs = function(evt) { + if (evt.target == this.that.element[0]) { + return true + } + }; + $.paramquery.cClass = cClass; + var cGenerateView = function(that) { + this.that = that; + this.hidearrHS1 = []; + this.offset = null + }; + $.paramquery.cGenerateView = cGenerateView; + var _pGenerateView = cGenerateView.prototype; + _pGenerateView.generateView = function(objP) { + var that = this.that, + thisOptions = that.options, + virtualX = thisOptions.virtualX, + numberCell = thisOptions.numberCell, + CM = that.colModel, + initH = that.initH, + finalH = that.finalH, + GM = thisOptions.groupModel, + freezeCols = parseInt(thisOptions.freezeCols), + freezeRows = parseInt(thisOptions.freezeRows), + wd, lft; + if (objP) { + var str = this._generateTables(null, null, objP); + objP.$cont.empty(); + var $tbl = $(str); + objP.$cont.append($tbl); + if (!that.tables) { + that.tables = [] + } + var indx = -1; + for (var l = 0; l < that.tables.length; l++) { + var cont = that.tables[l].cont; + if (cont == objP.$cont[0]) { + indx = l + } + } + if (indx == -1) { + that.tables.push({ + $tbl: $tbl, + cont: objP.$cont[0] + }) + } else { + that.tables[indx].$tbl = $tbl + } + } else { + that._bufferObj_calcInitFinal(); + var init = that.init; + this.init = that.init; + var finalRow = that["final"]; + this["final"] = that["final"]; + var str2 = this._generateTables(init, finalRow, objP); + if (that.$td_edit != null) { + that.quitEditMode({ + silent: true + }) + } + that.$cont.empty(); + if (that.totalVisibleRows === 0) { + that.$cont.append("
" + thisOptions.strNoRows + "
") + } else { + if (!virtualX && (freezeCols || numberCell.show)) { + that.$cont.append("
" + str2 + "
" + str2 + "
") + } else { + that.$cont.append("
" + str2 + "
") + } + } + var $div_child = that.$cont.children("div"); + if ($div_child.length == 2) { + var $cont_l = $($div_child[0]); + var $cont_r = $($div_child[1]); + $tbl = that.$cont.children().children("table"); + that.$tbl = $tbl; + var $tbl_r = $($tbl[1]); + wd = calcWidthCols.call(that, -1, freezeCols); + $cont_l.css({ + width: wd, + zIndex: 1 + }); + lft = calcWidthCols.call(that, freezeCols, initH); + $cont_r.css({ + left: wd + "px", + width: that.$tbl[0].scrollWidth, + position: "absolute" + }); + $tbl_r.css({ + left: (-1 * (lft + wd)) + "px" + }) + } else { + $tbl = that.$tbl = that.$cont.children().children("table"); + var $cont = $($div_child[0]); + lft = calcWidthCols.call(that, freezeCols, initH); + if (!virtualX) { + $tbl.css({ + left: "-" + (lft) + "px" + }) + } + } + that._fixTableViewPort(); + that._trigger("refresh", null, { + dataModel: thisOptions.dataModel, + colModel: CM, + pageData: (GM ? that.dataGM : that.data), + initV: that.init, + finalV: that["final"], + initH: initH, + finalH: finalH + }) + } + }; + _pGenerateView._generateTables = function(init, _final, objP) { + var that = this.that, + thisColModel = that.colModel, + CMLength = thisColModel.length, + thisOptions = that.options, + virtualX = thisOptions.virtualX, + initH = that.initH, + finalH = that.finalH, + numberCell = thisOptions.numberCell, + columnBorders = thisOptions.columnBorders, + rowBorders = thisOptions.rowBorders, + SM = thisOptions.scrollModel, + GM = thisOptions.groupModel, + hidearrHS = that.hidearrHS, + freezeCols = thisOptions.freezeCols, + freezeRows = parseInt(thisOptions.freezeRows), + lastFrozenRow = false, + outerWidths = that.outerWidths, + row = 0, + finalRow = (objP) ? objP.data.length - 1 : _final, + prevGroupVal = "", + GMtrue = GM ? true : false, + TVM = thisOptions.treeModel, + data = (objP && objP.data) ? objP.data : (GMtrue ? that.dataGM : (that.data)), + offset = that.rowIndxOffset; + if (!objP && (init == null || finalRow == null)) { + that.$cont.empty(); + that.$tbl = null; + return + } + if (!objP) { + that._trigger("beforeTableView", null, { + pageData: data, + initV: init, + finalV: _final, + initH: initH, + finalH: finalH, + colModel: thisColModel + }) + } + var tblClass = "pq-grid-table "; + if (columnBorders) { + tblClass += "pq-grid-td-border-right " + } + if (rowBorders) { + tblClass += "pq-grid-td-border-bottom " + } + var buffer = [""]; + this.hidearrHS1 = []; + if (1 === 1) { + buffer.push(""); + if (numberCell.show) { + var wd = numberCell.width + 1; + buffer.push("") + } + for (var col = 0; col <= finalH; col++) { + if ((virtualX || objP) && hidearrHS[col]) { + this.hidearrHS1.push(col); + continue + } + var column = thisColModel[col]; + if (column.hidden) { + continue + } + wd = outerWidths[col]; + buffer.push("") + } + buffer.push("") + } + this.offsetRow = null; + for (var row = 0; row <= finalRow; row++) { + if (row < init && row >= freezeRows) { + row = init + } + var rowObj = data[row], + rowData = rowObj, + rowIndxPage = GMtrue ? (rowObj.rowIndx - offset) : row, + rowHidden = (rowObj) ? rowObj.pq_hidden : false; + if (rowHidden) { + continue + } + lastFrozenRow = false; + if (freezeRows && that.lastFrozenRow == row) { + lastFrozenRow = true + } + if (this.offsetRow == null && rowIndxPage != null) { + that.offsetRow = (row - rowIndxPage) + } + if (GM && rowObj.groupTitle) { + this._generateTitleRow(GM, rowObj, buffer, lastFrozenRow) + } else { + if (GM && rowObj.groupSummary) { + this._generateSummaryRow(rowObj.data, thisColModel, buffer, lastFrozenRow) + } else { + var nestedData = rowData.pq_detail, + nestedshow = false; + if (nestedData && nestedData.show) { + nestedshow = true + } + this._generateRow(rowData, rowIndxPage, thisColModel, buffer, objP, lastFrozenRow, nestedshow); + if (nestedshow) { + this._generateDetailRow(rowData, rowIndxPage, thisColModel, buffer, objP, lastFrozenRow) + } + } + } + } + that.scrollMode = false; + buffer.push("
"); + var str = buffer.join(""); + if (objP) { + objP.$cont.empty(); + var $tbl = $(str); + objP.$cont.append($tbl); + if (!that.tables) { + that.tables = [] + } + var indx = -1; + for (var l = 0; l < that.tables.length; l++) { + var cont = that.tables[l].cont; + if (cont == objP.$cont[0]) { + indx = l + } + } + if (indx == -1) { + that.tables.push({ + $tbl: $tbl, + cont: objP.$cont[0] + }) + } else { + that.tables[indx].$tbl = $tbl + } + } else {} + return str + }; + _pGenerateView._renderCell = function(objP) { + var that = this.that, + options = that.options, + DM = options.dataModel, + rowIndxPage = objP.rowIndxPage, + rowIndx = objP.rowIndx, + rowData = objP.rowData, + colIndx = objP.colIndx, + $td = objP.$td, + column = objP.column, + type = column.type, + dataIndx = column.dataIndx, + cellData = rowData[dataIndx], + wrap = objP.wrap; + if (!rowData) { + return + } + var dataCell; + if (type == "checkBoxSelection") { + dataCell = "" + } else { + if (type == "detail") { + var DTM = options.detailModel; + var hicon = (cellData && cellData.show) ? DTM.expandIcon : DTM.collapseIcon; + dataCell = "
" + } else { + if (column.render) { + dataCell = column.render.call(that.element, { + data: that.data, + dataModel: DM, + rowData: rowData, + cellData: cellData, + rowIndxPage: rowIndxPage, + rowIndx: rowIndx, + colIndx: colIndx, + column: column, + dataIndx: dataIndx + }) + } else { + dataCell = cellData + } + } + } if (dataCell === "" || dataCell == undefined) { + dataCell = " " + } + var cls = "pq-td-div"; + if (wrap == false) { + cls += " pq-wrap-text" + } + var str = "", + TVM; + if (objP.tree && (TVM = options.treeModel) && TVM.labelIndx == dataIndx) { + var isLeaf = rowData.pq_leaf, + level = rowData.pq_level, + expanded = !rowData.pq_collapse, + treeMarginLeft = (level + 1) * TVM.indent, + leafClass = ""; + if (isLeaf) { + leafClass = TVM.leafIcon + } else { + if (expanded) { + leafClass = TVM.expandIcon + " pq-tree-expand-icon" + } else { + leafClass = TVM.collapseIcon + " pq-tree-expand-icon" + } + } + var strTree = ["
", "
"].join(""); + str = "
" + strTree + dataCell + "
" + } else { + str = "
" + dataCell + "
" + } if ($td != undefined) { + $td.html(str) + } + return str + }; + _pGenerateView._generateRow = function(rowData, rowIndx, thisColModel, buffer, objP, lastFrozenRow, nestedshow) { + var row_cls = "pq-grid-row"; + if (lastFrozenRow) { + row_cls += " pq-last-freeze-row" + } + if (nestedshow) { + row_cls += " pq-detail-master" + } + var that = this.that, + thisOptions = that.options, + freezeCols = thisOptions.freezeCols, + numberCell = thisOptions.numberCell, + TVM = thisOptions.treeModel, + tree = TVM.labelIndx ? true : false, + columnBorders = thisOptions.columnBorders, + wrap = thisOptions.wrap, + CMLength = thisColModel.length, + virtualX = thisOptions.virtualX, + initH = that.initH, + finalH = that.finalH, + offset = this.offset, + hidearrHS = that.hidearrHS, + customData = thisOptions.customData; + var const_cls = "pq-grid-cell "; + if (!thisOptions.wrap || objP) { + const_cls += "pq-wrap-text " + } + var objRender = { + rowIndx: rowIndx + offset, + rowIndxPage: rowIndx, + rowData: rowData, + wrap: wrap, + customData: customData + }; + if (thisOptions.stripeRows && (rowIndx / 2 == parseInt(rowIndx / 2))) { + row_cls += " pq-grid-oddRow" + } + if (rowData.pq_rowselect) { + row_cls += " pq-row-select ui-state-highlight" + } + var cellClass; + var pq_rowcls = rowData.pq_rowcls; + var pq_cellcls = rowData.pq_cellcls; + if (pq_rowcls != null) { + row_cls += " " + pq_rowcls + } + buffer.push(""); + if (numberCell.show) { + buffer.push(["", "
", ((objP) ? " " : (rowIndx + 1)), "
"].join("")) + } + for (var col = 0; col <= finalH; col++) { + if (col < initH && col >= freezeCols && (virtualX || objP)) { + col = initH; + if (col > finalH) { + throw ("initH>finalH"); + break + } + } + var column = thisColModel[col], + dataIndx = column.dataIndx; + if (column.hidden) { + continue + } + objRender.column = column; + objRender.colIndx = col; + objRender.dataIndx = dataIndx; + var cellSelection = false; + if (1 === 1) { + var pq_cellselect = rowData.pq_cellselect; + if (pq_cellselect) { + cellSelection = pq_cellselect[dataIndx] + } + } + var strStyle = ""; + var cls = const_cls; + if (column.align == "right") { + cls += " pq-align-right" + } else { + if (column.align == "center") { + cls += " pq-align-center" + } + } if (col == freezeCols - 1 && columnBorders) { + cls += " pq-last-freeze-col" + } + if (column.cls) { + cls = cls + " " + column.cls + } + if (cellSelection) { + cls = cls + " pq-cell-select ui-state-highlight" + } + if (pq_cellcls) { + var cellClass = pq_cellcls[dataIndx]; + if (cellClass) { + cls += " " + cellClass + } + } + var indxStr = "pq-col-indx='" + col + "'"; + if (objP) { + indxStr += " pq-dataIndx='" + dataIndx + "'" + } + var colSpan = ""; + objRender.tree = tree; + var str = ["", this._renderCell(objRender), ""].join(""); + buffer.push(str) + } + buffer.push(""); + return buffer + }; + var fn = { + widgetEventPrefix: "pqgrid" + }; + fn.options = { + collapsible: true, + colModel: null, + columnBorders: true, + customData: null, + dataModel: { + cache: false, + dataType: "JSON", + location: "local", + sorting: "local", + sortDir: "up", + method: "GET" + }, + direction: "", + draggable: false, + editable: true, + editModel: { + cellBorderWidth: 1, + clicksToEdit: 1, + filterKeys: true, + keyUpDown: true, + saveKey: "", + select: false + }, + editor: { + type: "contenteditable" + }, + validation: { + icon: "ui-icon-alert", + cls: "ui-state-error" + }, + flexHeight: false, + flexWidth: false, + freezeCols: 0, + freezeRows: 0, + getDataIndicesFromColIndices: true, + height: 400, + hoverMode: "row", + minWidth: 50, + numberCell: { + width: 30, + title: "", + resizable: false, + minWidth: 30, + show: true + }, + pageModel: { + curPage: 1, + totalPages: 0, + rPP: 10, + rPPOptions: [10, 20, 50, 100] + }, + resizable: false, + roundCorners: true, + rowBorders: true, + scrollModel: { + pace: "fast", + horizontal: true, + lastColumn: "auto", + autoFit: false, + theme: false + }, + selectionModel: { + type: "row", + mode: "range" + }, + showBottom: true, + showHeader: true, + showTitle: true, + showToolbar: true, + showTop: true, + sortable: true, + sql: false, + stripeRows: true, + title: " ", + treeModel: null, + width: 600, + wrap: true + }; + fn._regional = { + strAdd: "Add", + strDelete: "Delete", + strEdit: "Edit", + strLoading: "Loading", + strNextResult: "Next Result", + strNoRows: "No rows to display.", + strNothingFound: "Nothing found", + strPrevResult: "Previous Result", + strSearch: "Search", + strSelectedmatches: "Selected {0} of {1} match(es)" + }; + $.extend(fn.options, fn._regional); + fn._destroyResizable = function() { + if (this.element.data("resizable")) { + this.element.resizable("destroy") + } + }; + fn._destroyDraggable = function() { + if (this.element.data("draggable")) { + this.element.draggable("destroy") + } + }; + fn._disable = function() { + if (this.$disable == null) { + this.$disable = $("
").css("opacity", 0.2).appendTo(this.element) + } + }; + fn._enable = function() { + if (this.$disable) { + this.element[0].removeChild(this.$disable[0]); + this.$disable = null + } + }; + fn._destroy = function() { + this._destroyResizable(); + this._destroyDraggable(); + this.element.empty(); + this.element.css("height", ""); + this.element.css("width", ""); + this.element.removeClass("pq-grid ui-widget ui-widget-content ui-corner-all").removeData() + }; + fn._findCellFromEvtCoords = function(evt) { + throw ("not in use"); + if (this.$tbl == null) { + return null + } + var $div = $(evt.target).closest(".pq-editor-border-edit"); + if ($div.length > 0) { + return null + } + var top = evt.pageY - this.$cont.offset().top; + var left = evt.pageX - this.$cont.offset().left; + var $trs = this.$tbl.find("tr.pq-grid-row"); + var indx = 0, + rowIndxPage = 0, + colIndx = 0; + for (var i = 1; i < $trs.length; i++) { + if ($trs[i].offsetTop > top) { + break + } else { + indx++ + } + } + var $tr = $($trs[indx]); + rowIndxPage = parseInt($tr.attr("pq-row-indx")); + var $tds = $tr.find("td.pq-grid-cell"); + var indx = 0, + _found = false; + for (var i = 0; i < $tds.length; i++) { + var td = $tds[i]; + if (td.offsetLeft < left && td.offsetLeft + td.offsetWidth > left) { + _found = true; + break + } else { + if (td.offsetLeft > left) { + break + } else { + indx++ + } + } + } + if (!_found) { + return null + } + var $td = $($tds[indx]); + if ($td[0].nodeName.toUpperCase() != "TD") { + $td = $(evt.target).parent("td") + } + colIndx = parseInt($td.attr("pq-col-indx")); + if (isNaN(colIndx)) { + return null + } + return { + $td: $td, + rowIndxPage: rowIndxPage, + rowIndx: rowIndxPage + this.rowIndxOffset, + colIndx: colIndx, + dataIndx: this.colModel[colIndx].dataIndx + } + }; + fn._createSlidingTop = function() { + var that = this, + $top = this.$top, + slideup = false, + htCapture = 0, + $collapsible = $(["
", "", "
"].join("")).appendTo($top), + $icon = $collapsible.children("span"); + $collapsible.mouseover(function(evt) { + $collapsible.addClass("ui-state-hover") + }).mouseout(function(evt) { + $collapsible.removeClass("ui-state-hover") + }).click(function(evt) { + var ele = that.element, + thisOptions = that.options; + if (slideup) { + ele.animate({ + height: htCapture + }, function() { + that.refresh(); + $icon.addClass("ui-icon-circle-triangle-n").removeClass("ui-icon-circle-triangle-s"); + that.$toolbar.pqToolbar("enable") + }); + slideup = false + } else { + htCapture = (thisOptions.flexHeight) ? ele[0].offsetHeight : thisOptions.height; + htCapture = parseInt(htCapture) + "px"; + ele.animate({ + height: "23px" + }, function() { + $icon.addClass("ui-icon-circle-triangle-s").removeClass("ui-icon-circle-triangle-n"); + if (ele.hasClass("ui-resizable")) { + ele.resizable("destroy") + } + that.$toolbar.pqToolbar("disable") + }); + slideup = true + } + }); + this.$collapsible = $collapsible + }; + if ($.paramquery.pqg_incr == null) { + $.paramquery.pqg_incr = 0 + } + fn._create = function() { + var that = this; + this.iGenerateView = new cGenerateView(this); + this.iKeyNav = new cKeyNav(this); + this.cols = []; + this.widths = []; + this.outerWidths = []; + this.rowHeight = 22; + this.hidearr = []; + this.hidearrHS = []; + this.tables = []; + var that = this, + thisOptions = this.options; + this.$tbl = null; + this._calcThisColModel(); + this.iSort = new $.paramquery.cSort(this); + this.iSort._refreshSorters(); + this._initTypeColumns(); + $.paramquery.pqg_incr++; + var pqg_incr = $.paramquery.pqg_incr; + this.element.empty().addClass("pq-grid ui-widget ui-widget-content" + (thisOptions.roundCorners ? " ui-corner-all" : "")).append(["
", "
 
", "
", "
", "", "
", "
", "
", "
", "
", "
", "", "
"].join("")); + this._trigger("render", null, { + dataModel: this.options.dataModel, + colModel: this.colModel + }); + this.$top = $("div.pq-grid-top", this.element); + this.$title = $("div.pq-grid-title", this.element); + if (!thisOptions.showTitle) { + this.$title.css("display", "none") + } + if (thisOptions.collapsible) { + this._createSlidingTop() + } + this.$toolbar = $("div.pq-grid-toolbar", this.element); + this.$grid_inner = $("div.pq-grid-inner", this.element); + this.$grid_right = $(".pq-grid-right", this.element); + this.$header_o = $("div.pq-header-outer", this.$grid_right); + if (!thisOptions.showTop) { + this.$top.css("display", "none") + } + this.$header = $(".pq-grid-header", this.$grid_right); + this.$header_left = $(this.$header[0]); + this.$header_right = $(this.$header[1]); + this.$bottom = $("div.pq-grid-bottom", this.element); + if (!thisOptions.showBottom) { + this.$bottom.css("display", "none") + } + this.$footer = $("div.pq-grid-footer", this.element); + this.$cont_o = $("div.pq-cont-right", this.$grid_right); + this.$cont_fixed = $("div.pq-cont-fixed", this.$grid_right); + this.$cont = $("div.pq-cont", this.$grid_right); + this.$cont.on("click", function(evt) { + that._onClickCont(evt) + }); + this.$cont.on("click", "td.pq-grid-cell", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onClickCell(evt) + } + }); + this.$cont.on("click", "tr.pq-grid-row", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onClickRow(evt) + } + }); + this.$cont.on("contextmenu", "td.pq-grid-cell", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onRightClickCell(evt) + } + }); + this.$cont.on("contextmenu", "tr.pq-grid-row", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onRightClickRow(evt) + } + }); + this.$cont.on("dblclick", "td.pq-grid-cell", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onDblClickCell(evt) + } + }); + this.$cont.on("dblclick", "tr.pq-grid-row", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onDblClickRow(evt) + } + }); + this.$cont.on("mousedown", "td.pq-grid-cell", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onCellMouseDown(evt) + } + }); + this.$cont.on("mousedown", "tr.pq-grid-row", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onRowMouseDown(evt) + } + }); + this.$cont.on("mousemove", "td.pq-grid-cell", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onCellMouseMove(evt) + } + }); + this.$cont.on("mousemove", "tr.pq-grid-row", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onRowMouseMove(evt) + } + }); + this.$cont.on("mouseup", "td.pq-grid-cell", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onCellMouseUp(evt) + } + }); + this.element.on("mouseup", function(evt) { + if (that._trigger("mouseUp", evt, { + dataModel: that.options.dataModel + }) == false) { + return false + } + }); + this.$cont.on("mouseenter", "td.pq-grid-cell", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onCellMouseEnter(evt, $(this)) + } + }); + this.$cont.on("mouseenter", "tr.pq-grid-row", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onRowMouseEnter(evt, $(this)) + } + }); + this.$cont.on("mouseleave", "td.pq-grid-cell", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onCellMouseLeave(evt, $(this)) + } + }); + this.$cont.on("mouseleave", "tr.pq-grid-row", function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + return that._onRowMouseLeave(evt, $(this)) + } + }); + this.$cont.bind("mousewheel DOMMouseScroll", function(evt) { + return that._onMouseWheel(evt) + }); + var prevVScroll = 0; + this.$hvscroll = $("
").appendTo(this.$grid_inner); + this.$vscroll = $("
").appendTo(this.$grid_inner); + this.prevVScroll = 0; + var scrollModel = thisOptions.scrollModel; + this.$vscroll.pqScrollBar({ + pace: scrollModel.pace, + theme: scrollModel.theme, + direction: "vertical", + cur_pos: 0, + pageDown: function(evt, ui) { + that.iKeyNav.pageDown() + }, + pageUp: function(evt, ui) { + that.iKeyNav.pageUp() + }, + scroll: function(evt, obj) { + that.scrollMode = true; + that.setFlexWHCallback(function() { + that.iGenerateView.generateView() + }); + var num_eles; + if (evt.originalEvent && evt.originalEvent.type == "drag") { + num_eles = that._setScrollVNumEles() + } else { + num_eles = that._setScrollVNumEles(true) + } if (num_eles <= 1) { + that._setScrollHLength(); + that._setScrollHVLength() + } + } + }); + var prevHScroll = 0; + this.$hscroll = $("
").appendTo(this.$grid_inner); + this.$hscroll.pqScrollBar({ + direction: "horizontal", + pace: scrollModel.pace, + theme: scrollModel.theme, + cur_pos: 0, + scroll: function(evt, obj) { + that.refresh() + } + }); + this._refreshGridWidth(); + this.element.height(thisOptions.height); + this.disableSelection(); + if (window.opera) { + this.$grid_inner.bind("keypress.pq-grid", { + that: this + }, function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + that._onKeyPressDown(evt) + } + }) + } else { + this.$grid_inner.bind("keydown.pq-grid", { + that: this + }, function(evt) { + if ($(evt.target).closest(".pq-grid")[0] == that.element[0]) { + that._onKeyPressDown(evt) + } + }) + } + this._refreshOptions(); + this._refreshTitle(); + this._refreshDataIndices(); + this.iRows = new $.paramquery.cRows(this); + this.iCells = new $.paramquery.cCells(this); + this.generateLoading(); + this._initPager() + }; + fn._refreshGridWidth = function() { + var thisOptions = this.options, + wd2, element = this.element; + if ((thisOptions.width + "").indexOf("%") != -1) { + var parent = element.parent(), + wd = parent.width(), + superParent = null; + if (wd == 0) { + while (parent[0].tagName.toUpperCase() != "BODY") { + var newParent = parent.parent(); + if (newParent[0] == null) { + superParent = parent; + break + } else { + parent = newParent + } + } + if (superParent) { + var position = superParent.css("position"), + left = superParent.css("left"), + top = superParent.css("top"); + superParent.css({ + position: "absolute", + left: "-2000", + top: "-2000" + }).appendTo($(document.body)); + wd = element.parent().width(); + superParent.css({ + position: position, + left: left, + top: top + }) + } + } + var wd2 = parseInt(thisOptions.width) * wd / 100 + } else { + wd2 = thisOptions.width + } + element.width(wd2); + element.width(element.width()) + }; + fn._onMouseWheel = function(evt) { + if (this.options.flexHeight) { + return true + } + var that = this; + var num = 0; + var evt = evt.originalEvent; + if (evt.wheelDelta) { + num = evt.wheelDelta / 120 + } else { + if (evt.detail) { + num = evt.detail * -1 / 3 + } + } + var cur_pos = parseInt(that.$vscroll.pqScrollBar("option", "cur_pos")); + var new_pos = cur_pos - num; + if (new_pos >= 0) { + that.$vscroll.pqScrollBar("option", "cur_pos", cur_pos - num).pqScrollBar("scroll") + } + return false + }; + fn._onDblClickCell = function(evt) { + var that = this; + var $td = $(evt.currentTarget); + var obj = that.getCellIndices({ + $td: $td + }); + var rowIndxPage = obj.rowIndxPage, + offset = that.rowIndxOffset, + rowIndx = rowIndxPage + offset, + colIndx = obj.colIndx; + if (colIndx == null) { + return + } + if (that._trigger("cellDblClick", evt, { + $td: $td, + rowIndxPage: rowIndxPage, + rowIndx: rowIndx, + colIndx: colIndx, + column: that.colModel[colIndx], + rowData: that.data[rowIndxPage] + }) == false) { + return false + } + if (that.options.editModel.clicksToEdit > 1 && this.isEditableRow({ + rowIndx: rowIndx + }) && this.isEditableCell({ + colIndx: colIndx, + rowIndx: rowIndx + })) { + that._editCell($td) + } + }; + fn._onClickCont = function(evt) { + var that = this + }; + fn._onClickRow = function(evt) { + var that = this; + var $tr = $(evt.currentTarget); + var rowIndxPage = parseInt($tr.attr("pq-row-indx")), + offset = that.rowIndxOffset, + rowIndx = rowIndxPage + offset; + if (isNaN(rowIndxPage)) { + return + } + var objP = { + rowIndx: rowIndx, + evt: evt + }, options = this.options; + if (that._trigger("rowClick", evt, { + $tr: $tr, + rowIndxPage: rowIndxPage, + rowIndx: rowIndx, + rowData: that.data[rowIndxPage] + }) == false) { + return false + } + return + }; + fn._onRightClickRow = function(evt) { + var that = this, + $tr = $(evt.currentTarget), + rowIndxPage = parseInt($tr.attr("pq-row-indx")), + offset = that.rowIndxOffset, + rowIndx = rowIndxPage + offset; + if (isNaN(rowIndxPage)) { + return + } + var options = this.options; + if (that._trigger("rowRightClick", evt, { + $tr: $tr, + rowIndxPage: rowIndxPage, + rowIndx: rowIndx, + rowData: that.data[rowIndxPage] + }) == false) { + return false + } + }; + fn._onDblClickRow = function(evt) { + var that = this; + var $tr = $(evt.currentTarget); + var rowIndxPage = parseInt($tr.attr("pq-row-indx")), + offset = that.getRowIndxOffset(), + rowIndx = rowIndxPage + offset; + if (that._trigger("rowDblClick", evt, { + $tr: $tr, + rowIndxPage: rowIndxPage, + rowIndx: rowIndx, + rowData: that.data[rowIndxPage] + }) == false) { + return false + } + }; + fn._isValid = function(obj) { + var that = this, + rowData = obj.rowData, + value = $.trim(obj.value), + column = obj.column, + dataIndx = column.dataIndx, + gValid = this.options.validation, + valids = column.validations; + if (valids && valids.length > 0) { + for (var j = 0; j < valids.length; j++) { + var valid = valids[j], + valid = $.extend({}, gValid, valid), + type = valid.type, + msg = valid.msg, + msg = msg ? msg : " ", + icon = valid.icon, + cls = valid.cls, + cls = cls ? cls : "", + style = "padding:3px 10px;" + valid.style, + css = valid.css, + _valid = true, + invalid = { + valid: false, + msg: msg, + dataIndx: dataIndx + }, reqVal = valid.value; + if (type == "minLen" && value.length < reqVal) { + _valid = false + } else { + if (type == "maxLen" && value.length > reqVal) { + _valid = false + } else { + if (type == "gt" && value <= reqVal) { + _valid = false + } else { + if (type == "gte" && value < reqVal) { + _valid = false + } else { + if (type == "lt" && value >= reqVal) { + _valid = false + } else { + if (type == "lte" && value > reqVal) { + _valid = false + } else { + if (type == "regexp" && (new RegExp(reqVal)).test(value) == false) { + _valid = false + } else { + if (typeof type == "function") { + var obj2 = { + column: column, + value: value, + rowData: rowData, + msg: msg + }; + if (type.call(that.element, obj2) == false) { + _valid = false; + if (obj2.msg != msg) { + msg = obj2.msg + } + } + } + } + } + } + } + } + } + } if (!_valid) { + var rowIndx = this.getRowIndx({ + rowData: rowData + }).rowIndx; + if (rowIndx != null) { + this.goToPage({ + rowIndx: rowIndx + }); + this.scrollRow({ + rowIndx: rowIndx + }); + this.editCell({ + rowIndx: rowIndx, + dataIndx: dataIndx + }) + } + var cell = this.getEditCell(); + if (cell && cell.$cell) { + var $cell = cell.$cell; + $cell.attr("title", msg); + try { + $cell.tooltip("destroy") + } catch (ex) {} + $cell.tooltip({ + position: { + my: "left top", + at: "right top" + }, + content: function() { + var $this = $(this), + strIcon = (icon == "") ? "" : (""); + return strIcon + msg + }, + open: function(evt, ui) { + if (cls) { + ui.tooltip.addClass(cls) + } + if (style) { + var olds = ui.tooltip.attr("style"); + ui.tooltip.attr("style", olds + ";" + style) + } + if (css) { + ui.tooltip.css(css) + } + } + }).tooltip("open"); + $cell.find(".pq-editor-focus").focus() + } + return invalid + } + } + } + return { + valid: true + } + }; + fn.isValid = function(obj) { + var rowList = obj.rowList, + rowData = this.getRowData(obj), + dataIndx = obj.dataIndx; + if (dataIndx == null) { + var CM = this.colModel; + for (var i = 0, len = CM.length; i < len; i++) { + var column = CM[i], + hidden = column.hidden; + if (hidden) { + continue + } + var dataIndx = column.dataIndx, + value = rowData[dataIndx], + isValid = this._isValid({ + rowData: rowData, + value: value, + column: column + }); + if (!isValid.valid) { + return isValid + } + } + } else { + var column = this.getColumn({ + dataIndx: dataIndx + }), + value = (obj.value === undefined) ? rowData[dataIndx] : obj.value, + isValid = this._isValid({ + rowData: rowData, + value: value, + column: column + }); + if (!isValid.valid) { + return isValid + } + } + return { + valid: true + } + }; + fn.isEditableRow = function(objP) { + var thisOptions = this.options, + gEditable = thisOptions.editable; + if (gEditable != null) { + if (typeof gEditable == "function") { + var rowIndx = objP.rowIndx, + rowData = thisOptions.dataModel.data[rowIndx]; + return gEditable.call(this.element, { + rowData: rowData, + rowIndx: rowIndx + }) + } else { + return gEditable + } + } else { + return true + } + }; + fn.isEditableCell = function(objP) { + var colIndx = objP.colIndx, + dataIndx = objP.dataIndx, + colIndx = (colIndx == null) ? this.getColIndx({ + dataIndx: dataIndx + }) : colIndx, + column = this.colModel[colIndx], + dataIndx = (dataIndx == null) ? column.dataIndx : dataIndx, + cEditable = column.editable; + if (objP.checkVisible && column.hidden) { + return false + } + if (cEditable != null) { + if (typeof cEditable == "function") { + var rowIndx = objP.rowIndx, + rowData = this.getRowData(objP); + return cEditable.call(this.element, { + rowIndx: rowIndx, + rowData: rowData, + column: column, + dataIndx: dataIndx + }) + } else { + return cEditable + } + } else { + return true + } + }; + fn._getRowPQData = function(rowIndxPage, key, rowData) { + var rowData = (rowData == null) ? this.data[rowIndxPage] : rowData; + return rowData ? rowData[key] : null + }; + fn._setRowPQData = function(rowIndxPage, objP, rowData) { + var rowData = (rowData == null) ? this.data[rowIndxPage] : rowData; + if (!rowData) { + return + } + for (var key in objP) { + rowData[key] = objP[key] + } + }; + fn._onCellMouseDown = function(evt) { + var that = this; + var $td = $(evt.currentTarget); + var objP = that.getCellIndices({ + $td: $td + }); + objP.$td = $td; + objP.dataModel = that.options.dataModel; + if (that._trigger("cellMouseDown", evt, objP) == false) { + return false + } + return true + }; + fn._onRowMouseDown = function(evt) { + var that = this; + var $tr = $(evt.currentTarget); + var objP = that.getRowIndx({ + $tr: $tr + }); + objP.$tr = $tr; + objP.dataModel = that.options.dataModel; + if (that._trigger("rowMouseDown", evt, objP) == false) { + return false + } + return true + }; + fn._onCellMouseEnter = function(evt, $this) { + var $td = $this, + that = this; + if (that._trigger("cellMouseEnter", evt, { + $td: $td, + dataModel: that.options.dataModel + }) == false) { + return false + } + if (that.options.hoverMode == "cell") { + that.highlightCell($td) + } + return true + }; + fn._onRowMouseEnter = function(evt, $this) { + var $tr = $this, + that = this; + var objRI = that.getRowIndx({ + $tr: $tr + }); + var rowIndxPage = objRI.rowIndxPage; + if (that._trigger("rowMouseEnter", evt, { + $tr: $tr, + dataModel: that.options.dataModel + }) == false) { + return false + } + if (that.options.hoverMode == "row") { + that.highlightRow(rowIndxPage) + } + return true + }; + fn._onCellMouseLeave = function(evt, $this) { + var $td = $this, + that = this; + if (that._trigger("cellMouseLeave", evt, { + $td: $td, + dataModel: that.options.dataModel + }) == false) { + return false + } + if (that.options.hoverMode == "cell") { + that.unHighlightCell($td) + } + return true + }; + fn._onRowMouseLeave = function(evt, $this) { + var $tr = $this, + that = this; + var objRI = that.getRowIndx({ + $tr: $tr + }); + var rowIndxPage = objRI.rowIndxPage; + if (that._trigger("rowMouseLeave", evt, { + $tr: $tr, + dataModel: that.options.dataModel + }) == false) { + return false + } + if (that.options.hoverMode == "row") { + that.unHighlightRow(rowIndxPage) + } + return true + }; + fn._onCellMouseMove = function(evt) { + var that = this; + var $td = $(evt.currentTarget); + var objP = that.getCellIndices({ + $td: $td + }); + objP.$td = $td; + objP.dataModel = that.options.dataModel; + if (that._trigger("cellMouseMove", evt, objP) == false) { + return false + } + return true + }; + fn._onRowMouseMove = function(evt) { + var that = this; + var $tr = $(evt.currentTarget); + var objP = that.getRowIndx({ + $tr: $tr + }); + objP.$tr = $tr; + objP.dataModel = that.options.dataModel; + if (that._trigger("rowMouseMove", evt, objP) == false) { + return false + } + return true + }; + fn._onCellMouseUp = function(evt) { + var that = this; + var $td = $(evt.currentTarget); + var objP = that.getCellIndices({ + $td: $td + }); + objP.$td = $td; + objP.dataModel = that.options.dataModel; + if (that._trigger("cellMouseUp", evt, objP) == false) { + return false + } + return true + }; + fn._onClickCell = function(evt) { + var that = this, + thisOptions = this.options, + CM = this.colModel, + EM = thisOptions.editModel, + SM = thisOptions.selectionModel; + var $td = $(evt.currentTarget); + var objP = that.getCellIndices({ + $td: $td + }); + var rowIndxPage = objP.rowIndxPage, + offset = that.rowIndxOffset, + rowIndx = rowIndxPage + offset, + colIndx = objP.colIndx; + objP.rowIndx = rowIndx; + if (colIndx == null) { + return + } + var column = CM[colIndx], + dataIndx = column.dataIndx; + objP.dataIndx = dataIndx; + objP.evt = evt; + if (that._trigger("cellClick", evt, { + $td: $td, + rowIndxPage: rowIndxPage, + rowIndx: rowIndx, + colIndx: colIndx, + dataIndx: dataIndx, + column: column, + rowData: that.data[rowIndxPage] + }) == false) { + return false + } + if (EM.clicksToEdit == 1 && this.isEditableRow({ + rowIndx: rowIndx + }) && this.isEditableCell({ + colIndx: colIndx, + rowIndx: rowIndx + })) { + window.setTimeout(function() { + that.editCell(objP) + }, 0); + return + } + }; + fn._onRightClickCell = function(evt) { + var $td = $(evt.currentTarget); + var objP = this.getCellIndices({ + $td: $td + }); + var that = this, + rowIndxPage = objP.rowIndxPage, + offset = this.rowIndxOffset, + rowIndx = rowIndxPage + offset, + colIndx = objP.colIndx, + CM = this.colModel, + options = this.options, + DM = options.DM; + if (colIndx == null) { + return + } + var column = CM[colIndx], + dataIndx = column.dataIndx; + if (this._trigger("cellRightClick", evt, { + $td: $td, + rowIndxPage: rowIndxPage, + rowIndx: rowIndx, + colIndx: colIndx, + dataIndx: dataIndx, + column: column, + rowData: that.data[rowIndxPage] + }) == false) { + return false + } + }; + fn.highlightCell = function($td) { + $td.addClass("pq-grid-cell-hover ui-state-hover") + }; + fn.unHighlightCell = function($td) { + $td.removeClass("pq-grid-cell-hover ui-state-hover") + }; + fn.highlightRow = function(varr) { + if (isNaN(varr)) {} else { + var $tr = this.getRow({ + rowIndxPage: varr + }); + if ($tr) { + $tr.addClass("pq-grid-row-hover ui-state-hover") + } + } + }; + fn.unHighlightRow = function(varr) { + if (isNaN(varr)) {} else { + var $tr = this.getRow({ + rowIndxPage: varr + }); + if ($tr) { + $tr.removeClass("pq-grid-row-hover ui-state-hover") + } + } + }; + fn._getCreateEventData = function() { + return { + dataModel: this.options.dataModel, + data: this.data, + colModel: this.options.colModel + } + }; + fn._refreshOptions = function() { + this._refreshDataOptions() + }; + fn._refreshDataOptions = function() {}; + fn.enableSelection = function() { + this.$cont.enableSelection() + }; + fn.disableSelection = function() { + this.$cont.disableSelection(); + this.$header.find("tr.pq-grid-title-row").disableSelection() + }; + fn._isEditCell = function(evt) { + var $targ = $(evt.target); + var $div = $targ.closest("div.pq-editor-border-edit"); + if ($div && $div.length > 0) { + return true + } + return false + }; + fn._findCellFromEvt = function(evt) { + var $targ = $(evt.target); + var $td = $targ.closest(".pq-grid-cell"); + if ($td == null || $td.length == 0) { + return { + rowIndxPage: null, + colIndx: null, + $td: null + } + } else { + var obj = this.getCellIndices({ + $td: $td + }); + obj.$td = $td; + return obj + } + }; + fn._initPager = function() { + var DM = this.options.pageModel; + var that = this; + var obj2 = { + rPP: DM.rPP, + rPPOptions: DM.rPPOptions, + change: function(evt, ui) { + that.quitEditMode(); + var DM = that.options.pageModel; + if (ui.curPage != undefined) { + DM.prevPage = DM.curPage; + DM.curPage = ui.curPage + } + if (ui.rPP != undefined) { + DM.rPP = ui.rPP + } + if (DM.type == "remote") { + that.remoteRequest({ + callback: function() { + that._onDataAvailable({ + apply: true + }) + } + }) + } else { + that.refreshView() + } + }, + refresh: function(evt) { + that.refreshDataAndView() + } + }; + if (DM.type) { + this.$footer.pqPager(obj2) + } else {} + }; + fn._refreshHideArrHS = function() { + var that = this, + CM = this.colModel, + hidearrHS = that.hidearrHS, + initH = that.initH, + finalH = that.finalH, + freezeCols = parseInt(this.options.freezeCols); + for (var i = 0; i < freezeCols; i++) { + hidearrHS[i] = false + } + for (var i = freezeCols; i < initH; i++) { + hidearrHS[i] = true + } + for (var i = initH; i <= finalH; i++) { + hidearrHS[i] = false + } + for (var i = finalH + 1, len = CM.length; i < len; i++) { + hidearrHS[i] = true + } + }; + fn.generateLoading = function() { + if (this.$loading) { + this.$loading.remove() + } + this.$loading = $("
").appendTo(this.element); + $(["
", this.options.strLoading, "...
"].join("")).appendTo(this.$loading); + this.$loading.find("div.pq-loading-bg").css("opacity", 0.2) + }; + fn._refreshLoadingString = function() { + this.$loading.find("div.pq-loading-mask").children("div").html(this.options.strLoading) + }; + fn.showLoading = function() { + if (this.showLoadingCounter == null) { + this.showLoadingCounter = 0 + } + this.showLoadingCounter++; + this.$loading.show() + }; + fn.hideLoading = function() { + if (this.showLoadingCounter > 0) { + this.showLoadingCounter-- + } + if (!this.showLoadingCounter) { + this.$loading.hide() + } + }; + fn.refreshDataFromDataModel = function() { + this._trigger("beforeRefreshData", null, {}); + var thisOptions = this.options, + DM = thisOptions.dataModel, + PM = thisOptions.pageModel, + DMdata = DM.data, + paging = PM.type; + this.rowIndxOffset = 0; + if (DMdata == null || DMdata.length == 0) { + if (paging) { + PM.curPage = 0; + PM.totalPages = 0; + PM.totalRecords = 0 + } + this.data = DMdata; + return + } + if (paging && paging == "local") { + PM.totalRecords = DMdata.length; + PM.totalPages = Math.ceil(DMdata.length / PM.rPP); + if (PM.curPage > PM.totalPages) { + PM.curPage = PM.totalPages + } + if (PM.curPage < 1 && PM.totalPages > 0) { + PM.curPage = 1 + } + var begIndx = (PM.curPage - 1) * PM.rPP; + var endIndx = PM.curPage * PM.rPP; + if (endIndx > DMdata.length) { + endIndx = DMdata.length + } + this.data = DMdata.slice(begIndx, endIndx) + } else { + if (paging == "remote") { + var totalPages = Math.ceil(PM.totalRecords / PM.rPP); + PM.totalPages = totalPages; + if (totalPages && !PM.curPage) { + PM.curPage = 1 + } + var endIndx = PM.rPP; + if (endIndx > DMdata.length) { + endIndx = DMdata.length + } + this.data = DMdata.slice(0, endIndx) + } else { + this.data = DMdata.slice(0) + } + } if (paging == "local" || paging == "remote") { + this.rowIndxOffset = (PM.rPP * (PM.curPage - 1)) + } + }; + $.paramquery.filter = function() { + var conditions = { + begin: { + text: "Begins With", + TR: true, + string: true + }, + between: { + text: "Between", + TR: true, + string: true, + date: true, + number: true + }, + notbegin: { + text: "Does not begin with", + TR: true, + string: true + }, + contain: { + text: "Contains", + TR: true, + string: true + }, + notcontain: { + text: "Does not contain", + TR: true, + string: true + }, + equal: { + text: "Equal To", + TR: true, + string: true, + bool: true + }, + notequal: { + text: "Not Equal To", + TR: true, + string: true + }, + empty: { + text: "Empty", + TR: false, + string: true, + bool: true + }, + notempty: { + text: "Not Empty", + TR: false, + string: true, + bool: true + }, + end: { + text: "Ends With", + TR: true, + string: true + }, + notend: { + text: "Does not end with", + TR: true, + string: true + }, + less: { + text: "Less Than", + TR: true, + number: true, + date: true + }, + lte: { + text: "Less than or equal", + TR: true, + number: true, + date: true + }, + range: { + TR: true, + string: true, + number: true, + date: true + }, + regexp: { + TR: true, + string: true, + number: true, + date: true + }, + great: { + text: "Great Than", + TR: true, + number: true, + date: true + }, + gte: { + text: "Greater than or equal", + TR: true, + number: true, + date: true + } + }; + return { + conditions: conditions, + getAllConditions: (function() { + var arr = []; + for (var key in conditions) { + arr.push(key) + } + return arr + })(), + getConditions: function(type) { + var arr = []; + for (var key in conditions) { + if (conditions[key][type]) { + arr.push(key) + } + } + return arr + }, + getTRConditions: (function() { + var arr = []; + for (var key in conditions) { + if (conditions[key].TR) { + arr.push(key) + } + } + return arr + })(), + getWTRConditions: (function() { + var arr = []; + for (var key in conditions) { + if (!conditions[key].TR) { + arr.push(key) + } + } + return arr + })() + } + }(); + $.paramquery.filter.rules = {}; + $.paramquery.filter.rules.en = { + begin: "Begins With", + between: "Between", + notbegin: "Does not begin with", + contain: "Contains", + notcontain: "Does not contain", + equal: "Equal To", + notequal: "Not Equal To", + empty: "Empty", + notempty: "Not Empty", + end: "Ends With", + notend: "Does not end with", + less: "Less Than", + lte: "Less than or equal", + great: "Great Than", + gte: "Greater than or equal" + }; + fn.getQueryStringSort = function() { + var sorters = this.iSort.sorters, + sortBy = "", + options = this.options, + sql = options.sql, + stringify = options.stringify; + if (sql) { + for (var i = 0; i < sorters.length; i++) { + var sorter = sorters[i], + dataIndx = sorter.dataIndx, + dir = sorter.dir == "up" ? "asc" : "desc"; + sortBy += (i > 0 ? ", " : "") + dataIndx + " " + dir + } + return sortBy + } else { + if (sorters.length) { + if (stringify === false) { + return sorters + } else { + return JSON.stringify(sorters) + } + } else { + return "" + } + } + }; + fn.getQueryStringCRUD = function() { + return "" + }; + fn.getQueryStringFilter = function() { + var thisOptions = this.options, + sql = thisOptions.sql, + stringify = thisOptions.stringify, + FM = thisOptions.filterModel, + FMmode = FM.mode, + CM = this.colModel, + arrS = this.getFilterData({ + CM: CM, + location: "remote" + }), + filter = ""; + if (FM && FM.on && arrS) { + if (sql) { + filter = []; + for (var j = 0; j < arrS.length; j++) { + var f = arrS[j], + condition = f.condition, + dataIndx = f.dataIndx, + text = $.trim(f.value); + if (condition === "contain") { + filter.push(dataIndx + " like '%" + text + "%'") + } else { + if (condition === "notcontain") { + filter.push(dataIndx + " not like '%" + text + "%'") + } else { + if (condition === "begin") { + filter.push(dataIndx + " like '" + text + "%'") + } else { + if (condition === "end") { + filter.push(dataIndx + " like '%" + text + "'") + } else { + if (condition === "equal") { + filter.push(dataIndx + "='" + text + "'") + } else { + if (condition === "notequal") { + filter.push(dataIndx + "!='" + text + "'") + } else { + if (condition === "empty") { + filter.push("isnull(" + dataIndx + ",'')=''") + } else { + if (condition === "notempty") { + filter.push("isnull(" + dataIndx + ",'')!=''") + } else { + if (condition === "less") { + filter.push(dataIndx + "<'" + text + "'") + } else { + if (condition === "great") { + filter.push(dataIndx + ">'" + text + "'") + } + } + } + } + } + } + } + } + } + } + } + filter = filter.join(" " + FMmode + " ") + } else { + if (arrS.length) { + var obj = { + mode: FMmode, + data: arrS + }; + if (stringify === false) { + filter = obj + } else { + filter = JSON.stringify(obj) + } + } else { + filter = "" + } + } + } + return filter + }; + fn.remoteRequest = function(objP) { + if (this.loading) { + this.xhr.abort() + } + var that = this, + url = "", + dataURL = "", + thisOptions = this.options, + raiseFilterEvent = false, + thisColModel = this.colModel, + DM = thisOptions.dataModel, + FM = thisOptions.filterModel, + PM = thisOptions.pageModel; + if (typeof DM.getUrl == "function") { + var objk = { + colModel: thisColModel, + dataModel: DM, + groupModel: thisOptions.groupModel, + pageModel: PM, + filterModel: FM + }; + var objURL = DM.getUrl.call(this.element, objk); + if (objURL && objURL.url) { + url = objURL.url + } + if (objURL && objURL.data) { + dataURL = objURL.data + } + } else { + if (typeof DM.url == "string") { + url = DM.url; + var sortQueryString = {}, filterQueryString = {}, pageQueryString = {}; + if (DM.sorting == "remote") { + var sortingQS = this.getQueryStringSort(); + if (sortingQS) { + sortQueryString = { + pq_sort: sortingQS + } + } + } + if (PM.type == "remote") { + pageQueryString = { + pq_curpage: PM.curPage, + pq_rpp: PM.rPP + } + } + var filterQS; + if (FM.type != "local") { + filterQS = this.getQueryStringFilter(); + if (filterQS) { + raiseFilterEvent = true; + filterQueryString = { + pq_filter: filterQS + } + } + } + var postData = DM.postData, + postDataOnce = DM.postDataOnce; + if (postData && typeof postData == "function") { + postData = postData.call(this.element, { + colModel: thisColModel, + dataModel: DM + }) + } + dataURL = $.extend({ + pq_datatype: DM.dataType + }, filterQueryString, pageQueryString, sortQueryString, postData, postDataOnce) + } + } if (!url) { + return + } + this.loading = true; + this.showLoading(); + this.xhr = $.ajax({ + url: url, + dataType: DM.dataType, + async: (DM.async == null) ? true : DM.async, + cache: DM.cache, + contentType: DM.contentType, + type: DM.method, + data: dataURL, + beforeSend: function(jqXHR, settings) { + if (typeof DM.beforeSend == "function") { + return DM.beforeSend.call(that.element, jqXHR, settings) + } + }, + success: function(responseObj, textStatus, jqXHR) { + if (typeof DM.getData == "function") { + var retObj = DM.getData.call(that.element, responseObj, textStatus, jqXHR); + DM.data = retObj.data; + if (PM.type && PM.type == "remote") { + if (retObj.curPage) { + PM.curPage = retObj.curPage + } + if (retObj.totalRecords) { + PM.totalRecords = retObj.totalRecords + } + } + } else { + DM.data = responseObj.data; + if (PM.type && PM.type == "remote") { + if (responseObj.curPage) { + PM.curPage = responseObj.curPage + } + if (responseObj.totalRecords) { + PM.totalRecords = responseObj.totalRecords + } + } + } + that.hideLoading(); + that.loading = false; + that._trigger("load", null, { + dataModel: DM, + colModel: thisColModel + }); + if (raiseFilterEvent) { + that._trigger("filter", null, { + type: "remote", + dataModel: DM, + colModel: thisColModel, + filterModel: FM + }) + } + if (objP && objP.callback) { + objP.callback() + } + }, + error: function(jqXHR, textStatus, errorThrown) { + that.hideLoading(); + that.loading = false; + if (typeof DM.error == "function") { + DM.error.call(that.element, jqXHR, textStatus, errorThrown) + } else { + if (errorThrown != "abort") { + throw ("Error : " + errorThrown) + } + } + } + }) + }; + fn._fixFireFoxContentEditableIssue = function() { + if (window.postMessage) {} + }; + fn.setFlexWHCallback = function(fn) { + var that = this; + fn.call(that); + if (this.options.flexHeight) { + this.setGridHeightFromTable() + } + if (this.options.flexWidth) { + this._setGridWidthFromTable() + } + }; + fn._refreshTitle = function() { + this.$title.html(this.options.title) + }; + fn._refreshDraggable = function() { + if (this.options.draggable) { + this.$title.addClass("draggable"); + this.element.draggable({ + handle: this.$title, + start: function(evt, ui) {} + }) + } else { + this._destroyDraggable() + } + }; + fn._refreshResizable = function() { + var that = this; + if (this.options.resizable) { + this.element.resizable({ + helper: "ui-state-highlight", + delay: 0, + start: function(evt, ui) { + $(ui.helper).css({ + opacity: 0.5, + background: "#ccc", + border: "1px solid steelblue" + }) + }, + resize: function(evt, ui) {}, + stop: function(evt, ui) { + that.options.height = that.element.height(); + that.options.width = that.element.width(); + that._refresh(); + that.element.css("position", "relative") + } + }) + } else { + this._destroyResizable() + } + }; + fn.refresh = function(objP) { + this._refresh(objP) + }; + fn._refreshDataIndices = function() { + if (this.options.getDataIndicesFromColIndices == false) { + return + } + var CM = this.colModel, + CMLength = CM.length; + for (var i = 0; i < CMLength; i++) { + var column = CM[i]; + if (column.dataIndx == null) { + column.dataIndx = i + } + } + }; + fn.refreshView = function(obj) { + if (this.$td_edit != null) { + this.quitEditMode({ + silent: true + }) + } + this.refreshDataFromDataModel(); + this._refresh(obj) + }; + fn._refresh = function(objP) { + var that = this; + this._refreshGridWidth(); + this._refreshDataIndices(); + this._refreshResizable(); + this._refreshDraggable(); + this._refreshColumnWidths(); + this._computeOuterWidths(); + this._setScrollHNumEles(); + this._bufferObj_calcInitFinalH(); + this._refreshHideArrHS(); + if (!objP || objP.header !== false) { + this._createHeader() + } + this._refreshHeaderSortIcons(); + this._setInnerGridHeight(); + this._setRightGridHeight(); + this.setFlexWHCallback(function() { + that.iGenerateView.generateView(); + that._computeOuterWidths() + }); + this._setScrollHLength(); + this._setScrollVLength(); + this._setScrollVNumEles(true); + this._setScrollHLength(); + this._setScrollHVLength(); + this._refreshPager(); + this._refreshFreezeLine(); + this.disableSelection(); + this.options.dataModel.postDataOnce = undefined + }; + fn._setScrollHVLength = function() { + var options = this.options; + if (this.$hscroll.is(":hidden") || options.flexHeight || options.flexWidth) { + this.$hvscroll.css("visibility", "hidden") + } + }; + fn._refreshPager = function() { + var options = this.options, + DM = options.pageModel, + $footer = this.$footer, + paging = DM.type ? true : false, + rPP = DM.rPP, + totalRecords = DM.totalRecords; + if (paging) { + var obj = options.pageModel; + if ($footer.hasClass("pq-pager") == false) { + this._initPager() + } + $footer.pqPager("option", obj); + if (totalRecords > rPP) { + this.$bottom.css("display", "") + } + } else { + if ($footer.hasClass("pq-pager")) { + $footer.pqPager("destroy") + } + if (options.showBottom) { + this.$bottom.css("display", "") + } else { + this.$bottom.css("display", "none") + } + } + }; + fn._refreshViewAfterDataSort = function() { + this._refresh() + }; + fn.refreshSortingDataAndView = function() { + this._refreshSortingDataAndView({ + sorting: true + }) + }; + fn.getThis = function() { + return { + that: this + } + }; + fn._addRowsData = function(obj) { + var newdata = obj.data, + data = this.options.dataModel.data, + rowIndx = obj.rowIndx; + if (data == null) { + data = [] + } + if (rowIndx == null) { + for (var i = 0, len = newdata.length; i < len; i++) { + var rowData = newdata[i]; + data.push(rowData) + } + } else { + if (rowIndx < data.length) { + for (var i = 0, len = newdata.length; i < len; i++) { + var rowData = newdata[i]; + data.splice(rowIndx, 0, rowData); + rowIndx++ + } + } else { + return false + } + } + return true + }; + fn.addRows = function(obj) { + if (this._addRowsData(obj)) { + this.refreshDataFromDataModel(); + this.refresh(); + return true + } else { + return false + } + }; + fn.refreshDataAndView = function(objP) { + var DM = this.options.dataModel; + this.iSort._refreshSorters(); + if (DM.location == "remote") { + var self = this; + this.remoteRequest({ + callback: function() { + self._onDataAvailable(objP) + } + }) + } else { + this._onDataAvailable(objP) + } + }; + fn.getColIndx = function(obj) { + var dataIndx = obj.dataIndx; + if (dataIndx === undefined) { + throw ("dataIndx NA") + } + var thisColModel = this.colModel; + for (var i = 0, len = thisColModel.length; i < len; i++) { + if (thisColModel[i].dataIndx == dataIndx) { + return i + } + } + }; + fn.getColumn = function(obj) { + if (obj.dataIndx === undefined) { + throw ("dataIndx N/A") + } + var dataIndx = obj.dataIndx; + var thisColModel = this.colModel; + for (var i = 0, len = thisColModel.length; i < len; i++) { + var column = thisColModel[i]; + if (column.dataIndx == dataIndx) { + return column + } + } + return null + }; + fn._onDataAvailable = function() {}; + fn._computeOuterWidths = function() { + var thisOptions = this.options, + columnBorders = thisOptions.columnBorders, + numberCell = thisOptions.numberCell, + thisColModel = this.colModel, + outerWidths = this.outerWidths, + thisColModelLength = thisColModel.length; + for (var i = 0; i < thisColModelLength; i++) { + var column = thisColModel[i]; + outerWidths[i] = parseInt(column.width) + ((columnBorders) ? 1 : 0) + } + if (numberCell.show) { + this.numberCell_outerWidth = numberCell.width + 1 + } + return + }; + fn._setOption = function(key, value) { + var options = this.options; + if (key == "height") { + this.element.height(value); + this._super.call(this, key, value) + } else { + if (key == "width") { + this._super.call(this, key, value); + this._refreshGridWidth() + } else { + if (key == "title") { + this._super.call(this, key, value); + this._refreshTitle() + } else { + if (key == "roundCorners") { + if (value) { + this.element.addClass("ui-corner-all"); + this.$top.addClass("ui-corner-top"); + this.$bottom.addClass("ui-corner-bottom") + } else { + this.element.removeClass("ui-corner-all"); + this.$top.removeClass("ui-corner-top"); + this.$bottom.removeClass("ui-corner-bottom") + } + } else { + if (key == "freezeCols") { + if (!isNaN(value) && value >= 0 && parseInt(value) <= this.colModel.length - 2) { + options.freezeCols = parseInt(value); + this._refreshFreezeLine(); + this._setScrollHLength(); + this._super.call(this, key, value) + } + } else { + if (key == "resizable") { + this._super.call(this, key, value) + } else { + if (key == "scrollModel") { + this._super.call(this, key, value) + } else { + if (key == "dataModel") { + this._super.call(this, key, value) + } else { + if (key == "pageModel") { + this._super.call(this, key, value) + } else { + if (key === "selectionModel") { + var obj = value; + for (var key in obj) { + this.options.selectionModel[key] = obj[key] + } + } else { + if (key === "colModel") { + this._super.call(this, key, value); + this._calcThisColModel(); + this._refresh() + } else { + if (key === "disabled") { + if (value === true) { + this._disable() + } else { + this._enable() + } + } else { + if (key === "numberCell") { + this._super.call(this, key, value) + } else { + if (key === "customData") { + this._super.call(this, key, value) + } else { + if (key === "strLoading") { + this._super.call(this, key, value); + this._refreshLoadingString() + } else { + if (key === "showTop") { + if (value === true) { + this.$top.css("display", "") + } else { + this.$top.css("display", "none") + } + } else { + if (key === "showTitle") { + if (value === true) { + this.$title.css("display", "") + } else { + this.$title.css("display", "none") + } + } else { + if (key === "showToolbar") { + if (value === true) { + this.$toolbar.css("display", "") + } else { + this.$toolbar.css("display", "none") + } + } else { + if (key == "toolbar") { + this.$toolbar.remove(); + this._super.call(this, key, value); + this._createToolbar() + } else { + if (key === "collapsible") { + if (value === true) { + if (!this.$collapsible) { + this._createSlidingTop() + } + this.$collapsible.css("display", "") + } else { + if (this.$collapsible) { + this.$collapsible.css("display", "none") + } + } + } else { + if (key === "showBottom") { + if (value === true) { + this.$bottom.css("display", "") + } else { + this.$bottom.css("display", "none") + } + } else { + this._super.call(this, key, value) + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }; + fn._setOptions = function() { + this._super.apply(this, arguments) + }; + fn._generateCellRowOutline = function(obj) { + var $td = obj.$td, + $tr = obj.$tr, + rowIndxStart = obj.rowIndxStart, + cellBW = this.options.editModel.cellBorderWidth, + colIndxStart = obj.colIndxStart, + rowIndxEnd = obj.rowIndxEnd, + colIndxEnd = obj.colIndxEnd, + that = this; + if ($tr) { + var wd = that._calcRightEdgeCol(that.colModel.length - 1); + wd -= 4; + var ht = $tr[0].offsetHeight - 4; + var $table = $($tr[0].offsetParent); + var offsetParent = $table[0].offsetParent; + var lft = $tr[0].offsetLeft + $table[0].offsetLeft; + var top = $tr[0].offsetTop + $table[0].offsetTop; + that._generateCellHighlighter(offsetParent, lft, top, wd, ht) + } else { + if ($td) { + var $table = $($td[0].offsetParent); + var offsetParent = $table[0].offsetParent; + var wd = $td[0].offsetWidth - (cellBW ? (cellBW * 2) : 1); + var ht = $td[0].offsetHeight - (cellBW ? (cellBW * 2) : 1); + var lft = $td[0].offsetLeft + $table[0].offsetLeft + offsetParent.offsetLeft; + var top = $td[0].offsetTop + $table[0].offsetTop - this.$cont.scrollTop(); + that._generateCellHighlighter(offsetParent, lft, top, wd, ht, $td) + } + } + }; + fn._removeCellRowOutline = function(objP) { + if (objP && objP.old && this.$div_focus_old) { + var $editor = this.$div_focus_old.find(".pq-editor-focus"); + if ($editor[0] && $editor[0] == document.activeElement) { + if (this.options.debug) { + throw ("assert failed") + } + } + this.$div_focus_old.remove(); + this.$div_focus_old = null + } else { + if (this.$div_focus) { + var $editor = this.$div_focus.find(".pq-editor-focus"); + if ($editor[0] == document.activeElement) { + $editor.blur() + } + this.$div_focus.remove(); + this.$div_focus = null + } + } + }; + fn._generateCellHighlighter = function(offsetParent, lft, top, wd, ht, $td) { + var cellBW = this.options.editModel.cellBorderWidth, + $div_focus = this.$div_focus; + if ($div_focus) { + this.$div_focus_old = $div_focus + } + this.$div_focus = $("
").appendTo(this.$cont_o); + this.$div_focus.css({ + left: lft, + top: top, + height: ht, + width: wd, + borderWidth: cellBW + }) + }; + fn._onHeaderCellClick = function(colIndx, evt) { + var that = this, + column = that.colModel[colIndx], + thisOptions = this.options, + DM = thisOptions.dataModel, + dataIndx = column.dataIndx, + dataType = column.dataType; + if (that._trigger("headerCellClick", evt, { + column: column, + colIndx: colIndx, + dataIndx: dataIndx + }) === false) { + return + } + if (!thisOptions.sortable) { + return + } + if (column.sortable == false) { + return + } + this.sort({ + colIndx: colIndx, + column: column, + dataIndx: dataIndx + }) + }; + fn._selectRow = function(rowIndx, evt) { + this.selectRow(rowIndx, evt) + }; + fn._findfirstUnhiddenColIndx = function() { + for (var i = 0; i < this.colModel.length; i++) { + if (!this.colModel[i].hidden) { + return i + } + } + }; + fn.selectRow = function(obj) { + var rowIndx = obj.rowIndx, + evt = obj.evt, + offset = obj.offset; + if (evt && (evt.type == "keydown" || evt.type == "keypress")) { + if (this.iRows.replace(obj) == false) { + return false + } + } else { + if (this.iRows.add(obj) == false) { + return false + } + } if (evt != null) {} + return true + }; + fn.scrollY = function(rowIndx) { + this.$vscroll.pqScrollBar("option", "cur_pos", rowIndx).pqScrollBar("scroll") + }; + fn._get$Tbl = function(rowIndxPage, colIndx) { + return this.$tbl + }; + fn.scrollCell = function(obj) { + this.scrollRow(obj); + this.scrollColumn(obj) + }; + fn.scrollRow = function(obj) { + var rowIndxPage = obj.rowIndxPage, + nested = (this.iHierarchy ? true : false), + rowIndx = obj.rowIndx, + scrollCurPos = this.scrollCurPos, + rowIndxPage = (rowIndxPage == null) ? (rowIndx - this.rowIndxOffset) : rowIndxPage, + thisOptions = this.options, + freezeRows = parseInt(thisOptions.freezeRows); + if (rowIndxPage < freezeRows) { + return + } + var calcCurPos = this._calcCurPosFromRowIndxPage(rowIndxPage); + if (calcCurPos == null) { + return + } + if (calcCurPos < scrollCurPos) { + this.$vscroll.pqScrollBar("option", "cur_pos", calcCurPos).pqScrollBar("scroll") + } + var $tbl = this._get$Tbl(rowIndxPage); + var $trs = $tbl.children("tbody").children("tr[pq-row-indx=" + rowIndxPage + "]"), + $tr = $trs.last(), + $tr_first = $tr; + if ($trs.length > 1) { + $tr_first = $trs.first() + } + if ($tr[0] == undefined) { + this.$vscroll.pqScrollBar("option", "cur_pos", calcCurPos).pqScrollBar("scroll") + } else { + var td_bottom = $tr[0].offsetTop + $tr[0].offsetHeight, + htCont = this.$cont[0].offsetHeight, + marginTop = parseInt($tbl.css("marginTop")), + htSB = this._getScollBarHorizontalHeight(), + $tr_prev = $tr_first.prev("tr"); + if ($tr_prev.hasClass("pq-row-hidden") || $tr_prev.hasClass("pq-last-freeze-row")) { + return + } else { + if (td_bottom > htCont - htSB - marginTop) { + var diff = td_bottom - (htCont - htSB - marginTop); + var $trs = $tbl.children().children("tr"); + var ht = 0, + indx = 0; + var $tr_next; + if (freezeRows) { + $tr_next = $trs.filter("tr.pq-last-freeze-row").last().next(); + if ($tr_next.length == 0) { + $tr_next = $trs.filter("tr.pq-row-hidden").next() + } + } else { + $tr_next = $trs.filter("tr.pq-row-hidden").next() + } + do { + ht += $tr_next[0].offsetHeight; + if ($tr_next[0] == $tr[0]) { + break + } else { + if (!nested || ($tr_next.hasClass("pq-detail-child") == false)) { + indx++; + if (ht >= diff) { + break + } + } else { + if (ht >= diff) { + break + } + } + } + $tr_next = $tr_next.next() + } while (1 === 1); + var cur_pos = scrollCurPos + indx; + if (cur_pos > calcCurPos) { + cur_pos = calcCurPos + } + var num_eles = this.$vscroll.pqScrollBar("option", "num_eles"); + if (num_eles < cur_pos + 1) { + num_eles = cur_pos + 1 + } + this.$vscroll.pqScrollBar("option", { + num_eles: num_eles, + cur_pos: cur_pos + }).pqScrollBar("scroll") + } + } + } + }; + fn._bringCellToView = function(objP) { + if (objP.rowIndxPage == null || objP.colIndx == null) { + throw "rowIndxPage/colIndx NA" + } + var rowIndxPage = objP.rowIndxPage, + colIndx = objP.colIndx, + tdneedsRefresh = false, + freezeCols = this.options.freezeCols; + var $td; + if (this.hidearrHS[colIndx]) { + this.hidearrHS[colIndx] = false; + var cur_pos = colIndx - freezeCols - this._calcNumHiddenUnFrozens(colIndx); + this.$hscroll.pqScrollBar("option", "cur_pos", cur_pos).pqScrollBar("scroll"); + tdneedsRefresh = true + } else { + var $td = this.getCell(objP); + if ($td == null || $td.length == 0) { + return false + } + var td_right = this._calcRightEdgeCol(colIndx).width; + var wdSB = this._getScollBarVerticalWidth(); + if (td_right > this.$cont[0].offsetWidth - wdSB) { + var diff = calcWidthCols.call(this, -1, colIndx + 1) - (this.$cont[0].offsetWidth - wdSB); + var $tds = $td.parent("tr").children("td"); + var CM = this.colModel, + outerWidths = this.outerWidths, + CMLength = CM.length; + var wd = 0, + initH = 0; + for (var i = freezeCols; i < CMLength; i++) { + if (!CM[i].hidden) { + wd += outerWidths[i] + } + if (i == colIndx) { + initH = i - freezeCols - this._calcNumHiddenUnFrozens(i); + break + } else { + if (wd >= diff) { + initH = i - freezeCols - this._calcNumHiddenUnFrozens(i) + 1; + break + } + } + } + this.$hscroll.pqScrollBar("option", "cur_pos", initH).pqScrollBar("scroll"); + tdneedsRefresh = true + } + } if (tdneedsRefresh) { + var $td = this.getCell({ + rowIndxPage: rowIndxPage, + colIndx: colIndx + }); + return $td + } else { + return $td + } + }; + fn.scrollColumn = function(objP) { + var colIndx = objP.colIndx, + colIndx = (colIndx == null) ? this.getColIndx({ + dataIndx: objP.dataIndx + }) : colIndx, + freezeCols = this.options.freezeCols; + var td_right = this._calcRightEdgeCol(colIndx).width, + wdSB = this._getScollBarVerticalWidth(), + cont_wd = this.$cont[0].offsetWidth; + if (td_right > cont_wd - wdSB) { + var diff = calcWidthCols.call(this, -1, colIndx + 1) - (cont_wd - wdSB), + CM = this.colModel, + outerWidths = this.outerWidths, + CMLength = CM.length, + wd = 0, + initH = 0; + for (var i = freezeCols; i < CMLength; i++) { + if (!CM[i].hidden) { + wd += outerWidths[i] + } + if (i == colIndx) { + initH = i - freezeCols - this._calcNumHiddenUnFrozens(i); + break + } else { + if (wd >= diff) { + initH = i - freezeCols - this._calcNumHiddenUnFrozens(i) + 1; + break + } + } + } + this.$hscroll.pqScrollBar("option", "cur_pos", initH).pqScrollBar("scroll"); + return true + } else { + if (this.hidearrHS[colIndx]) { + this.hidearrHS[colIndx] = false; + var cur_pos = colIndx - freezeCols - this._calcNumHiddenUnFrozens(colIndx); + this.$hscroll.pqScrollBar("option", "cur_pos", cur_pos).pqScrollBar("scroll"); + return true + } + } + return false + }; + fn.selection = function(obj) { + var rowIndx = obj.rowIndx, + colIndx = obj.colIndx, + method = obj.method, + type = obj.type; + if (type == "row") { + return this["iRows"][method](obj) + } else { + if (type == "cell") { + return this["iCells"][method](obj) + } + } + return + }; + fn._bringPageIntoView = function(obj) { + var rowIndx = obj.rowIndx, + that = this; + var DM = this.options.pageModel; + if (DM.type == "local" && rowIndx >= 0) { + var curPage = DM.curPage; + var rPP = DM.rPP; + var begIndx = (curPage - 1) * rPP; + var endIndx = curPage * rPP; + if (rowIndx >= begIndx && rowIndx < endIndx) {} else { + DM.curPage = Math.ceil((rowIndx + 1) / rPP); + this.refreshDataFromDataModel(); + this._refreshViewAfterDataSort() + } + } + }; + fn.goToPage = function(obj) { + var DM = this.options.pageModel; + if (DM.type == "local" || DM.type == "remote") { + var rowIndx = obj.rowIndx, + rPP = DM.rPP, + page = (obj.page == null) ? Math.ceil((rowIndx + 1) / rPP) : obj.page, + curPage = DM.curPage; + if (page != curPage) { + DM.curPage = page; + if (DM.type == "local") { + this.refreshDataFromDataModel(); + this._refresh() + } else { + this.refreshDataAndView() + } + } + } + }; + fn.setSelection = function(obj) { + if (obj == null) { + this.iRows.removeAll({ + raiseEvent: true + }); + this.iCells.removeAll({ + raiseEvent: true + }); + return false + } + var data = this.data, + rowIndx, rowIndxPage; + if (obj.rowData) { + var obj2 = this.getRowIndx(obj); + rowIndx = obj2.rowIndx + } else { + var offset = this.rowIndxOffset, + rowIndx = obj.rowIndx, + rowIndxPage = obj.rowIndxPage, + rowIndx = (rowIndx == null) ? rowIndxPage + offset : rowIndx + } + var colIndx = (obj.colIndx == null && obj.dataIndx !== undefined) ? this.getColIndx({ + dataIndx: obj.dataIndx + }) : obj.colIndx, + evt = obj.evt; + if (rowIndx < 0 || colIndx < 0 || colIndx >= this.colModel.length) { + return false + } + if (data == null || data.length == 0) { + return false + } + obj.rowIndx = rowIndx; + obj.colIndx = colIndx; + this._bringPageIntoView(obj); + rowIndxPage = rowIndx - this.rowIndxOffset; + obj.rowIndxPage = rowIndxPage; + this.scrollRow({ + rowIndxPage: rowIndxPage + }); + if (colIndx == null) { + return this._selectRow(obj) + } else { + this._bringCellToView({ + rowIndxPage: rowIndxPage, + colIndx: colIndx + }); + return this.selectCell(obj) + } + }; + fn.getColModel = function() { + return this.colModel + }; + fn.saveEditCell = function(objP) { + if (this.$td_edit == null) { + return + } + var $td = this.$td_edit, + evt = objP ? objP.evt : null, + obj = this.getCellIndices({ + $td: $td + }), + offset = this.rowIndxOffset, + colIndx = obj.colIndx, + rowIndxPage = obj.rowIndxPage, + rowIndx = rowIndxPage + offset, + thisColModel = this.colModel, + column = thisColModel[colIndx], + dataIndx = column.dataIndx, + rowData = this.data[rowIndxPage], + options = this.options, + DM = options.dataModel, + oldVal; + if (rowData == null) { + return + } else { + oldVal = rowData[dataIndx] + } + obj.rowIndx = rowIndx; + obj.column = column; + obj.dataIndx = dataIndx; + if (rowIndxPage != null) { + var newVal = this._getEditCellData(obj); + if (newVal == "
") { + newVal = "" + } + if (oldVal == null && newVal === "") { + newVal = null + } + var objCell = { + rowIndx: rowIndx, + dataIndx: dataIndx, + column: column, + newVal: newVal, + value: newVal, + oldVal: oldVal, + rowData: rowData, + dataModel: DM + }; + if (this._trigger("cellBeforeSave", evt, objCell) === false) { + return false + } + if (newVal != oldVal) { + rowData[dataIndx] = newVal; + this._trigger("cellSave", evt, objCell); + if (options.track) { + var rowData = this.getRowData({ + rowIndx: rowIndx + }); + this.iUCData.update({ + rowData: rowData, + dataIndx: dataIndx, + oldVal: oldVal, + newVal: newVal + }) + } + this.refreshCell(obj); + this._fixTableViewPort(); + var that = this; + if (options.flexHeight) { + that.setGridHeightFromTable(); + that._fixIEFooterIssue() + } else { + if (objP) { + that.scrollRow({ + rowIndxPage: rowIndxPage + }) + } + } + } + return true + } + }; + fn._fixTableViewPort = function() { + var cont = this.$cont[0]; + cont.scrollTop = 0; + cont.scrollLeft = 0 + }; + fn._fixIEFooterIssue = function() { + $(".pq-grid-footer").css({ + position: "absolute" + }); + $(".pq-grid-footer").css({ + position: "relative" + }) + }; + fn.refreshColumn = function(obj) { + var customData = this.options.customData, + colIndx = (obj.colIndx == null) ? this.getColIndx({ + dataIndx: obj.dataIndx + }) : obj.colIndx, + offset = this.getRowIndxOffset(); + obj.colIndx = colIndx; + for (var row = this.init; row <= this["final"]; row++) { + var rowIndxPage = row; + obj.rowIndx = rowIndxPage + offset; + obj.rowIndxPage = rowIndxPage; + var column = this.colModel[colIndx]; + obj.$td = this.getCell(obj); + obj.rowData = this.data[rowIndxPage]; + obj.customData = customData; + obj.column = column; + this.iGenerateView._renderCell(obj) + } + }; + fn.refreshCell = function(obj) { + if (!this.data) { + return + } + var offset = this.rowIndxOffset, + rowIndx = obj.rowIndx, + rowIndxPage = obj.rowIndxPage, + rowIndx = obj.rowIndx = (rowIndx == null) ? rowIndxPage + offset : rowIndx, + rowIndxPage = obj.rowIndxPage = (rowIndxPage == null) ? rowIndx - offset : rowIndxPage, + dataIndx = obj.dataIndx, + colIndx = obj.colIndx, + colIndx = obj.colIndx = (colIndx == null) ? this.getColIndx({ + dataIndx: dataIndx + }) : colIndx, + $td = obj.$td = (obj.$td == null) ? this.getCell(obj) : obj.$td, + column = obj.column = this.colModel[colIndx], + TVM = this.options.treeModel, + rowData = this.data[rowIndxPage]; + if (!rowData) { + return + } + var objRender = obj; + objRender.tree = TVM.labelIndx ? true : false, objRender.rowData = rowData; + objRender.customData = this.options.customData; + if ($td && $td.length > 0) { + this.iGenerateView._renderCell(objRender) + } + }; + fn.refreshRow = function(obj) { + if (!this.data) { + return + } + var thisOptions = this.options, + offset = this.rowIndxOffset, + rowIndx = obj.rowIndx, + rowIndxPage = obj.rowIndxPage, + rowIndx = (rowIndx == null) ? rowIndxPage + offset : rowIndx, + rowIndxPage = (rowIndxPage == null) ? rowIndx - offset : rowIndxPage, + $trOld = (obj.$tr == null) ? this.getRow(obj) : obj.$tr, + CM = this.colModel, + rowData = this.data[rowIndxPage]; + if (!rowData) { + return + } + var buffer = []; + this.iGenerateView._generateRow(rowData, rowIndxPage, CM, buffer, null); + var trStr = buffer.join(""); + $trOld.replaceWith(trStr); + this._trigger("refresh", null, { + type: "row", + dataModel: thisOptions.dataModel, + colModel: CM, + rowData: rowData, + rowIndx: rowIndx, + rowIndxPage: rowIndxPage + }); + return + }; + fn.quitEditMode = function(objP) { + var that = this, + old = false, + silent = false, + fireOnly = false, + SM = this.options.selectionModel, + evt = undefined; + if (objP) { + old = objP.old; + silent = objP.silent; + fireOnly = objP.fireOnly; + evt = objP.evt + } + var $td = old ? this.$td_edit_old : this.$td_edit; + if ($td) { + var rowIndx, rowIndxPage, colIndx, column, dataIndx, setNull = function() { + if (old) { + that.$td_edit_old = null + } else { + that.$td_edit = null + } + }; + if (!old) { + this.disableSelection() + } + var obj = this.getCellIndices({ + $td: $td + }); + if (obj && obj.rowIndx != null) { + rowIndx = obj.rowIndx; + rowIndxPage = rowIndx - this.offsetRowIndx, colIndx = obj.colIndx; + column = this.colModel[colIndx]; + dataIndx = column.dataIndx + } else { + setNull(); + return + } if (!old && !fireOnly) { + if (SM.type == "cell") { + $td.attr("tabindex", "0").focus() + } else { + if (SM.type == "row") { + $td.parent("tr.pq-grid-row").attr("tabindex", "0").focus() + } + } + } + if (!silent && !old) { + this._trigger("quitEditMode", evt, { + $td: $td, + rowIndx: rowIndx, + rowIndxPage: rowIndxPage, + colIndx: colIndx, + column: column, + dataIndx: dataIndx, + rowData: this.data[rowIndxPage] + }) + } + if (!fireOnly) { + this._removeCellRowOutline(objP); + setNull() + } + } + }; + fn.getData = function() { + return this.data + }; + fn.getViewPortRowsIndx = function() { + return { + beginIndx: this.init, + endIndx: this["final"] + } + }; + fn.getRowIndxOffset = function() { + return this.rowIndxOffset + }; + fn.selectCell = function(obj) { + var rowIndx = obj.rowIndx, + colIndx = obj.colIndx, + evt = obj.evt; + if (evt && (evt.type == "keydown" || evt.type == "keypress")) { + if (this.iCells.replace(obj) == false) { + return false + } + } else { + if (this.iCells.add(obj) == false) { + return false + } + } if (evt != null) {} + return true + }; + fn._setGridFocus = function() { + var that = this; + var focusReq = true; + window.setTimeout(function() { + if (that.$td_edit == null) { + if (focusReq) { + focusReq = false + } + } + }, 0) + }; + fn.getEditCell = function() { + if (this.$td_edit) { + return { + $td: this.$td_edit, + $cell: this.$div_focus + } + } else { + return null + } + }; + fn.editCell = function(obj) { + var $td = this.getCell(obj); + if ($td != null && $td.length > 0) { + this._editCell($td); + return $td + } + }; + fn.getFirstEditableColIndx = function(objP) { + if (objP.rowIndx == null) { + throw "rowIndx NA" + } + if (!this.isEditableRow(objP)) { + return -1 + } + var CM = this.colModel; + for (var i = 0; i < CM.length; i++) { + objP.colIndx = i; + if (!this.isEditableCell(objP)) { + continue + } else { + if (CM[i].hidden) { + continue + } + } + return i + } + return -1 + }; + fn.editFirstCellInRow = function(objP) { + var offset = this.rowIndxOffset, + rowIndx = objP.rowIndx, + rowIndxPage = objP.rowIndxPage, + rowIndx = (rowIndx == null) ? (rowIndxPage + offset) : rowIndx, + rowIndxPage = (rowIndxPage == null) ? (rowIndx - offset) : rowIndxPage, + colIndx = this.getFirstEditableColIndx({ + rowIndx: rowIndx + }); + if (colIndx != -1) { + this.scrollRow({ + rowIndxPage: rowIndxPage + }); + var $td = this._bringCellToView({ + colIndx: colIndx, + rowIndxPage: rowIndxPage + }); + if ($td && $td.length > 0) { + this._editCell($td) + } + } + }; + fn._editCell = function($td) { + var that = this; + var obj = that.getCellIndices({ + $td: $td + }); + var rowIndxPage = obj.rowIndxPage, + offset = this.rowIndxOffset, + rowIndx = rowIndxPage + offset, + colIndx = obj.colIndx, + column = this.colModel[colIndx], + ceditor = column.editor, + geditor = this.options.editor, + editor = ceditor ? $.extend({}, geditor, ceditor) : geditor, + rowData = that.data[rowIndxPage], + contentEditable = false, + dataIndx = column.dataIndx; + if (this.$td_edit) { + if (this.$td_edit[0] == $td[0]) { + return false + } else { + this.$td_edit_old = this.$td_edit; + this.quitEditMode({ + fireOnly: true + }) + } + } + this.$td_edit = $td; + this._generateCellRowOutline({ + $td: $td + }); + var $cell = this.$div_focus.addClass("pq-editor-border-edit"); + if (column.align == "right") { + $cell.addClass("pq-align-right") + } else { + if (column.align == "center") { + $cell.addClass("pq-align-center") + } else { + $cell.addClass("pq-align-left") + } + } + var cellWd = $cell.width() - 8, + cellData = rowData[dataIndx], + inp; + var edtype = editor.type, + edSelect = editor.select, + edcls = editor.cls ? editor.cls : "", + cls = "pq-editor-focus " + edcls, + cls2 = cls + " pq-cell-editor ", + attr = editor.attr ? editor.attr : "", + edstyle = editor.style, + edstyle = (edstyle ? edstyle : ""), + styleCE = edstyle ? ("style='" + edstyle + "'") : "", + style = "style='width:" + cellWd + "px;" + edstyle + "'", + styleChk = edstyle ? ("style='" + edstyle + "'") : ""; + if (typeof edtype == "function") { + inp = edtype.call(that.element, { + $cell: $cell, + cellData: cellData, + rowData: rowData, + cls: cls, + dataIndx: dataIndx, + data: editor.data, + column: column + }) + } else { + if (edtype == "checkbox") { + var subtype = editor.subtype; + var checked = cellData ? "checked='checked'" : ""; + inp = ""; + $cell.html(inp); + var $ele = $cell.children("input"); + if (subtype == "triple") { + $ele.pqval({ + val: cellData + }); + $cell.click(function(evt) { + $(this).children("input").pqval({ + incr: true + }) + }) + } + } else { + if (edtype == "textarea" || edtype == "select" || edtype == "textbox") { + if (edtype == "textarea") { + inp = "" + } else { + if (edtype == "select") { + var options = editor.options; + var options = options ? options : []; + if (typeof options === "function") { + options = options.call(that.element, { + column: column, + rowData: rowData + }) + } + var attrSelect = [attr, " class='", cls2, "' ", style, " name='", dataIndx, "'"].join(""); + inp = $.paramquery.select({ + options: options, + attr: attrSelect, + labelIndx: editor.labelIndx, + valueIndx: editor.valueIndx, + groupIndx: editor.groupIndx + }) + } else { + inp = "" + } + } + $cell.html(inp); + $cell.children().val(cellData) + } else { + inp = "
"; + $cell.html(inp); + $cell.children().html(cellData); + contentEditable = true + } + } + } + var that = this; + if (that.$td_edit != null) { + var $cell = that.$div_focus, + $focus = $cell.children(".pq-editor-focus"); + $focus.focus(); + $focus.bind("keydown", function(evt) { + that.iKeyNav._bodyKeyPressDownInEdit(evt) + }); + if (that._trigger("cellEditFocus", null, { + $cell: $cell, + $editor: $focus, + dataIndx: dataIndx, + column: column, + rowIndx: rowIndx, + rowData: rowData + }) == false) { + return false + } + if (edSelect) { + if (contentEditable) { + try { + var el = $focus[0]; + var range = document.createRange(); + range.selectNodeContents(el); + var sel = window.getSelection(); + sel.removeAllRanges(); + sel.addRange(range) + } catch (ex) {} + } else { + $focus.select() + } + } + } + if (that.$td_edit_old) { + that.quitEditMode({ + old: true + }) + } + }; + fn.getRow = function(obj) { + var rowIndxPage = obj.rowIndxPage, + rowIndx = obj.rowIndx, + offset = this.rowIndxOffset, + DM = this.options.dataModel; + var $tr, $tbl = this.$tbl; + if ($tbl != undefined) { + var $tbody = $tbl.children("tbody"); + if (rowIndxPage != null) { + $tr = $tbody.children("tr[pq-row-indx=" + rowIndxPage + "]") + } else { + if (rowIndx != null) { + $tr = $tbody.children("tr[pq-row-indx=" + (rowIndx - offset) + "]") + } + } + } + return $tr + }; + fn.getCell = function(obj) { + var rowIndxPage = obj.rowIndxPage, + rowIndx = obj.rowIndx, + rowIndxPage = (rowIndxPage == null) ? (rowIndx - this.rowIndxOffset) : rowIndxPage, + colIndx = obj.colIndx, + dataIndx = obj.dataIndx, + colIndx = (colIndx == null) ? this.getColIndx({ + dataIndx: dataIndx + }) : colIndx, + $tbl = this.$tbl, + $td, thisOptions = this.options, + freezeCols = thisOptions.freezeCols; + if ($tbl != undefined) { + if ($tbl.length > 1) { + if (colIndx >= freezeCols) { + $tbl = $($tbl[1]) + } else { + $tbl = $($tbl[0]) + } + } + var $td = $tbl.children().children("tr[pq-row-indx=" + rowIndxPage + "]").children("td[pq-col-indx=" + colIndx + "]") + } + if ($td.length == 0 || $td[0].style.visibility == "hidden") { + return null + } + return $td + }; + fn.getCellHeader = function(obj) { + var colIndx = obj.colIndx, + dataIndx = obj.dataIndx, + colIndx = (colIndx == null) ? this.getColIndx({ + dataIndx: dataIndx + }) : colIndx, + $tbl = this.$tbl_header, + $td, options = this.options, + freezeCols = options.freezeCols; + if ($tbl != undefined) { + if ($tbl.length > 1) { + if (colIndx >= freezeCols) { + $tbl = $($tbl[1]) + } else { + $tbl = $($tbl[0]) + } + } + var $td = $tbl.children().children("tr:last").children("td[pq-col-indx=" + colIndx + "]") + } + if ($td.length == 0 || $td[0].style.visibility == "hidden") { + return null + } + return $td + }; + fn.getEditCellData = function() { + if (this.$td_edit) { + var obj = this.getCellIndices({ + $td: this.$td_edit + }); + return this._getEditCellData(obj) + } else { + return null + } + }; + fn._getEditCellData = function(obj) { + if (obj.colIndx == undefined || obj.rowIndxPage == undefined) { + throw ("colIndx, rowIndxpage N/A") + } + var colIndx = obj.colIndx, + rowIndxPage = obj.rowIndxPage, + rowIndx = (obj.rowIndx != null) ? obj.rowIndx : rowIndxPage + this.rowIndxOffset, + column = (obj.column) ? obj.column : this.colModel[colIndx], + ceditor = column.editor, + geditor = this.options.editor, + editor = ceditor ? $.extend({}, geditor, ceditor) : geditor, + dataIndx = column.dataIndx, + $cell = (obj.$cell) ? obj.$cell : this.$div_focus, + dataCell; + var getData = editor.getData; + if (typeof getData == "function") { + dataCell = editor.getData.call(this.element, { + $cell: $cell, + dataIndx: dataIndx, + rowIndx: rowIndx, + rowIndxPage: rowIndxPage, + column: column + }) + } else { + var edtype = editor.type; + if (edtype == "checkbox") { + var $ele = $cell.children(); + if (editor.subtype == "triple") { + dataCell = $ele.pqval() + } else { + dataCell = $ele.is(":checked") ? true : false + } + } else { + if (edtype == "contenteditable") { + dataCell = $cell.children().html() + } else { + var $ed = $cell.find('*[name="' + dataIndx + '"]'); + if ($ed && $ed.length) { + dataCell = $ed.val() + } else { + var $ed = $cell.find(".pq-editor-focus"); + if ($ed && $ed.length) { + dataCell = $ed.val() + } + } + } + } + } + return dataCell + }; + fn.getCellIndices = function(objP) { + var $td = objP.$td; + if ($td == null || $td.length == 0 || $td.closest(".pq-grid")[0] != this.element[0]) { + return { + rowIndxPage: null, + colIndx: null + } + } + var $tr = $td.parent("tr"); + var rowIndxPage = $tr.attr("pq-row-indx"); + if (rowIndxPage == null) { + return { + rowIndxPage: null, + colIndx: null + } + } + rowIndxPage = parseInt(rowIndxPage); + var colIndx = $td.attr("pq-col-indx"); + if (colIndx == null) { + return { + rowIndxPage: rowIndxPage, + colIndx: null + } + } + colIndx = parseInt(colIndx); + return { + rowIndxPage: rowIndxPage, + rowIndx: rowIndxPage + this.rowIndxOffset, + colIndx: colIndx, + dataIndx: this.colModel[colIndx].dataIndx + } + }; + fn.getRowsByClass = function(obj) { + var options = this.options, + DM = options.dataModel, + PM = options.pageModel, + paging = PM.type, + remotePaging = (paging == "remote") ? true : false, + offset = this.rowIndxOffset, + data = DM.data, + rows = []; + if (data == null) { + return rows + } + for (var i = 0, len = data.length; i < len; i++) { + var rowData = data[i]; + obj.rowData = rowData; + if (this.hasClass(obj)) { + var row = { + rowData: rowData + }; + if (remotePaging) { + row.rowIndx = (i + offset) + } else { + row.rowIndx = i + } + rows.push(row) + } + } + return rows + }; + fn.addClass = function(objP) { + var rowIndx = objP.rowIndx, + dataIndx = objP.dataIndx, + objcls = objP.cls, + offset = this.rowIndxOffset, + rowData = this.getRowData(objP); + if (!rowData) { + return + } + if (rowIndx == null) { + rowIndx = this.getRowIndx({ + rowData: rowData + }).rowIndx + } + var classes = objcls.split(" "); + for (var i = 0; i < classes.length; i++) { + var cls = classes[i]; + if (dataIndx == null && this.hasClass({ + rowData: rowData, + cls: cls + }) === false) { + var str = rowData.pq_rowcls; + if (str) { + rowData.pq_rowcls = $.trim(str) + " " + cls + } else { + rowData.pq_rowcls = cls + } if (rowIndx != null && objP.refresh !== false) { + var $tr = this.getRow({ + rowIndxPage: (rowIndx - offset) + }); + if ($tr) { + $tr.addClass(cls) + } + } + } else { + if (this.hasClass({ + rowData: rowData, + dataIndx: dataIndx, + cls: cls + }) === false) { + var objCls = rowData.pq_cellcls; + if (objCls) { + var oldCls = objCls[dataIndx]; + if (oldCls) { + objCls[dataIndx] = $.trim(oldCls) + " " + cls + } else { + objCls[dataIndx] = cls + } + } else { + var objCls = {}; + objCls[dataIndx] = cls; + rowData.pq_cellcls = objCls + } if (rowIndx != null && objP.refresh !== false) { + var $td = this.getCell({ + rowIndxPage: (rowIndx - offset), + dataIndx: dataIndx + }); + if ($td) { + $td.addClass(cls) + } + } + } + } + } + }; + fn.removeClass = function(objP) { + var rowIndx = objP.rowIndx, + rowData = this.getRowData(objP), + dataIndx = objP.dataIndx, + cls = objP.cls, + pq_cellcls = (dataIndx != null && rowData) ? rowData.pq_cellcls : null, + rowClass = rowData ? rowData.pq_rowcls : null; + if (rowData == null) { + return + } + if (rowIndx == null) { + rowIndx = this.getRowIndx({ + rowData: rowData + }).rowIndx + } + if (dataIndx == null) { + if (rowClass) { + rowData.pq_rowcls = this._removeClass(rowClass, cls) + } + if (rowIndx != null && objP.refresh !== false) { + var $tr = this.getRow({ + rowIndx: rowIndx + }); + if ($tr) { + $tr.removeClass(cls) + } + } + } else { + if (pq_cellcls) { + var cellClass = pq_cellcls[dataIndx]; + if (cellClass) { + rowData.pq_cellcls[dataIndx] = this._removeClass(cellClass, cls) + } + if (rowIndx != null && objP.refresh !== false) { + var $td = this.getCell({ + rowIndx: rowIndx, + dataIndx: dataIndx + }); + if ($td) { + $td.removeClass(cls) + } + } + } + } + }; + fn.hasClass = function(obj) { + var dataIndx = obj.dataIndx, + cls = obj.cls, + rowData = this.getRowData(obj), + re = new RegExp("\\b" + cls + "\\b"), + str; + if (rowData) { + if (dataIndx == null) { + str = rowData.pq_rowcls; + if (str && re.test(str)) { + return true + } else { + return false + } + } else { + var objCls = rowData.pq_cellcls; + if (objCls && objCls[dataIndx] && re.test(objCls[dataIndx])) { + return true + } else { + return false + } + } + } else { + return null + } + }; + fn._removeClass = function(str, str2) { + if (str) { + var arr = str.split(" "), + arr2 = str2.split(" "), + arr3 = []; + for (var i = 0, len = arr.length; i < len; i++) { + var cls = arr[i], + found = false; + for (var j = 0, len2 = arr2.length; j < len2; j++) { + var cls2 = arr2[j]; + if (cls === cls2) { + found = true; + break + } + } + if (!found) { + arr3.push(cls) + } + } + if (arr3.length > 1) { + return arr3.join(" ") + } else { + if (arr3.length === 1) { + return arr3[0] + } else { + return null + } + } + } + }; + fn.getRowIndx = function(obj) { + var $tr = obj.$tr, + rowData = obj.rowData; + if (rowData) { + var options = this.options, + DM = options.dataModel, + PM = options.pageModel, + paging = PM.type, + remotePaging = (paging == "remote") ? true : false, + data = DM.data, + _found = false; + if (data) { + for (var i = 0, len = data.length; i < len; i++) { + if (data[i] == rowData) { + _found = true; + break + } + } + } + if (_found) { + var offset = this.rowIndxOffset, + rowIndxPage = (remotePaging) ? i : (i - offset), + rowIndx = (remotePaging) ? (i + offset) : i; + return { + rowIndxPage: rowIndxPage, + rowIndx: rowIndx + } + } else { + return {} + } + } else { + if ($tr == null || $tr.length == 0) { + return { + rowIndxPage: null + } + } + var rowIndxPage = $tr.attr("pq-row-indx"); + if (rowIndxPage == null) { + return { + rowIndxPage: null + } + } + rowIndxPage = parseInt(rowIndxPage); + return { + rowIndxPage: rowIndxPage, + rowIndx: rowIndxPage + this.rowIndxOffset + } + } + }; + var cKeyNav = function(that) { + this.options = that.options; + this.that = that; + var self = this; + var widgetEventPrefix = that.widgetEventPrefix.toLowerCase(); + that.element.on(widgetEventPrefix + "celleditkeydown", function(evt, ui) { + return self.filterKeys(evt, ui) + }) + }; + var _pKeyNav = cKeyNav.prototype; + _pKeyNav._incrRowIndx = function(rowIndxPage, noRows) { + var that = this.that, + newRowIndx = rowIndxPage, + noRows = (noRows == null) ? 1 : noRows, + data = that.data, + counter = 0; + for (var i = rowIndxPage + 1, len = data.length; i < len; i++) { + var hidden = data[i].pq_hidden; + if (!hidden) { + counter++; + newRowIndx = i; + if (counter == noRows) { + return newRowIndx + } + } + } + return newRowIndx + }; + _pKeyNav._decrRowIndx = function(rowIndxPage, noRows) { + var that = this.that, + newRowIndx = rowIndxPage, + data = that.data, + noRows = (noRows == null) ? 1 : noRows, + counter = 0; + for (var i = rowIndxPage - 1; i >= 0; i--) { + var hidden = data[i].pq_hidden; + if (!hidden) { + counter++; + newRowIndx = i; + if (counter == noRows) { + return newRowIndx + } + } + } + return newRowIndx + }; + fn.addColumn = function(column, columnData) { + var thisOptions = this.options, + thisOptionsColModel = thisOptions.colModel, + data = thisOptions.dataModel.data; + thisOptionsColModel.push(column); + this._calcThisColModel(); + for (var i = 0; i < data.length; i++) { + var rowData = data[i]; + rowData.push("") + } + }; + fn.rowNextSelect = function() { + var sel = this.selection({ + type: "row", + method: "getSelection" + }), + rowIndx, rowIndxPage, offset = this.rowIndxOffset; + if (sel && sel[0]) { + rowIndx = sel[0].rowIndx; + rowIndxPage = rowIndx - offset; + rowIndxPage = this.iKeyNav._incrRowIndx(rowIndxPage) + } + if (rowIndxPage != null) { + this.setSelection(null); + this._setSelection({ + rowIndxPage: rowIndxPage + }) + } + return rowIndxPage + }; + fn.rowPrevSelect = function() { + var sel = this.selection({ + type: "row", + method: "getSelection" + }), + rowIndx, rowIndxPage, offset = this.rowIndxOffset; + if (sel && sel[0]) { + rowIndx = sel[0].rowIndx; + rowIndxPage = rowIndx - offset; + rowIndxPage = this.iKeyNav._decrRowIndx(rowIndxPage) + } + if (rowIndxPage != null) { + this.setSelection(null); + this.setSelection({ + rowIndxPage: rowIndxPage + }) + } + return rowIndxPage + }; + _pKeyNav._incrIndx = function(rowIndxPage, colIndx) { + var that = this.that, + lastRowIndxPage = that._getLastVisibleRowIndxPage(that.data), + CM = that.colModel, + CMLength = CM.length; + if (colIndx == null) { + if (rowIndxPage == lastRowIndxPage) { + return null + } + rowIndxPage = this._incrRowIndx(rowIndxPage); + return { + rowIndxPage: rowIndxPage + } + } + var column; + do { + colIndx++; + if (colIndx >= CMLength) { + if (rowIndxPage == lastRowIndxPage) { + return null + } + rowIndxPage = this._incrRowIndx(rowIndxPage); + colIndx = 0 + } + column = CM[colIndx] + } while (column && column.hidden); + return { + rowIndxPage: rowIndxPage, + colIndx: colIndx + } + }; + _pKeyNav._decrIndx = function(rowIndxPage, colIndx) { + var that = this.that, + CM = that.colModel, + CMLength = CM.length, + firstRowIndxPage = that._getFirstVisibleRowIndxPage(that.data); + if (colIndx == null) { + if (rowIndxPage == firstRowIndxPage) { + return null + } + rowIndxPage = this._decrRowIndx(rowIndxPage); + return { + rowIndxPage: rowIndxPage + } + } + var column; + do { + colIndx--; + if (colIndx < 0) { + if (rowIndxPage == firstRowIndxPage) { + return null + } + rowIndxPage = this._decrRowIndx(rowIndxPage); + colIndx = CMLength - 1 + } + column = CM[colIndx] + } while (column && column.hidden); + return { + rowIndxPage: rowIndxPage, + colIndx: colIndx + } + }; + _pKeyNav._incrEditIndx = function(rowIndxPage, colIndx) { + var that = this.that, + CM = that.colModel, + CMLength = CM.length, + column, offset = that.rowIndxOffset, + lastRowIndxPage = that._getLastVisibleRowIndxPage(that.data); + do { + colIndx++; + if (colIndx >= CMLength) { + if (rowIndxPage == lastRowIndxPage) { + return null + } + do { + rowIndxPage = this._incrRowIndx(rowIndxPage); + var rowIndx = rowIndxPage + offset, + isEditableRow = that.isEditableRow({ + rowIndx: rowIndx + }); + if (rowIndxPage == lastRowIndxPage && isEditableRow == false) { + return null + } + } while (isEditableRow == false); + colIndx = 0 + } + column = CM[colIndx]; + var rowIndx = rowIndxPage + offset, + isEditableCell = that.isEditableCell({ + rowIndx: rowIndx, + colIndx: colIndx, + checkVisible: true + }) + } while (column && (column.hidden || isEditableCell == false)); + return { + rowIndxPage: rowIndxPage, + colIndx: colIndx + } + }; + _pKeyNav._decrEditIndx = function(rowIndxPage, colIndx) { + var that = this.that, + CM = that.colModel, + CMLength = CM.length, + column, offset = that.rowIndxOffset, + firstRowIndxPage = that._getFirstVisibleRowIndxPage(that.data); + do { + colIndx--; + if (colIndx < 0) { + if (rowIndxPage == firstRowIndxPage) { + return null + } + do { + rowIndxPage = this._decrRowIndx(rowIndxPage); + var rowIndx = rowIndxPage + offset, + isEditableRow = that.isEditableRow({ + rowIndx: rowIndx + }); + if (rowIndxPage == firstRowIndxPage && isEditableRow == false) { + return null + } + } while (isEditableRow == false); + colIndx = CMLength - 1 + } + column = CM[colIndx]; + var rowIndx = rowIndxPage + offset, + isEditableCell = that.isEditableCell({ + rowIndx: rowIndx, + colIndx: colIndx, + checkVisible: true + }) + } while (column && (column.hidden || isEditableCell == false)); + return { + rowIndxPage: rowIndxPage, + colIndx: colIndx + } + }; + _pKeyNav._incrEditRowIndx = function(rowIndxPage, colIndx) { + var that = this.that, + offset = that.rowIndxOffset, + lastRowIndxPage = that._getLastVisibleRowIndxPage(that.data); + if (rowIndxPage == lastRowIndxPage) { + return null + } + do { + rowIndxPage = this._incrRowIndx(rowIndxPage); + var rowIndx = rowIndxPage + offset, + isEditableRow = that.isEditableRow({ + rowIndx: rowIndx + }), + isEditableCell = that.isEditableCell({ + rowIndx: rowIndx, + colIndx: colIndx + }), + isEditable = (isEditableRow && isEditableCell); + if (rowIndxPage == lastRowIndxPage && !isEditable) { + return null + } + } while (!isEditable); + return { + rowIndxPage: rowIndxPage, + colIndx: colIndx + } + }; + _pKeyNav._decrEditRowIndx = function(rowIndxPage, colIndx) { + var that = this.that, + offset = that.rowIndxOffset, + firstRowIndxPage = that._getFirstVisibleRowIndxPage(that.data); + if (rowIndxPage == firstRowIndxPage) { + return null + } + do { + rowIndxPage = this._decrRowIndx(rowIndxPage); + var rowIndx = rowIndxPage + offset, + isEditableRow = that.isEditableRow({ + rowIndx: rowIndx + }), + isEditableCell = that.isEditableCell({ + rowIndx: rowIndx, + colIndx: colIndx + }), + isEditable = (isEditableRow && isEditableCell); + if (rowIndxPage == firstRowIndxPage && !isEditable) { + return null + } + } while (!isEditable); + return { + rowIndxPage: rowIndxPage, + colIndx: colIndx + } + }; + fn._onKeyPressDown = function(evt) { + var $header = $(evt.target).closest(".pq-grid-header"); + if ($header.length > 0) { + if (this._trigger("headerKeyDown", evt, { + dataModel: this.options.dataModel + }) == false) { + return false + } else { + return true + } + } else { + var ret = this.iKeyNav._bodyKeyPressDown(evt); + if (ret === false) { + return false + } + if (this._trigger("keyDown", evt, { + dataModel: this.options.dataModel + }) == false) { + return false + } + } + }; + _pKeyNav._saveAndMove = function(obj, evt) { + var that = this.that, + thisOptions = this.options, + SM = thisOptions.selectionModel; + if (that.saveEditCell({ + evt: evt + }) == false) { + evt.preventDefault(); + return false + } + if (obj == null) { + evt.preventDefault(); + return false + } + var rowIndxPage = obj.rowIndxPage, + colIndx = obj.colIndx; + if (SM.type == "row") { + that.setSelection(null); + that.setSelection({ + rowIndxPage: rowIndxPage + }); + that._bringCellToView({ + rowIndxPage: rowIndxPage, + colIndx: colIndx + }) + } else { + if (SM.type == "cell") { + that.setSelection(null); + that.setSelection({ + rowIndxPage: rowIndxPage, + colIndx: colIndx + }) + } else { + that.scrollRow({ + rowIndxPage: rowIndxPage + }); + that._bringCellToView({ + rowIndxPage: rowIndxPage, + colIndx: colIndx + }) + } + } + var $td2 = that.getCell({ + rowIndxPage: rowIndxPage, + colIndx: colIndx + }); + if ($td2 && $td2.length > 0) { + that._editCell($td2) + } + evt.preventDefault(); + return false + }; + _pKeyNav._bodyKeyPressDownInEdit = function(evt) { + var that = this.that; + if (!that.$td_edit) { + return + } + var thisOptions = this.options, + offset = that.rowIndxOffset, + keyCodes = $.ui.keyCode, + CM = that.colModel, + gEM = thisOptions.editModel, + $td = $(that.$td_edit[0]), + obj = that.getCellIndices({ + $td: $td + }), + rowIndxPage = obj.rowIndxPage, + rowIndx = rowIndxPage + offset, + colIndx = obj.colIndx, + column = CM[colIndx], + cEM = column.editModel, + EM = cEM ? $.extend({}, gEM, cEM) : gEM; + if (that._trigger("cellEditKeyDown", evt, { + rowData: that.data[rowIndxPage], + $cell: that.$div_focus, + rowIndx: rowIndx, + rowIndxPage: rowIndxPage, + colIndx: colIndx, + $td: $td, + dataIndx: column.dataIndx, + column: column + }) == false) { + return false + } + if (evt.keyCode == keyCodes.TAB) { + var obj; + if (evt.shiftKey) { + obj = this._decrEditIndx(rowIndxPage, colIndx) + } else { + obj = this._incrEditIndx(rowIndxPage, colIndx) + } + return this._saveAndMove(obj, evt) + } else { + if (evt.keyCode == EM.saveKey) { + var obj = this._incrEditIndx(rowIndxPage, colIndx); + return this._saveAndMove(obj, evt) + } else { + if (evt.keyCode == keyCodes.ESCAPE) { + that.quitEditMode({ + evt: evt + }); + evt.preventDefault(); + return false + } else { + if (evt.keyCode == keyCodes.PAGE_UP || evt.keyCode == keyCodes.PAGE_DOWN) { + evt.preventDefault(); + return false + } else { + if (EM.keyUpDown) { + if (evt.keyCode == keyCodes.DOWN) { + var obj = this._incrEditRowIndx(rowIndxPage, colIndx); + return this._saveAndMove(obj, evt) + } else { + if (evt.keyCode == keyCodes.UP) { + var obj = this._decrEditRowIndx(rowIndxPage, colIndx); + return this._saveAndMove(obj, evt) + } + } + } + } + } + } + } + return + }; + _pKeyNav.filterKeys = function(evt, ui) { + var that = this.that, + FK = this.options.editModel.filterKeys; + var column = ui.column, + dataType = column.dataType, + cEM = column.editModel; + if (cEM && cEM.filterKeys != undefined) { + FK = cEM.filterKeys + } + if (!FK) { + return + } + if (dataType == "float" || dataType == "integer") { + var $this = $(evt.originalEvent.target), + nodeName = $this[0].nodeName.toLowerCase(), + re = (dataType == "integer") ? /^[\-]?[0-9]*$/ : /^[\-]?[0-9]*\.?[0-9]*$/; + var valsarr = ["input", "textarea", "select"], + byVal = "text"; + if ($.inArray(nodeName, valsarr) != -1) { + byVal = "val" + } + var oldVal = $this[byVal](); + window.setTimeout(function() { + var newVal = $this[byVal](); + if (re.test(newVal) == false) { + $this[byVal](oldVal) + } + }, 0) + } + }; + _pKeyNav.select = function(objP) { + var that = this.that, + rowIndx = objP.rowIndx, + colIndx = objP.colIndx, + SM = that.options.selectionModel, + evt = objP.evt; + if (evt.shiftKey && SM.mode != "single") { + if (SM.type == "row") { + that.scrollRow({ + rowIndx: rowIndx + }); + that.iRows.extendSelection({ + rowIndx: rowIndx, + evt: evt + }) + } else { + if (SM.type == "cell") { + that.scrollCell({ + rowIndx: rowIndx, + colIndx: colIndx + }); + that.iCells.extendSelection({ + rowIndx: rowIndx, + colIndx: colIndx, + evt: evt + }) + } + } + } else { + that.setSelection({ + rowIndx: rowIndx, + colIndx: colIndx, + evt: evt, + setFirst: true + }) + } + }; + _pKeyNav.createTextbox = function() { + var $text = $("textarea#pq-grid-excel"); + if ($text.length == 0) { + $text = $(""].join("") + }; + $.paramquery.select = function(objP) { + var attr = objP.attr, + opts = objP.options, + groupIndx = objP.groupIndx, + labelIndx = objP.labelIndx, + valueIndx = objP.valueIndx, + prepend = objP.prepend, + groupV, groupVLast; + var buffer = [""); + return buffer.join("") + }; + $.fn.pqval = function(obj) { + if (obj) { + if (obj.incr) { + var val = this.data("pq_value"); + this.prop("indeterminate", false); + if (val) { + val = false; + this.removeAttr("checked") + } else { + if (val === false) { + val = null; + this.prop("indeterminate", true); + this.removeAttr("checked") + } else { + val = true; + this.attr("checked", "checked") + } + } + this.data("pq_value", val); + return val + } else { + var val = obj.val; + this.data("pq_value", val); + this.prop("indeterminate", false); + if (val == null) { + this.prop("indeterminate", true); + this.removeAttr("checked") + } else { + if (val) { + this.attr("checked", "checked") + } else { + this.removeAttr("checked") + } + } + return this + } + } else { + return this.data("pq_value") + } + }; + var _pGenerateView = {}; + _pGenerateView._generateTitleRow = function(GM, rowObj, buffer, lastFrozenRow) { + var that = this.that, + thisOptions = that.options, + numberCell = thisOptions.numberCell, + groupTitle = rowObj.groupTitle, + GMTitle = GM.title, + groupLevel = rowObj.level, + GMRowIndx = rowObj.GMRowIndx, + GMIcon = GM.icon, + GMIcon = GMIcon ? GMIcon[groupLevel] : null, + GMIcon = (GMIcon && GMIcon.length && GMIcon.length == 2 && typeof GMIcon.push === "function") ? GMIcon : ["ui-icon-minus", "ui-icon-plus"]; + if (GMTitle && GMTitle[groupLevel] != null) { + if (GMTitle[groupLevel] === false) { + return + } + groupTitle = GMTitle[groupLevel].replace("{0}", groupTitle); + groupTitle = groupTitle.replace("{1}", rowObj.items) + } else { + groupTitle = groupTitle + " - " + rowObj.items + " item(s)" + } + buffer.push([""].join("")); + if (numberCell.show) { + buffer.push("
") + } + var icon = GMIcon[0]; + if (rowObj.collapsed) { + icon = GMIcon[1] + } + buffer.push("", "
", "", groupTitle, "
"); + buffer.push("") + }; + _pGenerateView._generateSummaryRow = function(rowData, thisColModel, buffer, lastFrozenRow) { + var row_cls = "pq-summary-row pq-grid-row" + (lastFrozenRow ? " pq-last-freeze-row" : ""), + that = this.that, + thisOptions = that.options, + virtualX = thisOptions.virtualX, + initH = that.initH, + finalH = that.finalH, + freezeCols = thisOptions.freezeCols, + numberCell = thisOptions.numberCell, + columnBorders = thisOptions.columnBorders, + wrap = thisOptions.wrap, + offset = this.offset; + var const_cls = "pq-grid-cell "; + var row_str = ""; + buffer.push(row_str); + if (numberCell.show) { + buffer.push(["", "
 
"].join("")) + } + for (var col = 0; col <= finalH; col++) { + if (col < initH && col >= freezeCols && virtualX) { + col = initH; + if (col > finalH) { + throw ("initH>finalH") + } + } + var column = thisColModel[col], + dataIndx = column.dataIndx; + if (column.hidden) { + continue + } + var strStyle = ""; + var cls = const_cls; + if (column.align == "right") { + cls += " pq-align-right" + } else { + if (column.align == "center") { + cls += " pq-align-center" + } + } if (col == freezeCols - 1 && columnBorders) { + cls += " pq-last-freeze-col" + } + if (column.cls) { + cls = cls + " " + column.cls + } + var valCell = (rowData[dataIndx] == null) ? " " : rowData[dataIndx]; + var str = ["", "
", valCell, "
"].join(""); + buffer.push(str) + } + buffer.push(""); + return buffer + }; + _pGenerateView._generateDetailRow = function(rowData, rowIndx, thisColModel, buffer, objP, lastFrozenRow) { + var row_cls = "pq-grid-row pq-detail-child"; + if (lastFrozenRow) { + row_cls += " pq-last-freeze-row" + } + var that = this.that, + thisOptions = that.options, + numberCell = thisOptions.numberCell, + CMLength = thisColModel.length, + offset = this.offset; + var const_cls = "pq-grid-cell "; + if (!thisOptions.wrap || objP) { + const_cls += "pq-wrap-text " + } + if (thisOptions.stripeRows && (rowIndx / 2 == parseInt(rowIndx / 2))) { + row_cls += " pq-grid-oddRow" + } + if (rowData.pq_rowselect) { + row_cls += " pq-row-select ui-state-highlight" + } + var pq_rowcls = rowData.pq_rowcls; + if (pq_rowcls != null) { + row_cls += " " + pq_rowcls + } + buffer.push(""); + if (numberCell.show) { + buffer.push(["", "
 
"].join("")) + } + buffer.push(""); + buffer.push(""); + return buffer + }; + var cGroupView = function(that) { + this.that = that + }; + var _pGroupView = cGroupView.prototype; + _pGroupView._refreshDataFromDataModel = function() { + this._groupData(); + this.initcollapsed() + }; + _pGroupView.bindEvents = function() { + var self = this; + this.that.$cont.on("click", "tr.pq-group-row", function(evt) { + return self.onClickGroupRow(evt) + }) + }; + _pGroupView.showHideRows = function(initIndx, level, hide) { + var arr = [], + that = this.that, + data = that.dataGM; + for (var i = initIndx, len = data.length; i < len; i++) { + var rowObj = data[i], + rowData = rowObj; + if (rowData.groupSummary) { + if (rowObj.level < level) { + break + } else { + rowObj.pq_hidden = hide + } + } else { + if (rowData.groupTitle) { + if (rowObj.collapsed) { + arr.push({ + indx: i, + level: rowObj.level + }) + } + if (rowObj.level <= level) { + break + } else { + rowObj.pq_hidden = hide + } + } else { + rowObj.pq_hidden = hide + } + } + } + return arr + }; + _pGroupView.onClickGroupRow = function(evt) { + var $tr = $(evt.currentTarget), + that = this.that; + var level = parseInt($tr.attr("level")), + GMRowIndx = parseInt($tr.attr("GMRowIndx")), + data = that.dataGM, + collapsed = true, + rowObj = data[GMRowIndx]; + if (!rowObj.collapsed) { + rowObj.collapsed = true; + collapsed = true + } else { + rowObj.collapsed = false; + collapsed = false + } if (collapsed) { + this.showHideRows(GMRowIndx + 1, level, true) + } else { + var arr = this.showHideRows(GMRowIndx + 1, level, false); + for (var j = 0; j < arr.length; j++) { + var indx = arr[j].indx; + var level = arr[j].level; + this.showHideRows(indx + 1, level, true) + } + } + that._refresh() + }; + _pGroupView.initcollapsed = function() { + var that = this.that, + data = that.dataGM; + if (!data) { + return + } + for (var i = 0, len = data.length; i < len; i++) { + var rowData = data[i], + groupTitle = rowData.groupTitle; + if (groupTitle !== undefined) { + var level = rowData.level, + collapsed = rowData.collapsed; + if (collapsed) { + this.showHideRows(i + 1, level, true) + } + } + } + }; + _pGroupView.max = function(arr, dataType) { + var ret; + if (dataType == "integer" || dataType == "float") { + ret = Math.max.apply(Math, arr); + if (dataType === "float") { + ret = ret.toFixed(2) + } + } else { + if (dataType == "date") { + arr = arr.sort(function(a, b) { + a = Date.parse(a); + b = Date.parse(b); + return (a - b) + }); + ret = arr[arr.length - 1] + } else { + arr = arr.sort(); + ret = arr[arr.length - 1] + } + } + return ret + }; + _pGroupView.min = function(arr, dataType) { + var ret; + if (dataType == "integer" || dataType == "float") { + ret = Math.min.apply(Math, arr); + if (dataType === "float") { + ret = ret.toFixed(2) + } + } else { + if (dataType == "date") { + arr = arr.sort(function(a, b) { + a = Date.parse(a); + b = Date.parse(b); + return (a - b) + }); + ret = arr[0] + } else { + arr = arr.sort(); + ret = arr[0] + } + } + return ret + }; + _pGroupView.count = function(arr) { + return arr.length + }; + _pGroupView.sum = function(arr, dataType) { + var s = 0, + fn; + if (dataType === "float") { + fn = parseFloat + } else { + if (dataType === "integer") { + fn = parseInt + } else { + fn = function(val) { + return val + } + } + } + for (var i = 0, len = arr.length; i < len; i++) { + s += fn(arr[i]) + } + if (dataType === "float") { + s = s.toFixed(2) + } + return s + }; + _pGroupView._groupData = function() { + var that = this.that, + data = that.data, + thisOptions = that.options, + GM = thisOptions.groupModel, + PM = thisOptions.pageModel, + CM = that.colModel, + rowOffset = (PM.type) ? ((PM.curPage - 1) * PM.rPP) : 0, + CMLength = CM.length, + GMdataIndx = GM.dataIndx, + GMLength = GMdataIndx.length, + GMcollapsed = GM.collapsed, + groupSummaryShow = []; + for (var u = 0; u < GMLength; u++) { + groupSummaryShow[u] = false; + for (var v = 0; v < CMLength; v++) { + var column = CM[v], + summary = column.summary; + if (!summary) { + continue + } + var summaryType = summary.type; + if (!summaryType || typeof summaryType.push != "function") { + continue + } + if (summaryType[u]) { + groupSummaryShow[u] = true; + break + } + } + } + if (GM && data && data.length > 0) { + var dataGM = [], + titleIndx = [], + groupVal = [], + prevGroupVal = [], + cols = []; + for (var u = 0; u < GMLength; u++) { + prevGroupVal[u] = ""; + groupVal[u] = ""; + cols[u] = {} + } + for (var i = 0, len = data.length; i <= len; i++) { + var rowData = data[i]; + var changeGroup = false, + changeGroupIndx = null; + for (var u = 0; u < GMLength; u++) { + groupVal[u] = (i < len) ? $.trim(rowData[GMdataIndx[u]]) : ""; + if (prevGroupVal[u] != groupVal[u]) { + changeGroup = true + } + if (changeGroup && changeGroupIndx == null) { + changeGroupIndx = u + } + } + if (changeGroup) { + for (var l = 0; l < GMLength; l++) { + prevGroupVal[l] = groupVal[l] + } + if (i > 0) { + for (var u = GMLength - 1; u >= changeGroupIndx; u--) { + if (groupSummaryShow[u]) { + var groupRowData = []; + for (var f = 0; f < CMLength; f++) { + var column = CM[f], + summary = column.summary, + summaryType = (summary) ? (summary.type ? summary.type[u] : null) : null; + if (summaryType) { + var dataIndx = column.dataIndx, + summaryCellData = "", + summaryTitle = summary.title ? summary.title[u] : null, + sText = "{0}"; + if (typeof summaryType == "function") { + summaryCellData = summaryType(cols[u][dataIndx], column.dataType) + } else { + sText = summaryType + ": {0}"; + summaryCellData = this[summaryType](cols[u][dataIndx], column.dataType) + } if (summaryTitle) { + sText = summaryTitle + } + groupRowData[dataIndx] = sText.replace("{0}", summaryCellData) + } + } + dataGM.push({ + groupSummary: true, + level: u, + data: groupRowData + }) + } + } + for (var m = changeGroupIndx; m < GMLength; m++) { + dataGM[titleIndx[m]].items = cols[m][CM[0].dataIndx].length + } + } + if (i == len) { + break + } + for (var z = GMLength - 1; z >= changeGroupIndx; z--) { + for (var e = 0; e < CMLength; e++) { + var column = CM[e]; + cols[z][column.dataIndx] = [] + } + } + for (var m = changeGroupIndx; m < GMLength; m++) { + dataGM.push({ + groupTitle: groupVal[m], + level: m, + GMRowIndx: dataGM.length, + collapsed: (GMcollapsed && (GMcollapsed[m] != null)) ? GMcollapsed[m] : false + }); + titleIndx[m] = dataGM.length - 1 + } + } + rowData.rowIndx = i + rowOffset; + rowData.pq_hidden = false; + dataGM.push(rowData); + for (var k = 0; k < CMLength; k++) { + var column = CM[k], + dataIndx = column.dataIndx; + for (var u = 0; u < GMLength; u++) { + cols[u][dataIndx].push(rowData[dataIndx]) + } + } + } + that.dataGM = dataGM + } + }; + var cDragColumns = function(that) { + this.that = that; + this.$drag_helper = null; + var dragColumns = that.options.dragColumns, + topIcon = dragColumns.topIcon, + bottomIcon = dragColumns.bottomIcon, + self = this; + this.status = "stop"; + this.$arrowTop = $("
").appendTo(that.element); + this.$arrowBottom = $("
").appendTo(that.element); + this.hideArrows(); + if (dragColumns && dragColumns.enabled) { + that.$header.on("touchstart mousedown", "td.pq-grid-col", function(evt, ui) { + if ($.support.touch) { + if (evt.type == "touchstart") { + var touch = evt.originalEvent.touches[0]; + if (touch.pq_composed) { + return + } + evt.preventDefault(); + self.setDraggables(evt, ui); + var evt2 = document.createEvent("UIEvent"); + evt2.initUIEvent("touchstart", true, true); + evt2.view = window; + evt2.altKey = false; + evt2.ctrlKey = false; + evt2.shiftKey = false; + evt2.metaKey = false; + evt2.touches = [{ + pageX: evt.pageX, + pageY: evt.pageY, + pq_composed: true + }]; + evt2.changedTouches = [{ + pageX: evt.pageX, + pageY: evt.pageY, + pq_composed: true + }]; + evt.target.dispatchEvent(evt2) + } + } else { + if (!evt.pq_composed) { + self.setDraggables(evt, ui); + evt.pq_composed = true; + var e = $.Event("mousedown", evt); + $(evt.target).trigger(e) + } + } + }) + } + }; + var _pDragColumns = cDragColumns.prototype; + _pDragColumns.showFeedback = function($td, leftDrop) { + var that = this.that; + var td = $td[0]; + var offParent = td.offsetParent.offsetParent; + var left = td.offsetLeft + offParent.offsetLeft + ((!leftDrop) ? td.offsetWidth : 0) - 8; + var top = that.$grid_inner[0].offsetTop + td.offsetTop - 16; + var top2 = that.$grid_inner[0].offsetTop + that.$header[0].offsetHeight; + this.$arrowTop.css({ + left: left, + top: top, + display: "" + }); + this.$arrowBottom.css({ + left: left, + top: top2, + display: "" + }) + }; + _pDragColumns.showArrows = function() { + this.$arrowTop.show(); + this.$arrowBottom.show() + }; + _pDragColumns.hideArrows = function() { + this.$arrowTop.hide(); + this.$arrowBottom.hide() + }; + _pDragColumns.updateDragHelper = function(accept) { + var that = this.that, + dragColumns = that.options.dragColumns, + acceptIcon = dragColumns.acceptIcon, + rejectIcon = dragColumns.rejectIcon, + $drag_helper = this.$drag_helper; + if (!$drag_helper) { + return + } + if (accept) { + $drag_helper.children("span.pq-drag-icon").addClass(acceptIcon).removeClass(rejectIcon); + $drag_helper.removeClass("ui-state-error") + } else { + $drag_helper.children("span.pq-drag-icon").removeClass(acceptIcon).addClass(rejectIcon); + $drag_helper.addClass("ui-state-error") + } + }; + _pDragColumns.setDraggables = function(evt, ui) { + var $td = $(evt.currentTarget), + that = this.that, + dragColumns = that.options.dragColumns, + rejectIcon = dragColumns.rejectIcon, + self = this; + if ($td.hasClass("ui-draggable")) { + return + } + if (!that.getHeaderColumnFromTD($td)) { + return + } + $td.draggable({ + distance: 10, + cursorAt: { + top: -18, + left: -10 + }, + helper: function() { + var $this = $(this); + self.status = "helper"; + self._setupDroppables($this); + that.$header.find(".pq-grid-col-resize-handle").hide(); + var colIndx = $this.attr("pq-col-indx"); + var rowIndx = $this.attr("pq-row-indx"); + $this.droppable("destroy"); + var column = that.headerCells[rowIndx][colIndx]; + var $drag_helper = $("
" + column.title + "
"); + self.$drag_helper = $drag_helper; + return $drag_helper[0] + }, + zIndex: "1000", + appendTo: that.element, + revert: "invalid", + drag: function(evt, ui) { + self.status = "drag"; + var $td = $("td.pq-drop-hover", that.$header); + if ($td.length > 0) { + self.showArrows(); + self.updateDragHelper(true); + var wd = $td.width(); + var lft = evt.clientX - $td.offset().left + $(document).scrollLeft(); + if (lft < wd / 2) { + self.leftDrop = true; + self.showFeedback($td, true) + } else { + self.leftDrop = false; + self.showFeedback($td, false) + } + } else { + self.hideArrows(); + if (that.$toolbar.hasClass("pq-drop-hover")) { + self.updateDragHelper(true) + } else { + self.updateDragHelper() + } + } + }, + stop: function(evt, ui) { + self.status = "stop"; + that.$header.find(".pq-grid-col-resize-handle").show(); + self.hideArrows() + } + }) + }; + _pDragColumns._columnIndexOf = function(colModel, column) { + for (var i = 0, len = colModel.length; i < len; i++) { + if (colModel[i] == column) { + return i + } + } + return -1 + }; + _pDragColumns.refreshSorting = function() { + var that = this.that; + window.setTimeout(function() { + var arr = that.$toolbar.sortable("toArray", { + attribute: "sorter" + }); + that.sorters = []; + for (var i = 0, len = arr.length; i < len; i++) { + that.sorters.push(eval("(" + arr[i] + ")")) + } + that.sortLocalData(that.sorters, that.data); + that.refresh() + }, 0) + }; + _pDragColumns._setupDroppables = function($td) { + var that = this.that, + self = this; + var objDrop = { + hoverClass: "pq-drop-hover ui-state-highlight", + tolerance: "pointer", + drop: function(evt, ui) { + if (that.dropPending) { + return + } + var colIndxDrag = parseInt(ui.draggable.attr("pq-col-indx"), 10); + var rowIndxDrag = parseInt(ui.draggable.attr("pq-row-indx"), 10); + var colIndxDrop = parseInt($(this).attr("pq-col-indx"), 10); + var rowIndxDrop = $(this).attr("pq-row-indx"); + var optCM = that.options.colModel; + var headerCells = that.headerCells; + var columnDrag = headerCells[rowIndxDrag][colIndxDrag]; + var colModelDrag, colModelDrop; + if (rowIndxDrag == 0) { + colModelDrag = optCM + } else { + colModelDrag = headerCells[rowIndxDrag - 1][colIndxDrag].colModel + } if (rowIndxDrop == 0) { + colModelDrop = optCM + } else { + colModelDrop = headerCells[rowIndxDrop - 1][colIndxDrop].colModel + } + var columnDrop = headerCells[rowIndxDrop][colIndxDrop]; + var indxDrag = self._columnIndexOf(colModelDrag, columnDrag); + var column = colModelDrag.splice(indxDrag, 1)[0]; + var indxDrop = self._columnIndexOf(colModelDrop, columnDrop); + var decr = (self.leftDrop) ? 1 : 0; + colModelDrop.splice(indxDrop + 1 - decr, 0, column); + that.dropPending = true; + window.setTimeout(function() { + that._calcThisColModel(); + that._refresh(); + that.dropPending = false + }, 0) + } + }; + var $tds = that.$header_left.find("td.pq-left-col"); + var $tds2 = that.$header_right.find("td.pq-right-col"); + $tds = $tds.add($tds2); + $tds.each(function(i, td) { + var $td = $(td); + if ($td.hasClass("ui-droppable")) { + return + } + $td.droppable(objDrop) + }); + return; + var column = that.getHeaderColumnFromTD($td); + var dataIndx = column.dataIndx; + if (that.getIndxInSorters(dataIndx) != -1) { + if (that.$toolbar.hasClass("ui-droppable")) { + that.$toolbar.droppable("destroy") + } + return + } + that.$toolbar.droppable({ + hoverClass: "pq-drop-hover ui-state-highlight", + tolerance: "pointer", + drop: function(evt, ui) { + var colIndxDrag = parseInt(ui.draggable.attr("pq-col-indx"), 10); + var rowIndxDrag = parseInt(ui.draggable.attr("pq-row-indx"), 10); + var optCM = that.options.colModel; + var headerCells = that.headerCells; + var columnDrag = headerCells[rowIndxDrag][colIndxDrag]; + var colModelDrag; + if (rowIndxDrag == 0) { + colModelDrag = optCM + } else { + colModelDrag = headerCells[rowIndxDrag - 1][colIndxDrag].colModel + } + var indxDrag = self._columnIndexOf(colModelDrag, columnDrag); + var column = colModelDrag[indxDrag]; + var dataIndx = column.dataIndx; + var dataType = column.dataType; + that.sorters.push({ + dataIndx: dataIndx, + dataType: dataType, + dir: "up" + }); + $("" + column.title + "").appendTo(that.$toolbar).button({ + icons: { + primary: "ui-icon-triangle-1-n", + secondary: "ui-icon-close" + } + }).mouseover(function(evt) { + var $target = $(evt.target); + if ($target.is("span.ui-icon-close")) { + $target.css("outline", "1px solid black") + } + }).mouseout(function(evt) { + var $target = $(evt.target); + if ($target.is("span.ui-icon-close")) { + $target.css("outline", "") + } + }).click(function(evt) { + var $button = $(this); + if ($(evt.target).is("span.ui-icon-close")) { + window.setTimeout(function() { + $button.button("destroy"); + $button.remove(); + self.refreshSorting() + }, 0) + } else { + var sorter = eval("(" + $button.attr("sorter") + ")"); + if (sorter.dir == "up") { + sorter.dir = "down"; + $button.button({ + icons: { + primary: "ui-icon-triangle-1-s", + secondary: "ui-icon-close" + } + }) + } else { + sorter.dir = "up"; + $button.button({ + icons: { + primary: "ui-icon-triangle-1-n", + secondary: "ui-icon-close" + } + }) + } + var sorterStr = "{dataIndx:" + sorter.dataIndx + ",dataType:'" + sorter.dataType + "',dir:'" + sorter.dir + "'}"; + $button.attr("sorter", sorterStr); + self.refreshSorting() + } + }); + self.refreshSorting(); + window.setTimeout(function() { + that.$toolbar.droppable("destroy") + }, 0) + } + }) + }; + fn.options = { + detailModel: { + cache: true, + offset: 100, + expandIcon: "ui-icon-triangle-1-se", + collapseIcon: "ui-icon-triangle-1-e" + }, + dragColumns: { + enabled: true, + acceptIcon: "ui-icon-check", + rejectIcon: "ui-icon-closethick", + topIcon: "ui-icon-circle-arrow-s", + bottomIcon: "ui-icon-circle-arrow-n" + }, + track: false, + treeModel: { + collapsed: true, + indent: 15, + leafIcon: "ui-icon-radio-off", + expandIcon: "ui-icon-triangle-1-se", + collapseIcon: "ui-icon-triangle-1-e" + }, + virtualX: true, + filterModel: { + on: true, + mode: "AND", + header: false + } + }; + fn._create = function() { + $.extend($.paramquery.cGenerateView.prototype, _pGenerateView); + var that = this, + thisOptions = this.options; + this.iGroupView = new cGroupView(this); + this.iHeaderSearch = new cHeaderSearch(this); + this.iUCData = new $.paramquery.cUCData(this); + this.pqSheet = {}; + new cMouseSelection(this); + this._super.apply(this); + this.iGroupView.bindEvents(); + this.pqSheet = {}; + this.iDragColumns = new cDragColumns(this); + this._createToolbar(); + this.refreshHeader(); + this.refreshDataAndView({ + header: false + }); + this.refresh(); + var widgetEventPrefix = that.widgetEventPrefix.toLowerCase(); + that.element.one(widgetEventPrefix + "load", function(evt, ui) { + that._refresh({ + header: false + }) + }) + }; + fn._createToolbar = function() { + var that = this, + options = this.options, + toolbar = options.toolbar; + if (toolbar) { + var tb = toolbar, + cls = tb.cls, + cls = cls ? cls : "", + style = tb.style, + style = style ? style : "", + attr = tb.attr, + attr = attr ? attr : "", + items = tb.items; + var $toolbar = $("
").appendTo($(".pq-grid-top", this.element)); + $toolbar.pqToolbar({ + items: items, + gridInstance: this + }); + if (!options.showToolbar) { + $toolbar.css("display", "none") + } + this.$toolbar = $toolbar + } + }; + fn.isLeftOrRight = function(colIndx) { + var thisOptions = this.options, + freezeCols = this.freezeCols; + if (colIndx > freezeCols) { + return "right" + } else { + return "left" + } + }; + fn.ovCreateHeader = function(buffer, const_cls) { + if (this.options.filterModel.header) { + this.iHeaderSearch.createDOM(buffer, const_cls) + } + }; + fn._createHeader = function() { + this._super.apply(this); + if (this.options.showHeader) { + this._trigger("createHeader") + } + }; + fn.exportExcel = function(obj) { + obj.format = "xml"; + return $.paramquery.pqgrid.exportToExcel.call(this, obj) + }; + fn.exportCsv = function(obj) { + obj.format = "csv"; + return $.paramquery.pqgrid.exportToExcel.call(this, obj) + }; + fn.filter = function(objP) { + var that = this, + thisOptions = this.options, + apply = (objP.apply === undefined) ? true : objP.apply, + sort = (objP.sort === undefined) ? true : objP.sort, + DM = thisOptions.dataModel, + FM = thisOptions.filterModel; + if (objP != undefined) { + var replace = (objP.oper == "replace") ? true : false, + rules = objP.data, + CM = this.colModel, + CM = (!apply) ? $.extend(true, [], CM) : CM, + foundCount = 0, + CMLength = CM.length, + rulesLength = rules.length; + for (var i = 0; i < CMLength; i++) { + var column = CM[i], + found = false; + for (var j = 0; j < rulesLength; j++) { + if (foundCount == rulesLength) { + break + } + var obj = rules[j]; + if (obj.dataIndx == column.dataIndx) { + found = true; + foundCount++; + var filter = column.filter, + condition = obj.condition, + value = obj.value; + if (!filter) { + filter = column.filter = { + on: true + } + } else { + filter.on = true + } if (condition) { + filter.condition = condition + } + condition = filter.condition; + filter.value = value; + if (condition == "between") { + filter.value2 = obj.value2 + } else { + if (condition == "range") { + var arrOpts = []; + if (value) { + if (typeof value == "string") { + var options = filter.options; + var firstIndx = value.indexOf('"'); + var lastIndx = value.lastIndexOf('"'); + value = value.substr(firstIndx, lastIndx + 1); + value = JSON.parse("[" + value + "]"); + if (options) { + for (var k = 0, optLen = options.length; k < optLen; k++) { + var opt = options[k]; + if ($.inArray(opt, value) != -1) { + arrOpts.push(opt) + } + } + } else { + arrOpts = value.split(",s*") + } + } else { + if (typeof value.push == "function") { + arrOpts = value + } + } + } + filter.value = arrOpts + } + } + break + } + } + if (replace && !found && column.filter) { + column.filter.on = false + } + } + } + var obj2 = { + header: false, + apply: apply, + sort: sort, + CM: CM + }; + if (DM.location == "remote" && FM.type != "local") { + this.remoteRequest({ + apply: apply, + CM: CM, + callback: function() { + return that._onDataAvailable(obj2) + } + }) + } else { + return that._onDataAvailable(obj2) + } + }; + fn._initTypeColumns = function() { + var CM = this.colModel; + for (var i = 0, len = CM.length; i < len; i++) { + var column = CM[i]; + if (column.type === "checkBoxSelection") { + new $.paramquery.cCheckBoxColumn(this, column.dataIndx) + } else { + if (column.type === "detail") { + column.dataIndx = "pq_detail"; + this.iHierarchy = new cHierarchy(this) + } + } + } + }; + fn.refreshHeader = function() { + this._createHeader() + }; + fn.refreshDataFromDataModel = function() { + this._super.apply(this); + var thisOptions = this.options, + GM = thisOptions.groupModel, + GMTrue = (GM) ? true : false; + if (GMTrue) { + this.iGroupView._refreshDataFromDataModel() + } + }; + var cSort = $.paramquery.cSort = function(that) { + this.that = that + }; + var _pSort = cSort.prototype; + _pSort._refreshSorters = function(pDataIndx) { + var that = this.that, + thisOptions = that.options, + DM = thisOptions.dataModel, + DMsortIndx = DM.sortIndx, + multiSort = $.isArray(DMsortIndx), + GM = thisOptions.groupModel, + GMdataIndx = GM ? GM.dataIndx : null, + GMDir = GM ? GM.dir : null, + foundInGMIndx = -1, + sorters = []; + if (GM) { + for (var i = 0; i < GMdataIndx.length; i++) { + var gDataIndx = GMdataIndx[i]; + if (gDataIndx == pDataIndx) { + foundInGMIndx = i + } + sorters.push({ + dataIndx: gDataIndx, + dir: (GMDir && GMDir[i]) ? GMDir[i] : "up" + }) + } + } + if (foundInGMIndx !== -1) { + var dir = sorters[foundInGMIndx].dir; + var newDir = (dir === "up") ? "down" : "up"; + sorters[foundInGMIndx].dir = newDir; + GMDir[foundInGMIndx] = newDir + } else { + if (pDataIndx != null) { + if (multiSort) { + var indx = $.inArray(pDataIndx, DM.sortIndx); + if (indx != -1) { + if (DM.sortDir[indx] == "up") { + DM.sortDir[indx] = "down" + } else { + if (DMsortIndx.length == 1) { + DM.sortDir[indx] = "up" + } else { + DM.sortIndx.splice(indx, 1); + DM.sortDir.splice(indx, 1) + } + } + } else { + var len = DM.sortIndx.length; + DM.sortIndx[len] = pDataIndx; + DM.sortDir[len] = "up" + } + } else { + if (DM.sortIndx == pDataIndx) { + DM.sortDir = (DM.sortDir == "up") ? "down" : "up" + } else { + DM.sortIndx = pDataIndx; + DM.sortDir = "up" + } + } + } + } if (DM.sortIndx != null) { + if (multiSort) { + for (var i = 0; i < DMsortIndx.length; i++) { + var dataIndx = DMsortIndx[i]; + if (this.inSorters(sorters, dataIndx) == -1) { + sorters.push({ + dataIndx: dataIndx, + dir: DM.sortDir[i] + }) + } + } + } else { + if (this.inSorters(sorters, DM.sortIndx) == -1) { + sorters.push({ + dataIndx: DM.sortIndx, + dir: DM.sortDir + }) + } + } + } + this.sorters = sorters + }; + _pSort.inSorters = function(sorters, dataIndx) { + var found = -1; + for (var i = 0; i < sorters.length; i++) { + var sorter = sorters[i]; + if (sorter.dataIndx == dataIndx) { + found = i; + break + } + } + return found + }; + _pSort._sortLocalData = function(data) { + var that = this.that, + thisOptions = that.options, + DM = thisOptions.dataModel, + CM = that.colModel, + sorters = this.sorters; + for (var i = 0; i < sorters.length; i++) { + var sorter = sorters[i], + dataIndx = sorter.dataIndx, + colIndx = that.getColIndx({ + dataIndx: dataIndx + }), + dataType = CM[colIndx].dataType; + sorter.dataType = dataType + } + return this.__sortLocalData(sorters, data) + }; + _pSort.__sortLocalData = function(sorters, data) { + if (data == null || data.length == 0) { + return + } + if (!sorters || !sorters.length) { + return data + } + + function sort_integer(obj1, obj2, dataIndx, dir) { + var val1 = obj1[dataIndx]; + var val2 = obj2[dataIndx]; + val1 = val1 ? parseInt(val1, 10) : 0; + val2 = val2 ? parseInt(val2, 10) : 0; + return ((val1 - val2) * dir) + } + + function sort_date(obj1, obj2, dataIndx, dir) { + var val1 = obj1[dataIndx]; + var val2 = obj2[dataIndx]; + val1 = val1 ? Date.parse(val1) : 0; + val2 = val2 ? Date.parse(val2) : 0; + return ((val1 - val2) * dir) + } + + function sort_custom(obj1, obj2, dataIndx, dir, dataType) { + var val1 = obj1[dataIndx]; + var val2 = obj2[dataIndx]; + return (dataType(val1, val2) * dir) + } + + function sort_float(obj1, obj2, dataIndx, dir) { + var val1 = (obj1[dataIndx] + "").replace(/,/g, ""); + var val2 = (obj2[dataIndx] + "").replace(/,/g, ""); + val1 = val1 ? parseFloat(val1) : 0; + val2 = val2 ? parseFloat(val2) : 0; + return ((val1 - val2) * dir) + } + + function sort_string(obj1, obj2, dataIndx, dir) { + var val1 = obj1[dataIndx]; + var val2 = obj2[dataIndx]; + val1 = val1 ? val1 : ""; + val2 = val2 ? val2 : ""; + var ret = 0; + if (val1 > val2) { + ret = 1 + } else { + if (val1 < val2) { + ret = -1 + } + } + return (ret * dir) + } + + function sort_stringi(obj1, obj2, dataIndx, dir) { + var val1 = obj1[dataIndx]; + var val2 = obj2[dataIndx]; + val1 = val1 ? val1.toUpperCase() : ""; + val2 = val2 ? val2.toUpperCase() : ""; + var ret = 0; + if (val1 > val2) { + ret = 1 + } else { + if (val1 < val2) { + ret = -1 + } + } + return (ret * dir) + } + + function sort_bool(obj1, obj2, dataIndx, dir) { + var val1 = obj1[dataIndx]; + var val2 = obj2[dataIndx]; + var ret = 0; + if ((val1 && !val2) || (val1 === false && val2 === null)) { + ret = 1 + } else { + if ((val2 && !val1) || (val2 === false && val1 === null)) { + ret = -1 + } + } + return (ret * dir) + } + + function innerSort() { + var arrFn = [], + arrDataIndx = [], + arrDir = [], + sortersLength = sorters.length; + + function sort_composite(obj1, obj2) { + var ret = 0; + for (var i = 0; i < sortersLength; i++) { + ret = arrFn[i](obj1, obj2, arrDataIndx[i], arrDir[i]); + if (ret != 0) { + break + } + } + return ret + } + for (var i = 0; i < sortersLength; i++) { + var sorter = sorters[i], + dataIndx = sorter.dataIndx, + dir = (sorter.dir == "up") ? 1 : -1, + dataType = sorter.dataType; + arrDataIndx[i] = dataIndx; + arrDir[i] = dir; + if (dataType == "integer") { + arrFn[i] = sort_integer + } else { + if (dataType == "float") { + arrFn[i] = sort_float + } else { + if (typeof dataType == "function") { + arrFn[i] = (function(dataType) { + return function(obj1, obj2, dataIndx, dir) { + return sort_custom(obj1, obj2, dataIndx, dir, dataType) + } + })(dataType) + } else { + if (dataType == "date") { + arrFn[i] = sort_date + } else { + if (dataType == "stringi") { + arrFn[i] = sort_stringi + } else { + if (dataType == "bool") { + arrFn[i] = sort_bool + } else { + arrFn[i] = sort_string + } + } + } + } + } + } + } + data = data.sort(sort_composite) + } + $.measureTime(innerSort, "innerSort"); + return data + }; + fn._refreshHeaderSortIcons = function() { + var thisOptions = this.options, + DM = thisOptions.dataModel, + sorters = this.iSort.sorters, + thisColModel = this.colModel; + var $header = this.$header; + var $pQuery_cols = $header.find(".pq-grid-col"); + $pQuery_cols.removeClass("pq-col-sort-asc pq-col-sort-desc ui-state-active"); + $header.find(".pq-col-sort-icon").removeClass("ui-icon ui-icon-triangle-1-n ui-icon-triangle-1-s"); + for (var i = 0; i < sorters.length; i++) { + var sorter = sorters[i]; + var dataIndx = sorter.dataIndx; + var colIndx = this.getColIndx({ + dataIndx: dataIndx + }); + var dir = sorter.dir; + var addClass = "ui-state-active pq-col-sort-" + (dir == "up" ? "asc" : "desc"); + var cls2 = "ui-icon ui-icon-triangle-1-" + (dir == "up" ? "n" : "s"); + $header.find(".pq-grid-col[pq-grid-col-indx=" + colIndx + "]").addClass(addClass); + $header.find(".pq-grid-col[pq-grid-col-indx=" + colIndx + "] .pq-col-sort-icon").addClass(cls2) + } + }; + fn.getHeaderColumnFromTD = function($td) { + var colIndx = $td.attr("pq-grid-col-indx"); + if (colIndx == null) { + return + } + var column = this.colModel[colIndx]; + return column + }; + fn.getIndxInSorters = function(dataIndx) { + var sorters = this.sorters; + for (var i = 0, len = sorters.length; i < len; i++) { + if (sorters[i].dataIndx == dataIndx) { + return i + } + } + return -1 + }; + fn._simulateEvent = function(event, simulatedType) { + if (event.originalEvent.touches.length > 1) { + return + } + event.preventDefault(); + var touch = event.originalEvent.changedTouches[0], + simulatedEvent = document.createEvent("MouseEvents"); + simulatedEvent.initMouseEvent(simulatedType, true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null); + event.target.dispatchEvent(simulatedEvent) + }; + fn._getTblSingle = function(rowIndxPage, colIndx) { + var $tbl = this.$tbl, + colIndx = (colIndx != null) ? colIndx : 0, + thisOptions = this.options, + freezeCols = thisOptions.freezeCols, + freezeRows = thisOptions.freezeRows; + if ($tbl != undefined) { + if ($tbl.length == 4) { + if (rowIndxPage >= freezeRows && colIndx >= freezeCols) { + $tbl = $($tbl[3]) + } else { + if (rowIndxPage >= freezeRows && colIndx < freezeCols) { + $tbl = $($tbl[2]) + } else { + if (rowIndxPage < freezeRows && colIndx >= freezeCols) { + $tbl = $($tbl[1]) + } else { + $tbl = $($tbl[0]) + } + } + } + } else { + if ($tbl.length == 2) { + if (rowIndxPage >= freezeRows && colIndx >= freezeCols) { + $tbl = $($tbl[1]) + } else { + $tbl = $($tbl[0]) + } + } else { + $tbl = $($tbl[0]) + } + } + } + return $tbl + }; + fn.getLargestRowCol = function(arr) { + var rowIndx, colIndx; + for (var i = 0; i < arr.length; i++) { + var sel = arr[i]; + var rowIndx2 = sel.rowIndx; + if (rowIndx == null) { + rowIndx = sel.rowIndx + } else { + if (rowIndx2 > rowIndx) { + rowIndx = rowIndx2 + } + } + rowIndx = sel.rowIndx + } + }; + fn._onLoad = function() { + this.options.dataModel.postData = "" + }; + fn._onRefreshSheet = function() { + var data = this.$dragSeries.data(); + if (data) { + var rowIndx = data.rowIndx, + colIndx = data.colIndx, + left = data.left, + top = data.top; + this.bb(rowIndx, colIndx) + } + }; + fn.bringCellToView = function(obj) { + this._bringCellToView(obj) + }; + fn._setUrl = function(queryStr) { + this.options.dataModel.getUrl = function() { + return { + url: this.url + ((queryStr != null) ? queryStr : "") + } + } + }; + fn.getDataPage = function() { + return this.data + }; + fn.getData = function(objP) { + var dataIndices = objP.dataIndx, + dILen = dataIndices.length, + data = objP.data, + DM = this.options.dataModel, + DMData = DM.data, + DMDataUF = DM.dataUF, + arr = [], + pr = function(data) { + for (var i = 0, len = data.length; i < len; i++) { + var rowData = data[i]; + var row = {}; + for (var j = 0; j < dILen; j++) { + var dataIndx = dataIndices[j]; + row[dataIndx] = rowData[dataIndx] + } + arr.push(row) + } + }; + if (data) { + pr(data) + } else { + if (DMData) { + pr(DMData) + } + if (DMDataUF) { + pr(DMDataUF) + } + } + var sorters = []; + for (var j = 0; j < dILen; j++) { + var dataIndx = dataIndices[j]; + var column = this.getColumn({ + dataIndx: dataIndx + }); + sorters.push({ + dataIndx: dataIndx, + dir: "up", + dataType: column.dataType + }) + } + arr = this.iSort.__sortLocalData(sorters, arr); + var arr2 = [], + item2 = undefined; + for (var i = 0; i < arr.length; i++) { + var rowData = arr[i]; + var item = JSON.stringify(rowData); + if (item !== item2) { + arr2.push(rowData); + item2 = item + } + } + return arr2 + }; + fn.getFilterData = function(objP) { + var CM = objP.CM; + if (!CM) { + throw ("CM N/A") + } + var CMLength = CM.length, + location = objP.location, + FM = this.options.filterModel, + FMmultiple = FM.multiple, + conditions = $.paramquery.filter.getAllConditions, + TRconditions = $.paramquery.filter.getTRConditions, + arrS = [], + isCorrect = function(condition, value, value2) { + if (condition == "between") { + if ((value == null || value === "") && (value2 == null || value2 === "")) { + return false + } else { + return true + } + } else { + if ($.inArray(condition, conditions) != -1) { + if ((value == null || value === "")) { + if ($.inArray(condition, TRconditions) != -1) { + return false + } + } + return true + } else { + return true + } + } + }, getValue = function(cd, dataType) { + if (location == "remote") { + cd = (cd == null) ? "" : cd; + return cd.toString() + } else { + return cFilterData.convert(cd, dataType) + } + }; + for (var i = 0; i < CMLength; i++) { + var column = CM[i], + dataIndx = column.dataIndx, + dataType = column.dataType, + dataType = (!dataType || typeof dataType == "function") ? "string" : dataType, + filter = column.filter; + if (FMmultiple) { + var cFM = column.filterModel; + if (cFM && cFM.on) { + var filters = [], + cMode = cFM.mode, + cFilters = cFM.filters; + for (var j = 0; j < cFilters.length; j++) { + var filter = cFilters[j], + value = filter.value, + condition = filter.condition; + if (isCorrect(condition, value)) { + value = getValue(value, dataType); + filters.push({ + value: value, + condition: condition + }) + } + } + arrS.push({ + dataIndx: dataIndx, + mode: cMode, + dataType: dataType, + filters: filters + }) + } + } else { + if (filter && filter.on) { + var value = filter.value, + value2 = filter.value2, + condition = filter.condition; + if (isCorrect(condition, value, value2)) { + if (condition == "between") { + if (value === "" || value == null) { + condition = "lte"; + value = getValue(value2, dataType) + } else { + if (value2 === "" || value2 == null) { + condition = "gte"; + value = getValue(value, dataType) + } else { + value = getValue(value, dataType); + value2 = getValue(value2, dataType) + } + } + } else { + if (condition == "regexp") { + if (location == "remote") { + value = value.toString() + } else { + if (typeof value == "string") { + try { + var modifiers = filter.modifiers, + modifiers = modifiers ? modifiers : "gi"; + value = new RegExp(value, modifiers) + } catch (ex) { + value = /.*/ + } + } + } + } else { + if (condition == "range") { + if (value == null) { + continue + } else { + if (typeof value == "string") { + value = getValue(value, dataType); + value = value.split(/\s*,\s*/) + } else { + if (value && typeof value.push == "function") { + if (value.length == 0) { + continue + } + value = value.slice(); + for (var j = 0, len = value.length; j < len; j++) { + value[j] = getValue(value[j], dataType) + } + } + } + } + } else { + value = getValue(value, dataType) + } + } + } + arrS.push({ + dataIndx: dataIndx, + value: value, + value2: value2, + condition: condition, + dataType: dataType, + cbFn: (location == "remote") ? "" : cFilterData.conditions[condition] + }) + } + } + } + } + return arrS + }; + var cFilterData = function(that) { + this.that = that + }; + var _pFilterData = cFilterData.prototype; + cFilterData.conditions = { + equal: function(cd, value) { + if (cd == value) { + return true + } + }, + contain: function(cd, value) { + if (cd.indexOf(value) != -1) { + return true + } + }, + notcontain: function(cd, value) { + if (cd.indexOf(value) == -1) { + return true + } + }, + empty: function(cd) { + if (cd.length == 0) { + return true + } + }, + notempty: function(cd) { + if (cd.length > 0) { + return true + } + }, + begin: function(cd, value) { + if (cd.indexOf(value) == 0) { + return true + } + }, + notbegin: function(cd, value) { + if (cd.indexOf(value) != 0) { + return true + } + }, + end: function(cd, value) { + var lastIndx = cd.lastIndexOf(value); + if (lastIndx != -1 && (lastIndx + value.length == cd.length)) { + return true + } + }, + notend: function(cd, value) { + var lastIndx = cd.lastIndexOf(value); + if (lastIndx != -1 && (lastIndx + value.length == cd.length)) {} else { + return true + } + }, + regexp: function(cd, value) { + if (value.test(cd)) { + value.lastIndex = 0; + return true + } + }, + notequal: function(cd, value) { + if (cd != value) { + return true + } + }, + great: function(cd, value) { + if (cd > value) { + return true + } + }, + gte: function(cd, value) { + if (cd >= value) { + return true + } + }, + between: function(cd, value, value2) { + if (cd >= value && cd <= value2) { + return true + } + }, + range: function(cd, value) { + if ($.inArray(cd, value) != -1) { + return true + } + }, + less: function(cd, value) { + if (cd < value) { + return true + } + }, + lte: function(cd, value) { + if (cd <= value) { + return true + } + } + }; + cFilterData.convert = function(cd, dataType) { + cd = (cd == null) ? "" : cd; + if (dataType == "string") { + cd = $.trim(cd).toUpperCase() + } else { + if (dataType == "date") { + cd = Date.parse(cd) + } else { + if (dataType == "integer") { + cd = parseInt(cd) + } else { + if (dataType == "float") { + cd = parseFloat(cd) + } else { + if (dataType == "bool") { + cd = String(cd).toLowerCase() + } + } + } + } + } + return cd + }; + _pFilterData.isMatchCellSingle = function(s, rowData) { + var dataIndx = s.dataIndx, + dataType = s.dataType, + value = s.value, + value2 = s.value2, + condition = s.condition, + cbFn = s.cbFn, + cd = rowData[dataIndx]; + if (condition == "regexp") { + cd = (cd == null) ? "" : cd + } else { + cd = cFilterData.convert(cd, dataType) + } + var found = cbFn(cd, value, value2) ? true : false; + return found + }; + _pFilterData.isMatchCellMultiple = function(s, rowData) { + var dataIndx = s.dataIndx, + dataType = s.dataType, + smode = s.mode, + filters = s.filters, + flen = filters.length; + if (flen == 0) { + return true + } + for (var i = 0; i < flen; i++) { + var f = filters[i], + value = f.value, + condition = f.condition, + cd = rowData[dataIndx], + found = this.isMatchRule(cd, condition, value, dataType); + if (smode == "OR" && found) { + return true + } + if (smode == "AND" && !found) { + return false + } + } + if (flen === 1) { + return found + } else { + if (smode == "AND") { + return true + } else { + if (smode == "OR") { + return false + } + } + } + }; + _pFilterData.isMatchRow = function(rowData, arrS, FMmode) { + if (arrS.length == 0) { + return true + } + for (var i = 0; i < arrS.length; i++) { + var s = arrS[i], + found = this.isMatchCell(s, rowData); + if (FMmode == "OR" && found) { + return true + } + if (FMmode == "AND" && !found) { + return false + } + } + if (FMmode == "AND") { + return true + } else { + if (FMmode == "OR") { + return false + } + } + }; + fn.filterLocalData = function(objP) { + objP = objP ? objP : {}; + var apply = objP.apply, + CM = (apply === false) ? objP.CM : this.colModel, + arrS = this.getFilterData({ + CM: CM + }), + options = this.options, + DM = options.dataModel, + data1 = DM.data, + data2 = DM.dataUF, + arr1 = [], + arr2 = [], + FM = options.filterModel, + FMmultiple = FM.multiple, + FMmode = FM ? FM.mode : null; + var iFD = new cFilterData(); + if (FMmultiple) { + iFD.isMatchCell = iFD.isMatchCellMultiple + } else { + iFD.isMatchCell = iFD.isMatchCellSingle + } if (FM.on && FMmode) { + if (data1) { + for (var i = 0, len = data1.length; i < len; i++) { + var rowData = data1[i]; + if (iFD.isMatchRow(rowData, arrS, FMmode)) { + arr1.push(rowData) + } else { + arr2.push(rowData) + } + } + } + if (data2) { + for (var i = 0, len = data2.length; i < len; i++) { + var rowData = data2[i]; + if (iFD.isMatchRow(rowData, arrS, FMmode)) { + arr1.push(rowData) + } else { + arr2.push(rowData) + } + } + } + } else { + if (data1) { + for (var i = 0, len = data1.length; i < len; i++) { + var rowData = data1[i]; + arr1.push(rowData) + } + } + if (data2) { + for (var i = 0, len = data2.length; i < len; i++) { + var rowData = data2[i]; + arr1.push(rowData) + } + } + } if (apply) { + DM.data = arr1; + DM.dataUF = arr2; + this._trigger("filter", null, { + type: "local", + dataModel: DM, + colModel: CM, + filterModel: FM + }) + } + return { + data: arr1, + dataUF: arr2 + } + }; + fn._onDataAvailable = function(objP) { + objP = objP ? objP : {}; + var options = this.options, + apply = objP.apply, + sort = objP.sort, + data = [], + FM = options.filterModel, + DM = options.dataModel, + location = DM.location; + if (apply !== false) { + this._trigger("dataAvailable", objP.evt, { + dataModel: DM + }) + } + if (FM && FM.on && ((location == "local" && FM.type != "remote") || (location == "remote" && FM.type == "local"))) { + data = this.filterLocalData(objP).data + } else { + data = DM.data + } if (DM.sorting && DM.sorting == "local") { + if (sort !== false) { + data = this.iSort._sortLocalData(data) + } + } + if (apply === false) { + return data + } else { + DM.data = data + } + this.refreshView(objP) + }; + fn.sort = function(obj) { + var that = this, + options = this.options, + colIndx = obj.colIndx, + dataIndx = obj.dataIndx, + evt = obj.evt, + DM = options.dataModel; + if (colIndx == null && dataIndx == null) { + dataIndx = DM.sortIndx; + if (dataIndx == null) { + return + } + } + colIndx = (colIndx == null) ? this.getColIndx({ + dataIndx: dataIndx + }) : colIndx; + var column = this.colModel[colIndx]; + dataIndx = (dataIndx == null) ? column.dataIndx : dataIndx; + if (that._trigger("beforeSort", evt, { + dataModel: DM, + column: column, + dataIndx: dataIndx + }) == false) { + return + } + if (that.$td_edit != null) { + that.quitEditMode() + } + this.iSort._refreshSorters(dataIndx); + if (DM.sorting == "local") { + this.iSort._sortLocalData(DM.data); + this.refreshView() + } else { + if (DM.sorting == "remote") { + this.remoteRequest({ + callback: function() { + that._trigger("sort", evt, { + dataModel: DM, + column: column, + dataIndx: dataIndx + }); + that._onDataAvailable() + } + }) + } + } + }; + fn._setScrollVLength = function(data) { + var GM = this.options.groupModel; + data = (GM) ? this.dataGM : data; + this._super.call(this, data) + }; + $.widget("paramquery.pqGrid", $.paramquery._pqGrid, fn); + $.paramquery.pqGrid.regional = {}; + $.paramquery.pqGrid.regional.en = fn._regional +})(jQuery); +(function($) { + $.paramquery = ($.paramquery == null) ? {} : $.paramquery; + $.paramquery.pqgrid = ($.paramquery.pqgrid == null) ? {} : $.paramquery.pqgrid; + $.paramquery.pqgrid.exportToExcel = function(obj) { + var that = this, + urlPost = (obj.urlPost === undefined) ? obj.url : obj.urlPost, + urlExcel = obj.url, + sheetName = (obj.sheetName == null) ? "pqGrid" : obj.sheetName, + format = obj.format, + getXMLContent = function() { + var CM = that.colModel, + CMLength = CM.length, + options = that.options, + DM = options.dataModel, + data = DM.data, + dataLength = data.length, + response = []; + var header = []; + for (var i = 0; i < CMLength; i++) { + var column = CM[i]; + if (!column.hidden) { + header.push('') + } + } + header.push(""); + for (var i = 0; i < CMLength; i++) { + var column = CM[i]; + if (!column.hidden) { + header.push('' + column.title + "") + } + } + header.push(""); + header = header.join("\n"); + for (var i = 0; i < dataLength; i++) { + var rowData = data[i]; + response.push(""); + for (var j = 0; j < CMLength; j++) { + var column = CM[j]; + if (!column.hidden) { + var dataIndx = column.dataIndx; + response.push('") + } + } + response.push("") + } + response = response.join("\n"); + var excelDoc = ['', '', '', '', "", header, response, "
", "
", "
"]; + return excelDoc.join("\n") + }, getCSVContent = function() { + var CM = that.colModel, + CMLength = CM.length, + options = that.options, + DM = options.dataModel, + data = DM.data, + dataLength = data.length, + csvRows = [], + header = [], + response = []; + for (var i = 0; i < CMLength; i++) { + var column = CM[i]; + if (!column.hidden) { + var title = column.title.replace(/\"/g, '""'); + header.push('"' + title + '"') + } + } + csvRows.push(header.join(",")); + for (var i = 0; i < dataLength; i++) { + var rowData = data[i]; + for (var j = 0; j < CMLength; j++) { + var column = CM[j]; + if (!column.hidden) { + var dataIndx = column.dataIndx; + var cellData = rowData[dataIndx] + ""; + cellData = cellData.replace(/\"/g, '""'); + response.push('"' + cellData + '"') + } + } + csvRows.push(response.join(",")); + response = [] + } + return csvRows.join("\n") + }; + var data = (format == "xml") ? getXMLContent() : getCSVContent(); + $.ajax({ + url: urlPost, + type: "POST", + cache: false, + data: { + extension: format, + excel: data + }, + success: function(filename) { + var url = urlExcel + (((urlExcel.indexOf("?") > 0) ? "&" : "?") + "filename=" + filename); + $(document.body).append("") + } + }) + } +})(jQuery); +(function($) { + var cUCData = $.paramquery.cUCData = function(that) { + this.that = that; + this.udata = []; + this.ddata = []; + this.adata = [] + }; + var _pUCData = cUCData.prototype; + _pUCData.add = function(obj) { + var that = this.that, + adata = this.adata, + rowData = obj.rowData, + recId = that.getRecId({ + rowData: rowData + }); + for (var i = 0, len = adata.length; i < len; i++) { + var rec = adata[i]; + if (recId != null && rec.recId == recId) { + throw ("primary key violation") + } + if (rec.rowData == rowData) { + throw ("same data can't be added twice.") + } + } + var obj = { + recId: recId, + rowData: rowData + }; + adata.push(obj) + }; + _pUCData.update = function(objP) { + var that = this.that, + rowData = that.getRowData(objP), + recId = that.getRecId({ + rowData: rowData + }), + dataIndx = objP.dataIndx, + oldVal = objP.oldVal, + newVal = objP.newVal, + udata = this.udata, + _found = false; + if (recId == null) { + return + } + for (var i = 0, len = udata.length; i < len; i++) { + var rec = udata[i]; + if (rec.rowData == rowData && rec.dataIndx == dataIndx) { + _found = true; + if (rec.oldVal == newVal) { + udata.splice(i, 1); + var obj = { + rowData: rowData, + dataIndx: dataIndx, + cls: "pq-cell-dirty" + }; + that.removeClass(obj) + } else { + rec.newVal = newVal + } + break + } + } + if (!_found) { + var obj = { + rowData: rowData, + recId: recId, + dataIndx: dataIndx, + newVal: newVal, + oldVal: oldVal + }; + udata.push(obj); + var obj = { + rowData: rowData, + dataIndx: dataIndx, + cls: "pq-cell-dirty" + }; + that.addClass(obj) + } + }; + _pUCData["delete"] = function(obj) { + var that = this.that, + rowIndx = obj.rowIndx, + rowIndxPage = obj.rowIndxPage, + offset = that.rowIndxOffset, + rowIndx = (rowIndx == null) ? (rowIndxPage + offset) : rowIndx, + rowIndxPage = (rowIndxPage == null) ? (rowIndx - offset) : rowIndxPage, + paging = that.options.pageModel.type, + indx = (paging == "remote") ? rowIndxPage : rowIndx, + adata = this.adata, + ddata = this.ddata, + rowData = that.getRowData(obj); + for (var i = 0, len = adata.length; i < len; i++) { + if (adata[i].rowData == rowData) { + adata.splice(i, 1); + return + } + } + ddata.push({ + indx: indx, + rowData: rowData + }) + }; + _pUCData.isDirty = function() { + var that = this.that, + udata = this.udata, + adata = this.adata, + ddata = this.ddata; + if (udata.length || adata.length || ddata.length) { + return true + } else { + return false + } + }; + _pUCData.getChangesValue = function() { + var that = this.that, + udata = this.udata, + adata = this.adata, + ddata = this.ddata, + mydata = { + updateList: [], + addList: [], + deleteList: [] + }, mupdateList = [], + updateList = [], + addList = [], + mdeleteList = [], + deleteList = []; + for (var i = 0, len = ddata.length; i < len; i++) { + var rec = ddata[i], + rowData = rec.rowData, + row = {}; + mdeleteList.push(rowData); + for (var key in rowData) { + if (key.indexOf("pq_") != 0) { + row[key] = rowData[key] + } + } + deleteList.push(row) + } + for (var i = 0; i < udata.length; i++) { + var rec = udata[i], + rowData = rec.rowData; + if ($.inArray(rowData, mdeleteList) != -1) { + continue + } + if ($.inArray(rowData, mupdateList) == -1) { + var row = {}; + for (var key in rowData) { + if (key.indexOf("pq_") != 0) { + row[key] = rowData[key] + } + } + mupdateList.push(rowData); + updateList.push(row) + } + } + for (var i = 0; i < adata.length; i++) { + var rec = adata[i], + rowData = rec.rowData, + row = {}; + for (var key in rowData) { + if (key.indexOf("pq_") != 0) { + row[key] = rowData[key] + } + } + addList.push(row) + } + mydata.updateList = updateList; + mydata.addList = addList; + mydata.deleteList = deleteList; + return mydata + }; + _pUCData.getChanges = function() { + var that = this.that, + udata = this.udata, + adata = this.adata, + ddata = this.ddata, + mydata = { + updateList: [], + addList: [], + deleteList: [] + }, updateList = [], + addList = [], + deleteList = []; + for (var i = 0, len = ddata.length; i < len; i++) { + var rec = ddata[i], + rowData = rec.rowData; + deleteList.push(rowData) + } + for (var i = 0; i < udata.length; i++) { + var rec = udata[i], + rowData = rec.rowData; + if ($.inArray(rowData, deleteList) != -1) { + continue + } + if ($.inArray(rowData, updateList) == -1) { + updateList.push(rowData) + } + } + for (var i = 0; i < adata.length; i++) { + var rec = adata[i], + rowData = rec.rowData; + addList.push(rowData) + } + mydata.updateList = updateList; + mydata.addList = addList; + mydata.deleteList = deleteList; + return mydata + }; + _pUCData.getChangesRaw = function() { + var that = this.that, + udata = this.udata, + adata = this.adata, + ddata = this.ddata, + mydata = { + updateList: [], + addList: [], + deleteList: [] + }; + mydata.updateList = udata; + mydata.addList = adata; + mydata.deleteList = ddata; + return mydata + }; + _pUCData.commitAdd = function(rows, recIndx) { + var CM = this.that.colModel, + CMLength = CM.length, + adata = this.adata, + adataLen = adata.length, + rowLen = rows.length, + foundRowData = []; + for (var j = 0; j < rowLen; j++) { + var row = rows[j]; + for (var i = 0; i < adataLen; i++) { + var rowData = adata[i].rowData, + _found = true; + for (var k = 0; k < CMLength; k++) { + var column = CM[k], + hidden = column.hidden, + dataIndx = column.dataIndx; + if (hidden || (dataIndx == recIndx)) { + continue + } + var cellData = rowData[dataIndx], + cellData = (cellData == null) ? "" : cellData + "", + cell = row[dataIndx], + cell = (cell == null) ? "" : cell + ""; + if (cellData != cell) { + _found = false; + break + } + } + if (_found) { + rowData[recIndx] = row[recIndx]; + foundRowData.push(rowData) + } + } + } + var newadata = []; + for (var i = 0; i < adataLen; i++) { + var rowData = adata[i].rowData; + if ($.inArray(rowData, foundRowData) == -1) { + newadata.push(adata[i]) + } + } + this.adata = newadata + }; + _pUCData.commitUpdate = function(rows, recIndx) { + var that = this.that, + CM = that.colModel, + CMLength = CM.length, + udata = this.udata, + udataLen = udata.length, + rowLen = rows.length, + foundRowData = []; + for (var i = 0; i < udataLen; i++) { + var rowData = udata[i].rowData; + if ($.inArray(rowData, foundRowData) != -1) { + continue + } + for (var j = 0; j < rowLen; j++) { + var row = rows[j]; + if (rowData[recIndx] == row[recIndx]) { + foundRowData.push(rowData); + for (var k = 0; k < CMLength; k++) { + var column = CM[k], + hidden = column.hidden, + dataIndx = column.dataIndx; + if (row[dataIndx] !== undefined) { + rowData[dataIndx] = row[dataIndx] + } + that.removeClass({ + rowData: rowData, + dataIndx: dataIndx, + cls: "pq-cell-dirty", + refresh: false + }) + } + } + } + } + var newudata = []; + for (var i = 0; i < udataLen; i++) { + var rowData = udata[i].rowData; + if ($.inArray(rowData, foundRowData) == -1) { + newudata.push(udata[i]) + } + } + this.udata = newudata + }; + _pUCData.commitDelete = function(rows, recIndx) { + var ddata = this.ddata, + ddataLen = ddata.length, + rowLen = rows.length, + foundRowData = []; + for (var i = 0; i < ddataLen; i++) { + var rowData = ddata[i].rowData; + for (var j = 0; j < rowLen; j++) { + var row = rows[j]; + if (rowData[recIndx] == row[recIndx]) { + foundRowData.push(rowData) + } + } + } + var newddata = []; + for (var i = 0; i < ddataLen; i++) { + var rowData = ddata[i].rowData; + if ($.inArray(rowData, foundRowData) == -1) { + newddata.push(ddata[i]) + } + } + this.ddata = newddata + }; + _pUCData.commitUpdateAll = function() { + var that = this.that, + udata = this.udata; + for (var i = 0, len = udata.length; i < len; i++) { + var rec = udata[i], + dataIndx = rec.dataIndx, + rowData = rec.rowData; + that.removeClass({ + rowData: rowData, + dataIndx: dataIndx, + cls: "pq-cell-dirty" + }) + } + this.udata = [] + }; + _pUCData.commitAddAll = function() { + this.adata = [] + }; + _pUCData.commitDeleteAll = function() { + this.ddata = [] + }; + _pUCData.commit = function(objP) { + var that = this.that, + DM = that.options.dataModel, + recIndx = DM.recIndx; + if (objP == null) { + this.commitAddAll(); + this.commitUpdateAll(); + this.commitDeleteAll() + } else { + var objType = objP.type, + rows = objP.rows; + if (objType == "add") { + if (rows) { + this.commitAdd(rows, recIndx) + } else { + this.commitAddAll() + } + } else { + if (objType == "update") { + if (rows) { + this.commitUpdate(rows, recIndx) + } else { + this.commitUpdateAll() + } + } else { + if (objType == "delete") { + if (rows) { + this.commitDelete(rows, recIndx) + } else { + this.commitDeleteAll() + } + } + } + } + } + that.refreshView() + }; + _pUCData.rollbackAdd = function(PM, data) { + var adata = this.adata, + paging = PM.type; + for (var i = 0, len = adata.length; i < len; i++) { + var rec = adata[i], + rowData = rec.rowData; + for (var j = 0, len2 = data.length; j < len2; j++) { + if (data[j] == rowData) { + var remA = data.splice(j, 1); + if (remA && remA.length && paging == "remote") { + PM.totalRecords-- + } + break + } + } + } + this.adata = [] + }; + _pUCData.rollbackDelete = function(PM, data) { + var ddata = this.ddata, + paging = PM.type; + for (var i = ddata.length - 1; i >= 0; i--) { + var rec = ddata[i], + indx = rec.indx, + rowData = rec.rowData; + data.splice(indx, 0, rowData); + if (paging == "remote") { + PM.totalRecords++ + } + } + this.ddata = [] + }; + _pUCData.rollbackUpdate = function(PM, data) { + var that = this.that, + udata = this.udata; + for (var i = 0, len = udata.length; i < len; i++) { + var rec = udata[i], + recId = rec.recId, + rowData = rec.rowData, + dataIndx = rec.dataIndx; + if (recId == null) { + continue + } + rowData[dataIndx] = rec.oldVal; + that.removeClass({ + rowData: rowData, + dataIndx: dataIndx, + cls: "pq-cell-dirty", + refresh: false + }) + } + this.udata = [] + }; + _pUCData.rollback = function(objP) { + var that = this.that, + DM = that.options.dataModel, + PM = that.options.pageModel, + refreshView = (objP && (objP.refresh != null)) ? objP.refresh : true, + objType = (objP && (objP.type != null)) ? objP.type : null, + data = DM.data; + if (objType == null || objType == "update") { + this.rollbackUpdate(PM, data) + } + if (objType == null || objType == "delete") { + this.rollbackDelete(PM, data) + } + if (objType == null || objType == "add") { + this.rollbackAdd(PM, data) + } + if (refreshView) { + that.refreshView() + } + }; + var fnGrid = $.paramquery.pqGrid.prototype; + fnGrid.getChanges = function(obj) { + this.quitEditMode(); + if (obj) { + var format = obj.format; + if (format) { + if (format == "byVal") { + return this.iUCData.getChangesValue() + } else { + if (format == "raw") { + return this.iUCData.getChangesRaw() + } + } + } + } + return this.iUCData.getChanges() + }; + fnGrid.rollback = function(obj) { + this.quitEditMode(); + this.iUCData.rollback(obj) + }; + fnGrid.isDirty = function() { + return this.iUCData.isDirty() + }; + fnGrid.commit = function(obj) { + this.quitEditMode(); + this.iUCData.commit(obj) + }; + fnGrid._getRowIndx = function() { + var that = this; + var arr = that.selection({ + type: "row", + method: "getSelection" + }); + if (arr && arr.length > 0) { + var rowIndx = arr[0].rowIndx, + offset = that.rowIndxOffset, + PM = that.options.pageModel, + paging = PM.type, + rowIndxPage = rowIndx - offset, + rPP = PM.rPP; + if (paging) { + if (rowIndxPage >= 0 && rowIndxPage < rPP) { + return rowIndx + } + } else { + return rowIndx + } + } else { + return null + } + }; + fnGrid.updateRow = function(objP) { + var that = this, + options = that.options, + track = options.track, + track = (objP.track != null) ? objP.track : track, + rowIndx = objP.rowIndx, + row = objP.row, + requireRefresh = false, + rowData = that.getRowData({ + rowIndx: rowIndx + }); + var obj = { + rowData: rowData + }; + for (var dataIndx in row) { + var oldVal = rowData[dataIndx], + newVal = row[dataIndx]; + if (newVal !== oldVal) { + requireRefresh = true; + if (track) { + obj.dataIndx = dataIndx; + obj.oldVal = oldVal; + obj.newVal = newVal; + this.iUCData.update(obj) + } + rowData[dataIndx] = newVal + } + } + if (requireRefresh) { + that.refreshRow({ + rowIndx: rowIndx + }) + } + }; + fnGrid._fillForm = function(obj) { + var that = this, + DM = that.options.dataModel, + PM = that.options.pageModel, + paging = PM.type, + data = DM.data, + CM = that.colModel, + offset = that.rowIndxOffset, + rowIndxPage = (obj.rowIndxPage == null) ? obj.rowIndx - offset : obj.rowIndxPage, + rowIndx = (obj.rowIndx == null) ? rowIndxPage + offset : obj.rowIndx, + indx = (paging == "remote") ? rowIndxPage : rowIndx, + rowData = data[indx]; + this.rowData = rowData; + this.$crudDialog.dialog("option", "title", "Edit Record (" + (rowIndx + 1) + ")"); + var $frm = this.$crudForm; + for (var i = 0; i < CM.length; i++) { + var column = CM[i], + dataIndx = column.dataIndx, + val = rowData[dataIndx]; + $frm.find("*[name='" + dataIndx + "']").val(val) + } + }; + fnGrid.getRecId = function(obj) { + var that = this, + DM = that.options.dataModel; + obj.dataIndx = DM.recIndx; + var recId = that.getCellData(obj); + return recId + }; + fnGrid.getCellData = function(obj) { + var rowData = this.getRowData(obj), + dataIndx = obj.dataIndx; + return rowData[dataIndx] + }; + fnGrid.getRowData = function(obj) { + var objRowData = obj.rowData; + if (objRowData != null) { + return objRowData + } + var options = this.options, + DM = options.dataModel, + PM = options.pageModel, + paging = PM.type, + recIndx = DM.recIndx, + recId = obj.recId, + data = DM.data; + if (recId != null) { + for (var i = 0, len = data.length; i < len; i++) { + var rowData = data[i]; + if (rowData[recIndx] == recId) { + return rowData + } + } + } else { + var rowIndx = obj.rowIndx, + rowIndxPage = obj.rowIndxPage, + offset = this.rowIndxOffset, + rowIndx = (rowIndx != null) ? rowIndx : rowIndxPage + offset, + rowIndxPage = (rowIndxPage != null) ? rowIndxPage : rowIndx - offset, + indx = (paging == "remote") ? rowIndxPage : rowIndx, + rowData = data[indx]; + return rowData + } + }; + fnGrid.deleteRow = function(obj) { + var that = this, + rowIndx = obj.rowIndx, + effect = obj.effect, + options = that.options, + DM = options.dataModel, + PM = options.pageModel, + paging = PM.type; + if (rowIndx != null) { + var indx = (paging == "remote") ? (rowIndx - this.rowIndxOffset) : rowIndx, + data = DM.data, + track = options.track, + track = (obj.track != null) ? obj.track : track; + if (track) { + this.iUCData["delete"]({ + rowIndx: rowIndx + }) + } + if (effect) { + var that = this, + $tr = this.getRow({ + rowIndx: rowIndx + }); + if ($tr) { + $tr.effect("fade", null, 350, function() { + var complete = obj.complete; + if (complete && typeof complete == "function") { + complete.call(that) + } + var remArr = data.splice(indx, 1); + if (remArr && remArr.length && paging == "remote") { + PM.totalRecords-- + } + that.refreshView() + }) + } + } else { + var remArr = data.splice(indx, 1); + if (remArr && remArr.length && paging == "remote") { + PM.totalRecords-- + } + this.refreshView() + } + } + }; + fnGrid._onDialogOpen = function() { + var that = this, + self = this, + $dialog = this.$crudDialog.parent(".ui-dialog"); + $(".pq-dialog-buttonset", $dialog).remove(); + if (this.crudEditMode == false) { + return + } + var $div = $("
").prependTo($(".ui-dialog-buttonpane", $dialog)); + this.prev = $("").appendTo($div).button({ + icons: { + primary: "ui-icon-circle-triangle-w" + }, + text: false + }).bind("click", function(evt) { + var rowIndxPage = that.rowPrevSelect(); + self._fillForm({ + rowIndxPage: rowIndxPage + }) + }); + this.prev.removeClass("ui-corner-all"); + this.next = $("").appendTo($div).button({ + icons: { + primary: "ui-icon-circle-triangle-e" + }, + text: false + }).bind("click", function(evt) { + var rowIndxPage = that.rowNextSelect(); + self._fillForm({ + rowIndxPage: rowIndxPage + }) + }); + this.next.removeClass("ui-corner-all") + }; + fnGrid.getFormData = function($frm) { + var that = this, + rowData = {}, CM = that.colModel; + for (var i = 0; i < CM.length; i++) { + var column = CM[i], + dataIndx = column.dataIndx, + $fld = $frm.find("*[name='" + dataIndx + "']"); + rowData[dataIndx] = $fld.val() + } + return rowData + }; + fnGrid.addRow = function(obj) { + var self = this; + return self._addLocal(obj) + }; + fnGrid._addLocal = function(obj) { + var that = this, + rowData = obj.rowData, + rowIndx = obj.rowIndx, + rowIndxPage = obj.rowIndxPage, + thatOptions = that.options, + DM = thatOptions.dataModel, + PM = thatOptions.pageModel, + paging = PM.type, + track = thatOptions.track, + track = (obj.track != null) ? obj.track : track, + data = DM.data; + if (rowData == null) { + return null + } + if (data == null) { + DM.data = []; + data = DM.data + } + if (track) { + this.iUCData.add({ + rowData: rowData + }) + } + if (rowIndx == null && rowIndxPage == null) { + data.push(rowData) + } else { + var offset = this.rowIndxOffset, + rowIndx = (rowIndx == null) ? (rowIndxPage + offset) : rowIndx, + rowIndxPage = (rowIndxPage == null) ? (rowIndx - offset) : rowIndxPage, + indx = (paging == "remote") ? rowIndxPage : rowIndx; + data.splice(indx, 0, rowData) + } if (paging == "remote") { + PM.totalRecords++ + } + if (!obj.refresh !== false) { + this.refreshView() + } + if (rowIndx == null) { + return data.length - 1 + } else { + return rowIndx + } + }; + fnGrid._addRemote = function(obj) { + var that = this, + rowData = obj.rowData; + rowData.pq_oper = "add"; + that.options.dataModel.postDataOnce = rowData + } +})(jQuery); +(function($) { + var fnTB = {}; + fnTB.options = { + items: [], + gridInstance: null + }; + fnTB._create = function() { + var self = this, + options = this.options, + that = options.gridInstance, + CM = that.colModel, + items = options.items, + element = this.element, + $grid = element.closest(".pq-grid"); + element.addClass("pq-toolbar"); + for (var i = 0, len = items.length; i < len; i++) { + var item = items[i], + type = item.type, + icon = item.icon, + options = item.options, + text = item.label, + listeners = item.listeners, + itemcls = item.cls, + cls = "ui-corner-all " + (itemcls ? itemcls : ""), + itemstyle = item.style, + style = itemstyle ? 'style="' + itemstyle + '"' : "", + itemattr = item.attr, + attr = itemattr ? itemattr : "", + $ctrl; + if (type == "textbox") { + $ctrl = $("").appendTo(element) + } else { + if (type == "checkbox") { + $ctrl = $("").appendTo(element) + } else { + if (type == "separator") { + $("").appendTo(element) + } else { + if (type == "button") { + $ctrl = $("").button({ + text: text ? true : false, + icons: { + primary: icon + } + }).appendTo(element) + } else { + if (type == "select") { + var options = item.options ? item.options : []; + if (typeof options === "function") { + options = options.call(that.element, { + colModel: CM + }) + } + inp = $.paramquery.select({ + options: options, + attr: " class='" + cls + "' " + attr + " " + style, + prepend: item.prepend, + groupIndx: item.groupIndx, + valueIndx: item.valueIndx, + labelIndx: item.labelIndx + }); + $ctrl = $(inp).appendTo(element) + } else { + if (typeof type == "string") { + $ctrl = $(type).appendTo(element) + } else { + if (typeof type == "function") { + var inp = type.call(that, { + colModel: CM, + cls: cls + }); + $ctrl = $(inp).appendTo(element) + } + } + } + } + } + } + } if (listeners) { + for (var j = 0; j < listeners.length; j++) { + var listener = listeners[j]; + for (var event in listener) { + $ctrl.bind(event, listener[event]) + } + } + } + } + }; + fnTB._destroy = function() { + this.element.empty().removeClass("pq-toolbar").enableSelection() + }; + fnTB._disable = function() { + if (this.$disable == null) { + this.$disable = $("
").css("opacity", 0.2).appendTo(this.element) + } + }; + fnTB._enable = function() { + if (this.$disable) { + this.element[0].removeChild(this.$disable[0]); + this.$disable = null + } + }; + fnTB._setOption = function(key, value) { + if (key == "disabled") { + if (value == true) { + this._disable() + } else { + this._enable() + } + } + }; + $.widget("paramquery.pqToolbar", fnTB) +})(jQuery); +(function($) { + var cSelection = function() { + this.focusSelection = null + }; + var _pSelection = cSelection.prototype; + _pSelection.getOldRowSel = function() { + var that = this.that, + lastSel; + if ((lastSel = this.focusSelection) && this.isSelected(lastSel)) { + var objP = that.getRowIndx(lastSel); + objP.rowData = lastSel.rowData; + return objP + } + }; + _pSelection.getOldCellSel = function() { + var that = this.that, + lastSel; + if ((lastSel = this.focusSelection) && this.isSelected(lastSel)) { + var rowData = lastSel.rowData; + var objP = that.getRowIndx({ + rowData: rowData + }); + objP.rowData = rowData; + objP.dataIndx = lastSel.dataIndx; + return objP + } + }; + _pSelection.getNewRowSel = function() { + var that = this.that, + $ae = document.activeElement ? $(document.activeElement) : null; + if ($ae && $ae.hasClass("pq-grid-row")) { + var $grid = $ae.closest(".pq-grid"); + if ($grid[0] == that.element[0]) { + var objP = that.getRowIndx({ + $tr: $ae + }); + objP.$tr = $ae; + return objP + } + } + }; + _pSelection.getNewCellSel = function() { + var that = this.that, + $ae = document.activeElement ? $(document.activeElement) : null; + if ($ae && $ae.hasClass("pq-grid-cell")) { + var $grid = $ae.closest(".pq-grid"); + if ($grid[0] == that.element[0]) { + var objP = that.getCellIndices({ + $td: $ae + }); + objP.$td = $ae; + return objP + } + } + }; + _pSelection.getFocusSelection = function(objP) { + if (this instanceof cRows) { + if (objP && objP.old === true) { + return this.getOldRowSel() + } else { + return this.getNewRowSel() + } + } else { + if (this instanceof cCells) { + if (objP && objP.old === true) { + return this.getOldCellSel() + } else { + return this.getNewCellSel() + } + } + } + }; + _pSelection.getFirstSelection = function() { + var fs = this.firstSelection; + if (fs && this.isSelected(fs)) { + return fs + } else { + this.refresh(); + var selection = this.selection; + if (selection.length) { + this.firstSelection = selection[0]; + return selection[0] + } + } + }; + _pSelection.getLastSelection = function() { + var ls = this.lastSelection; + if (ls) { + var that = this.that, + rowData = ls.rowData, + rowData2 = that.getRowData({ + rowIndx: rowIndx + }); + if (rowData == rowData2 && this.isSelected(ls)) { + return ls + } else { + return false + } + } else { + return null + } + }; + _pSelection.getLastSelectionCurPage = function() { + var ls = this.lastSelection; + if (ls && this.isSelected(ls)) { + var rowIndx = ls.rowIndx, + PM = this.that.options.pageModel; + if (PM.type) { + var curPage = PM.curPage, + rPP = PM.rPP; + if (Math.ceil((rowIndx + 1) / rPP) == curPage) { + return ls + } else { + return null + } + } else { + return ls + } + } else { + return null + } + }; + _pSelection.getSelection = function() { + this.refresh(); + return this.selection + }; + _pSelection.getSelectionCurPage = function() { + var that = this.that, + selection = this.getSelection(), + selection2 = [], + options = that.options, + DM = options.dataModel, + PM = options.pageModel; + if (PM.type) { + var curPage = DM.curPage, + rPP = DM.rPP; + for (var i = 0; i < selection.length; i++) { + var sel = selection[i], + rowIndx = sel.rowIndx; + if (Math.ceil((rowIndx + 1) / rPP) == curPage) { + selection2.push(sel) + } + } + return selection2 + } else { + return selection + } + }; + _pSelection.setDirty = function() {}; + var cRows = function(that) { + this.that = that; + this.options = that.options; + this.selection = [] + }; + $.paramquery.cRows = cRows; + var cCells = function(that) { + this.options = that.options; + this.that = that; + this.selection = [] + }; + $.paramquery.cCells = cCells; + var _pC = cCells.prototype = new cSelection; + var _pR = cRows.prototype = new cSelection; + _pR.extendSelection = function(objP) { + var that = this.that, + rowIndx = objP.rowIndx, + mode = that.options.selectionModel.mode, + evt = objP.evt; + var rowFirstSel = this.getFirstSelection(); + if (rowFirstSel == null) { + that.setSelection({ + rowIndx: rowIndx + }); + return + } + if (mode != "single") { + var rowIndx1 = rowFirstSel.rowIndx, + initRowIndx = rowIndx1, + finalRowIndx = rowIndx; + if (rowIndx1 > rowIndx) { + initRowIndx = rowIndx; + finalRowIndx = rowIndx1 + } + this.selectRange({ + initRowIndx: initRowIndx, + finalRowIndx: finalRowIndx, + evt: evt + }); + this.add({ + rowIndx: rowIndx + }) + } + }; + _pR.refresh = function() { + this.selection = []; + var that = this.that, + options = that.options, + DM = options.dataModel, + PM = options.pageModel, + paging = PM.type, + remote = (paging == "remote") ? true : false, + offset = that.rowIndxOffset, + data = DM.data; + if (!data) { + return + } + for (var i = 0, len = data.length; i < len; i++) { + var rowData = data[i]; + if (rowData.pq_rowselect) { + var rowIndx = (remote) ? (i + offset) : i; + this.selection.push({ + rowIndx: rowIndx, + rowData: rowData + }) + } + } + }; + _pR.replace = function(obj) { + var rowIndx = obj.rowIndx, + offset = (obj.offset == null) ? this.that.getRowIndxOffset() : obj.offset, + rowIndxPage = rowIndx - offset, + $tr = obj.$tr, + evt = obj.evt; + obj.offset = offset; + obj.rowIndxPage = rowIndxPage; + this.removeAll({ + raiseEvent: true + }); + this.add(obj) + }; + _pR.indexOf = function(obj) { + this.refresh(); + var rowIndx = obj.rowIndx, + selectedRows = this.selection; + for (var i = 0; i < selectedRows.length; i++) { + if (selectedRows[i].rowIndx == rowIndx) { + return i + } + } + return -1 + }; + _pR.isSelected = function(objP) { + var that = this.that, + rowData = that.getRowData(objP); + return (rowData) ? ((rowData.pq_rowselect == null) ? false : rowData.pq_rowselect) : null + }; + _pR._boundRow = function(obj) { + var rowIndxPage = obj.rowIndxPage, + that = this.that, + $tr = (obj.$tr == null) ? that.getRow({ + rowIndxPage: rowIndxPage + }) : obj.$tr; + if ($tr == null || $tr.length == 0) { + return false + } + $tr.addClass("pq-row-select ui-state-highlight"); + return $tr + }; + _pR.selectRange = function(objP) { + var that = this.that, + initRowIndx = objP.initRowIndx, + finalRowIndx = objP.finalRowIndx, + evt = objP.evt, + rowSelection = this.getSelection(), + rowSelection2 = rowSelection.slice(0); + for (var i = 0; i < rowSelection2.length; i++) { + var rowS = rowSelection2[i], + row = rowS.rowIndx; + if (row < initRowIndx || row > finalRowIndx) { + this.remove({ + rowIndx: row + }) + } + } + if (initRowIndx > finalRowIndx) { + var temp = initRowIndx; + initRowIndx = finalRowIndx; + finalRowIndx = temp + } + for (var row = initRowIndx; row <= finalRowIndx; row++) { + this.add({ + rowIndx: row, + focus: false + }) + } + }; + _pC._addToData = function(objP) { + var dataIndx = objP.dataIndx, + rowData = this.that.getRowData(objP); + if (!rowData.pq_cellselect) { + rowData.pq_cellselect = {} + } + rowData.pq_cellselect[dataIndx] = true + }; + _pC.extendSelection = function(objP) { + var that = this.that, + lastSel = this.getFirstSelection(), + rowIndx = objP.rowIndx, + colIndx = objP.colIndx, + mode = that.options.selectionModel.mode, + evt = objP.evt; + if (lastSel == null) { + that.setSelection({ + rowIndx: rowIndx, + colIndx: colIndx + }); + return + } + var rowIndx1 = lastSel.rowIndx, + colIndx1 = that.getColIndx({ + dataIndx: lastSel.dataIndx + }), + initRowIndx = rowIndx1, + finalRowIndx = rowIndx, + initColIndx = colIndx1, + finalColIndx = colIndx; + if (rowIndx1 > rowIndx) { + initRowIndx = rowIndx; + finalRowIndx = rowIndx1 + } + if (mode == "range") { + if (rowIndx1 > rowIndx) { + initColIndx = colIndx; + finalColIndx = colIndx1 + } + if (rowIndx == rowIndx1 && colIndx < colIndx1) { + initColIndx = colIndx; + finalColIndx = colIndx1 + } + this.selectRange({ + initRowIndx: initRowIndx, + initColIndx: initColIndx, + finalRowIndx: finalRowIndx, + finalColIndx: finalColIndx, + evt: evt + }); + this.add({ + rowIndx: rowIndx, + colIndx: colIndx + }) + } else { + if (mode == "block") { + if (colIndx1 > colIndx) { + initColIndx = colIndx; + finalColIndx = colIndx1 + } + this.selectBlock({ + initRowIndx: initRowIndx, + initColIndx: initColIndx, + finalRowIndx: finalRowIndx, + finalColIndx: finalColIndx, + evt: evt + }); + this.add({ + rowIndx: rowIndx, + colIndx: colIndx + }) + } + } + }; + _pC._removeFromData = function(objP) { + var rowData = objP.rowData; + if (rowData && rowData.pq_cellselect) { + delete rowData.pq_cellselect[objP.dataIndx] + } + }; + _pC.removeAll = function() { + this.refresh(); + var cells = this.selection.slice(0); + this.remove({ + cells: cells + }); + this.lastSelection = null + }; + _pR.removeAll = function(objP) { + var that = this.that, + page = objP ? objP.page : false; + this.refresh(); + var rows = this.selection.slice(0); + if (page) { + var rows2 = [], + offset = that.rowIndxOffset, + curPageData = that.data, + curPageDataLen = curPageData ? curPageData.length : 0; + for (var i = 0, len = rows.length; i < len; i++) { + var row = rows[i], + rowIndx = row.rowIndx, + rowIndxPage = rowIndx - offset; + if (rowIndxPage >= 0) { + if (rowIndxPage < curPageDataLen) { + rows2.push(row) + } else { + break + } + } + } + this.remove({ + rows: rows2 + }) + } else { + this.remove({ + rows: rows + }); + this.lastSelection = null + } + }; + _pC.isSelected = function(objP) { + var that = this.that, + rowData = that.getRowData(objP), + dataIndx = objP.dataIndx, + dataIndx = (dataIndx == null) ? that.colModel[objP.colIndx].dataIndx : dataIndx; + if (rowData == null) { + return null + } + if (rowData.pq_cellselect) { + if (rowData.pq_cellselect[dataIndx]) { + return true + } + } + return false + }; + _pC.refresh = function() { + this.selection = []; + var that = this.that, + DM = that.options.dataModel, + PM = that.options.pageModel, + data = DM.data, + paging = PM.type, + remote = (paging == "remote") ? true : false, + offset = that.rowIndxOffset; + if (!data) { + return + } + for (var i = 0, len = data.length; i < len; i++) { + var rowData = data[i]; + var pq_cellselect = rowData.pq_cellselect; + if (pq_cellselect) { + var rowIndx = (remote) ? (i + offset) : i; + for (var dataIndx in pq_cellselect) { + if (pq_cellselect[dataIndx]) { + this.selection.push({ + rowIndx: rowIndx, + rowData: rowData, + dataIndx: dataIndx + }) + } + } + } + } + this.isDirty = false + }; + _pC.replace = function(obj) { + var rowIndx = obj.rowIndx, + colIndx = obj.colIndx, + offset = (obj.offset == null) ? this.that.getRowIndxOffset() : obj.offset, + rowIndxPage = rowIndx - offset, + $td = obj.$td, + evt = obj.evt; + obj.rowIndxPage = rowIndxPage; + obj.offset = offset; + this.removeAll({ + raiseEvent: true + }); + this.add(obj) + }; + _pC.inView = function(rowIndxPage, colIndx) { + var that = this.that, + options = this.options, + freezeRows = options.freezeRows, + freezeCols = options.freezeCols; + return ((rowIndxPage < freezeRows || rowIndxPage >= that.init && rowIndxPage <= that["final"]) && (colIndx < freezeCols || colIndx >= that.initH && colIndx <= that.finalH)) + }; + _pC._add = function(objP) { + var that = this.that, + rowIndx = objP.rowIndx, + rowIndxPage = objP.rowIndxPage, + rowData = objP.rowData, + offset = that.rowIndxOffset, + success, rowIndx = (rowIndx == null) ? (rowIndxPage + offset) : rowIndx, + rowIndxPage = (rowIndxPage == null) ? (rowIndx - offset) : rowIndxPage, + rowData = (rowData == null) ? that.getRowData(objP) : rowData, + colIndx = objP.colIndx, + dataIndx = objP.dataIndx, + colIndx = (colIndx == null) ? that.getColIndx({ + dataIndx: dataIndx + }) : colIndx, + column = that.colModel[colIndx], + dataIndx = (dataIndx == null) ? column.dataIndx : dataIndx, + evt = objP.evt, + isSelected = this.isSelected({ + rowData: rowData, + dataIndx: dataIndx + }); + if (isSelected == null) { + return false + } + var inView = this.inView(rowIndxPage, colIndx); + if (isSelected === false) { + if (inView) { + var $td = that.getCell({ + rowIndxPage: rowIndxPage, + colIndx: colIndx + }); + if ($td) { + $td.addClass("pq-cell-select ui-state-highlight") + } + } + this._addToData({ + rowData: rowData, + dataIndx: dataIndx + }); + if (objP.trigger !== false) { + that._trigger("cellSelect", evt, { + rowIndx: rowIndx, + rowIndxPage: rowIndxPage, + colIndx: colIndx, + dataIndx: dataIndx, + column: column, + rowData: rowData + }) + } + success = true + } + this.lastSelection = { + rowIndx: rowIndx, + dataIndx: dataIndx, + rowData: rowData + }; + if (objP.focus !== false && inView) { + if (!$td || !$td.length) { + $td = that.getCell({ + rowIndxPage: rowIndxPage, + dataIndx: dataIndx + }) + } + if ($td && $td.length) { + $td.attr("tabindex", "0"); + $td.focus(); + that._fixTableViewPort(); + this.focusSelection = { + rowData: rowData, + rowIndx: rowIndx, + dataIndx: dataIndx + } + } + } + if (objP.setFirst) { + this.firstSelection = { + rowIndx: rowIndx, + rowData: rowData, + dataIndx: dataIndx + } + } + if (success) { + return { + rowIndx: rowIndx, + rowData: rowData, + dataIndx: dataIndx, + colIndx: colIndx, + column: column + } + } + }; + _pR.inView = function(rowIndxPage) { + var that = this.that, + options = this.options, + freezeRows = options.freezeRows; + return ((rowIndxPage < freezeRows || rowIndxPage >= that.init && rowIndxPage <= that["final"])) + }; + _pR._add = function(objP) { + var that = this.that, + success, rowIndx = objP.rowIndx, + rowIndxPage = objP.rowIndxPage, + offset = that.rowIndxOffset, + rowIndx = (rowIndx == null) ? (rowIndxPage + offset) : rowIndx, + rowIndxPage = (rowIndxPage == null) ? (rowIndx - offset) : rowIndxPage, + rowData = (rowData == null) ? that.getRowData(objP) : rowData, + $tr = objP.$tr, + evt = objP.evt, + isSelected = this.isSelected({ + rowData: rowData + }); + objP.rowIndxPage = rowIndxPage; + if (isSelected == null) { + return false + } + var inView = this.inView(rowIndxPage); + if (isSelected === false) { + if (inView) { + var ret = this._boundRow(objP), + $tr = ret + } + rowData.pq_rowselect = true; + if (objP.trigger !== false) { + that._trigger("rowSelect", evt, { + rowIndx: rowIndx, + rowIndxPage: rowIndxPage, + rowData: rowData, + $tr: $tr + }) + } + success = true + } + this.lastSelection = { + rowIndx: rowIndx, + rowData: rowData + }; + if (objP.focus !== false && inView) { + if (!$tr || !$tr.length) { + $tr = that.getRow({ + rowIndxPage: rowIndxPage + }) + } + if ($tr) { + $tr = $($tr[0]); + $tr.attr("tabindex", "0"); + $tr.focus(); + that._fixTableViewPort(); + this.focusSelection = { + rowData: rowData, + rowIndx: rowIndx + } + } + } + if (objP.setFirst) { + this.firstSelection = { + rowIndx: rowIndx, + rowData: rowData + } + } + if (success) { + return { + rowIndx: rowIndx, + rowData: rowData + } + } + }; + _pC.add = function(objP) { + var that = this.that, + evt = objP.evt, + cells = objP.cells, + cells2 = []; + if (cells && typeof cells.push == "function") { + for (var i = 0, len = cells.length; i < len; i++) { + var cell = cells[i]; + cell.trigger = false; + var ret = this._add(cell); + if (ret) { + cells2.push(ret) + } + } + if (cells2.length) { + that._trigger("cellSelect", evt, { + cells: cells2 + }) + } + } else { + this._add(objP) + } + }; + _pR.add = function(objP) { + var that = this.that, + evt = objP.evt, + rows = objP.rows, + rows2 = []; + if (rows && typeof rows.push == "function") { + for (var i = 0, len = rows.length; i < len; i++) { + var row = rows[i]; + row.trigger = false; + var ret = this._add(row); + if (ret) { + rows2.push(ret) + } + } + if (rows2.length) { + that._trigger("rowSelect", evt, { + rows: rows2 + }) + } + } else { + this._add(objP) + } + }; + _pC._remove = function(objP) { + var that = this.that, + rowIndx = objP.rowIndx, + rowIndxPage = objP.rowIndxPage, + offset = that.rowIndxOffset, + rowIndx = (rowIndx == null) ? (rowIndxPage + offset) : rowIndx, + rowIndxPage = (rowIndxPage == null) ? (rowIndx - offset) : rowIndxPage, + rowData = (rowData == null) ? that.getRowData(objP) : rowData, + colIndx = objP.colIndx, + dataIndx = objP.dataIndx, + colIndx = (colIndx == null) ? that.getColIndx({ + dataIndx: dataIndx + }) : colIndx, + column = that.colModel[colIndx], + dataIndx = (dataIndx == null) ? column.dataIndx : dataIndx, + evt = objP.evt, + isSelected = this.isSelected({ + rowData: rowData, + dataIndx: dataIndx + }); + if (isSelected) { + if (this.inView(rowIndxPage, colIndx)) { + var $td = that.getCell({ + rowIndxPage: rowIndxPage, + colIndx: colIndx + }); + if ($td) { + $td.removeClass("pq-cell-select ui-state-highlight"); + $td.removeAttr("tabindex") + } + } + this._removeFromData({ + rowData: rowData, + dataIndx: dataIndx + }); + if (objP.trigger !== false) { + that._trigger("cellUnSelect", evt, { + rowIndx: rowIndx, + colIndx: colIndx, + dataIndx: dataIndx, + rowData: rowData + }) + } + return { + rowIndx: rowIndx, + rowData: rowData, + dataIndx: dataIndx, + colIndx: colIndx, + column: column + } + } + }; + _pR._remove = function(objP) { + var that = this.that, + rowIndx = objP.rowIndx, + rowIndxPage = objP.rowIndxPage, + offset = that.rowIndxOffset, + rowIndx = (rowIndx == null) ? (rowIndxPage + offset) : rowIndx, + rowIndxPage = (rowIndxPage == null) ? (rowIndx - offset) : rowIndxPage, + rowData = (rowData == null) ? that.getRowData(objP) : rowData, + $tr = objP.$tr, + evt = objP.evt, + isSelected = this.isSelected({ + rowData: rowData + }); + if (isSelected) { + if (this.inView(rowIndxPage)) { + var $tr = that.getRow({ + rowIndxPage: rowIndxPage + }); + if ($tr) { + $tr.removeClass("pq-row-select ui-state-highlight"); + $tr.removeAttr("tabindex") + } + } + rowData.pq_rowselect = false; + if (objP.trigger !== false) { + that._trigger("rowUnSelect", evt, { + rowIndx: rowIndx, + rowData: rowData, + $tr: $tr + }) + } + return { + rowIndx: rowIndx, + rowData: rowData + } + } + }; + _pC.remove = function(objP) { + var cells = objP.cells; + if (cells && typeof cells.push == "function") { + var cells2 = []; + for (var i = 0, len = cells.length; i < len; i++) { + var cell = cells[i]; + cell.trigger = false; + var ret = this._remove(cell); + if (ret) { + cells2.push(ret) + } + } + if (cells2.length) { + this.that._trigger("cellUnSelect", objP.evt, { + cells: cells2 + }) + } + } else { + this._remove(objP) + } + }; + _pR.remove = function(objP) { + var rows = objP.rows; + if (rows && typeof rows.push == "function") { + var rows2 = []; + for (var i = 0, len = rows.length; i < len; i++) { + var row = rows[i]; + row.trigger = false; + var ret = this._remove(row); + if (ret) { + rows2.push(ret) + } + } + if (rows2.length) { + this.that._trigger("rowUnSelect", objP.evt, { + rows: rows2 + }) + } + } else { + this._remove(objP) + } + }; + _pC.indexOf = function(obj) { + this.refresh(); + var rowIndx = obj.rowIndx, + that = this.that, + dataIndx = (obj.dataIndx == null) ? that.colModel[obj.colIndx].dataIndx : obj.dataIndx; + obj.dataIndx = dataIndx; + var selectedCells = this.selection; + for (var i = 0; i < selectedCells.length; i++) { + var sCell = selectedCells[i]; + if (sCell.rowIndx == rowIndx && sCell.dataIndx == dataIndx) { + return i + } + } + return -1 + }; + _pC.selectAll = function(objP) { + var that = this.that, + all = (objP && objP.all) ? true : false, + data = all ? this.options.dataModel.data : that.data, + offset = that.rowIndxOffset, + CM = that.colModel, + CMLength = CM.length, + cells = [], + addCell = function(rowData, rowIndx) { + for (var j = 0; j < CMLength; j++) { + var column = CM[j]; + if (column.hidden) { + continue + } + var cell = { + rowIndx: rowIndx, + rowData: rowData, + colIndx: j, + dataIndx: column.dataIndx, + focus: false + }; + cells.push(cell) + } + }; + if (!data) { + return + } + for (var i = 0, len = data.length; i < len; i++) { + var rowData = data[i] + } + if (all) { + var paging = this.options.pageModel.type, + remote = (paging == "remote") ? true : false; + for (var i = 0, len = data.length; i < len; i++) { + var rowData = data[i], + rowIndx = i; + if (remote) { + rowIndx = i + offset + } + addCell(rowData, rowIndx) + } + } else { + for (var i = 0, len = data.length; i < len; i++) { + var rowData = data[i], + rowIndxPage = i, + rowIndx = rowIndxPage + offset; + addCell(rowData, rowIndx) + } + } + this.add({ + cells: cells + }) + }; + _pR.selectAll = function(objP) { + var that = this.that, + all = (objP && objP.all) ? true : false, + data = all ? this.options.dataModel.data : that.data, + rows = []; + if (!data) { + return + } + if (all) { + var paging = this.options.pageModel.type, + remote = (paging == "remote") ? true : false; + for (var i = 0, len = data.length; i < len; i++) { + var obj = { + rowData: data[i], + focus: false + }; + if (remote) { + obj.rowIndxPage = i + } else { + obj.rowIndx = i + } + rows.push(obj) + } + } else { + for (var i = 0, len = data.length; i < len; i++) { + var rowData = data[i]; + rows.push({ + rowIndxPage: i, + rowData: rowData, + focus: false + }) + } + } + this.add({ + rows: rows + }) + }; + _pC.selectRange = function(objP) { + var that = this.that, + initRowIndx = objP.initRowIndx, + initColIndx = objP.initColIndx, + finalRowIndx = objP.finalRowIndx, + finalColIndx = objP.finalColIndx, + cellSelection = this.getSelection(), + cellSelection2 = cellSelection.slice(0); + for (var i = 0; i < cellSelection2.length; i++) { + var cellS = cellSelection2[i], + row = cellS.rowIndx, + dataIndx = cellS.dataIndx, + col = that.getColIndx({ + dataIndx: dataIndx + }); + if (row < initRowIndx || row > finalRowIndx) { + this.remove({ + rowIndx: row, + colIndx: col, + dataIndx: dataIndx + }) + } else { + if (row == initRowIndx && col < initColIndx) { + this.remove({ + rowIndx: row, + colIndx: col, + dataIndx: dataIndx + }) + } else { + if (row == finalRowIndx && col > finalColIndx) { + this.remove({ + rowIndx: row, + colIndx: col, + dataIndx: dataIndx + }) + } + } + } + } + for (var col = 0; col < that.colModel.length; col++) { + var column = that.colModel[col]; + if (column.hidden) { + continue + } + var dataIndx = column.dataIndx; + var row = initRowIndx; + do { + if (row == initRowIndx && col < initColIndx) {} else { + if (row == finalRowIndx && col > finalColIndx) { + break + } else { + this.add({ + rowIndx: row, + colIndx: col, + dataIndx: dataIndx, + focus: false + }) + } + } + row++ + } while (row <= finalRowIndx) + } + }; + _pC.selectBlock = function(objP) { + var that = this.that, + initRowIndx = objP.initRowIndx, + initColIndx = objP.initColIndx, + finalRowIndx = objP.finalRowIndx, + finalColIndx = objP.finalColIndx, + cellSelection = this.getSelection(), + cellSelection2 = cellSelection.slice(0); + for (var i = 0; i < cellSelection2.length; i++) { + var cellS = cellSelection2[i], + row = cellS.rowIndx, + dataIndx = cellS.dataIndx, + col = that.getColIndx({ + dataIndx: dataIndx + }); + if (col < initColIndx || col > finalColIndx) { + this.remove({ + rowIndx: row, + dataIndx: dataIndx, + colIndx: col + }) + } else { + if (row < initRowIndx || row > finalRowIndx) { + this.remove({ + rowIndx: row, + dataIndx: dataIndx, + colIndx: col + }) + } + } + } + var arrSel = [], + CM = that.colModel; + for (var col = initColIndx; col <= finalColIndx; col++) { + var column = CM[col]; + var dataIndx = column.dataIndx; + if (column.hidden) { + continue + } + var row = initRowIndx; + do { + arrSel.push({ + rowIndx: row, + colIndx: col, + dataIndx: dataIndx, + focus: false + }); + row++ + } while (row <= finalRowIndx); + this.add({ + cells: arrSel + }) + } + } +})(jQuery); +(function($) { + var cCheckBoxColumn = $.paramquery.cCheckBoxColumn = function(that, cbDataIndx) { + var self = this; + this.that = that; + this.options = that.options; + this.type = "checkBoxSelection"; + this.cbDataIndx = cbDataIndx; + var widgetEventPrefix = that.widgetEventPrefix.toLowerCase(); + that.element.on(widgetEventPrefix + "dataavailable", function(evt, ui) { + if (self.belongs(evt)) { + return self._onDataAvailable(evt, ui) + } + }); + that.element.on(widgetEventPrefix + "cellclick", function(evt, ui) { + if (self.belongs(evt)) { + return self.cellClick(evt, ui) + } + }); + that.element.on(widgetEventPrefix + "rowselect", function(evt, ui) { + if (self.belongs(evt)) { + return self.rowSelect(evt, ui) + } + }); + that.element.on(widgetEventPrefix + "rowunselect", function(evt, ui) { + if (self.belongs(evt)) { + return self.rowUnSelect(evt, ui) + } + }); + that.element.on(widgetEventPrefix + "cellkeydown", function(evt, ui) { + if (self.belongs(evt)) { + return self.cellKeyDown(evt, ui) + } + }); + that.element.on(widgetEventPrefix + "refreshheader", function(evt, ui) { + if (self.belongs(evt)) { + return self.refreshHeader(evt, ui) + } + }) + }; + var _pCheckBC = cCheckBoxColumn.prototype = new $.paramquery.cClass; + _pCheckBC.hasHeaderChkBox = function() { + var SM = this.options.selectionModel; + if (SM.cbHeader === false) { + return false + } else { + return true + } + }; + _pCheckBC.setValCBox = function() { + if (!this.hasHeaderChkBox()) { + return + } + var that = this.that, + options = this.options, + cbAll = options.selectionModel.cbAll, + data = cbAll ? options.dataModel.data : that.data, + val = null, + selFound = 0, + unSelFound = 0; + for (var i = 0, len = data.length; i < len; i++) { + var rowData = data[i]; + if (rowData.pq_rowselect) { + selFound++ + } else { + unSelFound++ + } + } + if (selFound == len) { + val = true + } else { + if (unSelFound == len) { + val = false + } + } + this.$inp.pqval({ + val: val + }) + }; + _pCheckBC.refreshHeader = function(evt, ui) { + if (!this.hasHeaderChkBox()) { + return + } + var that = this.that, + data = that.data; + if (!data) { + return + } + var self = this, + $td = that.getCellHeader({ + dataIndx: this.cbDataIndx + }); + $td.html(""); + var $inp = this.$inp = $td.find("input").click(function(evt) { + if ($(this).is(":checked")) { + self.selectAllRows() + } else { + self.unSelectAllRows() + } + evt.stopPropagation() + }); + this.setValCBox() + }; + _pCheckBC.selectAllRows = function() { + var that = this.that, + all = this.options.selectionModel.cbAll; + that.iRows.selectAll({ + all: all + }) + }; + _pCheckBC.unSelectAllRows = function() { + var that = this.that, + all = this.options.selectionModel.cbAll; + if (all) { + that.iRows.removeAll() + } else { + that.iRows.removeAll({ + page: true + }) + } + }; + _pCheckBC._onDataAvailable = function() { + var that = this.that, + data = this.options.dataModel.data, + dataIndx = this._findSelectionIndx(); + if (dataIndx != null && data) { + for (var i = 0, len = data.length; i < len; i++) { + var rowData = data[i]; + if (rowData[dataIndx]) { + rowData.pq_rowselect = true + } + } + } + }; + _pCheckBC._findSelectionIndx = function() { + if (this.cbDataIndx) { + return this.cbDataIndx + } + }; + _pCheckBC.cellClick = function(evt, ui) { + var that = this.that, + rowIndx = ui.rowIndx, + rowData = ui.rowData, + column = ui.column, + type = this.type; + if (column && column.type === type) { + var dataIndx = column.dataIndx; + if (!rowData[dataIndx]) { + that.iRows.add({ + rowIndx: rowIndx + }) + } else { + that.iRows.remove({ + rowIndx: rowIndx + }) + } + evt.stopPropagation(); + return false + } + }; + _pCheckBC.rowSelect = function(evt, ui) { + var that = this.that, + rows = ui.rows, + rowData = ui.rowData, + dataIndx = this._findSelectionIndx(); + if (rows) { + for (var i = 0, len = rows.length; i < len; i++) { + var row = rows[i], + rowIndx = row.rowIndx, + rowData = row.rowData; + rowData[dataIndx] = true; + that.refreshCell({ + rowIndx: rowIndx, + dataIndx: dataIndx + }) + } + } else { + if (rowData) { + rowData[dataIndx] = true; + rowIndx = ui.rowIndx, that.refreshCell({ + rowIndx: rowIndx, + dataIndx: dataIndx + }) + } + } + this.setValCBox() + }; + _pCheckBC.rowUnSelect = function(evt, ui) { + var that = this.that, + rows = ui.rows, + rowData = ui.rowData, + dataIndx = this._findSelectionIndx(); + if (rows) { + for (var i = 0, len = rows.length; i < len; i++) { + var row = rows[i], + rowIndx = row.rowIndx, + rowData = row.rowData; + rowData[dataIndx] = false; + that.refreshCell({ + rowIndx: rowIndx, + dataIndx: dataIndx + }) + } + } else { + if (rowData) { + rowData[dataIndx] = false; + rowIndx = ui.rowIndx, that.refreshCell({ + rowIndx: rowIndx, + dataIndx: dataIndx + }) + } + } + this.setValCBox() + }; + _pCheckBC.cellKeyDown = function(evt, ui) { + var that = this.that, + rowIndx = ui.rowIndx, + column = ui.column, + rowData = rowData, + type = this.type; + if (column && column.type === type) { + var dataIndx = column.dataIndx, + rowIndx = ui.rowIndx; + if (evt.keyCode == 13 || evt.keyCode == 32) { + if (!rowData[dataIndx]) { + that.selection({ + type: "row", + method: "add", + rowIndx: rowIndx + }) + } else { + that.selection({ + type: "row", + method: "remove", + rowIndx: rowIndx + }) + } + evt.stopPropagation(); + evt.preventDefault(); + return false + } + } + } +})(jQuery); +(function($) { + var cExcel = function(that, $ae) { + this.that = that; + this.$ae = $ae + }; + var _pExcel = cExcel.prototype; + _pExcel.createClipBoard = function() { + var $ae = this.$ae, + $text = $("textarea#pq-grid-excel"); + if ($text.length == 0) { + $text = $(""}else{if(H=="select"){var x=i.options;var x=x?x:[];if(typeof x==="function"){x=x.call(C.element,{column:L,rowData:N})}var o=[t," class='",k,"' ",O," name='",D,"'"].join("");I=h.paramquery.select({options:x,attr:o,labelIndx:i.labelIndx,valueIndx:i.valueIndx,groupIndx:i.groupIndx})}else{I=""}}E.html(I);E.children().val(T)}else{I="
";E.html(I);E.children().html(T);F=true}}}var C=this;if(C.$td_edit!=null){var E=C.$div_focus,v=E.children(".pq-editor-focus");v.focus();v.bind("keydown",function(U){C.iKeyNav._bodyKeyPressDownInEdit(U)});if(C._trigger("cellEditFocus",null,{$cell:E,$editor:v,dataIndx:D,column:L,rowIndx:u,rowData:N})==false){return false}if(w){if(F){try{var R=v[0];var n=document.createRange();n.selectNodeContents(R);var A=window.getSelection();A.removeAllRanges();A.addRange(n)}catch(J){}}else{v.select()}}}if(C.$td_edit_old){C.quitEditMode({old:true})}};g.getRow=function(n){var j=n.rowIndxPage,m=n.rowIndx,o=this.rowIndxOffset,k=this.options.dataModel;var l,p=this.$tbl;if(p!=undefined){var i=p.children("tbody");if(j!=null){l=i.children("tr[pq-row-indx="+j+"]")}else{if(m!=null){l=i.children("tr[pq-row-indx="+(m-o)+"]")}}}return l};g.getCell=function(n){var j=n.rowIndxPage,m=n.rowIndx,j=(j==null)?(m-this.rowIndxOffset):j,l=n.colIndx,o=n.dataIndx,l=(l==null)?this.getColIndx({dataIndx:o}):l,i=this.$tbl,k,q=this.options,p=q.freezeCols;if(i!=undefined){if(i.length>1){if(l>=p){i=h(i[1])}else{i=h(i[0])}}var k=i.children().children("tr[pq-row-indx="+j+"]").children("td[pq-col-indx="+l+"]")}if(k.length==0||k[0].style.visibility=="hidden"){return null}return k};g.getCellHeader=function(m){var l=m.colIndx,j=m.dataIndx,l=(l==null)?this.getColIndx({dataIndx:j}):l,o=this.$tbl_header,n,i=this.options,k=i.freezeCols;if(o!=undefined){if(o.length>1){if(l>=k){o=h(o[1])}else{o=h(o[0])}}var n=o.children().children("tr:last").children("td[pq-col-indx="+l+"]")}if(n.length==0||n[0].style.visibility=="hidden"){return null}return n};g.getEditCellData=function(){if(this.$td_edit){var i=this.getCellIndices({$td:this.$td_edit});return this._getEditCellData(i)}else{return null}};g._getEditCellData=function(q){if(q.colIndx==undefined||q.rowIndxPage==undefined){throw ("colIndx, rowIndxpage N/A")}var j=q.colIndx,i=q.rowIndxPage,o=(q.rowIndx!=null)?q.rowIndx:i+this.rowIndxOffset,m=(q.column)?q.column:this.colModel[j],k=m.editor,l=this.options.editor,r=k?h.extend({},l,k):l,t=m.dataIndx,u=(q.$cell)?q.$cell:this.$div_focus,v;var p=r.getData;if(typeof p=="function"){v=r.getData.call(this.element,{$cell:u,dataIndx:t,rowIndx:o,rowIndxPage:i,column:m})}else{var w=r.type;if(w=="checkbox"){var s=u.children();if(r.subtype=="triple"){v=s.pqval()}else{v=s.is(":checked")?true:false}}else{if(w=="contenteditable"){v=u.children().html()}else{var n=u.find('*[name="'+t+'"]');if(n&&n.length){v=n.val()}else{var n=u.find(".pq-editor-focus");if(n&&n.length){v=n.val()}}}}}return v};g.getCellIndices=function(j){var m=j.$td;if(m==null||m.length==0||m.closest(".pq-grid")[0]!=this.element[0]){return{rowIndxPage:null,colIndx:null}}var k=m.parent("tr");var i=k.attr("pq-row-indx");if(i==null){return{rowIndxPage:null,colIndx:null}}i=parseInt(i);var l=m.attr("pq-col-indx");if(l==null){return{rowIndxPage:i,colIndx:null}}l=parseInt(l);return{rowIndxPage:i,rowIndx:i+this.rowIndxOffset,colIndx:l,dataIndx:this.colModel[l].dataIndx}};g.getRowsByClass=function(n){var u=this.options,v=u.dataModel,r=u.pageModel,j=r.type,p=(j=="remote")?true:false,l=this.rowIndxOffset,o=v.data,t=[];if(o==null){return t}for(var m=0,q=o.length;m1){return r.join(" ")}else{if(r.length===1){return r[0]}else{return null}}}};g.getRowIndx=function(r){var t=r.$tr,m=r.rowData;if(m){var w=this.options,x=w.dataModel,v=w.pageModel,k=v.type,s=(k=="remote")?true:false,q=x.data,l=false;if(q){for(var p=0,u=q.length;p=0;n--){var p=q[n].pq_hidden;if(!p){k++;l=n;if(k==m){return l}}}return l};g.addColumn=function(m,n){var l=this.options,j=l.colModel,p=l.dataModel.data;j.push(m);this._calcThisColModel();for(var k=0;k=o){if(i==m){return null}i=this._incrRowIndx(i);n=0}k=j[n]}while(k&&k.hidden);return{rowIndxPage:i,colIndx:n}};e._decrIndx=function(i,n){var m=this.that,j=m.colModel,o=j.length,k=m._getFirstVisibleRowIndxPage(m.data);if(n==null){if(i==k){return null}i=this._decrRowIndx(i);return{rowIndxPage:i}}var l;do{n--;if(n<0){if(i==k){return null}i=this._decrRowIndx(i);n=o-1}l=j[n]}while(l&&l.hidden);return{rowIndxPage:i,colIndx:n}};e._incrEditIndx=function(i,l){var r=this.that,n=r.colModel,j=n.length,m,p=r.rowIndxOffset,q=r._getLastVisibleRowIndxPage(r.data);do{l++;if(l>=j){if(i==q){return null}do{i=this._incrRowIndx(i);var o=i+p,s=r.isEditableRow({rowIndx:o});if(i==q&&s==false){return null}}while(s==false);l=0}m=n[l];var o=i+p,k=r.isEditableCell({rowIndx:o,colIndx:l,checkVisible:true})}while(m&&(m.hidden||k==false));return{rowIndxPage:i,colIndx:l}};e._decrEditIndx=function(i,l){var q=this.that,n=q.colModel,j=n.length,m,p=q.rowIndxOffset,s=q._getFirstVisibleRowIndxPage(q.data);do{l--;if(l<0){if(i==s){return null}do{i=this._decrRowIndx(i);var o=i+p,r=q.isEditableRow({rowIndx:o});if(i==s&&r==false){return null}}while(r==false);l=j-1}m=n[l];var o=i+p,k=q.isEditableCell({rowIndx:o,colIndx:l,checkVisible:true})}while(m&&(m.hidden||k==false));return{rowIndxPage:i,colIndx:l}};e._incrEditRowIndx=function(i,k){var o=this.that,l=o.rowIndxOffset,n=o._getLastVisibleRowIndxPage(o.data);if(i==n){return null}do{i=this._incrRowIndx(i);var m=i+l,p=o.isEditableRow({rowIndx:m}),j=o.isEditableCell({rowIndx:m,colIndx:k}),q=(p&&j);if(i==n&&!q){return null}}while(!q);return{rowIndxPage:i,colIndx:k}};e._decrEditRowIndx=function(i,k){var n=this.that,l=n.rowIndxOffset,p=n._getFirstVisibleRowIndxPage(n.data);if(i==p){return null}do{i=this._decrRowIndx(i);var m=i+l,o=n.isEditableRow({rowIndx:m}),j=n.isEditableCell({rowIndx:m,colIndx:k}),q=(o&&j);if(i==p&&!q){return null}}while(!q);return{rowIndxPage:i,colIndx:k}};g._onKeyPressDown=function(i){var j=h(i.target).closest(".pq-grid-header");if(j.length>0){if(this._trigger("headerKeyDown",i,{dataModel:this.options.dataModel})==false){return false}else{return true}}else{var k=this.iKeyNav._bodyKeyPressDown(i);if(k===false){return false}if(this._trigger("keyDown",i,{dataModel:this.options.dataModel})==false){return false}}};e._saveAndMove=function(p,k){var n=this.that,l=this.options,j=l.selectionModel;if(n.saveEditCell({evt:k})==false){k.preventDefault();return false}if(p==null){k.preventDefault();return false}var i=p.rowIndxPage,o=p.colIndx;if(j.type=="row"){n.setSelection(null);n.setSelection({rowIndxPage:i});n._bringCellToView({rowIndxPage:i,colIndx:o})}else{if(j.type=="cell"){n.setSelection(null);n.setSelection({rowIndxPage:i,colIndx:o})}else{n.scrollRow({rowIndxPage:i});n._bringCellToView({rowIndxPage:i,colIndx:o})}}var m=n.getCell({rowIndxPage:i,colIndx:o});if(m&&m.length>0){n._editCell(m)}k.preventDefault();return false};e._bodyKeyPressDownInEdit=function(w){var s=this.that;if(!s.$td_edit){return}var v=this.options,q=s.rowIndxOffset,t=h.ui.keyCode,o=s.colModel,i=v.editModel,k=h(s.$td_edit[0]),r=s.getCellIndices({$td:k}),j=r.rowIndxPage,p=j+q,m=r.colIndx,n=o[m],l=n.editModel,u=l?h.extend({},i,l):i;if(s._trigger("cellEditKeyDown",w,{rowData:s.data[j],$cell:s.$div_focus,rowIndx:p,rowIndxPage:j,colIndx:m,$td:k,dataIndx:n.dataIndx,column:n})==false){return false}if(w.keyCode==t.TAB){var r;if(w.shiftKey){r=this._decrEditIndx(j,m)}else{r=this._incrEditIndx(j,m)}return this._saveAndMove(r,w)}else{if(w.keyCode==u.saveKey){var r=this._incrEditIndx(j,m);return this._saveAndMove(r,w)}else{if(w.keyCode==t.ESCAPE){s.quitEditMode({evt:w});w.preventDefault();return false}else{if(w.keyCode==t.PAGE_UP||w.keyCode==t.PAGE_DOWN){w.preventDefault();return false}else{if(u.keyUpDown){if(w.keyCode==t.DOWN){var r=this._incrEditRowIndx(j,m);return this._saveAndMove(r,w)}else{if(w.keyCode==t.UP){var r=this._decrEditRowIndx(j,m);return this._saveAndMove(r,w)}}}}}}}return};e.filterKeys=function(s,o){var m=this.that,l=this.options.editModel.filterKeys;var k=o.column,q=k.dataType,j=k.editModel;if(j&&j.filterKeys!=undefined){l=j.filterKeys}if(!l){return}if(q=="float"||q=="integer"){var n=h(s.originalEvent.target),p=n[0].nodeName.toLowerCase(),u=(q=="integer")?/^[\-]?[0-9]*$/:/^[\-]?[0-9]*\.?[0-9]*$/;var t=["input","textarea","select"],i="text";if(h.inArray(p,t)!=-1){i="val"}var r=n[i]();window.setTimeout(function(){var v=n[i]();if(u.test(v)==false){n[i](r)}},0)}};e.select=function(j){var m=this.that,l=j.rowIndx,n=j.colIndx,i=m.options.selectionModel,k=j.evt;if(k.shiftKey&&i.mode!="single"){if(i.type=="row"){m.scrollRow({rowIndx:l});m.iRows.extendSelection({rowIndx:l,evt:k})}else{if(i.type=="cell"){m.scrollCell({rowIndx:l,colIndx:n});m.iCells.extendSelection({rowIndx:l,colIndx:n,evt:k})}}}else{m.setSelection({rowIndx:l,colIndx:n,evt:k,setFirst:true})}};e.createTextbox=function(){var i=h("textarea#pq-grid-excel");if(i.length==0){i=h(""].join("")};$.paramquery.select=function(objP){var attr=objP.attr,opts=objP.options,groupIndx=objP.groupIndx,labelIndx=objP.labelIndx,valueIndx=objP.valueIndx,prepend=objP.prepend,groupV,groupVLast;var buffer=["");return buffer.join("")};$.fn.pqval=function(obj){if(obj){if(obj.incr){var val=this.data("pq_value");this.prop("indeterminate",false);if(val){val=false;this.removeAttr("checked")}else{if(val===false){val=null;this.prop("indeterminate",true);this.removeAttr("checked")}else{val=true;this.attr("checked","checked")}}this.data("pq_value",val);return val}else{var val=obj.val;this.data("pq_value",val);this.prop("indeterminate",false);if(val==null){this.prop("indeterminate",true);this.removeAttr("checked")}else{if(val){this.attr("checked","checked")}else{this.removeAttr("checked")}}return this}}else{return this.data("pq_value")}};var _pGenerateView={};_pGenerateView._generateTitleRow=function(GM,rowObj,buffer,lastFrozenRow){var that=this.that,thisOptions=that.options,numberCell=thisOptions.numberCell,groupTitle=rowObj.groupTitle,GMTitle=GM.title,groupLevel=rowObj.level,GMRowIndx=rowObj.GMRowIndx,GMIcon=GM.icon,GMIcon=GMIcon?GMIcon[groupLevel]:null,GMIcon=(GMIcon&&GMIcon.length&&GMIcon.length==2&&typeof GMIcon.push==="function")?GMIcon:["ui-icon-minus","ui-icon-plus"];if(GMTitle&&GMTitle[groupLevel]!=null){if(GMTitle[groupLevel]===false){return}groupTitle=GMTitle[groupLevel].replace("{0}",groupTitle);groupTitle=groupTitle.replace("{1}",rowObj.items)}else{groupTitle=groupTitle+" - "+rowObj.items+" item(s)"}buffer.push([""].join(""));if(numberCell.show){buffer.push("
")}var icon=GMIcon[0];if(rowObj.collapsed){icon=GMIcon[1]}buffer.push("","
","",groupTitle,"
");buffer.push("")};_pGenerateView._generateSummaryRow=function(rowData,thisColModel,buffer,lastFrozenRow){var row_cls="pq-summary-row pq-grid-row"+(lastFrozenRow?" pq-last-freeze-row":""),that=this.that,thisOptions=that.options,virtualX=thisOptions.virtualX,initH=that.initH,finalH=that.finalH,freezeCols=thisOptions.freezeCols,numberCell=thisOptions.numberCell,columnBorders=thisOptions.columnBorders,wrap=thisOptions.wrap,offset=this.offset;var const_cls="pq-grid-cell ";var row_str="";buffer.push(row_str);if(numberCell.show){buffer.push(["","
 
"].join(""))}for(var col=0;col<=finalH;col++){if(col=freezeCols&&virtualX){col=initH;if(col>finalH){throw ("initH>finalH")}}var column=thisColModel[col],dataIndx=column.dataIndx;if(column.hidden){continue}var strStyle="";var cls=const_cls;if(column.align=="right"){cls+=" pq-align-right"}else{if(column.align=="center"){cls+=" pq-align-center"}}if(col==freezeCols-1&&columnBorders){cls+=" pq-last-freeze-col"}if(column.cls){cls=cls+" "+column.cls}var valCell=(rowData[dataIndx]==null)?" ":rowData[dataIndx];var str=["","
",valCell,"
"].join("");buffer.push(str)}buffer.push("");return buffer};_pGenerateView._generateDetailRow=function(rowData,rowIndx,thisColModel,buffer,objP,lastFrozenRow){var row_cls="pq-grid-row pq-detail-child";if(lastFrozenRow){row_cls+=" pq-last-freeze-row"}var that=this.that,thisOptions=that.options,numberCell=thisOptions.numberCell,CMLength=thisColModel.length,offset=this.offset;var const_cls="pq-grid-cell ";if(!thisOptions.wrap||objP){const_cls+="pq-wrap-text "}if(thisOptions.stripeRows&&(rowIndx/2==parseInt(rowIndx/2))){row_cls+=" pq-grid-oddRow"}if(rowData.pq_rowselect){row_cls+=" pq-row-select ui-state-highlight"}var pq_rowcls=rowData.pq_rowcls;if(pq_rowcls!=null){row_cls+=" "+pq_rowcls}buffer.push("");if(numberCell.show){buffer.push(["","
 
"].join(""))}buffer.push("");buffer.push("");return buffer};var cGroupView=function(that){this.that=that};var _pGroupView=cGroupView.prototype;_pGroupView._refreshDataFromDataModel=function(){this._groupData();this.initcollapsed()};_pGroupView.bindEvents=function(){var self=this;this.that.$cont.on("click","tr.pq-group-row",function(evt){return self.onClickGroupRow(evt)})};_pGroupView.showHideRows=function(initIndx,level,hide){var arr=[],that=this.that,data=that.dataGM;for(var i=initIndx,len=data.length;i0){var dataGM=[],titleIndx=[],groupVal=[],prevGroupVal=[],cols=[];for(var u=0;u0){for(var u=GMLength-1;u>=changeGroupIndx;u--){if(groupSummaryShow[u]){var groupRowData=[];for(var f=0;f=changeGroupIndx;z--){for(var e=0;e").appendTo(that.element);this.$arrowBottom=$("
").appendTo(that.element);this.hideArrows();if(dragColumns&&dragColumns.enabled){that.$header.on("touchstart mousedown","td.pq-grid-col",function(evt,ui){if($.support.touch){if(evt.type=="touchstart"){var touch=evt.originalEvent.touches[0];if(touch.pq_composed){return}evt.preventDefault();self.setDraggables(evt,ui);var evt2=document.createEvent("UIEvent");evt2.initUIEvent("touchstart",true,true);evt2.view=window;evt2.altKey=false;evt2.ctrlKey=false;evt2.shiftKey=false;evt2.metaKey=false;evt2.touches=[{pageX:evt.pageX,pageY:evt.pageY,pq_composed:true}];evt2.changedTouches=[{pageX:evt.pageX,pageY:evt.pageY,pq_composed:true}];evt.target.dispatchEvent(evt2)}}else{if(!evt.pq_composed){self.setDraggables(evt,ui);evt.pq_composed=true;var e=$.Event("mousedown",evt);$(evt.target).trigger(e)}}})}};var _pDragColumns=cDragColumns.prototype;_pDragColumns.showFeedback=function($td,leftDrop){var that=this.that;var td=$td[0];var offParent=td.offsetParent.offsetParent;var left=td.offsetLeft+offParent.offsetLeft+((!leftDrop)?td.offsetWidth:0)-8;var top=that.$grid_inner[0].offsetTop+td.offsetTop-16;var top2=that.$grid_inner[0].offsetTop+that.$header[0].offsetHeight;this.$arrowTop.css({left:left,top:top,display:""});this.$arrowBottom.css({left:left,top:top2,display:""})};_pDragColumns.showArrows=function(){this.$arrowTop.show();this.$arrowBottom.show()};_pDragColumns.hideArrows=function(){this.$arrowTop.hide();this.$arrowBottom.hide()};_pDragColumns.updateDragHelper=function(accept){var that=this.that,dragColumns=that.options.dragColumns,acceptIcon=dragColumns.acceptIcon,rejectIcon=dragColumns.rejectIcon,$drag_helper=this.$drag_helper;if(!$drag_helper){return}if(accept){$drag_helper.children("span.pq-drag-icon").addClass(acceptIcon).removeClass(rejectIcon);$drag_helper.removeClass("ui-state-error")}else{$drag_helper.children("span.pq-drag-icon").removeClass(acceptIcon).addClass(rejectIcon);$drag_helper.addClass("ui-state-error")}};_pDragColumns.setDraggables=function(evt,ui){var $td=$(evt.currentTarget),that=this.that,dragColumns=that.options.dragColumns,rejectIcon=dragColumns.rejectIcon,self=this;if($td.hasClass("ui-draggable")){return}if(!that.getHeaderColumnFromTD($td)){return}$td.draggable({distance:10,cursorAt:{top:-18,left:-10},helper:function(){var $this=$(this);self.status="helper";self._setupDroppables($this);that.$header.find(".pq-grid-col-resize-handle").hide();var colIndx=$this.attr("pq-col-indx");var rowIndx=$this.attr("pq-row-indx");$this.droppable("destroy");var column=that.headerCells[rowIndx][colIndx];var $drag_helper=$("
"+column.title+"
");self.$drag_helper=$drag_helper;return $drag_helper[0]},zIndex:"1000",appendTo:that.element,revert:"invalid",drag:function(evt,ui){self.status="drag";var $td=$("td.pq-drop-hover",that.$header);if($td.length>0){self.showArrows();self.updateDragHelper(true);var wd=$td.width();var lft=evt.clientX-$td.offset().left+$(document).scrollLeft();if(lft"+column.title+"
").appendTo(that.$toolbar).button({icons:{primary:"ui-icon-triangle-1-n",secondary:"ui-icon-close"}}).mouseover(function(evt){var $target=$(evt.target);if($target.is("span.ui-icon-close")){$target.css("outline","1px solid black")}}).mouseout(function(evt){var $target=$(evt.target);if($target.is("span.ui-icon-close")){$target.css("outline","")}}).click(function(evt){var $button=$(this);if($(evt.target).is("span.ui-icon-close")){window.setTimeout(function(){$button.button("destroy");$button.remove();self.refreshSorting()},0)}else{var sorter=eval("("+$button.attr("sorter")+")");if(sorter.dir=="up"){sorter.dir="down";$button.button({icons:{primary:"ui-icon-triangle-1-s",secondary:"ui-icon-close"}})}else{sorter.dir="up";$button.button({icons:{primary:"ui-icon-triangle-1-n",secondary:"ui-icon-close"}})}var sorterStr="{dataIndx:"+sorter.dataIndx+",dataType:'"+sorter.dataType+"',dir:'"+sorter.dir+"'}";$button.attr("sorter",sorterStr);self.refreshSorting()}});self.refreshSorting();window.setTimeout(function(){that.$toolbar.droppable("destroy")},0)}})};fn.options={detailModel:{cache:true,offset:100,expandIcon:"ui-icon-triangle-1-se",collapseIcon:"ui-icon-triangle-1-e"},dragColumns:{enabled:true,acceptIcon:"ui-icon-check",rejectIcon:"ui-icon-closethick",topIcon:"ui-icon-circle-arrow-s",bottomIcon:"ui-icon-circle-arrow-n"},track:false,treeModel:{collapsed:true,indent:15,leafIcon:"ui-icon-radio-off",expandIcon:"ui-icon-triangle-1-se",collapseIcon:"ui-icon-triangle-1-e"},virtualX:true,filterModel:{on:true,mode:"AND",header:false}};fn._create=function(){$.extend($.paramquery.cGenerateView.prototype,_pGenerateView);var that=this,thisOptions=this.options;this.iGroupView=new cGroupView(this);this.iHeaderSearch=new cHeaderSearch(this);this.iUCData=new $.paramquery.cUCData(this);this.pqSheet={};new cMouseSelection(this);this._super.apply(this);this.iGroupView.bindEvents();this.pqSheet={};this.iDragColumns=new cDragColumns(this);this._createToolbar();this.refreshHeader();this.refreshDataAndView({header:false});this.refresh();var widgetEventPrefix=that.widgetEventPrefix.toLowerCase();that.element.one(widgetEventPrefix+"load",function(evt,ui){that._refresh({header:false})})};fn._createToolbar=function(){var that=this,options=this.options,toolbar=options.toolbar;if(toolbar){var tb=toolbar,cls=tb.cls,cls=cls?cls:"",style=tb.style,style=style?style:"",attr=tb.attr,attr=attr?attr:"",items=tb.items;var $toolbar=$("
").appendTo($(".pq-grid-top",this.element));$toolbar.pqToolbar({items:items,gridInstance:this});if(!options.showToolbar){$toolbar.css("display","none")}this.$toolbar=$toolbar}};fn.isLeftOrRight=function(colIndx){var thisOptions=this.options,freezeCols=this.freezeCols;if(colIndx>freezeCols){return"right"}else{return"left"}};fn.ovCreateHeader=function(buffer,const_cls){if(this.options.filterModel.header){this.iHeaderSearch.createDOM(buffer,const_cls)}};fn._createHeader=function(){this._super.apply(this);if(this.options.showHeader){this._trigger("createHeader")}};fn.exportExcel=function(obj){obj.format="xml";return $.paramquery.pqgrid.exportToExcel.call(this,obj)};fn.exportCsv=function(obj){obj.format="csv";return $.paramquery.pqgrid.exportToExcel.call(this,obj)};fn.filter=function(objP){var that=this,thisOptions=this.options,apply=(objP.apply===undefined)?true:objP.apply,sort=(objP.sort===undefined)?true:objP.sort,DM=thisOptions.dataModel,FM=thisOptions.filterModel;if(objP!=undefined){var replace=(objP.oper=="replace")?true:false,rules=objP.data,CM=this.colModel,CM=(!apply)?$.extend(true,[],CM):CM,foundCount=0,CMLength=CM.length,rulesLength=rules.length;for(var i=0;ival2){ret=1}else{if(val1val2){ret=1}else{if(val11){return}event.preventDefault();var touch=event.originalEvent.changedTouches[0],simulatedEvent=document.createEvent("MouseEvents");simulatedEvent.initMouseEvent(simulatedType,true,true,window,1,touch.screenX,touch.screenY,touch.clientX,touch.clientY,false,false,false,false,0,null);event.target.dispatchEvent(simulatedEvent)};fn._getTblSingle=function(rowIndxPage,colIndx){var $tbl=this.$tbl,colIndx=(colIndx!=null)?colIndx:0,thisOptions=this.options,freezeCols=thisOptions.freezeCols,freezeRows=thisOptions.freezeRows;if($tbl!=undefined){if($tbl.length==4){if(rowIndxPage>=freezeRows&&colIndx>=freezeCols){$tbl=$($tbl[3])}else{if(rowIndxPage>=freezeRows&&colIndx=freezeCols){$tbl=$($tbl[1])}else{$tbl=$($tbl[0])}}}}else{if($tbl.length==2){if(rowIndxPage>=freezeRows&&colIndx>=freezeCols){$tbl=$($tbl[1])}else{$tbl=$($tbl[0])}}else{$tbl=$($tbl[0])}}}return $tbl};fn.getLargestRowCol=function(arr){var rowIndx,colIndx;for(var i=0;irowIndx){rowIndx=rowIndx2}}rowIndx=sel.rowIndx}};fn._onLoad=function(){this.options.dataModel.postData=""};fn._onRefreshSheet=function(){var data=this.$dragSeries.data();if(data){var rowIndx=data.rowIndx,colIndx=data.colIndx,left=data.left,top=data.top;this.bb(rowIndx,colIndx)}};fn.bringCellToView=function(obj){this._bringCellToView(obj)};fn._setUrl=function(queryStr){this.options.dataModel.getUrl=function(){return{url:this.url+((queryStr!=null)?queryStr:"")}}};fn.getDataPage=function(){return this.data};fn.getData=function(objP){var dataIndices=objP.dataIndx,dILen=dataIndices.length,data=objP.data,DM=this.options.dataModel,DMData=DM.data,DMDataUF=DM.dataUF,arr=[],pr=function(data){for(var i=0,len=data.length;i0){return true}},begin:function(cd,value){if(cd.indexOf(value)==0){return true}},notbegin:function(cd,value){if(cd.indexOf(value)!=0){return true}},end:function(cd,value){var lastIndx=cd.lastIndexOf(value);if(lastIndx!=-1&&(lastIndx+value.length==cd.length)){return true}},notend:function(cd,value){var lastIndx=cd.lastIndexOf(value);if(lastIndx!=-1&&(lastIndx+value.length==cd.length)){}else{return true}},regexp:function(cd,value){if(value.test(cd)){value.lastIndex=0;return true}},notequal:function(cd,value){if(cd!=value){return true}},great:function(cd,value){if(cd>value){return true}},gte:function(cd,value){if(cd>=value){return true}},between:function(cd,value,value2){if(cd>=value&&cd<=value2){return true}},range:function(cd,value){if($.inArray(cd,value)!=-1){return true}},less:function(cd,value){if(cd')}}u.push("");for(var s=0;s'+o.title+"")}}u.push("");u=u.join("\n");for(var s=0;s");for(var r=0;r")}}p.push("")}p=p.join("\n");var k=['','','','',"",u,p,"
","
","
"];return k.join("\n")},i=function(){var q=g.colModel,l=q.length,y=g.options,z=y.dataModel,t=z.data,m=t.length,k=[],u=[],p=[];for(var s=0;s0)?"&":"?")+"filename="+k);a(document.body).append("")}})}})(jQuery);(function(b){var d=b.paramquery.cUCData=function(e){this.that=e;this.udata=[];this.ddata=[];this.adata=[]};var c=d.prototype;c.add=function(l){var h=this.that,g=this.adata,j=l.rowData,k=h.getRecId({rowData:j});for(var f=0,e=g.length;f=0;g--){var m=f[g],j=m.indx,k=m.rowData;l.splice(j,0,k);if(e=="remote"){h.totalRecords++}}this.ddata=[]};c.rollbackUpdate=function(o,h){var l=this.that,e=this.udata;for(var j=0,m=e.length;j0){var i=f[0].rowIndx,l=j.rowIndxOffset,h=j.options.pageModel,g=h.type,e=i-l,k=h.rPP;if(g){if(e>=0&&e").prependTo(b(".ui-dialog-buttonpane",h));this.prev=b("").appendTo(e).button({icons:{primary:"ui-icon-circle-triangle-w"},text:false}).bind("click",function(j){var i=g.rowPrevSelect();f._fillForm({rowIndxPage:i})});this.prev.removeClass("ui-corner-all");this.next=b("").appendTo(e).button({icons:{primary:"ui-icon-circle-triangle-e"},text:false}).bind("click",function(j){var i=g.rowNextSelect();f._fillForm({rowIndxPage:i})});this.next.removeClass("ui-corner-all")};a.getFormData=function(m){var k=this,l={},e=k.colModel;for(var g=0;g").appendTo(d)}else{if(h=="checkbox"){s=b("").appendTo(d)}else{if(h=="separator"){b("").appendTo(d)}else{if(h=="button"){s=b("").button({text:o?true:false,icons:{primary:B}}).appendTo(d)}else{if(h=="select"){var g=C.options?C.options:[];if(typeof g==="function"){g=g.call(n.element,{colModel:f})}e=b.paramquery.select({options:g,attr:" class='"+c+"' "+v+" "+z,prepend:C.prepend,groupIndx:C.groupIndx,valueIndx:C.valueIndx,labelIndx:C.labelIndx});s=b(e).appendTo(d)}else{if(typeof h=="string"){s=b(h).appendTo(d)}else{if(typeof h=="function"){var e=h.call(n,{colModel:f,cls:c});s=b(e).appendTo(d)}}}}}}}if(t){for(var x=0;x").css("opacity",0.2).appendTo(this.element)}};a._enable=function(){if(this.$disable){this.element[0].removeChild(this.$disable[0]);this.$disable=null}};a._setOption=function(c,d){if(c=="disabled"){if(d==true){this._disable()}else{this._enable()}}};b.widget("paramquery.pqToolbar",a)})(jQuery);(function(f){var g=function(){this.focusSelection=null};var d=g.prototype;d.getOldRowSel=function(){var j=this.that,i;if((i=this.focusSelection)&&this.isSelected(i)){var h=j.getRowIndx(i);h.rowData=i.rowData;return h}};d.getOldCellSel=function(){var j=this.that,i;if((i=this.focusSelection)&&this.isSelected(i)){var k=i.rowData;var h=j.getRowIndx({rowData:k});h.rowData=k;h.dataIndx=i.dataIndx;return h}};d.getNewRowSel=function(){var k=this.that,j=document.activeElement?f(document.activeElement):null;if(j&&j.hasClass("pq-grid-row")){var i=j.closest(".pq-grid");if(i[0]==k.element[0]){var h=k.getRowIndx({$tr:j});h.$tr=j;return h}}};d.getNewCellSel=function(){var k=this.that,j=document.activeElement?f(document.activeElement):null;if(j&&j.hasClass("pq-grid-cell")){var i=j.closest(".pq-grid");if(i[0]==k.element[0]){var h=k.getCellIndices({$td:j});h.$td=j;return h}}};d.getFocusSelection=function(h){if(this instanceof c){if(h&&h.old===true){return this.getOldRowSel()}else{return this.getNewRowSel()}}else{if(this instanceof a){if(h&&h.old===true){return this.getOldCellSel()}else{return this.getNewCellSel()}}}};d.getFirstSelection=function(){var h=this.firstSelection;if(h&&this.isSelected(h)){return h}else{this.refresh();var i=this.selection;if(i.length){this.firstSelection=i[0];return i[0]}}};d.getLastSelection=function(){var h=this.lastSelection;if(h){var j=this.that,k=h.rowData,i=j.getRowData({rowIndx:rowIndx});if(k==i&&this.isSelected(h)){return h}else{return false}}else{return null}};d.getLastSelectionCurPage=function(){var h=this.lastSelection;if(h&&this.isSelected(h)){var k=h.rowIndx,i=this.that.options.pageModel;if(i.type){var j=i.curPage,l=i.rPP;if(Math.ceil((k+1)/l)==j){return h}else{return null}}else{return h}}else{return null}};d.getSelection=function(){this.refresh();return this.selection};d.getSelectionCurPage=function(){var m=this.that,o=this.getSelection(),q=[],r=m.options,s=r.dataModel,p=r.pageModel;if(p.type){var n=s.curPage,l=s.rPP;for(var k=0;ki){j=i;m=h}this.selectRange({initRowIndx:j,finalRowIndx:m,evt:o});this.add({rowIndx:i})}};b.refresh=function(){this.selection=[];var q=this.that,s=q.options,t=s.dataModel,r=s.pageModel,j=r.type,h=(j=="remote")?true:false,m=q.rowIndxOffset,o=t.data;if(!o){return}for(var n=0,p=o.length;nn){this.remove({rowIndx:r})}}if(k>n){var q=k;k=n;n=q}for(var r=k;r<=n;r++){this.add({rowIndx:r,focus:false})}};e._addToData=function(h){var i=h.dataIndx,j=this.that.getRowData(h);if(!j.pq_cellselect){j.pq_cellselect={}}j.pq_cellselect[i]=true};e.extendSelection=function(t){var q=this.that,h=this.getFirstSelection(),m=t.rowIndx,j=t.colIndx,p=q.options.selectionModel.mode,s=t.evt;if(h==null){q.setSelection({rowIndx:m,colIndx:j});return}var i=h.rowIndx,l=q.getColIndx({dataIndx:h.dataIndx}),n=i,r=m,k=l,o=j;if(i>m){n=m;r=i}if(p=="range"){if(i>m){k=j;o=l}if(m==i&&jj){k=j;o=l}this.selectBlock({initRowIndx:n,initColIndx:k,finalRowIndx:r,finalColIndx:o,evt:s});this.add({rowIndx:m,colIndx:j})}}};e._removeFromData=function(h){var i=h.rowData;if(i&&i.pq_cellselect){delete i.pq_cellselect[h.dataIndx]}};e.removeAll=function(){this.refresh();var h=this.selection.slice(0);this.remove({cells:h});this.lastSelection=null};b.removeAll=function(u){var p=this.that,q=u?u.page:false;this.refresh();var t=this.selection.slice(0);if(q){var r=[],m=p.rowIndxOffset,j=p.data,k=j?j.length:0;for(var n=0,o=t.length;n=0){if(h=j.init&&h<=j["final"])&&(m=j.initH&&m<=j.finalH))};e._add=function(u){var p=this.that,o=u.rowIndx,h=u.rowIndxPage,m=u.rowData,n=p.rowIndxOffset,t,o=(o==null)?(h+n):o,h=(h==null)?(o-n):h,m=(m==null)?p.getRowData(u):m,k=u.colIndx,q=u.dataIndx,k=(k==null)?p.getColIndx({dataIndx:q}):k,l=p.colModel[k],q=(q==null)?l.dataIndx:q,s=u.evt,j=this.isSelected({rowData:m,dataIndx:q});if(j==null){return false}var r=this.inView(h,k);if(j===false){if(r){var i=p.getCell({rowIndxPage:h,colIndx:k});if(i){i.addClass("pq-cell-select ui-state-highlight")}}this._addToData({rowData:m,dataIndx:q});if(u.trigger!==false){p._trigger("cellSelect",s,{rowIndx:o,rowIndxPage:h,colIndx:k,dataIndx:q,column:l,rowData:m})}t=true}this.lastSelection={rowIndx:o,dataIndx:q,rowData:m};if(u.focus!==false&&r){if(!i||!i.length){i=p.getCell({rowIndxPage:h,dataIndx:q})}if(i&&i.length){i.attr("tabindex","0");i.focus();p._fixTableViewPort();this.focusSelection={rowData:m,rowIndx:o,dataIndx:q}}}if(u.setFirst){this.firstSelection={rowIndx:o,rowData:m,dataIndx:q}}if(t){return{rowIndx:o,rowData:m,dataIndx:q,colIndx:k,column:l}}};b.inView=function(h){var j=this.that,i=this.options,k=i.freezeRows;return((h=j.init&&h<=j["final"]))};b._add=function(s){var n=this.that,r,l=s.rowIndx,h=s.rowIndxPage,k=n.rowIndxOffset,l=(l==null)?(h+k):l,h=(h==null)?(l-k):h,j=(j==null)?n.getRowData(s):j,m=s.$tr,q=s.evt,i=this.isSelected({rowData:j});s.rowIndxPage=h;if(i==null){return false}var p=this.inView(h);if(i===false){if(p){var o=this._boundRow(s),m=o}j.pq_rowselect=true;if(s.trigger!==false){n._trigger("rowSelect",q,{rowIndx:l,rowIndxPage:h,rowData:j,$tr:m})}r=true}this.lastSelection={rowIndx:l,rowData:j};if(s.focus!==false&&p){if(!m||!m.length){m=n.getRow({rowIndxPage:h})}if(m){m=f(m[0]);m.attr("tabindex","0");m.focus();n._fixTableViewPort();this.focusSelection={rowData:j,rowIndx:l}}}if(s.setFirst){this.firstSelection={rowIndx:l,rowData:j}}if(r){return{rowIndx:l,rowData:j}}};e.add=function(q){var j=this.that,n=q.evt,p=q.cells,m=[];if(p&&typeof p.push=="function"){for(var h=0,k=p.length;ht){this.remove({rowIndx:u,colIndx:h,dataIndx:s})}else{if(u==p&&hq){this.remove({rowIndx:u,colIndx:h,dataIndx:s})}}}}for(var h=0;hq){break}else{this.add({rowIndx:u,colIndx:h,dataIndx:s,focus:false})}}u++}while(u<=t)}};e.selectBlock=function(x){var t=this.that,r=x.initRowIndx,m=x.initColIndx,v=x.finalRowIndx,s=x.finalColIndx,j=this.getSelection(),l=j.slice(0);for(var q=0;qs){this.remove({rowIndx:w,dataIndx:u,colIndx:h})}else{if(wv){this.remove({rowIndx:w,dataIndx:u,colIndx:h})}}}var o=[],n=t.colModel;for(var h=m;h<=s;h++){var k=n[h];var u=k.dataIndx;if(k.hidden){continue}var w=r;do{o.push({rowIndx:w,colIndx:h,dataIndx:u,focus:false});w++}while(w<=v);this.add({cells:o})}}})(jQuery);(function(c){var b=c.paramquery.cCheckBoxColumn=function(f,g){var e=this;this.that=f;this.options=f.options;this.type="checkBoxSelection";this.cbDataIndx=g;var d=f.widgetEventPrefix.toLowerCase();f.element.on(d+"dataavailable",function(h,i){if(e.belongs(h)){return e._onDataAvailable(h,i)}});f.element.on(d+"cellclick",function(h,i){if(e.belongs(h)){return e.cellClick(h,i)}});f.element.on(d+"rowselect",function(h,i){if(e.belongs(h)){return e.rowSelect(h,i)}});f.element.on(d+"rowunselect",function(h,i){if(e.belongs(h)){return e.rowUnSelect(h,i)}});f.element.on(d+"cellkeydown",function(h,i){if(e.belongs(h)){return e.cellKeyDown(h,i)}});f.element.on(d+"refreshheader",function(h,i){if(e.belongs(h)){return e.refreshHeader(h,i)}})};var a=b.prototype=new c.paramquery.cClass;a.hasHeaderChkBox=function(){var d=this.options.selectionModel;if(d.cbHeader===false){return false}else{return true}};a.setValCBox=function(){if(!this.hasHeaderChkBox()){return}var l=this.that,n=this.options,m=n.selectionModel.cbAll,g=m?n.dataModel.data:l.data,e=null,d=0,j=0;for(var h=0,k=g.length;h");var i=this.$inp=j.find("input").click(function(k){if(c(this).is(":checked")){e.selectAllRows()}else{e.unSelectAllRows()}k.stopPropagation()});this.setValCBox()};a.selectAllRows=function(){var e=this.that,d=this.options.selectionModel.cbAll;e.iRows.selectAll({all:d})};a.unSelectAllRows=function(){var e=this.that,d=this.options.selectionModel.cbAll;if(d){e.iRows.removeAll()}else{e.iRows.removeAll({page:true})}};a._onDataAvailable=function(){var g=this.that,j=this.options.dataModel.data,e=this._findSelectionIndx();if(e!=null&&j){for(var f=0,d=j.length;f").appendTo(document.body)}var i=e.offset(),h=i.left,g=i.top;f.css({position:"absolute",left:h,top:g,display:"",height:1,width:1,borderWidth:0});f.focus()};d.destroyClipBoard=function(){var f=c("textarea#pq-grid-excel");if(f.length){var e=document.activeElement;if(e==f[0]){this.$ae.focus()}f.css("display","none")}};d.clearClipBoard=function(){var e=c("textarea#pq-grid-excel");e.val("")};d.copy=function(){var t=c("textarea#pq-grid-excel");var l=this.that,g=l.colModel,e=g.length,h=l.options.selectionModel.type,x=[],s=[];x=l.iRows.getSelection();for(var v=0,w=x.length;v_CX>@2HRA^-& zM@dak03rDV0RR9304x9i000jFwE_SFg^Z7>%k2-NoD4~F7Mmgb43>dLn6 z3&-+I*Y=I)`p)(tOe&Ymrt=AnN~hGS^@`1Ex7@Dx3l59N td{ + background:#fff; + color:#333; } -tr.pq-grid-oddRow td{ - background:#fafafa; +tr.pq-grid-oddRow > td{ + background:#fafafa; } div.pq-hvscroll-square{ - background:#eee; + background:#eee; } -tr.pq-grid-row-hover td +tr.pq-grid-row-hover > td { - background-color:#d8e8fa; - /*background-color:#efefef;*/ + background-color:#efefef; } -tr.pq-row-select td +tr.pq-row-select > td { - background-color:#6699cc; + background:#d8e8fa; +} +.pq-grid td .ui-state-highlight{ + background:steelblue; + border-width:0px; color:#fff; } div.pq-grid tr td.pq-grid-cell-hover { - background:#d8e8fa; - border-width:0px;/*TR*/ + background-color:#efefef; + border-width:0px; } .pq-grid tr td.pq-grid-number-cell { background:#e4ecf7; - /*border:1px solid #9eb6ce; - border-top:0px; - border-left:0px;*/ color:#333; } div.pq-grid tr td.pq-cell-select { - background:#88bbdd; - color:#fff; + background:#d8e8fa; } .pq-grid div.pq-loading-mask{ - background:#dae5f3; - border:1px solid steelblue; - color:#333; - font-weight:normal; + background:#dae5f3; + border:1px solid steelblue; + color:#333; + font-weight:normal; } div.pq-loading-mask div{ - border:1px solid #999; - background:#ddd; + border:1px solid #999; + background:#ddd; +} +.pq-sb-vert-theme .pq-sb-slider{ + border-color:#98AFC7; +} +.pq-sb-horiz-theme .pq-sb-slider{ + border-color:#98AFC7; } \ No newline at end of file diff --git a/themes/peach/pq-grid.css b/themes/peach/pq-grid.css deleted file mode 100644 index cbc40b4..0000000 --- a/themes/peach/pq-grid.css +++ /dev/null @@ -1,109 +0,0 @@ -div.pq-grid{ - border:1px solid tan; -} -div.pq-header-outer{ - background:linen;/* peachpuff;*/ -} -span.pq-grid-header{ - background:url('images/column-header-bg.png'); - /*background: #f1f1f1; /* for non-css3 browsers */ - background-image: linear-gradient(#fefefe,#e6e6e6); - - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fefefe', endColorstr='#f9ccca'); /* for IE */ - background: -webkit-gradient(linear, left top, left bottom, from(#fefefe), to(#f9ccca)); /* for webkit browsers */ - background: -moz-linear-gradient(top, #fefefe, #f9ccca); /* for firefox 3.6+ */ -} - -div.pq-grid-header td{ - /*background:url('images/column-header-bg.gif');*/ -} -.pq-grid-header td.pq-col-sort-asc,.pq-grid-header td.pq-col-sort-desc{ - background: url(images/column-header-over-bg.gif) #ebf3fd; -} - -/*background for odd rows*/ -tr.pq-grid-oddRow td{ - background:snow; /*cornsilk; /*lemonchiffon;*/ - -} -tr td.pq-grid-number-cell{ - background-color:crimson;/*#e4ecf7;*/ - border-color:peachpuff; /*peachpuff;/*#9eb6ce;*/ - color:lightyellow; - text-align:center; - cursor:url('images/pointer.cur'),auto; -} -tr td.pq-last-freeze-col{ - border-right:1px solid crimson; -} -div.pq-grid-top{ - background:linen; /*peachpuff;*/ -} -div.pq-grid-title{ - border-bottom:1px solid tan; -} -div.pq-grid-toolbar -{ - border-bottom:1px solid tan; -} -div.pq-grid-bottom{ - border-top:1px solid tan; - background:linen; /* peachpuff;*/ -} -div.pq-grid-footer{ - -} -div.pq-hvscroll-square{ - background:linen; /*peachpuff;*/ -} - -/*hover and selection styles *************************************************************/ - -tr.pq-grid-row-hover td -{ - background-color:bisque; -} -/*row selection*/ -div.pq-grid tr.pq-row-select td -{ - background-color:crimson; - color:#fff; -} -div.pq-grid tr td.pq-grid-cell-hover -{ - background-color:bisque; -} - - /*restore background of number cell*/ -tr td.pq-grid-number-cell -{ - background-color:crimson; /*#f1ddcf; /*seashell; /*bisque;*/ - color:#fff; -} - -div.pq-grid tr td.pq-cell-select -{ - background-color:crimson; - color:#fff; -} - -/*for scrollbar*/ - -.pq-scrollbar-vert div.top-btn,.pq-scrollbar-vert div.bottom-btn{ - background-image:url(images/sprite.png); -} -.pq-scrollbar-horiz div.left-btn,.pq-scrollbar-horiz div.right-btn{ - background-image:url(images/sprite.png); -} - - -.pq-sb-slider *,.pq-sb-slider-h *{ - background-image:url(images/sprite.png); -} - -.pq-sb-slider .vert-slider-bg{ - background:#B6CEFB url(images/vert-slider-bg.png); -} -.pq-sb-slider-h .horiz-slider-bg{ - background:#B6CEFB url(images/horiz-slider-bg.png); -}