From d4a94d49849bde35010ae6af90a6a4f463ec72c4 Mon Sep 17 00:00:00 2001 From: BurningTreeC Date: Mon, 28 Oct 2024 05:56:28 +0100 Subject: [PATCH] more refactoring for readability --- core/wiki/macros/sidebar-resizer.tid | 58 +++++++++++++++++++++------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/core/wiki/macros/sidebar-resizer.tid b/core/wiki/macros/sidebar-resizer.tid index d8e299e79..3f361014a 100644 --- a/core/wiki/macros/sidebar-resizer.tid +++ b/core/wiki/macros/sidebar-resizer.tid @@ -85,6 +85,27 @@ title: $:/core/procedures/sidebar-resizer <$action-deletetiddler $tiddler="$:/state/sidebar/resizing"/> \end +\function get.story-width.result() +[compare:number:ltthenaddsuffix] +:else[compare:number:gteqthenaddsuffix] +:else[addsuffix] +\end + +\function get.tiddler-width.result() +[match[%]thencompare:number:ltthencompare:number:gteq[0]then] +:else[match[%]thencompare:number:gtthen] +:else[!match[%]thencompare:number:ltthenaddsuffix] +:else[!match[%]thencompare:number:gteqthenaddsuffix] +:else[compare:number:lt[0]then[0]addsuffix] +:else[addsuffix] +\end + +\function get.story-right.result() +[compare:number:ltthenaddsuffix] +:else[compare:number:gteqthenaddsuffix] +:else[addsuffix] +\end + \procedure set-storywidth-storyright-actions() <$let storyRightStart={{{ [convert.to.pixels.locally{$:/state/sidebar/resizing!!start-story-right}] }}} @@ -127,14 +148,10 @@ title: $:/core/procedures/sidebar-resizer tiddlerMinWidthConverted={{{ [match[%]thenmultiply[100]divide] :else[function[convert.to.result],,] }}} tiddlerMaxWidthConverted={{{ [match[%]thenmultiply[100]divide] :else[function[convert.to.result],,] }}} storyWidthSetTiddler={{{ [!is[blank]] :else[] }}} - tiddlerWidthSetTiddler={{{ [!is[blank]] :else[] }}} + tiddlerWidthSetTiddler={{{ [!is[blank]] :else[] }}}> - storyWidthResult={{{ [compare:number:ltthenaddsuffix] :else[compare:number:gteqthenaddsuffix] :else[addsuffix] }}} - - tiddlerWidthResult={{{ [match[%]thencompare:number:ltthencompare:number:gteq[0]then] :else[match[%]thencompare:number:gtthen] :else[!match[%]thencompare:number:ltthenaddsuffix] :else[!match[%]thencompare:number:gteqthenaddsuffix] :else[compare:number:lt[0]then[0]addsuffix] :else[addsuffix] }}}> - - <$action-setfield $tiddler=<> text=<>/> - <$action-setfield $tiddler=<> text=<>/> + <$action-setfield $tiddler=<> text=<>/> + <$action-setfield $tiddler=<> text=<>/> @@ -143,17 +160,21 @@ title: $:/core/procedures/sidebar-resizer storyRiverWidthConverted={{{ [function[convert.to.result],,] }}} storyRiverLimitConverted={{{ [function[convert.to.result],,] }}} storyMinWidthAddLeftConverted={{{ [function[convert.to.result],,] }}} - storyRightSetTiddler={{{ [!is[blank]] :else[] }}} + storyRightSetTiddler={{{ [!is[blank]] :else[] }}}> - result={{{ [compare:number:ltthenaddsuffix] :else[compare:number:gteqthenaddsuffix] :else[addsuffix] }}}> - - <$action-setfield $tiddler=<> text=<>/> + <$action-setfield $tiddler=<> text=<>/> \end +\function get.sidebar-width.result() +[compare:number:gteqthenaddsuffix] +:else[compare:number:ltthenaddsuffix] +:else[addsuffix] +\end + \procedure set-sidebarwidth-actions() <$let sidebarMinWidthValue={{{ [!is[blank]get[text]] :else[] }}} @@ -173,11 +194,17 @@ title: $:/core/procedures/sidebar-resizer sidebarMinWidthConverted={{{ [function[convert.to.result],,] }}} sidebarWidthSetTiddler={{{ [!is[blank]] :else[] }}}> - <$action-setfield $tiddler=<> text={{{ [compare:number:gteqthenaddsuffix] :else[compare:number:ltthenaddsuffix] :else[addsuffix] }}}/> + <$action-setfield $tiddler=<> text=<>/> \end +\function get.story-width.centralised.result() +[compare:number:ltthenaddsuffix] +:else[compare:number:gteqthenaddsuffix] +:else[addsuffix] +\end + \procedure set-centralised-actions() <$let storyMinWidthValue={{{ [!is[blank]get[text]] :else[{$:/themes/tiddlywiki/centralised/metrics/storyminwidth}] }}} @@ -198,14 +225,17 @@ title: $:/core/procedures/sidebar-resizer storyMaxWidthConverted={{{ [function[convert.to.result],,] }}} storyWidthSetTiddler={{{ [!is[blank]] :else[] }}}> - <$action-setfield $tiddler=<> text={{{ [compare:number:ltthenaddsuffix] :else[compare:number:gteqthenaddsuffix] :else[addsuffix] }}}/> + <$action-setfield $tiddler=<> text=<>/> \end -\function get.drag.diff() [subtract{$:/state/sidebar/resizing!!start-posx}] :map[{$:/themes/tiddlywiki/vanilla/options/sidebarposition}match[left]thenmultiply[-1]else] +\function get.drag.diff() +[subtract{$:/state/sidebar/resizing!!start-posx}] +:map[{$:/themes/tiddlywiki/vanilla/options/sidebarposition}match[left]thenmultiply[-1]else] +\end \procedure sidebar-resizer-pointermove-actions() <%if [[$:/state/sidebar/resizing]!is[missing]] %>