Skip to content

Instantly share code, notes, and snippets.

@killercup
Created August 26, 2008 19:27
Show Gist options
  • Save killercup/7323 to your computer and use it in GitHub Desktop.
Save killercup/7323 to your computer and use it in GitHub Desktop.
// part of my admin.js. requires jquery. to use it, just call the function.
// got the idea from: http://www.mahner.org/weblog/spass-mit-newforms-admin-automatische-felder/
function authorselection() {
/* If there is an author field, and it is set to a user, hide the selection
* and let the user have to click on "change" to change it. This takes one
* decision to make form the user, but keeps functionality.
*/
if (!($("div#content-main select[name='author'] option[@selected]").text() == "---------")) {
// $("div#content-main select[name='author']").hide();
$("div#content-main select[name='author'], div#content-main select[name='author'] + a#add_id_author").hide().parent().append(
'<p class="authorchangereplace"><strong>'
+ $("div#content-main select[name='author'] option[@selected]").text()
+ '</strong> <a href="#changeauthor" class="changeauthor">(Change)</a></p>'
);
}
$("div#content-main a.changeauthor").click(function(ev){
ev.preventDefault();
$(this).parent().remove();
$("div#content-main select[name='author'], div#content-main select[name='author'] + a#add_id_author").fadeIn(300);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment