From 581ffec5ed72c0d5840c404f5ceb83551f066992 Mon Sep 17 00:00:00 2001 From: paweldomas Date: Wed, 11 Mar 2015 10:03:32 +0100 Subject: [PATCH] Fixes issues after jquery-impromptu update. --- css/modaldialog.css | 5 ++++ modules/UI/UI.js | 33 +++++++++------------- modules/UI/prezi/Prezi.js | 18 ++++++------ modules/UI/toolbars/Toolbar.js | 47 +++++++++++++++---------------- modules/UI/util/MessageHandler.js | 9 ++++-- 5 files changed, 58 insertions(+), 54 deletions(-) diff --git a/css/modaldialog.css b/css/modaldialog.css index b8f17b8bc..d3025aa6b 100644 --- a/css/modaldialog.css +++ b/css/modaldialog.css @@ -26,4 +26,9 @@ button.jqidefaultbutton #inviteLinkRef { color: #2c8ad2; +} + +#inviteLinkRef { + -webkit-user-select: text; + user-select: text; } \ No newline at end of file diff --git a/modules/UI/UI.js b/modules/UI/UI.js index c5d04ec73..156b2f334 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -483,7 +483,7 @@ function onPasswordReqiured(callback) { message += APP.translation.translateString( "dialog.passwordRequired"); message += '' + - ''; @@ -492,18 +492,17 @@ function onPasswordReqiured(callback) { true, "dialog.Ok", function (e, v, m, f) {}, - function (event) { - document.getElementById('lockKey').focus(); - }, + null, function (e, v, m, f) { if (v) { - var lockKey = document.getElementById('lockKey'); - if (lockKey.value !== null) { - Toolbar.setSharedKey(lockKey.value); - callback(lockKey.value); + var lockKey = f.lockKey; + if (lockKey) { + Toolbar.setSharedKey(lockKey); + callback(lockKey); } } - } + }, + ':input:first' ); } function onMucEntered(jid, id, displayName) { @@ -633,9 +632,9 @@ UI.showLoginPopup = function(callback) message += APP.translation.translateString( "dialog.passwordRequired"); message += '' + - '' + - ''; UI.messageHandler.openTwoButtonDialog(null, null, null, message, @@ -643,17 +642,13 @@ UI.showLoginPopup = function(callback) "dialog.Ok", function (e, v, m, f) { if (v) { - var username = document.getElementById('passwordrequired.username'); - var password = document.getElementById('passwordrequired.password'); - - if (username.value !== null && password.value != null) { - callback(username.value, password.value); + if (f.username !== null && f.password != null) { + callback(f.username, f.password); } } }, - function (event) { - document.getElementById('passwordrequired.username').focus(); - } + null, null, ':input:first' + ); } diff --git a/modules/UI/prezi/Prezi.js b/modules/UI/prezi/Prezi.js index cc24bfa55..b822a170c 100644 --- a/modules/UI/prezi/Prezi.js +++ b/modules/UI/prezi/Prezi.js @@ -82,23 +82,24 @@ var Prezi = { var openPreziState = { state0: { html: '

' + html + '

' + - '', persistent: false, buttons: buttons, - defaultButton: 1, - submit: function(e,v,m,f){ + focus: ':input:first', + defaultButton: 0, + submit: function (e, v, m, f) { e.preventDefault(); if(v) { - var preziUrl = document.getElementById('preziUrl'); + var preziUrl = f.preziUrl; - if (preziUrl.value) + if (preziUrl) { var urlValue - = encodeURI(UIUtil.escapeHtml(preziUrl.value)); + = encodeURI(UIUtil.escapeHtml(preziUrl)); if (urlValue.indexOf('http://prezi.com/') != 0 && urlValue.indexOf('https://prezi.com/') != 0) @@ -130,10 +131,11 @@ var Prezi = { linkError, persistent: false, buttons: buttons1, + focus: ':input:first', defaultButton: 1, - submit:function(e,v,m,f) { + submit: function (e, v, m, f) { e.preventDefault(); - if(v==0) + if (v === 0) $.prompt.close(); else $.prompt.goToState('state0'); diff --git a/modules/UI/toolbars/Toolbar.js b/modules/UI/toolbars/Toolbar.js index 8b52a921f..549cf47b6 100644 --- a/modules/UI/toolbars/Toolbar.js +++ b/modules/UI/toolbars/Toolbar.js @@ -131,25 +131,23 @@ function toggleRecording() { var token = APP.translation.translateString("dialog.token"); APP.UI.messageHandler.openTwoButtonDialog(null, null, null, '

' + msg + '

' + - '', false, "dialog.Save", function (e, v, m, f) { if (v) { - var token = document.getElementById('recordingToken'); + var token = f.recordingToken; - if (token.value) { - callback(UIUtil.escapeHtml(token.value)); + if (token) { + callback(UIUtil.escapeHtml(token)); } } }, - function (event) { - document.getElementById('recordingToken').focus(); - }, - function () { - } + null, + function () { }, + ':input:first' ); }, Toolbar.setRecordingButtonState, Toolbar.setRecordingButtonState); } @@ -232,22 +230,21 @@ function callSipButtonClicked() "dialog.sipMsg"); messageHandler.openTwoButtonDialog(null, null, null, '

' + sipMsg + '

' + - '', false, "dialog.Dial", function (e, v, m, f) { if (v) { - var numberInput = document.getElementById('sipNumber'); - if (numberInput.value) { - APP.xmpp.dial(numberInput.value, 'fromnumber', - UI.getRoomName(), sharedKey); + var numberInput = f.sipNumber; + if (numberInput) { + APP.xmpp.dial( + numberInput, 'fromnumber', UI.getRoomName(), sharedKey); } } }, - function (event) { - document.getElementById('sipNumber').focus(); - } + null, + ':input:first' ); } @@ -377,24 +374,23 @@ var Toolbar = (function (my) { "dialog.yourPassword"); messageHandler.openTwoButtonDialog(null, null, null, '

' + msg + '

' + - '', false, "dialog.Save", - function (e, v) { + function (e, v, m, f) { if (v) { - var lockKey = document.getElementById('lockKey'); + var lockKey = f.lockKey; - if (lockKey.value) { - Toolbar.setSharedKey(UIUtil.escapeHtml(lockKey.value)); + if (lockKey) { + Toolbar.setSharedKey( + UIUtil.escapeHtml(lockKey)); lockRoom(true); } } }, - function () { - document.getElementById('lockKey').focus(); - } + null, null, 'input:first' ); } } @@ -438,6 +434,7 @@ var Toolbar = (function (my) { /** * Opens the settings dialog. + * FIXME: not used ? */ my.openSettingsDialog = function () { var settings1 = APP.translation.generateTranslatonHTML( diff --git a/modules/UI/util/MessageHandler.js b/modules/UI/util/MessageHandler.js index ffc2380e3..e3a3e97d5 100644 --- a/modules/UI/util/MessageHandler.js +++ b/modules/UI/util/MessageHandler.js @@ -32,10 +32,14 @@ var messageHandler = (function(my) { * @param submitFunction function to be called on submit * @param loadedFunction function to be called after the prompt is fully loaded * @param closeFunction function to be called after the prompt is closed + * @param focus optional focus selector or button index to be focused after + * the dialog is opened + * @param defaultButton index of default button which will be activated when + * the user press 'enter'. Indexed from 0. */ my.openTwoButtonDialog = function(titleKey, titleString, msgKey, msgString, persistent, leftButtonKey, submitFunction, loadedFunction, - closeFunction) + closeFunction, focus, defaultButton) { var buttons = []; @@ -58,7 +62,8 @@ var messageHandler = (function(my) { title: title, persistent: false, buttons: buttons, - defaultButton: 1, + defaultButton: defaultButton, + focus: focus, loaded: loadedFunction, submit: submitFunction, close: closeFunction