From b2e2ba308c08bf62f3f9cc2e1c45d7b9cfa99cf8 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Mon, 2 Nov 2015 02:15:58 +0500 Subject: [PATCH] tune confirmPopup() --- css/style.css | 4 +++ js/interface_common.js | 76 +++++++++++++++++++++++++++------------- theme_calm/css/style.css | 4 +++ 3 files changed, 60 insertions(+), 24 deletions(-) diff --git a/css/style.css b/css/style.css index 94144a4..42d15b4 100644 --- a/css/style.css +++ b/css/style.css @@ -1855,6 +1855,10 @@ ol.toptrends-list { *********** CONFIRM POPUP ************ **************************************/ +.confirm-popup.prompt-wrapper { + margin-top: -80px; +} + .confirm-popup .message { text-align: center; margin: 12px; diff --git a/js/interface_common.js b/js/interface_common.js index fb6cace..96030cd 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -66,7 +66,8 @@ function closeModalHandler(classBase) { } function confirmPopup(event, req) { - event.stopPropagation(); + if (event && event.stopPropagation) + event.stopPropagation(); var modal = openModal({ classBase: '.prompt-wrapper', @@ -79,30 +80,57 @@ function confirmPopup(event, req) { modal.content.find('.message').text(req.messageTxt); var btn = modal.content.find('.confirm'); - if (req.confirmTxt) - btn.text(req.confirmTxt); - else - btn.text(polyglot.t('Confirm')); - if (req.confirmFunc) { - btn.on('click', function () { - closePrompt(); - req.confirmFunc(req.confirmFuncArgs); - }); - } else - btn.on('click', closePrompt); - + if (req.removeConfirm) + btn.remove(); + else { + if (req.confirmTxt) + btn.text(req.confirmTxt); + else + btn.text(polyglot.t('Confirm')); + if (req.confirmFunc) { + btn.on('click', function () { + closePrompt(); + req.confirmFunc(req.confirmFuncArgs); + }); + } else + btn.on('click', closePrompt); + } var btn = modal.content.find('.cancel'); - if (req.cancelTxt) - btn.text(req.cancelTxt); - else - btn.text(polyglot.t('Cancel')); - if (req.cancelFunc) { - btn.on('click', function () { - closePrompt(); - req.cancelFunc(req.cancelFuncArgs); - }); - } else - btn.on('click', closePrompt); + if (req.removeCancel) + btn.remove(); + else { + if (req.cancelTxt) + btn.text(req.cancelTxt); + else + btn.text(polyglot.t('Cancel')); + if (req.cancelFunc) { + btn.on('click', function () { + closePrompt(); + req.cancelFunc(req.cancelFuncArgs); + }); + } else + btn.on('click', closePrompt); + } + var btn = modal.self.find('.prompt-close'); + if (req.removeClose) + btn.remove(); + else { + if (req.closeFunc) { + if (typeof req.closeFunc === 'string') { + if (req.closeFunc === 'confirmFunc') { + req.closeFunc = req.confirmFunc; + req.closeFuncArgs = req.confirmFuncArgs; + } else if (req.closeFunc === 'cancelFunc') { + req.closeFunc = req.cancelFunc; + req.closeFuncArgs = req.cancelFuncArgs; + } + } + btn.on('click', function () { + closePrompt(); + req.closeFunc(req.closeFuncArgs); + }); + } + } } function checkNetworkStatusAndAskRedirect(cbFunc, cbArg) { diff --git a/theme_calm/css/style.css b/theme_calm/css/style.css index bad4484..6204e53 100644 --- a/theme_calm/css/style.css +++ b/theme_calm/css/style.css @@ -2263,6 +2263,10 @@ textarea.splited-post { *********** CONFIRM POPUP ************ **************************************/ +.confirm-popup.prompt-wrapper { + margin-top: -80px; +} + .confirm-popup .message { text-align: center; margin: 12px;