From 2933ccf89514b3ea163caa3f1b52817943fda8d5 Mon Sep 17 00:00:00 2001 From: Robert Lyon Date: Mon, 10 Oct 2016 10:57:18 +1300 Subject: [PATCH] Bug 1631809: Allow image preview modal use within other modals Like adding image block modal or tinymce insert image modal behatnotneeded Change-Id: If608f87b852b8ee2e4d6c74bdf2a31124599eb03 Signed-off-by: Robert Lyon (cherry picked from commit 6601edd07bcd347a4e4c640cb07d73a775dde11e) --- htdocs/artefact/file/js/filebrowser.js | 10 +++++++--- .../raw/plugintype/artefact/file/templates/files.tpl | 1 - .../artefact/file/templates/form/filebrowser.tpl | 1 + .../artefact/file/templates/form/filelist.tpl | 2 +- .../admin/disable_external_resources.feature | 2 +- .../features/artefact/resume/resume_page.feature | 12 ++++++------ 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/htdocs/artefact/file/js/filebrowser.js b/htdocs/artefact/file/js/filebrowser.js index bfdd82cd5e..5e8423d3aa 100644 --- a/htdocs/artefact/file/js/filebrowser.js +++ b/htdocs/artefact/file/js/filebrowser.js @@ -707,7 +707,7 @@ function FileBrowser(idprefix, folderid, config, globalconfig) { return; } - var pagemodalbody = $j('.modal-body'); + var pagemodalbody = $j('#page-modal .modal-body'); var elem = $j('#' + self.id + '_filelist .img-modal-preview'); @@ -747,7 +747,11 @@ function FileBrowser(idprefix, folderid, config, globalconfig) { e.preventDefault(); // if folder, or a link that goes somewhere exit out - if(e.target.nodeName === 'A'){ + if (e.target.nodeName === 'A') { + return; + } + // if an image preview link + if (jQuery(e.target).parent().hasClass('img-modal-preview')) { return; } @@ -756,7 +760,7 @@ function FileBrowser(idprefix, folderid, config, globalconfig) { // remove visual selection if this is for selecting 1 file if (self.config.selectone) { - for(j = 0; j < elem.length; j = j + 1){ + for (j = 0; j < elem.length; j = j + 1) { removeElementClass(elem[j], 'active'); } } diff --git a/htdocs/theme/raw/plugintype/artefact/file/templates/files.tpl b/htdocs/theme/raw/plugintype/artefact/file/templates/files.tpl index 06dcd30a8d..35ad10c569 100644 --- a/htdocs/theme/raw/plugintype/artefact/file/templates/files.tpl +++ b/htdocs/theme/raw/plugintype/artefact/file/templates/files.tpl @@ -29,5 +29,4 @@ {/if} -{include file="pagemodal.tpl"} {include file="footer.tpl"} diff --git a/htdocs/theme/raw/plugintype/artefact/file/templates/form/filebrowser.tpl b/htdocs/theme/raw/plugintype/artefact/file/templates/form/filebrowser.tpl index cffb573592..45add105e4 100644 --- a/htdocs/theme/raw/plugintype/artefact/file/templates/form/filebrowser.tpl +++ b/htdocs/theme/raw/plugintype/artefact/file/templates/form/filebrowser.tpl @@ -181,6 +181,7 @@ {/if} + {include file="pagemodal.tpl"} {if $tabs} {/if} diff --git a/htdocs/theme/raw/plugintype/artefact/file/templates/form/filelist.tpl b/htdocs/theme/raw/plugintype/artefact/file/templates/form/filelist.tpl index 178ef0dab0..cf3dd4e60a 100644 --- a/htdocs/theme/raw/plugintype/artefact/file/templates/form/filelist.tpl +++ b/htdocs/theme/raw/plugintype/artefact/file/templates/form/filelist.tpl @@ -79,7 +79,7 @@ {elseif !$publishable} {$displaytitle} {else} - + {$displaytitle} {/if} diff --git a/test/behat/features/admin/disable_external_resources.feature b/test/behat/features/admin/disable_external_resources.feature index 9bd4369072..916cddd36f 100644 --- a/test/behat/features/admin/disable_external_resources.feature +++ b/test/behat/features/admin/disable_external_resources.feature @@ -30,7 +30,7 @@ Scenario: Enable/disable external resources in mahara pages | Block title | Text block with an internal image | And I click the "Insert/edit image" button in the editor And I expand the section "Image" - And I follow "Image2.png" + And I press "Select \"Image2.png\"" And I press "Submit" And I press "Save" diff --git a/test/behat/features/artefact/resume/resume_page.feature b/test/behat/features/artefact/resume/resume_page.feature index 610d8d780a..4899c46f7b 100644 --- a/test/behat/features/artefact/resume/resume_page.feature +++ b/test/behat/features/artefact/resume/resume_page.feature @@ -172,7 +172,7 @@ Scenario: Editing admin resume page (Bug 1426983) And I press "Add a file" And I wait "1" seconds And I attach the file "Image2.png" to "File" - And I press "Close" + And I press "Close" in the "#editgoalsandskills_filebrowser_upload_browse" "css_element" And I wait "1" seconds And I press "Save" And I should see "Saved successfully" @@ -183,7 +183,7 @@ Scenario: Editing admin resume page (Bug 1426983) And I press "Add a file" And I wait "1" seconds And I attach the file "Image2.png" to "File" - And I press "Close" + And I press "Close" in the "#editgoalsandskills_filebrowser_upload_browse" "css_element" And I wait "1" seconds And I press "Save" And I should see "Saved successfully" @@ -194,7 +194,7 @@ Scenario: Editing admin resume page (Bug 1426983) And I press "Add a file" And I wait "1" seconds And I attach the file "Image2.png" to "File" - And I press "Close" + And I press "Close" in the "#editgoalsandskills_filebrowser_upload_browse" "css_element" And I wait "1" seconds And I press "Save" And I should see "Saved successfully" @@ -205,7 +205,7 @@ Scenario: Editing admin resume page (Bug 1426983) And I press "Add a file" And I wait "1" seconds And I attach the file "Image2.png" to "File" - And I press "Close" + And I press "Close" in the "#editgoalsandskills_filebrowser_upload_browse" "css_element" And I wait "1" seconds And I press "Save" And I should see "Saved successfully" @@ -216,7 +216,7 @@ Scenario: Editing admin resume page (Bug 1426983) And I press "Add a file" And I wait "1" seconds And I attach the file "Image2.png" to "File" - And I press "Close" + And I press "Close" in the "#editgoalsandskills_filebrowser_upload_browse" "css_element" And I wait "1" seconds And I press "Save" And I should see "Saved successfully" @@ -227,7 +227,7 @@ Scenario: Editing admin resume page (Bug 1426983) And I press "Add a file" And I wait "1" seconds And I attach the file "Image2.png" to "File" - And I press "Close" + And I press "Close" in the "#editgoalsandskills_filebrowser_upload_browse" "css_element" And I wait "1" seconds And I press "Save" And I should see "Saved successfully" -- GitLab