diff --git a/dist/jsoneditor.js b/dist/jsoneditor.js index 1d0cf7556..ecbd1abd9 100644 --- a/dist/jsoneditor.js +++ b/dist/jsoneditor.js @@ -1553,7 +1553,8 @@ JSONEditor.AbstractEditor = Class.extend({ // Template to generate the link href var href = this.jsoneditor.compileTemplate(data.href,this.template_engine); - + var relTemplate = this.jsoneditor.compileTemplate(data.rel,this.template_engine); + // Template to generate the link's download attribute var download = null; if(data.download) download = data.download; @@ -1574,8 +1575,9 @@ JSONEditor.AbstractEditor = Class.extend({ // When a watched field changes, update the url this.link_watchers.push(function(vars) { var url = href(vars); + var rel = relTemplate(vars); link.setAttribute('href',url); - link.setAttribute('title',data.rel || url); + link.setAttribute('title',rel || url); image.setAttribute('src',url); }); } @@ -1594,8 +1596,9 @@ JSONEditor.AbstractEditor = Class.extend({ // When a watched field changes, update the url this.link_watchers.push(function(vars) { var url = href(vars); + var rel = relTemplate(vars); link.setAttribute('href',url); - link.textContent = data.rel || url; + link.textContent = rel || url; media.setAttribute('src',url); }); } @@ -1608,8 +1611,9 @@ JSONEditor.AbstractEditor = Class.extend({ // When a watched field changes, update the url this.link_watchers.push(function(vars) { var url = href(vars); + var rel = relTemplate(vars); holder.setAttribute('href',url); - holder.textContent = data.rel || url; + holder.textContent = rel || url; }); } diff --git a/src/editor.js b/src/editor.js index 3ca319d2e..b3f87b113 100644 --- a/src/editor.js +++ b/src/editor.js @@ -177,7 +177,8 @@ JSONEditor.AbstractEditor = Class.extend({ // Template to generate the link href var href = this.jsoneditor.compileTemplate(data.href,this.template_engine); - + var relTemplate = this.jsoneditor.compileTemplate(data.rel ? data.rel : data.href,this.template_engine); + // Template to generate the link's download attribute var download = null; if(data.download) download = data.download; @@ -198,8 +199,9 @@ JSONEditor.AbstractEditor = Class.extend({ // When a watched field changes, update the url this.link_watchers.push(function(vars) { var url = href(vars); + var rel = relTemplate(vars); link.setAttribute('href',url); - link.setAttribute('title',data.rel || url); + link.setAttribute('title',rel || url); image.setAttribute('src',url); }); } @@ -218,8 +220,9 @@ JSONEditor.AbstractEditor = Class.extend({ // When a watched field changes, update the url this.link_watchers.push(function(vars) { var url = href(vars); + var rel = relTemplate(vars); link.setAttribute('href',url); - link.textContent = data.rel || url; + link.textContent = rel || url; media.setAttribute('src',url); }); } @@ -232,8 +235,9 @@ JSONEditor.AbstractEditor = Class.extend({ // When a watched field changes, update the url this.link_watchers.push(function(vars) { var url = href(vars); + var rel = relTemplate(vars); holder.setAttribute('href',url); - holder.textContent = data.rel || url; + holder.textContent = rel || url; }); }