1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Bail out earlier when displaying a modal for a non-existent tiddler

This commit is contained in:
Jeremy Ruston 2013-09-10 15:28:15 +01:00
parent ff0b93886b
commit e034f28091

View File

@ -27,10 +27,12 @@ Options include:
Modal.prototype.display = function(title,options) {
options = options || {};
var self = this,
duration = $tw.utils.getAnimationDuration();
// Up the modal count and adjust the body class
this.modalCount++;
this.adjustPageClass();
duration = $tw.utils.getAnimationDuration(),
tiddler = this.wiki.getTiddler(title);
// Don't do anything if the tiddler doesn't exist
if(!tiddler) {
return;
}
// Create the wrapper divs
var wrapper = document.createElement("div"),
modalBackdrop = document.createElement("div"),
@ -41,12 +43,10 @@ Modal.prototype.display = function(title,options) {
modalLink = document.createElement("a"),
modalFooter = document.createElement("div"),
modalFooterHelp = document.createElement("span"),
modalFooterButtons = document.createElement("span"),
tiddler = this.wiki.getTiddler(title);
// Don't do anything if the tiddler doesn't exist
if(!tiddler) {
return;
}
modalFooterButtons = document.createElement("span");
// Up the modal count and adjust the body class
this.modalCount++;
this.adjustPageClass();
// Add classes
$tw.utils.addClass(wrapper,"modal-wrapper");
$tw.utils.addClass(modalBackdrop,"modal-backdrop");