+
Index: lams_central/web/css/authoring.css
===================================================================
diff -u -rb435669d04000e91dcbdbd9dc5a4b8b46f42e320 -r78d3840bba4ebbc2d65e9d8d064f3fc209b189ab
--- lams_central/web/css/authoring.css (.../authoring.css) (revision b435669d04000e91dcbdbd9dc5a4b8b46f42e320)
+++ lams_central/web/css/authoring.css (.../authoring.css) (revision 78d3840bba4ebbc2d65e9d8d064f3fc209b189ab)
@@ -66,24 +66,29 @@
border: none;
}
-div.dialogTitle {
- padding: 5px 0px 5px 0px;
- font-weight: bold;
- text-align: center;
+.dialogContainer .ui-spinner {
+ border: none;
}
+div.propertiesDialogContainer .modal-header,
+div#groupNamingDialog .modal-header,
+div#exportLDDialog .modal-header {
+ padding: 5px;
+}
-div.propertiesDialogContainer .ui-dialog-titlebar {
- padding: 0 0 0 5px;
+div.propertiesDialogContainer .modal-title,
+div#groupNamingDialog .modal-title,
+div#exportLDDialog .modal-title {
+ font-size: 16px;
}
-div.propertiesDialogContainer .dialogContainer table {
+div.propertiesDialogContainer .dialogContents table {
width: 100%;
}
-div.propertiesDialogContainer .dialogContainer td {
- padding-bottom: 5px;
+div.propertiesDialogContainer .dialogContents td {
+ padding: 5px;
}
input[name="propertiesContentFieldGroupDivide"] {
@@ -103,9 +108,13 @@
width: 99%;
}
+div#groupNamingDialog .btn-group {
+ margin: 5px 0;
+}
+
input.groupName {
- margin-bottom: 5px;
- width: 98%;
+ margin: 5px 0 5px 10px;
+ width: 95%;
}
@@ -117,8 +126,6 @@
div.exportDialog {
text-align: center;
- font-size: 17px;
- font-weight: bold;
}
div.exportDialog a {
@@ -133,87 +140,90 @@
cursor: pointer;
}
+div#ldStoreDialogContents {
+ width: 100%;
+ height: 100%;
+}
-
-div#ldStoreDialog .modal-body > table {
+div#ldStoreDialogContents > table {
height: 100%;
width: 100%;
border-collapse: separate;
}
-div#ldStoreDialog #ldStoreDialogButtonCell {
+div#ldStoreDialogContents #ldStoreDialogButtonCell {
height: 40px;
border-top: thin dotted #2E6E9E;
padding-top: 5px;
}
-div#ldStoreDialog #ldStoreDialogButtonCell > div > div {
+div#ldStoreDialogContents #ldStoreDialogButtonCell > div > div {
display: inline-block;
}
-div#ldStoreDialog td#ldStoreDialogTreeCell {
+div#ldStoreDialogContents td#ldStoreDialogTreeCell {
padding: 2px 2px 0px 5px;
vertical-align: top;
width: 200px;
border-right: thin dotted #2E6E9E;
}
-div#ldStoreDialog div#ldStoreDialogTree {
+div#ldStoreDialogContents div#ldStoreDialogTree {
overflow: auto;
}
-div#ldStoreDialog #ldStoreDialogAccessCell {
+div#ldStoreDialogContents #ldStoreDialogAccessCell {
height: 150px;
vertical-align: top;
border-top: thin dotted #2E6E9E;
border-right: thin dotted #2E6E9E;
padding: 5px 0px 5px 0px;
}
-div#ldStoreDialog #ldStoreDialogAccessCell > div#ldStoreDialogAccessTitle {
+div#ldStoreDialogContents #ldStoreDialogAccessCell > div#ldStoreDialogAccessTitle {
font-size: 11px;
font-weight: bold;
text-align: center;
}
-div#ldStoreDialog #ldStoreDialogAccessCell > div.access {
+div#ldStoreDialogContents #ldStoreDialogAccessCell > div.access {
padding: 3px 0 3px 3px;
cursor: pointer;
}
-div#ldStoreDialog #ldStoreDialogAccessCell > div.selected {
+div#ldStoreDialogContents #ldStoreDialogAccessCell > div.selected {
background-color: #dfeffc;
}
-div#ldStoreDialog td#ldStoreDialogCanvasCell {
+div#ldStoreDialogContents td#ldStoreDialogCanvasCell {
text-align: center;
padding: 10px 0px 0px 10px;
vertical-align: middle;
}
-div#ldStoreDialog div#ldStoreDialogCanvasDiv {
+div#ldStoreDialogContents div#ldStoreDialogCanvasDiv {
overflow: auto;
}
-div#ldStoreDialog img#ldScreenshotLoading {
+div#ldStoreDialogContents img#ldScreenshotLoading {
padding-top: 200px;
}
-div#ldStoreDialog #ldStoreDialogImportPartFrame {
+div#ldStoreDialogContents #ldStoreDialogImportPartFrame {
border: none;
width: 99%;
}
-div#ldStoreDialog div#ldStoreDialogNameContainer {
+div#ldStoreDialogContents div#ldStoreDialogNameContainer {
margin-left: 20px;
}
-div#ldStoreDialog div#ldStoreDialogNameContainer span {
+div#ldStoreDialogContents div#ldStoreDialogNameContainer span {
font-weight: bold;
}
-div#ldStoreDialog #ldStoreDialogNameContainer input {
+div#ldStoreDialogContents #ldStoreDialogNameContainer input {
width: 300px;
margin-left: 10px;
}
@@ -303,16 +313,6 @@
background-color: #dfeffc;
}
-
-div#exportImageDialog div#exportCanvas {
- margin: 5px;
- padding: 5px;
- text-align: center;
- border: thin dashed black;
-}
-
-
-
/**** Main authoring styles ****/
div#toolbar {
@@ -323,12 +323,6 @@
display: none;
}
-#groupingButton span {
- background: url('../images/icons/group.png') no-repeat 3px 3px;
- padding-left: 25px;
-}
-
-
table#authoringTable {
table-layout: fixed;
width: 100%;
@@ -425,5 +419,4 @@
#canvas {
overflow: auto;
vertical-align: top;
-}
-
+}
\ No newline at end of file
Index: lams_central/web/includes/javascript/authoring/authoringActivity.js
===================================================================
diff -u -ra2844b7929c3d01d170ec34fc150216700d8a7ea -r78d3840bba4ebbc2d65e9d8d064f3fc209b189ab
--- lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision a2844b7929c3d01d170ec34fc150216700d8a7ea)
+++ lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision 78d3840bba4ebbc2d65e9d8d064f3fc209b189ab)
@@ -1525,7 +1525,7 @@
if (layout.propertiesDialog) {
// no selected activity = no properties dialog
- layout.propertiesDialog.dialog('close');
+ layout.propertiesDialog.css('visibility', 'hidden');
}
layout.selectedObject = null;
}
Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js
===================================================================
diff -u -rb435669d04000e91dcbdbd9dc5a4b8b46f42e320 -r78d3840bba4ebbc2d65e9d8d064f3fc209b189ab
--- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision b435669d04000e91dcbdbd9dc5a4b8b46f42e320)
+++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision 78d3840bba4ebbc2d65e9d8d064f3fc209b189ab)
@@ -855,8 +855,7 @@
}
}, false);
- $('.modal-body', layout.ldStoreDialog).empty().append(ldStoreDialogContents.children());
- ldStoreDialogContents.remove();
+ $('.modal-body', layout.ldStoreDialog).empty().append(ldStoreDialogContents.show());
layout.dialogs.push(layout.ldStoreDialog);
@@ -914,24 +913,18 @@
'resizable' : false,
'draggable' : false,
'width' : 290,
- 'open' : function(){
- // hide the contents so there is no "jump" during repositioning
- $(this).css('visibility', 'hidden');
- },
- 'close' : null
+ 'close' : null,
+ 'data' : {
+ 'position' : {
+ 'my' : 'right top',
+ 'at' : 'right+10px top+10px',
+ 'of' : '#canvas'
+ }
+ }
});
// remove the title along with X button
$('.modal-header', layout.infoDialog).remove();
- layout.infoDialog.on('shown.bs.modal', function(){
- // reposition the dialog
- $(this).css('visibility', 'visible')
- .position({
- 'my' : 'right top',
- 'at' : 'right+5px top+10px',
- 'of' : '#canvas'
- });
- });
layout.dialogs.push(layout.infoDialog);
Index: lams_central/web/includes/javascript/authoring/authoringHandler.js
===================================================================
diff -u -rb435669d04000e91dcbdbd9dc5a4b8b46f42e320 -r78d3840bba4ebbc2d65e9d8d064f3fc209b189ab
--- lams_central/web/includes/javascript/authoring/authoringHandler.js (.../authoringHandler.js) (revision b435669d04000e91dcbdbd9dc5a4b8b46f42e320)
+++ lams_central/web/includes/javascript/authoring/authoringHandler.js (.../authoringHandler.js) (revision 78d3840bba4ebbc2d65e9d8d064f3fc209b189ab)
@@ -566,26 +566,25 @@
var dialog = layout.propertiesDialog,
// do not run this method too often
thisRun = new Date().getTime();
- if (thisRun - dialog.lastRun < layout.conf.propertiesDialogDimThrottle){
+ if (thisRun - dialog.data('lastRun') < layout.conf.propertiesDialogDimThrottle){
return;
}
- dialog.lastRun = thisRun;
+ dialog.data('lastRun', thisRun);
// is the dialog visible at all?
if (layout.selectedObject) {
// calculate dim/show threshold
- var container = dialog.container,
- dialogPosition = container.offset(),
+ var dialogPosition = dialog.offset(),
dialogStartX = dialogPosition.left,
dialogStartY = dialogPosition.top,
- dialogEndX = dialogStartX + container.width(),
- dialogEndY = dialogStartY + container.height(),
+ dialogEndX = dialogStartX + dialog.width(),
+ dialogEndY = dialogStartY + dialog.height(),
dimTreshold = layout.conf.propertiesDialogDimThreshold,
tooFarX = event.pageX < dialogStartX - dimTreshold || event.pageX > dialogEndX + dimTreshold,
tooFarY = event.pageY < dialogStartY - dimTreshold || event.pageY > dialogEndY + dimTreshold,
opacity = tooFarX || tooFarY ? layout.conf.propertiesDialogDimOpacity : 1;
- container.css('opacity', opacity);
+ dialog.css('opacity', opacity);
}
}
},
Index: lams_central/web/includes/javascript/authoring/authoringMenu.js
===================================================================
diff -u -rb435669d04000e91dcbdbd9dc5a4b8b46f42e320 -r78d3840bba4ebbc2d65e9d8d064f3fc209b189ab
--- lams_central/web/includes/javascript/authoring/authoringMenu.js (.../authoringMenu.js) (revision b435669d04000e91dcbdbd9dc5a4b8b46f42e320)
+++ lams_central/web/includes/javascript/authoring/authoringMenu.js (.../authoringMenu.js) (revision 78d3840bba4ebbc2d65e9d8d064f3fc209b189ab)
@@ -6,40 +6,21 @@
init : function(){
// dialog allowing to save canvas as SVG or PNG image
- layout.exportImageDialog = $('#exportImageDialog').dialog({
+ layout.exportImageDialog = showDialog('exportImageDialog',{
'autoOpen' : false,
'width' : 350,
'height' : 75,
- 'show' : 'fold',
- 'hide' : 'fold',
'draggable': false,
'resizable': false,
'modal' : true,
'title' : LABELS.EXPORT_IMAGE_DIALOG_TITLE
- }).click(function(){
- layout.exportImageDialog.dialog('close');
+ }, false);
+ layout.exportImageDialog.click(function(){
+ layout.exportImageDialog.modal('hide');
});
+ $('.modal-body', layout.exportImageDialog).empty().append($('#exportImageDialog').show);
layout.dialogs.push(layout.exportImageDialog);
-
-
- // dialog for downloading the sequence as ZIP
- layout.exportLDDialog = $('#exportLDDialog').dialog({
- 'autoOpen' : false,
- 'width' : 320,
- 'height' : 120,
- 'hide' : 'fold',
- 'draggable': false,
- 'resizable': false,
- 'modal' : true,
- 'title' : LABELS.EXPORT_SEQUENCE_DIALOG_TITLE,
- 'beforeClose' : function(){
- $('iframe', layout.exportLDDialog).attr('src', null);
- }
- }).click(function(){
- layout.exportLDDialog.dialog('close');
- });
- layout.dialogs.push(layout.exportLDDialog);
},
@@ -278,10 +259,24 @@
return;
}
- $('iframe', layout.exportLDDialog)
- .attr('src', LAMS_URL + 'authoring/exportToolContent.do?method=export&learningDesignID='
- + layout.ld.learningDesignID);
- layout.exportLDDialog.dialog('open');
+ // dialog for downloading the sequence as ZIP
+ var exportLDDialog = showDialog('exportLDDialog',{
+ 'autoOpen' : false,
+ 'width' : 320,
+ 'height' : 90,
+ 'draggable': false,
+ 'resizable': false,
+ 'modal' : true,
+ 'title' : LABELS.EXPORT_SEQUENCE_DIALOG_TITLE,
+ 'open' : function() {
+ $('iframe', this).attr('src', LAMS_URL + 'authoring/exportToolContent.do?method=export&learningDesignID='
+ + layout.ld.learningDesignID);
+ }
+ }).click(function(){
+ exportLDDialog.modal('hide');
+ });
+ $('#exportLDDialogContents').clone().attr('id', null).show().appendTo($('.modal-body', exportLDDialog).empty());
+ exportLDDialog.modal('show');
},
@@ -316,7 +311,7 @@
'download' : (layout.ld.title ? layout.ld.title : 'Untitled') + '.png'
});
- layout.exportImageDialog.dialog('open');
+ layout.exportImageDialog.modal('show');
} else {
return imageCode;
}
@@ -366,7 +361,7 @@
+ '&download=true&_=' + new Date().getTime()
});
}
- layout.exportImageDialog.dialog('open');
+ layout.exportImageDialog.modal('show');
} else {
return imageCode;
}
@@ -399,7 +394,7 @@
}
});
- var canvasClone = result.canvasClone = canvas.clone()
+ var canvasClone = result.canvasClone = canvas.clone();
// remove the rubbish bin icon
canvasClone.find('#rubbishBin').remove();
// IE needs this. There are 2 xmlns declarations and no xmlns:xlink
Index: lams_central/web/includes/javascript/authoring/authoringProperty.js
===================================================================
diff -u -rbcd7980b62ca16ad230dee6712f7112bf9021c70 -r78d3840bba4ebbc2d65e9d8d064f3fc209b189ab
--- lams_central/web/includes/javascript/authoring/authoringProperty.js (.../authoringProperty.js) (revision bcd7980b62ca16ad230dee6712f7112bf9021c70)
+++ lams_central/web/includes/javascript/authoring/authoringProperty.js (.../authoringProperty.js) (revision 78d3840bba4ebbc2d65e9d8d064f3fc209b189ab)
@@ -58,7 +58,7 @@
// make onChange function a local variable, because it's used several times
var changeFunction = function(){
// extract changed properties and redraw the activity
- var content = $(this).closest('.dialogContainer'),
+ var content = $(this).closest('.dialogContents'),
activity = content.data('parentObject'),
branchingActivity = activity.branchingActivity,
redrawNeeded = false,
@@ -189,7 +189,7 @@
// make onChange function a local variable, because it's used several times
var changeFunction = function(){
// extract changed properties and redraw the activity
- var content = $(this).closest('.dialogContainer'),
+ var content = $(this).closest('.dialogContents'),
activity = content.data('parentObject'),
redrawNeeded = false,
newTitle = $('.propertiesContentFieldTitle', content).val();
@@ -296,7 +296,7 @@
// make onChange function a local variable, because it's used several times
var changeFunction = function(){
// extract changed properties and redraw the activity, if needed
- var content = $(this).closest('.dialogContainer'),
+ var content = $(this).closest('.dialogContents'),
activity = content.data('parentObject'),
redrawNeeded = false,
newTitle = $('.propertiesContentFieldTitle', content).val(),
@@ -383,7 +383,7 @@
$('.propertiesContentFieldEqualSizes', content).attr('checked', activity.equalSizes ? 'checked' : null);
$('.propertiesContentFieldViewLearners', content).attr('checked', activity.viewLearners ? 'checked' : null);
- $('.propertiesContentFieldNameGroups', content).button().click(function(){
+ $('.propertiesContentFieldNameGroups', content).click(function(){
PropertyLib.openGroupNamingDialog(activity);
});
@@ -407,7 +407,7 @@
$('input', content).change(function(){
// extract changed properties and redraw the label, if needed
- var content = $(this).closest('.dialogContainer'),
+ var content = $(this).closest('.dialogContents'),
label = content.data('parentObject'),
redrawNeeded = false,
newTitle = $('.propertiesContentFieldTitle', content).val();
@@ -523,7 +523,7 @@
$('input, select', content).change(function(){
// extract changed properties and redraw the activity
- var content = $(this).closest('.dialogContainer'),
+ var content = $(this).closest('.dialogContents'),
activity = content.data('parentObject'),
redrawNeeded = false,
newTitle = $('.propertiesContentFieldTitle', content).val();
@@ -588,7 +588,7 @@
$('input', content).change(function(){
// extract changed properties and redraw the transition
- var content = $(this).closest('.dialogContainer'),
+ var content = $(this).closest('.dialogContents'),
region = content.data('parentObject'),
redrawNeeded = false,
newTitle = $('.propertiesContentFieldTitle', content).val(),
@@ -642,7 +642,7 @@
$('input, select', content).change(function(){
// extract changed properties and redraw the activity
- var content = $(this).closest('.dialogContainer'),
+ var content = $(this).closest('.dialogContents'),
activity = content.data('parentObject'),
redrawNeeded = false,
newTitle = $('.propertiesContentFieldTitle', content).val();
@@ -707,7 +707,7 @@
$('input', content).change(function(){
// extract changed properties and redraw the transition
- var content = $(this).closest('.dialogContainer'),
+ var content = $(this).closest('.dialogContents'),
transition = content.data('parentObject'),
redrawNeeded = false,
newTitle = $('.propertiesContentFieldTitle', content).val();
@@ -760,80 +760,69 @@
init : function(){
// initialise the properties dialog singleton
- var propertiesDialog = layout.propertiesDialog =
- $('
')
- .appendTo('body')
- .dialog({
- 'autoOpen' : false,
- 'closeOnEscape' : false,
- 'position' : {
- 'my' : 'right top',
- 'at' : 'right top',
- 'of' : '#canvas'
- },
- 'resizable' : false,
- 'title' : LABELS.PROPERTIES_DIALOG_TITLE
- });
+ var propertiesDialog = layout.propertiesDialog = showDialog('propertiesDialog',{
+ 'autoOpen' : false,
+ 'title' : LABELS.PROPERTIES_DIALOG_TITLE,
+ 'width' : 370,
+ 'close' : null,
+ 'data' : {
+ 'position' : false
+ }
+ }, false);
+ $('.modal-body', propertiesDialog).empty();
// for proximity detection throttling (see handlers)
- propertiesDialog.lastRun = 0;
+ propertiesDialog.data('lastRun', 0);
// remove close button, add dimming
- propertiesDialog.container = propertiesDialog.closest('.ui-dialog');
- propertiesDialog.container.addClass('propertiesDialogContainer')
+ propertiesDialog.addClass('propertiesDialogContainer')
.css('opacity', layout.conf.propertiesDialogDimOpacity)
.mousemove(HandlerPropertyLib.approachPropertiesDialogHandler)
- .find('.ui-dialog-titlebar-close').remove();
+ .find('.modal-header button').remove();
layout.dialogs.push(propertiesDialog);
+ var groupNamingContent = $('#propertiesContentGroupNaming');
+ $('#groupNamingOKButton', groupNamingContent).click(function() {
+ var dialog = layout.groupNamingDialog,
+ activity = groupNamingContent.data('parentObject'),
+ names = [],
+ error = null;
+
+ // extract group names from text fields and validate them
+ $('input', groupNamingContent).each(function(){
+ var groupName = $(this).val().trim();
+ if (GeneralLib.nameValidator.test(groupName)) {
+ names.push(groupName);
+ } else {
+ error = LABELS.GROUP_TITLE_VALIDATION_ERORR;
+ return false;
+ }
+ });
+
+ if (error) {
+ alert(error);
+ return;
+ }
+
+ $('input', groupNamingContent).each(function(index){
+ activity.groups[index].name = names[index];
+ });
+
+ dialog.modal('hide');
+ });
+ $('#groupNamingCancelButton', groupNamingContent).click(function() {
+ layout.groupNamingDialog.modal('hide');
+ });
// initialise dialog from group naming
- layout.groupNamingDialog = $('
').dialog({
+ layout.groupNamingDialog = showDialog('groupNamingDialog',{
'autoOpen' : false,
'modal' : true,
- 'show' : 'fold',
- 'hide' : 'fold',
- 'position' : {
- 'of' : '#canvas'
- },
- 'title' : LABELS.GROUP_NAMING_DIALOG_TITLE,
- 'buttons' : [
- {
- 'text' : LABELS.OK_BUTTON,
- 'click' : function() {
- var dialog = $(this),
- activity = dialog.dialog('option', 'parentObject'),
- names = [],
- error = null;
-
- // extract group names from text fields and validate them
- $('input', dialog).each(function(){
- var groupName = $(this).val().trim();
- if (GeneralLib.nameValidator.test(groupName)) {
- names.push(groupName);
- } else {
- error = LABELS.GROUP_TITLE_VALIDATION_ERORR;
- return false;
- }
- });
-
- if (error) {
- alert(error);
- return;
- }
-
- $('input', dialog).each(function(index){
- activity.groups[index].name = names[index];
- });
-
- dialog.dialog('close');
- }
- },
- {
- 'text' : LABELS.CANCEL_BUTTON,
- 'click' : function() {
- $(this).dialog('close');
- }
- }
- ]
- });
+ 'draggable' : true,
+ 'width' : 400,
+ 'title' : LABELS.GROUP_NAMING_DIALOG_TITLE
+ }, false);
+
+
+ $('.modal-body', layout.groupNamingDialog).empty().append(groupNamingContent.show());
+ $('.modal-header button', layout.groupNamingDialog).remove();
// add to dialogs array so they can be easily closed at once
layout.dialogs.push(layout.groupNamingDialog);
@@ -1732,16 +1721,16 @@
* Fills group naming dialog with existing group names and opens it.
*/
openGroupNamingDialog : function(activity) {
- var dialog = layout.groupNamingDialog;
- // remove existing entries and add reference to the initiating activity
- dialog.empty().dialog('option', 'parentObject', activity);
-
+ var dialog = layout.groupNamingDialog,
+ // add reference to the initiating activity
+ content = $('.dialogContents', dialog).data('parentObject', activity),
+ // remove existing entries
+ groupsDiv = $('#groupNamingGroups', content).empty();
$.each(activity.groups, function(){
- $('
').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);
+ });
+ }
});
}