FCLT#61196 Interface toggle beter ondersteunen

svn path=/Website/trunk/; revision=47696
This commit is contained in:
Jos Groot Lipman
2020-08-10 12:53:00 +00:00
parent 66aee77af2
commit cad678a9e5
9 changed files with 221 additions and 241 deletions

View File

@@ -111,7 +111,7 @@ __Log("== Entering shorturl.asp ==");
{
isKnownBookmark = true;
checkUserAgent(); // devicebits waren anders mogelijk nog niet gezet
if (device.test(device.isDesktop) || device.test(device.isTouch))
if (Session("interface") == "mobile" || Session("interface") == "touch")
{
url = locked_bdradr_key > 0? known_bookmarks[u].lckgui : known_bookmarks[u].gui;
}
@@ -253,4 +253,4 @@ __Log("== Entering shorturl.asp ==");
Response.Redirect(theURL);
%>
<% ASPPAGE_END(); %>
<% ASPPAGE_END(); %>

View File

@@ -37,7 +37,7 @@ if (!S("email_password"))
shared.simpel_page(L("lcl_no_auth"));
checkUserAgent(); // heeft device capability bits gezet
if (device.test(device.isMobile))
if (Session("interface") == "mobile")
FCLTHeader.Requires({css:[FCLTHeader._mobileTemplateCss]});
%>
<html>
@@ -76,4 +76,4 @@ IFACE.FORM_END();
</div>
</body>
</html>
<% ASPPAGE_END(); %>
<% ASPPAGE_END(); %>

View File

@@ -30,7 +30,6 @@
var noMenu = false; // option: do not show a menu
var noHeader = false;// option: do not show a header
var noTabs = false; // option: do not do tabs
var noSwitchMsg = false; // option: do not show message for switch to mobile
// Logging option: for internal debugging purposes, bitcoded
// IHateTabs option: do not use our internal tabmanager
// Jumpto option: for deeplinking, uses an alternate body
@@ -38,7 +37,6 @@
if (Request.QueryString("noMenu").Count>0) noMenu = true;
if (Request.QueryString("noHeader").Count>0) noHeader = true;
if (Request.QueryString("IHateTabs").Count>0) noTabs = true;
if (Request.QueryString("noSwitchMsg").Count>0) noSwitchMsg = true;
__Log("Welcome.asp expired?");
var sql = "DELETE FROM fac_menu"
@@ -98,7 +96,7 @@
autoopen.unshift({ u: firstPage, t: L("lcl_body_portal"), noclose: true, nopin: true, activate: !hasActivate });
}
if (device.test(device.isTouch)) { %>
if (Session("interface") == "touch") { %>
<html>
<% } else { %>
<html style='overflow:hidden'>
@@ -128,7 +126,7 @@ if (device.test(device.isTouch)) { %>
<link rel="apple-touch-icon" sizes="180x180" href="<%= rooturl + "/" + S("fac_favicon_folder") %>/Icon-60@3x.png" />
<%
if (device.test(device.isTouch))
if (Session("interface") == "touch")
{
noTabs = true;
noHeader = true;
@@ -142,6 +140,18 @@ if (device.test(device.isTouch)) { %>
var scrollbarWidth;
var timeoutInstance;
<% if (Session("interfaceforce") == 1) { %>
window.localStorage.setItem("interface", "<%safe.jsstring(Session("interface"))%>");
<% } else { %>
var interface = window.localStorage.getItem("interface");
if (interface && interface != "<%safe.jsstring(Session("interface"))%>")
{ // we hadden verkeerd gegokt, localStorage weet het beter
parent.location.href = "../../default.asp?interface=" + interface;
}
<% }
Session.Contents.Remove("interfaceforce");
%>
// Functie om de breedte van een scrollbar te berekenen
function getScrollBarWidth() {
var $outer = $("<div>").css({visibility: "hidden", width: 100, overflow: "scroll"}).appendTo("body");
@@ -509,7 +519,7 @@ if (device.test(device.isTouch)) { %>
$("div.ui-tabs-submenu").hide();
});
<% if (!device.test(device.isTouch)) { %>
<% if (Session("interface") != "touch") { %>
$("#menutabs").filterMenuByText("#menufilter");
$("#menufilter").focus();
<% } %>
@@ -553,14 +563,6 @@ if (device.test(device.isTouch)) { %>
localStorage.setItem("selectedMenuTab", selectedTabId);
});
var interf = window.localStorage.getItem("interface");
//for retrieving current interface choice
if ("1" == "<%=(device.test(device.isDesktop) && noSwitchMsg == false) ? 1 : 0%>" && (interf == "mobile" || interf == "touch"))
{
loadToggleInterface();
}
}); // jQuery.ready
<% if (__Logging & 2) { %>
@@ -629,12 +631,11 @@ function menu(evt, item, regel, menu_key) // E
}
</script>
</head>
<%
if (!device.test(device.isTouch)) { %>
if (Session("interface") == "desktop") { %>
<body>
<form name="u2" action="../aut/LogOff.asp" method="post" onSubmit="logOff();">
<% IFACE.FORM_END(); %>
@@ -749,7 +750,7 @@ else { //if (isTouch)
$("#touchmenu ul.ui-tabs-nav li").width(w+'%');
</script>
</body>
<% } // if (isTouch)
<% }
%>
</html>
<% ASPPAGE_END(); %>
<% ASPPAGE_END(); %>

View File

@@ -173,7 +173,7 @@ function touch2desktop(params)
{
if(device.isTouch || device.isDesktop) {
Response.write("<div id='touch2desktop' onclick='toDesktop(); window.localStorage.setItem(`interface`, `desktop`);'>" + I("fa-desktop") + L("lcl_desktop_classicmode") + "</div>");
}
}
}
@@ -346,13 +346,13 @@ function generateHeaderFunctions (params)
function toMobile()
{
window.localStorage.setItem("interface", "mobile");
parent.location.href="../../default.asp?pda=1";
parent.location.href="../../default.asp?interface=mobile";
}
function toDesktop()
{
window.localStorage.setItem("interface", "desktop");
parent.location.href="../../default.asp";
parent.location.href="../../default.asp?interface=desktop";
}
// prodsearch voor touch
@@ -386,14 +386,11 @@ function generateHeaderFunctions (params)
"json");
}
function loadToggleInterface(){
function loadToggleInterface()
{
var current_interface = window.localStorage.getItem("interface");
window.localStorage.setItem("interface", (current_interface == "touch" ? "touch" : "mobile"));
var initurl = window.location.href;
var initurlPt1 = initurl.split("/appl/");
var data = {};
<% protectRequest.dataToken("data"); %>
var url = initurlPt1[0] + "?" + (window.localStorage.getItem("interface") == "mobile" ? "pda=1" : "touch=1");
var url = rooturl + "?interface=" + (window.localStorage.getItem("interface"));
window.location.href = url;
}

View File

@@ -95,7 +95,7 @@ if (!user.lcid())
// - mobile (heel eigen interface in de pda/ folder)
checkUserAgent(); // heeft device capability bits gezet
if (device.test(device.isDesktop)) { // normale desktop interface
if (Session("interface") == "desktop") { // normale desktop interface
%>
<html>
<head>
@@ -119,9 +119,9 @@ if (device.test(device.isDesktop)) { // normale desktop interface
</frameset>
</html>
<%
} else if (device.test(device.isTouch)) { // no frames
} else if (Session("interface") == "touch") { // no frames
Response.redirect("appl/fac/Facilitor.asp?"+ Request.ServerVariables("QUERY_STRING"));
} else { //device.test(device.isMobile)
} else { // device.test(device.isMobile)
Response.redirect("appl/pda/Facilitor.asp?"+ Request.ServerVariables("QUERY_STRING"));
}
%>

View File

@@ -12,7 +12,10 @@
<!--#include file="../Shared/status.inc"-->
<%
if (S("mobile_enabled") != 1)
shared.simpel_page("Mobile module not enabled."); // Wel betalen he!
{
shared.simpel_page("Mobile module not enabled.<br><a href='" + rooturl + "?interface=desktop'>Continue</a>"); // Wel betalen he!
Session("interface") = "desktop";
}
// Uses S("mobile_alg_level"); // L, G of V

View File

@@ -8,111 +8,110 @@
window.fcltmobile = 1;
if (window.localStorage.getItem("interface") == "touch") {
toTouch();
}
// Fix voor CVE-2015-9251 in jQuery 2.2.4 (FCLT#54923)
// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
jQuery.ajaxPrefilter( function( s ) {
if ( s.crossDomain ) {
s.contents.script = false;
}
} );
jQuery.ajaxPrefilter(function(s) {
if (s.crossDomain) {
s.contents.script = false;
}
});
$(document).bind("mobileinit", function() {
// Enhancement to use history.replaceState in supported browsers,
// to convert the hash-based Ajax URL into the full document path.
// Note that we recommend disabling this feature if Ajax is disabled
// or if extensive use of external links are used.
$.mobile.pushStateEnabled = false;
// $.mobile.ajaxEnabled = false;
// Enhancement to use history.replaceState in supported browsers,
// to convert the hash-based Ajax URL into the full document path.
// Note that we recommend disabling this feature if Ajax is disabled
// or if extensive use of external links are used.
$.mobile.pushStateEnabled = false;
// $.mobile.ajaxEnabled = false;
if (window.FcltMgr);
if (window.FcltMgr);
});
$(document).bind("pageinit", function(){
$(document).bind("pageinit", function() {
$("i.dateklikker,i.timeklikker").each(function() {
$(this).appendTo($(this).prev());
});
});
$(function () {
$("a.previewext").on("click", function (event) {
event.preventDefault();
var target = $(this),
href = target.attr("href"),
short = target.attr("id"),
closebtn = '<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>',
header = '<div data-role="header"><h2>' + target.html() + '</h2></div>',
img = '<img src="' + href + '" alt="' + target.html() + '" class="photo">',
popup = '<div data-role="popup" id="popup-' + short + '" data-short="' + short + '" data-theme="none" data-overlay-theme="a" data-corners="false" data-tolerance="15"></div>';
$(function() {
$("a.previewext").on("click", function(event) {
event.preventDefault();
var target = $(this),
href = target.attr("href"),
short = target.attr("id"),
closebtn = '<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>',
header = '<div data-role="header"><h2>' + target.html() + '</h2></div>',
img = '<img src="' + href + '" alt="' + target.html() + '" class="photo">',
popup = '<div data-role="popup" id="popup-' + short + '" data-short="' + short + '" data-theme="none" data-overlay-theme="a" data-corners="false" data-tolerance="15"></div>';
// Create the popup.
$(header)
.appendTo($(popup)
.appendTo($.mobile.activePage)
.popup())
.toolbar()
.before(closebtn)
.after(img);
// Create the popup.
$(header)
.appendTo($(popup)
.appendTo($.mobile.activePage)
.popup())
.toolbar()
.before(closebtn)
.after(img);
// Wait with opening the popup until the popup image has been loaded in the DOM.
// This ensures the popup gets the correct size and position
$(".photo", "#popup-" + short).load(function () {
// Open the popup
$("#popup-" + short).popup("open");
// Wait with opening the popup until the popup image has been loaded in the DOM.
// This ensures the popup gets the correct size and position
$(".photo", "#popup-" + short).load(function() {
// Open the popup
$("#popup-" + short).popup("open");
// Clear the fallback
clearTimeout(fallback);
// Clear the fallback
clearTimeout(fallback);
});
// Fallback in case the browser doesn't fire a load event
var fallback = setTimeout(function() {
$("#popup-" + short).popup("open");
}, 2000);
});
// Fallback in case the browser doesn't fire a load event
var fallback = setTimeout(function () {
$("#popup-" + short).popup("open");
}, 2000);
});
// Set a max-height to make large images shrink to fit the screen.
$(document).on("popupbeforeposition", ".ui-popup", function() {
var image = $(this).children("img"),
height = image.height(),
width = image.width();
// Set a max-height to make large images shrink to fit the screen.
$(document).on("popupbeforeposition", ".ui-popup", function () {
var image = $(this).children("img"),
height = image.height(),
width = image.width();
// Set height and width attribute of the image
$(this).attr({
"height": height,
"width": width
});
// Set height and width attribute of the image
$(this).attr({
"height": height,
"width": width
// 68px: 2 * 15px for top/bottom tolerance, 38px for the header.
var maxHeight = $(window).height() - 68 + "px";
$("img.photo", this).css("max-height", maxHeight);
});
// 68px: 2 * 15px for top/bottom tolerance, 38px for the header.
var maxHeight = $(window).height() - 68 + "px";
$("img.photo", this).css("max-height", maxHeight);
});
// Remove the popup after it has been closed to manage DOM size
$(document).on("popupafterclose", ".ui-popup", function () {
$(this).remove();
});
// Remove the popup after it has been closed to manage DOM size
$(document).on("popupafterclose", ".ui-popup", function() {
$(this).remove();
});
});
function McltCallbackAndThen(afterAction)
{
return function (json, textStatus)
{
function McltCallbackAndThen(afterAction) {
return function(json, textStatus) {
if (json.message) alert(json.message); // Normaal door FcltMgr.closeDetail
if (json.warning) alert(json.warning);
json.message = null;
json.warning = null;
if (json.success)
{
if (json.success) {
if (afterAction) afterAction(json);
}
}
};
function McltCallbackAndThenAlways(afterAction)
{
return function (json, textStatus)
{
function McltCallbackAndThenAlways(afterAction) {
return function(json, textStatus) {
if (json.message) alert(json.message);
if (json.warning) alert(json.warning);
json.message = null;
@@ -121,59 +120,51 @@ function McltCallbackAndThenAlways(afterAction)
}
};
function jqToast (msg)
{
$("<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'><h3>"+msg+"</h3></div>")
.css({ display: "block",
opacity: 0.90,
position: "absolute",
padding: "7px",
"text-align": "center",
width: "270px",
left: (($(window).width() - 284)/2)+"px",
top: ($(window).scrollTop() + $(window).height()/2)+"px" })
.appendTo( $.mobile.pageContainer ).delay( 2500 )
.fadeOut( 400, function(){
$(this).remove();
});
function jqToast(msg) {
$("<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'><h3>" + msg + "</h3></div>")
.css({
display: "block",
opacity: 0.90,
position: "absolute",
padding: "7px",
"text-align": "center",
width: "270px",
left: (($(window).width() - 284) / 2) + "px",
top: ($(window).scrollTop() + $(window).height() / 2) + "px"
})
.appendTo($.mobile.pageContainer).delay(2500)
.fadeOut(400, function() {
$(this).remove();
});
}
var McltCallbackSaved = McltCallbackAndThen(function (json)
{
if (json.success)
var McltCallbackSaved = McltCallbackAndThen(function(json) {
if (json.success)
jqToast(L("lcl_mobile_data_saved"));
});
});
var McltCallbackRefresh = McltCallbackAndThen(function (json)
{
window.location.href = window.location.href;
});
var McltCallbackRefresh = McltCallbackAndThen(function(json) {
window.location.href = window.location.href;
});
var McltCallbackClose = McltCallbackAndThen(function (json)
{
window.history.back(1);
});
var McltCallbackClose = McltCallbackAndThen(function(json) {
window.history.back(1);
});
var McltCallbackHome = McltCallbackAndThen(function (json)
{
// window.history.back(1); doet geen refresh als je bijvoorbeeld net een reservering hebt verwijderd
window.location.href = rooturl +"/appl/pda/facilitor.asp"
});
var McltCallbackHome = McltCallbackAndThen(function(json) {
// window.history.back(1); doet geen refresh als je bijvoorbeeld net een reservering hebt verwijderd
window.location.href = rooturl + "/appl/pda/facilitor.asp";
});
var mobile =
{
button:
{
click: function(evt, btn)
{
var mobile = {
button: {
click: function(evt, btn) {
FcltMgr.stopPropagation(evt);
if (btn.getAttribute("singlepress") && $(btn).hasClass("btn_disabled"))
{ // FcltMgr.alert("Heb geduld");
if (btn.getAttribute("singlepress") && $(btn).hasClass("btn_disabled")) { // FcltMgr.alert("Heb geduld");
return;
}
if (btn.getAttribute("singlepress"))
{
if (btn.getAttribute("singlepress")) {
mobile.button.disable(btn);
}
var elem = btn.getAttribute("mobClick");
@@ -187,72 +178,63 @@ var mobile =
if (typeof mobile == "undefined")
return;
if (result === false)
{
if (result === false) {
mobile.button.enable(btn);
}
},
disable: function(btn)
{
disable: function(btn) {
if (!btn || btn.tagName != 'A')
return; // not a mobile button
$(btn).toggleClass("btn_disabled", true)
.removeClass("btn_enabled");
.removeClass("btn_enabled");
},
enable: function(btn)
{
enable: function(btn) {
if (!btn || btn.tagName != 'A')
return; // not a mobile button
$(btn).toggleClass("btn_enabled", true)
.removeClass("btn_disabled");
.removeClass("btn_disabled");
}
}
}
function onBijlagenMobile(formurl, // protected
saveUrl, // protected
multi,
objButton)
{
saveUrl, // protected
multi,
objButton) {
// Vorige eventueel opruimen
$("#bijlagepopup").trigger( "destroy" ).remove(); // eventuele vorige opruimen
$("#bijlagepopup").trigger("destroy").remove(); // eventuele vorige opruimen
var html = '<iframe class="mfcltmodal"'
+' frameborder="0"'
+' id="fcltmodal" name="fcltmodal" scrolling="no" style="padding: 0px;"'
+' src="' + rooturl + '/appl/shared/empty.html">'
+'</iframe>';
var html = '<iframe class="mfcltmodal"' +
' frameborder="0"' +
' id="fcltmodal" name="fcltmodal" scrolling="no" style="padding: 0px;"' +
' src="' + rooturl + '/appl/shared/empty.html">' +
'</iframe>';
html = '<div id="bijlagepopup" data-role="popup" class="ui-content" data-theme="c">'
+ '<a href="#" data-rel="back" data-role="button" data-theme="c" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a>'
+ html
+ '</div>';
html = '<div id="bijlagepopup" data-role="popup" class="ui-content" data-theme="c">' +
'<a href="#" data-rel="back" data-role="button" data-theme="c" data-icon="delete" data-iconpos="notext" class="ui-btn-right">Close</a>' +
html +
'</div>';
var $html = $(html);
$( "body" ).append ( $html );
$html.trigger( "create" );
$("body").append($html);
$html.trigger("create");
$("#bijlagepopup").on("popupafterclose",
function(event, ui)
{
function(event, ui) {
if (window.return_data) // gezet door BijlagenForm.asp
{
// Overkill alert(window.return_data.fileName + " is toegevoegd");
if (window.return_data.fileName)
{
if ($(objButton).is("[src]"))
{
if (window.return_data.fileName) {
if ($(objButton).is("[src]")) {
afterUploadForm(window.return_data.fileName);
}
else
{
} else {
$(objButton).val(window.return_data.fileName)
.show()
.attr("onclick", "")
.attr("readonly", "1")
.parent().next().hide(); // de 'Add' knop
.show()
.attr("onclick", "")
.attr("readonly", "1")
.parent().next().hide(); // de 'Add' knop
}
}
}
@@ -267,44 +249,37 @@ function onBijlagenMobile(formurl, // protected
}
// make filename safe for show
function safeFilename(s)
{
return s.replace(/[\x00-\x1F|\/|\\|\*|\%\<\>\"\:\;\?\|\+]+/g, "_");
function safeFilename(s) {
return s.replace(/[\x00-\x1F|\/|\\|\*|\%\<\>\"\:\;\?\|\+]+/g, "_");
}
// remove element of deleted file
function removeElement(element)
{
return function (json)
{
function removeElement(element) {
return function(json) {
element.remove();
if (json.toaster)
{
if (json.toaster) {
jqToast(json.toaster);
}
}
};
// delete flex-attachment
function DeleteFile(fname, safeDeleteurl, element)
{
FcltMgr.confirm(L("lcl_delete") + " " + safeFilename(fname) + "?", function() {
var data = {};
protectRequest.dataToken(data);
$.post("../shared/" + safeDeleteurl,
data,
McltCallbackAndThen(removeElement(element))
);
});
function DeleteFile(fname, safeDeleteurl, element) {
FcltMgr.confirm(L("lcl_delete") + " " + safeFilename(fname) + "?", function() {
var data = {};
protectRequest.dataToken(data);
$.post("../shared/" + safeDeleteurl,
data,
McltCallbackAndThen(removeElement(element))
);
});
}
function disable(btn)
{
$(btn).attr("onclick", "return false;")
function disable(btn) {
$(btn).attr("onclick", "return false;")
.toggleClass("btn-disabled", true)
.removeClass("btn-enabled");
}
function toTouch()
{
window.localStorage.setItem("interface", "touch");
parent.location.href="../../default.asp?touch=1&noSwitchMsg=1";
}
function toTouch() {
window.localStorage.setItem("interface", "touch");
parent.location.href = "../../default.asp?interface=touch";
}

View File

@@ -277,9 +277,9 @@ FCLTHeader =
default:
FCLTHeader.AddStylesheet(this._templateCss, true); // Template, optional
}
if (device.test(device.isTouch))
if (Session("interface") == "touch")
FCLTHeader.AddStylesheet(rooturl+"/appl/shared/touch.css");
if (device.test(device.isMobile))
if (Session("interface") == "mobile")
FCLTHeader.AddStylesheet(FCLTHeader._mobileTemplateCss, true);
if ((params.cssmode || 0) == 0)
{

View File

@@ -62,9 +62,40 @@ function checkUserAgent ()
else
device.set(device.canPrint | device.canExcel, 0);
checkInterface (); // eventuele overrules
return res.isSupported;
}
function checkInterface ()
{
// Is de interface in de url geforceerd?
var interface = getQParamSafe("interface", "");
// Oldstyle parameters
if (getQParamInt("mobile",0)==1 || getQParamInt("pda",0)==1)
interface = "mobile";
if (getQParamInt("touch",0)==1)
interface = "touch";
if (getQParamInt("desktop",0)==1)
interface = "desktop";
if (inArray(interface, ["desktop", "mobile", "touch"])) // whitelisting
{
Session("interface") = interface;
Session("interfaceforce") = 1; // negeer later localStorage
}
if (!Session("interface"))
{ // We weten nog niets. Initiele keuze maar kan later clientside nog overruled worden op basis van localStorage!
Session("interface") = "desktop";
if (device.test(device.isTouch))
Session("interface") = "touch";
else if (device.test(device.isMobile) && S("mobile_enabled") == 1)
Session("interface") = "mobile";
}
}
function toggleInterface(){
//switch to pda mode
device.set(device.isTouch, 1);
@@ -79,23 +110,6 @@ function _checkUserAgent ()
isHandheld: false,
supportsPlaceholder: true
};
// Mogelijkheid iets expliciet *aan* te zetten
if (getQParamInt("mobile",0)==1 || getQParamInt("pda",0)==1)
{
res.isHandheld = S("mobile_enabled")==1;
return res;
}
else if (getQParamInt("touch",0)==1)
{
res.isTouchscreen = true;
return res;
}
else if (getQParamInt("desktop",0)==1)
{
// geen autodetect doen. isHandheld en isTouchscreen blijven false.
return res;
}
// dan maar eerst autodetect
var ver;
@@ -148,16 +162,6 @@ function _checkUserAgent ()
}
}
// Nu nog de mogelijkheid iets expliciet *uit* te zetten
if (getQParamInt("mobile",-1)==0 || getQParamInt("pda",-1)==0)
{
res.isHandheld = false;
}
if (getQParamInt("touch",-1)==0)
{
res.isTouchscreen = false;
}
return res;
}
%>