WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 41a673a

Browse files
committed
Added help center handlers.
1 parent 1228bea commit 41a673a

File tree

8 files changed

+68
-8
lines changed

8 files changed

+68
-8
lines changed

src/grid/ko/gridEditor.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,25 @@ export class GridEditor {
105105
binding: binding,
106106
half: half,
107107
providers: providers,
108+
openHelpCenter: (articleKey: string) => {
109+
const view: View = {
110+
heading: "Help center",
111+
component: {
112+
name: "help-center",
113+
params: {
114+
articleKey: articleKey,
115+
}
116+
},
117+
resizing: {
118+
directions: "vertically horizontally",
119+
initialWidth: 500,
120+
initialHeight: 700
121+
},
122+
scrolling: false
123+
};
124+
125+
this.viewManager.openViewAsPopup(view);
126+
},
108127
openWidgetEditor: () => {
109128
this.viewManager.openWidgetEditor(binding);
110129
},

src/ko/bindingHandlers/bindingHandlers.helpCenter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ export class HelpCenterBindingHandler {
2121
directions: "vertically horizontally",
2222
initialWidth: 500,
2323
initialHeight: 700
24-
}
24+
},
25+
scrolling: false
2526
};
2627

2728
this.viewManager.openViewAsPopup(view);
2829
};
2930

30-
ko.applyBindingsToNode(element, { click: openHelpCenter }, null);
31+
ko.applyBindingsToNode(element, { activate: openHelpCenter }, null);
3132
}
3233
};
3334
}

src/ko/bindingHandlers/bindingHandlers.tooltip.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,21 @@ import { BalloonHandle, BalloonActivationMethod } from "@paperbits/common/ui/bal
55
const defaultTooltipDelayMs = 700;
66

77
interface TooltipOptions {
8+
/**
9+
* Tooltip heading.
10+
*/
11+
heading?: string;
12+
813
/**
914
* Tooltip message.
1015
*/
1116
message: string;
1217

18+
/**
19+
* Tooltip help article.
20+
*/
21+
articleKey?: string;
22+
1323
/**
1424
* Preferred tooltip position, e.g. `top`.
1525
*/
@@ -31,6 +41,11 @@ interface TooltipOptions {
3141
isDisabled: ko.Observable<boolean>;
3242
}
3343

44+
interface TooltipParams {
45+
heading: string;
46+
observableText: ko.Observable<string>;
47+
articleKey: string;
48+
}
3449

3550
ko.bindingHandlers["tooltip"] = {
3651
init: (triggerElement: HTMLElement, valueAccessor: () => TooltipOptions) => {
@@ -63,7 +78,11 @@ ko.bindingHandlers["tooltip"] = {
6378
let hasText: boolean = false;
6479
const isDisabled: () => boolean = () => !!options.isDisabled ? options.isDisabled() : false;
6580

66-
const textParams: any = {};
81+
const textParams: TooltipParams = {
82+
heading: options.heading,
83+
observableText: null,
84+
articleKey: options.articleKey
85+
};
6786
let closeTimeout = 0;
6887

6988
if (ko.isObservable(tooltipMessage)) {
@@ -80,7 +99,7 @@ ko.bindingHandlers["tooltip"] = {
8099
}
81100
else {
82101
hasText = !!tooltipMessage;
83-
textParams.text = tooltipMessage;
102+
textParams.observableText = tooltipMessage;
84103
}
85104

86105
ko.applyBindingsToNode(triggerElement, {

src/ko/ui/tooltip.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1-
<div class="tooltip" data-bind="html: observableText, scrollable: true"></div>
1+
<div class="tooltip">
2+
<!-- ko if: heading -->
3+
<h1 data-bind="text: heading"></h1>
4+
<!-- /ko-->
5+
<div data-bind="html: observableText, scrollable: true"></div>
6+
7+
<!-- ko if: articleKey -->
8+
<a href="#" class="btn btn-link" data-bind="helpCenter: articleKey">Learn more ></a>
9+
<!-- /ko-->
10+
</div>
11+
212
<span class="text-hide" aria-live="polite" data-bind="text: announcementText"></span>

src/ko/ui/tooltip.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,24 @@ export class Tooltip {
1111
public readonly announcementText: ko.Observable<string>;
1212

1313
constructor() {
14+
this.heading = ko.observable();
1415
this.observableText = ko.observable();
1516
this.announcementText = ko.observable();
17+
this.articleKey = ko.observable();
1618
}
1719

1820
@Param()
1921
public text: any;
2022

23+
@Param()
24+
public heading: any;
25+
2126
@Param()
2227
public observableText: any;
2328

29+
@Param()
30+
public articleKey: any;
31+
2432
@OnMounted()
2533
public init(): void {
2634
if (!this.text) {

src/workshops/navigation/ko/navigationToolButton.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ToolButton, ViewManager, View } from "@paperbits/common/ui";
22

3-
const helpText = "<h1>Navigation</h1><p>Add or edit navigation menus.</p>";
3+
const helpText = "<p>Add or edit navigation menus.</p>";
44

55
export class NavigationToolButton implements ToolButton {
66
public readonly iconClass: string = "paperbits-icon paperbits-menu-34";
@@ -15,6 +15,7 @@ export class NavigationToolButton implements ToolButton {
1515
const view: View = {
1616
heading: this.title,
1717
helpText: helpText,
18+
helpArticle: "/navigation",
1819
component: { name: "navigation" }
1920
};
2021

src/workshops/page/ko/pagesToolButton.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ToolButton, ViewManager, View } from "@paperbits/common/ui";
22

3-
const helpText = "<h1>Pages</h1><p>Add or edit pages of your website. Each page has a unique URL, which also automatically defines the layout it is part of.</p>";
3+
const helpText = "<p>Add or edit pages of your website. Each page has a unique URL, which also automatically defines the layout it is part of.</p>";
44

55
export class PagesToolButton implements ToolButton {
66
public readonly iconClass: string = "paperbits-icon paperbits-menu-4";
@@ -14,7 +14,9 @@ export class PagesToolButton implements ToolButton {
1414

1515
const view: View = {
1616
heading: this.title,
17+
helpHeading: this.title,
1718
helpText: helpText,
19+
helpArticle: "/pages",
1820
component: { name: "pages" }
1921
};
2022

src/workshops/workshops.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1>
2828
<span data-bind="text: heading"></span>
2929
<!-- ko if: $data.helpText -->
3030
<button class="btn-help" role="tooltip" aria-label="Help"
31-
data-bind="tooltip: { message: $data.helpText, position: 'right', activateOn: 'clickOrKeyDown' }">
31+
data-bind="tooltip: { heading: $data.helpHeading, message: $data.helpText, articleKey: $data.helpArticle, position: 'right', activateOn: 'clickOrKeyDown' }">
3232
<i aria-hidden="true" class="paperbits-icon paperbits-c-question"></i>
3333
</button>
3434
<!--/ko -->

0 commit comments

Comments
 (0)