Ben Thomson f79e672a13
Establish base Snowboard framework in Backend (#548)
This PR establishes a base Snowboard framework in the Backend. While we won't likely have any specific Snowboard widgets or functionality in the 1.1 branch, it will allow people to use Snowboard in the Backend should they wish.

Fixes #541.

Co-authored-by: Luke Towers <github@luketowers.ca>
2022-05-16 13:31:49 +08:00

103 lines
2.2 KiB
JavaScript

/*
* Winter General Utilities
*/
/*
* Path helpers
*/
if ($.wn === undefined)
$.wn = {}
if ($.oc === undefined)
$.oc = $.wn
$.wn.backendUrl = function(url) {
var backendBasePath = $('meta[name="backend-base-path"]').attr('content')
if (!backendBasePath)
return url
if (url.substr(0, 1) == '/')
url = url.substr(1)
return backendBasePath + '/' + url
}
/*
* String escape
*/
if ($.wn === undefined)
$.wn = {}
if ($.oc === undefined)
$.oc = $.wn
$.wn.escapeHtmlString = function(string) {
var htmlEscapes = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'/': '&#x2F;'
},
htmlEscaper = /[&<>"'\/]/g
return ('' + string).replace(htmlEscaper, function(match) {
return htmlEscapes[match];
})
}
/*
* Inverse Click Event (not used)
*
* Calls the handler function if the user has clicked outside the object
* and not on any of the elements in the exception list.
*/
/*
$.fn.extend({
clickOutside: function(handler, exceptions) {
var $this = this;
$('body').on('click', function(event) {
if (exceptions && $.inArray(event.target, exceptions) > -1) {
return;
} else if ($.contains($this[0], event.target)) {
return;
} else {
handler(event, $this);
}
});
return this;
}
})
*/
/*
* Browser Fixes
* - If another fix using JS is necessary, move this logic to backend.fixes.js
*/
/*
* Internet Explorer v11
* - IE11 will not honor height 100% when overflow is used on the Y axis.
*/
if (!!window.MSInputMethodContext && !!document.documentMode) {
$(window).on('resize', function() {
fixMediaManager()
fixSidebar()
})
function fixMediaManager() {
var $el = $('div[data-control="media-manager"] .control-scrollpad')
$el.height($el.parent().height())
}
function fixSidebar() {
$('#layout-sidenav').height(Math.max(
$('#layout-body').innerHeight(),
$(window).height() - $('#layout-mainmenu').height()
))
}
}