Last active
October 26, 2015 21:57
-
-
Save pedrokoblitz/c9bd81b56a096d557ea2 to your computer and use it in GitHub Desktop.
esconde o link da tabela
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* checa se o username é igual ao do avaliador | |
* @param {string} username [description] | |
* @param {string} fieldText [description] | |
* @return {boolean} | |
*/ | |
var checkUsername = function (username, avaliadores) { | |
return ! avaliadores.indexOf(username) > -1; | |
}; | |
/** | |
* esconde o link .linkcompleto | |
* @param {node} element [description] | |
*/ | |
var hideLink = function (element) { | |
element.parent().find('td:last a').hide(); | |
}; | |
/** | |
* anda nas linhas da tabela, checa avaliadores e esconde o link se necessário | |
* @param {string} username [description] | |
* @param {array} rows [description] | |
*/ | |
var loopAndHide = function (username, rows) { | |
rows.each(function(key, item) { | |
var avaliadores = jQuery(this).find('.selaval'); | |
var nomeAvaliador = avaliadores.text(); | |
if (checkUsername(username, nomeAvaliador)) { | |
hideLink(avaliadores); | |
} | |
}); | |
}; | |
var rows = jQuery("#dev-table tr"); | |
var username = jQuery("#nome_usuario_logado").text() // '<?php $user = get_current_user(); echo $user->user_login; ?>' | |
loopAndHide(username, rows); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment