Skip to content

Commit

Permalink
feat(flyout): support short notation $.
Browse files Browse the repository at this point in the history
This PR adds jquery short notation support ($.) to flyout which is made dynamically out of js properties and thus are not bound to an existing dom node.

Previously you always had to select body (which still works) when no existing domnode template exists. Infact the body selector was completely ignored.
  • Loading branch information
prudho committed Sep 17, 2022
1 parent 6a18b84 commit 01b81c0
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/definitions/modules/flyout.js
Expand Up @@ -23,7 +23,7 @@ window = (typeof window != 'undefined' && window.Math == Math)
: Function('return this')()
;

$.fn.flyout = function(parameters) {
$.flyout = $.fn.flyout = function(parameters) {
var
$allModules = $(this),
$window = $(window),
Expand Down Expand Up @@ -75,8 +75,10 @@ $.fn.flyout = function(parameters) {
$pusher = $context.children(selector.pusher),
$style,

isFlyoutComponent = $module.hasClass('flyout'),

element = this,
instance = $module.hasClass(namespace) ? $module.data(moduleNamespace) : undefined,
instance = isFlyoutComponent ? $module.data(moduleNamespace) : undefined,

ignoreRepeatedEvents = false,
isBody = $context[0] === $body[0],
Expand All @@ -97,14 +99,17 @@ $.fn.flyout = function(parameters) {
initialize: function() {
module.debug('Initializing flyout', parameters);

if(!$module.hasClass(namespace)) {
if(!isFlyoutComponent) {
module.create.flyout();
if(!$.isFunction(settings.onHidden)) {
settings.onHidden = function () {
module.destroy();
$module.remove();
};
}
if(!settings.autoShow) {
settings.autoShow = true;
}
}
$module.addClass(settings.class);
if (settings.title !== '') {
Expand Down Expand Up @@ -422,13 +427,6 @@ $.fn.flyout = function(parameters) {
$flyouts = $context.children(selector.flyout);
},

repaint: function() {
module.verbose('Forcing repaint event');
element.style.display = 'none';
element.scrollTop = element.scrollTop;
element.style.display = '';
},

setup: {
cache: function() {
module.cache = {
Expand Down Expand Up @@ -591,7 +589,6 @@ $.fn.flyout = function(parameters) {
: function(){}
;
module.set.overlay();
module.repaint();
if(settings.returnScroll) {
currentScroll = (isBody ? $window : $context).scrollTop();
}
Expand Down

0 comments on commit 01b81c0

Please sign in to comment.