Skip to content

Commit 6672f1c

Browse files
committed
Merge pull request #6 from bradmb/button-binding
Binding Interface Display To A Button Element
2 parents 0a3e3c6 + 05d40e1 commit 6672f1c

File tree

10 files changed

+157
-65
lines changed

10 files changed

+157
-65
lines changed

README.md

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,31 @@
44

55
This script was designed based on a need I had to provide a simple Slack support interface for end users of an application, but also as a challenge to myself to build a full JavaScript plugin without using JQuery (which I have become extremely comfortable using for everything).
66

7+
----------
8+
9+
## How it works ##
10+
11+
When a user pulls up this support window, it will establish a websocket connection to the Slack API, pulling messages back in real time.
12+
13+
As more than one user could be in the support channel at a time, messages to users of this interface are filtered, requiring you to specify a unique id at the beginning of your message in Slack.
14+
15+
Not only will this allow you and your team to chat between each other about the question without it spamming the user, but it will also ensure that messages directed to that user don't show up in other user windows.
16+
17+
The first message from a user sent from this interface will include a message attachment that instructs how to reply to this user by using their unique id. The unique id will also show next to the user's name in each message they send.
18+
19+
----------
20+
21+
## What it looks like ##
22+
This is the display for the default "float" configuration. If docking to the left/right side of the screen, you will instead get a narrow interface that extends from the top to the bottom of your page.
23+
24+
### The welcome screen (if you don't pass a name in the config) ###
25+
<img src="http://i.imgur.com/SyIIp3o.png" width="500" />
26+
27+
### The chat interface with an ongoing conversation ###
28+
<img src="http://i.imgur.com/IXlHfFL.png" width="500" />
29+
30+
### What it looks like from a Slack channel ###
31+
<img src="http://i.imgur.com/n1NcOYH.png" width="500" />
732

833
----------
934

@@ -14,7 +39,7 @@ This script was designed based on a need I had to provide a simple Slack support
1439

1540
----------
1641

17-
## How to setup ##
42+
## How to install ##
1843
Download a copy of the [latest release from the releases page](https://github.com/bradmb/sl.js/releases) and reference them in your code.
1944

2045
If you're using Visual Studio, simply grab the file off NuGet to ensure you have access to the latest package at all times:
@@ -23,19 +48,30 @@ If you're using Visual Studio, simply grab the file off NuGet to ensure you have
2348
PM> Install-Package sl.js -Pre
2449
```
2550

26-
Today, running the script will fully display the interface, but a button binding will be coming soon (see: to do list). Until then, you will need to setup your own binding on a button to initialize the code.
51+
## How to setup ##
2752

28-
To bring up the interface, simply call this:
53+
Your basic configuration items are simple: Your Slack token, the Slack Channel ID, and the DIV where this will use as the spot where all the elements are rendered:
2954
```javascript
3055
var slConfig = {
3156
token: 'SLACK-TOKEN',
3257
channel: 'SLACK-CHANNEL',
3358
element: 'PAGE-DIV-ID'
3459
};
60+
```
61+
62+
63+
To bind this interface to a button that will display on click, use this:
64+
```javascript
65+
var sl = new SLjs.Button('BUTTON-ID', slConfig);
66+
```
3567

36-
var sl = new SLjs.Application(slConfig);
68+
To bring up the interface immediately (no binding to a button), simply call this:
69+
```javascript
70+
var sl = new SLjs.Interface(slConfig);
3771
```
3872

73+
## Extra configuration options ##
74+
3975
The configuration options listed above are the *minimum* options required. You are free to fill in additional parameters, including:
4076

4177
Parameter | Type | Description | Options
@@ -67,22 +103,8 @@ workDates: {
67103

68104
----------
69105

70-
## How it works ##
71-
72-
When a user pulls up this support window, it will establish a websocket connection to the Slack API, pulling messages back in real time.
73-
74-
As more than one user could be in the support channel at a time, messages to users of this interface are filtered, requiring you to specify a unique id at the beginning of your message in Slack.
75-
76-
Not only will this allow you and your team to chat between each other about the question without it spamming the user, but it will also ensure that messages directed to that user don't show up in other user windows.
77-
78-
The first message from a user sent from this interface will include a message attachment that instructs how to reply to this user by using their unique id. The unique id will also show next to the user's name in each message they send.
79-
80-
----------
81-
82106
## To do ##
83-
- Add non-websocket backup feature
84-
- Add server-side features (id generation, traffic routing)
85107
- ~~Add additional display methods (docking to left/right of page)~~
86-
- Add button binding options
108+
- ~~Add button binding options~~
87109
- Add support for parsing Slack message edits
88110
- ~~Add support work hours~~

sl.js/release/sl.js

Lines changed: 60 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sl.js/release/sl.js.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134

135135
#sljs-wrapper.sljs-pos-side #sljs-interface.sljs-chat .sljs-chat-message-input {
136136
position: absolute;
137-
bottom: 0;
137+
bottom: 5px;
138138

139139
padding: 10px;
140140

sl.js/release/sl.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)