Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up jQuery modal dialog functions #60

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions help_text.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
define('WT_SCRIPT_NAME', 'help_text.php');
require './includes/session.php';

$controller=new WT_Controller_Ajax();

$help = WT_Filter::get('help');
switch ($help) {
//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1500,8 +1498,7 @@
}
break;
}

$controller->pageHeader();

echo '<span class="helpheader">', $title, '</span>';
echo '<div class="helpcontent">', $text,'</div>';
// This file is called by a getJSON call so return the data
// in correct format
header('Content-Type: application/json');
echo json_encode(array('title'=>$title,'content'=>$text));
56 changes: 23 additions & 33 deletions js/webtrees-1.5.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,63 +34,53 @@ var assist_window_specs='width=900,height=800,left=70,top=70,resizable=1,scrollb
var gmap_window_specs='width=650,height=600,left=200,top=150,resizable=1,scrollbars=1'; // googlemap module place editing
var fam_nav_specs='width=300,height=600,left=817,top=150,resizable=1,scrollbars=1'; // media_0_inverselink.php

// TODO: This function loads help_text.php twice. It should only load it once.
function helpDialog(which, mod) {
url='help_text.php?help='+which+'&mod='+mod;
dialog=jQuery('<div></div>')
.load(url+' .helpcontent')
function modalNotes(title, content) {
jQuery('<div />', {
title: title,
html: content
})
.dialog({
modal: true,
width: 500,
closeText: ""
closeText: "",
open: function () {
// Close the dialog when we click outside it.
var dialog = this;
jQuery('.ui-widget-overlay').on('click', function () {
jQuery(dialog).dialog('close');
});
}
});
jQuery(".ui-widget-overlay").on("click", function () {
jQuery("div:ui-dialog:visible").dialog("close");
});
jQuery('.ui-dialog-title').load(url+' .helpheader');
return false;
}

function helpDialog(which, mod) {
jQuery.getJSON('help_text.php?help=' + which + '&mod=' + mod, function (json) {
modalNotes(json.title, json.content);
});
}

// Create a modal dialog, fetching the contents from a URL
function modalDialog(url, title) {
jQuery(document).ajaxComplete(function() {
jQuery('.ui-dialog').before('<div class="ui-widget-overlay" />');
});
dialog=jQuery('<div title="'+title+'"></div>')
jQuery('<div />', {
title: title
})
.load(url)
.dialog({
modal: false,
width: 700,
closeText: "",
close: function(event, ui) {
close: function (event, ui) {
jQuery(this).remove();
jQuery('.ui-widget-overlay').remove();
}
});
// Close the window when we click outside it.
jQuery(".ui-widget-overlay").on("click", function () {
jQuery("div:ui-dialog:visible").dialog("close");
jQuery(this).remove();
});
return false;
}

// Create a modal dialog to display notes
function modalNotes(content, title) {
dialog=jQuery('<div title="'+title+'"></div>')
.html(content)
.dialog({
modal: true,
width: 500,
closeText: "",
close: function(event, ui) { jQuery(this).remove(); }
});
// Close the window when we click outside it.
jQuery(".ui-widget-overlay").on("click", function () {
jQuery("div:ui-dialog:visible").dialog("close");
});
return false;
}

// For a dialog containing a form, submit the form via AJAX
// (to save the data), then reload the page (to display it).
Expand Down