Skip to content

Commit 126e646

Browse files
devvaannshabose
authored andcommitted
refactor: move function logic to independent functions
1 parent eb45359 commit 126e646

1 file changed

Lines changed: 46 additions & 30 deletions

File tree

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,46 @@ function RemoteFunctions(config = {}) {
14751475
});
14761476
});
14771477

1478+
function getMode() {
1479+
return config.mode;
1480+
}
1481+
1482+
function isSyncEnabled() {
1483+
return config.syncSourceAndPreview !== false;
1484+
}
1485+
1486+
function getHighlightCount() {
1487+
if (!_highlightShadowRoot) { return 0; }
1488+
return _highlightShadowRoot.querySelectorAll('.overlay-container').length;
1489+
}
1490+
1491+
function getHighlightTrackingElement(index) {
1492+
if (!_highlightShadowRoot) { return null; }
1493+
const overlay = _highlightShadowRoot.querySelectorAll('.overlay-container')[index];
1494+
if (!overlay || !overlay.trackingElement) { return null; }
1495+
const el = overlay.trackingElement;
1496+
return {
1497+
id: el.id,
1498+
classList: Array.from(el.classList)
1499+
};
1500+
}
1501+
1502+
function getHighlightStyle(index, property) {
1503+
if (!_highlightShadowRoot) { return null; }
1504+
const overlay = _highlightShadowRoot.querySelectorAll('.overlay-container')[index];
1505+
return overlay ? overlay.style[property] : null;
1506+
}
1507+
1508+
function setHotCornerHidden(hidden) {
1509+
if (SHARED_STATE._hotCorner && SHARED_STATE._hotCorner.hotCorner) {
1510+
if (hidden) {
1511+
SHARED_STATE._hotCorner.hotCorner.classList.add('hc-hidden');
1512+
} else {
1513+
SHARED_STATE._hotCorner.hotCorner.classList.remove('hc-hidden');
1514+
}
1515+
}
1516+
}
1517+
14781518
let customReturns = {};
14791519
// only apis that needs to be called from phoenix js layer should be customReturns. APis that are shared within
14801520
// the remote function context only should not be in customReturns and should be in
@@ -1491,37 +1531,13 @@ function RemoteFunctions(config = {}) {
14911531
"updateConfig": updateConfig,
14921532
"dismissUIAndCleanupState": dismissUIAndCleanupState,
14931533
"escapeKeyPressInEditor": _handleEscapeKeyPress,
1494-
"getMode": function() { return config.mode; },
1495-
"isSyncEnabled": function() { return config.syncSourceAndPreview !== false; },
1534+
"getMode": getMode,
1535+
"isSyncEnabled": isSyncEnabled,
14961536
"suppressDOMEditDismissal": suppressDOMEditDismissal,
1497-
"getHighlightCount": function() {
1498-
if (!_highlightShadowRoot) { return 0; }
1499-
return _highlightShadowRoot.querySelectorAll('.overlay-container').length;
1500-
},
1501-
"getHighlightTrackingElement": function(index) {
1502-
if (!_highlightShadowRoot) { return null; }
1503-
const overlay = _highlightShadowRoot.querySelectorAll('.overlay-container')[index];
1504-
if (!overlay || !overlay.trackingElement) { return null; }
1505-
const el = overlay.trackingElement;
1506-
return {
1507-
id: el.id,
1508-
classList: Array.from(el.classList)
1509-
};
1510-
},
1511-
"getHighlightStyle": function(index, property) {
1512-
if (!_highlightShadowRoot) { return null; }
1513-
const overlay = _highlightShadowRoot.querySelectorAll('.overlay-container')[index];
1514-
return overlay ? overlay.style[property] : null;
1515-
},
1516-
"setHotCornerHidden": function(hidden) {
1517-
if (SHARED_STATE._hotCorner && SHARED_STATE._hotCorner.hotCorner) {
1518-
if (hidden) {
1519-
SHARED_STATE._hotCorner.hotCorner.classList.add('hc-hidden');
1520-
} else {
1521-
SHARED_STATE._hotCorner.hotCorner.classList.remove('hc-hidden');
1522-
}
1523-
}
1524-
}
1537+
"getHighlightCount": getHighlightCount,
1538+
"getHighlightTrackingElement": getHighlightTrackingElement,
1539+
"getHighlightStyle": getHighlightStyle,
1540+
"setHotCornerHidden": setHotCornerHidden
15251541
};
15261542

15271543
// the below code comment is replaced by added scripts for extensibility

0 commit comments

Comments
 (0)