Skip to content

Commit

Permalink
[Footer] simpler implementation of collabbutton notification badge
Browse files Browse the repository at this point in the history
  • Loading branch information
Tynan DeBold committed Dec 19, 2018
1 parent a4473c7 commit e7e7866
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 42 deletions.
49 changes: 11 additions & 38 deletions docs/src/xhtml/components/footer/collabbutton.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,25 @@
<h1>Footer collabbutton</h1>
<section>

<p>The Footer features a special button which is dedicated to launching the <em>collaboration</em> panel. To show the button, call <code>collabbutton</code> with a onclick method and a callback.</p>
<p>The Footer features a special button which is dedicated to launching the <em>collaboration</em> panel. To show the
button, simply call the method <code>configbutton</code> with a callback.</p>

<figure data-ts="DoxScript">
<script type="runnable">
ts.ui.Footer.collabbutton({
onclick: function() {
ts.ui.Notification.success('Go collaborate!');
}
ts.ui.Footer.collabbutton(function onclick() {
ts.ui.Notification.success('Go collaborate!');
});
</script>
</figure>

<h3>Showing a notification badge</h3>
<p>The collaboration button can have two states: a default state and a state showing a notification badge. The default state shows just the special button. The notification state shows the special button as well as a small notification badge over the icon. To show the button with the notification state, call the method with the onclick property and a callback, as show above, and also a badge property set to true.</p>
<p>The collaboration button can have two states: a default state and a state showing a notification badge. The default state shows just the special button. The notification state shows the special button as well as a small notification badge over the icon. To show the button with the notification state, add <code>true</code> as a second argument to the <code>configbutton</code> method.</p>

<figure data-ts="DoxScript">
<script type="runnable">
ts.ui.Footer.collabbutton({
badge: true,
onclick: function() {
ts.ui.Notification.success('Go collaborate!');
}
});
ts.ui.Footer.collabbutton(function onclick() {
ts.ui.Notification.success('Go collaborate!');
}, true);
</script>
</figure>

Expand All @@ -43,7 +39,7 @@
<script type="runnable">
ts.ui.Footer.collabbutton(null);
</script>
</figure>
</figure>

<div data-ts="DoxApi">
<script type="application/json">
Expand All @@ -52,31 +48,8 @@
"methods": [
{
"name": "collabbutton",
"args": "(<Object|null>)",
"desc": "Get or set the collaboration button. Pass `null` to remove the whole button."
}
]
}
</script>
</div>


<div data-ts="DoxApi">
<script type="application/json">
{
"name": "ts.ui.Footer.collabbutton",
"properties": [
{
"name": "badge",
"type": "boolean",
"desc": "Show the button with a badge."
}
],
"methods": [
{
"name": "onclick",
"args": "(Function)",
"desc": "Get or set the collaboration button."
"args": "(<Function|true|null>)",
"desc": "Get or set the collaboration button. Pass `true` as a second argument to show a notification badge. Pass `null` to remove the whole button."
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,17 @@ ts.ui.FooterBarModel = (function using(PagerModel, ActionModel, chained) {
* TODO: Move this thing to the general {ts.ui.ToolBarModel}
* @returns {this|ts.ui.ActionModel}
*/
collabbutton: chained(function(args) {
collabbutton: chained(function(onclick) {
var actions = this.bufferbar.actions;
if (arguments.length) {
actions.clear();
if (args !== null) {
if (onclick !== null) {
actions.push({
label: ts.ui.Footer.localize().collaboration,
icon: 'ts-icon-comment',
onclick: args.onclick
onclick: onclick
});
if (args.badge === true) {
if (arguments[1]) {
this.centerbar.collabbutton = this.backupbar.collabbutton = true;
} else {
this.centerbar.collabbutton = this.backupbar.collabbutton = false;
Expand Down

0 comments on commit e7e7866

Please sign in to comment.