Skip to content

Commit 0e43300

Browse files
authored
Merge pull request #10 from CodingCarlos/dev
Shall work
2 parents 91eb87d + f174f85 commit 0e43300

File tree

19 files changed

+2379
-18
lines changed

19 files changed

+2379
-18
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
# --- Node modules ---------------------
2+
node_modules/
3+
14
# -- Firebase config -------------------
2-
js/firebase.js
5+
js/firebase.js
6+
dist/firebase.js

README.md

Lines changed: 135 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,136 @@
1+
![shieldsIO](https://img.shields.io/github/issues/CodingCarlos/inapp-support.svg)
2+
![shieldsIO](https://img.shields.io/github/release/CodingCarlos/inapp-support.svg)
3+
![shieldsIO](https://img.shields.io/badge/license-AGPL-blue.svg)
4+
5+
**WARNING**: This is not a stable version. We are currently developing things, and it may have heavy security problems, have parts not finished, have parts broken, or crash unexpectedly. I do not recommend you to use it in production yet.
6+
17
# inapp-support
2-
HTML5 inApp support chat using your own firebase account
8+
HTML5 inApp support chat using your own firebase account. It is also possible to send images. Just include firebase, your config (as in firebase console is given to you), and add to your code:
9+
10+
```html
11+
<!-- Include IASChat, take it from dist/chat.js -->
12+
<script src="js/chat.js"></script>
13+
14+
<!-- Main working -->
15+
<script type="text/javascript">
16+
window.onload = function() {
17+
window.IASChat = new IASChat({
18+
uid: '33g07u1sDg44aa12', // The user id here
19+
name: 'CodingCarlos', // The user name here
20+
pic: 'http://yourdomain.com/pic/user/pic.jpg' // The user picture here
21+
button: true
22+
});
23+
};
24+
</script>
25+
```
26+
27+
And it's done!
28+
29+
---
30+
31+
## Configuration
32+
### client js
33+
To configure the chat, just use the object passed on IASChat instantiation. *Bold are mandatory*
34+
35+
- **uid**: String User id (if you put a Number, shall work, but I can't promise you that it will work as expected)
36+
- **name**: String User name
37+
- **pic**: String User picture
38+
- **button**: Boolean Show or not the fab button to open the chat
39+
- mainColor: Color [hex, name, rgb, rgba] Main color (chat topbar background, show button background and chat input border bottom)
40+
- textColor: Color Main text color (Chat topbar text/icons, show button text/icons)
41+
- topbarBg: Color Chat topbar background color
42+
- topbarColor: Color Chat topbar text and icons color
43+
- buttonBg: Color Show button background color
44+
- buttonColor: Color Show button text/icon color
45+
- inputBorderColor: Color Chat text input border bottom color
46+
- container: String Container for chat (*#identifier* or *.className*)
47+
- hashSign: String Symbol or string to add before url hash when chat open (Default: '?'. I.e.: url#existentHash**?**ias=true)
48+
- defaultSupportName: String Default support name (if no supporter assigned)
49+
- defaultSupportPic: String Default support picture (if no supporter assigned)
50+
51+
In IASChatProvider, there are some extra features:
52+
- container: String Container for support panel (*#identifier* or *.className*. Default: *body*)
53+
- chatContainer: String Container for chat (*#identifier* or *.className*. Default: *body* or support container)
54+
55+
In the future, early future, I hope to add...
56+
- uploadFiles: Boolean Enable or disable the option to upload and send pictures.
57+
- onlyPictures: Boolean Allow only pictures, or all file types.
58+
59+
*I'm open to any suggestion or request for more configuration params. Don't hesitate to open a new Issue*
60+
61+
### firebase
62+
Create a new firebase project (or use a existing one), and add the configuration script to your code, if possible, before including chat.js.
63+
64+
Then, configure your security rules according to your authentication method (if you are already using firebase authentication as app authentication, the same authentication is valid). If you are not already using firebase authentication, but a custom method, maybe you shall [use the firease custom authentication method](https://firebase.google.com/docs/auth/web/custom-auth) (I'll try to add more info and demos in the future).
65+
66+
Just for a test, set the rules as this for database:
67+
```
68+
{
69+
"rules": {
70+
".read": true,
71+
".write": true
72+
}
73+
}
74+
```
75+
And for storage:
76+
```
77+
service firebase.storage {
78+
match /b/chat-e6e7d.appspot.com/o {
79+
match /{allPaths=**} {
80+
allow read, write: if true;
81+
//allow read, write: if request.auth != null;
82+
}
83+
}
84+
}
85+
```
86+
**Be careful**: *This allows anybody to read and write ALL your database and files. This is just for test prouposes, not for production.*
87+
88+
## Support panel
89+
Check the code in demo/support.html to add to your existent panel. No authorization/authentication done here. That is your work in your own control/support pannel. As said before, you shall check yourself the firebase rules.
90+
91+
```html
92+
<!-- Include IASChat -->
93+
<script src="js/chat.js"></script>
94+
<!-- Include IASChat Support Provider -->
95+
<script src="js/provider.js"></script>
96+
97+
<!-- Main working -->
98+
<script type="text/javascript">
99+
window.onload = function() {
100+
window.IASChatProvider = new IASChatProvider({
101+
uid: '8sd0df4s8f0ss', // The support user id here
102+
name: 'Supporter', // The support user name here
103+
pic: 'http://yourdomain.com/pic/user/pic.jpg' // The supporter picture here
104+
container: '#container' // OPTIONAL: Container for support pannel (*#identifier* or *.className*).
105+
});
106+
};
107+
</script>
108+
```
109+
110+
### Assign user to supporter
111+
Supporter wil got assigned any chat that answer. Unassigned chats will appear to all supporters. To change assignation, for now, you have to do it in firebase console.
112+
113+
In the future any supporter will be able to assign a chat, or change it's assignations to other supporter. But so, in the future.
114+
115+
### Add supporters
116+
Initialize the support user, and done.
117+
118+
### Secure the panel
119+
This is your work. Support pannel in demo folder is not really a support panel, but a demo. This is not a fully control panel app, just a support chat "component" to add to your existing app.
120+
121+
122+
## Responsiveness
123+
Nope, right now is not desktop/tablet responsive, just mobile, but I'm doing my best to add larger screen support.
124+
125+
## Contribute
126+
You can use this code as you like. If you find a bug, or want to ask for a feature, just open an issue, and we'll do our best. If you can fix it, do a pull request to ``dev`` branch, and we promise to review it as fast as possible to merge it.
127+
128+
If you are new on this open source world, here is a short guide about how to make a pull request to contribute:
129+
130+
1. [Fork](https://github.com/CodingCarlos/inapp-support/fork) then clone `git clone [email protected]:your-username/inapp-support.git` inapp-support repository
131+
2. Create a new branch in your personally forked repo, with a name similar to your edits, such as `fix-whatever`
132+
3. Make your edits inside your new branch
133+
4. Commit them and push them back to your personal github fork
134+
5. Make a new [Pull Request](https://github.com/CodingCarlos/inapp-support/compare/) on the inapp-support repo. Point your branch to the `dev` inapp-support branch and submit.
135+
136+
I will do my best to review and accept the commit as soon as possible.

css/style.css

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#ias {
2+
position: fixed;
3+
top: 0;
4+
left: 0;
5+
height: 100%;
6+
width: 100%;
7+
z-index: 999;
8+
}
9+
10+
#ias.hidden {
11+
display: none;
12+
}
13+
14+
#ias_topbar {
15+
background-color: #ff9800;
16+
height: 56px;
17+
width: 100%;
18+
}
19+
20+
#ias_topbar #ias_topbar-pic {
21+
padding: 8px 16px;
22+
width: 40px;
23+
height: 40px;
24+
float: left;
25+
}
26+
#ias_topbar #ias_topbar-pic img {
27+
height: 100%;
28+
border-radius: 50%;
29+
}
30+
31+
#ias_topbar #ias_topbar-text {
32+
float: left;
33+
margin-left: 6px;
34+
margin-top: 15px;
35+
font-size: 24px;
36+
color: #fff;
37+
}
38+
39+
#ias_topbar #ias_topbar-close {
40+
color: #fff;
41+
float: right;
42+
font-size: 24px;
43+
margin: 16px 16px 0 0;
44+
}
45+
46+
47+
#ias_messages {
48+
background: #f7f8fb;
49+
height: calc(100% - 112px);
50+
overflow: auto;
51+
padding-top: 12px;
52+
}
53+
54+
.ias_message {
55+
margin: 4px 8px;
56+
padding: 4px 12px;
57+
}
58+
59+
.ias_message-sent {
60+
text-align: right;
61+
}
62+
63+
.ias_message span {
64+
background-color: #fff;
65+
padding: 4px 12px;
66+
border-radius: 5px 5px 0 5px;
67+
box-shadow: 1px 1px 5px rgba(0,0,0,.1);
68+
color: #333;
69+
}
70+
71+
72+
#ias_write {
73+
background-color: #fff;
74+
border-top: 1px solid #efefef;
75+
height: 48px;
76+
position: fixed;
77+
bottom: 0;
78+
left: 0;
79+
width: 100%;
80+
}
81+
82+
#ias_write input {
83+
border: 0;
84+
border-bottom: 1px solid #ff9800;
85+
height: 31px;
86+
margin: 0 16px;
87+
outline: none;
88+
padding: 8px 8px 0px 8px;
89+
width: 85%;
90+
width: calc(100% - 96px);
91+
}
92+
93+
#ias_write button {
94+
background-color: #fff;
95+
border: none;
96+
position: fixed;
97+
right: 12px;
98+
bottom: 5px;
99+
border-radius: 50%;
100+
font-size: 24px;
101+
width: 34px;
102+
padding: 0;
103+
overflow: hidden;
104+
line-height: normal;
105+
}
106+
107+
#ias_write button img {
108+
width: 70%;
109+
}
110+
111+
112+
#ias-show {
113+
background-color: #ff9800;
114+
border-radius: 50%;
115+
bottom: 16px;
116+
box-shadow: 0 1px 1.5px 0 rgba(0,0,0,.12), 0 1px 1px 0 rgba(0,0,0,.24);
117+
box-sizing: border-box;
118+
height: 56px;
119+
padding: 16px;
120+
position: fixed;
121+
right: 16px;
122+
width: 56px;
123+
}

demo/index.html

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>InApp Support</title>
7+
8+
<!-- Disable tap highlight on IE -->
9+
<meta name="msapplication-tap-highlight" content="no">
10+
11+
<!-- Web Application Manifest -->
12+
<!-- <link rel="manifest" href="manifest.json"> -->
13+
14+
<!-- Add to homescreen for Chrome on Android -->
15+
<meta name="mobile-web-app-capable" content="yes">
16+
<meta name="application-name" content="inApp support">
17+
<meta name="theme-color" content="#303F9F">
18+
19+
<!-- Add to homescreen for Safari on iOS -->
20+
<meta name="apple-mobile-web-app-capable" content="yes">
21+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
22+
<meta name="apple-mobile-web-app-title" content="inApp Support">
23+
<meta name="apple-mobile-web-app-status-bar-style" content="#303F9F">
24+
25+
<!-- Tile icon for Win8 -->
26+
<meta name="msapplication-TileColor" content="#3372DF">
27+
<meta name="msapplication-navbutton-color" content="#303F9F">
28+
29+
30+
31+
<!-- App Styling -->
32+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&amp;lang=en">
33+
</head>
34+
<body>
35+
36+
<h1>User side support</h1>
37+
38+
<!-- <div id="ias-show">OPEN CHAT</div> -->
39+
40+
<!-- Firebase -->
41+
<script src="https://www.gstatic.com/firebasejs/3.6.1/firebase.js"></script>
42+
<script src="../js/firebase.js"></script>
43+
44+
<!-- Include IASChat -->
45+
<script src="../dist/chat.js"></script>
46+
47+
<!-- Main working -->
48+
<script type="text/javascript">
49+
window.onload = function() {
50+
window.IASChat = new IASChat({
51+
uid: 1234,
52+
name: 'paco',
53+
pic: 'https://s3.amazonaws.com/uifaces/faces/twitter/brad_frost/128.jpg',
54+
button: true,
55+
// topbarBg: 'lightgrey',
56+
// topbarColor: '#000',
57+
// buttonBg: 'red',
58+
// buttonColor: '#ccc',
59+
// inputBorderColor: 'rgba(0, 0, 0, .2)',
60+
mainColor: '#ff9800',
61+
textColor: '#fff',
62+
defaultSupportName: 'John Doe',
63+
defaultSupportPic: 'http://lorempixel.com/100/100/people'
64+
});
65+
};
66+
</script>
67+
68+
</body>
69+
</html>

0 commit comments

Comments
 (0)