Skip to content

Commit

Permalink
Fix SetDeviceBreakpoints (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
OS-giulianasilva authored Nov 9, 2023
1 parent 17d6cd3 commit 3187388
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 37 deletions.
4 changes: 2 additions & 2 deletions dist/OutSystemsUI.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ declare namespace OSFramework.OSUI.Constants {
True: string;
};
};
const AllowPropagationAttr = "[data-allow-event-propagation]";
const Dot = ".";
const Comma = ",";
const EnableLogMessages = false;
Expand Down Expand Up @@ -3591,7 +3592,6 @@ declare namespace OSFramework.OSUI.Patterns.Tooltip {
private _eventIconOnMouseLeave;
private _eventOnBalloonClick;
private _eventOnBlur;
private _eventOnBodyClick;
private _eventOnClick;
private _eventOnFocus;
private _eventOnKeypress;
Expand All @@ -3604,6 +3604,7 @@ declare namespace OSFramework.OSUI.Patterns.Tooltip {
private _isIconMouseEnter;
private _isOpen;
private _isOpenedByApi;
private _isSafari;
private _platformEventOnToggleCallback;
private _requestAnimationOnBodyScroll;
private _requestAnimationOnWindowResize;
Expand All @@ -3619,7 +3620,6 @@ declare namespace OSFramework.OSUI.Patterns.Tooltip {
private _onBalloonWrapperMouseEnter;
private _onBalloonWrapperMouseLeave;
private _onBlur;
private _onBodyClick;
private _onClick;
private _onFocus;
private _onIconMouseEnter;
Expand Down
44 changes: 15 additions & 29 deletions dist/OutSystemsUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ var OSFramework;
True: 'true',
},
};
Constants.AllowPropagationAttr = '[data-allow-event-propagation]';
Constants.Dot = '.';
Constants.Comma = ',';
Constants.EnableLogMessages = false;
Expand Down Expand Up @@ -11115,6 +11116,7 @@ var OSFramework;
this._tooltipBalloonPositionClass = '';
this._isOpen = this.configs.StartVisible;
this._tooltipBalloonPositionClass = this.configs.Position;
this._isSafari = OutSystems.OSUI.Utils.GetBrowser() === OSUI.GlobalEnum.Browser.safari;
}
_moveBalloonElement() {
OSUI.Helper.Dom.Move(this._tooltipBalloonWrapperElem, this._activeScreenElement);
Expand Down Expand Up @@ -11152,27 +11154,15 @@ var OSFramework;
if (this._tooltipBalloonContentActiveElem) {
this._tooltipBalloonContentActiveElem.removeEventListener(OSUI.GlobalEnum.HTMLEvent.Blur, this._eventOnBlur);
}
const _closestElem = document.activeElement.closest(OSUI.Constants.Dot + Tooltip_1.Enum.CssClass.Pattern);
if (_closestElem !== this.selfElement) {
if (document.activeElement !== this._tooltipIconElem && this._tooltipBalloonContentElem.contains(document.activeElement) === false) {
this._triggerClose();
}
else {
else if (document.activeElement !== document.body) {
this._tooltipBalloonContentActiveElem = document.activeElement;
this._tooltipBalloonContentActiveElem.addEventListener(OSUI.GlobalEnum.HTMLEvent.Blur, this._eventOnBlur);
}
});
}
_onBodyClick(_eventName, e) {
if (this.isBuilt && this._isOpenedByApi === false) {
const _clickedElem = e.target;
const _closestElem = _clickedElem.closest(OSUI.Constants.Dot + Tooltip_1.Enum.CssClass.Pattern);
const _closestBalloonElem = _clickedElem.closest(OSUI.Constants.Dot + Tooltip_1.Enum.CssClass.BalloonWrapper);
if (_closestElem !== this.selfElement && _closestBalloonElem !== this._tooltipBalloonWrapperElem) {
OSUI.Event.DOMEvents.Listeners.GlobalListenerManager.Instance.removeHandler(OSUI.Event.DOMEvents.Listeners.Type.BodyOnClick, this._eventOnBodyClick);
this._triggerClose();
}
}
}
_onClick(e) {
e.stopPropagation();
this._triggerOpen();
Expand Down Expand Up @@ -11298,7 +11288,7 @@ var OSFramework;
}
}
_setUpEvents() {
if (OSUI.Helper.DeviceInfo.HasAccessibilityEnabled) {
if (this.configs.IsHover === false) {
this._tooltipIconElem.addEventListener(OSUI.GlobalEnum.HTMLEvent.Blur, this._eventOnBlur);
this._tooltipIconElem.addEventListener(OSUI.GlobalEnum.HTMLEvent.Focus, this._eventOnFocus);
this._tooltipIconElem.addEventListener(OSUI.GlobalEnum.HTMLEvent.keyDown, this._eventOnKeypress);
Expand All @@ -11307,9 +11297,6 @@ var OSFramework;
this._requestAnimationOnBodyScroll = requestAnimationFrame(this._eventOnScreenScroll);
OSUI.Event.DOMEvents.Listeners.GlobalListenerManager.Instance.addHandler(OSUI.Event.DOMEvents.Listeners.Type.WindowResize, this._eventOnWindowResize);
this._requestAnimationOnWindowResize = requestAnimationFrame(this._eventOnWindowResize);
if (this._isOpen) {
OSUI.Event.DOMEvents.Listeners.GlobalListenerManager.Instance.addHandler(OSUI.Event.DOMEvents.Listeners.Type.BodyOnClick, this._eventOnBodyClick);
}
if (this.configs.IsHover === false || OSUI.Helper.DeviceInfo.IsDesktop === false) {
this._tooltipIconElem.addEventListener(OSUI.GlobalEnum.HTMLEvent.Click, this._eventOnClick);
this._tooltipBalloonContentElem.addEventListener(OSUI.GlobalEnum.HTMLEvent.Click, this._eventOnBalloonClick);
Expand All @@ -11324,8 +11311,11 @@ var OSFramework;
_triggerClose() {
if (this._isOpen) {
this._isOpen = false;
OSUI.Helper.Dom.Styles.RemoveClass(this.selfElement, Tooltip_1.Enum.CssClass.IsOpened);
OSUI.Helper.Dom.Styles.RemoveClass(this._tooltipBalloonWrapperElem, Tooltip_1.Enum.CssClass.BalloonIsOpened);
const _timeout = this._tooltipBalloonContentElem.querySelector(OSUI.Constants.AllowPropagationAttr) || this._isSafari ? 110 : 0;
OSUI.Helper.ApplySetTimeOut(() => {
OSUI.Helper.Dom.Styles.RemoveClass(this.selfElement, Tooltip_1.Enum.CssClass.IsOpened);
OSUI.Helper.Dom.Styles.RemoveClass(this._tooltipBalloonWrapperElem, Tooltip_1.Enum.CssClass.BalloonIsOpened);
}, _timeout);
this._unsetObserver();
if (this._tooltipBalloonPositionClass !== this.configs.Position) {
OSUI.Helper.Dom.Styles.RemoveClass(this._tooltipBalloonWrapperElem, this._tooltipBalloonPositionClass);
Expand Down Expand Up @@ -11353,7 +11343,6 @@ var OSFramework;
OSUI.Helper.Dom.Styles.AddClass(this.selfElement, Tooltip_1.Enum.CssClass.IsOpened);
OSUI.Helper.Dom.Styles.AddClass(this._tooltipBalloonWrapperElem, Tooltip_1.Enum.CssClass.BalloonIsOpened);
});
OSUI.Event.DOMEvents.Listeners.GlobalListenerManager.Instance.addHandler(OSUI.Event.DOMEvents.Listeners.Type.BodyOnClick, this._eventOnBodyClick);
OSUI.Helper.AsyncInvocation(this._setObserver.bind(this));
this.triggerPlatformEventCallback(this._platformEventOnToggleCallback, true);
OSUI.Helper.AsyncInvocation(() => {
Expand All @@ -11367,7 +11356,6 @@ var OSFramework;
this._tooltipIconElem.removeEventListener(OSUI.GlobalEnum.HTMLEvent.Focus, this._eventOnFocus);
this._tooltipIconElem.removeEventListener(OSUI.GlobalEnum.HTMLEvent.keyDown, this._eventOnKeypress);
this._tooltipBalloonContentElem.removeEventListener(OSUI.GlobalEnum.HTMLEvent.Click, this._eventOnBalloonClick);
OSUI.Event.DOMEvents.Listeners.GlobalListenerManager.Instance.removeHandler(OSUI.Event.DOMEvents.Listeners.Type.BodyOnClick, this._eventOnBodyClick);
OSUI.Event.DOMEvents.Listeners.GlobalListenerManager.Instance.removeHandler(OSUI.Event.DOMEvents.Listeners.Type.ScreenOnScroll, this._eventOnScreenScroll);
OSUI.Event.DOMEvents.Listeners.GlobalListenerManager.Instance.removeHandler(OSUI.Event.DOMEvents.Listeners.Type.WindowResize, this._eventOnWindowResize);
this._tooltipBalloonContentElem.removeEventListener(OSUI.GlobalEnum.HTMLEvent.TransitionEnd, this._eventOnOpenedBalloon);
Expand Down Expand Up @@ -11414,7 +11402,6 @@ var OSFramework;
setCallbacks() {
this._eventOnBalloonClick = this._onBalloonClick.bind(this);
this._eventOnBlur = this._onBlur.bind(this);
this._eventOnBodyClick = this._onBodyClick.bind(this);
this._eventOnScreenScroll = this._onScreenScroll.bind(this);
this._eventOnClick = this._onClick.bind(this);
this._eventOnFocus = this._onFocus.bind(this);
Expand Down Expand Up @@ -11445,7 +11432,6 @@ var OSFramework;
unsetCallbacks() {
this._eventOnBalloonClick = undefined;
this._eventOnBlur = undefined;
this._eventOnBodyClick = undefined;
this._eventOnScreenScroll = undefined;
this._eventOnClick = undefined;
this._eventOnFocus = undefined;
Expand Down Expand Up @@ -16137,14 +16123,14 @@ var OutSystems;
OSFramework.OSUI.GlobalEnum.DeviceType.desktop,
];
let device;
if (windowWidth < phoneMax || (isLandscape === false && windowHeight < phoneMax)) {
const windowSize = isLandscape ? windowWidth : windowHeight;
if (windowSize <= phoneMax) {
device = 0;
}
else if ((windowWidth >= phoneMax && windowWidth <= tabletMax) ||
(windowHeight >= phoneMax && windowHeight <= tabletMax && isLandscape)) {
else if (windowSize <= tabletMax) {
device = 1;
}
else if (windowWidth > tabletMax || (windowHeight > tabletMax && isLandscape)) {
else {
device = 2;
}
return [orient, deviceList[device]];
Expand Down Expand Up @@ -17131,7 +17117,7 @@ var OutSystems;
const result = OutSystems.OSUI.Utils.CreateApiResponse({
errorCode: OSUI.ErrorCodes.Utilities.FailAddFavicon,
callback: () => {
const existingFavicon = OSFramework.OSUI.Helper.Dom.TagSelector(document.head, "link[rel*='icon']");
const existingFavicon = OSFramework.OSUI.Helper.Dom.TagSelector(document.head, "link[rel='shortcut icon']");
if (existingFavicon) {
existingFavicon.href = URL;
}
Expand Down
13 changes: 7 additions & 6 deletions src/scripts/OutSystems/OSUI/Utils/DeviceDetection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,17 @@ namespace OutSystems.OSUI.Utils.DeviceDetection {
];

let device;
if (windowWidth < phoneMax || (isLandscape === false && windowHeight < phoneMax)) {

// To set the device using the window dimensions, we just need to look into the largest dimension
const windowSize = isLandscape ? windowWidth : windowHeight;

if (windowSize <= phoneMax) {
//Is phone!
device = 0;
} else if (
(windowWidth >= phoneMax && windowWidth <= tabletMax) ||
(windowHeight >= phoneMax && windowHeight <= tabletMax && isLandscape)
) {
} else if (windowSize <= tabletMax) {
//Is Tablet!
device = 1;
} else if (windowWidth > tabletMax || (windowHeight > tabletMax && isLandscape)) {
} else {
//Is Desktop!
device = 2;
}
Expand Down

0 comments on commit 3187388

Please sign in to comment.