Skip to content

Commit

Permalink
#1 Floria updates (decoupling from Dojo, still wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldhasson-hmhn committed May 13, 2023
1 parent 1d5b255 commit f1ecb55
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 302 deletions.
15 changes: 7 additions & 8 deletions WebContent/static/floria.v2.0/module-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ ajaxUrl: function(url, method, errorMsg, successFunc, errorFunc, postContents, t
url = url + "?" + (FloriaDOM.isObject(postContents) == true ? FloriaDOM.makeUrlParams(postContents) : postContents);
}


if (handleAs == null)
handleAs = 'json';

// Is this used at all anymore?????
if (handleAs != 'json')
if (handleAs != null && handleAs != 'json' && handleAs != 'jsonX')
{
alert("AjaxRequest.ajaxUrl called with handleAs: '"+handleAs+"'. Check consle logs for stack trace.\n\nThis was deprecated!");
alert("FloriaAjax.ajaxUrl called with handleAs: '"+handleAs+"'. Check consle logs for stack trace.\n\nThis was deprecated!");
console.trace();
return;
}
Expand All @@ -30,15 +26,18 @@ ajaxUrl: function(url, method, errorMsg, successFunc, errorFunc, postContents, t
xhr.open(method, url);
xhr.timeout = timeout
xhr.setRequestHeader("Content-type", "application/"+(handleAs||'json')+"; charset=utf-8");
if (handleAs==null||handleAs=='json')
if (handleAs==null || handleAs=='json')
xhr.responseType = 'json';
else if (handleAs=='jsonX')
xhr.responseType = 'text';

xhr.onload = function() {
try
{
if (xhr.getResponseHeader("x-wanda-canceler") == "1")
alert("FYI THAT YOU CANCELED ANOTHER REQUEST!\n\nYou (or another user on the same account) was running a request you interrupted.");

let data = xhr.response;
let data = handleAs=='jsonX' ? FloriaDOM.jsonParseWithComments(xhr.response) : xhr.response;
if (data?.code != 200 || xhr.status != 200)
return xhr.onerror({code: data?.code||xhr.status, message : data?.msg||xhr.statusText, errors: data?.errors, type: data?.type });
if (data == null)
Expand Down
78 changes: 74 additions & 4 deletions WebContent/static/floria.v2.0/module-dialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

import { FloriaDOM } from "./module-dom.js";
import { createPopper } from "/static/jslibs/popperjs/popper.js";


// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -70,7 +71,7 @@ export function FloriaDialog(elementId)
repaint = true;
else
{
lastDialog._md.style.top = "110%";
lastDialog._md.style.top = "75%";
lastDialog._md.style.opacity="";
lastDialog._md.style.zIndex=0;
}
Expand All @@ -89,7 +90,7 @@ export function FloriaDialog(elementId)
this._md.style.width=this._w+"%";
this._md.style.height=this._h+"%";
this._md.style.left=((100-this._w)/2)+"%";
this._md.style.top = "-25%"; //((100-this._h)/2)+"%"; // new comes from the top
this._md.style.top = "-10%"; //((100-this._h)/2)+"%"; // new comes from the top
this._md.style.zIndex=1000+__DIALOGS.length;

// Unhide everything as a setTimeout to trigger animations if any
Expand Down Expand Up @@ -152,12 +153,12 @@ export function FloriaDialog(elementId)
that._onHideHandler();

// It's possible for someone to close a dialog and re-open a new one right away.
// Because of the timeouts below for animation effects, we hve to "capture" this._md
// Because of the timeouts below for animation effects, we have to "capture" this._md
// before it gets overwritten by the following show().
var that_md = that._md;
// Reset items to default (from css)
setTimeout(function(){
that_md.style.top="-25%";
that_md.style.top="-10%";
that_md.style.opacity="0";
that_md.style.zIndex=0;
__hiding = false;
Expand Down Expand Up @@ -186,3 +187,72 @@ export function FloriaDialog(elementId)
};








// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tooltip dialog
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

export function FloriaTooltipDialog(elementId, content)
{
var that = this;

that._e = document.getElementById(elementId);
that._tt = document.getElementById(elementId+"_TD");
if (that._tt == null)
{
that._tt = document.createElement('div');
that._tt.setAttribute("id", elementId+"_TD");
that._tt.setAttribute("fade-in-popper", "");
that._tt.classList.add("popperTooltip");
document.body.appendChild(that._tt);
}
that._tt.innerHTML=content;
that._popper = createPopper(that._e, that._tt);
var onclick=function(evt) { that._clickHandler(evt); };
that._e.addEventListener("click", onclick);
var onmouseleave=function(evt) { that.hide(evt); };
var onmouseleave2=function(evt) { setTimeout(function(){that.hide();},100); };
that._tt.addEventListener("mouseleave", onmouseleave);
that._tt.addEventListener("click", onmouseleave2);

that._clickHandler = function (evt)
{
if (evt != null)
evt.preventDefault();
if (this._tt.hasAttribute("show-popper"))
this._tt.removeAttribute("show-popper");
else
this._tt.setAttribute("show-popper", "");
this._popper.update();
}
that.destroy = function()
{
if (this._popper)
{
this._popper.destroy();
this._e.removeEventListener("click", onclick);
this._tt.removeEventListener("mouseleave", onmouseleave);
this._tt.removeEventListener("click", onmouseleave2);
this._popper = null;
}
}
that.hide = function (evt)
{
if (evt != null)
evt.preventDefault();
this._tt.removeAttribute("show-popper");
this._popper.update();
}
that.show = function (evt)
{
if (evt != null)
evt.preventDefault();
this._tt.setAttribute("show-popper", "");
this._popper.update();
}
};
Loading

0 comments on commit f1ecb55

Please sign in to comment.