Commit d3e8e060 authored by Eric Eastwood's avatar Eric Eastwood

Add `options.host`

parent 46a2e0a3
......@@ -28,7 +28,7 @@
document.querySelector('.js-create-chat-button').addEventListener('click', function(e) {
console.log('Create');
chat = new GitterChat({
room: 'gitterHQ/sidecar'
room: 'gitterHQ/sidecar-demo'
});
});
......
......@@ -13,7 +13,7 @@
<button class="js-gitter-toggle-chat-button" data-gitter-toggle-chat-state="false">Close Chat</button>
<script>
((window.gitter = {}).chat = {}).options = {
room: 'marionettejs/backbone.marionette'
room: 'gitterHQ/sidecar-demo'
};
</script>
<script src="../../dist/sidecar.js" async defer></script>
......
......@@ -11,8 +11,6 @@ import * as domUtility from './dom-utility.js';
const gitterUrl = 'https://gitter.im/';
let parseAttributeTruthiness = function(value) {
if(value) {
......@@ -125,8 +123,8 @@ let embedGitterChat = function(opts) {
if(targetElementOpts.room) {
let iframe = elementStore.createElement('iframe');
iframe.setAttribute('frameborder', '0');
iframe.src = `${gitterUrl}${targetElementOpts.room}/~embed`;
//iframe.src = `${gitterUrl}${targetElementOpts.room}/~chat`;
iframe.src = `${opts.host}${targetElementOpts.room}/~embed`;
//iframe.src = `${opts.host}${targetElementOpts.room}/~chat`;
targetElement.appendChild(iframe);
}
......@@ -165,9 +163,15 @@ const defaults = {
// - `fixed`
// - `off-canvas`
// - `flex-aside`
layout: 'fixed'
layout: 'fixed',
//showLeftMenu: false
// Undocumented private options ;)
// Base URL of the gitter instance you are running
// We are not using a nice URL parser/formatter,
// so make sure to add the trailing slash so that concating goes smooth
host: 'https://gitter.im/'
};
......@@ -243,7 +247,7 @@ class chatEmbed {
activationElement = $(activationElement || (() => {
let button = this[ELEMENTSTORE].createElement('a');
// We use the option for the room (not pertaining to a particular targetElement attribute if set)
button.href = `${gitterUrl}${opts.room}`;
button.href = `${opts.host}${opts.room}`;
button.innerHTML = 'Open Chat';
button.classList.add('gitter-open-chat-button');
document.body.appendChild(button);
......@@ -328,7 +332,7 @@ class chatEmbed {
this.toggleChat(false);
// Open in new tab
let win = window.open(`${gitterUrl}${this[OPTIONS].room}`, '_blank');
let win = window.open(`${opts.host}${this[OPTIONS].room}`, '_blank');
win.focus();
e.preventDefault();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment