Skip to content

Instantly share code, notes, and snippets.

@aj07mm
Created August 22, 2014 14:48
Show Gist options
  • Save aj07mm/9028da9654e894c42a99 to your computer and use it in GitHub Desktop.
Save aj07mm/9028da9654e894c42a99 to your computer and use it in GitHub Desktop.
Switcher = {
getNumberOfColumns: function(){
//menos as 5 columns default
//retorna só as colunas sem switch
return ($('td.tablesorter-header').length/2)-5;
},
getIncrementator:function(){
var i = 3;
for (var i = 1; i <= 5; i++) {
if(getNumberOfColumns() == i){
return i-2;
}
};
return 0;
},
showQtd:function(){
var i = this.getIncrementator();
var arr = $('td.tablesorter-header');
if(arr.length != 0){
//arr[0].textContent = 'Depto';
//arr[1].textContent = 'Depto - descricao';
arr[2+i].textContent = 'Qtde Compras 2013';
arr[3+i].textContent = 'Qtde Compras 2014';
arr[4+i].textContent = 'Qtde Venda Média';
arr[5+i].textContent = 'Qtde Estoque – D-1';
arr[6+i].textContent = 'Qtde Estoque Total';
}
_.map(document.getElementsByClassName('val'),function(num){
return num.style.display = 'none';
});
_.map(document.getElementsByClassName('qtd'),function(num){
return num.style.display = 'block';
});
},
showVal:function() {
var i = this.getIncrementator();
var arr = $('td.tablesorter-header');
if(arr.length != 0){
//arr[0].textContent = 'Depto';
//arr[1].textContent = 'Depto - descricao';
arr[2+i].textContent = '$ Compras 2013';
arr[3+i].textContent = '$ Compras 2014';
arr[4+i].textContent = '$ Venda Média';
arr[5+i].textContent = '$ Estoque – D-1';
arr[6+i].textContent = '$ Estoque Total';
}
_.map(document.getElementsByClassName('qtd'),function(num){
return num.style.display = 'none';
});
_.map(document.getElementsByClassName('val'),function(num){
return num.style.display = 'block';
});
}
}
$(document).ready(function(){
$("#chartSwitch").switchButton({
width: 80,
height: 30,
button_width: 50,
off_label: "VALOR",
on_label: "QUANTIDADE",
off_callback: Switcher.showVal,
on_callback: Switcher.showQtd
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment