Skip to content

Commit

Permalink
Add custom icon FIX #14
Browse files Browse the repository at this point in the history
By passing an aditional parameter, you are able to add your own png/svg
image as icon. All explained in readme docs
  • Loading branch information
CodingCarlos committed Mar 7, 2017
1 parent 1712607 commit 1ac4b12
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ To configure the chat, just use the object passed on IASChat instantiation. *Bol
- topbarColor: Color Chat topbar text and icons color
- buttonBg: Color Show button background color
- buttonColor: Color Show button text/icon color
- buttonIcon: String Image URI for the icon you want to add in the open button. SVG or PNG recommended, but all image types should work
- inputBorderColor: Color Chat text input border bottom color
- container: String Container for chat (*#identifier* or *.className*)
- hashSign: String Symbol or string to add before url hash when chat open (Default: '?'. I.e.: url#existentHash**?**ias=true)
Expand Down
1 change: 1 addition & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ <h1>User side support</h1>
button: true,
// topbarBg: 'lightgrey',
// topbarColor: '#000',
// buttonIcon: 'http://simpleicon.com/wp-content/uploads/rocket.png',
// buttonBg: 'red',
// buttonColor: '#ccc',
// inputBorderColor: 'rgba(0, 0, 0, .2)',
Expand Down
11 changes: 11 additions & 0 deletions dist/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function IASChat(config) {
var topbarColor = config.topbarColor || textColor;
var buttonBg = config.buttonBg || mainColor;
var buttonColor = config.buttonColor || textColor;
var buttonIcon = config.buttonIcon || null;
var inputBorderColor = config.inputBorderColor || mainColor;
var defaultSupportName = config.defaultSupportName || 'Support chat';
var defaultSupportPic = config.defaultSupportPic || 'https://s3.amazonaws.com/uifaces/faces/twitter/robertovivancos/128.jpg';
Expand Down Expand Up @@ -177,6 +178,16 @@ function IASChat(config) {
form.children[1].style.margin = '0 16px';
form.children[1].style.width = 'calc(100% - 88px)';
}

// If changed button icon
if(buttonIcon) {
var icon = document.createElement('img');
icon.style.width = '24px';
icon.style.height = '24px';
icon.setAttribute('src', buttonIcon);
document.getElementById('ias-show').removeChild(document.getElementById('ias-show').firstChild);
document.getElementById('ias-show').appendChild(icon);
}
}


Expand Down
11 changes: 11 additions & 0 deletions js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function IASChat(config) {
var topbarColor = config.topbarColor || textColor;
var buttonBg = config.buttonBg || mainColor;
var buttonColor = config.buttonColor || textColor;
var buttonIcon = config.buttonIcon || null;
var inputBorderColor = config.inputBorderColor || mainColor;
var defaultSupportName = config.defaultSupportName || 'Support chat';
var defaultSupportPic = config.defaultSupportPic || 'https://s3.amazonaws.com/uifaces/faces/twitter/robertovivancos/128.jpg';
Expand Down Expand Up @@ -177,6 +178,16 @@ function IASChat(config) {
form.children[1].style.margin = '0 16px';
form.children[1].style.width = 'calc(100% - 88px)';
}

// If changed button icon
if(buttonIcon) {
var icon = document.createElement('img');
icon.style.width = '24px';
icon.style.height = '24px';
icon.setAttribute('src', buttonIcon);
document.getElementById('ias-show').removeChild(document.getElementById('ias-show').firstChild);
document.getElementById('ias-show').appendChild(icon);
}
}


Expand Down

0 comments on commit 1ac4b12

Please sign in to comment.