/* Copyright (c) 2010, Movitica Team. All rights reserved. */ YAHOO.namespace("website.dialog"); /** * * */ YAHOO.website.dialog.NewFbUser = function(nUid, sFirstName, sLastName) { this._nUid = nUid; this._sFirstName = sFirstName; this._sLastName = sLastName; this._sName = sFirstName + sLastName; }; YAHOO.website.dialog.NewFbUser.prototype.id = null; YAHOO.website.dialog.NewFbUser.prototype._sUserName = null; YAHOO.website.dialog.NewFbUser.prototype._oDialog = null; YAHOO.website.dialog.NewFbUser.prototype._nUid = null; YAHOO.website.dialog.NewFbUser.prototype._sFirstName = null; YAHOO.website.dialog.NewFbUser.prototype._sLastName = null; /** * */ YAHOO.website.dialog.NewFbUser.prototype.show = function() { if (this._oDialog == null) { this.id = Dom.generateId(null, "modal-dialog-"); var oDialog = this._oDialog = new YAHOO.widget.Panel(this.id, { modal: true, width: "300px", fixedcenter: true, constraintoviewport: true, underlay: "shadow", close: true, visible: false, draggable: false }); var sOkBtnId = Dom.generateId(null, "btn-ok-"); oDialog.setHeader("Select preferable username"); oDialog.setBody( "You are not registered at movitica.com. You can use Facebook account. Just select preferable name." + ((this._sName) ? "
" + this._sName + "
" : "") + ((this._sFirstName) ? "
" + this._sFirstName + "
" : "") + ((this._sLastName) ? "
" + this._sLastName + "
" : "") + "
" + ((this._sName || this._sFirstName || this._sLastName) ? "" : "") + "Custom username
" + "
" ); oDialog.render(document.body); Event.addListener(sOkBtnId, "click", this._onOkBtnClick, this, true); } this._oDialog.show(); } /** * */ YAHOO.website.dialog.NewFbUser.prototype.hide = function() { if (this._oDialog) this._oDialog.hide(); } /** * * @param {Object} e */ YAHOO.website.dialog.NewFbUser.prototype._onOkBtnClick = function(e) { var aInputs = this._oDialog.body.getElementsByTagName("input"); var username = "", textInput = ""; for (var i = 0; i < aInputs.length; i++) { var oInput = aInputs[i]; if ((oInput.type == "radio") && (oInput.checked)) { username = oInput.value; } else if (oInput.type == "text") { textInput = oInput.value; } } if (username == "") { username = YAHOO.lang.trim(textInput); } if (username == "") { alert("Username can't be empty.") return; } var oAjaxData = { uid: this._nUid, username: username }; YAHOO.website.service.ajax.execute( "registerFbUser", oAjaxData, { success: function(data) { // Hide ajax loader. if (data) { this.hide(); window.location.reload(); } else { alert ("Probably user name is exist. Try another username.") } }, failure: function() { // Hide ajax loader. }, scope: this } ); }