diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2020-04-24 11:44:03 -0400 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2020-04-24 11:44:03 -0400 |
commit | edf82f7a686169ea279627bac1c661aaa3459ec9 (patch) | |
tree | e8e3c3ccd75f8b2577ef9219e6189b8392c4a413 /src/new_fields/Doc.ts | |
parent | a51439a6569079ca2652ce28745317fecce3a353 (diff) |
more starburst tweaks.
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 52c3ce141..48606833c 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -998,23 +998,7 @@ export namespace Doc { newCollection._layoutEngine = "pass"; newCollection.overflow = "visible"; - const script = "if (self._layoutEngine === 'starburst') {" + - " self.overflow = undefined;" + - " self.x = self.x + self._width/2 - 55; " + - " self.y = self.y + self._height/2 - 55; " + - " self._width = self._height = 110;" + - " self._layoutEngine = 'pass';" + - " } else {" + - " self.overflow = 'visible';" + - " !self.starburstRadius && (self.starburstRadius = 500);" + - " if (self._layoutEngine === 'pass') { " + - " self.x = self.x + self._width/2 - 12.5; " + - " self.y = self.y + self._height/2 - 12.5; " + - " }; " + - " self._width = self._height = 25;" + - " self._layoutEngine = 'starburst';" + - " };"; - newCollection.onClick = ScriptField.MakeScript(script, { self: Doc.name }); + newCollection.onClick = ScriptField.MakeScript("toggleStarburst(self)", { self: Doc.name }); } @@ -1071,4 +1055,27 @@ Scripting.addGlobal(function selectedDocs(container: Doc, excludeCollections: bo return docs.length ? new List(docs) : prevValue; }); Scripting.addGlobal(function setDocFilter(container: Doc, key: string, value: any, modifiers?: "check" | "x" | undefined) { Doc.setDocFilter(container, key, value, modifiers); }); -Scripting.addGlobal(function setDocFilterRange(container: Doc, key: string, range: number[]) { Doc.setDocFilterRange(container, key, range); });
\ No newline at end of file +Scripting.addGlobal(function setDocFilterRange(container: Doc, key: string, range: number[]) { Doc.setDocFilterRange(container, key, range); }); +Scripting.addGlobal(function toggleStarburst(self: Doc) { + if (self._layoutEngine === 'starburst') { + const defaultSize = 110; + self.overflow = undefined; + self.x = NumCast(self.x) + self[WidthSym]() / 2 - NumCast(self._starburstWidth, defaultSize) / 2; + self.y = NumCast(self.y) + self[HeightSym]() / 2 - NumCast(self._starburstHeight, defaultSize) / 2; + self._width = NumCast(self._starburstWidth, defaultSize); + self._height = NumCast(self._starburstHeight, defaultSize); + self._layoutEngine = 'pass'; + } else { + const defaultSize = 25; + self.overflow = 'visible'; + !self.starburstRadius && (self.starburstRadius = 200); + if (self._layoutEngine === 'pass') { + self.x = NumCast(self.x) + self[WidthSym]() / 2 - defaultSize / 2; + self.y = NumCast(self.y) + self[HeightSym]() / 2 - defaultSize / 2; + self._starburstWidth = self._width; + self._starburstHeight = self._height; + } + self._width = self._height = defaultSize; + self._layoutEngine = 'starburst'; + } +});
\ No newline at end of file |