Skip to content

Commit

Permalink
removed nglr namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Jan 9, 2010
1 parent 88eca57 commit 9b9a0da
Show file tree
Hide file tree
Showing 45 changed files with 5,514 additions and 1,911 deletions.
35 changes: 9 additions & 26 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ include FileUtils

desc 'Compile JavaScript'
task :compile do
compiled = %x(java -jar lib/shrinksafe/shrinksafe.jar \
lib/webtoolkit/webtoolkit.base64.js \
concat = %x(cat \
lib/underscore/underscore.js \
src/angular.prefix \
lib/webtoolkit/webtoolkit.base64.js \
lib/swfobject.js/swfobject.js \
src/Loader.js \
src/API.js \
src/Binder.js \
Expand All @@ -19,35 +21,16 @@ task :compile do
src/Users.js \
src/Validators.js \
src/Widgets.js \
src/angular-bootstrap.js \
src/angular.suffix \
)
f = File.new("angular.js", 'w')
f.write(compiled)
f.write(concat)
f.close
end

desc 'Compile JavaScript with Google Closure Compiler'
task :compileclosure do
# --compilation_level ADVANCED_OPTIMIZATIONS \
%x(java -jar lib/compiler-closure/compiler.jar \
--js lib/webtoolkit/webtoolkit.base64.js \
--js lib/underscore/underscore.js \
--js src/Loader.js \
--js src/API.js \
--js src/Binder.js \
--js src/ControlBar.js \
--js src/DataStore.js \
--js src/Filters.js \
--js src/JSON.js \
--js src/Model.js \
--js src/Parser.js \
--js src/Scope.js \
--js src/Server.js \
--js src/Users.js \
--js src/Validators.js \
--js src/Widgets.js \
--js src/angular-bootstrap.js \
--js_output_file angular.js)
--compilation_level ADVANCED_OPTIMIZATIONS \
--js angular.js \
--js_output_file angular-minified.js)
end

namespace :server do
Expand Down
2 changes: 1 addition & 1 deletion TODO.text
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
- angular.defaults = {}
- var scope = angular.compile(element, options);
* angular.js is not self boot straping by default.
*
* Remove SWFObject
122 changes: 122 additions & 0 deletions angular-minified.js

Large diffs are not rendered by default.

4,732 changes: 4,568 additions & 164 deletions angular.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions jsTestDriver.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ load:

exclude:
- src/angular-bootstrap.js
- src/angular.prefix
- src/angular.suffix

Binary file removed lib/shrinksafe/js.jar
Binary file not shown.
Binary file removed lib/shrinksafe/shrinksafe.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions src/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ angular.Array = {
}
return true;
};
var getter = nglr.Scope.getter;
var getter = Scope.getter;
var search = function(obj, text){
if (text.charAt(0) === '!') {
return !search(obj, text.substr(1));
Expand Down Expand Up @@ -147,7 +147,7 @@ angular.Array = {
},
orderBy:function(array, expression, descend) {
function reverse(comp, descending) {
return nglr.toBoolean(descending) ?
return toBoolean(descending) ?
function(a,b){return comp(b,a);} : comp;
}
function compare(v1, v2){
Expand Down Expand Up @@ -224,7 +224,7 @@ angular.Array = {
value = {};
array[index] = value;
}
nglr.merge(mergeValue, value);
merge(mergeValue, value);
return array;
}
};
Expand Down Expand Up @@ -281,7 +281,7 @@ angular.Function = {
if (_.isFunction(expression)){
return expression;
} else if (expression){
var scope = new nglr.Scope();
var scope = new Scope();
return function($) {
scope.state = $;
return scope.eval(expression);
Expand Down
106 changes: 53 additions & 53 deletions src/Binder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2009 BRAT Tech LLC
nglr.Binder = function(doc, widgetFactory, urlWatcher, config) {
Binder = function(doc, widgetFactory, urlWatcher, config) {
this.doc = doc;
this.urlWatcher = urlWatcher;
this.anchor = {};
Expand All @@ -8,7 +8,7 @@ nglr.Binder = function(doc, widgetFactory, urlWatcher, config) {
this.updateListeners = [];
};

nglr.Binder.parseBindings = function(string) {
Binder.parseBindings = function(string) {
var results = [];
var lastIndex = 0;
var index;
Expand All @@ -28,18 +28,18 @@ nglr.Binder.parseBindings = function(string) {
return results.length === 0 ? [ string ] : results;
};

nglr.Binder.hasBinding = function(string) {
var bindings = nglr.Binder.parseBindings(string);
return bindings.length > 1 || nglr.Binder.binding(bindings[0]) !== null;
Binder.hasBinding = function(string) {
var bindings = Binder.parseBindings(string);
return bindings.length > 1 || Binder.binding(bindings[0]) !== null;
};

nglr.Binder.binding = function(string) {
Binder.binding = function(string) {
var binding = string.replace(/\n/gm, ' ').match(/^\{\{(.*)\}\}$/);
return binding ? binding[1] : null;
};


nglr.Binder.prototype.parseQueryString = function(query) {
Binder.prototype.parseQueryString = function(query) {
var params = {};
query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,
function (match, left, right) {
Expand All @@ -48,7 +48,7 @@ nglr.Binder.prototype.parseQueryString = function(query) {
return params;
};

nglr.Binder.prototype.parseAnchor = function(url) {
Binder.prototype.parseAnchor = function(url) {
var self = this;
url = url || this.urlWatcher.getUrl();

Expand All @@ -65,13 +65,13 @@ nglr.Binder.prototype.parseAnchor = function(url) {
});
};

nglr.Binder.prototype.onUrlChange = function (url) {
Binder.prototype.onUrlChange = function (url) {
console.log("URL change detected", url);
this.parseAnchor(url);
this.updateView();
};

nglr.Binder.prototype.updateAnchor = function() {
Binder.prototype.updateAnchor = function() {
var url = this.urlWatcher.getUrl();
var anchorIndex = url.indexOf('#');
if (anchorIndex > -1)
Expand All @@ -93,7 +93,7 @@ nglr.Binder.prototype.updateAnchor = function() {
return url;
};

nglr.Binder.prototype.updateView = function() {
Binder.prototype.updateView = function() {
var start = new Date().getTime();
var scope = jQuery(this.doc).scope();
scope.set("$invalidWidgets", []);
Expand All @@ -103,7 +103,7 @@ nglr.Binder.prototype.updateView = function() {
_.each(this.updateListeners, function(fn) {fn();});
};

nglr.Binder.prototype.docFindWithSelf = function(exp){
Binder.prototype.docFindWithSelf = function(exp){
var doc = jQuery(this.doc);
var selection = doc.find(exp);
if (doc.is(exp)){
Expand All @@ -112,31 +112,31 @@ nglr.Binder.prototype.docFindWithSelf = function(exp){
return selection;
};

nglr.Binder.prototype.executeInit = function() {
Binder.prototype.executeInit = function() {
this.docFindWithSelf("[ng-init]").each(function() {
var jThis = jQuery(this);
var scope = jThis.scope();
try {
scope.eval(jThis.attr('ng-init'));
} catch (e) {
nglr.alert("EVAL ERROR:\n" + jThis.attr('ng-init') + '\n' + nglr.toJson(e, true));
alert("EVAL ERROR:\n" + jThis.attr('ng-init') + '\n' + toJson(e, true));
}
});
};

nglr.Binder.prototype.entity = function (scope) {
Binder.prototype.entity = function (scope) {
this.docFindWithSelf("[ng-entity]").attr("ng-watch", function() {
try {
var jNode = jQuery(this);
var decl = scope.entity(jNode.attr("ng-entity"));
return decl + (jNode.attr('ng-watch') || "");
} catch (e) {
nglr.alert(e);
alert(e);
}
});
};

nglr.Binder.prototype.compile = function() {
Binder.prototype.compile = function() {
var jNode = jQuery(this.doc);
var self = this;
if (this.config.autoSubmit) {
Expand All @@ -153,37 +153,37 @@ nglr.Binder.prototype.compile = function() {
jNode.removeClass("ng-exception");
} catch (e) {
jNode.addClass("ng-exception");
jNode.attr('ng-error', nglr.toJson(e, true));
jNode.attr('ng-error', toJson(e, true));
}
self.updateView();
return false;
});
};

nglr.Binder.prototype.translateBinding = function(node, parentPath, factories) {
Binder.prototype.translateBinding = function(node, parentPath, factories) {
var path = parentPath.concat();
var offset = path.pop();
var parts = nglr.Binder.parseBindings(node.nodeValue);
if (parts.length > 1 || nglr.Binder.binding(parts[0])) {
var parts = Binder.parseBindings(node.nodeValue);
if (parts.length > 1 || Binder.binding(parts[0])) {
var parent = node.parentNode;
if (nglr.isLeafNode(parent)) {
if (isLeafNode(parent)) {
parent.setAttribute('ng-bind-template', node.nodeValue);
factories.push({path:path, fn:function(node, scope, prefix) {
return new nglr.BindUpdater(node, node.getAttribute('ng-bind-template'));
return new BindUpdater(node, node.getAttribute('ng-bind-template'));
}});
} else {
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
var binding = nglr.Binder.binding(part);
var binding = Binder.binding(part);
var newNode;
if (binding) {
newNode = document.createElement("span");
var jNewNode = jQuery(newNode);
jNewNode.attr("ng-bind", binding);
if (i === 0) {
factories.push({path:path.concat(offset + i), fn:nglr.Binder.prototype.ng_bind});
factories.push({path:path.concat(offset + i), fn:Binder.prototype.ng_bind});
}
} else if (nglr.msie && part.charAt(0) == ' ') {
} else if (msie && part.charAt(0) == ' ') {
newNode = document.createElement("span");
newNode.innerHTML = '&nbsp;' + part.substring(1);
} else {
Expand All @@ -196,7 +196,7 @@ nglr.Binder.prototype.translateBinding = function(node, parentPath, factories) {
}
};

nglr.Binder.prototype.precompile = function(root) {
Binder.prototype.precompile = function(root) {
var factories = [];
this.precompileNode(root, [], factories);
return function (template, scope, prefix) {
Expand All @@ -211,13 +211,13 @@ nglr.Binder.prototype.precompile = function(root) {
try {
scope.addWidget(factory.fn(node, scope, prefix));
} catch (e) {
nglr.alert(e);
alert(e);
}
}
};
};

nglr.Binder.prototype.precompileNode = function(node, path, factories) {
Binder.prototype.precompileNode = function(node, path, factories) {
var nodeType = node.nodeType;
if (nodeType == Node.TEXT_NODE) {
this.translateBinding(node, path, factories);
Expand All @@ -234,19 +234,19 @@ nglr.Binder.prototype.precompileNode = function(node, path, factories) {
if (attributes) {
var bindings = node.getAttribute('ng-bind-attr');
node.removeAttribute('ng-bind-attr');
bindings = bindings ? nglr.fromJson(bindings) : {};
bindings = bindings ? fromJson(bindings) : {};
var attrLen = attributes.length;
for (var i = 0; i < attrLen; i++) {
var attr = attributes[i];
var attrName = attr.name;
// http://www.glennjones.net/Post/809/getAttributehrefbug.htm
var attrValue = nglr.msie && attrName == 'href' ?
var attrValue = msie && attrName == 'href' ?
decodeURI(node.getAttribute(attrName, 2)) : attr.value;
if (nglr.Binder.hasBinding(attrValue)) {
if (Binder.hasBinding(attrValue)) {
bindings[attrName] = attrValue;
}
}
var json = nglr.toJson(bindings);
var json = toJson(bindings);
if (json.length > 2) {
node.setAttribute("ng-bind-attr", json);
}
Expand All @@ -270,7 +270,7 @@ nglr.Binder.prototype.precompileNode = function(node, path, factories) {
return clone;
};
factories.push({path:path, fn:function(node, scope, prefix) {
return new nglr.RepeaterUpdater(jQuery(node), repeaterExpression, template, prefix);
return new RepeaterUpdater(jQuery(node), repeaterExpression, template, prefix);
}});
return;
}
Expand Down Expand Up @@ -309,42 +309,42 @@ nglr.Binder.prototype.precompileNode = function(node, path, factories) {
}
};

nglr.Binder.prototype.ng_eval = function(node) {
return new nglr.EvalUpdater(node, node.getAttribute('ng-eval'));
Binder.prototype.ng_eval = function(node) {
return new EvalUpdater(node, node.getAttribute('ng-eval'));
};

nglr.Binder.prototype.ng_bind = function(node) {
return new nglr.BindUpdater(node, "{{" + node.getAttribute('ng-bind') + "}}");
Binder.prototype.ng_bind = function(node) {
return new BindUpdater(node, "{{" + node.getAttribute('ng-bind') + "}}");
};

nglr.Binder.prototype.ng_bind_attr = function(node) {
return new nglr.BindAttrUpdater(node, nglr.fromJson(node.getAttribute('ng-bind-attr')));
Binder.prototype.ng_bind_attr = function(node) {
return new BindAttrUpdater(node, fromJson(node.getAttribute('ng-bind-attr')));
};

nglr.Binder.prototype.ng_hide = function(node) {
return new nglr.HideUpdater(node, node.getAttribute('ng-hide'));
Binder.prototype.ng_hide = function(node) {
return new HideUpdater(node, node.getAttribute('ng-hide'));
};

nglr.Binder.prototype.ng_show = function(node) {
return new nglr.ShowUpdater(node, node.getAttribute('ng-show'));
Binder.prototype.ng_show = function(node) {
return new ShowUpdater(node, node.getAttribute('ng-show'));
};

nglr.Binder.prototype.ng_class = function(node) {
return new nglr.ClassUpdater(node, node.getAttribute('ng-class'));
Binder.prototype.ng_class = function(node) {
return new ClassUpdater(node, node.getAttribute('ng-class'));
};

nglr.Binder.prototype.ng_class_even = function(node) {
return new nglr.ClassEvenUpdater(node, node.getAttribute('ng-class-even'));
Binder.prototype.ng_class_even = function(node) {
return new ClassEvenUpdater(node, node.getAttribute('ng-class-even'));
};

nglr.Binder.prototype.ng_class_odd = function(node) {
return new nglr.ClassOddUpdater(node, node.getAttribute('ng-class-odd'));
Binder.prototype.ng_class_odd = function(node) {
return new ClassOddUpdater(node, node.getAttribute('ng-class-odd'));
};

nglr.Binder.prototype.ng_style = function(node) {
return new nglr.StyleUpdater(node, node.getAttribute('ng-style'));
Binder.prototype.ng_style = function(node) {
return new StyleUpdater(node, node.getAttribute('ng-style'));
};

nglr.Binder.prototype.ng_watch = function(node, scope) {
Binder.prototype.ng_watch = function(node, scope) {
scope.watch(node.getAttribute('ng-watch'));
};
Loading

0 comments on commit 9b9a0da

Please sign in to comment.