Skip to content

Commit 6489279

Browse files
Refactor Ruler class to centralize common functionality and enforce subclass implementation
- Converted ruler file into typescript - created base class and subclass for Horizontal and vertical ruler - Moved the `_updatePaintTimer` method to the base `Ruler` class to avoid duplication across `HRuler` and `VRuler`. - Added `_updateBreakPoints` as an abstract-like method in the base class, throwing an error to enforce implementation in subclasses. - Streamlined the initialization logic in `Ruler.initializeRuler` for better readability and modularity. Signed-off-by: Darshan-upadhyay1110 <[email protected]> Change-Id: I8f0187588ffab533e135023285acb3dcada832d4
1 parent 86203fc commit 6489279

File tree

7 files changed

+1259
-950
lines changed

7 files changed

+1259
-950
lines changed

browser/Makefile.am

+5-2
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,10 @@ COOL_JS_LST =\
456456
src/control/Parts.js \
457457
src/control/Scroll.js \
458458
src/control/Styles.js \
459-
src/control/Ruler.js \
459+
src/control/Ruler.ts \
460460
src/control/VRuler.ts \
461+
src/control/HRuler.ts \
462+
src/control/Ruler.ts \
461463
src/slideshow/SlideCache.ts \
462464
src/slideshow/SlideCompositor.ts \
463465
src/slideshow/LayerRenderer.ts \
@@ -988,10 +990,11 @@ pot:
988990
src/control/Control.Zotero.js \
989991
src/control/Parts.js \
990992
src/control/Permission.js \
991-
src/control/Ruler.js \
993+
src/control/Ruler.ts \
992994
src/control/Signing.js \
993995
src/control/Toolbar.js \
994996
src/control/VRuler.ts \
997+
src/control/Ruler.ts \
995998
src/control/jsdialog/Definitions.Menu.ts \
996999
src/control/jsdialog/Util.SnackbarController.ts \
9971000
src/control/jsdialog/Widget.ColorPicker.ts \

browser/css/leaflet.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,8 @@ input.clipboard {
897897
align-items: center;
898898
}
899899

900-
.cool-ruler-tabstopcontainer {
900+
.cool-ruler-tabstopcontainer,
901+
.cool-ruler-horizontal-tabstopcontainer {
901902
height: 100%;
902903
position: absolute;
903904
}

browser/src/control/Control.UIManager.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,11 @@ L.Control.UIManager = L.Control.extend({
476476
if ((window.mode.isTablet() || window.mode.isDesktop()) && !app.isReadOnly()) {
477477
var showRuler = this.getBooleanDocTypePref('ShowRuler');
478478
var interactiveRuler = this.map.isEditMode();
479-
var isRTL = document.documentElement.dir === 'rtl';
480-
L.control.ruler({position: (isRTL ? 'topright' : 'topleft'), interactive:interactiveRuler, showruler: showRuler}).addTo(this.map);
481-
if (!this.map.isPresentationOrDrawing())
482-
L.control.vruler(this.map, {position: (isRTL ? 'topright' : 'topleft'), interactive:interactiveRuler, showruler: showRuler});
483-
this.map.fire('rulerchanged');
479+
// Call the static method from the Ruler class
480+
app.definitions.ruler.initializeRuler(this.map, {
481+
interactive: interactiveRuler,
482+
showruler: showRuler
483+
});
484484
}
485485
},
486486

0 commit comments

Comments
 (0)