Changeset 17562 for extensions/GrumPluginClasses/js
- Timestamp:
- Aug 14, 2012, 9:55:13 PM (12 years ago)
- Location:
- extensions/GrumPluginClasses/js
- Files:
-
- 6 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GrumPluginClasses/js/ui.dynamicTable.js
r16012 r17562 54 54 options = 55 55 { 56 autoLoad:true, 56 57 columns:[], 57 58 postUrl:'', … … 65 66 currentPage:1, 66 67 sortBoxTitle:'Sort by', 68 showTotalRow:'auto', // visible, hidden, auto 67 69 footerString: 68 70 { … … 93 95 sortedColumns:[], 94 96 filteredColumns:[], 95 loadedData:[] 97 loadedData:[], 98 totalRowHasData:false 96 99 } 97 100 ); … … 131 134 } 132 135 ), 136 loadingContentWorkInProgress:$('<div/>', 137 { 138 class:'ui-dynamicTableLoadingWorkInProgress' 139 } 140 ), 141 142 totalRowContent:$('<table/>', 143 { 144 'class':'ui-dynamicTableTotalRow' 145 } 146 ), 147 totalRowTr:$('<tr/>'), 148 133 149 134 150 footer:$('<div/>', … … 154 170 .append(objects.headerContainer.append(objects.header.append(objects.headerTr))) 155 171 .append(objects.loadingContent) 172 .append(objects.loadingContentWorkInProgress) 156 173 .append(objects.contentContainer.append(objects.content)) 174 .append(objects.totalRowContent.append(objects.totalRowTr)) 157 175 .append(objects.footer 158 176 .append(objects.footerNbItems) … … 285 303 }, // footerString 286 304 305 autoLoad: function (value) 306 { 307 if(value!=null) 308 { 309 // set selected value 310 return( 311 this.each( 312 function() 313 { 314 privateMethods.setAutoLoad($(this), value, true); 315 } 316 ) 317 ); 318 } 319 else 320 { 321 var options=this.data('options'); 322 return(options.autoLoad); 323 } 324 }, // autoLoad 325 326 327 showTotalRow : function (value) 328 { 329 if(value!=null) 330 { 331 // set selected value 332 return( 333 this.each( 334 function() 335 { 336 privateMethods.setShowTotalRow($(this), value); 337 } 338 ) 339 ); 340 } 341 else 342 { 343 var options=this.data('options'); 344 return(options.showTotalRow); 345 } 346 }, // showTotalRow 347 348 287 349 currentPage: function (value) 288 350 { … … 509 571 510 572 return(properties.loadedData); 511 } // loadedData 573 }, // loadedData 574 575 /** 576 * refresh table content 577 * @param Integer value: page; if not specified, refresh current page 578 */ 579 refreshContent: function (value) 580 { 581 privateMethods.loadContent($(this), value); 582 }, 583 584 /** 585 * force table to resize columns 586 */ 587 resizeContent: function (value) 588 { 589 privateMethods.setColumnsSize($(this)); 590 }, 591 512 592 513 593 }; // methods … … 528 608 properties.initialized=false; 529 609 610 privateMethods.setAutoLoad(object, (value.autoLoad!=null)?value.autoLoad:options.autoLoad); 611 privateMethods.setShowTotalRow(object, (value.showTotalRow!=null)?value.showTotalRow:options.showTotalRow); 530 612 privateMethods.setPostData(object, (value.postData!=null)?value.postData:options.postData); 531 613 privateMethods.setPostUrl(object, (value.postUrl!=null)?value.postUrl:options.postUrl); … … 549 631 550 632 551 552 privateMethods.loadContent(object);633 if(options.autoLoad) 634 privateMethods.loadContent(object); 553 635 554 636 }, 637 638 setAutoLoad : function (object, value) 639 { 640 var properties=object.data('properties'), 641 options=object.data('options'); 642 643 if((!properties.initialized || value!=options.autoLoad) && (value==true || value==false)) 644 { 645 options.autoLoad=value; 646 } 647 648 return(options.autoLoad); 649 }, // setAutoLoad 650 651 setShowTotalRow : function (object, value) 652 { 653 var properties=object.data('properties'), 654 options=object.data('options'); 655 656 if((!properties.initialized || value!=options.showTotalRow) && (value=='visible' || value=='hidden' || value=='auto')) 657 { 658 options.showTotalRow=value; 659 if(properties.initialized) 660 privateMethods.showTotalRow(object); 661 } 662 663 return(options.showTotalRow); 664 }, // setAutoLoad 665 555 666 556 667 setColumns : function (object, value) … … 827 938 828 939 /* 829 * update DOM for headers & footer 940 * update DOM for headers & footer & total row 830 941 */ 831 942 updateTable : function (object) … … 840 951 841 952 objects.headerTr.children().remove(); 953 objects.totalRowTr.children().remove(); 842 954 843 955 properties.hasSortableButton=false; … … 930 1042 931 1043 objects.headerTr.append(td); 1044 1045 td=$('<td/>'); 1046 if(options.columns[i].width!='') td.attr('style', 'width:'+options.columns[i].width+';'); 1047 objects.totalRowTr.append(td); 932 1048 } 933 1049 … … 959 1075 modal:true, 960 1076 width:cWidth, 961 height: 150,1077 height:250, 962 1078 autoHeight:false, 963 1079 title:options.sortBoxTitle, … … 982 1098 ).append(button); 983 1099 objects.headerTr.append(td); 1100 1101 td=$('<td/>'); 1102 objects.totalRowTr.append(td); 984 1103 } 985 1104 }, //updateTable 986 1105 987 988 loadContent : function (object) 1106 /** 1107 * load table content 1108 * 1109 * @param Integer page: page to load; if not specified, use the current page 1110 */ 1111 loadContent : function (object, page) 989 1112 { 990 1113 var data=null, … … 997 1120 if(options.postUrl=='') return(false); 998 1121 1122 if(page>0 && page <= objects.footerPagesNavigator.inputPages('nbPages')) 1123 options.currentPage=page; 999 1124 privateMethods.displayLoading(object, true); 1000 1125 … … 1030 1155 msg=$.parseJSON(msg); 1031 1156 1032 if(msg==null) return(false); 1157 if(msg==null || msg.rows==null) 1158 { 1159 privateMethods.displayLoading(object, false); 1160 return(false); 1161 } 1033 1162 1034 1163 if(options.contentLoaded) object.trigger('dynamicTableContentLoaded', msg); … … 1036 1165 objects.content.find('tr').unbind('click.dynamicTable'); 1037 1166 objects.content.children().remove(); 1167 objects.contentContainer.scrollTop('0px'); 1038 1168 1039 1169 delete properties.loadedData; … … 1078 1208 } 1079 1209 1210 if(msg.total!=null && $.isArray(msg.total)) 1211 { 1212 properties.totalRowHasData=true; 1213 objects.totalRowTr.children().each( 1214 function (index) 1215 { 1216 $(this).html(msg.total[index]); 1217 } 1218 ); 1219 } 1220 else 1221 { 1222 properties.totalRowHasData=false; 1223 } 1224 1080 1225 if(options.click) 1081 1226 objects.content.find('tr').bind('click.dynamicTable', options.click); 1082 1227 1228 privateMethods.showTotalRow(object); 1083 1229 privateMethods.setColumnsSize(object); 1084 1230 privateMethods.displayLoading(object, false); … … 1088 1234 // 1089 1235 objects.loadingContent.attr('style', 'display:none;'); 1236 objects.loadingContentWorkInProgress.attr('style', 'display:none;'); 1090 1237 }, 1091 1238 } … … 1096 1243 { 1097 1244 var cols=[], 1245 options=object.data('options'), 1246 properties=object.data('properties'), 1098 1247 objects=object.data('objects'); 1099 1248 … … 1107 1256 ); 1108 1257 1109 1258 // resize first row of table content 1110 1259 objects.content.find('tr:first td').each( 1111 1260 function (index) … … 1125 1274 ); 1126 1275 1276 // resize total row if displayed 1277 if(options.showTotalRow=='visible' || 1278 options.showTotalRow=='auto' && properties.totalRowHasData) 1279 { 1280 objects.totalRowTr.find('td').each( 1281 function (index) 1282 { 1283 var style=''; 1284 1285 if(index==(cols.length-1)) 1286 { 1287 style='max-width:'; 1288 } 1289 else 1290 { 1291 style='width:'; 1292 } 1293 $(this).attr('style', style+cols[index]+'px;'); 1294 } 1295 ); 1296 } 1297 1127 1298 return(true); 1128 1299 }, //setColumnsSize … … 1135 1306 { 1136 1307 objects.loadingContent.attr('style', 'display:block;width:'+objects.contentContainer.width()+'px;height:'+objects.contentContainer.height()+'px;'); 1308 objects.loadingContentWorkInProgress.css( 1309 { 1310 'display':'block', 1311 'width':objects.contentContainer.width()+'px', 1312 'height':objects.contentContainer.height()+'px', 1313 'background-position':Math.round((objects.contentContainer.width()-16)/2)+'px '+Math.round((objects.contentContainer.height()-16)/2)+'px' 1314 } 1315 ); 1137 1316 } 1138 1317 else 1139 1318 { 1140 1319 objects.loadingContent.attr('style', 'display:none;'); 1320 objects.loadingContentWorkInProgress.attr('style', 'display:none;'); 1141 1321 } 1142 1322 }, //displayLoading 1143 1323 1144 updateNbItems: function (object)1324 showTotalRow : function (object) 1145 1325 { 1146 1326 var options=object.data('options'), … … 1148 1328 properties=object.data('properties'); 1149 1329 1330 switch(options.showTotalRow) 1331 { 1332 case 'visible': 1333 objects.totalRowContent.css('display', 'block'); 1334 break; 1335 case 'hidden': 1336 objects.totalRowContent.css('display', 'none'); 1337 break; 1338 case 'auto': 1339 if(properties.totalRowHasData) 1340 { 1341 objects.totalRowContent.css('display', 'block'); 1342 } 1343 else 1344 { 1345 objects.totalRowContent.css('display', 'none'); 1346 } 1347 break; 1348 } 1349 }, // showTotalRow 1350 1351 updateNbItems: function (object) 1352 { 1353 var options=object.data('options'), 1354 objects=object.data('objects'), 1355 properties=object.data('properties'); 1356 1150 1357 if(properties.nbItems>1) 1151 1358 { … … 1157 1364 } 1158 1365 1159 } 1366 } // updateNbItems 1160 1367 1161 1368 }; -
extensions/GrumPluginClasses/js/ui.inputFilterBox.js
r16012 r17562 644 644 multiple:($.inArray('in', options.filterOperators)>-1), 645 645 colsWidth:[], 646 colsCss:['col1', 'col2', 'col3'], 646 647 items:itemsList, 647 648 serverUrl:serverUrl,
Note: See TracChangeset
for help on using the changeset viewer.