mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-07 22:33:50 +00:00
Fix for the link macro to work around iPhone annoyance
This prevents Mobile Safari from sliding the address bar into view whenever a tiddler link is clicked
This commit is contained in:
parent
0d1598eaa1
commit
594871e2d1
@ -78,10 +78,10 @@ LinkWidget.prototype.generate = function() {
|
|||||||
this.attributes.href = this.to;
|
this.attributes.href = this.to;
|
||||||
} else {
|
} else {
|
||||||
var wikiLinkTemplateMacro = this.renderer.findMacroDefinition("tw-wikilink-template"),
|
var wikiLinkTemplateMacro = this.renderer.findMacroDefinition("tw-wikilink-template"),
|
||||||
wikiLinkTemplate = wikiLinkTemplateMacro ? wikiLinkTemplateMacro.text.trim() : "$uri_encoded$",
|
wikiLinkTemplate = wikiLinkTemplateMacro ? wikiLinkTemplateMacro.text.trim() : "$uri_encoded$";
|
||||||
wikiLinkText = wikiLinkTemplate.replace("$uri_encoded$",encodeURIComponent(this.to));
|
this.wikiLinkText = wikiLinkTemplate.replace("$uri_encoded$",encodeURIComponent(this.to));
|
||||||
wikiLinkText = wikiLinkText.replace("$uri_doubleencoded$",encodeURIComponent(encodeURIComponent(this.to)));
|
this.wikiLinkText = this.wikiLinkText.replace("$uri_doubleencoded$",encodeURIComponent(encodeURIComponent(this.to)));
|
||||||
this.attributes.href = wikiLinkText;
|
this.attributes.href = this.wikiLinkText;
|
||||||
}
|
}
|
||||||
this.events = events;
|
this.events = events;
|
||||||
} else {
|
} else {
|
||||||
@ -101,6 +101,7 @@ LinkWidget.prototype.handleClickEvent = function(event) {
|
|||||||
navigateFromClientRect: this.renderer.domNode.getBoundingClientRect()
|
navigateFromClientRect: this.renderer.domNode.getBoundingClientRect()
|
||||||
});
|
});
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -153,6 +154,10 @@ LinkWidget.prototype.postRenderInDom = function() {
|
|||||||
if(this.renderer.domNode.tagName === "A") {
|
if(this.renderer.domNode.tagName === "A") {
|
||||||
this.renderer.domNode.setAttribute("draggable",true);
|
this.renderer.domNode.setAttribute("draggable",true);
|
||||||
}
|
}
|
||||||
|
// Hack the href of internal links to include a #, again omitted from the static representation. This helps the browser see it as an internal link (eg it prevents Mobile Safari on iPhone from sliding the address bar into view)
|
||||||
|
if(!this.isExternal) {
|
||||||
|
this.renderer.domNode.setAttribute("href","#" + this.wikiLinkText);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LinkWidget.prototype.refreshInDom = function(changedAttributes,changedTiddlers) {
|
LinkWidget.prototype.refreshInDom = function(changedAttributes,changedTiddlers) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user