This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
forked from cameroncondry/cbc-kitten-scientists
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4c3199
commit 2d6e454
Showing
4 changed files
with
71 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { UserScript } from "../../UserScript"; | ||
|
||
export class ExpandoButton { | ||
readonly host: UserScript; | ||
readonly element: JQuery<HTMLElement>; | ||
|
||
/** | ||
* Constructs an expando element that is commonly used to expand and | ||
* collapses a section of the UI. | ||
* | ||
* @param host A reference to the host. | ||
* @param id The ID of the section this is the expando for. | ||
*/ | ||
constructor(host: UserScript, id: string) { | ||
const element = $("<div/>", { | ||
id: `toggle-items-${id}`, | ||
title: host.engine.i18n("ui.itemsShow"), | ||
text: "+", | ||
}).addClass("ks-expando-button"); | ||
|
||
this.element = element; | ||
this.host = host; | ||
} | ||
|
||
setCollapsed() { | ||
this.element.prop("title", this.host.engine.i18n("ui.itemsShow")); | ||
this.element.text("+"); | ||
} | ||
setExpanded() { | ||
this.element.prop("title", this.host.engine.i18n("ui.itemsHide")); | ||
this.element.text("-"); | ||
} | ||
|
||
refreshUi() { | ||
/* intentionally left blank */ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { UserScript } from "../../UserScript"; | ||
|
||
export abstract class UiComponent { | ||
/** | ||
* A reference to the host itself. | ||
*/ | ||
readonly host: UserScript; | ||
|
||
/** | ||
* The main DOM element for this component, in a JQuery wrapper. | ||
*/ | ||
abstract readonly element: JQuery<HTMLElement>; | ||
|
||
constructor(host: UserScript) { | ||
this.host = host; | ||
} | ||
|
||
abstract refreshUi(): void; | ||
} |