diff --git a/javascript/CMSMain.js b/javascript/CMSMain.js index 19100584..dc1514ad 100644 --- a/javascript/CMSMain.js +++ b/javascript/CMSMain.js @@ -167,6 +167,30 @@ var ss_MainLayout; } }}); + /** + * @class Toggle display of group dropdown in "access" tab, + * based on selection of radiobuttons. + * @name ss.Form_EditForm.Access + */ + $('#Form_EditForm #CanViewType, #Form_EditForm #CanEditType').concrete('ss', function($){ + return/** @lends ss.Form_EditForm.Access */{ + onmatch: function() { + // TODO Decouple + var dropdown; + if(this.attr('id') == 'CanViewType') dropdown = $('#ViewerGroups'); + else if(this.attr('id') == 'CanEditType') dropdown = $('#EditorGroups'); + + this.find('.optionset :input').bind('change', function(e) { + dropdown.toggle(e.target.value == 'OnlyTheseUsers'); + }); + + // initial state + var currentVal = this.find('input[name=' + this.attr('id') + ']:checked').val(); + dropdown.toggle(currentVal == 'OnlyTheseUsers'); + } + } + }); + /** * @class Email containing the link to the archived version of the page. * Visible on readonly older versions of a specific page at the moment. diff --git a/javascript/SitetreeAccess.js b/javascript/SitetreeAccess.js deleted file mode 100644 index 2652b256..00000000 --- a/javascript/SitetreeAccess.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * UI behaviour for the "Access" tab - * - * Adapted from the forum module "ForumAccess.js" file. - * - * @author Markus Lanthaler - */ - -ViewersGroupHide = function() { - $('ViewerGroups').style.display = "none"; -} -EditorsGroupHide = function() { - $('EditorGroups').style.display = "none"; -} - -Behaviour.register({ - '#Form_EditForm_CanViewType_OnlyTheseUsers': { - - onclick: function() { - $('ViewerGroups').style.display = "block"; - }, - - initialize: function() { - if($('Form_EditForm_CanViewType_OnlyTheseUsers')) { - if($('Form_EditForm_CanViewType_OnlyTheseUsers').checked) - $('ViewerGroups').style.display = "block"; - else - $('ViewerGroups').style.display = "none"; - } - } - }, - '#Form_EditForm_CanViewType_Anyone': { - onclick: ViewersGroupHide - }, - '#Form_EditForm_CanViewType_LoggedInUsers': { - onclick: ViewersGroupHide - }, - '#Form_EditForm_CanViewType_Inherit': { - onclick: ViewersGroupHide - }, - - '#Form_EditForm_CanEditType_OnlyTheseUsers': { - - onclick: function() { - $('EditorGroups').style.display = "block"; - }, - - initialize: function() { - if($('Form_EditForm_CanEditType_OnlyTheseUsers')) { - if($('Form_EditForm_CanEditType_OnlyTheseUsers').checked) - $('EditorGroups').style.display = "block"; - else - $('EditorGroups').style.display = "none"; - } - } - }, - '#Form_EditForm_CanEditType_LoggedInUsers': { - onclick: EditorsGroupHide - }, - '#Form_EditForm_CanEditType_Inherit': { - onclick: EditorsGroupHide - } -}); \ No newline at end of file