X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/34c9285ef29074d0c13cea81fbb05e93eb369b4a..dec5a3d8b3a4cc70a9b2bc7bc1305ba0ae11a369:/src/editor/modules/data/document.js diff --git a/src/editor/modules/data/document.js b/src/editor/modules/data/document.js index db2b7a8..b0f7c25 100644 --- a/src/editor/modules/data/document.js +++ b/src/editor/modules/data/document.js @@ -14,6 +14,7 @@ var logger = logging.getLogger('document'); var Document = function() { wlxml.WLXMLDocument.apply(this, Array.prototype.slice.call(arguments, 0)); + this.properties = {}; }; Document.prototype = Object.create(wlxml.WLXMLDocument.prototype); @@ -45,6 +46,20 @@ _.extend(Document.prototype, { link = cfg.documentAttachmentUrl(link.substr(7)); } return link; + }, + getLinkForUrl: function(url) { + /* globals window */ + var baseUrl = function(url) {return url.split('/').slice(0,-1).join('/');}; + if(baseUrl(url) === baseUrl(window.location.origin + this.getUrlForLink('file://test'))) { + return 'file://' + _.last(url.split('/')); + } + return url; + }, + setProperty: function(propName, propValue) { + if(this.properties[propName] !== propValue) { + this.properties[propName] = propValue; + this.trigger('propertyChanged', propName, propValue); + } } });