Index: lams_central/web/authoring/authoring.jsp =================================================================== diff -u -r5199d1dc08051a94fead98f76b225edeb92f01f8 -r78d3840bba4ebbc2d65e9d8d064f3fc209b189ab --- lams_central/web/authoring/authoring.jsp (.../authoring.jsp) (revision 5199d1dc08051a94fead98f76b225edeb92f01f8) +++ lams_central/web/authoring/authoring.jsp (.../authoring.jsp) (revision 78d3840bba4ebbc2d65e9d8d064f3fc209b189ab) @@ -688,7 +688,7 @@ -
+ @@ -931,7 +931,24 @@ +
+
+
+
+ + + +
+
+
+
').addClass('groupName').appendTo(dialog).val(this.name); - dialog.append('
'); + $('').addClass('groupName').appendTo(groupsDiv).val(this.name); }); - dialog.dialog('open'); + dialog.modal('show'); }, @@ -1760,25 +1749,50 @@ */ openPropertiesDialog : function(object) { object.loadPropertiesDialogContent(); - var dialog = layout.propertiesDialog; - dialog.children().detach(); - dialog.append(object.propertiesContent); + var dialog = layout.propertiesDialog, + modalBody = $('.modal-body', dialog); + modalBody.children().detach(); + modalBody.append(object.propertiesContent); if (object.readOnly) { // make all widgets read-only - dialog.find('input, select, textarea').attr('disabled', 'disabled'); + dialog.find('input, select, textarea').prop('disabled', true); dialog.find('.spinner').spinner('option', 'disabled', true); } - dialog.dialog('open'); dialog.find('input').blur(); - var box = object.items.getBBox(), - x = box.x2 + canvas.offset().left + 5, - y = box.y + canvas.offset().top; - dialog.dialog('option', 'position', [x, y]); - if (dialog.offset().left < box.x2 + canvas.offset().left) { - // if dialog covers the activity (too close to right border), - // move it to the other side - x = box.x + canvas.offset().left - dialog.width() - 35; - dialog.dialog('option', 'position', [x, y]); + dialog.on('shown.bs.modal', function(){ + var box = object.items.getBBox(), + canvasOffset = canvas.offset(), + canvasWidth = canvas.width(), + canvasHeight = canvas.height(), + dialogWidth = dialog.width(), + dialogHeight = dialog.height(), + x = box.x2 + canvasOffset.left + 5, + y = box.y + canvasOffset.top - dialogHeight; + + if (x + dialogWidth > canvasOffset.left + canvasWidth + 30) { + // if dialog covers the activity (too close to right border), + // move it to the other side + x = box.x + canvasOffset.left - dialogWidth; + } + + if (y < canvasOffset.top) { + y = box.y + canvasOffset.top; + var adjuster = 0; + while (y > canvasOffset.top && y + dialogHeight > canvasOffset.top + canvasHeight){ + y -= adjuster++; + }; + } + + dialog.offset({ + 'left' : x, + 'top' : y + }); + }); + + if (dialog.css('display') == 'none') { + dialog.modal('show'); + } else { + dialog.trigger('shown.bs.modal'); } }, Index: lams_central/web/includes/javascript/dialog.js =================================================================== diff -u -rdec72575c7e173cdf993a4c09cc481962a9d46cf -r78d3840bba4ebbc2d65e9d8d064f3fc209b189ab --- lams_central/web/includes/javascript/dialog.js (.../dialog.js) (revision dec72575c7e173cdf993a4c09cc481962a9d46cf) +++ lams_central/web/includes/javascript/dialog.js (.../dialog.js) (revision 78d3840bba4ebbc2d65e9d8d064f3fc209b189ab) @@ -26,7 +26,6 @@ * If not, creates a new dialog with the given ID and init parameters. */ function showDialog(id, initParams, extraButtons, recreate) { - var dialog = $('#' + id); // is it open already? if (dialog.length > 0) { @@ -45,7 +44,7 @@ // use the input attributes or fall back to default ones initParams = $.extend({ 'autoOpen' : true, - 'modal' : true, + 'modal' : false, 'draggable' : true, 'resizable' : extraButtons == true, 'beforeClose' : function(){ @@ -76,16 +75,24 @@ if (initParams.resizable) { modalContent.resizable(); } - if (initParams.draggable && ! /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { - // breaks the close buttons on Android and iPhone - modalDialog.draggable(); + // breaks the close buttons on Android and iPhone + var draggable = initParams.draggable && ! /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); + if (draggable) { + modalDialog.draggable({ + 'cancel' : '.modal-body' + }); } // store extra attributes for dialog content internal use if (initParams.data) { dialog.data(initParams.data); } - dialog.on('show.bs.modal', initParams.open); + dialog.on('show.bs.modal', initParams.modal ? initParams.open : function(event){ + dialog.css('visibility', 'hidden'); + if (initParams.open) { + initParams.open.call(dialog, event); + } + }); dialog.on('hide.bs.modal', initParams.beforeClose); dialog.on('hidden.bs.modal', initParams.close); @@ -102,17 +109,27 @@ modalDialog.css({ 'margin' : 0 }); - dialog.width(modalDialog.outerWidth(true) + 5); - dialog.height(modalDialog.outerHeight(true) + 5); + dialog.width(modalDialog.outerWidth(true) + 15); + dialog.height(modalDialog.outerHeight(true) + 15); // remove overlay dialog.siblings('.modal-backdrop').remove(); + dialog.css('visibility', 'visible'); - dialog.position({ - 'of' : 'body' - }); + // center the dialog or put it into previously defined position + var position = dialog.data('position'); + if (position !== false) { + position = position || { + 'my' : 'top', + 'at' : 'top+15px', + 'of' : 'body' + }; + dialog.position(position); + } + - if (initParams.draggable) { + if (draggable) { modalDialog.on('drag', function(event, ui){ + // pass the event to the dialog, not its internal element dialog.offset({ 'top' : ui.offset.top + 5, 'left' : ui.offset.left + 5 @@ -122,6 +139,13 @@ }); }); } + + if (initParams.resizable) { + modalContent.on('resize', function(event, ui){ + dialog.width(ui.size.width + 15); + dialog.height(ui.size.height + 15); + }); + } }); }