jquery-ui: replace dialog with own implementation

This commit is contained in:
Milan
2021-03-13 16:56:45 +01:00
parent 56e4dc91de
commit 978673bf3f
4 changed files with 67 additions and 59 deletions

View File

@@ -673,3 +673,20 @@ ul.tabContainer li:last-child{
border-top-right-radius:0.5rem; border-top-right-radius:0.5rem;
} }
#content #dialog{
position:absolute;
z-index:1000;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
width: 15rem;
height: 4rem;
text-align:center;
vertical-align:middle;
display:inline;
}

View File

@@ -337,50 +337,39 @@ function showMouse(){
function checkStudio(){ function checkStudio(){
if($('#studio_id').val()=='-1'){ if($('#studio_id').val()=='-1'){
$("#no_studio_selected").dialog({ showDialog({ title: "please select a studio" });
modal: true,
title: "please select a studio",
});
return 0; return 0;
} }
return 1; return 1;
} }
function show_not_assigned_to_series_dialog(){ function show_not_assigned_to_series_dialog(){
$("#event_no_series").dialog({ showDialog({
resizable: false, title : loc['label_event_not_assigned_to_series'],
width:800, buttons : {
height:340, Cancel : function() { $(this).parent().remove(); }
modal: true,
title: loc['label_event_not_assigned_to_series'],
buttons: {
Cancel: function() {
$( this ).dialog( "close" );
}
} }
}); });
} }
function show_schedule_series_dialog(project_id, studio_id, series_id, start_date){ function show_schedule_series_dialog(project_id, studio_id, series_id, start_date){
$("#series").dialog({ showDialog({
resizable: false, title : loc['label_schedule_series'],
width:800, content : $('#series').html(),
height:340, width : "50rem",
modal: true, height : "15rem",
title: loc['label_schedule_series'], buttons : {
buttons: {
"Schedule": function() { "Schedule": function() {
var series_id=$('#series_select').val(); var series_id = $('#dialog #series_select').val();
var duration=$('#series_duration').val(); var duration = $('#dialog #series_duration').val();
var start_date=$('#series_date').val(); var start_date = $('#dialog #series_date').val();
var url='series.cgi?project_id='+project_id+'&studio_id='+studio_id+'&series_id='+series_id+'&start='+escape(start_date)+'&duration='+duration+'&show_hint_to_add_schedule=1#tabs-schedule'; var url='series.cgi?project_id='+project_id+'&studio_id='+studio_id+'&series_id='+series_id+'&start='+escape(start_date)+'&duration='+duration+'&show_hint_to_add_schedule=1#tabs-schedule';
load(url); load(url);
}, },
"Cancel" : function() { Cancel : function() { $(this).parent().remove(); }
$( this ).dialog( "close" );
}
} }
}); });
showDateTimePicker('#dialog #series_date');
} }
function setDatePicker(){ function setDatePicker(){
@@ -485,12 +474,10 @@ function createId(prefix) {
function showRmsPlot(id, project_id, studio_id, start){ function showRmsPlot(id, project_id, studio_id, start){
console.log(id+" "+project_id+" "+studio_id+" "+start) console.log(id+" "+project_id+" "+studio_id+" "+start)
$('#'+id).dialog({ showDialog({
width:940, width:940,
height:560, height:560,
open: function () { onOpen: function () { $(this).scrollTop(0); }
$(this).scrollTop(0);
}
}); });
return false; return false;
} }

View File

@@ -122,35 +122,42 @@ function setTextWidth(select, minValue){
// trigger action on commit // trigger action on commit
function commitAction (title, action){ function commitAction (title, action){
if (action==null) {alert("missing action");return} if ( title == null ) { alert("missing title");return; }
if (title==null) {alert("missing title");return} if ( action == null ) { alert("missing action");return; }
if ($("#dialog-confirm").length>0) $("#dialog-confirm").remove(); showDialog({
$("#content").append( title : '<img src="image/alert.svg">Are you sure?</p>',
'<div id="dialog-confirm" title="'+title+'" style="min-height:2em;">' buttons : {
+'<p>' OK : function(){ action(); },
+'<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>' Cancel : function(){ $(this).parent().remove(); }
+'Are you sure?'
+'</p>'
+'</div>'
);
$( "#dialog-confirm" ).dialog({
resizable: false,
height: "200",
modal: true,
buttons: {
Okay : function() {
$(this).dialog( "close" );
action();
},
Cancel: function() {
$(this).dialog( "close" );
}
} }
}); });
} }
function showDialog(options){
if ($("#dialog").length>0) $("#dialog").remove();
$("#content").append(
'<div id="dialog" class="panel">'
+ (options.title ? '<div>'+options.title+'</div>' :'')
+ (options.content ? options.content :'')
+'</div>'
);
var dialog = $('#content #dialog');
if (options.width) dialog.css("width", options.width);
if (options.height) dialog.css("height", options.height);
if (options.buttons) {
Object.keys(options.buttons).forEach( function (key) {
var value = options.buttons[key];
dialog.append("<button>"+key+"</button");
var button=$("#content #dialog button").last();
button.on("click", value);
button.addClass( 'dialog-'+key.toLowerCase().replace( /[^a-zA-Z0-9]/g, '-') )
});
}
if (options.onOpen) options.onOpen();
return dialog;
}
// set action=<action> at form and submit the form after confirmation // set action=<action> at form and submit the form after confirmation
function commitForm ( formElement, action, title){ function commitForm ( formElement, action, title){
if (formElement==null) { alert("missing id");return } if (formElement==null) { alert("missing id");return }

View File

@@ -18,7 +18,7 @@ function updateActiveImage(){
$('div.images div.image.active').click(); $('div.images div.image.active').click();
} }
// open dialog to show or edit image properties // show or edit image properties
function updateImageEditor(elem, filename, target, project_id, studio_id, series_id, event_id, pid){ function updateImageEditor(elem, filename, target, project_id, studio_id, series_id, event_id, pid){
var url='image.cgi?show='+filename; var url='image.cgi?show='+filename;
url += '&template=edit-image.html'; url += '&template=edit-image.html';
@@ -126,10 +126,7 @@ function deleteImage(id, filename) {
return false; return false;
} }
// close all open dialogs
function hideImageDetails(id, filename){ function hideImageDetails(id, filename){
try{$('#img_editor').dialog('close');}catch(e){}
var url='image.cgi?show='+filename+'&template=image-single.html&project_id='+project_id+'&studio_id='+studio_id; var url='image.cgi?show='+filename+'&template=image-single.html&project_id='+project_id+'&studio_id='+studio_id;
console.log("hideImageDetails, load url="+url) console.log("hideImageDetails, load url="+url)
$("#"+id).load(url); $("#"+id).load(url);