De-referer external urls.

This commit is contained in:
Ruud
2012-08-24 22:46:32 +02:00
parent e33c6b3a5f
commit d817179747
2 changed files with 13 additions and 10 deletions
+12
View File
@@ -29,6 +29,7 @@ var CouchPotato = new Class({
History.addEvent('change', self.openPage.bind(self));
self.c.addEvent('click:relay(a[href^=/]:not([target]))', self.pushState.bind(self));
self.c.addEvent('click:relay(a[href^=http])', self.openDerefered.bind(self));
},
getOption: function(name){
@@ -269,6 +270,17 @@ var CouchPotato = new Class({
createUrl: function(action, params){
return this.options.base_url + (action ? action+'/' : '') + (params ? '?'+Object.toQueryString(params) : '')
},
openDerefered: function(e, el){
(e).stop();
var url = 'http://www.dereferer.org/?' + el.get('href');
if(el.get('target') == '_blank' || (e.meta && Browser.Platform.mac) || (e.control && !Browser.Platform.mac))
window.open(url);
else
window.location = url;
}
});