includes/clientside/static/acl.js
changeset 73 0a74676a2f2f
parent 42 45ebe475ff75
child 74 68469a95658d
equal deleted inserted replaced
72:bda11e521e8a 73:0a74676a2f2f
   139   // Scope selector
   139   // Scope selector
   140   if(do_scopesel)
   140   if(do_scopesel)
   141   {
   141   {
   142     scopediv1 = document.createElement('div');
   142     scopediv1 = document.createElement('div');
   143     scopediv2 = document.createElement('div');
   143     scopediv2 = document.createElement('div');
       
   144     scopediv3 = document.createElement('div');
   144     scopeRadioPage = document.createElement('input');
   145     scopeRadioPage = document.createElement('input');
   145       scopeRadioPage.type = 'radio';
   146       scopeRadioPage.type = 'radio';
   146       scopeRadioPage.name = 'scope';
   147       scopeRadioPage.name = 'scope';
   147       scopeRadioPage.value = 'page';
   148       scopeRadioPage.value = 'page';
   148       scopeRadioPage.checked = 'checked';
   149       scopeRadioPage.checked = 'checked';
       
   150       scopeRadioPage.className = '1048576';
       
   151       scopeRadioPage.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'none'; };
   149     scopeRadioGlobal = document.createElement('input');
   152     scopeRadioGlobal = document.createElement('input');
   150       scopeRadioGlobal.type = 'radio';
   153       scopeRadioGlobal.type = 'radio';
   151       scopeRadioGlobal.name = 'scope';
   154       scopeRadioGlobal.name = 'scope';
   152       scopeRadioGlobal.value = 'global';
   155       scopeRadioGlobal.value = 'global';
       
   156       scopeRadioGlobal.className = '1048576';
       
   157       scopeRadioGlobal.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'none'; };
       
   158     scopeRadioGroup = document.createElement('input');
       
   159       scopeRadioGroup.type = 'radio';
       
   160       scopeRadioGroup.name = 'scope';
       
   161       scopeRadioGroup.value = 'group';
       
   162       scopeRadioGroup.className = '1048576';
       
   163       scopeRadioGroup.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'block'; };
   153     lblPage = document.createElement('label');
   164     lblPage = document.createElement('label');
   154       lblPage.style.display = 'block';
   165       lblPage.style.display = 'block';
   155       lblPage.appendChild(scopeRadioPage);
   166       lblPage.appendChild(scopeRadioPage);
   156       lblPage.appendChild(document.createTextNode('Only this page'));
   167       lblPage.appendChild(document.createTextNode('Only this page'));
   157     lblGlobal = document.createElement('label');
   168     lblGlobal = document.createElement('label');
   158       lblGlobal.style.display = 'block';
   169       lblGlobal.style.display = 'block';
   159       lblGlobal.appendChild(scopeRadioGlobal);
   170       lblGlobal.appendChild(scopeRadioGlobal);
   160       lblGlobal.appendChild(document.createTextNode('The entire website'));
   171       lblGlobal.appendChild(document.createTextNode('The entire website'));
       
   172     lblGroup = document.createElement('label');
       
   173       lblGroup.style.display = 'block';
       
   174       lblGroup.appendChild(scopeRadioGroup);
       
   175       lblGroup.appendChild(document.createTextNode('A group of pages'));
   161     scopediv1.appendChild(lblPage);
   176     scopediv1.appendChild(lblPage);
   162     scopediv2.appendChild(lblGlobal);
   177     scopediv2.appendChild(lblGroup);
       
   178     scopediv3.appendChild(lblGlobal);
   163     
   179     
   164     scopedesc = document.createElement('p');
   180     scopedesc = document.createElement('p');
   165     scopedesc.appendChild(document.createTextNode('What should this access rule control?'));
   181     scopedesc.appendChild(document.createTextNode('What should this access rule control?'));
       
   182     
       
   183     scopePGrp = document.createElement('select');
       
   184     scopePGrp.style.marginLeft = '13px';
       
   185     scopePGrp.style.display = 'none';
       
   186     scopePGrp.id = "enACL_pgsel_1048576";
       
   187     
       
   188     var opt;
       
   189     for ( var i = 0; i < groups.page_groups.length; i++ )
       
   190     {
       
   191       opt = document.createElement('option');
       
   192       opt.value = groups.page_groups[i].id;
       
   193       opt.appendChild(document.createTextNode(groups.page_groups[i].name));
       
   194       scopePGrp.appendChild(opt);
       
   195     }
       
   196     
       
   197     scopediv2.appendChild(scopePGrp);
       
   198     
   166   }
   199   }
   167   
   200   
   168   // Styles
   201   // Styles
   169   span.style.marginLeft = '13px';
   202   span.style.marginLeft = '13px';
   170   span.style.padding = '5px 0';
   203   span.style.padding = '5px 0';
   178   selector.appendChild(span2);
   211   selector.appendChild(span2);
   179   
   212   
   180   container = document.createElement('div');
   213   container = document.createElement('div');
   181   container.style.margin = 'auto';
   214   container.style.margin = 'auto';
   182   container.style.width = '360px';
   215   container.style.width = '360px';
   183   container.style.paddingTop = '100px';
   216   container.style.paddingTop = '50px';
   184   
   217   
   185   head = document.createElement('h2');
   218   head = document.createElement('h2');
   186   head.appendChild(document.createTextNode('Manage page access'));
   219   head.appendChild(document.createTextNode('Manage page access'));
   187   
   220   
   188   desc = document.createElement('p');
   221   desc = document.createElement('p');
   195   if(do_scopesel)
   228   if(do_scopesel)
   196   {
   229   {
   197     container.appendChild(scopedesc);
   230     container.appendChild(scopedesc);
   198     container.appendChild(scopediv1);
   231     container.appendChild(scopediv1);
   199     container.appendChild(scopediv2);
   232     container.appendChild(scopediv2);
       
   233     container.appendChild(scopediv3);
   200   }
   234   }
   201   
   235   
   202   main.appendChild(container);
   236   main.appendChild(container);
   203   
   237   
   204   var mode = document.createElement('input');
   238   var mode = document.createElement('input');
   589         else if(scope == 'global')
   623         else if(scope == 'global')
   590         {
   624         {
   591           obj['page_id'] = false;
   625           obj['page_id'] = false;
   592           obj['namespace'] = false;
   626           obj['namespace'] = false;
   593         }
   627         }
       
   628         else if(scope == 'group')
       
   629         {
       
   630           obj['page_id'] = document.getElementById('enACL_pgsel_1048576').value;
       
   631           obj['namespace'] = '__PageGroup';
       
   632         }
   594         else
   633         else
   595         {
   634         {
   596           alert('Invalid scope');
   635           alert('Invalid scope');
   597           return false;
   636           return false;
   598         }
   637         }