aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMisko Hevery2010-01-18 17:56:08 -0800
committerMisko Hevery2010-01-18 17:56:08 -0800
commit0e566fe6cb41de388df6793b350fb81aaa4a8476 (patch)
treedc526a2a5de174f820ef375ffcdb45e32de9cda7 /src
parent7b558b5382c864b00392f50fa5095e53f7b486d0 (diff)
downloadangular.js-0e566fe6cb41de388df6793b350fb81aaa4a8476.tar.bz2
tweeter demo client
Diffstat (limited to 'src')
-rw-r--r--src/Angular.js30
-rw-r--r--src/Binder.js1
-rw-r--r--src/Filters.js17
3 files changed, 33 insertions, 15 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 69cab0a2..3dc72ff7 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -227,7 +227,7 @@ Angular.prototype = {
bindHtml: function() {
log('Angular.bindHtml()');
- var watcher = new UrlWatcher(this.location);
+ var watcher = this.watcher = new UrlWatcher(this.location);
var document = this.document;
var widgetFactory = new WidgetFactory(this.config.server, this.config.database);
var binder = new Binder(document[0], widgetFactory, watcher, this.config);
@@ -285,12 +285,6 @@ Angular.prototype = {
log('$binder.parseAnchor()');
binder.parseAnchor();
- log('$binder.updateView()');
- binder.updateView();
-
- //watcher.listener = bind(binder, binder.onUrlChange, watcher);
- //watcher.onUpdate = function(){alert("update");};
- //watcher.watch();
document.find("body").show();
log('ready()');
},
@@ -378,12 +372,13 @@ UrlWatcher.prototype = {
},
setUrl: function(url) {
-// var existingURL = window.location.href;
-// if (!existingURL.match(/#/))
-// existingURL += '#';
-// if (existingURL != url)
-// window.location.href = url;
-// this.existingURL = url;
+ //TODO: conditionaly?
+ var existingURL = window.location.href;
+ if (!existingURL.match(/#/))
+ existingURL += '#';
+ if (existingURL != url)
+ window.location.href = url;
+ this.existingURL = url;
},
getUrl: function() {
@@ -409,6 +404,13 @@ angular['compile'] = function(root, config) {
'updateView':function(){return scope.updateView();},
'set':function(){return scope.set.apply(scope, arguments);},
'get':function(){return scope.get.apply(scope, arguments);},
- 'init':function(){scope.get('$binder.executeInit')(); scope.updateView();}
+ 'init':function(){scope.get('$binder.executeInit')(); scope.updateView();},
+ 'watchUrl':function(){
+ var binder = scope.get('$binder');
+ var watcher = angular.watcher;
+ watcher.listener = bind(binder, binder.onUrlChange, watcher);
+ watcher.onUpdate = function(){alert("update");};
+ watcher.watch();
+ }
};
}; \ No newline at end of file
diff --git a/src/Binder.js b/src/Binder.js
index 36cb6ec3..b29a07c6 100644
--- a/src/Binder.js
+++ b/src/Binder.js
@@ -66,7 +66,6 @@ Binder.prototype = {
},
onUrlChange: function (url) {
- log("URL change detected", url);
this.parseAnchor(url);
this.updateView();
},
diff --git a/src/Filters.js b/src/Filters.js
index 666c9f30..833d5630 100644
--- a/src/Filters.js
+++ b/src/Filters.js
@@ -293,6 +293,23 @@ foreach({
'html': function(html){
return new angularFilter.Meta({html:html});
+ },
+
+ 'linky': function(text){
+ function regExpEscape(text) {
+ return text.replace(/([\/\.\*\+\?\|\(\)\[\]\{\}\\])/g, '\\$1');
+ }
+ var URL = /(ftp|http|https):\/\/([^\(\)|\s]+)/gm;
+ var html = text;
+ var dups = {};
+ foreach(text.match(URL)||[], function(url){
+ url = url.replace(/\.$/, '');
+ if (!dups[url]) {
+ html = html.replace(new RegExp(regExpEscape(url), 'gm'), '<a href="'+url+'">'+url+'</a>');
+ dups[url] = true;
+ }
+ });
+ return new angularFilter.Meta({text:text, html:html});
}
}, function(v,k){angularFilter[k] = v;});