Ignore:
Timestamp:
Aug 14, 2012, 9:55:13 PM (12 years ago)
Author:
grum
Message:

bug:2723
+ improve some GPC framework functionnalities

Location:
extensions/GrumPluginClasses/js
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/GrumPluginClasses/js/ui.dynamicTable.js

    r16012 r17562  
    5454                  options =
    5555                    {
     56                      autoLoad:true,
    5657                      columns:[],
    5758                      postUrl:'',
     
    6566                      currentPage:1,
    6667                      sortBoxTitle:'Sort by',
     68                      showTotalRow:'auto',     // visible, hidden, auto
    6769                      footerString:
    6870                        {
     
    9395                    sortedColumns:[],
    9496                    filteredColumns:[],
    95                     loadedData:[]
     97                    loadedData:[],
     98                    totalRowHasData:false
    9699                  }
    97100                );
     
    131134                        }
    132135                      ),
     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
    133149
    134150                    footer:$('<div/>',
     
    154170                  .append(objects.headerContainer.append(objects.header.append(objects.headerTr)))
    155171                  .append(objects.loadingContent)
     172                  .append(objects.loadingContentWorkInProgress)
    156173                  .append(objects.contentContainer.append(objects.content))
     174                  .append(objects.totalRowContent.append(objects.totalRowTr))
    157175                  .append(objects.footer
    158176                            .append(objects.footerNbItems)
     
    285303        }, // footerString
    286304
     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
    287349       currentPage: function (value)
    288350        {
     
    509571
    510572          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
    512592
    513593    }; // methods
     
    528608          properties.initialized=false;
    529609
     610          privateMethods.setAutoLoad(object, (value.autoLoad!=null)?value.autoLoad:options.autoLoad);
     611          privateMethods.setShowTotalRow(object, (value.showTotalRow!=null)?value.showTotalRow:options.showTotalRow);
    530612          privateMethods.setPostData(object, (value.postData!=null)?value.postData:options.postData);
    531613          privateMethods.setPostUrl(object, (value.postUrl!=null)?value.postUrl:options.postUrl);
     
    549631
    550632
    551 
    552           privateMethods.loadContent(object);
     633          if(options.autoLoad)
     634            privateMethods.loadContent(object);
    553635
    554636        },
     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
    555666
    556667      setColumns : function (object, value)
     
    827938
    828939      /*
    829        * update DOM for headers & footer
     940       * update DOM for headers & footer & total row
    830941       */
    831942      updateTable : function (object)
     
    840951
    841952          objects.headerTr.children().remove();
     953          objects.totalRowTr.children().remove();
    842954
    843955          properties.hasSortableButton=false;
     
    9301042
    9311043            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);
    9321048          }
    9331049
     
    9591075                            modal:true,
    9601076                            width:cWidth,
    961                             height:150,
     1077                            height:250,
    9621078                            autoHeight:false,
    9631079                            title:options.sortBoxTitle,
     
    9821098                ).append(button);
    9831099            objects.headerTr.append(td);
     1100
     1101            td=$('<td/>');
     1102            objects.totalRowTr.append(td);
    9841103          }
    9851104        }, //updateTable
    9861105
    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)
    9891112        {
    9901113          var data=null,
     
    9971120          if(options.postUrl=='') return(false);
    9981121
     1122          if(page>0 && page <= objects.footerPagesNavigator.inputPages('nbPages'))
     1123            options.currentPage=page;
    9991124          privateMethods.displayLoading(object, true);
    10001125
     
    10301155                  msg=$.parseJSON(msg);
    10311156
    1032                   if(msg==null) return(false);
     1157                  if(msg==null || msg.rows==null)
     1158                  {
     1159                    privateMethods.displayLoading(object, false);
     1160                    return(false);
     1161                  }
    10331162
    10341163                  if(options.contentLoaded) object.trigger('dynamicTableContentLoaded', msg);
     
    10361165                  objects.content.find('tr').unbind('click.dynamicTable');
    10371166                  objects.content.children().remove();
     1167                  objects.contentContainer.scrollTop('0px');
    10381168
    10391169                  delete properties.loadedData;
     
    10781208                  }
    10791209
     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
    10801225                  if(options.click)
    10811226                    objects.content.find('tr').bind('click.dynamicTable', options.click);
    10821227
     1228                  privateMethods.showTotalRow(object);
    10831229                  privateMethods.setColumnsSize(object);
    10841230                  privateMethods.displayLoading(object, false);
     
    10881234                  //
    10891235                  objects.loadingContent.attr('style', 'display:none;');
     1236                  objects.loadingContentWorkInProgress.attr('style', 'display:none;');
    10901237                },
    10911238            }
     
    10961243        {
    10971244          var cols=[],
     1245              options=object.data('options'),
     1246              properties=object.data('properties'),
    10981247              objects=object.data('objects');
    10991248
     
    11071256          );
    11081257
    1109 
     1258          // resize first row of table content
    11101259          objects.content.find('tr:first td').each(
    11111260            function (index)
     
    11251274          );
    11261275
     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
    11271298          return(true);
    11281299        }, //setColumnsSize
     
    11351306          {
    11361307            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            );
    11371316          }
    11381317          else
    11391318          {
    11401319            objects.loadingContent.attr('style', 'display:none;');
     1320            objects.loadingContentWorkInProgress.attr('style', 'display:none;');
    11411321          }
    11421322        }, //displayLoading
    11431323
    1144       updateNbItems: function (object)
     1324      showTotalRow : function (object)
    11451325        {
    11461326          var options=object.data('options'),
     
    11481328              properties=object.data('properties');
    11491329
     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
    11501357          if(properties.nbItems>1)
    11511358          {
     
    11571364          }
    11581365
    1159         }
     1366        } // updateNbItems
    11601367
    11611368    };
  • extensions/GrumPluginClasses/js/ui.inputFilterBox.js

    r16012 r17562  
    644644                  multiple:($.inArray('in', options.filterOperators)>-1),
    645645                  colsWidth:[],
     646                  colsCss:['col1', 'col2', 'col3'],
    646647                  items:itemsList,
    647648                  serverUrl:serverUrl,
Note: See TracChangeset for help on using the changeset viewer.