Skip to content

Commit

Permalink
Retools JS a bit to be more modular, and so that the 'Enable Group Bl…
Browse files Browse the repository at this point in the history
…og' item gets checked properly when an error occurs during creation
  • Loading branch information
boonebgorges committed Nov 22, 2011
1 parent d753329 commit d88209c
Showing 1 changed file with 38 additions and 25 deletions.
63 changes: 38 additions & 25 deletions groupblog/js/general.js
@@ -1,31 +1,44 @@
jQuery(document).ready( function() {

jQuery('input[name=groupblog-enable-blog]').click(function(){
if (jQuery(this).is(':checked')) {
jQuery('input[name=groupblog-create-new]').removeAttr('disabled');
jQuery('select[name=groupblog-blogid]').removeAttr('disabled');
jQuery('input[name=groupblog-silent-add]').removeAttr('disabled');
jQuery('#groupblog-layout-options input[type=radio]').removeAttr('disabled');
if (jQuery('input[name=groupblog-silent-add]').is(':checked')) {
jQuery('#groupblog-member-options input[type=radio]').removeAttr('disabled');
} else {
jQuery('#groupblog-member-options input[type=radio]').attr('disabled','true');
}
} else {
jQuery('input[name=groupblog-create-new]').attr('disabled','true');
jQuery('select[name=groupblog-blogid]').attr('disabled','true');
jQuery('input[name=groupblog-silent-add]').attr('disabled','true');
jQuery('#groupblog-member-options input[type=radio]').attr('disabled','true');
jQuery('#groupblog-layout-options input[type=radio]').attr('disabled','true');
}
jQuery(document).ready( function($) {
$('input[name=groupblog-enable-blog]').click(function(){
bpgb_toggle_options(this);
});

jQuery('input[name=groupblog-silent-add]').click(function(){
if (jQuery(this).is(':checked')) {
jQuery('#groupblog-member-options input[type=radio]').removeAttr('disabled');
$('input[name=groupblog-silent-add]').click(function(){
if ($(this).is(':checked')) {
$('#groupblog-member-options input[type=radio]').removeAttr('disabled');
} else {
jQuery('#groupblog-member-options input[type=radio]').attr('disabled','true');
$('#groupblog-member-options input[type=radio]').attr('disabled','true');
}
});

var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
if ( 'create_error' == hash[0] ) {
var b = $('input[name=groupblog-enable-blog]');
$(b).attr('checked','checked');
bpgb_toggle_options(b);
}
}

function bpgb_toggle_options(a) {
if ($(a).is(':checked')) {
$('input[name=groupblog-create-new]').removeAttr('disabled');
$('select[name=groupblog-blogid]').removeAttr('disabled');
$('input[name=groupblog-silent-add]').removeAttr('disabled');
$('#groupblog-layout-options input[type=radio]').removeAttr('disabled');
if ($('input[name=groupblog-silent-add]').is(':checked')) {
$('#groupblog-member-options input[type=radio]').removeAttr('disabled');
} else {
$('#groupblog-member-options input[type=radio]').attr('disabled','true');
}
} else {
$('input[name=groupblog-create-new]').attr('disabled','true');
$('select[name=groupblog-blogid]').attr('disabled','true');
$('input[name=groupblog-silent-add]').attr('disabled','true');
$('#groupblog-member-options input[type=radio]').attr('disabled','true');
$('#groupblog-layout-options input[type=radio]').attr('disabled','true');
}
}

});
},(jQuery));

0 comments on commit d88209c

Please sign in to comment.