Commit ab754a5b authored by Timo Tegtmeier's avatar Timo Tegtmeier

Corrected html link handling in story view

parent d7c82cf6
......@@ -25,7 +25,7 @@ enyo.kind({
kind: enyo.Control,
classes: "html-content",
allowHtml: true,
allowHtml: true,
events: {
onLinkClick: ""
......@@ -34,25 +34,23 @@ enyo.kind({
findLink: function(node, ancestor) {
var run = node;
while (run && run != ancestor) {
if (run.href) {
return run.href;
if(run.tagName == 'A' || run.tagName == 'a') {
return run["data-href"];
}
run = run.parentNode;
}
return null;
},
clickHandler: function(sender, event) {
var url = this.findLink(event.target, this.hasNode());
clickHandler: function(event) {
event.preventDefault();
event.stopPropagation();
var url = this.findLink(event.target, this.node);
if (url) {
this.doLinkClick(url, event);
event.preventDefault();
return true;
} else if (event.didDrag) {
return true;
} else {
return this.doClick();
this.doLinkClick({ url: url });
}
event.preventDefault();
return true;
},
......@@ -67,6 +65,8 @@ enyo.kind({
node = node || this.node;
if(node.tagName == 'A' || node.tagName == 'a') {
node.onclick = this.clickHandler;
node["data-href"] = node.href;
node.href = "javascript:void(0)";
return;
}
for(var i = 0; i < node.childNodes.length; i++)
......@@ -75,6 +75,7 @@ enyo.kind({
setContent: function(data) {
this.inherited(arguments);
this._links = [];
if(this.hasNode())
this.applyClickHandler();
},
......@@ -83,4 +84,4 @@ enyo.kind({
this.inherited(arguments);
this.clickHandler = enyo.bind(this, this.clickHandler);
}
});
\ No newline at end of file
});
......@@ -17,7 +17,6 @@ enyo.depends(
"utils/formatting.js",
"utils/simplehtmlparser.js",
"utils/codepages.js",
"utils/helper.js",
// Utilities
"utils/spooler.js",
......
......@@ -372,9 +372,9 @@ enyo.kind({
return true;
},
handleClick: function(href) {
innerLinkClicked: function(sender, event) {
if(!this._scrolling) {
enyo.application.openLink(href);
enyo.application.openLink(event.url);
}
return true;
},
......
/*
* commonjs/helper.js - common helper functions
*
*/
/* FeedReader - A RSS Feed Aggregator for Firefox OS
* Copyright (C) 2009-2013 Timo Tegtmeier
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
function PrependHyperLinks(node, scope, handler) {
if(!node) {
return;
}
try {
if((node.nodeName == 'A') && node.href && (!node.href.match(/javascript.*/))) {
node.onclick = enyo.bind(scope, handler, node.href);
node.href = 'javascript:void(0)';
}
for(var i = 0; i < node.childNodes.length; i++) {
PrependHyperLinks(node.childNodes[i], scope, handler);
}
} catch(e) {
LogException(e);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment