summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/static/js/ace2_inner.js9
-rw-r--r--tests/frontend/specs/automatic_reconnect.js13
-rw-r--r--tests/frontend/specs/pad_modal.js64
3 files changed, 72 insertions, 14 deletions
diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js
index f44a6583..b1aebf3c 100644
--- a/src/static/js/ace2_inner.js
+++ b/src/static/js/ace2_inner.js
@@ -3367,7 +3367,12 @@ function Ace2Inner(){
evt.preventDefault();
}
}
- //hide the dropdownso
+
+ hideEditBarDropdowns();
+ }
+
+ function hideEditBarDropdowns()
+ {
if(window.parent.parent.padeditbar){ // required in case its in an iframe should probably use parent.. See Issue 327 https://github.com/ether/etherpad-lite/issues/327
window.parent.parent.padeditbar.toggleDropDown("none");
}
@@ -4983,6 +4988,8 @@ function Ace2Inner(){
$(document).on("keypress", handleKeyEvent);
$(document).on("keyup", handleKeyEvent);
$(document).on("click", handleClick);
+ // dropdowns on edit bar need to be closed on clicks on both pad inner and pad outer
+ $(outerWin.document).on("click", hideEditBarDropdowns);
// Disabled: https://github.com/ether/etherpad-lite/issues/2546
// Will break OL re-numbering: https://github.com/ether/etherpad-lite/pull/2533
// $(document).on("cut", handleCut);
diff --git a/tests/frontend/specs/automatic_reconnect.js b/tests/frontend/specs/automatic_reconnect.js
index 9e4783e7..e2d2df36 100644
--- a/tests/frontend/specs/automatic_reconnect.js
+++ b/tests/frontend/specs/automatic_reconnect.js
@@ -33,19 +33,6 @@ describe('Automatic pad reload on Force Reconnect message', function() {
done();
});
- it('disables editor', function(done) {
- var editorDocument = helper.padOuter$("iframe[name='ace_inner']").get(0).contentDocument;
- var editorBody = editorDocument.getElementById('innerdocbody');
-
- var editorIsEditable = editorBody.contentEditable === 'false' // IE/Safari
- || editorDocument.designMode === 'off'; // other browsers
-
- expect(editorIsEditable).to.be(true);
-
- done();
- });
-
-
context('and user clicks on Cancel', function() {
beforeEach(function() {
var $errorMessageModal = helper.padChrome$('#connectivity .userdup');
diff --git a/tests/frontend/specs/pad_modal.js b/tests/frontend/specs/pad_modal.js
new file mode 100644
index 00000000..d3afe107
--- /dev/null
+++ b/tests/frontend/specs/pad_modal.js
@@ -0,0 +1,64 @@
+describe('Pad modal', function() {
+ var padId, $originalPadFrame;
+
+ beforeEach(function(done) {
+ padId = helper.newPad(function() {
+ // open same pad on another iframe, to force userdup error
+ var $otherIframeWithSamePad = $('<iframe src="/p/' + padId + '" style="height: 1px;"></iframe>');
+ $originalPadFrame = $('#iframe-container iframe');
+ $otherIframeWithSamePad.insertAfter($originalPadFrame);
+
+ // wait for modal to be displayed
+ var $errorMessageModal = helper.padChrome$('#connectivity .userdup');
+ helper.waitFor(function() {
+ return $errorMessageModal.is(':visible');
+ }, 50000).done(done);
+ });
+
+ this.timeout(60000);
+ });
+
+ it('disables editor', function(done) {
+ var editorDocument = helper.padOuter$("iframe[name='ace_inner']").get(0).contentDocument;
+ var editorBody = editorDocument.getElementById('innerdocbody');
+
+ var editorIsEditable = editorBody.contentEditable === 'false' // IE/Safari
+ || editorDocument.designMode === 'off'; // other browsers
+
+ expect(editorIsEditable).to.be(true);
+
+ done();
+ });
+
+ context('and user clicks on editor', function() {
+ beforeEach(function() {
+ var $editor = helper.padInner$('#innerdocbody');
+ $editor.click();
+ });
+
+ it('closes the modal', function(done) {
+ var $errorMessageModal = helper.padChrome$('#connectivity .userdup');
+ var modalIsVisible = $errorMessageModal.is(':visible');
+
+ expect(modalIsVisible).to.be(false);
+
+ done();
+ });
+ });
+
+ context('and user clicks on pad outer', function() {
+ beforeEach(function() {
+ var $lineNumbersColumn = helper.padOuter$('#sidedivinner');
+ $lineNumbersColumn.click();
+ });
+
+ it('closes the modal', function(done) {
+ var $errorMessageModal = helper.padChrome$('#connectivity .userdup');
+ var modalIsVisible = $errorMessageModal.is(':visible');
+
+ expect(modalIsVisible).to.be(false);
+
+ done();
+ });
+ });
+});