mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-26 19:47:20 +00:00
Move isModified from Tiddler to Wiki
Replace this with a $tw.wiki.isModifiedTiddler(title) as part of the wiki object. This allows it to be used outside of the current Wiki which can change.
This commit is contained in:
parent
23a71b433e
commit
a505b6ffc0
32
boot/boot.js
32
boot/boot.js
@ -795,22 +795,6 @@ $tw.Tiddler.prototype.isDraft = function() {
|
||||
return this.hasField("draft.of");
|
||||
};
|
||||
|
||||
$tw.Tiddler.prototype.isModified = function() {
|
||||
if(!this.isDraft()) {
|
||||
return false;
|
||||
}
|
||||
var ignoredFields = ["created", "modified", "title", "draft.title", "draft.of", "tags"],
|
||||
tiddler = this,
|
||||
origTiddler = $tw.wiki.getTiddler(this.fields["draft.of"]);
|
||||
if(!$tw.utils.isArrayEqual(tiddler.fields.tags,origTiddler.fields.tags)) {
|
||||
return true;
|
||||
}
|
||||
return !Object.keys(tiddler.fields).every(function(field) {
|
||||
if(ignoredFields.indexOf(field) >= 0) { return true; }
|
||||
return tiddler.fields[field] === origTiddler.fields[field];
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
Register and install the built in tiddler field modules
|
||||
*/
|
||||
@ -1140,6 +1124,22 @@ $tw.Wiki.prototype.deserializeTiddlers = function(type,text,srcFields) {
|
||||
}
|
||||
};
|
||||
|
||||
$tw.Wiki.prototype.isModifiedTiddler = function(title) {
|
||||
var tiddler = this.getTiddler(title);
|
||||
if(!tiddler.isDraft()) {
|
||||
return false;
|
||||
}
|
||||
var ignoredFields = ["created", "modified", "title", "draft.title", "draft.of", "tags"],
|
||||
origTiddler = this.getTiddler(tiddler.fields["draft.of"]);
|
||||
if(!$tw.utils.isArrayEqual(tiddler.fields.tags,origTiddler.fields.tags)) {
|
||||
return true;
|
||||
}
|
||||
return !Object.keys(tiddler.fields).every(function(field) {
|
||||
if(ignoredFields.indexOf(field) >= 0) { return true; }
|
||||
return tiddler.fields[field] === origTiddler.fields[field];
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
Register the built in tiddler deserializer modules
|
||||
*/
|
||||
|
@ -315,7 +315,7 @@ NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) {
|
||||
{title: draftTitle}
|
||||
}
|
||||
));
|
||||
} else if(!tiddler.isModified()) {
|
||||
} else if(!this.wiki.isModifiedTiddler(title)) {
|
||||
event.type = "tw-cancel-tiddler";
|
||||
this.dispatchEvent(event);
|
||||
} else if(isConfirmed) {
|
||||
|
Loading…
Reference in New Issue
Block a user