Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted October 20, 201311 yr Hello, I wanted to propose the inclusion of a set of functions that allow you to install a checkbox in topicview template making sure that when clicked will select all posts of that page! For example : /************************************************/ /* IPB3 Javascript */ /* -------------------------------------------- */ /* ips.topic.js - Topic view code */ /* © IPS, Inc 2008 */ /* -------------------------------------------- */ /* Author: Rikki Tissier */ /************************************************/ var _topic = window.IPBoard; _topic.prototype.topic = { totalChecked: 0, inSection: '', topic_id: 0, page_id: 0, postcache: [], poll: [], pollPopups: [], deletePerms: {}, deleteUrls: {}, deletePopUps: [], hidePopUps: [], restorePopUps: [], counts: {}, timers: {}, polling: { count: 0 }, mqBoxShowing: false, fastReplyId: '', isPosting: false, modOptionsUnapproved: 0, modOptionsHidden: 0, modOptionsUnhidden: 0, init: function() { Debug.write("Initializing ips.topic.js"); document.observe("dom:loaded", function(){ if( ipb.topic.inSection == 'topicview' ) { /* Check to see if we want a PID but it doesn't exist on this page */ if ( window.location.hash.substring(1).match( /entry/ ) ) { var pid = window.location.hash.substring(1).replace(/entry/, ''); if ( ipb.topic.redirectPost && pid && $$('a[data-entry-pid]').length && ! $$('a[data-entry-pid="' + pid + '"]').length ) { window.location = ipb.vars['board_url'] + '/index.php?app=forums&module=forums§ion=findpost&pid=' + pid + '&t=' + ipb.topic.topic_id; } } /* Scroll to a post? */ if ( ! pid ) { pid = getQueryStringParamByName('p'); } if ( pid && $('entry' + pid ) ) { ipb.topic.scrollToPost( parseInt( pid ) ); } ipb.delegate.register('a[data-entry-pid]', ipb.topic.launchPostShare ); if( $('show_filters') ) { $('show_filters').observe('click', ipb.topic.toggleFilters ); $('filter_form').hide(); } ipb.topic.preCheckPosts(); // Set up delegates ipb.delegate.register('.multiquote', ipb.topic.toggleMultimod); ipb.delegate.register('._ips_trigger_quote', ipb.topic.ajaxQuote); ipb.delegate.register('.edit_post', ipb.topic.ajaxEditShow); ipb.delegate.register('.hide_post', ipb.topic.hidePopUp); ipb.delegate.register('.delete_post', ipb.topic.deletePopUp); ipb.delegate.register('.toggle_post', ipb.topic.ajaxTogglePostApprove); ipb.delegate.register('.sd_content', ipb.topic.sDeletePostShow); ipb.delegate.register('.sd_remove', ipb.topic.confirmSingleDelete); ipb.delegate.register('input.post_mod', ipb.topic.checkPost); ipb.delegate.register('.modlink_09', ipb.topic.topicDeletePopUp ); /* Answer stuffs */ //ipb.delegate.register('[data-post-button=answer]', ipb.topic.QA_answer ); if ( $('submit_post') ){ $('submit_post').observe( "click", ipb.topic.ajaxFastReply ); } // Check for existing multi-quoted posts try { quoted = ipb.Cookie.get('mqtids').split(',').compact().without('').size(); } catch(err){ quoted = 0; } // Show button if we have quoted posts if( quoted ) { $('multiQuoteInsert').show(); ipb.topic.mqBoxShowing = true; $('mqbutton').update( ipb.lang['mq_reply_swap'].replace( /#{num}/, quoted ) ); } // Set up MQ handler if( $('multiQuoteInsert') ){ $('mqbutton').observe( 'click', ipb.topic.insertQuotedPosts ); if( $('multiQuoteClear') ){ $('multiQuoteClear').on('click', ipb.topic.clearMultiQuote); } } } else if( ipb.topic.inSection == 'searchview' ) { ipb.delegate.register('input.post_mod', ipb.topic.checkPost); ipb.delegate.register('.sd_content', ipb.topic.sDeletePostShow); } }); /* Do this regardless */ ipb.delegate.register('.hide_signature', ipb.topic.signatureCloseClick); }, /* ------------------------------ */ /** * Reads the cookie and checks posts as necessary */ preCheckPosts: function() { if (!$('selectedpidsJS') || !$F('selectedpidsJS')) { return true; } // Get the cookie pids = $F('selectedpidsJS').split(','); if (pids) { pids.each(function(pid) { if (!pid.blank()) { if ($('checkbox_' + pid)) { ipb.topic.checkPost(this, $('checkbox_' + pid)); $('checkbox_' + pid).checked = true; } else { ipb.topic.totalChecked++; } } }); } ipb.topic.updatePostModButton(); }, /* ------------------------------ */ /** * Checks a post * * @var {event} e The event */ checkPost: function(e, check) { Debug.write("Check post"); remove = $A(); data = $F('selectedpidsJS'); if (data != null) { pids = data.split(',') || $A(); } else { pids = $A(); } if (check.checked == true) { pids.push(check.id.replace('checkbox_', '')); ipb.topic.totalChecked++; switch (check.readAttribute("data-status")) { case '1': ipb.topic.modOptionsUnapproved += 1; break; case '2': ipb.topic.modOptionsHidden += 1; break; default: ipb.topic.modOptionsUnhidden += 1; break; } } else { remove.push(check.id.replace('checkbox_', '')); ipb.topic.totalChecked--; switch (check.readAttribute("data-status")) { case '1': ipb.topic.modOptionsUnapproved -= 1; break; case '2': ipb.topic.modOptionsHidden -= 1; break; default: ipb.topic.modOptionsUnhidden -= 1; break; } } pids = pids.uniq().without(remove).join(','); ipb.Cookie.set('modpids', pids, 0); $('selectedpidsJS').value = pids; ipb.topic.updatePostModButton(); }, ipb.topic.init(); please integrate this modification into next release of ipb 3.4.x also because prototype with 4.x not serve more fuss
October 21, 201311 yr Author example now i have changed into /*ipb.topic.preCheckPosts(); INTO*/ if( $('pmod_all') ) { ipb.topic.preCheckPosts(); $('pmod_all').observe( 'click', ipb.topic.checkAllPosts ); } else { ipb.topic.preCheckPosts(); } And I have added before 1125 line this part checkAllPosts: function(e) { Debug.write('checkAllPosts'); check = Event.findElement(e, 'input'); toCheck = $F(check); ipb.topic.totalChecked = 0; toRemove = new Array(); selectedPosts = $F('selectedpidsJS').split(',').compact(); $$('input.post_mod[name*=selectedpids]').each( function(check){ if( toCheck != null ) { check.checked = true; selectedPosts.push( check.id.replace('checkbox_', '') ); ipb.topic.totalChecked++; } else { toRemove.push( check.id.replace('checkbox_', '') ); check.checked = false; } }); selectedPosts = selectedPosts.uniq(); if( toRemove.length >= 1 ) { for( i=0; i<toRemove.length; i++ ) { //selectedPosts = selectedPosts.without( parseInt( toRemove ) ); idToBeRemoved = parseInt( toRemove ); if ( ! isNaN( idToBeRemoved ) ) { // without not so hot in Chrome _selectedPosts = selectedPosts; selectedPosts = $A(); _selectedPosts.each( function( item ) { if ( idToBeRemoved != item ) { selectedPosts.push( item ); } } ); } } } selectedPosts = selectedPosts.join(','); ipb.Cookie.set('modpids', selectedPosts, 0); $('selectedpidsJS').value = selectedPosts; ipb.topic.updatePostModButton(); },adding now into topicViewTemplate this html <if test="$this->memberData['is_mod'] == 1"> <span class='right'> <input type='checkbox' id='pmod_all' class='input_check' title='{$this->lang->words['post_select_all']}' value='1' /> </span> </if> IT WORK!
Archived
This topic is now archived and is closed to further replies.