Skip to content
Snippets Groups Projects
Commit cf82a5b5 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

started jQuery port of ACL manager

parent 1c56be7b
No related branches found
No related tags found
No related merge requests found
/**
* ACL Manager AJAX enhancements
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
acl = {
/**
* Initialize the object and attach the event handlers
*
* @todo move to jQuery
*/
init: function(){
this.ctl = $('acl_manager');
if(!this.ctl) return;
......@@ -10,50 +20,39 @@ acl = {
addEvent($('acl__user').getElementsByTagName('input')[1],'click',acl.loadinfo);
},
/**
* Handle user dropdown
*
* Hides or shows the user/group entry box depending on wht was selected in the
* dropdown element
*/
userselhandler: function(e){
// make entry field visible/invisible
if(this.value == '__g__' || this.value == '__u__'){
$('acl__user').getElementsByTagName('input')[0].style.display = ''; //acl_w
$('acl__user').getElementsByTagName('input')[1].style.display = ''; //submit
jQuery('#acl__user input').show();
}else{
$('acl__user').getElementsByTagName('input')[0].style.display = 'none';
$('acl__user').getElementsByTagName('input')[1].style.display = 'none';
jQuery('#acl__user input').hide();
}
acl.loadinfo();
},
/**
* Load the current permission info and edit form
*
* @param frm - Form element with needed data
*/
loadinfo: function(){
// get form
var frm = $('acl__detail').getElementsByTagName('form')[0];
// prepare an AJAX call
var ajax = new sack(DOKU_BASE + 'lib/plugins/acl/ajax.php');
ajax.AjaxFailedAlert = '';
ajax.encodeURIString = false;
if(ajax.failed) return true;
// prepare data
var data = Array();
data[0] = ajax.encVar('ns',frm.elements['ns'].value);
data[1] = ajax.encVar('id',frm.elements['id'].value);
data[2] = ajax.encVar('acl_t',frm.elements['acl_t'].value);
data[3] = ajax.encVar('acl_w',frm.elements['acl_w'].value);
data[4] = ajax.encVar('sectok',frm.elements['sectok'].value);
data[5] = ajax.encVar('ajax','info');
ajax.elementObj = $('acl__info');
ajax.runAJAX(data.join('&'));
var frm = jQuery('#acl__detail form')[0];
jQuery('#acl__info').load(
DOKU_BASE + 'lib/plugins/acl/ajax.php',
{
'ns': frm.elements['ns'].value,
'id': frm.elements['id'].value,
'acl_t': frm.elements['acl_t'].value,
'acl_w': frm.elements['acl_w'].value,
'sectok': frm.elements['sectok'].value,
'ajax': 'info',
}
);
return false;
},
......@@ -92,37 +91,37 @@ acl = {
* Open or close a subtree using AJAX
*
* @author Andreas Gohr <andi@splitbrain.org>
* @param DOMElement clicky - the plus/minus icon in front of a namespace
*/
treetoggle: function(clicky){
var listitem = clicky.parentNode.parentNode;
var listitem = jQuery(clicky).parent().parent();
// if already open, close by removing the sublist
var sublists = listitem.getElementsByTagName('ul');
var sublists = listitem.find('ul');
if(sublists.length){
listitem.removeChild(sublists[0]);
listitem.remove('ul');
clicky.src = DOKU_BASE+'lib/images/plus.gif';
clicky.alt = '+';
return false;
}
// get the enclosed link (is always the first one)
var link = listitem.getElementsByTagName('a')[0];
// prepare new ul to load into it via ajax
var ul = document.createElement('ul');
listitem[0].appendChild(ul);
// prepare an AJAX call to fetch the subtree
var ajax = new sack(DOKU_BASE + 'lib/plugins/acl/ajax.php');
ajax.AjaxFailedAlert = '';
ajax.encodeURIString = false;
if(ajax.failed) return true;
// get the enclosed link and the edit form
var link = listitem.find('a')[0];
var frm = jQuery('#acl__detail form')[0];
// prepare ajax data
var data = acl.parseatt(link.search);
data['ajax'] = 'tree';
data['current_ns'] = frm.elements['ns'].value;
data['current_id'] = frm.elements['id'].value;
// run ajax
jQuery(ul).load(DOKU_BASE + 'lib/plugins/acl/ajax.php', data);
//prepare the new ul
var ul = document.createElement('ul');
listitem.appendChild(ul);
ajax.elementObj = ul;
ajax.setVar('ajax', 'tree');
var frm = $('acl__detail').getElementsByTagName('form')[0];
ajax.setVar('current_ns', encodeURIComponent(frm.elements['ns'].value));
ajax.setVar('current_id', encodeURIComponent(frm.elements['id'].value));
ajax.runAJAX(link.search.substr(1));
clicky.src = DOKU_BASE+'lib/images/minus.gif';
return false;
},
......@@ -130,6 +129,8 @@ acl = {
/**
* Handles all clicks in the tree, dispatching the right action based on the
* clicked element
*
* @todo move to jQuery
*/
treehandler: function(e){
if(e.target.src){ // is it an image?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment