Olá!
Que tal ter o mesmo sistema de mostrar e ocultar as categorias igual ao da versão Invision?
Eu sei que existem vários códigos com o mesmo propósito deste, mas nunca vi um que funcionasse em todas as versões, menos a Invision pois esse sistema já existe!
Abaixo o código para ser adicionado somente no "Índice":
Façam um teste! Eu espero que gostem,
JS
Que tal ter o mesmo sistema de mostrar e ocultar as categorias igual ao da versão Invision?
Eu sei que existem vários códigos com o mesmo propósito deste, mas nunca vi um que funcionasse em todas as versões, menos a Invision pois esse sistema já existe!
Abaixo o código para ser adicionado somente no "Índice":
- Código:
/***
* Application: toggle Category
* Description: Show/hide categories!
* Version: 0.02632015-jq1.9.1
* RC1 (Release candidate 1!) - Invision
* Author: JScript - 2015/03/26 - based on Invision.js
* This work is free. You can redistribute it and/or modify it
* under the terms of the WTFPL, Version 2
*/
$(function() {
var Autor = "JScript <jscriptbrasil at live dot com>, based on Invision.js";
style = document.createElement("style"),
//Versions: |phpBB2----------------------------------------| |phpBB3-------------| |PunBB-----------------| |Invision already have it!|
oCat = $('#content-container .three-col td:eq(1) .forumline, #main-content .forabg, #main-content .main-head, '),
oThis = null,
oTemp = null,
sEval = '';
style.type = "text/css";
style.innerHTML =
'.contract, .expand {' +
' background: url("http://2img.net/i/fa/invision/exp_minus.gif") no-repeat scroll 50% 50% rgba(0, 0, 0, 0);' +
' cursor: pointer;' +
' float: right;' +
' margin-top: 3px;' +
'}' +
'.expand {' +
' background: url("http://2img.net/i/fa/invision/exp_plus.gif") no-repeat scroll 50% 50% rgba(0, 0, 0, 0);' +
'}';
document.getElementsByTagName("head")[0].appendChild(style);
switch (oCat[0].className) {
case 'forumline': //phpBB2
sEval = "oTemp = oThis.find('tr').first();oTemp.addClass('title-bar');" +
"oTemp.find('th:last').append('<div onclick=\"toggleCategory(\\'c' + i + '\\');\" id=\"bc' + i + '\" class=\"contract\" style=\"margin-top: -15px;\"> </div>');" +
"oThis.find('tr').not('.title-bar').addClass('c' + i);";
break;
case 'forabg': //phpBB3
sEval = "oThis.find('ul.topiclist:first dl.icon').append('<div onclick=\"toggleCategory(\\'c' + i + '\\');\" id=\"bc' + i + '\" class=\"contract\"> </div>');" +
"oThis.find('ul.topiclist.forums').attr('id', 'c' + i);";
break;
case 'main-head': //PunBB
sEval = "oThis.find('h2').append('<div onclick=\"toggleCategory(\\'c' + i + '\\');\" id=\"bc' + i + '\" class=\"contract\"> </div>');" +
"oThis.next().attr('id', 'c' + i);";
break;
}
for (var i = 0, len = oCat.length; i < len; i++) {
oThis = $(oCat[i]);
eval(sEval);
}
initCategories();
});
// by invision.js
function initCategories() {
var id;
cookies = document.cookie.split('; ');
for (var i = 0; i < cookies.length; i++) {
if (cookies[i].charAt(0) == '_') {
cookie = cookies[i].split('=');
if (cookie[1] == '1') {
id = cookie[0].substring(1);
if (document.getElementById(id)) {
toggleCategory(id)
}
}
}
}
}
// by invision.js, modified by JScript
function toggleCategory(id) {
var obj = document.getElementById(id);
var button = document.getElementById('b' + id);
if (obj) {
var toggle = obj.style.display == 'none';
obj.style.display = toggle ? '' : 'none';
} else {
var elems = document.getElementsByClassName(id);
for (var i = 0, len = elems.length; i < len; i++) {
var toggle = elems[i].style.display == 'none';
elems[i].style.display = toggle ? '' : 'none';
}
}
button.className = toggle ? 'contract' : 'expand';
my_setcookie('_' + id, toggle ? '' : '1', true);
return false
}
Façam um teste! Eu espero que gostem,
JS