aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Angular.js19
-rw-r--r--src/angular-bootstrap.js39
-rw-r--r--src/delete/Model.js (renamed from src/moveToAngularCom/Model.js)0
-rw-r--r--src/markups.js1
-rw-r--r--src/services.js40
5 files changed, 53 insertions, 46 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 72ff26b0..5b5aa87b 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -45,7 +45,7 @@ UrlWatcher.prototype = {
}
};
-
+////////////////////////////////////
if (typeof document.getAttribute == 'undefined')
document.getAttribute = function() {};
@@ -386,3 +386,20 @@ function compile(element, config) {
}
/////////////////////////////////////////////////
+function parseKeyValue(keyValue) {
+ var obj = {}, key_value, key;
+ foreach((keyValue || "").split('&'), function(keyValue){
+ if (keyValue) {
+ key_value = keyValue.split('=');
+ key = decodeURIComponent(key_value[0]);
+ obj[key] = key_value[1] ? decodeURIComponent(key_value[1]) : true;
+ }
+ });
+ return obj;
+}
+
+function angularInit(config){
+ if (config.autobind) {
+ compile(window.document, config).$init();
+ }
+}
diff --git a/src/angular-bootstrap.js b/src/angular-bootstrap.js
index 7798afa5..b0a3aa4f 100644
--- a/src/angular-bootstrap.js
+++ b/src/angular-bootstrap.js
@@ -22,23 +22,16 @@
* THE SOFTWARE.
*/
(function(previousOnLoad){
- var filename = /(.*)\/angular-(.*).js(#(.*))?/;
- var scripts = document.getElementsByTagName("SCRIPT");
- var serverPath;
- var config = {};
+ var filename = /(.*)\/angular-(.*).js(#(.*))?/,
+ scripts = document.getElementsByTagName("SCRIPT"),
+ serverPath,
+ config,
+ match;
for(var j = 0; j < scripts.length; j++) {
- var match = (scripts[j].src || "").match(filename);
+ match = (scripts[j].src || "").match(filename);
if (match) {
serverPath = match[1];
- parseConfig(match[4]);
- }
- }
-
- function parseConfig(args) {
- var keyValues = args.split('&'), keyValue, i = 0;
- for (; i < keyValues.length; i++) {
- keyValue = keyValues[i].split('=');
- config[keyValue[0]] = keyValue[1] || true;
+ config = match[4];
}
}
@@ -53,7 +46,6 @@
addScript("/jqlite.js");
addScript("/Parser.js");
addScript("/Resource.js");
- addScript("/URLWatcher.js");
// Extension points
addScript("/apis.js");
@@ -63,17 +55,14 @@
addScript("/directives.js");
addScript("/markups.js");
addScript("/widgets.js");
+ addScript("/services.js");
- if (config.autobind) {
- window.onload = function(){
- try {
- if (previousOnLoad) previousOnLoad();
- } catch(e) {}
- var scope = angular.compile(window.document, config);
- if (config.rootScope) window[config.rootScope] = scope;
- scope.$init();
- };
- }
+ window.onload = function(){
+ try {
+ if (previousOnLoad) previousOnLoad();
+ } catch(e) {}
+ angularInit(parseKeyValue(config));
+ };
})(window.onload);
diff --git a/src/moveToAngularCom/Model.js b/src/delete/Model.js
index b09efd0e..b09efd0e 100644
--- a/src/moveToAngularCom/Model.js
+++ b/src/delete/Model.js
diff --git a/src/markups.js b/src/markups.js
index 6bc27c85..3ae713fb 100644
--- a/src/markups.js
+++ b/src/markups.js
@@ -51,6 +51,7 @@ angularTextMarkup('{{}}', function(text, textNode, parentElement) {
}
});
+// TODO: this should be widget not a markup
angularTextMarkup('OPTION', function(text, textNode, parentElement){
if (parentElement[0].nodeName == "OPTION") {
var select = document.createElement('select');
diff --git a/src/services.js b/src/services.js
index 14c71363..5d235b32 100644
--- a/src/services.js
+++ b/src/services.js
@@ -1,34 +1,34 @@
angularService("$window", bind(window, identity, window));
-angularService("$anchor", function(){
+var URL_MATCH = /^(file|ftp|http|https):\/\/(\w+:{0,1}\w*@)?([\w\.]+)(:([0-9]+))?([^\?#]+)?(\?([^#]*))((#([^\?]*))(\?([^\?]*))?)$/;
+angularService("$location", function(){
var scope = this;
- function anchor(url){
+ function location(url){
if (isDefined(url)) {
- if (url.charAt(0) == '#') url = url.substr(1);
- var pathQuery = url.split('?');
- anchor.path = decodeURIComponent(pathQuery[0]);
- anchor.param = {};
- foreach((pathQuery[1] || "").split('&'), function(keyValue){
- if (keyValue) {
- var parts = keyValue.split('=');
- var key = decodeURIComponent(parts[0]);
- var value = parts[1];
- if (!value) value = true;
- anchor.param[key] = decodeURIComponent(value);
- }
- });
+ var match = URL_MATCH.exec(url);
+ dump(match);
+ location.href = url;
+ location.protocol = match[1];
+ location.host = match[3];
+ location.port = match[5];
+ location.path = match[6];
+ location.search = parseKeyValue(match[8]);
+ location.hash = match[9];
+ location.hashPath = match[11];
+ location.hashSearch = parseKeyValue(match[13]);
+ foreach(location, dump);
}
var params = [];
- foreach(anchor.param, function(value, key){
+ foreach(location.param, function(value, key){
params.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
});
- return (anchor.path ? anchor.path : '') + (params.length ? '?' + params.join('&') : '');
+ return (location.path ? location.path : '') + (params.length ? '?' + params.join('&') : '');
};
this.$config.location.watch(function(url){
- anchor(url);
+ location(url);
});
this.$onEval(PRIORITY_LAST, function(){
- scope.$config.location.set(anchor());
+ scope.$config.location.set(location());
});
- return anchor;
+ return location;
});