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..b4d40c8 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: @@ -20,7 +23,10 @@ CandyShop.CreateRoom = (function(self, Candy, $) { /** * Initializes the CreateRoom plugin with the default settings. */ - self.init = function(){ + self.init = function(options){ + // 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.