Portal signin via Control Instance

This commit is contained in:
Andy Howard
2024-10-29 08:40:47 +00:00
parent bf6bb966bc
commit c5ee285e27
467 changed files with 25771 additions and 3347 deletions
@@ -21,6 +21,10 @@
{
return !isNaN(parseFloat(n)) && isFinite(n);
}
sbm.getTime = function ()
{
return (new Date()).getTime();
}
sbm.zeroPad = function (num, count)
{
var val = num + '';
@@ -52,12 +56,12 @@
if (file.filename) return filename.split('.').pop();
return "";
}
sbm.formatFileSize = function (size)
sbm.formatFileSize = function (size, decimals = 0)
{
if (size / 10 ** 9 > 1) return Math.floor(size / 10 ** 9) + 'Gb';
if (size / 10 ** 6 > 1) return Math.floor(size / 10 ** 6) + 'Mb';
if (size / 10 ** 3 > 1) return Math.floor(size / 10 ** 3) + 'Kb';
return size + 'bytes';
if (size / 10 ** 9 > 1) return (size / 10.0 ** 9).toFixed(decimals) + ' Gb';
if (size / 10 ** 6 > 1) return (size / 10.0 ** 6).toFixed(decimals) + ' Mb';
if (size / 10 ** 3 > 1) return (size / 10.0 ** 3).toFixed(decimals) + ' Kb';
return size + ' bytes';
}
sbm.escapeRegExp = function (val)
{
@@ -70,6 +74,21 @@
}
sbm.debug = sbm.debugMode ? win.console.log.bind(win.console) : function () { };
//--------------------------------------------------------------
sbm.compareCI = function (a, b)
{
var comparison = a.toLowerCase().localeCompare(b.toLowerCase());
if (comparison === 0)
return a.localeCompare(b);
return comparison;
}
sbm.arraySortCI = function ()
{
if (!this) return this;
this.sort(function (a, b) { return sbm.compareCI(a, b); });
return this;
};
//--------------------------------------------------------------
sbm.setOddDataRowClass = function (rowSel, cName)
{
@@ -78,35 +97,49 @@
return index % 2 == 1 ? (cName || "other") : "";
});
}
sbm.populateSelect = function ($sel, values, code, desc)
{
code = code || 'code';
desc = desc || 'desc';
$sel = $($sel).empty();
for (const value of values || [])
$sel.append($('<option>').prop('value', value[code]).text(value[desc]));
}
sbm.populateSelectCodeDesc = function ($sel, values)
{
$sel = $($sel).empty();
for (const value of values)
$sel.append($('<option>').prop('value', value.code).text(value.desc));
sbm.populateSelect($sel, values);
}
sbm.checkTextAreaMaxLength = function (ctrl, len)
{
if (ctrl == null || ctrl.value == null) return;
if (ctrl.value.length > len) ctrl.value = ctrl.value.substring(0, len);
}
sbm.setAvailableCharsLabel = function ($if, max, $lbl)
sbm.setAvailableCharsInfo = function ($if, max, $info)
{
var avail = Math.max(0, max - $if.val().length);
$lbl.text(avail == 1 ? sbm.lbl.availableCharacter : sbm.lbl.availableCharacters.replace(/\{0\}/g, avail));
let info = '';
if (max > 0)
{
let avail = Math.max(0, max - $if.val().length);
info = (avail == 1 ? sbm.lbl.charAvailable : sbm.lbl.charsAvailable.replace(/\{0\}/g, avail));
}
($info || $('.sbm-info', $if.closest('.sbm-form-control'))).text(info);
}
sbm.setCharsAvailableLabel = function ($if, max)
{
var avail = Math.max(0, max - $if.val().length);
$('.sbm-select-chars-available', $if.closest('.sbm-form-control')).text(avail == 1 ? sbm.lbl.availableCharacter : sbm.lbl.availableCharacters.replace(/\{0\}/g, avail));
}
sbm.setItemsSelectedLabel = function ($sel)
sbm.setItemsSelectedInfo = function ($sel, $info)
{
var sel = $(':selected', $sel).length;
$('.sbm-select-items-selected', $sel.closest('.sbm-form-control')).text(sel == 0 ? sbm.lbl.noneSelected : sbm.lbl.numberSelected.replace(/\{0\}/g, sel));
($info || $('.sbm-info', $sel.closest('.sbm-form-control'))).text(sel == 0 ? sbm.lbl.noneSelected : sbm.lbl.numberSelected.replace(/\{0\}/g, sel));
}
sbm.initCalendars = function (sel)
sbm.initCalendars = function (sel, opt)
{
return $(sel).datepicker();
return $(sel).datepicker(opt || {});
}
sbm.allowClearCalendar = function (sel)
{
$(sel).datepicker().on('keyup', function (e)
{
if (e.key == 'Backspace' || e.key == 'Delete')
$(this).datepicker('setDate', null).datepicker('hide').trigger('change');
});
}
sbm.refreshPaging = function (response, context, refreshFn)
{
@@ -119,7 +152,7 @@
sbm.navigateTo = function (action)
{
sbm.doPleaseWait();
$('#frmNavigate').prop('action', sbm.url.base + action).submit();
$('#frmNavigate').prop('action', sbm.url.base + action).trigger('submit');
}
sbm.goToPage = function (action)
{
@@ -127,17 +160,6 @@
location = sbm.url.base + action;
}
// Account action.
sbm.onAccountAction = function (select)
{
var action = $(select).val();
$(select).val("");
if (action == "Profile")
sbm.navigateTo("Profile");
else if (action == "Organisations")
sbm.navigateTo("Organisations");
}
// Security.
sbm.redirectHome = function ()
{
@@ -171,12 +193,12 @@
}
sbm.dlgOpts = function ()
{
return { autoOpen: false, modal: true, show: 'clip', hide: 'clip', minWidth: 320, maxWidth: 480, width: 'auto', resizable: false, draggable: false, closeOnEscape: false, dialogClass: "dialog-no-close", buttons: {} };
return { autoOpen: false, modal: true, show: 'clip', hide: 'clip', minWidth: 320, maxWidth: 480, width: 'auto', resizable: false, draggable: false, closeOnEscape: false, dialogClass: "no-close", buttons: {} };
}
sbm.dlgOptsClose = function ()
{
var opts = sbm.dlgOpts();
opts.buttons[sbm.dlg.btn.close] = function () { $(this).dialog('close'); };
opts.buttons[sbm.lbl.close] = function () { $(this).dialog('close'); };
return opts;
}
sbm.doAlert = function (title, msg, onOk)
@@ -189,11 +211,12 @@
if (!sbm.isDef(sbm.$dlg.alert))
{
var opt = sbm.dlgOpts();
opt.buttons[sbm.dlg.btn.ok] = function () { $(this).dialog('close'); if (onOk) onOk(); };
sbm.$dlg.alert = $('<div id="dlgAlert"><div id="dlgAlertMsg"></div></div>').dialog(opt);
}
$('#dlgAlertMsg', sbm.$dlg.alert).html(msg);
sbm.$dlg.alert.dialog('option', { title: title || sbm.dlg.title.alert });
$('#dlgAlertMsg', sbm.$dlg.alert).html(msg.replace(/\\n/g, '<br>'));
let btns = [];
btns[sbm.lbl.ok] = function () { $(this).dialog('close'); if (onOk) onOk(); };
sbm.$dlg.alert.dialog('option', { title: title || sbm.dlg.title.alert, buttons: btns });
sbm.openDialog(sbm.$dlg.alert);
}
sbm.doConfirm = function (title, msg, onOk, onCancel)
@@ -208,11 +231,11 @@
var opt = sbm.dlgOpts();
sbm.$dlg.confirm = $('<div id="dlgConfirm"><div class="spacer2"></div><div id="dlgConfirmMsg"></div></div>').dialog(opt);
}
var buttons = sbm.$dlg.confirm.dialog('option', 'buttons');
buttons[sbm.dlg.btn.yes] = function () { $(this).dialog('close'); if (onOk) onOk(); };
buttons[sbm.dlg.btn.no] = function () { $(this).dialog('close'); if (onCancel) onCancel(); };
sbm.$dlg.confirm.dialog('option', { title: title || sbm.dlg.title.confirm, 'buttons': buttons });
$('#dlgConfirmMsg').html(msg);
var btns = [];
btns[sbm.lbl.yes] = function () { $(this).dialog('close'); if (onOk) onOk(); };
btns[sbm.lbl.no] = function () { $(this).dialog('close'); if (onCancel) onCancel(); };
sbm.$dlg.confirm.dialog('option', { title: title || sbm.dlg.title.confirm, buttons: btns });
$('#dlgConfirmMsg').html(msg.replace(/\\n/g, '<br>'));
sbm.openDialog(sbm.$dlg.confirm);
}
sbm.confirmItemRemove = function (fn)
@@ -234,7 +257,7 @@
opt.hide = { effect: 'fade', duration: 200 };
sbm.$dlg.progress = $('<div id="dlgProgress"><div id="dlgProgressMsg"></div></div>').dialog(opt);
}
$('#dlgProgressMsg').html(msg);
$('#dlgProgressMsg').html(msg.replace(/\\n/g, '<br>'));
sbm.$dlg.progress.dialog('option', { title: title || sbm.dlg.title.progress });
if (delay > 0) sbm.toShowProgress = setTimeout(function () { sbm.$dlg.progress.dialog('open'); }, delay);
else sbm.$dlg.progress.dialog('open');
@@ -479,22 +502,25 @@
sbm.onWinResizePage = function () { };
sbm.onWinResize = function ()
{
var winH = $(win).height();
var $pageBody = $('#sbm-page-body');
var $hdr = $('#sbm-page-header');
var $ftr = $('#sbm-page-footer');
if (sbm.isAutoHeight())
$pageBody.height('auto');
else
$pageBody.innerHeight(Math.min(1200, winH - $hdr.outerHeight() - $ftr.outerHeight(true)));
$ftr.css('visibility', 'visible');
$('body').toggleClass('sbm-layout-flex', !sbm.isAutoHeight()).toggleClass('sbm-layout-flow', sbm.isAutoHeight());
sbm.onWinResizePage();
}
setTimeout(sbm.onWinResize, 50);
//--------------------------------------------------------------
$(function ()
{
$(win).on('resize', function () { sbm.onWinResize(); });
$('.sbm-button-cta,.sbm-button-action,.sbm-action-link,.sbm-social-icon.sbm-action').prop('tabindex', 0);
$.fn.visible = function () { return this.css('visibility', 'visible'); };
$.fn.invisible = function () { return this.css('visibility', 'hidden'); };
$.fn.toggleVisibility = function ()
{
return this.css('visibility', function (i, visibility) { return (visibility == 'visible') ? 'hidden' : 'visible'; });
};
if (sbm.keepLoggedIn)
sbm.configureKeepLoggedIn();
else if (!sbm.awaitingLogin)