|
@@ -66,12 +66,36 @@
|
|
const _converse = this.__super__._converse;
|
|
const _converse = this.__super__._converse;
|
|
this.__super__.initialize.apply(this, arguments);
|
|
this.__super__.initialize.apply(this, arguments);
|
|
this.registerlink = new _converse.RegisterLink();
|
|
this.registerlink = new _converse.RegisterLink();
|
|
- this.el.appendChild(this.registerlink.el);
|
|
|
|
|
|
+ const div = document.createElement('div');
|
|
|
|
+ div.innerHTML = tpl_register_link({'__': _converse.__})
|
|
|
|
+ this.el.appendChild(div);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
ControlBoxView: {
|
|
ControlBoxView: {
|
|
|
|
|
|
|
|
+ initialize () {
|
|
|
|
+ this.__super__.initialize.apply(this, arguments);
|
|
|
|
+ this.model.on('change:active-form', this.showLoginOrRegisterForm.bind(this))
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ showLoginOrRegisterForm (ev) {
|
|
|
|
+ const { _converse } = this.__super__;
|
|
|
|
+ if (this.model.get('active-form') == "register") {
|
|
|
|
+ this.loginpanel.el.classList.add('hidden');
|
|
|
|
+ this.registerpanel.el.classList.remove('hidden');
|
|
|
|
+ if (_converse.registration_domain &&
|
|
|
|
+ ev.target.getAttribute('data-id') === "register" &&
|
|
|
|
+ !this.model.get('registration_form_rendered')) {
|
|
|
|
+ this.registerpanel.fetchRegistrationForm(_converse.registration_domain);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.loginpanel.el.classList.remove('hidden');
|
|
|
|
+ this.registerpanel.el.classList.add('hidden');
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
renderRegistrationPanel () {
|
|
renderRegistrationPanel () {
|
|
const { _converse } = this.__super__;
|
|
const { _converse } = this.__super__;
|
|
if (_converse.allow_registration) {
|
|
if (_converse.allow_registration) {
|
|
@@ -84,6 +108,7 @@
|
|
'afterend',
|
|
'afterend',
|
|
this.registerpanel.el
|
|
this.registerpanel.el
|
|
);
|
|
);
|
|
|
|
+ this.showLoginOrRegisterForm();
|
|
}
|
|
}
|
|
return this;
|
|
return this;
|
|
},
|
|
},
|
|
@@ -118,33 +143,37 @@
|
|
providers_link: 'https://xmpp.net/directory.php', // Link to XMPP providers shown on registration page
|
|
providers_link: 'https://xmpp.net/directory.php', // Link to XMPP providers shown on registration page
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+
|
|
|
|
+ _converse.RegistrationRouter = Backbone.Router.extend({
|
|
|
|
+
|
|
|
|
+ initialize () {
|
|
|
|
+ this.route('converse-login', _.partial(this.setActiveForm, 'login'));
|
|
|
|
+ this.route('converse-register', _.partial(this.setActiveForm, 'register'));
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ setActiveForm (value) {
|
|
|
|
+ _converse.api.waitUntil('controlboxInitialized').then(() => {
|
|
|
|
+ const controlbox = _converse.chatboxes.get('controlbox')
|
|
|
|
+ if (controlbox.get('connected')) {
|
|
|
|
+ controlbox.save({'active-form': value});
|
|
|
|
+ } else {
|
|
|
|
+ controlbox.set({'active-form': value});
|
|
|
|
+ }
|
|
|
|
+ }).catch(_.partial(_converse.log, _, Strophe.LogLevel.FATAL));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ const router = new _converse.RegistrationRouter();
|
|
|
|
+
|
|
|
|
+
|
|
_converse.RegisterLink = Backbone.View.extend({
|
|
_converse.RegisterLink = Backbone.View.extend({
|
|
tagName: 'div',
|
|
tagName: 'div',
|
|
- events: {
|
|
|
|
- 'click .register-account': 'showRegistrationForm'
|
|
|
|
- },
|
|
|
|
|
|
|
|
initialize () {
|
|
initialize () {
|
|
this.render();
|
|
this.render();
|
|
},
|
|
},
|
|
|
|
|
|
render () {
|
|
render () {
|
|
- this.el.innerHTML = tpl_register_link({'__': __});
|
|
|
|
return this;
|
|
return this;
|
|
- },
|
|
|
|
-
|
|
|
|
- showRegistrationForm (ev) {
|
|
|
|
- ev.preventDefault();
|
|
|
|
- document.querySelector("#converse-register-panel").classList.remove('hidden');
|
|
|
|
- document.querySelector("#converse-login-panel").classList.add('hidden');
|
|
|
|
- if (!_.isUndefined(_converse.chatboxes.browserStorage)) {
|
|
|
|
- this.model.save({'active-panel': "register"});
|
|
|
|
- }
|
|
|
|
- if (_converse.registration_domain &&
|
|
|
|
- ev.target.getAttribute('data-id') === "register" &&
|
|
|
|
- !this.model.get('registration_form_rendered')) {
|
|
|
|
- this.registerpanel.fetchRegistrationForm(_converse.registration_domain);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -153,8 +182,7 @@
|
|
id: "converse-register-panel",
|
|
id: "converse-register-panel",
|
|
className: 'controlbox-pane',
|
|
className: 'controlbox-pane',
|
|
events: {
|
|
events: {
|
|
- 'submit form#converse-register': 'onProviderChosen',
|
|
|
|
- 'click .login-here': 'showLoginForm'
|
|
|
|
|
|
+ 'submit form#converse-register': 'onProviderChosen'
|
|
},
|
|
},
|
|
|
|
|
|
initialize (cfg) {
|
|
initialize (cfg) {
|
|
@@ -193,15 +221,6 @@
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
|
|
- showLoginForm (ev) {
|
|
|
|
- ev.preventDefault();
|
|
|
|
- document.querySelector("#converse-login-panel").classList.remove('hidden');
|
|
|
|
- document.querySelector("#converse-register-panel").classList.add('hidden');
|
|
|
|
- if (!_.isUndefined(_converse.chatboxes.browserStorage)) {
|
|
|
|
- this.model.save({'active-panel': "login"});
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
getRegistrationFields (req, _callback, raw) {
|
|
getRegistrationFields (req, _callback, raw) {
|
|
/* Send an IQ stanza to the XMPP server asking for the
|
|
/* Send an IQ stanza to the XMPP server asking for the
|
|
* registration fields.
|
|
* registration fields.
|