diff --git a/Makefile b/Makefile index 8d6dbe2a2..2086d76e5 100644 --- a/Makefile +++ b/Makefile @@ -186,13 +186,17 @@ MANAGERJSONDST=$(SRCMANAGERDIR)/site/static/struct.json \ _example/conf/lmConf-1.js # Javascript and CSS to minify -JSSRCFILES:=$(shell find */site/static/js $(SRCPORTALDIR)/example -type f -name '*.js' ! -name '*.min.js') \ +JSSRCFILES:=$(shell find */site/static/js $(SRCPORTALDIR)/site/htdocs/static/common/js -type f -name '*.js' ! -name '*.min.js') \ $(SRCMANAGERDIR)/site/static/bwr/file-saver.js/FileSaver.js -CSSSRCFILES:=$(shell find */site/static/css $(SRCPORTALDIR)/example -type f -name '*.css' ! -name '*.min.css') +CSSSRCFILES:=$(shell find */site/static/css $(SRCPORTALDIR)/site/htdocs/static/common/css -type f -name '*.css' ! -name '*.min.css') # Coffee files -COFFEESRCFILES:=$(shell find */site/coffee/ -type f -name '*.coffee') -COFFEEDSTFILES:=$(subst coffee/,static/js/,$(COFFEESRCFILES:.coffee=.js)) +MANAGERCOFFEESRCFILES:=$(shell find lemonldap-ng-manager/site/coffee -type f -name '*.coffee') +PORTALCOFFEESRCFILES:=$(shell find lemonldap-ng-portal/site/coffee -type f -name '*.coffee') +COFFEESRCFILES=$(MANAGERCOFFEESRCFILES) $(PORTALCOFFEESRCFILES) +MANAGERCOFFEEDSTFILES:=$(subst coffee/,static/js/,$(MANAGERCOFFEESRCFILES:.coffee=.js)) +PORTALCOFFEEDSTFILES:=$(subst coffee/,htdocs/static/common/js/,$(PORTALCOFFEESRCFILES:.coffee=.js)) +COFFEEDSTFILES:=$(MANAGERCOFFEEDSTFILES) $(PORTALCOFFEEDSTFILES) # Minified files JSDSTFILES=$(JSSRCFILES:.js=.min.js) @@ -264,10 +268,10 @@ js: $(COFFEEDSTFILES) minify: js $(JSDSTFILES) $(CSSDSTFILES) -$(SRCPORTALDIR)/site/static/js/%.js: $(SRCPORTALDIR)/site/coffee/%.coffee +$(SRCPORTALDIR)/site/htdocs/static/common/js/%.js: $(SRCPORTALDIR)/site/coffee/%.coffee @if which coffee >/dev/null; then \ echo "Compiling $(SRCPORTALDIR)/site/coffee/$*.coffee"; \ - coffee -c -o $(SRCPORTALDIR)/site/static/js/ $(SRCPORTALDIR)/site/coffee/$*.coffee; \ + coffee -c -o $(SRCPORTALDIR)/site/htdocs/static/common/js/ $(SRCPORTALDIR)/site/coffee/$*.coffee; \ fi $(SRCMANAGERDIR)/site/static/js/%.js: $(SRCMANAGERDIR)/site/coffee/%.coffee diff --git a/lemonldap-ng-portal/site/coffee/portal.coffee b/lemonldap-ng-portal/site/coffee/portal.coffee index d28e6403a..6851e90fe 100644 --- a/lemonldap-ng-portal/site/coffee/portal.coffee +++ b/lemonldap-ng-portal/site/coffee/portal.coffee @@ -97,6 +97,8 @@ ping = -> else location.reload true +window.ping = ping + # Initialization $(document).ready -> if antiframe and top != self diff --git a/lemonldap-ng-portal/site/htdocs/static/common/js/portal.js b/lemonldap-ng-portal/site/htdocs/static/common/js/portal.js index 52c778415..873da91bb 100644 --- a/lemonldap-ng-portal/site/htdocs/static/common/js/portal.js +++ b/lemonldap-ng-portal/site/htdocs/static/common/js/portal.js @@ -1,218 +1,153 @@ -/** - * LemonLDAP::NG Portal jQuery scripts +// Generated by CoffeeScript 1.10.0 + +/* +LemonLDAP::NG Portal jQuery scripts + +Used variables: + - displaytab + - choicetab + - login + - newwindow + - antiframe */ -/* Used variables - * - displaytab - * - choicetab - * - login - * - newwindow - * - antiframe - */ +(function() { + var activeTimer, antiframe, getOrder, isHiddenFormValueSet, newwindow, ping, restoreOrder, setSelector, translate, translatePage, + indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; -/* Set newwindow value (default is false) */ -if (newwindow.match('1')) { - newwindow = true; -} else { - newwindow = false; -} - -/* Set antiframe value (default is true) */ -if (antiframe.match('0')) { - antiframe = false; -} else { - antiframe = true; -} - -/* Set activeTimer value (default is true) */ -if (activeTimer.match('0')) { - activeTimer = false; -} else { - activeTimer = true; -} - -/* jQuery */ -$(document).ready(function() { - - /* AntiFrame script */ - if (antiframe && top != self) { - top.location.href = location.href; - } - - /* Sortable menu */ - $("#appslist").sortable({ - axis: "y", - cursor: "move", - opacity: 0.5, - revert: true, - items: "> div.category", - update: function() { - getOrder(); - } - }); - - restoreOrder(); - - /* Display message */ - $("div.message").fadeIn('slow'); - - /* Set timezone */ - $("input[name=timezone]").val(-(new Date().getTimezoneOffset() / 60)); - - /* Menu tabs */ - var menuTabs = $("#menu").tabs({ - active: 0 - }); - var menuIndex = $('#menu a[href="#' + displaytab + '"]').parent().index(); - if (menuIndex < 0) { - menuIndex = 0; - } - menuTabs.tabs("option", "active", menuIndex); - - /* Authentication choice tabs */ - var authMenuTabs = $("#authMenu").tabs({ - active: 0 - }); - // TODO: cookie - //$("#authMenu").tabs({cookie: {name: 'lemonldapauthchoice'}}); - if (choicetab) { - var authMenuIndex = $('#authMenu a[href="#' + choicetab + '"]').parent().index(); - authMenuTabs.tabs("option", "active", authMenuIndex); - } - - /* Focus on first visible input */ - $("input[type!=hidden]:first").focus(); - if (login) { - $("input[type=password]:first").focus(); - } - - /* Open links in new windows */ - if (newwindow) { - $('#appslist a').attr("target", "_blank"); - } - - /* Complete removeOther link */ - if ($("p.removeOther").length) { - var action = $("form.login").attr("action"); - var method = $("form.login").attr("method"); - - var back_url = ""; - if (action.indexOf("?") != -1) { - back_url = action.substring(0, action.indexOf("?")) + "?"; - } else { - back_url = action + "?"; - } - - $("form.login input[type=hidden]").each(function(index) { - back_url = back_url + "&" + $(this).attr("name") + "=" + $(this).val(); + translatePage = function(lang) { + return $("[trspan]").each(function() { + return this.text(translate(this.attr('trspan'))); }); + }; - var link = $("p.removeOther a").attr("href"); + translate = function(str) {}; - link = link + "&method=" + method + "&url=" + $.base64Encode(back_url); + newwindow = window.newwindow.match('1') ? true : false; - $("p.removeOther a").attr("href", link); + antiframe = window.antiframe.match('0') ? false : true; - } -}); + activeTimer = window.activeTimer.match('0') ? false : true; -/* Code from http://snipplr.com/view/29434/ */ -// set the list selector -var setSelector = "#appslist"; -// function that writes the list order to session -function getOrder() { - // save custom order to persistent session - $.ajax({ - type: "POST", - url: scriptname, - data: { - storeAppsListOrder: $(setSelector).sortable("toArray").join() - }, - dataType: 'json' - }); -} + setSelector = "#appslist"; -// function that restores the list order from session -function restoreOrder() { - var list = $(setSelector); - if (list == null) return; + getOrder = function() { + return $.ajax({ + type: "POST", + url: scriptname, + data: { + storeAppsListOrder: $(setSelector).sortable("toArray").join() + }, + dataType: 'json' + }); + }; - // fetch the session value (saved order) - if (!appslistorder) return; - - // make array from saved order - var IDs = appslistorder.split(","); - - // fetch current order - var items = list.sortable("toArray"); - - // make array from current order - var rebuild = new Array(); - for (var v = 0, len = items.length; v < len; v++) { - rebuild[items[v]] = items[v]; - } - - for (var i = 0, n = IDs.length; i < n; i++) { - - // item id from saved order - var itemID = IDs[i]; - - if (itemID in rebuild) { - - // select item id from current order - var item = rebuild[itemID]; - - // select the item according to current order - var child = $(setSelector + ".ui-sortable").children("#" + item); - - // select the item according to the saved order - var savedOrd = $(setSelector + ".ui-sortable").children("#" + itemID); - - // remove all the items - child.remove(); - - // add the items in turn according to saved order - // we need to filter here since the "ui-sortable" - // class is applied to all ul elements and we - // only want the very first! You can modify this - // to support multiple lists - not tested! - $(setSelector + ".ui-sortable").filter(":first").append(savedOrd); + restoreOrder = function() { + var IDs, child, i, item, itemID, items, j, len, len1, list, rebuild, savedOrd, v; + list = $(setSelector); + if (!((list != null) && appslistorder)) { + return null; } - } -} - -/* function boolean isHiddenFormValueSet(string option) - * Check if an hidden option is set - * @param option Option name - * @return true if option is set, false else - */ -function isHiddenFormValueSet(option) { - if ($('#lmhidden_' + option).length) { - return true; - } else { - return false; - } -} - -/* function void ping() - * Check if session is alive on server side - * @return nothing - */ -function ping() { - $.ajax({ - type: "POST", - url: scriptname, - data: { - ping: 1 - }, - dataType: 'json', - success: function(data) { - if (!data.auth) { - location.reload(true); - } - else { - setTimeout('ping();', pingInterval); + IDs = appslistorder.split(','); + items = list.sortable("toArray"); + rebuild = []; + for (i = 0, len = items.length; i < len; i++) { + v = items[i]; + rebuild[v] = v; + } + for (j = 0, len1 = IDs.length; j < len1; j++) { + itemID = IDs[j]; + if (indexOf.call(rebuild, itemID) >= 0) { + item = rebuild[itemID]; + child = $(setSelector + ".ui-sortable").children("#" + item); + savedOrd = $(setSelector + ".ui-sortable").children("#" + itemID); + child.remove(); + $(setSelector + ".ui-sortable").filter(":first").append(savedOrd); } } + return 1; + }; + + isHiddenFormValueSet = function(option) { + return $('#lmhidden_' + option).length; + }; + + ping = function() { + return $.ajax({ + type: "POST", + url: scriptname, + data: { + ping: 1 + }, + dataType: 'json', + success: function(data) { + if (data.auth) { + return setTimeout('ping();', pingInterval); + } else { + return location.reload(true); + } + } + }); + }; + + window.ping = ping; + + $(document).ready(function() { + var action, authMenuTabs, back_url, link, menuIndex, menuTabs, method; + if (antiframe && top !== self) { + top.location.href = location.href; + } + $("#appslist").sortable({ + axis: "y", + cursor: "move", + opacity: 0.5, + revert: true, + items: "> div.category", + update: function() { + return getOrder(); + } + }); + restoreOrder(); + $("div.message").fadeIn('slow'); + $("input[name=timezone]").val(-(new Date().getTimezoneOffset() / 60)); + menuTabs = $("#menu").tabs({ + active: 0 + }); + menuIndex = $('#menu a[href="#' + displaytab + '"]').parent().index(); + if (menuIndex < 0) { + menuIndex = 0; + } + menuTabs.tabs("option", "active", menuIndex); + authMenuTabs = $("#authMenu").tabs({ + active: 0 + }); + if (choicetab) { + authMenuTabs.tabs("option", "active", $('#authMenu a[href="#' + choicetab + '"]').parent().index()); + } + if (login) { + $("input[type=password]:first").focus(); + } else { + $("input[type!=hidden]:first").focus(); + } + if (newwindow) { + $('#appslist a').attr("target", "_blank"); + } + if ($("p.removeOther").length) { + action = $("form.login").attr("action"); + method = $("form.login").attr("method"); + back_url = ""; + if (action.indexOf("?") !== -1) { + action.substring(0, action.indexOf("?")) + "?"; + } else { + back_url = action + "?"; + } + $("form.login input[type=hidden]").each(function(index) { + return back_url += "&" + $(this).attr("name") + "=" + $(this).val(); + }); + link = $("p.removeOther a").attr("href") + "&method=" + method + "&url=" + btoa(back_url); + $("p.removeOther a").attr("href", link); + } + return translatePage(lang); }); -} \ No newline at end of file + +}).call(this); diff --git a/lemonldap-ng-portal/site/htdocs/static/common/js/portal.min.js b/lemonldap-ng-portal/site/htdocs/static/common/js/portal.min.js index 46a2c0951..6c7b0ee1b 100644 --- a/lemonldap-ng-portal/site/htdocs/static/common/js/portal.min.js +++ b/lemonldap-ng-portal/site/htdocs/static/common/js/portal.min.js @@ -1 +1 @@ -if(newwindow.match("1")){newwindow=true}else{newwindow=false}if(antiframe.match("0")){antiframe=false}else{antiframe=true}if(activeTimer.match("0")){activeTimer=false}else{activeTimer=true}$(document).ready(function(){if(antiframe&&top!=self){top.location.href=location.href}$("#appslist").sortable({axis:"y",cursor:"move",opacity:0.5,revert:true,items:"> div.category",update:function(){getOrder()}});restoreOrder();$("div.message").fadeIn("slow");$("input[name=timezone]").val(-(new Date().getTimezoneOffset()/60));var b=$("#menu").tabs({active:0});var e=$('#menu a[href="#'+displaytab+'"]').parent().index();if(e<0){e=0}b.tabs("option","active",e);var a=$("#authMenu").tabs({active:0});if(choicetab){var d=$('#authMenu a[href="#'+choicetab+'"]').parent().index();a.tabs("option","active",d)}$("input[type!=hidden]:first").focus();if(login){$("input[type=password]:first").focus()}if(newwindow){$("#appslist a").attr("target","_blank")}if($("p.removeOther").length){var g=$("form.login").attr("action");var h=$("form.login").attr("method");var c="";if(g.indexOf("?")!=-1){c=g.substring(0,g.indexOf("?"))+"?"}else{c=g+"?"}$("form.login input[type=hidden]").each(function(i){c=c+"&"+$(this).attr("name")+"="+$(this).val()});var f=$("p.removeOther a").attr("href");f=f+"&method="+h+"&url="+$.base64Encode(c);$("p.removeOther a").attr("href",f)}});var setSelector="#appslist";function getOrder(){$.ajax({type:"POST",url:scriptname,data:{storeAppsListOrder:$(setSelector).sortable("toArray").join()},dataType:"json"})}function restoreOrder(){var h=$(setSelector);if(h==null){return}if(!appslistorder){return}var d=appslistorder.split(",");var j=h.sortable("toArray");var k=new Array();for(var l=0,f=j.length;l=0){y=w[l];m=$(e+".ui-sortable").children("#"+y);s=$(e+".ui-sortable").children("#"+l);m.remove();$(e+".ui-sortable").filter(":first").append(s)}}return 1};a=function(l){return $("#lmhidden_"+l).length};j=function(){return $.ajax({type:"POST",url:scriptname,data:{ping:1},dataType:"json",success:function(l){if(l.auth){return setTimeout("ping();",pingInterval)}else{return location.reload(true)}}})};window.ping=j;$(document).ready(function(){var q,m,n,p,o,l,r;if(d&&top!==self){top.location.href=location.href}$("#appslist").sortable({axis:"y",cursor:"move",opacity:0.5,revert:true,items:"> div.category",update:function(){return i()}});h();$("div.message").fadeIn("slow");$("input[name=timezone]").val(-(new Date().getTimezoneOffset()/60));l=$("#menu").tabs({active:0});o=$('#menu a[href="#'+displaytab+'"]').parent().index();if(o<0){o=0}l.tabs("option","active",o);m=$("#authMenu").tabs({active:0});if(choicetab){m.tabs("option","active",$('#authMenu a[href="#'+choicetab+'"]').parent().index())}if(login){$("input[type=password]:first").focus()}else{$("input[type!=hidden]:first").focus()}if(g){$("#appslist a").attr("target","_blank")}if($("p.removeOther").length){q=$("form.login").attr("action");r=$("form.login").attr("method");n="";if(q.indexOf("?")!==-1){q.substring(0,q.indexOf("?"))+"?"}else{n=q+"?"}$("form.login input[type=hidden]").each(function(s){return n+="&"+$(this).attr("name")+"="+$(this).val()});p=$("p.removeOther a").attr("href")+"&method="+r+"&url="+btoa(n);$("p.removeOther a").attr("href",p)}return k(lang)})}).call(this); \ No newline at end of file