From bb41ec5c32873c80f72a85d02bb22bb8ac5809ed Mon Sep 17 00:00:00 2001 From: Melissa Noelle Date: Mon, 25 Aug 2014 12:12:15 -0400 Subject: [PATCH] Adding subdomain option to createroom plugin. --- createroom/README.md | 6 ++++-- createroom/createroom.js | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/createroom/README.md b/createroom/README.md index 07abb28..103da00 100644 --- a/createroom/README.md +++ b/createroom/README.md @@ -11,8 +11,10 @@ Include the JavaScript and CSS files: ``` -To enable this Left Tabs plugin, add its `init` method _before_ you `init` Candy: +To enable the Create Room plugin, add its `init` method _before_ you `init` Candy. You can pass it your chat subdomain as well: ```JavaScript -CandyShop.CreateRoom.init(); +CandyShop.CreateRoom.init({ + subdomain: 'chat' +}); Candy.init('/http-bind', { ... ``` diff --git a/createroom/createroom.js b/createroom/createroom.js index e05f4e3..35b2727 100644 --- a/createroom/createroom.js +++ b/createroom/createroom.js @@ -6,6 +6,9 @@ var CandyShop = (function(self) { return self; }(CandyShop || {})); CandyShop.CreateRoom = (function(self, Candy, $) { + self._options = { + subdomain: 'conference' + } /** Object: about * * Contains: @@ -21,6 +24,9 @@ CandyShop.CreateRoom = (function(self, Candy, $) { * Initializes the CreateRoom plugin with the default settings. */ self.init = function(){ + // apply the supplied options to the defaults specified + $.extend(true, self._options, options); + $(Candy).on('candy:view.room.after-add', function() { self.appendButton(); }); @@ -54,7 +60,7 @@ CandyShop.CreateRoom = (function(self, Candy, $) { } else { var roomName = $('#create-group-form-name').val().trim(); // Create a valid roomjid. - var roomJid = roomName.replace(/[^A-Z0-9]+/ig, "_").toLowerCase() + '@conference.' + + var roomJid = roomName.replace(/[^A-Z0-9]+/ig, "_").toLowerCase() + '@' + self._options.subdomain + '.' + Candy.Core.getConnection().domain; // Once we've joined the room, send configuration information.