forked from boonebgorges/bp-groupblog
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retools JS a bit to be more modular, and so that the 'Enable Group Bl…
…og' item gets checked properly when an error occurs during creation
- Loading branch information
1 parent
d753329
commit d88209c
Showing
1 changed file
with
38 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); |