rails_jq_grid 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. data/COPYRIGHT.txt +17 -0
  2. data/GPL-LICENSE +675 -0
  3. data/README.rdoc +176 -0
  4. data/Rakefile +47 -0
  5. data/VERSION +1 -0
  6. data/app/helpers/rails_jq_grid/jq_grid_css_helper.rb +29 -0
  7. data/app/helpers/rails_jq_grid/jq_grid_helper.rb +21 -0
  8. data/app/helpers/rails_jq_grid/jq_grid_js_helper.rb +30 -0
  9. data/app/models/rails_jq_grid/jq_grid.rb +315 -0
  10. data/app/models/rails_jq_grid/jq_grid_column.rb +33 -0
  11. data/app/models/rails_jq_grid/jq_grid_method_missing.rb +50 -0
  12. data/app/models/rails_jq_grid/jq_grid_option_or_method.rb +46 -0
  13. data/lib/rails_jq_grid/acts_as_jq_grid_able.rb +76 -0
  14. data/lib/rails_jq_grid/acts_as_jq_grid_data_source.rb +34 -0
  15. data/lib/rails_jq_grid/engine.rb +23 -0
  16. data/lib/rails_jq_grid.rb +7 -0
  17. data/lib/tasks/rails_jq_grid.rake +1 -0
  18. data/public/javascripts/rails-jqgrid/Changes.txt +1160 -0
  19. data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg.js +1 -0
  20. data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg1251.js +1 -0
  21. data/public/javascripts/rails-jqgrid/i18n/grid.locale-cat.js +1 -0
  22. data/public/javascripts/rails-jqgrid/i18n/grid.locale-cn.js +1 -0
  23. data/public/javascripts/rails-jqgrid/i18n/grid.locale-cs.js +1 -0
  24. data/public/javascripts/rails-jqgrid/i18n/grid.locale-de.js +1 -0
  25. data/public/javascripts/rails-jqgrid/i18n/grid.locale-dk.js +1 -0
  26. data/public/javascripts/rails-jqgrid/i18n/grid.locale-el.js +1 -0
  27. data/public/javascripts/rails-jqgrid/i18n/grid.locale-en.js +1 -0
  28. data/public/javascripts/rails-jqgrid/i18n/grid.locale-es.js +1 -0
  29. data/public/javascripts/rails-jqgrid/i18n/grid.locale-fa.js +1 -0
  30. data/public/javascripts/rails-jqgrid/i18n/grid.locale-fi.js +1 -0
  31. data/public/javascripts/rails-jqgrid/i18n/grid.locale-fr.js +1 -0
  32. data/public/javascripts/rails-jqgrid/i18n/grid.locale-he.js +1 -0
  33. data/public/javascripts/rails-jqgrid/i18n/grid.locale-hu.js +1 -0
  34. data/public/javascripts/rails-jqgrid/i18n/grid.locale-is.js +1 -0
  35. data/public/javascripts/rails-jqgrid/i18n/grid.locale-it.js +1 -0
  36. data/public/javascripts/rails-jqgrid/i18n/grid.locale-ja.js +1 -0
  37. data/public/javascripts/rails-jqgrid/i18n/grid.locale-nl.js +1 -0
  38. data/public/javascripts/rails-jqgrid/i18n/grid.locale-no.js +1 -0
  39. data/public/javascripts/rails-jqgrid/i18n/grid.locale-pl.js +1 -0
  40. data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt-br.js +1 -0
  41. data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt.js +1 -0
  42. data/public/javascripts/rails-jqgrid/i18n/grid.locale-ro.js +1 -0
  43. data/public/javascripts/rails-jqgrid/i18n/grid.locale-ru.js +1 -0
  44. data/public/javascripts/rails-jqgrid/i18n/grid.locale-sk.js +1 -0
  45. data/public/javascripts/rails-jqgrid/i18n/grid.locale-sv.js +1 -0
  46. data/public/javascripts/rails-jqgrid/i18n/grid.locale-tr.js +1 -0
  47. data/public/javascripts/rails-jqgrid/i18n/grid.locale-ua.js +1 -0
  48. data/public/javascripts/rails-jqgrid/install.txt +43 -0
  49. data/public/javascripts/rails-jqgrid/jquery-1.4.2.min.js +154 -0
  50. data/public/javascripts/rails-jqgrid/jquery-ui-1.8.4.custom.min.js +763 -0
  51. data/public/javascripts/rails-jqgrid/jquery.jqGrid.min.js +445 -0
  52. data/public/javascripts/rails-jqgrid/src/JsonXml.js +330 -0
  53. data/public/javascripts/rails-jqgrid/src/css/ellipsis-xbl.xml +13 -0
  54. data/public/javascripts/rails-jqgrid/src/css/jquery.searchFilter.css +7 -0
  55. data/public/javascripts/rails-jqgrid/src/css/ui.jqgrid.css +129 -0
  56. data/public/javascripts/rails-jqgrid/src/css/ui.multiselect.css +30 -0
  57. data/public/javascripts/rails-jqgrid/src/grid.base.js +3003 -0
  58. data/public/javascripts/rails-jqgrid/src/grid.celledit.js +486 -0
  59. data/public/javascripts/rails-jqgrid/src/grid.common.js +636 -0
  60. data/public/javascripts/rails-jqgrid/src/grid.custom.js +818 -0
  61. data/public/javascripts/rails-jqgrid/src/grid.formedit.js +1872 -0
  62. data/public/javascripts/rails-jqgrid/src/grid.import.js +201 -0
  63. data/public/javascripts/rails-jqgrid/src/grid.inlinedit.js +250 -0
  64. data/public/javascripts/rails-jqgrid/src/grid.jqueryui.js +503 -0
  65. data/public/javascripts/rails-jqgrid/src/grid.loader.js +47 -0
  66. data/public/javascripts/rails-jqgrid/src/grid.postext.js +64 -0
  67. data/public/javascripts/rails-jqgrid/src/grid.setcolumns.js +126 -0
  68. data/public/javascripts/rails-jqgrid/src/grid.subgrid.js +260 -0
  69. data/public/javascripts/rails-jqgrid/src/grid.tbltogrid.js +106 -0
  70. data/public/javascripts/rails-jqgrid/src/grid.treegrid.js +483 -0
  71. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg.js +132 -0
  72. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg1251.js +132 -0
  73. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cat.js +128 -0
  74. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cn.js +132 -0
  75. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cs.js +128 -0
  76. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-de.js +128 -0
  77. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-dk.js +128 -0
  78. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-el.js +126 -0
  79. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-en.js +128 -0
  80. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-es.js +128 -0
  81. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fa.js +125 -0
  82. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fi.js +130 -0
  83. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fr.js +126 -0
  84. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-he.js +127 -0
  85. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-hu.js +129 -0
  86. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-is.js +126 -0
  87. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-it.js +1 -0
  88. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ja.js +155 -0
  89. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-nl.js +149 -0
  90. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-no.js +1 -0
  91. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pl.js +127 -0
  92. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt-br.js +127 -0
  93. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt.js +125 -0
  94. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ro.js +139 -0
  95. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ru.js +127 -0
  96. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sk.js +127 -0
  97. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sv.js +127 -0
  98. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-tr.js +126 -0
  99. data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ua.js +127 -0
  100. data/public/javascripts/rails-jqgrid/src/jqDnR.js +68 -0
  101. data/public/javascripts/rails-jqgrid/src/jqModal.js +69 -0
  102. data/public/javascripts/rails-jqgrid/src/jquery.fmatter.js +542 -0
  103. data/public/javascripts/rails-jqgrid/src/jquery.searchFilter.js +716 -0
  104. data/public/javascripts/rails-jqgrid/src/ui.multiselect.js +314 -0
  105. data/public/stylesheets/rails-jqgrid/ellipsis-xbl.xml +13 -0
  106. data/public/stylesheets/rails-jqgrid/themes/AUTHORS.txt +30 -0
  107. data/public/stylesheets/rails-jqgrid/themes/GPL-LICENSE.txt +278 -0
  108. data/public/stylesheets/rails-jqgrid/themes/MIT-LICENSE.txt +25 -0
  109. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  110. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  111. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  112. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  113. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  114. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  115. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  116. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  117. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_222222_256x240.png +0 -0
  118. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  119. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_454545_256x240.png +0 -0
  120. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_888888_256x240.png +0 -0
  121. data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  122. data/public/stylesheets/rails-jqgrid/themes/smoothness/jquery-ui-1.8.4.custom.css +572 -0
  123. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_flat_55_999999_40x100.png +0 -0
  124. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_flat_75_aaaaaa_40x100.png +0 -0
  125. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_glass_45_0078ae_1x400.png +0 -0
  126. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_glass_55_f8da4e_1x400.png +0 -0
  127. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_glass_75_79c9ec_1x400.png +0 -0
  128. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_gloss-wave_45_e14f1c_500x100.png +0 -0
  129. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_gloss-wave_50_6eac2c_500x100.png +0 -0
  130. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_gloss-wave_75_2191c0_500x100.png +0 -0
  131. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  132. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_0078ae_256x240.png +0 -0
  133. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_056b93_256x240.png +0 -0
  134. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_d8e7f3_256x240.png +0 -0
  135. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_e0fdff_256x240.png +0 -0
  136. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_f5e175_256x240.png +0 -0
  137. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_f7a50d_256x240.png +0 -0
  138. data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_fcd113_256x240.png +0 -0
  139. data/public/stylesheets/rails-jqgrid/themes/start/jquery-ui-1.8.4.custom.css +573 -0
  140. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png +0 -0
  141. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png +0 -0
  142. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_glass_20_555555_1x400.png +0 -0
  143. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png +0 -0
  144. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png +0 -0
  145. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png +0 -0
  146. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png +0 -0
  147. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png +0 -0
  148. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png +0 -0
  149. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_222222_256x240.png +0 -0
  150. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_4b8e0b_256x240.png +0 -0
  151. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_a83300_256x240.png +0 -0
  152. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_cccccc_256x240.png +0 -0
  153. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_ffffff_256x240.png +0 -0
  154. data/public/stylesheets/rails-jqgrid/themes/ui-darkness/jquery-ui-1.8.4.custom.css +572 -0
  155. data/public/stylesheets/rails-jqgrid/themes/version.txt +1 -0
  156. data/public/stylesheets/rails-jqgrid/ui.jqgrid.css +2 -0
  157. data/rails_jq_grid.gemspec +200 -0
  158. data/spec/spec.opts +1 -0
  159. data/spec/spec_helper.rb +8 -0
  160. metadata +240 -0
@@ -0,0 +1,483 @@
1
+ ;(function($) {
2
+ /*
3
+ **
4
+ * jqGrid extension - Tree Grid
5
+ * Tony Tomov tony@trirand.com
6
+ * http://trirand.com/blog/
7
+ * Dual licensed under the MIT and GPL licenses:
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ * http://www.gnu.org/licenses/gpl.html
10
+ **/
11
+ $.jgrid.extend({
12
+ setTreeNode : function(rd, row){
13
+ return this.each(function(){
14
+ var $t = this;
15
+ if( !$t.grid || !$t.p.treeGrid ) { return; }
16
+ var expCol = $t.p.expColInd;
17
+ var expanded = $t.p.treeReader.expanded_field;
18
+ var isLeaf = $t.p.treeReader.leaf_field;
19
+ var level = $t.p.treeReader.level_field;
20
+ row.level = rd[level];
21
+
22
+ if($t.p.treeGridModel == 'nested') {
23
+ var lft = rd[$t.p.treeReader.left_field],
24
+ rgt = rd[$t.p.treeReader.right_field];
25
+ if(!rd[isLeaf]) {
26
+ // NS Model
27
+ rd[isLeaf] = (parseInt(rgt,10) === parseInt(lft,10)+1) ? 'true' : 'false';
28
+ }
29
+ } else {
30
+ //row.parent_id = rd[$t.p.treeReader.parent_id_field];
31
+ }
32
+ var curLevel = parseInt(rd[level],10), ident,lftpos;
33
+ if($t.p.tree_root_level === 0) {
34
+ ident = curLevel+1;
35
+ lftpos = curLevel;
36
+ } else {
37
+ ident = curLevel;
38
+ lftpos = curLevel -1;
39
+ }
40
+ var twrap = "<div class='tree-wrap tree-wrap-"+$t.p.direction+"' style='width:"+(ident*18)+"px;'>";
41
+ twrap += "<div style='"+($t.p.direction=="rtl" ? "right:" : "left:")+(lftpos*18)+"px;' class='ui-icon ";
42
+
43
+ if(rd[isLeaf] == "true" || rd[isLeaf] === true) {
44
+ twrap += $t.p.treeIcons.leaf+" tree-leaf'";
45
+ rd[isLeaf] = true;
46
+ rd[expanded] = false;
47
+ } else {
48
+ if(rd[expanded] == "true" || rd[expanded] === true) {
49
+ twrap += $t.p.treeIcons.minus+" tree-minus treeclick'";
50
+ rd[expanded] = true;
51
+ } else {
52
+ twrap += $t.p.treeIcons.plus+" tree-plus treeclick'";
53
+ rd[expanded] = false;
54
+ }
55
+ rd[isLeaf] = false;
56
+ }
57
+ twrap += "</div></div>";
58
+ if(!$t.p.loadonce) {
59
+ rd[$t.p.localReader.id] = row.id;
60
+ $t.p.data.push(rd);
61
+ $t.p._index[row.id]=$t.p.data.length-1;
62
+ }
63
+ if(parseInt(rd[level],10) !== parseInt($t.p.tree_root_level,10)) {
64
+ if(!$($t).jqGrid("isVisibleNode",rd)){
65
+ $(row).css("display","none");
66
+ }
67
+ }
68
+
69
+ $("td:eq("+expCol+")",row).wrapInner("<span></span>").prepend(twrap);
70
+ $(".treeclick",row).bind("click",function(e){
71
+ var target = e.target || e.srcElement,
72
+ ind2 =$(target,$t.rows).closest("tr.jqgrow")[0].id,
73
+ pos = $t.p._index[ind2],
74
+ isLeaf = $t.p.treeReader.leaf_field,
75
+ expanded = $t.p.treeReader.expanded_field;
76
+ if(!$t.p.data[pos][isLeaf]){
77
+ if($t.p.data[pos][expanded]){
78
+ $($t).jqGrid("collapseRow",$t.p.data[pos]);
79
+ $($t).jqGrid("collapseNode",$t.p.data[pos]);
80
+ } else {
81
+ $($t).jqGrid("expandRow",$t.p.data[pos]);
82
+ $($t).jqGrid("expandNode",$t.p.data[pos]);
83
+ }
84
+ }
85
+ return false;
86
+ });
87
+ if($t.p.ExpandColClick === true) {
88
+ $("span", row).css("cursor","pointer").bind("click",function(e){
89
+ var target = e.target || e.srcElement,
90
+ ind2 =$(target,$t.rows).closest("tr.jqgrow")[0].id,
91
+ pos = $t.p._index[ind2],
92
+ isLeaf = $t.p.treeReader.leaf_field,
93
+ expanded = $t.p.treeReader.expanded_field;
94
+ if(!$t.p.data[pos][isLeaf]){
95
+ if($t.p.data[pos][expanded]){
96
+ $($t).jqGrid("collapseRow",$t.p.data[pos]);
97
+ $($t).jqGrid("collapseNode",$t.p.data[pos]);
98
+ } else {
99
+ $($t).jqGrid("expandRow",$t.p.data[pos]);
100
+ $($t).jqGrid("expandNode",$t.p.data[pos]);
101
+ }
102
+ }
103
+ $($t).jqGrid("setSelection",ind2);
104
+ return false;
105
+ });
106
+ }
107
+ });
108
+ },
109
+ setTreeGrid : function() {
110
+ return this.each(function (){
111
+ var $t = this, i=0, pico;
112
+ if(!$t.p.treeGrid) { return; }
113
+ if(!$t.p.treedatatype ) { $.extend($t.p,{treedatatype: $t.p.datatype}); }
114
+ $t.p.subGrid = false; $t.p.altRows =false;
115
+ $t.p.pgbuttons = false; $t.p.pginput = false;
116
+ $t.p.multiselect = false; $t.p.rowList = [];
117
+ pico = 'ui-icon-triangle-1-' + ($t.p.direction=="rtl" ? 'w' : 'e');
118
+ $t.p.treeIcons = $.extend({plus:pico,minus:'ui-icon-triangle-1-s',leaf:'ui-icon-radio-off'},$t.p.treeIcons || {});
119
+ if($t.p.treeGridModel == 'nested') {
120
+ $t.p.treeReader = $.extend({
121
+ level_field: "level",
122
+ left_field:"lft",
123
+ right_field: "rgt",
124
+ leaf_field: "isLeaf",
125
+ expanded_field: "expanded"
126
+ },$t.p.treeReader);
127
+ } else
128
+ if($t.p.treeGridModel == 'adjacency') {
129
+ $t.p.treeReader = $.extend({
130
+ level_field: "level",
131
+ parent_id_field: "parent",
132
+ leaf_field: "isLeaf",
133
+ expanded_field: "expanded"
134
+ },$t.p.treeReader );
135
+ }
136
+ for (var key in $t.p.colModel){
137
+ if($t.p.colModel.hasOwnProperty(key)) {
138
+ if($t.p.colModel[key].name == $t.p.ExpandColumn) {
139
+ $t.p.expColInd = i;
140
+ break;
141
+ }
142
+ i++;
143
+ }
144
+ }
145
+ if(!$t.p.expColInd) { $t.p.expColInd = 0; }
146
+ $.each($t.p.treeReader,function(i,n){
147
+ if(n){
148
+ $t.p.colNames.push(n);
149
+ $t.p.colModel.push({name:n,width:1,hidden:true,sortable:false,resizable:false,hidedlg:true,editable:true,search:false});
150
+ }
151
+ });
152
+ });
153
+ },
154
+ expandRow: function (record){
155
+ this.each(function(){
156
+ var $t = this;
157
+ if(!$t.grid || !$t.p.treeGrid) { return; }
158
+ var childern = $($t).jqGrid("getNodeChildren",record),
159
+ //if ($($t).jqGrid("isVisibleNode",record)) {
160
+ expanded = $t.p.treeReader.expanded_field;
161
+ $(childern).each(function(i){
162
+ var id = $.jgrid.getAccessor(this,$t.p.localReader.id);
163
+ $("#"+id,$t.grid.bDiv).css("display","");
164
+ if(this[expanded]) {
165
+ $($t).jqGrid("expandRow",this);
166
+ }
167
+ });
168
+ //}
169
+ });
170
+ },
171
+ collapseRow : function (record) {
172
+ this.each(function(){
173
+ var $t = this;
174
+ if(!$t.grid || !$t.p.treeGrid) { return; }
175
+ var childern = $($t).jqGrid("getNodeChildren",record),
176
+ expanded = $t.p.treeReader.expanded_field;
177
+ $(childern).each(function(i){
178
+ var id = $.jgrid.getAccessor(this,$t.p.localReader.id)
179
+ $("#"+id,$t.grid.bDiv).css("display","none");
180
+ if(this[expanded]){
181
+ $($t).jqGrid("collapseRow",this);
182
+ }
183
+ });
184
+ });
185
+ },
186
+ // NS ,adjacency models
187
+ getRootNodes : function() {
188
+ var result = [];
189
+ this.each(function(){
190
+ var $t = this;
191
+ if(!$t.grid || !$t.p.treeGrid) { return; }
192
+ switch ($t.p.treeGridModel) {
193
+ case 'nested' :
194
+ var level = $t.p.treeReader.level_field;
195
+ $($t.p.data).each(function(i){
196
+ if(parseInt(this[level],10) === parseInt($t.p.tree_root_level,10)) {
197
+ result.push(this);
198
+ }
199
+ });
200
+ break;
201
+ case 'adjacency' :
202
+ var parent_id = $t.p.treeReader.parent_id_field;
203
+ $($t.p.data).each(function(i){
204
+ if(this[parent_id] === null || String(this[parent_id]).toLowerCase() == "null") {
205
+ result.push(this);
206
+ }
207
+ });
208
+ break;
209
+ }
210
+ });
211
+ return result;
212
+ },
213
+ getNodeDepth : function(rc) {
214
+ var ret = null;
215
+ this.each(function(){
216
+ if(!this.grid || !this.p.treeGrid) { return; }
217
+ var $t = this;
218
+ switch ($t.p.treeGridModel) {
219
+ case 'nested' :
220
+ var level = $t.p.treeReader.level_field;
221
+ ret = parseInt(rc[level],10) - parseInt($t.p.tree_root_level,10);
222
+ break;
223
+ case 'adjacency' :
224
+ ret = $($t).jqGrid("getNodeAncestors",rc).length;
225
+ break;
226
+ }
227
+ });
228
+ return ret;
229
+ },
230
+ getNodeParent : function(rc) {
231
+ var result = null;
232
+ this.each(function(){
233
+ var $t = this;
234
+ if(!$t.grid || !$t.p.treeGrid) { return; }
235
+ switch ($t.p.treeGridModel) {
236
+ case 'nested' :
237
+ var lftc = $t.p.treeReader.left_field,
238
+ rgtc = $t.p.treeReader.right_field,
239
+ levelc = $t.p.treeReader.level_field,
240
+ lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10);
241
+ $(this.p.data).each(function(){
242
+ if(parseInt(this[levelc],10) === level-1 && parseInt(this[lftc],10) < lft && parseInt(this[rgtc],10) > rgt) {
243
+ result = this;
244
+ return false;
245
+ }
246
+ });
247
+ break;
248
+ case 'adjacency' :
249
+ var parent_id = $t.p.treeReader.parent_id_field;
250
+ $(this.p.data).each(function(i,val){
251
+ if(this.id == rc[parent_id] ) {
252
+ result = this;
253
+ return false;
254
+ }
255
+ });
256
+ break;
257
+ }
258
+ });
259
+ return result;
260
+ },
261
+ getNodeChildren : function(rc) {
262
+ var result = [];
263
+ this.each(function(){
264
+ var $t = this;
265
+ if(!$t.grid || !$t.p.treeGrid) { return; }
266
+ switch ($t.p.treeGridModel) {
267
+ case 'nested' :
268
+ var lftc = $t.p.treeReader.left_field,
269
+ rgtc = $t.p.treeReader.right_field,
270
+ levelc = $t.p.treeReader.level_field,
271
+ lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10);
272
+ $(this.p.data).each(function(i){
273
+ if(parseInt(this[levelc],10) === level+1 && parseInt(this[lftc],10) > lft && parseInt(this[rgtc],10) < rgt) {
274
+ result.push(this);
275
+ }
276
+ });
277
+ break;
278
+ case 'adjacency' :
279
+ var parent_id = $t.p.treeReader.parent_id_field;
280
+ $(this.p.data).each(function(i,val){
281
+ if(this[parent_id] == rc.id) {
282
+ result.push(this);
283
+ }
284
+ });
285
+ break;
286
+ }
287
+ });
288
+ return result;
289
+ },
290
+ getFullTreeNode : function(rc) {
291
+ var result = [];
292
+ this.each(function(){
293
+ var $t = this, len;
294
+ if(!$t.grid || !$t.p.treeGrid) { return; }
295
+ switch ($t.p.treeGridModel) {
296
+ case 'nested' :
297
+ var lftc = $t.p.treeReader.left_field,
298
+ rgtc = $t.p.treeReader.right_field,
299
+ levelc = $t.p.treeReader.level_field,
300
+ lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10);
301
+ $(this.p.data).each(function(i){
302
+ if(parseInt(this[levelc],10) >= level && parseInt(this[lftc],10) >= lft && parseInt(this[lftc],10) <= rgt) {
303
+ result.push(this);
304
+ }
305
+ });
306
+ break;
307
+ case 'adjacency' :
308
+ result.push(rc);
309
+ var parent_id = $t.p.treeReader.parent_id_field;
310
+ $(this.p.data).each(function(i){
311
+ len = result.length;
312
+ for (i = 0; i < len; i++) {
313
+ if (result[i].id == this[parent_id]) {
314
+ result.push(this);
315
+ break;
316
+ }
317
+ }
318
+ });
319
+ break;
320
+ }
321
+ });
322
+ return result;
323
+ },
324
+ // End NS, adjacency Model
325
+ getNodeAncestors : function(rc) {
326
+ var ancestors = [];
327
+ this.each(function(){
328
+ if(!this.grid || !this.p.treeGrid) { return; }
329
+ var parent = $(this).jqGrid("getNodeParent",rc);
330
+ while (parent) {
331
+ ancestors.push(parent);
332
+ parent = $(this).jqGrid("getNodeParent",parent);
333
+ }
334
+ });
335
+ return ancestors;
336
+ },
337
+ isVisibleNode : function(rc) {
338
+ var result = true;
339
+ this.each(function(){
340
+ var $t = this;
341
+ if(!$t.grid || !$t.p.treeGrid) { return; }
342
+ var ancestors = $($t).jqGrid("getNodeAncestors",rc),
343
+ expanded = $t.p.treeReader.expanded_field;
344
+ $(ancestors).each(function(){
345
+ result = result && this[expanded];
346
+ if(!result) {return false;}
347
+ });
348
+ });
349
+ return result;
350
+ },
351
+ isNodeLoaded : function(rc) {
352
+ var result;
353
+ this.each(function(){
354
+ var $t = this;
355
+ if(!$t.grid || !$t.p.treeGrid) { return; }
356
+ var isLeaf = $t.p.treeReader.leaf_field;
357
+ if(rc.loaded !== undefined) {
358
+ result = rc.loaded;
359
+ } else if( rc[isLeaf] || $($t).jqGrid("getNodeChildren",rc).length > 0){
360
+ result = true;
361
+ } else {
362
+ result = false;
363
+ }
364
+ });
365
+ return result;
366
+ },
367
+ expandNode : function(rc) {
368
+ return this.each(function(){
369
+ if(!this.grid || !this.p.treeGrid) { return; }
370
+ var expanded = this.p.treeReader.expanded_field;
371
+ if(!rc[expanded]) {
372
+ var id = $.jgrid.getAccessor(rc,this.p.localReader.id)
373
+ var rc1 = $("#"+id,this.grid.bDiv)[0];
374
+ var position = this.p._index[id];
375
+ if( $(this).jqGrid("isNodeLoaded",this.p.data[position]) ) {
376
+ rc[expanded] = true;
377
+ $("div.treeclick",rc1).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus");
378
+ } else {
379
+ rc[expanded] = true;
380
+ $("div.treeclick",rc1).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus");
381
+ this.p.treeANode = rc1.rowIndex;
382
+ this.p.datatype = this.p.treedatatype;
383
+ if(this.p.treeGridModel == 'nested') {
384
+ $(this).jqGrid("setGridParam",{postData:{nodeid:id,n_left:rc.lft,n_right:rc.rgt,n_level:rc.level}});
385
+ } else {
386
+ $(this).jqGrid("setGridParam",{postData:{nodeid:id,parentid:rc.parent_id,n_level:rc.level}});
387
+ }
388
+ $(this).trigger("reloadGrid");
389
+ if(this.p.treeGridModel == 'nested') {
390
+ $(this).jqGrid("setGridParam",{postData:{nodeid:'',n_left:'',n_right:'',n_level:''}});
391
+ } else {
392
+ $(this).jqGrid("setGridParam",{postData:{nodeid:'',parentid:'',n_level:''}});
393
+ }
394
+ }
395
+ }
396
+ });
397
+ },
398
+ collapseNode : function(rc) {
399
+ return this.each(function(){
400
+ if(!this.grid || !this.p.treeGrid) { return; }
401
+ if(rc.expanded) {
402
+ rc.expanded = false;
403
+ var id = $.jgrid.getAccessor(rc,this.p.localReader.id)
404
+ var rc1 = $("#"+id,this.grid.bDiv)[0];
405
+ $("div.treeclick",rc1).removeClass(this.p.treeIcons.minus+" tree-minus").addClass(this.p.treeIcons.plus+" tree-plus");
406
+ }
407
+ });
408
+ },
409
+ SortTree : function( sortname, newDir, st, datefmt) {
410
+ return this.each(function(){
411
+ if(!this.grid || !this.p.treeGrid) { return; }
412
+ var i, len,
413
+ rec, records = [], $t = this, query, roots,
414
+ rt = $(this).jqGrid("getRootNodes");
415
+ // Sorting roots
416
+ query = $.jgrid.from(rt);
417
+ query.orderBy(sortname,newDir,st, datefmt);
418
+ roots = query.select();
419
+
420
+ // Sorting children
421
+ for (i = 0, len = roots.length; i < len; i++) {
422
+ rec = roots[i];
423
+ records.push(rec);
424
+ $(this).jqGrid("collectChildrenSortTree",records, rec, sortname, newDir,st, datefmt);
425
+ }
426
+ $.each(records, function(index, row) {
427
+ var id = $.jgrid.getAccessor(this,$t.p.localReader.id);
428
+ if(index===0) {
429
+ var row1 = $("#"+id,$t.grid.bDiv);
430
+ $("td",row1).each( function( k ) {
431
+ $(this).css("width",$t.grid.headers[k].width+"px");
432
+ });
433
+ $t.grid.cols = row1[0].cells;
434
+ }
435
+ $('tbody',$t.grid.bDiv).append($("#"+id,$t.grid.bDiv));
436
+ });
437
+ query = null; roots=null;records=null;
438
+ });
439
+ },
440
+ collectChildrenSortTree : function(records, rec, sortname, newDir,st, datefmt) {
441
+ return this.each(function(){
442
+ if(!this.grid || !this.p.treeGrid) { return; }
443
+ var i, len,
444
+ child, ch, query, children;
445
+ ch = $(this).jqGrid("getNodeChildren",rec);
446
+ query = $.jgrid.from(ch);
447
+ query.orderBy(sortname,newDir,newDir,st, datefmt);
448
+ children = query.select();
449
+ for (i = 0, len = children.length; i < len; i++) {
450
+ child = children[i];
451
+ records.push(child);
452
+ $(this).jqGrid("collectChildrenSortTree",records, child, sortname, newDir, st, datefmt);
453
+ }
454
+ });
455
+ },
456
+ // experimental
457
+ setTreeRow : function(rowid, data) {
458
+ var nm, success=false;
459
+ this.each(function(){
460
+ var t = this;
461
+ if(!t.grid || !t.p.treeGrid) { return; }
462
+ success = $(t).jqGrid("setRowData",rowid,data);
463
+ });
464
+ return success;
465
+ },
466
+ delTreeNode : function (rowid) {
467
+ return this.each(function () {
468
+ var $t = this;
469
+ if(!$t.grid || !$t.p.treeGrid) { return; }
470
+ var rc = $($t).jqGrid("getInd",rowid,true);
471
+ if (rc) {
472
+ var dr = $($t).jqGrid("getNodeChildren",rc);
473
+ if(dr.length>0){
474
+ for (var i=0;i<dr.length;i++){
475
+ $($t).jqGrid("delRowData",dr[i].id);
476
+ }
477
+ }
478
+ $($t).jqGrid("delRowData",rc.id);
479
+ }
480
+ });
481
+ }
482
+ });
483
+ })(jQuery);
@@ -0,0 +1,132 @@
1
+ ;(function($){
2
+ /**
3
+ * jqGrid Bulgarian Translation
4
+ * Tony Tomov tony@trirand.com
5
+ * http://trirand.com/blog/
6
+ * Dual licensed under the MIT and GPL licenses:
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ * http://www.gnu.org/licenses/gpl.html
9
+ **/
10
+ $.jgrid = {
11
+ defaults : {
12
+ recordtext: "{0} - {1} от {2}",
13
+ emptyrecords: "Няма запис(и)",
14
+ loadtext: "Зареждам...",
15
+ pgtext : "Стр. {0} от {1}"
16
+ },
17
+ search : {
18
+ caption: "Търсене...",
19
+ Find: "Намери",
20
+ Reset: "Изчисти",
21
+ odata : ['равно', 'различно', 'по-малко', 'по-малко или=','по-голямо','по-голямо или =', 'започва с','не започва с','се намира в','не се намира в','завършва с','не завършава с','съдържа', 'не съдържа' ],
22
+ groupOps: [ { op: "AND", text: "&nbsp;И " }, { op: "OR", text: "ИЛИ" } ],
23
+ matchText: " включи",
24
+ rulesText: " клауза"
25
+ },
26
+ edit : {
27
+ addCaption: "Нов Запис",
28
+ editCaption: "Редакция Запис",
29
+ bSubmit: "Запиши",
30
+ bCancel: "Изход",
31
+ bClose: "Затвори",
32
+ saveData: "Данните са променени! Да съхраня ли промените?",
33
+ bYes : "Да",
34
+ bNo : "Не",
35
+ bExit : "Отказ",
36
+ msg: {
37
+ required:"Полето е задължително",
38
+ number:"Въведете валидно число!",
39
+ minValue:"стойността трябва да е по-голяма или равна от",
40
+ maxValue:"стойността трябва да е по-малка или равна от",
41
+ email: "не е валиден ел. адрес",
42
+ integer: "Въведете валидно цяло число",
43
+ date: "Въведете валидна дата",
44
+ url: "e невалиден URL. Изискава се префикс('http://' или 'https://')",
45
+ nodefined : " е недефинирана!",
46
+ novalue : " изисква връщане на стойност!",
47
+ customarray : "Потреб. Функция трябва да върне масив!",
48
+ customfcheck : "Потребителска функция е задължителна при този тип елемент!"
49
+ }
50
+ },
51
+ view : {
52
+ caption: "Преглед запис",
53
+ bClose: "Затвори"
54
+ },
55
+ del : {
56
+ caption: "Изтриване",
57
+ msg: "Да изтрия ли избраният запис?",
58
+ bSubmit: "Изтрий",
59
+ bCancel: "Отказ"
60
+ },
61
+ nav : {
62
+ edittext: " ",
63
+ edittitle: "Редакция избран запис",
64
+ addtext:" ",
65
+ addtitle: "Добавяне нов запис",
66
+ deltext: " ",
67
+ deltitle: "Изтриване избран запис",
68
+ searchtext: " ",
69
+ searchtitle: "Търсене запис(и)",
70
+ refreshtext: "",
71
+ refreshtitle: "Обнови таблица",
72
+ alertcap: "Предупреждение",
73
+ alerttext: "Моля, изберете запис",
74
+ viewtext: "",
75
+ viewtitle: "Преглед избран запис"
76
+ },
77
+ col : {
78
+ caption: "Избери колони",
79
+ bSubmit: "Ок",
80
+ bCancel: "Изход"
81
+ },
82
+ errors : {
83
+ errcap : "Грешка",
84
+ nourl : "Няма посочен url адрес",
85
+ norecords: "Няма запис за обработка",
86
+ model : "Модела не съответства на имената!"
87
+ },
88
+ formatter : {
89
+ integer : {thousandsSeparator: " ", defaultValue: '0'},
90
+ number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
91
+ currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:" лв.", defaultValue: '0.00'},
92
+ date : {
93
+ dayNames: [
94
+ "Нед", "Пон", "Вт", "Ср", "Чет", "Пет", "Съб",
95
+ "Неделя", "Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота"
96
+ ],
97
+ monthNames: [
98
+ "Яну", "Фев", "Мар", "Апр", "Май", "Юни", "Юли", "Авг", "Сеп", "Окт", "Нов", "Дек",
99
+ "Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"
100
+ ],
101
+ AmPm : ["","","",""],
102
+ S: function (j) {
103
+ if(j==7 || j==8 || j== 27 || j== 28) {
104
+ return 'ми';
105
+ }
106
+ return ['ви', 'ри', 'ти'][Math.min((j - 1) % 10, 2)];
107
+ },
108
+ srcformat: 'Y-m-d',
109
+ newformat: 'd/m/Y',
110
+ masks : {
111
+ ISO8601Long:"Y-m-d H:i:s",
112
+ ISO8601Short:"Y-m-d",
113
+ ShortDate: "n/j/Y",
114
+ LongDate: "l, F d, Y",
115
+ FullDateTime: "l, F d, Y g:i:s A",
116
+ MonthDay: "F d",
117
+ ShortTime: "g:i A",
118
+ LongTime: "g:i:s A",
119
+ SortableDateTime: "Y-m-d\\TH:i:s",
120
+ UniversalSortableDateTime: "Y-m-d H:i:sO",
121
+ YearMonth: "F, Y"
122
+ },
123
+ reformatAfterEdit : false
124
+ },
125
+ baseLinkUrl: '',
126
+ showAction: '',
127
+ target: '',
128
+ checkbox : {disabled:true},
129
+ idName : 'id'
130
+ }
131
+ };
132
+ })(jQuery);