[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/jscripts/ -> inline_reports.js (source)

   1  var inlineReports = {
   2      init: function()
   3      {
   4          inlineReports.cookieName = 'inlinereports';
   5          var inputs = $('input');
   6  
   7          if(!inputs.length)
   8          {
   9              return false;
  10          }
  11  
  12          var inlineIds = inlineReports.getCookie(inlineReports.cookieName);
  13          var removedIds = inlineReports.getCookie(inlineReports.cookieName+'_removed');
  14          var allChecked = true;
  15  
  16          $(inputs).each(function() {
  17              var element = $(this);
  18              if((element.attr('name') != 'allbox') && (element.attr('type') == 'checkbox') && (element.attr('id')) && (element.attr('id').split('_')[0] == 'reports'))
  19              {
  20                  $(element).on('click', inlineReports.checkItem);
  21              }
  22  
  23              if(element.attr('id'))
  24              {
  25                  var inlineCheck = element.attr('id').split('_');
  26                  var id = inlineCheck[1];
  27  
  28                  if(inlineCheck[0] == 'reports')
  29                  {
  30                      if(inlineIds.indexOf(id) != -1 || (inlineIds.indexOf('ALL') != -1 && removedIds.indexOf(id) == -1))
  31                      {
  32                          element.prop('checked', true);
  33                          var report = element.parents('.inline_row');
  34                          if(report.length)
  35                          {
  36                              report.addClass('trow_selected');
  37                          }
  38                      }
  39                      else
  40                      {
  41                          element.prop('checked', false);
  42                          var report = element.parents('.inline_row');
  43                          if(report.length)
  44                          {
  45                              report.removeClass('trow_selected');
  46                          }
  47                      }
  48                      allChecked = false;
  49                  }
  50              }
  51          });
  52  
  53          inlineReports.updateCookies(inlineIds, removedIds);
  54  
  55          if(inlineIds.indexOf('ALL') != -1 && removedIds.length == 0)
  56          {
  57              var allSelectedRow = $('#allSelectedrow');
  58              if(allSelectedRow)
  59              {
  60                  allSelectedRow.show();
  61              }
  62          }
  63          else if(inlineIds.indexOf('ALL') == -1 && allChecked == true)
  64          {
  65              var selectRow = $('#selectAllrow');
  66              if(selectRow)
  67              {
  68                  selectRow.show();
  69              }
  70          }
  71          return true;
  72      },
  73  
  74      checkItem: function()
  75      {
  76          var element = $(this);
  77  
  78          if(!element || !element.attr('id'))
  79          {
  80              return false;
  81          }
  82  
  83          var inlineCheck = element.attr('id').split('_');
  84          var id = inlineCheck[1];
  85  
  86          if(!id)
  87          {
  88              return false;
  89          }
  90  
  91          var inlineIds = inlineReports.getCookie(inlineReports.cookieName);
  92          var removedIds = inlineReports.getCookie(inlineReports.cookieName+'_removed');
  93  
  94          if(element.prop('checked') == true)
  95          {
  96              if(inlineIds.indexOf('ALL') == -1)
  97              {
  98                  inlineIds = inlineReports.addId(inlineIds, id);
  99              }
 100              else
 101              {
 102                  removedIds = inlineReports.removeId(removedIds, id);
 103                  if(removedIds.length == 0)
 104                  {
 105                      var allSelectedRow = $('#allSelectedrow');
 106                      if(allSelectedRow)
 107                      {
 108                          allSelectedRow.show();
 109                      }
 110                  }
 111              }
 112              var report = element.parents('.inline_row');
 113              if(report.length)
 114              {
 115                  report.addClass('trow_selected');
 116              }
 117          }
 118          else
 119          {
 120              if(inlineIds.indexOf('ALL') == -1)
 121              {
 122                  inlineIds = inlineReports.removeId(inlineIds, id);
 123                  var selectRow = $('#selectAllrow');
 124                  if(selectRow)
 125                  {
 126                      selectRow.hide();
 127                  }
 128              }
 129              else
 130              {
 131                  removedIds = inlineReports.addId(removedIds, id);
 132                  var allSelectedRow = $('#allSelectedrow');
 133                  if(allSelectedRow)
 134                  {
 135                      allSelectedRow.hide();
 136                  }
 137              }
 138              var report = element.parents('.inline_row');
 139              if(report.length)
 140              {
 141                  report.removeClass('trow_selected');
 142              }
 143          }
 144  
 145          inlineReports.updateCookies(inlineIds, removedIds);
 146  
 147          return true;
 148      },
 149  
 150      clearChecked: function()
 151      {
 152          $('#selectAllrow').hide();
 153          $('#allSelectedrow').hide();
 154  
 155          var inputs = $('input');
 156  
 157          if(!inputs.length)
 158          {
 159              return false;
 160          }
 161  
 162          $(inputs).each(function() {
 163              var element = $(this);
 164              if(!element.val()) return;
 165              if(element.attr('type') == 'checkbox' && ((element.attr('id') && element.attr('id').split('_')[0] == 'reports') || element.attr('name') == 'allbox'))
 166              {
 167                  element.prop('checked', false);
 168              }
 169          });
 170  
 171          $('.trow_selected').each(function() {
 172              $(this).removeClass('trow_selected');
 173          });
 174  
 175          $('#inline_read').val(mark_read_text+' (0)');
 176          Cookie.unset(inlineReports.cookieName);
 177          Cookie.unset(inlineReports.cookieName + '_removed');
 178  
 179          return true;
 180      },
 181  
 182      checkAll: function(master)
 183      {
 184          inputs = $('input');
 185          master = $(master);
 186  
 187          if(!inputs.length)
 188          {
 189              return false;
 190          }
 191  
 192          var inlineIds = inlineReports.getCookie(inlineReports.cookieName);
 193          var removedIds = inlineReports.getCookie(inlineReports.cookieName+'_removed');
 194  
 195          var newIds = new Array();
 196          $(inputs).each(function() {
 197              var element = $(this);
 198              if(!element.val() || !element.attr('id')) return;
 199              inlineCheck = element.attr('id').split('_');
 200              if((element.attr('name') != 'allbox') && (element.attr('type') == 'checkbox') && (inlineCheck[0] == 'reports'))
 201              {
 202                  var id = inlineCheck[1];
 203                  var changed = (element.prop('checked') != master.prop('checked'));
 204                  element.prop('checked', master.prop('checked'));
 205  
 206                  var report = element.parents('.inline_row');
 207                  if(report.length)
 208                  {
 209                      if(master.prop('checked') == true)
 210                      {
 211                          report.addClass('trow_selected');
 212                      }
 213                      else
 214                      {
 215                          report.removeClass('trow_selected');
 216                      }
 217                  }
 218  
 219                  if(changed)
 220                  {
 221                      if(master.prop('checked') == true)
 222                      {
 223                          if(inlineIds.indexOf('ALL') == -1)
 224                          {
 225                              inlineIds = inlineReports.addId(inlineIds, id);
 226                          }
 227                          else
 228                          {
 229                              removedIds = inlineReports.removeId(removedIds, id);
 230                          }
 231                      }
 232                      else
 233                      {
 234                          if(inlineIds.indexOf('ALL') == -1)
 235                          {
 236                              inlineIds = inlineReports.removeId(inlineIds, id);
 237                          }
 238                          else
 239                          {
 240                              removedIds = inlineReports.addId(removedIds, id);
 241                          }
 242                      }
 243                  }
 244              }
 245          });
 246  
 247          var count = inlineReports.updateCookies(inlineIds, removedIds);
 248  
 249          if(count < all_text)
 250          {
 251              var selectRow = $('#selectAllrow');
 252              if(selectRow.length)
 253              {
 254                  if(master.prop('checked') == true)
 255                  {
 256                      selectRow.show();
 257                  }
 258                  else
 259                  {
 260                      selectRow.hide();
 261                  }
 262              }
 263          }
 264  
 265          if(inlineIds.indexOf('ALL') == -1 || removedIds.length != 0)
 266          {
 267              $('#allSelectedrow').hide();
 268          }
 269          else if(inlineIds.indexOf('ALL') != -1 && removedIds.length == 0)
 270          {
 271              $('#allSelectedrow').show();
 272          }
 273      },
 274  
 275      selectAll: function()
 276      {
 277          inlineReports.updateCookies(new Array('ALL'), new Array());
 278  
 279          $('#selectAllrow').hide();
 280          $('#allSelectedrow').show();
 281      },
 282  
 283      getCookie: function(name)
 284      {
 285          var inlineCookie = Cookie.get(name);
 286  
 287          var ids = new Array();
 288          if(inlineCookie)
 289          {
 290              var inlineIds = inlineCookie.split('|');
 291              $.each(inlineIds, function(index, item) {
 292                  if(item != '' && item != null)
 293                  {
 294                      ids.push(item);
 295                  }
 296              });
 297          }
 298          return ids;
 299      },
 300  
 301      setCookie: function(name, array)
 302      {
 303          if(array.length != 0)
 304          {
 305              var data = '|'+array.join('|')+'|';
 306              Cookie.set(name, data, 60 * 60 * 1000);
 307          }
 308          else
 309          {
 310              Cookie.unset(name);
 311          }
 312      },
 313  
 314      updateCookies: function(inlineIds, removedIds)
 315      {
 316          if(inlineIds.indexOf('ALL') != -1)
 317          {
 318              var count = all_text - removedIds.length;
 319          }
 320          else
 321          {
 322              var count = inlineIds.length;
 323          }
 324          if(count < 0)
 325          {
 326              count = 0;
 327          }
 328          $('#inline_read').val(mark_read_text+' ('+count+')');
 329          if(count == 0)
 330          {
 331              inlineReports.clearChecked();
 332          }
 333          else
 334          {
 335              inlineReports.setCookie(inlineReports.cookieName, inlineIds);
 336              inlineReports.setCookie(inlineReports.cookieName+'_removed', removedIds);
 337          }
 338          return count;
 339      },
 340  
 341      addId: function(array, id)
 342      {
 343          if(array.indexOf(id) == -1)
 344          {
 345              array.push(id);
 346          }
 347          return array;
 348      },
 349  
 350      removeId: function(array, id)
 351      {
 352          var position = array.indexOf(id);
 353          if(position != -1)
 354          {
 355              array.splice(position, 1);
 356          }
 357          return array;
 358      }
 359  };
 360  
 361  $(inlineReports.init);


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref