make tidy-js (#683)

This commit is contained in:
Clément Oudot 2014-02-05 16:30:30 +00:00
parent 6a72659c95
commit d18840122f
9 changed files with 1451 additions and 1317 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5,15 +5,17 @@
*/ */
function displayNotification(id) { function displayNotification(id) {
$.ajax({ $.ajax({
type:"POST", type: "POST",
url:scriptname, url: scriptname,
data:{'notification':id}, data: {
dataType:'html', 'notification': id
success:function(data){ },
dataType: 'html',
success: function(data) {
$('#data').html(data); $('#data').html(data);
}, },
error:function(xhr, ajaxOptions, thrownError){ error: function(xhr, ajaxOptions, thrownError) {
$('#data').html('<h3>Request failed</h3> Error code: '+xhr.status+', '+thrownError); $('#data').html('<h3>Request failed</h3> Error code: ' + xhr.status + ', ' + thrownError);
} }
}); });
} }
@ -25,15 +27,17 @@ function displayNotification(id) {
*/ */
function displayNotificationDone(id) { function displayNotificationDone(id) {
$.ajax({ $.ajax({
type:"POST", type: "POST",
url:scriptname, url: scriptname,
data:{'notificationDone':id}, data: {
dataType:'html', 'notificationDone': id
success:function(data){ },
dataType: 'html',
success: function(data) {
$('#data').html(data); $('#data').html(data);
}, },
error:function(xhr, ajaxOptions, thrownError){ error: function(xhr, ajaxOptions, thrownError) {
$('#data').html('<h3>Request failed</h3> Error code: '+xhr.status+', '+thrownError); $('#data').html('<h3>Request failed</h3> Error code: ' + xhr.status + ', ' + thrownError);
} }
}); });
} }
@ -45,16 +49,18 @@ function displayNotificationDone(id) {
*/ */
function del(id) { function del(id) {
$.ajax({ $.ajax({
type:"POST", type: "POST",
url:scriptname, url: scriptname,
data:{'delete':id}, data: {
dataType:'html', 'delete': id
success:function(data){
$('#data').html(data);
$('#uid'+id).remove();
}, },
error:function(xhr, ajaxOptions, thrownError){ dataType: 'html',
$('#data').html('<h3>Request failed</h3> Error code: '+xhr.status+', '+thrownError); success: function(data) {
$('#data').html(data);
$('#uid' + id).remove();
},
error: function(xhr, ajaxOptions, thrownError) {
$('#data').html('<h3>Request failed</h3> Error code: ' + xhr.status + ', ' + thrownError);
} }
}); });
} }
@ -66,15 +72,17 @@ function del(id) {
*/ */
function purge(id) { function purge(id) {
$.ajax({ $.ajax({
type:"POST", type: "POST",
url:scriptname, url: scriptname,
data:{'purge':id}, data: {
dataType:'html', 'purge': id
success:function(data){ },
dataType: 'html',
success: function(data) {
$('#data').html(data); $('#data').html(data);
}, },
error:function(xhr, ajaxOptions, thrownError){ error: function(xhr, ajaxOptions, thrownError) {
$('#data').html('<h3>Request failed</h3> Error code: '+xhr.status+', '+thrownError); $('#data').html('<h3>Request failed</h3> Error code: ' + xhr.status + ', ' + thrownError);
} }
}); });
} }
@ -84,7 +92,9 @@ function purge(id) {
function newNotif() { function newNotif() {
var data = $("#newNotif").html(); var data = $("#newNotif").html();
$('#data').html(data); $('#data').html(data);
$("#data input#date").datepicker({'dateFormat':'yy-mm-dd'}); $("#data input#date").datepicker({
'dateFormat': 'yy-mm-dd'
});
return; return;
} }
@ -101,28 +111,48 @@ function sendNewNotif() {
var xml = $("textarea#xml").val(); var xml = $("textarea#xml").val();
// Reset CSS // Reset CSS
$("input#uid").css('border-width','0'); $("input#uid").css('border-width', '0');
$("input#date").css('border-width','0'); $("input#date").css('border-width', '0');
$("input#ref").css('border-width','0'); $("input#ref").css('border-width', '0');
$("textarea#xml").css('border-width','0'); $("textarea#xml").css('border-width', '0');
// Check data // Check data
if(!uid){$("input#uid").css('border-color','red').css('border-width','2px').focus();return false;} if (!uid) {
if(!date){$("input#date").css('border-color','red').css('border-width','2px').focus();return false;} $("input#uid").css('border-color', 'red').css('border-width', '2px').focus();
if(!ref){$("input#ref").css('border-color','red').css('border-width','2px').focus();return false;} return false;
if(!xml){$("textarea#xml").css('border-color','red').css('border-width','2px').focus();return false;} }
if (!date) {
$("input#date").css('border-color', 'red').css('border-width', '2px').focus();
return false;
}
if (!ref) {
$("input#ref").css('border-color', 'red').css('border-width', '2px').focus();
return false;
}
if (!xml) {
$("textarea#xml").css('border-color', 'red').css('border-width', '2px').focus();
return false;
}
// Send AJAX request // Send AJAX request
$.ajax({ $.ajax({
type:"POST", type: "POST",
url:scriptname, url: scriptname,
data:{'newNotif':{'uid':uid,'date':date,'ref':ref,'condition':condition,'xml':xml}}, data: {
dataType:'html', 'newNotif': {
success:function(data){ 'uid': uid,
'date': date,
'ref': ref,
'condition': condition,
'xml': xml
}
},
dataType: 'html',
success: function(data) {
$('#data').html(data); $('#data').html(data);
}, },
error:function(xhr, ajaxOptions, thrownError){ error: function(xhr, ajaxOptions, thrownError) {
$('#data').html('<h3>Request failed</h3> Error code: '+xhr.status+', '+thrownError); $('#data').html('<h3>Request failed</h3> Error code: ' + xhr.status + ', ' + thrownError);
} }
}); });
} }

View File

@ -1,31 +1,35 @@
function displaySession(id) { function displaySession(id) {
$.ajax({ $.ajax({
type:"POST", type: "POST",
url:scriptname, url: scriptname,
data:{'session':id}, data: {
dataType:'html', 'session': id
success:function(data){ },
dataType: 'html',
success: function(data) {
$('#data').html(data); $('#data').html(data);
}, },
error:function(xhr, ajaxOptions, thrownError){ error: function(xhr, ajaxOptions, thrownError) {
$('#data').html('<h3>Request failed</h3> Error code: '+xhr.status+', '+thrownError); $('#data').html('<h3>Request failed</h3> Error code: ' + xhr.status + ', ' + thrownError);
} }
}); });
} }
function del(id) { function del(id) {
$.ajax({ $.ajax({
type:"POST", type: "POST",
url:scriptname, url: scriptname,
data:{'delete':id}, data: {
dataType:'html', 'delete': id
success:function(data){ },
dataType: 'html',
success: function(data) {
$('#data').html(data); $('#data').html(data);
// Delete session from tree // Delete session from tree
$('#uid'+id).remove(); $('#uid' + id).remove();
$('#ip'+id).remove(); $('#ip' + id).remove();
}, },
error:function(xhr, ajaxOptions, thrownError){ error: function(xhr, ajaxOptions, thrownError) {
$('#data').html('<h3>Request failed</h3> Error code: '+xhr.status+', '+thrownError); $('#data').html('<h3>Request failed</h3> Error code: ' + xhr.status + ', ' + thrownError);
} }
}); });
} }

View File

@ -41,11 +41,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
$.fn.simpleTree = function(opt) {
$.fn.simpleTree = function(opt){ return this.each(function() {
return this.each(function(){
var TREE = this; var TREE = this;
var ROOT = $('.root',this); var ROOT = $('.root', this);
var mousePressed = false; var mousePressed = false;
var mouseMoved = false; var mouseMoved = false;
var dragMoveType = false; var dragMoveType = false;
@ -55,475 +54,490 @@ $.fn.simpleTree = function(opt){
var ajaxCache = Array(); var ajaxCache = Array();
TREE.option = { TREE.option = {
drag: true, drag: true,
animate: false, animate: false,
autoclose: false, autoclose: false,
speed: 'fast', speed: 'fast',
afterAjax: false, afterAjax: false,
afterMove: false, afterMove: false,
afterClick: false, afterClick: false,
afterDblClick: false, afterDblClick: false,
// added by Erik Dohmen (2BinBusiness.nl) to make context menu cliks available // added by Erik Dohmen (2BinBusiness.nl) to make context menu cliks available
afterContextMenu: false, afterContextMenu: false,
docToFolderConvert: false, docToFolderConvert: false,
useClickToToggle: false, useClickToToggle: false,
afterCloseNearby: false, afterCloseNearby: false,
afterNewNode: false, afterNewNode: false,
afterSetTrigger: false afterSetTrigger: false
}; };
TREE.option = $.extend(TREE.option,opt); TREE.option = $.extend(TREE.option, opt);
$.extend(this, {getSelected: function(){ $.extend(this, {
return $('span.active', this).parent(); getSelected: function() {
}}); return $('span.active', this).parent();
TREE.closeNearby = function(obj) }
{ });
$(obj).siblings().filter('.folder-open, .folder-open-last').each(function(){ TREE.closeNearby = function(obj) {
var childUl = $('>ul',this); $(obj).siblings().filter('.folder-open, .folder-open-last').each(function() {
var childUl = $('>ul', this);
var className = this.className; var className = this.className;
this.className = className.replace('open','close'); this.className = className.replace('open', 'close');
if(TREE.option.animate) if (TREE.option.animate) {
{ childUl.animate({
childUl.animate({height:"toggle"},TREE.option.speed); height: "toggle"
}else{ },
TREE.option.speed);
} else {
childUl.hide(); childUl.hide();
} }
if(typeof TREE.option.afterCloseNearby == 'function') if (typeof TREE.option.afterCloseNearby == 'function') {
{ TREE.option.afterCloseNearby($(this).parent());
TREE.option.afterCloseNearby($(this).parent());
} }
}); });
}; };
TREE.nodeToggle = function(obj) TREE.nodeToggle = function(obj) {
{ var childUl = $('>ul', obj);
var childUl = $('>ul',obj); if (obj.className.match('open')) {
if(obj.className.match('open')){ obj.className = obj.className.replace('open', 'close');
obj.className = obj.className.replace('open','close'); if (TREE.option.animate) {
if(TREE.option.animate) childUl.animate({
{ height: "toggle"
childUl.animate({height:"toggle"},TREE.option.speed); },
}else{ TREE.option.speed);
} else {
childUl.hide(); childUl.hide();
} }
}else{ } else {
obj.className = obj.className.replace('close','open'); obj.className = obj.className.replace('close', 'open');
if(TREE.option.animate) if (TREE.option.animate) {
{ childUl.animate({
childUl.animate({height:"toggle"},TREE.option.speed, function(){ height: "toggle"
if(TREE.option.autoclose)TREE.closeNearby(obj); },
if(childUl.is('.ajax'))TREE.setAjaxNodes(childUl, obj.id); TREE.option.speed, function() {
if (TREE.option.autoclose) TREE.closeNearby(obj);
if (childUl.is('.ajax')) TREE.setAjaxNodes(childUl, obj.id);
}); });
}else{ } else {
childUl.show(); childUl.show();
if(TREE.option.autoclose)TREE.closeNearby(obj); if (TREE.option.autoclose) TREE.closeNearby(obj);
if(childUl.is('.ajax'))TREE.setAjaxNodes(childUl, obj.id); if (childUl.is('.ajax')) TREE.setAjaxNodes(childUl, obj.id);
} }
} }
}; };
TREE.setAjaxNodes = function(node, parentId, callback) TREE.setAjaxNodes = function(node, parentId, callback) {
{ if ($.inArray(parentId, ajaxCache) == -1) {
if($.inArray(parentId,ajaxCache) == -1){ ajaxCache[ajaxCache.length] = parentId;
ajaxCache[ajaxCache.length]=parentId;
var url = $.trim($('>li', node).text()); var url = $.trim($('>li', node).text());
if(url && url.indexOf('url:')) if (url && url.indexOf('url:')) {
{ url = $.trim(url.replace(/.*\{url:(.*)\}/i, '$1'));
url=$.trim(url.replace(/.*\{url:(.*)\}/i ,'$1')); var js = '';
var js=''; var call = '';
var call=''; if (url.indexOf(',js:')) {
if(url.indexOf(',js:')){ call = url.match(/.*,call:(.*)/i);
call=url.match(/.*,call:(.*)/i); if (call == null) {
if(call==null){call='';}else{call=call[1].replace(/,call.*$/,'');} call = '';
js=url.match(/.*,js:(.*)/i); } else {
if(js==null){js='';}else{js=js[1].replace(/,call.*$/,'');} call = call[1].replace(/,call.*$/, '');
url=$.trim(url.replace(/,(?:js|call):.*/i ,'')); }
js = url.match(/.*,js:(.*)/i);
if (js == null) {
js = '';
} else {
js = js[1].replace(/,call.*$/, '');
}
url = $.trim(url.replace(/,(?:js|call):.*/i, ''));
} }
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: url, url: url,
contentType:'html', contentType: 'html',
cache:false, cache: false,
success: function(response){ success: function(response) {
node.removeAttr('class'); node.removeAttr('class');
if(response.length>0){ if (response.length > 0) {
node.html(response); node.html(response);
$.extend(node,{url:url}); $.extend(node, {
TREE.setTreeNodes(node, true); url: url
});
TREE.setTreeNodes(node, true);
} else { } else {
$("li.line",node).remove(); $("li.line", node).remove();
$("li.doc-last",node).remove(); $("li.doc-last", node).remove();
} }
if(typeof TREE.option.afterAjax == 'function') if (typeof TREE.option.afterAjax == 'function') {
{
TREE.option.afterAjax(node); TREE.option.afterAjax(node);
} }
if(typeof callback == 'function') if (typeof callback == 'function') {
{
callback(node); callback(node);
} }
if(js.length){if(!js.match(/\(/))js+='()';$('>span',node.parent()).click(function(){eval(js)});} if (js.length) {
if(call.length){if(!call.match(/\(/))call+='()';eval(call);} if (!js.match(/\(/)) js += '()';
$('>span', node.parent()).click(function() {
eval(js)
});
}
if (call.length) {
if (!call.match(/\(/)) call += '()';
eval(call);
}
}, },
error: function(xhr, ajaxOptions, thrownError){ error: function(xhr, ajaxOptions, thrownError) {
TREE.closeNearby(node); TREE.closeNearby(node);
alert('Failed to get remote datas. Error code: '+xhr.status+', '+thrownError); alert('Failed to get remote datas. Error code: ' + xhr.status + ', ' + thrownError);
} }
}); });
} }
} }
}; };
TREE.setTreeNodes = function(obj, useParent){ TREE.setTreeNodes = function(obj, useParent) {
obj = useParent? obj.parent():obj; obj = useParent ? obj.parent() : obj;
$('li>span', obj).addClass('text') $('li>span', obj).addClass('text').bind('selectstart', function() {
.bind('selectstart', function() {
return false; return false;
}).click(function(){ }).click(function() {
// Remove all active classes and add the text class // Remove all active classes and add the text class
$('.active',TREE).toggleClass('active').addClass('text'); $('.active', TREE).toggleClass('active').addClass('text');
if(this.className.match('text')) if (this.className.match('text')) {
{ this.className = this.className.replace('text', 'active');
this.className=this.className.replace('text','active');
} }
if(TREE.option.useClickToToggle) if (TREE.option.useClickToToggle) {
{
TREE.nodeToggle($(this).parent().get(0)); TREE.nodeToggle($(this).parent().get(0));
} }
if(typeof TREE.option.afterClick == 'function') if (typeof TREE.option.afterClick == 'function') {
{
TREE.option.afterClick($(this).parent()); TREE.option.afterClick($(this).parent());
} }
return false; return false;
}).dblclick(function(){ }).dblclick(function() {
mousePressed = false; mousePressed = false;
if(!TREE.option.useClickToToggle) if (!TREE.option.useClickToToggle) {
{
TREE.nodeToggle($(this).parent().get(0)); TREE.nodeToggle($(this).parent().get(0));
} }
if(typeof TREE.option.afterDblClick == 'function') if (typeof TREE.option.afterDblClick == 'function') {
{
TREE.option.afterDblClick($(this).parent()); TREE.option.afterDblClick($(this).parent());
} }
return false; return false;
// added by Erik Dohmen (2BinBusiness.nl) to make context menu actions // added by Erik Dohmen (2BinBusiness.nl) to make context menu actions
// available // available
}).bind("contextmenu",function(){ }).bind("contextmenu", function() {
$('.active',TREE).toggleClass('active').addClass('text'); $('.active', TREE).toggleClass('active').addClass('text');
if(this.className.match('text')) if (this.className.match('text')) {
{ this.className = this.className.replace('text', 'active');
this.className=this.className.replace('text','active');
} }
if(typeof TREE.option.afterContextMenu == 'function') if (typeof TREE.option.afterContextMenu == 'function') {
{
TREE.option.afterContextMenu($(this).parent()); TREE.option.afterContextMenu($(this).parent());
} }
return false; return false;
}).mousedown(function(event){ }).mousedown(function(event) {
mousePressed = true; mousePressed = true;
cloneNode = $(this).parent().clone(); cloneNode = $(this).parent().clone();
var LI = $(this).parent(); var LI = $(this).parent();
if(TREE.option.drag) if (TREE.option.drag) {
{
$('>ul', cloneNode).hide(); $('>ul', cloneNode).hide();
$('body').append('<div id="drag_container"><ul></ul></div>'); $('body').append('<div id="drag_container"><ul></ul></div>');
$('#drag_container').hide().css({opacity:'0.8'}); $('#drag_container').hide().css({
opacity: '0.8'
});
$('#drag_container >ul').append(cloneNode); $('#drag_container >ul').append(cloneNode);
$("<img>").attr({id : "tree_plus",src : imagepath+"tree/plus.gif"}).css({width: "7px",display: "block",position: "absolute",left : "5px",top: "5px", display:'none'}).appendTo("body"); $("<img>").attr({
$(document).bind("mousemove", {LI:LI}, TREE.dragStart).bind("mouseup",TREE.dragEnd); id: "tree_plus",
src: imagepath + "tree/plus.gif"
}).css({
width: "7px",
display: "block",
position: "absolute",
left: "5px",
top: "5px",
display: 'none'
}).appendTo("body");
$(document).bind("mousemove", {
LI: LI
},
TREE.dragStart).bind("mouseup", TREE.dragEnd);
} }
return false; return false;
}).mouseup(function(){ }).mouseup(function() {
if(mousePressed && mouseMoved && dragNode_source) if (mousePressed && mouseMoved && dragNode_source) {
{
TREE.moveNodeToFolder($(this).parent()); TREE.moveNodeToFolder($(this).parent());
} }
TREE.eventDestroy(); TREE.eventDestroy();
}); });
$('li', obj).each(function(i){ $('li', obj).each(function(i) {
var className = this.className; var className = this.className;
var open = false; var open = false;
var cloneNode=false; var cloneNode = false;
var LI = this; var LI = this;
var childNode = $('>ul',this); var childNode = $('>ul', this);
if(childNode.size()>0){ if (childNode.size() > 0) {
var setClassName = 'folder-'; var setClassName = 'folder-';
if(className && className.indexOf('hidden')>=0){ if (className && className.indexOf('hidden') >= 0) {
setClassName=setClassName+'hidden'; setClassName = setClassName + 'hidden';
}else if(className && className.indexOf('open')>=0){ } else if (className && className.indexOf('open') >= 0) {
setClassName=setClassName+'open'; setClassName = setClassName + 'open';
open=true; open = true;
}else{ } else {
setClassName=setClassName+'close'; setClassName = setClassName + 'close';
} }
this.className = setClassName + ($(this).is(':last-child')? '-last':''); this.className = setClassName + ($(this).is(':last-child') ? '-last' : '');
if(!open || className.indexOf('ajax')>=0)childNode.hide(); if (!open || className.indexOf('ajax') >= 0) childNode.hide();
TREE.setTrigger(this); TREE.setTrigger(this);
}else{ } else {
var setClassName = 'doc'; var setClassName = 'doc';
this.className = setClassName + ($(this).is(':last-child')? '-last':''); this.className = setClassName + ($(this).is(':last-child') ? '-last' : '');
} }
}).before('<li class="line">&nbsp;</li>') }).before('<li class="line">&nbsp;</li>').filter(':last-child').after('<li class="line-last"></li>');
.filter(':last-child').after('<li class="line-last"></li>');
TREE.setEventLine($('.line, .line-last', obj)); TREE.setEventLine($('.line, .line-last', obj));
}; };
TREE.setTrigger = function(node){ TREE.setTrigger = function(node) {
$('>span',node).before('<img class="trigger" src="'+imagepath+'tree/spacer.gif" border=0>'); $('>span', node).before('<img class="trigger" src="' + imagepath + 'tree/spacer.gif" border=0>');
var trigger = $('>.trigger', node); var trigger = $('>.trigger', node);
trigger.click(function(event){ trigger.click(function(event) {
TREE.nodeToggle(node); TREE.nodeToggle(node);
}); });
trigger.css('float','left'); trigger.css('float', 'left');
if(typeof TREE.option.afterSetTrigger == 'function') if (typeof TREE.option.afterSetTrigger == 'function') {
{
TREE.option.afterSetTrigger(node); TREE.option.afterSetTrigger(node);
} }
}; };
TREE.dragStart = function(event){ TREE.dragStart = function(event) {
var LI = $(event.data.LI); var LI = $(event.data.LI);
if(mousePressed) if (mousePressed) {
{
mouseMoved = true; mouseMoved = true;
if(dragDropTimer) clearTimeout(dragDropTimer); if (dragDropTimer) clearTimeout(dragDropTimer);
if($('#drag_container:not(:visible)')){ if ($('#drag_container:not(:visible)')) {
$('#drag_container').show(); $('#drag_container').show();
LI.prev('.line').hide(); LI.prev('.line').hide();
dragNode_source = LI; dragNode_source = LI;
} }
$('#drag_container').css({position:'absolute', "left" : (event.pageX + 5), "top": (event.pageY + 15) }); $('#drag_container').css({
if(LI.is(':visible'))LI.hide(); position: 'absolute',
"left": (event.pageX + 5),
"top": (event.pageY + 15)
});
if (LI.is(':visible')) LI.hide();
var temp_move = false; var temp_move = false;
if(event.target.tagName.toLowerCase()=='span' && $.inArray(event.target.className, Array('text','active','trigger'))!= -1) if (event.target.tagName.toLowerCase() == 'span' && $.inArray(event.target.className, Array('text', 'active', 'trigger')) != -1) {
{
var parent = event.target.parentNode; var parent = event.target.parentNode;
var offs = $(parent).offset({scroll:false}); var offs = $(parent).offset({
var screenScroll = {x : (offs.left - 3),y : event.pageY - offs.top}; scroll: false
});
var screenScroll = {
x: (offs.left - 3),
y: event.pageY - offs.top
};
var isrc = $("#tree_plus").attr('src'); var isrc = $("#tree_plus").attr('src');
var ajaxChildSize = $('>ul.ajax',parent).size(); var ajaxChildSize = $('>ul.ajax', parent).size();
var ajaxChild = $('>ul.ajax',parent); var ajaxChild = $('>ul.ajax', parent);
screenScroll.x += 19; screenScroll.x += 19;
screenScroll.y = event.pageY - screenScroll.y + 5; screenScroll.y = event.pageY - screenScroll.y + 5;
if(parent.className.indexOf('folder-close')>=0 && ajaxChildSize==0) if (parent.className.indexOf('folder-close') >= 0 && ajaxChildSize == 0) {
{ if (isrc.indexOf('minus') != -1) $("#tree_plus").attr('src', imagepath + 'tree/plus.gif');
if(isrc.indexOf('minus')!=-1)$("#tree_plus").attr('src',imagepath+'tree/plus.gif'); $("#tree_plus").css({
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show(); "left": screenScroll.x,
dragDropTimer = setTimeout(function(){ "top": screenScroll.y
parent.className = parent.className.replace('close','open'); }).show();
$('>ul',parent).show(); dragDropTimer = setTimeout(function() {
}, 700); parent.className = parent.className.replace('close', 'open');
}else if(parent.className.indexOf('folder')>=0 && ajaxChildSize==0){ $('>ul', parent).show();
if(isrc.indexOf('minus')!=-1)$("#tree_plus").attr('src',imagepath+'tree/plus.gif'); },
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show(); 700);
}else if(parent.className.indexOf('folder-close')>=0 && ajaxChildSize>0) } else if (parent.className.indexOf('folder') >= 0 && ajaxChildSize == 0) {
{ if (isrc.indexOf('minus') != -1) $("#tree_plus").attr('src', imagepath + 'tree/plus.gif');
$("#tree_plus").css({
"left": screenScroll.x,
"top": screenScroll.y
}).show();
} else if (parent.className.indexOf('folder-close') >= 0 && ajaxChildSize > 0) {
mouseMoved = false; mouseMoved = false;
$("#tree_plus").attr('src',imagepath+'tree/minus.gif'); $("#tree_plus").attr('src', imagepath + 'tree/minus.gif');
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show(); $("#tree_plus").css({
"left": screenScroll.x,
"top": screenScroll.y
}).show();
$('>ul',parent).show(); $('>ul', parent).show();
/* /*
Thanks for the idea of Erik Dohmen Thanks for the idea of Erik Dohmen
*/ */
TREE.setAjaxNodes(ajaxChild,parent.id, function(){ TREE.setAjaxNodes(ajaxChild, parent.id, function() {
parent.className = parent.className.replace('close','open'); parent.className = parent.className.replace('close', 'open');
mouseMoved = true; mouseMoved = true;
$("#tree_plus").attr('src',imagepath+'tree/plus.gif'); $("#tree_plus").attr('src', imagepath + 'tree/plus.gif');
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show(); $("#tree_plus").css({
"left": screenScroll.x,
"top": screenScroll.y
}).show();
}); });
}else{ } else {
if(TREE.option.docToFolderConvert) if (TREE.option.docToFolderConvert) {
{ $("#tree_plus").css({
$("#tree_plus").css({"left": screenScroll.x, "top": screenScroll.y}).show(); "left": screenScroll.x,
}else{ "top": screenScroll.y
}).show();
} else {
$("#tree_plus").hide(); $("#tree_plus").hide();
} }
} }
}else{ } else {
$("#tree_plus").hide(); $("#tree_plus").hide();
} }
return false; return false;
} }
return true; return true;
}; };
TREE.dragEnd = function(){ TREE.dragEnd = function() {
if(dragDropTimer) clearTimeout(dragDropTimer); if (dragDropTimer) clearTimeout(dragDropTimer);
TREE.eventDestroy(); TREE.eventDestroy();
}; };
TREE.setEventLine = function(obj){ TREE.setEventLine = function(obj) {
obj.mouseover(function(){ obj.mouseover(function() {
if(this.className.indexOf('over')<0 && mousePressed && mouseMoved) if (this.className.indexOf('over') < 0 && mousePressed && mouseMoved) {
{ this.className = this.className.replace('line', 'line-over');
this.className = this.className.replace('line','line-over');
} }
}).mouseout(function(){ }).mouseout(function() {
if(this.className.indexOf('over')>=0) if (this.className.indexOf('over') >= 0) {
{ this.className = this.className.replace('-over', '');
this.className = this.className.replace('-over','');
} }
}).mouseup(function(){ }).mouseup(function() {
if(mousePressed && dragNode_source && mouseMoved) if (mousePressed && dragNode_source && mouseMoved) {
{
dragNode_destination = $(this).parents('li:first'); dragNode_destination = $(this).parents('li:first');
TREE.moveNodeToLine(this); TREE.moveNodeToLine(this);
TREE.eventDestroy(); TREE.eventDestroy();
} }
}); });
}; };
TREE.checkNodeIsLast = function(node) TREE.checkNodeIsLast = function(node) {
{ if (node.className.indexOf('last') >= 0) {
if(node.className.indexOf('last')>=0)
{
var prev_source = dragNode_source.prev().prev(); var prev_source = dragNode_source.prev().prev();
if(prev_source.size()>0) if (prev_source.size() > 0) {
{ prev_source[0].className += '-last';
prev_source[0].className+='-last';
} }
node.className = node.className.replace('-last',''); node.className = node.className.replace('-last', '');
} }
}; };
TREE.checkLineIsLast = function(line) TREE.checkLineIsLast = function(line) {
{ if (line.className.indexOf('last') >= 0) {
if(line.className.indexOf('last')>=0)
{
var prev = $(line).prev(); var prev = $(line).prev();
if(prev.size()>0) if (prev.size() > 0) {
{ prev[0].className = prev[0].className.replace('-last', '');
prev[0].className = prev[0].className.replace('-last','');
} }
dragNode_source[0].className+='-last'; dragNode_source[0].className += '-last';
} }
}; };
TREE.eventDestroy = function() TREE.eventDestroy = function() {
{
// added by Erik Dohmen (2BinBusiness.nl), the unbind mousemove TREE.dragStart action // added by Erik Dohmen (2BinBusiness.nl), the unbind mousemove TREE.dragStart action
// like this other mousemove actions binded through other actions ain't removed (use it myself // like this other mousemove actions binded through other actions ain't removed (use it myself
// to determine location for context menu) // to determine location for context menu)
$(document).unbind('mousemove',TREE.dragStart).unbind('mouseup').unbind('mousedown'); $(document).unbind('mousemove', TREE.dragStart).unbind('mouseup').unbind('mousedown');
$('#drag_container, #tree_plus').remove(); $('#drag_container, #tree_plus').remove();
if(dragNode_source) if (dragNode_source) {
{
$(dragNode_source).show().prev('.line').show(); $(dragNode_source).show().prev('.line').show();
} }
dragNode_destination = dragNode_source = mousePressed = mouseMoved = false; dragNode_destination = dragNode_source = mousePressed = mouseMoved = false;
//ajaxCache = Array(); //ajaxCache = Array();
}; };
TREE.convertToFolder = function(node){ TREE.convertToFolder = function(node) {
node[0].className = node[0].className.replace('doc','folder-open'); node[0].className = node[0].className.replace('doc', 'folder-open');
node.append('<ul><li class="line-last"></li></ul>'); node.append('<ul><li class="line-last"></li></ul>');
TREE.setTrigger(node[0]); TREE.setTrigger(node[0]);
TREE.setEventLine($('.line, .line-last', node)); TREE.setEventLine($('.line, .line-last', node));
}; };
TREE.convertToDoc = function(node){ TREE.convertToDoc = function(node) {
$('>ul', node).remove(); $('>ul', node).remove();
$('img', node).remove(); $('img', node).remove();
node[0].className = node[0].className.replace(/folder-(open|close)/gi , 'doc'); node[0].className = node[0].className.replace(/folder-(open|close)/gi, 'doc');
}; };
TREE.moveNodeToFolder = function(node) TREE.moveNodeToFolder = function(node) {
{
// Open node if it's closed // Open node if it's closed
if(node[0].className.match('close')){TREE.nodeToggle(node[0]);} if (node[0].className.match('close')) {
if(!TREE.option.docToFolderConvert && node[0].className.indexOf('doc')!=-1) TREE.nodeToggle(node[0]);
{ }
if (!TREE.option.docToFolderConvert && node[0].className.indexOf('doc') != -1) {
return true; return true;
}else if(TREE.option.docToFolderConvert && node[0].className.indexOf('doc')!=-1){ } else if (TREE.option.docToFolderConvert && node[0].className.indexOf('doc') != -1) {
TREE.convertToFolder(node); TREE.convertToFolder(node);
} }
TREE.checkNodeIsLast(dragNode_source[0]); TREE.checkNodeIsLast(dragNode_source[0]);
var lastLine = $('>ul >.line-last', node); var lastLine = $('>ul >.line-last', node);
if(lastLine.size()>0) if (lastLine.size() > 0) {
{
TREE.moveNodeToLine(lastLine[0]); TREE.moveNodeToLine(lastLine[0]);
} }
}; };
TREE.moveNodeToLine = function(node){ TREE.moveNodeToLine = function(node) {
TREE.checkNodeIsLast(dragNode_source[0]); TREE.checkNodeIsLast(dragNode_source[0]);
TREE.checkLineIsLast(node); TREE.checkLineIsLast(node);
var parent = $(dragNode_source).parents('li:first'); var parent = $(dragNode_source).parents('li:first');
var line = $(dragNode_source).prev('.line'); var line = $(dragNode_source).prev('.line');
$(node).before(dragNode_source); $(node).before(dragNode_source);
$(dragNode_source).before(line); $(dragNode_source).before(line);
node.className = node.className.replace('-over',''); node.className = node.className.replace('-over', '');
var nodeSize = $('>ul >li', parent).not('.line, .line-last').filter(':visible').size(); var nodeSize = $('>ul >li', parent).not('.line, .line-last').filter(':visible').size();
if(TREE.option.docToFolderConvert && nodeSize==0) if (TREE.option.docToFolderConvert && nodeSize == 0) {
{
TREE.convertToDoc(parent); TREE.convertToDoc(parent);
}else if(nodeSize==0) } else if (nodeSize == 0) {
{ parent[0].className = parent[0].className.replace('open', 'close');
parent[0].className=parent[0].className.replace('open','close'); $('>ul', parent).hide();
$('>ul',parent).hide();
} }
// added by Erik Dohmen (2BinBusiness.nl) select node // added by Erik Dohmen (2BinBusiness.nl) select node
if($('span:first',dragNode_source).attr('class')=='text') if ($('span:first', dragNode_source).attr('class') == 'text') {
{ $('.active', TREE).toggleClass('active').addClass('text');
$('.active',TREE).toggleClass('active').addClass('text'); $('span:first', dragNode_source).toggleClass('text').addClass('active');
$('span:first',dragNode_source).toggleClass('text').addClass('active');
} }
if(typeof(TREE.option.afterMove) == 'function') if (typeof(TREE.option.afterMove) == 'function') {
{
var pos = $(dragNode_source).prevAll(':not(.line)').size(); var pos = $(dragNode_source).prevAll(':not(.line)').size();
TREE.option.afterMove($(node).parents('li:first'), $(dragNode_source), pos); TREE.option.afterMove($(node).parents('li:first'), $(dragNode_source), pos);
} }
}; };
TREE.addNode = function(id, text, callback) TREE.addNode = function(id, text, callback) {
{ TREE.newNodeIn(TREE.getSelected(), id, text, callback);
TREE.newNodeIn(TREE.getSelected(),id,text,callback);
}; };
TREE.newNodeIn = function(node, id, text, callback) TREE.newNodeIn = function(node, id, text, callback) {
{ var temp_node = $('<li><ul><li id="' + id + '"><span>' + text + '</span></li></ul></li>');
var temp_node = $('<li><ul><li id="'+id+'"><span>'+text+'</span></li></ul></li>'); TREE.setTreeNodes(temp_node, false);
TREE.setTreeNodes(temp_node,false);
destination = node; destination = node;
dragNode_source = $('.doc-last',temp_node); dragNode_source = $('.doc-last', temp_node);
TREE.moveNodeToFolder(destination); TREE.moveNodeToFolder(destination);
temp_node.remove(); temp_node.remove();
if(typeof TREE.option.afterNewNode == 'function') if (typeof TREE.option.afterNewNode == 'function') {
{
TREE.option.afterNewNode(node); TREE.option.afterNewNode(node);
} }
if(typeof(callback) == 'function') if (typeof(callback) == 'function') {
{
callback(dragNode_destination, dragNode_source); callback(dragNode_destination, dragNode_source);
} }
}; };
TREE.newNodeAfter = function(id, text, callback) TREE.newNodeAfter = function(id, text, callback) {
{ TREE.newNodeIn(TREE.getSelected().parent().parent(), id, text, callback);
TREE.newNodeIn(TREE.getSelected().parent().parent(),id,text,callback);
}; };
TREE.newAjaxNodeIn = function(node,id,text,url,callback) TREE.newAjaxNodeIn = function(node, id, text, url, callback) {
{ var temp_node = $('<li><ul><li id="' + id + '"><span>' + text + '</span><ul class="ajax"><li id="new">.{url:' + url + '}</li></ul></li></ul></li>');
var temp_node = $('<li><ul><li id="'+id+'"><span>'+text+'</span><ul class="ajax"><li id="new">.{url:'+url+'}</li></ul></li></ul></li>'); TREE.setTreeNodes(temp_node, false);
TREE.setTreeNodes(temp_node,false);
destination = node; destination = node;
dragNode_source = $('.folder-close-last',temp_node); dragNode_source = $('.folder-close-last', temp_node);
TREE.moveNodeToFolder(destination); TREE.moveNodeToFolder(destination);
temp_node.remove(); temp_node.remove();
if(typeof TREE.option.afterNewNode == 'function') if (typeof TREE.option.afterNewNode == 'function') {
{
TREE.option.afterNewNode(node); TREE.option.afterNewNode(node);
} }
if(typeof(callback) == 'function') if (typeof(callback) == 'function') {
{
callback(dragNode_destination, dragNode_source); callback(dragNode_destination, dragNode_source);
} }
}; };
TREE.delNode = function(callback) TREE.delNode = function(callback) {
{
dragNode_source = TREE.getSelected(); dragNode_source = TREE.getSelected();
TREE.checkNodeIsLast(dragNode_source[0]); TREE.checkNodeIsLast(dragNode_source[0]);
dragNode_source.prev().remove(); dragNode_source.prev().remove();
dragNode_source.remove(); dragNode_source.remove();
if(typeof(callback) == 'function') if (typeof(callback) == 'function') {
{
callback(dragNode_destination); callback(dragNode_destination);
} }
}; };
TREE.init = function(obj) TREE.init = function(obj) {
{
TREE.setTreeNodes(obj, false); TREE.setTreeNodes(obj, false);
}; };
TREE.init(ROOT); TREE.init(ROOT);

View File

@ -1,5 +1,4 @@
$(document).ready(function() {
$(document).ready(function(){
// Adapt some class to fit Bootstrap theme // Adapt some class to fit Bootstrap theme
$("div.message-positive").addClass("alert-success"); $("div.message-positive").addClass("alert-success");
@ -9,4 +8,3 @@ $(document).ready(function(){
$("table.info").addClass("table"); $("table.info").addClass("table");
}); });

View File

@ -1,12 +1,12 @@
/* Watch login and logout events */ /* Watch login and logout events */
navigator.id.watch({ navigator.id.watch({
loggedInUser: null, loggedInUser: null,
onlogin: function(assertion) { onlogin: function(assertion) {
// POST assertion // POST assertion
$('form.BrowserID').append('<input type="hidden" name="browserIdAssertion" value="'+assertion+'" />').submit(); $('form.BrowserID').append('<input type="hidden" name="browserIdAssertion" value="' + assertion + '" />').submit();
}, },
onlogout: function() { onlogout: function() {
// Do nothing // Do nothing
} }
}); });

View File

@ -1,4 +1,4 @@
$(document).ready(function(){ $(document).ready(function() {
// Manage auto login // Manage auto login
if (browserIdAutoLogin.match('1')) { if (browserIdAutoLogin.match('1')) {
@ -7,7 +7,7 @@ $(document).ready(function(){
// Intercept submit the first time // Intercept submit the first time
var intercepted = 0; var intercepted = 0;
$("form.BrowserID").submit(function( event ) { $("form.BrowserID").submit(function(event) {
if (!intercepted) { if (!intercepted) {
event.preventDefault(); event.preventDefault();
intercepted = 1; intercepted = 1;

View File

@ -1,3 +1,3 @@
$(document).ready(function(){ $(document).ready(function() {
navigator.id.logout(); navigator.id.logout();
}); });

View File

@ -12,20 +12,32 @@
*/ */
/* Set autocomplete real value */ /* Set autocomplete real value */
if(autocomplete.match('1')){autocomplete='on';} if (autocomplete.match('1')) {
if(autocomplete.match('0')){autocomplete='off';} autocomplete = 'on';
}
if (autocomplete.match('0')) {
autocomplete = 'off';
}
/* Set newwindow value (default is false) */ /* Set newwindow value (default is false) */
if(newwindow.match('1')){newwindow=true;}else{newwindow=false;} if (newwindow.match('1')) {
newwindow = true;
} else {
newwindow = false;
}
/* Set antiframe value (default is true) */ /* Set antiframe value (default is true) */
if(antiframe.match('0')){antiframe=false;}else{antiframe=true;} if (antiframe.match('0')) {
antiframe = false;
} else {
antiframe = true;
}
/* jQuery */ /* jQuery */
$(document).ready(function(){ $(document).ready(function() {
/* AntiFrame script */ /* AntiFrame script */
if(antiframe && top!=self){ if (antiframe && top != self) {
top.location.href = location.href; top.location.href = location.href;
} }
@ -36,7 +48,9 @@ $(document).ready(function(){
opacity: 0.5, opacity: 0.5,
revert: true, revert: true,
items: "> div.category", items: "> div.category",
update: function(){ getOrder(); } update: function() {
getOrder();
}
}); });
restoreOrder(); restoreOrder();
@ -45,32 +59,42 @@ $(document).ready(function(){
$("div.message").fadeIn('slow'); $("div.message").fadeIn('slow');
/* Set timezone */ /* Set timezone */
$("input[name=timezone]").val( -(new Date().getTimezoneOffset()/60) ); $("input[name=timezone]").val(-(new Date().getTimezoneOffset() / 60));
/* Menu tabs */ /* Menu tabs */
var menuTabs = $("#menu").tabs({active:0}); var menuTabs = $("#menu").tabs({
var menuIndex = $('#menu a[href="#'+displaytab+'"]').parent().index(); active: 0
if (menuIndex<0){menuIndex=0;} });
menuTabs.tabs("option","active",menuIndex); var menuIndex = $('#menu a[href="#' + displaytab + '"]').parent().index();
if (menuIndex < 0) {
menuIndex = 0;
}
menuTabs.tabs("option", "active", menuIndex);
/* Authentication choice tabs */ /* Authentication choice tabs */
var authMenuTabs = $("#authMenu").tabs({active:0}); var authMenuTabs = $("#authMenu").tabs({
active: 0
});
// TODO: cookie // TODO: cookie
//$("#authMenu").tabs({cookie: {name: 'lemonldapauthchoice'}}); //$("#authMenu").tabs({cookie: {name: 'lemonldapauthchoice'}});
if(choicetab){ if (choicetab) {
var authMenuIndex = $('#authMenu a[href="#'+choicetab+'"]').parent().index(); var authMenuIndex = $('#authMenu a[href="#' + choicetab + '"]').parent().index();
authMenuTabs.tabs("option","active",authMenuIndex); authMenuTabs.tabs("option", "active", authMenuIndex);
} }
/* Focus on first visible input */ /* Focus on first visible input */
$("input[type!=hidden]:first").focus(); $("input[type!=hidden]:first").focus();
if(login){ $("input[type=password]:first").focus(); } if (login) {
$("input[type=password]:first").focus();
}
/* Password autocompletion */ /* Password autocompletion */
$("input[type='password']").attr("autocomplete",autocomplete); $("input[type='password']").attr("autocomplete", autocomplete);
/* Open links in new windows */ /* Open links in new windows */
if(newwindow){ $('#appslist a').attr("target", "_blank"); } if (newwindow) {
$('#appslist a').attr("target", "_blank");
}
/* Complete removeOther link */ /* Complete removeOther link */
if ($("p.removeOther").length) { if ($("p.removeOther").length) {
@ -79,12 +103,12 @@ $(document).ready(function(){
var back_url = ""; var back_url = "";
if (action.indexOf("?") != -1) { if (action.indexOf("?") != -1) {
back_url = action.substring(0,action.indexOf("?")) + "?"; back_url = action.substring(0, action.indexOf("?")) + "?";
} else { } else {
back_url = action + "?"; back_url = action + "?";
} }
$("form.login input[type=hidden]").each(function(index){ $("form.login input[type=hidden]").each(function(index) {
back_url = back_url + "&" + $(this).attr("name") + "=" + $(this).val(); back_url = back_url + "&" + $(this).attr("name") + "=" + $(this).val();
}); });
@ -92,7 +116,7 @@ $(document).ready(function(){
link = link + "&method=" + method + "&url=" + $.base64Encode(back_url); link = link + "&method=" + method + "&url=" + $.base64Encode(back_url);
$("p.removeOther a").attr("href",link); $("p.removeOther a").attr("href", link);
} }
}); });
@ -104,10 +128,12 @@ var setSelector = "#appslist";
function getOrder() { function getOrder() {
// save custom order to persistent session // save custom order to persistent session
$.ajax({ $.ajax({
type:"POST", type: "POST",
url:scriptname, url: scriptname,
data:{storeAppsListOrder:$(setSelector).sortable("toArray").join()}, data: {
dataType:'json' storeAppsListOrder: $(setSelector).sortable("toArray").join()
},
dataType: 'json'
}); });
} }
@ -127,7 +153,7 @@ function restoreOrder() {
// make array from current order // make array from current order
var rebuild = new Array(); var rebuild = new Array();
for ( var v=0, len=items.length; v<len; v++ ){ for (var v = 0, len = items.length; v < len; v++) {
rebuild[items[v]] = items[v]; rebuild[items[v]] = items[v];
} }
@ -142,10 +168,10 @@ function restoreOrder() {
var item = rebuild[itemID]; var item = rebuild[itemID];
// select the item according to current order // select the item according to current order
var child = $(setSelector+".ui-sortable").children("#" + item); var child = $(setSelector + ".ui-sortable").children("#" + item);
// select the item according to the saved order // select the item according to the saved order
var savedOrd = $(setSelector+".ui-sortable").children("#" + itemID); var savedOrd = $(setSelector + ".ui-sortable").children("#" + itemID);
// remove all the items // remove all the items
child.remove(); child.remove();
@ -155,7 +181,7 @@ function restoreOrder() {
// class is applied to all ul elements and we // class is applied to all ul elements and we
// only want the very first! You can modify this // only want the very first! You can modify this
// to support multiple lists - not tested! // to support multiple lists - not tested!
$(setSelector+".ui-sortable").filter(":first").append(savedOrd); $(setSelector + ".ui-sortable").filter(":first").append(savedOrd);
} }
} }
} }
@ -165,29 +191,32 @@ function restoreOrder() {
* @param option Option name * @param option Option name
* @return true if option is set, false else * @return true if option is set, false else
*/ */
function isHiddenFormValueSet(option){ function isHiddenFormValueSet(option) {
if($('#lmhidden_'+option).length){ if ($('#lmhidden_' + option).length) {
return true; return true;
}else{ } else {
return false; return false;
} }
} }
function ping() { function ping() {
$.ajax({type:"POST", $.ajax({
url:scriptname, type: "POST",
data:{ping:1}, url: scriptname,
dataType:'json', data: {
success:function(data){ ping: 1
if(!data.auth){ },
location.reload(true); dataType: 'json',
success: function(data) {
if (!data.auth) {
location.reload(true);
}
else {
setTimeout('ping();', 60000);
}
} }
else{ /*,
setTimeout('ping();',60000);
}
}/*,
error:function(xhr, ajaxOptions, thrownError){ error:function(xhr, ajaxOptions, thrownError){
alert('Request failed Error code: '+xhr.status+', '+thrownError); alert('Request failed Error code: '+xhr.status+', '+thrownError);
}*/ }*/
}); });
} }