From 7514c587d5475529b9194d7edd06dfbc0c6797a3 Mon Sep 17 00:00:00 2001 From: Shuai Lin Date: Tue, 3 May 2016 11:43:59 +0800 Subject: [PATCH] Added a helper function "showConfirmWithExtraOption". --- seahub/templates/js/templates.html | 9 +++++++++ static/scripts/common.js | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/seahub/templates/js/templates.html b/seahub/templates/js/templates.html index 72d7eeb4a4..0f3931e3c2 100644 --- a/seahub/templates/js/templates.html +++ b/seahub/templates/js/templates.html @@ -1489,3 +1489,12 @@ {% trans "Log out" %} + + diff --git a/static/scripts/common.js b/static/scripts/common.js index 25610e08cd..a1dc91c24a 100644 --- a/static/scripts/common.js +++ b/static/scripts/common.js @@ -289,6 +289,29 @@ define([ $yesBtn.click(yesCallback); }, + confirm_with_extra_option_template: _.template($('#confirm-dialog-with-extra-option-tmpl').html()), + + showConfirmWithExtraOption: function(title, content, extraOption, yesCallback) { + var $popup = $("#confirm-popup"); + var $cont = $('#confirm-con'); + var $yesBtn = $('#confirm-yes'); + + var html = this.confirm_with_extra_option_template({ + 'title': title, + 'content': content, + 'extraOption': extraOption + }); + + $cont.html(html); + $popup.modal({appendTo: '#main'}); + $('#simplemodal-container').css({'height':'auto'}); + + $yesBtn.click(function() { + var extraOptionChecked = $('#confirm-extra-option:checked').val() === 'on'; + yesCallback(extraOptionChecked); + }); + }, + closeModal: function() { $.modal.close(); },