1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-27 10:30:28 +00:00

Add isModified to Tiddler object

Adds a check to see if this tiddler differers from the tiddler
referenced in the draft.of field. It iterates of the fields property
skiping those feilds that offer a false positives. Uses the isEqual util
for the tags array.
This commit is contained in:
Devin Weaver 2014-04-25 08:45:17 -04:00
parent 23640d7af4
commit 3a78465d2d

View File

@ -795,6 +795,20 @@ $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.isEqual(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
*/