Commit e660923d authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Bug 1848100: Skins - cannot Save changes once background image file previewed"

parents bca63866 be433e76
...@@ -740,13 +740,16 @@ var FileBrowser = (function($) { ...@@ -740,13 +740,16 @@ var FileBrowser = (function($) {
if ($('#' + self.id + '_filelist').length === 0) { if ($('#' + self.id + '_filelist').length === 0) {
return; return;
} }
var pagemodal = $('#page-modal');
var pagemodal = $('#' + ($(this).attr('id') + '_page-modal')); // try pagemodal with variable
if (pagemodal.length === 0) { if (pagemodal.length === 0) {
return; pagemodal = $('#page-modal'); // try generic pagemodal
if (pagemodal.length === 0) {
return;
}
} }
var pagemodalbody = $('#page-modal .modal-body'); var pagemodalbody = pagemodal.find('.modal-body');
var elem = $('#' + self.id + '_filelist .img-modal-preview'); var elem = $('#' + self.id + '_filelist .img-modal-preview');
elem.each(function() { elem.each(function() {
...@@ -755,19 +758,25 @@ var FileBrowser = (function($) { ...@@ -755,19 +758,25 @@ var FileBrowser = (function($) {
e.preventDefault(); e.preventDefault();
self.clear_create_folder_messages(); self.clear_create_folder_messages();
var previewimg = $('#previewimg'); var previewimg = pagemodal.find('.previewimg');
if (previewimg.length === 0) { if (previewimg.length === 0) {
previewimg = $('<img id="previewimg" src="">'); previewimg = $('<img class="previewimg" src="">');
pagemodalbody.append(previewimg); pagemodalbody.append(previewimg);
} }
var imgsrc = $(this).attr('href'); var imgsrc = $(this).attr('href');
imgsrc = updateUrlParameter(imgsrc, 'maxwidth', 400); imgsrc = updateUrlParameter(imgsrc, 'maxwidth', 400);
imgsrc = updateUrlParameter(imgsrc, 'maxheight', 400); imgsrc = updateUrlParameter(imgsrc, 'maxheight', 400);
previewimg.attr('src',imgsrc); previewimg.attr('src', imgsrc);
$('#page-modal').modal('show'); $(pagemodal).modal('show');
}); });
}); });
//Set the click event for Close button on preview image modal
$(pagemodal).on('click', '.modal-footer .btn', function() {
$(this).closest('.modal').modal('hide');
});
}; };
this.connect_select_buttons = function () { this.connect_select_buttons = function () {
......
...@@ -62,7 +62,7 @@ define('TITLE', $title); ...@@ -62,7 +62,7 @@ define('TITLE', $title);
$form = ArtefactTypeTask::get_form($task->get('parent'), $group, $task); $form = ArtefactTypeTask::get_form($task->get('parent'), $group, $task);
$smarty = smarty(['js/preview.js', 'artefact/plans/js/taskedit.js', $smarty = smarty(['paginator', 'js/preview.js', 'artefact/plans/js/taskedit.js',
'js/lodash/lodash.js', 'js/gridstack/gridstack.js', 'js/gridlayout.js']); 'js/lodash/lodash.js', 'js/gridstack/gridstack.js', 'js/gridlayout.js']);
$smarty->assign('editform', $form); $smarty->assign('editform', $form);
$smarty->assign('PAGEHEADING', $pageheading); $smarty->assign('PAGEHEADING', $pageheading);
......
...@@ -60,7 +60,7 @@ else { ...@@ -60,7 +60,7 @@ else {
$form = ArtefactTypeTask::get_form($planId, $group); $form = ArtefactTypeTask::get_form($planId, $group);
$smarty = smarty(['js/preview.js', 'artefact/plans/js/taskedit.js', $smarty = smarty(['paginator', 'js/preview.js', 'artefact/plans/js/taskedit.js',
'js/lodash/lodash.js', 'js/gridstack/gridstack.js', 'js/gridlayout.js']); 'js/lodash/lodash.js', 'js/gridstack/gridstack.js', 'js/gridlayout.js']);
$smarty->assign('form', $form); $smarty->assign('form', $form);
......
...@@ -109,7 +109,7 @@ function editcomposite_callback(form, data) { ...@@ -109,7 +109,7 @@ function editcomposite_callback(form, data) {
} }
}; };
$(function($) { $(function($) {
$('#page-modal').on('hidden.bs.modal', function (e) { $('#editcomposite_filebrowser_page-modal').on('hidden.bs.modal', function (e) {
// check if the upload file modal is still visible and if so put the body class back to allow scrolling // check if the upload file modal is still visible and if so put the body class back to allow scrolling
if ($('#editcomposite_filebrowser_upload_browse').hasClass('show')) { if ($('#editcomposite_filebrowser_upload_browse').hasClass('show')) {
$('body').addClass('modal-open'); $('body').addClass('modal-open');
......
...@@ -127,7 +127,7 @@ function editgoalsandskills_callback(form, data) { ...@@ -127,7 +127,7 @@ function editgoalsandskills_callback(form, data) {
}; };
$(function($) { $(function($) {
$('#page-modal').on('hidden.bs.modal', function (e) { $('#editgoalsandskills_filebrowser_page-modal').on('hidden.bs.modal', function (e) {
// check if the upload file modal is still visible and if so put the body class back to allow scrolling // check if the upload file modal is still visible and if so put the body class back to allow scrolling
if ($('#editgoalsandskills_filebrowser_upload_browse').hasClass('show')) { if ($('#editgoalsandskills_filebrowser_upload_browse').hasClass('show')) {
$('body').addClass('modal-open'); $('body').addClass('modal-open');
......
...@@ -73,6 +73,7 @@ if ($viewids = get_column_sql('SELECT id FROM {view} WHERE owner = ? AND type = ...@@ -73,6 +73,7 @@ if ($viewids = get_column_sql('SELECT id FROM {view} WHERE owner = ? AND type =
); );
} }
$jsfiles = array( $jsfiles = array(
'paginator',
'js/preview.js', 'js/preview.js',
'js/export.js', 'js/export.js',
'js/lodash/lodash.js', 'js/lodash/lodash.js',
......
...@@ -193,7 +193,7 @@ ...@@ -193,7 +193,7 @@
</tbody> </tbody>
</table> </table>
{/if} {/if}
{include file="pagemodal.tpl"} {include file="pagemodal.tpl" prefix=$prefix keepParentModalOpen=true}
{if $tabs} {if $tabs}
</div> </div>
{/if} {/if}
......
...@@ -467,7 +467,7 @@ ...@@ -467,7 +467,7 @@
} }
// Preview image in popup modal // Preview image in popup modal
#previewimg { .modal-body .previewimg {
display: block; display: block;
margin: 0 auto; margin: 0 auto;
} }
......
<div class="modal fade page-modal js-page-modal" id="page-modal" tabindex="-1" role="dialog"> <div class="modal fade page-modal js-page-modal" id="{if $prefix}{$prefix}_{/if}page-modal" tabindex="-1" role="dialog">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-body"></div> <div class="modal-body"></div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{str tag=Close}</button> <button type="button" class="btn btn-secondary" {if !$keepParentModalOpen}data-dismiss="modal"{/if}>{str tag=Close}</button>
</div> </div>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment