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