aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMisko Hevery2010-01-09 15:02:43 -0800
committerMisko Hevery2010-01-09 15:02:43 -0800
commit9b9a0dadcce82ae42ac09ad396d647739af20a06 (patch)
tree854d162ac442509d12b17d7ed5123d7d43850f1e /src
parent88eca572fdc7f68a7f384b612052c49de00df433 (diff)
downloadangular.js-9b9a0dadcce82ae42ac09ad396d647739af20a06.tar.bz2
removed nglr namespace
Diffstat (limited to 'src')
-rw-r--r--src/API.js8
-rw-r--r--src/Binder.js106
-rw-r--r--src/ControlBar.js22
-rw-r--r--src/DataStore.js72
-rw-r--r--src/Filters.js8
-rw-r--r--src/JSON.js20
-rw-r--r--src/Loader.js145
-rw-r--r--src/Model.js26
-rw-r--r--src/Parser.js116
-rw-r--r--src/Scope.js62
-rw-r--r--src/Server.js32
-rw-r--r--src/Users.js8
-rw-r--r--src/Validators.js2
-rw-r--r--src/Widgets.js244
-rw-r--r--src/Widgets.js.orig764
-rw-r--r--src/XSitePost.js100
-rw-r--r--src/angular-bootstrap.js3
-rw-r--r--src/angular.prefix2
-rw-r--r--src/angular.suffix1
-rw-r--r--src/test/Runner.js26
-rw-r--r--src/test/Steps.js2
21 files changed, 455 insertions, 1314 deletions
diff --git a/src/API.js b/src/API.js
index c51fe01d..6fb6e8fc 100644
--- a/src/API.js
+++ b/src/API.js
@@ -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));
@@ -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){
@@ -224,7 +224,7 @@ angular.Array = {
value = {};
array[index] = value;
}
- nglr.merge(mergeValue, value);
+ merge(mergeValue, value);
return array;
}
};
@@ -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);
diff --git a/src/Binder.js b/src/Binder.js
index 8b4d27fb..3589cb88 100644
--- a/src/Binder.js
+++ b/src/Binder.js
@@ -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 = {};
@@ -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;
@@ -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) {
@@ -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();
@@ -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)
@@ -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", []);
@@ -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)){
@@ -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) {
@@ -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 {
@@ -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) {
@@ -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);
@@ -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);
}
@@ -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;
}
@@ -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'));
};
diff --git a/src/ControlBar.js b/src/ControlBar.js
index 3e1f0b57..b66a1464 100644
--- a/src/ControlBar.js
+++ b/src/ControlBar.js
@@ -1,16 +1,16 @@
// Copyright (C) 2008,2009 BRAT Tech LLC
-nglr.ControlBar = function (document, serverUrl) {
+ControlBar = function (document, serverUrl) {
this.document = document;
this.serverUrl = serverUrl;
this.window = window;
this.callbacks = [];
};
-nglr.ControlBar.prototype.bind = function () {
+ControlBar.prototype.bind = function () {
};
-nglr.ControlBar.HTML =
+ControlBar.HTML =
'<div>' +
'<div class="ui-widget-overlay"></div>' +
'<div id="ng-login" ng-non-bindable="true">' +
@@ -18,25 +18,25 @@ nglr.ControlBar.HTML =
'</div>' +
'</div>';
-nglr.ControlBar.prototype.login = function (loginSubmitFn) {
+ControlBar.prototype.login = function (loginSubmitFn) {
this.callbacks.push(loginSubmitFn);
if (this.callbacks.length == 1) {
this.doTemplate("/user_session/new.mini?return_url=" + encodeURIComponent(this.urlWithoutAnchor()));
}
};
-nglr.ControlBar.prototype.logout = function (loginSubmitFn) {
+ControlBar.prototype.logout = function (loginSubmitFn) {
this.callbacks.push(loginSubmitFn);
if (this.callbacks.length == 1) {
this.doTemplate("/user_session/do_destroy.mini");
}
};
-nglr.ControlBar.prototype.urlWithoutAnchor = function (path) {
+ControlBar.prototype.urlWithoutAnchor = function (path) {
return this.window.location.href.split("#")[0];
};
-nglr.ControlBar.prototype.doTemplate = function (path) {
+ControlBar.prototype.doTemplate = function (path) {
var self = this;
var id = new Date().getTime();
var url = this.urlWithoutAnchor();
@@ -49,7 +49,7 @@ nglr.ControlBar.prototype.doTemplate = function (path) {
resizable: false, modal:true,
title: 'Authentication: <a href="http://www.getangular.com"><tt>&lt;angular/&gt;</tt></a>'
});
- nglr["_iframe_notify_" + id] = function() {
+ callbacks["_iframe_notify_" + id] = function() {
loginView.dialog("destroy");
loginView.remove();
jQuery.each(self.callbacks, function(i, callback){
@@ -59,13 +59,13 @@ nglr.ControlBar.prototype.doTemplate = function (path) {
};
};
-nglr.ControlBar.FORBIDEN =
+ControlBar.FORBIDEN =
'<div ng-non-bindable="true" title="Permission Error:">' +
'Sorry, you do not have permission for this!'+
'</div>';
-nglr.ControlBar.prototype.notAuthorized = function () {
+ControlBar.prototype.notAuthorized = function () {
if (this.forbidenView) return;
- this.forbidenView = jQuery(nglr.ControlBar.FORBIDEN);
+ this.forbidenView = jQuery(ControlBar.FORBIDEN);
this.forbidenView.dialog({bgiframe:true, height:70, modal:true});
};
diff --git a/src/DataStore.js b/src/DataStore.js
index 97ab92ff..bdf882a0 100644
--- a/src/DataStore.js
+++ b/src/DataStore.js
@@ -1,6 +1,6 @@
// Copyright (C) 2009 BRAT Tech LLC
-nglr.DataStore = function(post, users, anchor) {
+DataStore = function(post, users, anchor) {
this.post = post;
this.users = users;
this._cache = {$collections:[]};
@@ -8,14 +8,14 @@ nglr.DataStore = function(post, users, anchor) {
this.bulkRequest = [];
};
-nglr.DataStore.prototype.cache = function(document) {
- if (document.constructor != nglr.Model) {
- throw "Parameter must be an instance of Entity! " + nglr.toJson(document);
+DataStore.prototype.cache = function(document) {
+ if (document.constructor != Model) {
+ throw "Parameter must be an instance of Entity! " + toJson(document);
}
var key = document.$entity + '/' + document.$id;
var cachedDocument = this._cache[key];
if (cachedDocument) {
- nglr.Model.copyDirectFields(document, cachedDocument);
+ Model.copyDirectFields(document, cachedDocument);
} else {
this._cache[key] = document;
cachedDocument = document;
@@ -23,7 +23,7 @@ nglr.DataStore.prototype.cache = function(document) {
return cachedDocument;
};
-nglr.DataStore.prototype.load = function(instance, id, callback, failure) {
+DataStore.prototype.load = function(instance, id, callback, failure) {
if (id && id !== '*') {
var self = this;
this._jsonRequest(["GET", instance.$entity + "/" + id], function(response) {
@@ -31,13 +31,13 @@ nglr.DataStore.prototype.load = function(instance, id, callback, failure) {
instance.$migrate();
var clone = instance.$$entity(instance);
self.cache(clone);
- (callback||nglr.noop)(instance);
+ (callback||noop)(instance);
}, failure);
}
return instance;
};
-nglr.DataStore.prototype.loadMany = function(entity, ids, callback) {
+DataStore.prototype.loadMany = function(entity, ids, callback) {
var self=this;
var list = [];
var callbackCount = 0;
@@ -45,26 +45,26 @@ nglr.DataStore.prototype.loadMany = function(entity, ids, callback) {
list.push(self.load(entity(), id, function(){
callbackCount++;
if (callbackCount == ids.length) {
- (callback||nglr.noop)(list);
+ (callback||noop)(list);
}
}));
});
return list;
}
-nglr.DataStore.prototype.loadOrCreate = function(instance, id, callback) {
+DataStore.prototype.loadOrCreate = function(instance, id, callback) {
var self=this;
return this.load(instance, id, callback, function(response){
if (response.$status_code == 404) {
instance.$id = id;
- (callback||nglr.noop)(instance);
+ (callback||noop)(instance);
} else {
throw response;
}
});
};
-nglr.DataStore.prototype.loadAll = function(entity, callback) {
+DataStore.prototype.loadAll = function(entity, callback) {
var self = this;
var list = [];
list.$$accept = function(doc){
@@ -78,12 +78,12 @@ nglr.DataStore.prototype.loadAll = function(entity, callback) {
document.$loadFrom(rows[i]);
list.push(self.cache(document));
}
- (callback||nglr.noop)(list);
+ (callback||noop)(list);
});
return list;
};
-nglr.DataStore.prototype.save = function(document, callback) {
+DataStore.prototype.save = function(document, callback) {
var self = this;
var data = {};
document.$saveTo(data);
@@ -103,7 +103,7 @@ nglr.DataStore.prototype.save = function(document, callback) {
});
};
-nglr.DataStore.prototype.remove = function(document, callback) {
+DataStore.prototype.remove = function(document, callback) {
var self = this;
var data = {};
document.$saveTo(data);
@@ -117,11 +117,11 @@ nglr.DataStore.prototype.remove = function(document, callback) {
}
}
});
- (callback||nglr.noop)(response);
+ (callback||noop)(response);
});
};
-nglr.DataStore.prototype._jsonRequest = function(request, callback, failure) {
+DataStore.prototype._jsonRequest = function(request, callback, failure) {
request.$$callback = callback;
request.$$failure = failure||function(response){
throw response;
@@ -129,7 +129,7 @@ nglr.DataStore.prototype._jsonRequest = function(request, callback, failure) {
this.bulkRequest.push(request);
};
-nglr.DataStore.prototype.flush = function() {
+DataStore.prototype.flush = function() {
if (this.bulkRequest.length === 0) return;
var self = this;
var bulkRequest = this.bulkRequest;
@@ -142,7 +142,7 @@ nglr.DataStore.prototype.flush = function() {
self.post(bulkRequest, callback);
});
} else if(bulkResponse.$status_code) {
- nglr.alert(nglr.toJson(bulkResponse));
+ alert(toJson(bulkResponse));
} else {
for ( var i = 0; i < bulkResponse.length; i++) {
var response = bulkResponse[i];
@@ -163,7 +163,7 @@ nglr.DataStore.prototype.flush = function() {
this.post(bulkRequest, callback);
};
-nglr.DataStore.prototype.saveScope = function(scope, callback) {
+DataStore.prototype.saveScope = function(scope, callback) {
var saveCounter = 1;
function onSaveDone() {
saveCounter--;
@@ -172,7 +172,7 @@ nglr.DataStore.prototype.saveScope = function(scope, callback) {
}
for(var key in scope) {
var item = scope[key];
- if (item && item.$save == nglr.Model.prototype.$save) {
+ if (item && item.$save == Model.prototype.$save) {
saveCounter++;
item.$save(onSaveDone);
}
@@ -180,7 +180,7 @@ nglr.DataStore.prototype.saveScope = function(scope, callback) {
onSaveDone();
};
-nglr.DataStore.prototype.query = function(type, query, arg, callback){
+DataStore.prototype.query = function(type, query, arg, callback){
var self = this;
var queryList = [];
queryList.$$accept = function(doc){
@@ -200,7 +200,7 @@ nglr.DataStore.prototype.query = function(type, query, arg, callback){
return queryList;
};
-nglr.DataStore.prototype.entities = function(callback) {
+DataStore.prototype.entities = function(callback) {
var entities = [];
var self = this;
this._jsonRequest(["GET", "$entities"], function(response) {
@@ -213,7 +213,7 @@ nglr.DataStore.prototype.entities = function(callback) {
return entities;
};
-nglr.DataStore.prototype.documentCountsByUser = function(){
+DataStore.prototype.documentCountsByUser = function(){
var counts = {};
var self = this;
self.post([["GET", "$users"]], function(code, response){
@@ -224,7 +224,7 @@ nglr.DataStore.prototype.documentCountsByUser = function(){
return counts;
};
-nglr.DataStore.prototype.userDocumentIdsByEntity = function(user){
+DataStore.prototype.userDocumentIdsByEntity = function(user){
var ids = {};
var self = this;
self.post([["GET", "$users/" + user]], function(code, response){
@@ -235,19 +235,19 @@ nglr.DataStore.prototype.userDocumentIdsByEntity = function(user){
return ids;
};
-nglr.DataStore.NullEntity = function(){};
-nglr.DataStore.NullEntity.all = function(){return [];};
-nglr.DataStore.NullEntity.query = function(){return [];};
-nglr.DataStore.NullEntity.load = function(){return {};};
-nglr.DataStore.NullEntity.title = undefined;
+DataStore.NullEntity = function(){};
+DataStore.NullEntity.all = function(){return [];};
+DataStore.NullEntity.query = function(){return [];};
+DataStore.NullEntity.load = function(){return {};};
+DataStore.NullEntity.title = undefined;
-nglr.DataStore.prototype.entity = function(name, defaults){
+DataStore.prototype.entity = function(name, defaults){
if (!name) {
- return nglr.DataStore.NullEntity;
+ return DataStore.NullEntity;
}
var self = this;
var entity = function(initialState){
- return new nglr.Model(entity, initialState);
+ return new Model(entity, initialState);
};
// entity.name does not work as name seems to be reserved for functions
entity.title = name;
@@ -275,7 +275,7 @@ nglr.DataStore.prototype.entity = function(name, defaults){
return entity;
};
-nglr.DataStore.prototype.join = function(join){
+DataStore.prototype.join = function(join){
var fn = function(){
throw "Joined entities can not be instantiated into a document.";
};
@@ -312,7 +312,7 @@ nglr.DataStore.prototype.join = function(join){
var row = {};
joinedResult.push(row);
row[baseName] = doc;
- var id = nglr.Scope.getter(row, nextJoinOn);
+ var id = Scope.getter(row, nextJoinOn);
joinIds[id] = id;
});
nextJoin.join.loadMany(_.toArray(joinIds), function(result){
@@ -321,7 +321,7 @@ nglr.DataStore.prototype.join = function(join){
byId[doc.$id] = doc;
});
_(joinedResult).each(function(row){
- var id = nglr.Scope.getter(row, nextJoinOn);
+ var id = Scope.getter(row, nextJoinOn);
row[nextJoinName] = byId[id];
});
});
diff --git a/src/Filters.js b/src/Filters.js
index f75f3603..dd4217be 100644
--- a/src/Filters.js
+++ b/src/Filters.js
@@ -60,11 +60,11 @@ angular.filter.date = function(amount) {
angular.filter.json = function(object) {
jQuery(this.element).addClass("ng-monospace");
- return nglr.toJson(object, true);
+ return toJson(object, true);
};
angular.filter.trackPackage = function(trackingNo, noMatch) {
- trackingNo = nglr.trim(trackingNo);
+ trackingNo = trim(trackingNo);
var tNo = trackingNo.replace(/ /g, '');
var MATCHERS = angular.filter.trackPackage.MATCHERS;
for ( var i = 0; i < MATCHERS.length; i++) {
@@ -77,7 +77,7 @@ angular.filter.trackPackage = function(trackingNo, noMatch) {
return new angular.filter.Meta({
text:text,
url:url,
- html: '<a href="' + nglr.escapeAttr(url) + '">' + text + '</a>',
+ html: '<a href="' + escapeAttr(url) + '">' + text + '</a>',
trackingNo:trackingNo});
}
}
@@ -115,7 +115,7 @@ angular.filter.link = function(obj, title) {
if (angular.validator.email(url) === null) {
url = "mailto:" + url;
}
- var html = '<a href="' + nglr.escapeHtml(url) + '">' + text + '</a>';
+ var html = '<a href="' + escapeHtml(url) + '">' + text + '</a>';
return new angular.filter.Meta({text:text, url:url, html:html});
}
return obj;
diff --git a/src/JSON.js b/src/JSON.js
index 2b6393bf..84c9a857 100644
--- a/src/JSON.js
+++ b/src/JSON.js
@@ -1,18 +1,18 @@
-nglr.array = [].constructor;
+array = [].constructor;
-nglr.toJson = function(obj, pretty){
+toJson = function(obj, pretty){
var buf = [];
- nglr.toJsonArray(buf, obj, pretty ? "\n " : null);
+ toJsonArray(buf, obj, pretty ? "\n " : null);
return buf.join('');
};
-nglr.toPrettyJson = function(obj) {
- return nglr.toJson(obj, true);
+toPrettyJson = function(obj) {
+ return toJson(obj, true);
};
-nglr.fromJson = function(json) {
+fromJson = function(json) {
try {
- var parser = new nglr.Parser(json, true);
+ var parser = new Parser(json, true);
var expression = parser.primary();
parser.assertAllConsumed();
return expression();
@@ -23,7 +23,7 @@ nglr.fromJson = function(json) {
};
-nglr.toJsonArray = function(buf, obj, pretty){
+toJsonArray = function(buf, obj, pretty){
var type = typeof obj;
if (obj === null) {
buf.push("null");
@@ -50,7 +50,7 @@ nglr.toJsonArray = function(buf, obj, pretty){
if (typeof item == 'function' || typeof item == 'undefined') {
buf.push("null");
} else {
- nglr.toJsonArray(buf, item, pretty);
+ toJsonArray(buf, item, pretty);
}
sep = true;
}
@@ -80,7 +80,7 @@ nglr.toJsonArray = function(buf, obj, pretty){
}
buf.push(angular.String.quote(key));
buf.push(":");
- nglr.toJsonArray(buf, value, childPretty);
+ toJsonArray(buf, value, childPretty);
comma = true;
}
} catch (e) {
diff --git a/src/Loader.js b/src/Loader.js
index eae6e4f5..dfaa355a 100644
--- a/src/Loader.js
+++ b/src/Loader.js
@@ -22,34 +22,37 @@ if (typeof Node == 'undefined') {
};
}
-if (_.isUndefined(window.nglr)) nglr = {};
-if (_.isUndefined(window.angular)) angular = {};
-if (_.isUndefined(angular.validator)) angular.validator = {};
-if (_.isUndefined(angular.filter)) angular.filter = {};
-if (_.isUndefined(window.console))
+var callbacks = {};
+
+if (!window.angular){ angular = {}; window['angular'] = angular; }
+if (!angular.validator) angular.validator = {};
+if (!angular.filter) angular.filter = {};
+if (!window.console)
window.console = {
log:function() {},
error:function() {}
};
-if (_.isUndefined(nglr.alert)) {
- nglr.alert = function(){console.log(arguments); window.alert.apply(window, arguments); };
+if (_.isUndefined(alert)) {
+ alert = function(){console.log(arguments); window.alert.apply(window, arguments); };
}
-nglr.consoleLog = function(level, objs) {
+var consoleNode;
+
+consoleLog = function(level, objs) {
var log = document.createElement("div");
log.className = level;
var msg = "";
var sep = "";
for ( var i = 0; i < objs.length; i++) {
var obj = objs[i];
- msg += sep + (typeof obj == 'string' ? obj : nglr.toJson(obj));
+ msg += sep + (typeof obj == 'string' ? obj : toJson(obj));
sep = " ";
}
log.appendChild(document.createTextNode(msg));
- nglr.consoleNode.appendChild(log);
+ consoleNode.appendChild(log);
};
-nglr.isNode = function(inp) {
+isNode = function(inp) {
return inp &&
inp.tagName &&
inp.nodeName &&
@@ -57,7 +60,7 @@ nglr.isNode = function(inp) {
inp.removeAttribute;
};
-nglr.isLeafNode = function(node) {
+isLeafNode = function(node) {
switch (node.nodeName) {
case "OPTION":
case "PRE":
@@ -68,11 +71,11 @@ nglr.isLeafNode = function(node) {
}
};
-nglr.noop = function() {
+noop = function() {
};
-nglr.setHtml = function(node, html) {
- if (nglr.isLeafNode(node)) {
- if (nglr.msie) {
+setHtml = function(node, html) {
+ if (isLeafNode(node)) {
+ if (msie) {
node.innerText = html;
} else {
node.textContent = html;
@@ -82,7 +85,7 @@ nglr.setHtml = function(node, html) {
}
};
-nglr.escapeHtml = function(html) {
+escapeHtml = function(html) {
if (!html || !html.replace)
return html;
return html.
@@ -91,14 +94,14 @@ nglr.escapeHtml = function(html) {
replace(/>/g, '&gt;');
};
-nglr.escapeAttr = function(html) {
+escapeAttr = function(html) {
if (!html || !html.replace)
return html;
return html.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g,
'&quot;');
};
-nglr.bind = function(_this, _function) {
+bind = function(_this, _function) {
if (!_this)
throw "Missing this";
if (!_.isFunction(_function))
@@ -108,7 +111,7 @@ nglr.bind = function(_this, _function) {
};
};
-nglr.shiftBind = function(_this, _function) {
+shiftBind = function(_this, _function) {
return function() {
var args = [ this ];
for ( var i = 0; i < arguments.length; i++) {
@@ -118,7 +121,7 @@ nglr.shiftBind = function(_this, _function) {
};
};
-nglr.outerHTML = function(node) {
+outerHTML = function(node) {
var temp = document.createElement('div');
temp.appendChild(node);
var outerHTML = temp.innerHTML;
@@ -126,26 +129,26 @@ nglr.outerHTML = function(node) {
return outerHTML;
};
-nglr.trim = function(str) {
+trim = function(str) {
return str.replace(/^ */, '').replace(/ *$/, '');
};
-nglr.toBoolean = function(value) {
+toBoolean = function(value) {
var v = ("" + value).toLowerCase();
if (v == 'f' || v == '0' || v == 'false' || v == 'no')
value = false;
return !!value;
};
-nglr.merge = function(src, dst) {
+merge = function(src, dst) {
for ( var key in src) {
var value = dst[key];
var type = typeof value;
if (type == 'undefined') {
- dst[key] = nglr.fromJson(nglr.toJson(src[key]));
- } else if (type == 'object' && value.constructor != nglr.array &&
+ dst[key] = fromJson(toJson(src[key]));
+ } else if (type == 'object' && value.constructor != array &&
key.substring(0, 1) != "$") {
- nglr.merge(src[key], value);
+ merge(src[key], value);
}
}
};
@@ -154,25 +157,25 @@ nglr.merge = function(src, dst) {
// Loader
// ////////////////////////////
-nglr.Loader = function(document, head, config) {
+Loader = function(document, head, config) {
this.document = jQuery(document);
this.head = jQuery(head);
this.config = config;
this.location = window.location;
};
-nglr.Loader.prototype.load = function() {
+Loader.prototype.load = function() {
this.configureLogging();
this.loadCss('/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css');
- this.loadCss('/stylesheets/nglr.css');
+ this.loadCss('/stylesheets/css');
console.log("Server: " + this.config.server);
- nglr.msie = jQuery.browser.msie;
+ msie = jQuery.browser.msie;
this.configureJQueryPlugins();
this.computeConfiguration();
this.bindHtml();
};
-nglr.Loader.prototype.configureJQueryPlugins = function() {
+Loader.prototype.configureJQueryPlugins = function() {
console.log('Loader.configureJQueryPlugins()');
jQuery.fn.removeNode = function() {
var node = this.get(0);
@@ -189,15 +192,15 @@ nglr.Loader.prototype.configureJQueryPlugins = function() {
return null;
};
jQuery.fn.controller = function() {
- return this.data('controller') || nglr.NullController.instance;
+ return this.data('controller') || NullController.instance;
};
};
-nglr.Loader.prototype.uid = function() {
+Loader.prototype.uid = function() {
return "" + new Date().getTime();
};
-nglr.Loader.prototype.computeConfiguration = function() {
+Loader.prototype.computeConfiguration = function() {
var config = this.config;
if (!config.database) {
var match = config.server.match(/https?:\/\/([\w]*)/);
@@ -205,27 +208,27 @@ nglr.Loader.prototype.computeConfiguration = function() {
}
};
-nglr.Loader.prototype.bindHtml = function() {
+Loader.prototype.bindHtml = function() {
console.log('Loader.bindHtml()');
- var watcher = new nglr.UrlWatcher(this.location);
+ var watcher = new UrlWatcher(this.location);
var document = this.document;
- var widgetFactory = new nglr.WidgetFactory(this.config.server, this.config.database);
- var binder = new nglr.Binder(document[0], widgetFactory, watcher, this.config);
- widgetFactory.onChangeListener = nglr.shiftBind(binder, binder.updateModel);
- var controlBar = new nglr.ControlBar(document.find('body'), this.config.server);
+ var widgetFactory = new WidgetFactory(this.config.server, this.config.database);
+ var binder = new Binder(document[0], widgetFactory, watcher, this.config);
+ widgetFactory.onChangeListener = shiftBind(binder, binder.updateModel);
+ var controlBar = new ControlBar(document.find('body'), this.config.server);
var onUpdate = function(){binder.updateView();};
var server = this.config.database=="$MEMORY" ?
- new nglr.FrameServer(this.window) :
- new nglr.Server(this.config.server, jQuery.getScript);
- server = new nglr.VisualServer(server, new nglr.Status(jQuery(document.body)), onUpdate);
- var users = new nglr.Users(server, controlBar);
+ new FrameServer(this.window) :
+ new Server(this.config.server, jQuery.getScript);
+ server = new VisualServer(server, new Status(jQuery(document.body)), onUpdate);
+ var users = new Users(server, controlBar);
var databasePath = '/data/' + this.config.database;
var post = function(request, callback){
server.request("POST", databasePath, request, callback);
};
- var datastore = new nglr.DataStore(post, users, binder.anchor);
+ var datastore = new DataStore(post, users, binder.anchor);
binder.updateListeners.push(function(){datastore.flush();});
- var scope = new nglr.Scope( {
+ var scope = new Scope( {
$anchor : binder.anchor,
$binder : binder,
$config : this.config,
@@ -241,7 +244,7 @@ nglr.Loader.prototype.bindHtml = function() {
jQuery.each(["get", "set", "eval", "addWatchListener", "updateView"],
function(i, method){
- angular[method] = nglr.bind(scope, scope[method]);
+ angular[method] = bind(scope, scope[method]);
});
document.data('scope', scope);
@@ -265,7 +268,7 @@ nglr.Loader.prototype.bindHtml = function() {
fetchCurrentUser();
console.log('PopUp.bind()');
- new nglr.PopUp(document).bind();
+ new PopUp(document).bind();
console.log('$binder.parseAnchor()');
binder.parseAnchor();
@@ -276,16 +279,16 @@ nglr.Loader.prototype.bindHtml = function() {
console.log('$binder.updateView()');
binder.updateView();
- watcher.listener = nglr.bind(binder, binder.onUrlChange, watcher);
- watcher.onUpdate = function(){nglr.alert("update");};
+ watcher.listener = bind(binder, binder.onUrlChange, watcher);
+ watcher.onUpdate = function(){alert("update");};
watcher.watch();
document.find("body").show();
console.log('ready()');
};
-nglr.Loader.prototype.visualPost = function(delegate) {
- var status = new nglr.Status(jQuery(document.body));
+Loader.prototype.visualPost = function(delegate) {
+ var status = new Status(jQuery(document.body));
return function(request, delegateCallback) {
status.beginRequest(request);
var callback = function() {
@@ -293,14 +296,14 @@ nglr.Loader.prototype.visualPost = function(delegate) {
try {
delegateCallback.apply(this, arguments);
} catch (e) {
- nglr.alert(nglr.toJson(e));
+ alert(toJson(e));
}
};
delegate(request, callback);
};
};
-nglr.Loader.prototype.configureLogging = function() {
+Loader.prototype.configureLogging = function() {
var url = window.location.href + '#';
url = url.split('#')[1];
var config = {
@@ -312,19 +315,19 @@ nglr.Loader.prototype.configureLogging = function() {
config[part[0]] = part[1];
}
if (config.debug == 'console') {
- nglr.consoleNode = document.createElement("div");
- nglr.consoleNode.id = 'ng-console';
- document.getElementsByTagName('body')[0].appendChild(nglr.consoleNode);
+ consoleNode = document.createElement("div");
+ consoleNode.id = 'ng-console';
+ document.getElementsByTagName('body')[0].appendChild(consoleNode);
console.log = function() {
- nglr.consoleLog('ng-console-info', arguments);
+ consoleLog('ng-console-info', arguments);
};
console.error = function() {
- nglr.consoleLog('ng-console-error', arguments);
+ consoleLog('ng-console-error', arguments);
};
}
};
-nglr.Loader.prototype.loadCss = function(css) {
+Loader.prototype.loadCss = function(css) {
var cssTag = document.createElement('link');
cssTag.rel = "stylesheet";
cssTag.type = "text/css";
@@ -334,7 +337,7 @@ nglr.Loader.prototype.loadCss = function(css) {
this.head[0].appendChild(cssTag);
};
-nglr.UrlWatcher = function(location) {
+UrlWatcher = function(location) {
this.location = location;
this.delay = 25;
this.setTimeout = function(fn, delay) {
@@ -346,7 +349,7 @@ nglr.UrlWatcher = function(location) {
this.expectedUrl = location.href;
};
-nglr.UrlWatcher.prototype.watch = function() {
+UrlWatcher.prototype.watch = function() {
var self = this;
var pull = function() {
if (self.expectedUrl !== self.location.href) {
@@ -357,12 +360,12 @@ nglr.UrlWatcher.prototype.watch = function() {
}
self.location.href = self.expectedUrl;
var id = '_iframe_notify_' + notify[1];
- var notifyFn = nglr[id];
- delete nglr[id];
+ var notifyFn = callbacks[id];
+ delete callbacks[id];
try {
- (notifyFn||nglr.noop)();
+ (notifyFn||noop)();
} catch (e) {
- nglr.alert(e);
+ alert(e);
}
} else {
self.listener(self.location.href);
@@ -374,16 +377,16 @@ nglr.UrlWatcher.prototype.watch = function() {
pull();
};
-nglr.UrlWatcher.prototype.setUrl = function(url) {
+UrlWatcher.prototype.setUrl = function(url) {
var existingURL = window.location.href;
if (!existingURL.match(/#/))
existingURL += '#';
if (existingURL != url)
window.location.href = url;
- self.existingURL = url;
+ this.existingURL = url;
};
-nglr.UrlWatcher.prototype.getUrl = function() {
+UrlWatcher.prototype.getUrl = function() {
return window.location.href;
};
@@ -394,7 +397,7 @@ angular['compile'] = function(root, config) {
};
//todo: don't load stylesheet by default
//todo: don't start watcher
- var loader = new nglr.Loader(root, jQuery("head"), _(defaults).extend(config));
+ var loader = new Loader(root, jQuery("head"), _(defaults).extend(config));
loader.load();
return jQuery(root).scope();
};
diff --git a/src/Model.js b/src/Model.js
index 5e48251f..35f6a1c1 100644
--- a/src/Model.js
+++ b/src/Model.js
@@ -3,14 +3,14 @@
// Single $ is special and does not get searched
// Double $$ is special an is client only (does not get sent to server)
-nglr.Model = function(entity, initial) {
+Model = function(entity, initial) {
this.$$entity = entity;
this.$loadFrom(initial||{});
this.$entity = entity.title;
this.$migrate();
};
-nglr.Model.copyDirectFields = function(src, dst) {
+Model.copyDirectFields = function(src, dst) {
if (src === dst || !src || !dst) return;
var isDataField = function(src, dst, field) {
return (field.substring(0,2) !== '$$') &&
@@ -27,39 +27,39 @@ nglr.Model.copyDirectFields = function(src, dst) {
}
};
-nglr.Model.prototype.$migrate = function() {
- nglr.merge(this.$$entity.defaults, this);
+Model.prototype.$migrate = function() {
+ merge(this.$$entity.defaults, this);
return this;
};
-nglr.Model.prototype.$merge = function(other) {
- nglr.merge(other, this);
+Model.prototype.$merge = function(other) {
+ merge(other, this);
return this;
};
-nglr.Model.prototype.$save = function(callback) {
+Model.prototype.$save = function(callback) {
this.$$entity.datastore.save(this, callback === true ? undefined : callback);
if (callback === true) this.$$entity.datastore.flush();
return this;
};
-nglr.Model.prototype.$delete = function(callback) {
+Model.prototype.$delete = function(callback) {
this.$$entity.datastore.remove(this, callback === true ? undefined : callback);
if (callback === true) this.$$entity.datastore.flush();
return this;
};
-nglr.Model.prototype.$loadById = function(id, callback) {
+Model.prototype.$loadById = function(id, callback) {
this.$$entity.datastore.load(this, id, callback);
return this;
};
-nglr.Model.prototype.$loadFrom = function(other) {
- nglr.Model.copyDirectFields(other, this);
+Model.prototype.$loadFrom = function(other) {
+ Model.copyDirectFields(other, this);
return this;
};
-nglr.Model.prototype.$saveTo = function(other) {
- nglr.Model.copyDirectFields(this, other);
+Model.prototype.$saveTo = function(other) {
+ Model.copyDirectFields(this, other);
return this;
};
diff --git a/src/Parser.js b/src/Parser.js
index 3d72bebf..b23215be 100644
--- a/src/Parser.js
+++ b/src/Parser.js
@@ -1,4 +1,4 @@
-nglr.Lexer = function(text, parsStrings){
+Lexer = function(text, parsStrings){
this.text = text;
// UTC dates have 20 characters, we send them through parser
this.dateParseLength = parsStrings ? 20 : -1;
@@ -6,7 +6,7 @@ nglr.Lexer = function(text, parsStrings){
this.index = 0;
};
-nglr.Lexer.OPERATORS = {
+Lexer.OPERATORS = {
'null':function(self){return null;},
'true':function(self){return true;},
'false':function(self){return false;},
@@ -31,7 +31,7 @@ nglr.Lexer.OPERATORS = {
'!':function(self, a){return !a;}
};
-nglr.Lexer.prototype.peek = function() {
+Lexer.prototype.peek = function() {
if (this.index + 1 < this.text.length) {
return this.text.charAt(this.index + 1);
} else {
@@ -39,9 +39,9 @@ nglr.Lexer.prototype.peek = function() {
}
};
-nglr.Lexer.prototype.parse = function() {
+Lexer.prototype.parse = function() {
var tokens = this.tokens;
- var OPERATORS = nglr.Lexer.OPERATORS;
+ var OPERATORS = Lexer.OPERATORS;
var canStartRegExp = true;
while (this.index < this.text.length) {
var ch = this.text.charAt(this.index);
@@ -102,22 +102,22 @@ nglr.Lexer.prototype.parse = function() {
return tokens;
};
-nglr.Lexer.prototype.isNumber = function(ch) {
+Lexer.prototype.isNumber = function(ch) {
return '0' <= ch && ch <= '9';
};
-nglr.Lexer.prototype.isWhitespace = function(ch) {
+Lexer.prototype.isWhitespace = function(ch) {
return ch == ' ' || ch == '\r' || ch == '\t' ||
ch == '\n' || ch == '\v';
};
-nglr.Lexer.prototype.isIdent = function(ch) {
+Lexer.prototype.isIdent = function(ch) {
return 'a' <= ch && ch <= 'z' ||
'A' <= ch && ch <= 'Z' ||
'_' == ch || ch == '$';
};
-nglr.Lexer.prototype.readNumber = function() {
+Lexer.prototype.readNumber = function() {
var number = "";
var start = this.index;
while (this.index < this.text.length) {
@@ -134,7 +134,7 @@ nglr.Lexer.prototype.readNumber = function() {
fn:function(){return number;}});
};
-nglr.Lexer.prototype.readIdent = function() {
+Lexer.prototype.readIdent = function() {
var ident = "";
var start = this.index;
while (this.index < this.text.length) {
@@ -146,7 +146,7 @@ nglr.Lexer.prototype.readIdent = function() {
}
this.index++;
}
- var fn = nglr.Lexer.OPERATORS[ident];
+ var fn = Lexer.OPERATORS[ident];
if (!fn) {
fn = function(self){
return self.scope.get(ident);
@@ -155,8 +155,8 @@ nglr.Lexer.prototype.readIdent = function() {
}
this.tokens.push({index:start, text:ident, fn:fn});
};
-nglr.Lexer.ESCAPE = {"n":"\n", "f":"\f", "r":"\r", "t":"\t", "v":"\v", "'":"'", '"':'"'};
-nglr.Lexer.prototype.readString = function(quote) {
+Lexer.ESCAPE = {"n":"\n", "f":"\f", "r":"\r", "t":"\t", "v":"\v", "'":"'", '"':'"'};
+Lexer.prototype.readString = function(quote) {
var start = this.index;
var dateParseLength = this.dateParseLength;
this.index++;
@@ -170,7 +170,7 @@ nglr.Lexer.prototype.readString = function(quote) {
this.index += 4;
string += String.fromCharCode(parseInt(hex, 16));
} else {
- var rep = nglr.Lexer.ESCAPE[ch];
+ var rep = Lexer.ESCAPE[ch];
if (rep) {
string += rep;
} else {
@@ -198,7 +198,7 @@ nglr.Lexer.prototype.readString = function(quote) {
(start+1) + "' in expression '" + this.text + "'.";
};
-nglr.Lexer.prototype.readRegexp = function(quote) {
+Lexer.prototype.readRegexp = function(quote) {
var start = this.index;
this.index++;
var regexp = "";
@@ -233,30 +233,30 @@ nglr.Lexer.prototype.readRegexp = function(quote) {
};
-nglr.Parser = function(text, parseStrings){
+Parser = function(text, parseStrings){
this.text = text;
- this.tokens = new nglr.Lexer(text, parseStrings).parse();
+ this.tokens = new Lexer(text, parseStrings).parse();
this.index = 0;
};
-nglr.Parser.ZERO = function(){
+Parser.ZERO = function(){
return 0;
};
-nglr.Parser.prototype.error = function(msg, token) {
+Parser.prototype.error = function(msg, token) {
throw "Token '" + token.text +
"' is " + msg + " at column='" +
(token.index + 1) + "' of expression '" +
this.text + "' starting at '" + this.text.substring(token.index) + "'.";
};
-nglr.Parser.prototype.peekToken = function() {
+Parser.prototype.peekToken = function() {
if (this.tokens.length === 0)
throw "Unexpected end of expression: " + this.text;
return this.tokens[0];
};
-nglr.Parser.prototype.peek = function(e1, e2, e3, e4) {
+Parser.prototype.peek = function(e1, e2, e3, e4) {
var tokens = this.tokens;
if (tokens.length > 0) {
var token = tokens[0];
@@ -269,7 +269,7 @@ nglr.Parser.prototype.peek = function(e1, e2, e3, e4) {
return false;
};
-nglr.Parser.prototype.expect = function(e1, e2, e3, e4){
+Parser.prototype.expect = function(e1, e2, e3, e4){
var token = this.peek(e1, e2, e3, e4);
if (token) {
this.tokens.shift();
@@ -279,7 +279,7 @@ nglr.Parser.prototype.expect = function(e1, e2, e3, e4){
return false;
};
-nglr.Parser.prototype.consume = function(e1){
+Parser.prototype.consume = function(e1){
if (!this.expect(e1)) {
var token = this.peek();
throw "Expecting '" + e1 + "' at column '" +
@@ -289,32 +289,32 @@ nglr.Parser.prototype.consume = function(e1){
}
};
-nglr.Parser.prototype._unary = function(fn, parse) {
+Parser.prototype._unary = function(fn, parse) {
var right = parse.apply(this);
return function(self) {
return fn(self, right(self));
};
};
-nglr.Parser.prototype._binary = function(left, fn, parse) {
+Parser.prototype._binary = function(left, fn, parse) {
var right = parse.apply(this);
return function(self) {
return fn(self, left(self), right(self));
};
};
-nglr.Parser.prototype.hasTokens = function () {
+Parser.prototype.hasTokens = function () {
return this.tokens.length > 0;
};
-nglr.Parser.prototype.assertAllConsumed = function(){
+Parser.prototype.assertAllConsumed = function(){
if (this.tokens.length !== 0) {
throw "Did not understand '" + this.text.substring(this.tokens[0].index) +
"' while evaluating '" + this.text + "'.";
}
};
-nglr.Parser.prototype.statements = function(){
+Parser.prototype.statements = function(){
var statements = [];
while(true) {
if (this.tokens.length > 0 && !this.peek('}', ')', ';', ']'))
@@ -333,7 +333,7 @@ nglr.Parser.prototype.statements = function(){
}
};
-nglr.Parser.prototype.filterChain = function(){
+Parser.prototype.filterChain = function(){
var left = this.expression();
var token;
while(true) {
@@ -345,15 +345,15 @@ nglr.Parser.prototype.filterChain = function(){
}
};
-nglr.Parser.prototype.filter = function(){
+Parser.prototype.filter = function(){
return this._pipeFunction(angular.filter);
};
-nglr.Parser.prototype.validator = function(){
+Parser.prototype.validator = function(){
return this._pipeFunction(angular.validator);
};
-nglr.Parser.prototype._pipeFunction = function(fnScope){
+Parser.prototype._pipeFunction = function(fnScope){
var fn = this.functionIdent(fnScope);
var argsFn = [];
var token;
@@ -375,11 +375,11 @@ nglr.Parser.prototype._pipeFunction = function(fnScope){
}
};
-nglr.Parser.prototype.expression = function(){
+Parser.prototype.expression = function(){
return this.throwStmt();
};
-nglr.Parser.prototype.throwStmt = function(){
+Parser.prototype.throwStmt = function(){
if (this.expect('throw')) {
var throwExp = this.assignment();
return function (self) {
@@ -390,7 +390,7 @@ nglr.Parser.prototype.throwStmt = function(){
}
};
-nglr.Parser.prototype.assignment = function(){
+Parser.prototype.assignment = function(){
var left = this.logicalOR();
var token;
if (token = this.expect('=')) {
@@ -406,7 +406,7 @@ nglr.Parser.prototype.assignment = function(){
}
};
-nglr.Parser.prototype.logicalOR = function(){
+Parser.prototype.logicalOR = function(){
var left = this.logicalAND();
var token;
while(true) {
@@ -418,7 +418,7 @@ nglr.Parser.prototype.logicalOR = function(){
}
};
-nglr.Parser.prototype.logicalAND = function(){
+Parser.prototype.logicalAND = function(){
var left = this.negated();
var token;
while(true) {
@@ -430,7 +430,7 @@ nglr.Parser.prototype.logicalAND = function(){
}
};
-nglr.Parser.prototype.negated = function(){
+Parser.prototype.negated = function(){
var token;
if (token = this.expect('!')) {
return this._unary(token.fn, this.equality);
@@ -439,7 +439,7 @@ nglr.Parser.prototype.negated = function(){
}
};
-nglr.Parser.prototype.equality = function(){
+Parser.prototype.equality = function(){
var left = this.relational();
var token;
while(true) {
@@ -451,7 +451,7 @@ nglr.Parser.prototype.equality = function(){
}
};
-nglr.Parser.prototype.relational = function(){
+Parser.prototype.relational = function(){
var left = this.additive();
var token;
while(true) {
@@ -463,7 +463,7 @@ nglr.Parser.prototype.relational = function(){
}
};
-nglr.Parser.prototype.additive = function(){
+Parser.prototype.additive = function(){
var left = this.multiplicative();
var token;
while(token = this.expect('+','-')) {
@@ -472,7 +472,7 @@ nglr.Parser.prototype.additive = function(){
return left;
};
-nglr.Parser.prototype.multiplicative = function(){
+Parser.prototype.multiplicative = function(){
var left = this.unary();
var token;
while(token = this.expect('*','/','%')) {
@@ -481,18 +481,18 @@ nglr.Parser.prototype.multiplicative = function(){
return left;
};
-nglr.Parser.prototype.unary = function(){
+Parser.prototype.unary = function(){
var token;
if (this.expect('+')) {
return this.primary();
} else if (token = this.expect('-')) {
- return this._binary(nglr.Parser.ZERO, token.fn, this.multiplicative);
+ return this._binary(Parser.ZERO, token.fn, this.multiplicative);
} else {
return this.primary();
}
};
-nglr.Parser.prototype.functionIdent = function(fnScope) {
+Parser.prototype.functionIdent = function(fnScope) {
var token = this.expect();
var element = token.text.split('.');
var instance = fnScope;
@@ -509,7 +509,7 @@ nglr.Parser.prototype.functionIdent = function(fnScope) {
return instance;
};
-nglr.Parser.prototype.primary = function() {
+Parser.prototype.primary = function() {
var primary;
if (this.expect('(')) {
var expression = this.filterChain();
@@ -545,7 +545,7 @@ nglr.Parser.prototype.primary = function() {
return primary;
};
-nglr.Parser.prototype.closure = function(hasArgs) {
+Parser.prototype.closure = function(hasArgs) {
var args = [];
if (hasArgs) {
if (!this.expect(')')) {
@@ -561,7 +561,7 @@ nglr.Parser.prototype.closure = function(hasArgs) {
this.consume("}");
return function(self){
return function($){
- var scope = new nglr.Scope(self.scope.state);
+ var scope = new Scope(self.scope.state);
scope.set('$', $);
for ( var i = 0; i < args.length; i++) {
scope.set(args[i], arguments[i]);
@@ -571,16 +571,16 @@ nglr.Parser.prototype.closure = function(hasArgs) {
};
};
-nglr.Parser.prototype.fieldAccess = function(object) {
+Parser.prototype.fieldAccess = function(object) {
var field = this.expect().text;
var fn = function (self){
- return nglr.Scope.getter(object(self), field);
+ return Scope.getter(object(self), field);
};
fn.isAssignable = field;
return fn;
};
-nglr.Parser.prototype.objectIndex = function(obj) {
+Parser.prototype.objectIndex = function(obj) {
var indexFn = this.expression();
this.consume(']');
if (this.expect('=')) {
@@ -597,7 +597,7 @@ nglr.Parser.prototype.objectIndex = function(obj) {
}
};
-nglr.Parser.prototype.functionCall = function(fn) {
+Parser.prototype.functionCall = function(fn) {
var argsFn = [];
if (this.peekToken().text != ')') {
do {
@@ -620,7 +620,7 @@ nglr.Parser.prototype.functionCall = function(fn) {
};
// This is used with json array declaration
-nglr.Parser.prototype.arrayDeclaration = function () {
+Parser.prototype.arrayDeclaration = function () {
var elementFns = [];
if (this.peekToken().text != ']') {
do {
@@ -637,7 +637,7 @@ nglr.Parser.prototype.arrayDeclaration = function () {
};
};
-nglr.Parser.prototype.object = function () {
+Parser.prototype.object = function () {
var keyValues = [];
if (this.peekToken().text != '}') {
do {
@@ -659,7 +659,7 @@ nglr.Parser.prototype.object = function () {
};
};
-nglr.Parser.prototype.entityDeclaration = function () {
+Parser.prototype.entityDeclaration = function () {
var decl = [];
while(this.hasTokens()) {
decl.push(this.entityDecl());
@@ -676,7 +676,7 @@ nglr.Parser.prototype.entityDeclaration = function () {
};
};
-nglr.Parser.prototype.entityDecl = function () {
+Parser.prototype.entityDecl = function () {
var entity = this.expect().text;
var instance;
var defaults;
@@ -705,7 +705,7 @@ nglr.Parser.prototype.entityDecl = function () {
};
};
-nglr.Parser.prototype.watch = function () {
+Parser.prototype.watch = function () {
var decl = [];
while(this.hasTokens()) {
decl.push(this.watchDecl());
@@ -722,7 +722,7 @@ nglr.Parser.prototype.watch = function () {
};
};
-nglr.Parser.prototype.watchDecl = function () {
+Parser.prototype.watchDecl = function () {
var anchorName = this.expect().text;
this.consume(":");
var expression;
diff --git a/src/Scope.js b/src/Scope.js
index 45dd15a4..e3634cee 100644
--- a/src/Scope.js
+++ b/src/Scope.js
@@ -1,6 +1,6 @@
// Copyright (C) 2009 BRAT Tech LLC
-nglr.Scope = function(initialState, name) {
+Scope = function(initialState, name) {
this.widgets = [];
this.watchListeners = {};
this.name = name;
@@ -14,9 +14,9 @@ nglr.Scope = function(initialState, name) {
}
};
-nglr.Scope.expressionCache = {};
+Scope.expressionCache = {};
-nglr.Scope.prototype.updateView = function() {
+Scope.prototype.updateView = function() {
var self = this;
this.fireWatchers();
_.each(this.widgets, function(widget){
@@ -26,21 +26,21 @@ nglr.Scope.prototype.updateView = function() {
});
};
-nglr.Scope.prototype.addWidget = function(controller) {
+Scope.prototype.addWidget = function(controller) {
if (controller) this.widgets.push(controller);
};
-nglr.Scope.prototype.isProperty = function(exp) {
+Scope.prototype.isProperty = function(exp) {
for ( var i = 0; i < exp.length; i++) {
var ch = exp.charAt(i);
- if (ch!='.' && !nglr.Lexer.prototype.isIdent(ch)) {
+ if (ch!='.' && !Lexer.prototype.isIdent(ch)) {
return false;
}
}
return true;
};
-nglr.Scope.getter = function(instance, path) {
+Scope.getter = function(instance, path) {
if (!path) return instance;
var element = path.split('.');
var key;
@@ -65,16 +65,16 @@ nglr.Scope.getter = function(instance, path) {
}
}
if (typeof instance === 'function' && !instance.$$factory) {
- return nglr.bind(lastInstance, instance);
+ return bind(lastInstance, instance);
}
return instance;
};
-nglr.Scope.prototype.get = function(path) {
- return nglr.Scope.getter(this.state, path);
+Scope.prototype.get = function(path) {
+ return Scope.getter(this.state, path);
};
-nglr.Scope.prototype.set = function(path, value) {
+Scope.prototype.set = function(path, value) {
var element = path.split('.');
var instance = this.state;
for ( var i = 0; element.length > 1; i++) {
@@ -90,17 +90,17 @@ nglr.Scope.prototype.set = function(path, value) {
return value;
};
-nglr.Scope.prototype.setEval = function(expressionText, value) {
- this.eval(expressionText + "=" + nglr.toJson(value));
+Scope.prototype.setEval = function(expressionText, value) {
+ this.eval(expressionText + "=" + toJson(value));
};
-nglr.Scope.prototype.eval = function(expressionText, context) {
- var expression = nglr.Scope.expressionCache[expressionText];
+Scope.prototype.eval = function(expressionText, context) {
+ var expression = Scope.expressionCache[expressionText];
if (!expression) {
- var parser = new nglr.Parser(expressionText);
+ var parser = new Parser(expressionText);
expression = parser.statements();
parser.assertAllConsumed();
- nglr.Scope.expressionCache[expressionText] = expression;
+ Scope.expressionCache[expressionText] = expression;
}
context = context || {};
context.scope = this;
@@ -110,7 +110,7 @@ nglr.Scope.prototype.eval = function(expressionText, context) {
//TODO: Refactor. This function needs to be an execution closure for widgets
// move to widgets
// remove expression, just have inner closure.
-nglr.Scope.prototype.evalWidget = function(widget, expression, context, onSuccess, onFailure) {
+Scope.prototype.evalWidget = function(widget, expression, context, onSuccess, onFailure) {
try {
var value = this.eval(expression, context);
if (widget.hasError) {
@@ -125,7 +125,7 @@ nglr.Scope.prototype.evalWidget = function(widget, expression, context, onSucces
return true;
} catch (e){
console.error('Eval Widget Error:', e);
- var jsonError = nglr.toJson(e, true);
+ var jsonError = toJson(e, true);
widget.hasError = true;
jQuery(widget.view).
addClass('ng-exception').
@@ -137,42 +137,42 @@ nglr.Scope.prototype.evalWidget = function(widget, expression, context, onSucces
}
};
-nglr.Scope.prototype.validate = function(expressionText, value) {
- var expression = nglr.Scope.expressionCache[expressionText];
+Scope.prototype.validate = function(expressionText, value) {
+ var expression = Scope.expressionCache[expressionText];
if (!expression) {
- expression = new nglr.Parser(expressionText).validator();
- nglr.Scope.expressionCache[expressionText] = expression;
+ expression = new Parser(expressionText).validator();
+ Scope.expressionCache[expressionText] = expression;
}
var self = {scope:this};
return expression(self)(self, value);
};
-nglr.Scope.prototype.entity = function(entityDeclaration) {
- var expression = new nglr.Parser(entityDeclaration).entityDeclaration();
+Scope.prototype.entity = function(entityDeclaration) {
+ var expression = new Parser(entityDeclaration).entityDeclaration();
return expression({scope:this});
};
-nglr.Scope.prototype.markInvalid = function(widget) {
+Scope.prototype.markInvalid = function(widget) {
this.state.$invalidWidgets.push(widget);
};
-nglr.Scope.prototype.watch = function(declaration) {
+Scope.prototype.watch = function(declaration) {
var self = this;
- new nglr.Parser(declaration).watch()({
+ new Parser(declaration).watch()({
scope:this,
addListener:function(watch, exp){
self.addWatchListener(watch, function(n,o){
try {
return exp({scope:self}, n, o);
} catch(e) {
- nglr.alert(e);
+ alert(e);
}
});
}
});
};
-nglr.Scope.prototype.addWatchListener = function(watchExpression, listener) {
+Scope.prototype.addWatchListener = function(watchExpression, listener) {
var watcher = this.watchListeners[watchExpression];
if (!watcher) {
watcher = {listeners:[], expression:watchExpression};
@@ -181,7 +181,7 @@ nglr.Scope.prototype.addWatchListener = function(watchExpression, listener) {
watcher.listeners.push(listener);
};
-nglr.Scope.prototype.fireWatchers = function() {
+Scope.prototype.fireWatchers = function() {
var self = this;
var fired = false;
jQuery.each(this.watchListeners, function(name, watcher) {
diff --git a/src/Server.js b/src/Server.js
index 94b0cc10..d00f893b 100644
--- a/src/Server.js
+++ b/src/Server.js
@@ -1,6 +1,6 @@
// Copyright (C) 2008,2009 BRAT Tech LLC
-nglr.Server = function(url, getScript) {
+Server = function(url, getScript) {
this.url = url;
this.nextId = 0;
this.getScript = getScript;
@@ -8,51 +8,51 @@ nglr.Server = function(url, getScript) {
this.maxSize = 1800;
};
-nglr.Server.prototype.base64url = function(txt) {
+Server.prototype.base64url = function(txt) {
return Base64.encode(txt);
};
-nglr.Server.prototype.request = function(method, url, request, callback) {
+Server.prototype.request = function(method, url, request, callback) {
var requestId = this.uuid + (this.nextId++);
- nglr[requestId] = function(response) {
- delete nglr[requestId];
+ callbacks[requestId] = function(response) {
+ delete angular[requestId];
callback(200, response);
};
var payload = {u:url, m:method, p:request};
- payload = this.base64url(nglr.toJson(payload));
+ payload = this.base64url(toJson(payload));
var totalPockets = Math.ceil(payload.length / this.maxSize);
var baseUrl = this.url + "/$/" + requestId + "/" + totalPockets + "/";
for ( var pocketNo = 0; pocketNo < totalPockets; pocketNo++) {
var pocket = payload.substr(pocketNo * this.maxSize, this.maxSize);
- this.getScript(baseUrl + (pocketNo+1) + "?h=" + pocket, nglr.noop);
+ this.getScript(baseUrl + (pocketNo+1) + "?h=" + pocket, noop);
}
};
-nglr.FrameServer = function(frame) {
+FrameServer = function(frame) {
this.frame = frame;
};
-nglr.FrameServer.PREFIX = "$DATASET:";
+FrameServer.PREFIX = "$DATASET:";
-nglr.FrameServer.prototype = {
+FrameServer.prototype = {
read:function(){
- this.data = nglr.fromJson(this.frame.name.substr(nglr.FrameServer.PREFIX.length));
+ this.data = fromJson(this.frame.name.substr(FrameServer.PREFIX.length));
},
write:function(){
- this.frame.name = nglr.FrameServer.PREFIX + nglr.toJson(this.data);
+ this.frame.name = FrameServer.PREFIX + toJson(this.data);
},
request: function(method, url, request, callback) {
- //alert(method + " " + url + " " + nglr.toJson(request) + " " + nglr.toJson(callback));
+ //alert(method + " " + url + " " + toJson(request) + " " + toJson(callback));
}
};
-nglr.VisualServer = function(delegate, status, update) {
+VisualServer = function(delegate, status, update) {
this.delegate = delegate;
this.update = update;
this.status = status;
};
-nglr.VisualServer.prototype = {
+VisualServer.prototype = {
request:function(method, url, request, callback) {
var self = this;
this.status.beginRequest(request);
@@ -61,7 +61,7 @@ nglr.VisualServer.prototype = {
try {
callback.apply(this, arguments);
} catch (e) {
- nglr.alert(nglr.toJson(e));
+ alert(toJson(e));
}
self.update();
});
diff --git a/src/Users.js b/src/Users.js
index c0c15848..d10b96df 100644
--- a/src/Users.js
+++ b/src/Users.js
@@ -1,10 +1,10 @@
// Copyright (C) 2008,2009 BRAT Tech LLC
-nglr.Users = function(server, controlBar) {
+Users = function(server, controlBar) {
this.server = server;
this.controlBar = controlBar;
};
-nglr.Users.prototype = {
+Users.prototype = {
fetchCurrentUser:function(callback) {
var self = this;
this.server.request("GET", "/account.json", {}, function(code, response){
@@ -17,7 +17,7 @@ nglr.Users.prototype = {
var self = this;
this.controlBar.logout(function(){
delete self.current;
- (callback||nglr.noop)();
+ (callback||noop)();
});
},
@@ -25,7 +25,7 @@ nglr.Users.prototype = {
var self = this;
this.controlBar.login(function(){
self.fetchCurrentUser(function(){
- (callback||nglr.noop)();
+ (callback||noop)();
});
});
},
diff --git a/src/Validators.js b/src/Validators.js
index 94cb1d52..7cfaa2b4 100644
--- a/src/Validators.js
+++ b/src/Validators.js
@@ -72,7 +72,7 @@ angular.validator.url = function(value) {
angular.validator.json = function(value) {
try {
- nglr.fromJson(value);
+ fromJson(value);
return null;
} catch (e) {
return e.toString();
diff --git a/src/Widgets.js b/src/Widgets.js
index de74533a..3a0f2845 100644
--- a/src/Widgets.js
+++ b/src/Widgets.js
@@ -1,7 +1,7 @@
// Copyright (C) 2009 BRAT Tech LLC
-nglr.WidgetFactory = function(serverUrl, database) {
+WidgetFactory = function(serverUrl, database) {
this.nextUploadId = 0;
this.serverUrl = serverUrl;
this.database = database;
@@ -9,7 +9,7 @@ nglr.WidgetFactory = function(serverUrl, database) {
this.onChangeListener = function(){};
};
-nglr.WidgetFactory.prototype.createController = function(input, scope) {
+WidgetFactory.prototype.createController = function(input, scope) {
var controller;
var type = input.attr('type').toLowerCase();
var exp = input.attr('name');
@@ -17,22 +17,22 @@ nglr.WidgetFactory.prototype.createController = function(input, scope) {
var event = "change";
var bubbleEvent = true;
if (type == 'button' || type == 'submit' || type == 'reset' || type == 'image') {
- controller = new nglr.ButtonController(input[0], exp);
+ controller = new ButtonController(input[0], exp);
event = "click";
bubbleEvent = false;
} else if (type == 'text' || type == 'textarea' || type == 'hidden' || type == 'password') {
- controller = new nglr.TextController(input[0], exp);
+ controller = new TextController(input[0], exp);
event = "keyup change";
} else if (type == 'checkbox') {
- controller = new nglr.CheckboxController(input[0], exp);
+ controller = new CheckboxController(input[0], exp);
event = "click";
} else if (type == 'radio') {
- controller = new nglr.RadioController(input[0], exp);
+ controller = new RadioController(input[0], exp);
event="click";
} else if (type == 'select-one') {
- controller = new nglr.SelectController(input[0], exp);
+ controller = new SelectController(input[0], exp);
} else if (type == 'select-multiple') {
- controller = new nglr.MultiSelectController(input[0], exp);
+ controller = new MultiSelectController(input[0], exp);
} else if (type == 'file') {
controller = this.createFileController(input, exp);
} else {
@@ -54,9 +54,9 @@ nglr.WidgetFactory.prototype.createController = function(input, scope) {
return controller;
};
-nglr.WidgetFactory.prototype.createFileController = function(fileInput) {
+WidgetFactory.prototype.createFileController = function(fileInput) {
var uploadId = '__uploadWidget_' + (this.nextUploadId++);
- var view = nglr.FileController.template(uploadId);
+ var view = FileController.template(uploadId);
fileInput.after(view);
var att = {
data:this.serverUrl + "/admin/ServerAPI.swf",
@@ -67,13 +67,13 @@ nglr.WidgetFactory.prototype.createFileController = function(fileInput) {
allowScriptAccess:"always"};
var swfNode = this.createSWF(att, par, uploadId);
fileInput.remove();
- var cntl = new nglr.FileController(view, fileInput[0].name, swfNode, this.serverUrl + "/data/" + this.database);
+ var cntl = new FileController(view, fileInput[0].name, swfNode, this.serverUrl + "/data/" + this.database);
jQuery(swfNode).data('controller', cntl);
return cntl;
};
-nglr.WidgetFactory.prototype.createTextWidget = function(textInput) {
- var controller = new nglr.TextController(textInput);
+WidgetFactory.prototype.createTextWidget = function(textInput) {
+ var controller = new TextController(textInput);
controller.onChange(this.onChangeListener);
return controller;
};
@@ -82,7 +82,7 @@ nglr.WidgetFactory.prototype.createTextWidget = function(textInput) {
// FileController
///////////////////////
-nglr.FileController = function(view, scopeName, uploader, databaseUrl) {
+FileController = function(view, scopeName, uploader, databaseUrl) {
this.view = view;
this.uploader = uploader;
this.scopeName = scopeName;
@@ -91,13 +91,13 @@ nglr.FileController = function(view, scopeName, uploader, databaseUrl) {
this.lastValue = undefined;
};
-nglr.FileController.dispatchEvent = function(id, event, args) {
+FileController.dispatchEvent = function(id, event, args) {
var object = document.getElementById(id);
var controller = jQuery(object).data("controller");
- nglr.FileController.prototype['_on_' + event].apply(controller, args);
+ FileController.prototype['_on_' + event].apply(controller, args);
};
-nglr.FileController.template = function(id) {
+FileController.template = function(id) {
return jQuery('<span class="ng-upload-widget">' +
'<input type="checkbox" ng-non-bindable="true"/>' +
'<object id="' + id + '" />' +
@@ -106,33 +106,33 @@ nglr.FileController.template = function(id) {
'</span>');
};
-nglr.FileController.prototype._on_cancel = function() {
+FileController.prototype._on_cancel = function() {
};
-nglr.FileController.prototype._on_complete = function() {
+FileController.prototype._on_complete = function() {
};
-nglr.FileController.prototype._on_httpStatus = function(status) {
- nglr.alert("httpStatus:" + this.scopeName + " status:" + status);
+FileController.prototype._on_httpStatus = function(status) {
+ alert("httpStatus:" + this.scopeName + " status:" + status);
};
-nglr.FileController.prototype._on_ioError = function() {
- nglr.alert("ioError:" + this.scopeName);
+FileController.prototype._on_ioError = function() {
+ alert("ioError:" + this.scopeName);
};
-nglr.FileController.prototype._on_open = function() {
- nglr.alert("open:" + this.scopeName);
+FileController.prototype._on_open = function() {
+ alert("open:" + this.scopeName);
};
-nglr.FileController.prototype._on_progress = function(bytesLoaded, bytesTotal) {
+FileController.prototype._on_progress = function(bytesLoaded, bytesTotal) {
};
-nglr.FileController.prototype._on_securityError = function() {
- nglr.alert("securityError:" + this.scopeName);
+FileController.prototype._on_securityError = function() {
+ alert("securityError:" + this.scopeName);
};
-nglr.FileController.prototype._on_uploadCompleteData = function(data) {
- var value = nglr.fromJson(data);
+FileController.prototype._on_uploadCompleteData = function(data) {
+ var value = fromJson(data);
value.url = this.attachmentsPath + '/' + value.id + '/' + value.text;
this.view.find("input").attr('checked', true);
var scope = this.view.scope();
@@ -142,14 +142,14 @@ nglr.FileController.prototype._on_uploadCompleteData = function(data) {
scope.get('$binder').updateView();
};
-nglr.FileController.prototype._on_select = function(name, size, type) {
+FileController.prototype._on_select = function(name, size, type) {
this.name = name;
this.view.find("a").text(name).attr('href', name);
this.view.find("span").text(angular.filter.bytes(size));
this.upload();
};
-nglr.FileController.prototype.updateModel = function(scope) {
+FileController.prototype.updateModel = function(scope) {
var isChecked = this.view.find("input").attr('checked');
var value = isChecked ? this.value : null;
if (this.lastValue === value) {
@@ -160,7 +160,7 @@ nglr.FileController.prototype.updateModel = function(scope) {
}
};
-nglr.FileController.prototype.updateView = function(scope) {
+FileController.prototype.updateView = function(scope) {
var modelValue = scope.get(this.scopeName);
if (modelValue && this.value !== modelValue) {
this.value = modelValue;
@@ -172,7 +172,7 @@ nglr.FileController.prototype.updateView = function(scope) {
this.view.find("input").attr('checked', !!modelValue);
};
-nglr.FileController.prototype.upload = function() {
+FileController.prototype.upload = function() {
if (this.name) {
this.uploader.uploadFile(this.attachmentsPath);
}
@@ -182,23 +182,23 @@ nglr.FileController.prototype.upload = function() {
///////////////////////
// NullController
///////////////////////
-nglr.NullController = function(view) {this.view = view;};
-nglr.NullController.prototype.updateModel = function() { return true; };
-nglr.NullController.prototype.updateView = function() { };
-nglr.NullController.instance = new nglr.NullController();
+NullController = function(view) {this.view = view;};
+NullController.prototype.updateModel = function() { return true; };
+NullController.prototype.updateView = function() { };
+NullController.instance = new NullController();
///////////////////////
// ButtonController
///////////////////////
-nglr.ButtonController = function(view) {this.view = view;};
-nglr.ButtonController.prototype.updateModel = function(scope) { return true; };
-nglr.ButtonController.prototype.updateView = function(scope) {};
+ButtonController = function(view) {this.view = view;};
+ButtonController.prototype.updateModel = function(scope) { return true; };
+ButtonController.prototype.updateView = function(scope) {};
///////////////////////
// TextController
///////////////////////
-nglr.TextController = function(view, exp) {
+TextController = function(view, exp) {
this.view = view;
this.exp = exp;
this.validator = view.getAttribute('ng-validate');
@@ -212,7 +212,7 @@ nglr.TextController = function(view, exp) {
}
};
-nglr.TextController.prototype.updateModel = function(scope) {
+TextController.prototype.updateModel = function(scope) {
var value = this.view.value;
if (this.lastValue === value) {
return false;
@@ -223,7 +223,7 @@ nglr.TextController.prototype.updateModel = function(scope) {
}
};
-nglr.TextController.prototype.updateView = function(scope) {
+TextController.prototype.updateView = function(scope) {
var view = this.view;
var value = scope.get(this.exp);
if (typeof value === "undefined") {
@@ -258,14 +258,14 @@ nglr.TextController.prototype.updateView = function(scope) {
///////////////////////
// CheckboxController
///////////////////////
-nglr.CheckboxController = function(view, exp) {
+CheckboxController = function(view, exp) {
this.view = view;
this.exp = exp;
this.lastValue = undefined;
this.initialValue = view.checked ? view.value : "";
};
-nglr.CheckboxController.prototype.updateModel = function(scope) {
+CheckboxController.prototype.updateModel = function(scope) {
var input = this.view;
var value = input.checked ? input.value : '';
if (this.lastValue === value) {
@@ -277,7 +277,7 @@ nglr.CheckboxController.prototype.updateModel = function(scope) {
}
};
-nglr.CheckboxController.prototype.updateView = function(scope) {
+CheckboxController.prototype.updateView = function(scope) {
var input = this.view;
var value = scope.eval(this.exp);
if (typeof value === "undefined") {
@@ -290,14 +290,14 @@ nglr.CheckboxController.prototype.updateView = function(scope) {
///////////////////////
// SelectController
///////////////////////
-nglr.SelectController = function(view, exp) {
+SelectController = function(view, exp) {
this.view = view;
this.exp = exp;
this.lastValue = undefined;
this.initialValue = view.value;
};
-nglr.SelectController.prototype.updateModel = function(scope) {
+SelectController.prototype.updateModel = function(scope) {
var input = this.view;
if (input.selectedIndex < 0) {
scope.setEval(this.exp, null);
@@ -313,7 +313,7 @@ nglr.SelectController.prototype.updateModel = function(scope) {
}
};
-nglr.SelectController.prototype.updateView = function(scope) {
+SelectController.prototype.updateView = function(scope) {
var input = this.view;
var value = scope.get(this.exp);
if (typeof value === 'undefined') {
@@ -329,14 +329,14 @@ nglr.SelectController.prototype.updateView = function(scope) {
///////////////////////
// MultiSelectController
///////////////////////
-nglr.MultiSelectController = function(view, exp) {
+MultiSelectController = function(view, exp) {
this.view = view;
this.exp = exp;
this.lastValue = undefined;
this.initialValue = this.selected();
};
-nglr.MultiSelectController.prototype.selected = function () {
+MultiSelectController.prototype.selected = function () {
var value = [];
var options = this.view.options;
for ( var i = 0; i < options.length; i++) {
@@ -348,7 +348,7 @@ nglr.MultiSelectController.prototype.selected = function () {
return value;
};
-nglr.MultiSelectController.prototype.updateModel = function(scope) {
+MultiSelectController.prototype.updateModel = function(scope) {
var value = this.selected();
// TODO: This is wrong! no caching going on here as we are always comparing arrays
if (this.lastValue === value) {
@@ -360,7 +360,7 @@ nglr.MultiSelectController.prototype.updateModel = function(scope) {
}
};
-nglr.MultiSelectController.prototype.updateView = function(scope) {
+MultiSelectController.prototype.updateView = function(scope) {
var input = this.view;
var selected = scope.get(this.exp);
if (typeof selected === "undefined") {
@@ -380,7 +380,7 @@ nglr.MultiSelectController.prototype.updateView = function(scope) {
///////////////////////
// RadioController
///////////////////////
-nglr.RadioController = function(view, exp) {
+RadioController = function(view, exp) {
this.view = view;
this.exp = exp;
this.lastChecked = undefined;
@@ -389,7 +389,7 @@ nglr.RadioController = function(view, exp) {
this.initialValue = view.checked ? view.value : null;
};
-nglr.RadioController.prototype.updateModel = function(scope) {
+RadioController.prototype.updateModel = function(scope) {
var input = this.view;
if (this.lastChecked) {
return false;
@@ -401,7 +401,7 @@ nglr.RadioController.prototype.updateModel = function(scope) {
}
};
-nglr.RadioController.prototype.updateView = function(scope) {
+RadioController.prototype.updateView = function(scope) {
var input = this.view;
var value = scope.get(this.exp);
if (this.initialValue && typeof value === "undefined") {
@@ -417,25 +417,25 @@ nglr.RadioController.prototype.updateView = function(scope) {
///////////////////////
//ElementController
///////////////////////
-nglr.BindUpdater = function(view, exp) {
+BindUpdater = function(view, exp) {
this.view = view;
- this.exp = nglr.Binder.parseBindings(exp);
+ this.exp = Binder.parseBindings(exp);
this.hasError = false;
this.scopeSelf = {element:view};
};
-nglr.BindUpdater.toText = function(obj) {
- var e = nglr.escapeHtml;
+BindUpdater.toText = function(obj) {
+ var e = escapeHtml;
switch(typeof obj) {
case "string":
case "boolean":
case "number":
return e(obj);
case "function":
- return nglr.BindUpdater.toText(obj());
+ return BindUpdater.toText(obj());
case "object":
- if (nglr.isNode(obj)) {
- return nglr.outerHTML(obj);
+ if (isNode(obj)) {
+ return outerHTML(obj);
} else if (obj instanceof angular.filter.Meta) {
switch(typeof obj.html) {
case "string":
@@ -444,8 +444,8 @@ nglr.BindUpdater.toText = function(obj) {
case "function":
return obj.html();
case "object":
- if (nglr.isNode(obj.html))
- return nglr.outerHTML(obj.html);
+ if (isNode(obj.html))
+ return outerHTML(obj.html);
default:
break;
}
@@ -461,43 +461,43 @@ nglr.BindUpdater.toText = function(obj) {
}
if (obj === null)
return "";
- return e(nglr.toJson(obj, true));
+ return e(toJson(obj, true));
default:
return "";
}
};
-nglr.BindUpdater.prototype.updateModel = function(scope) {};
-nglr.BindUpdater.prototype.updateView = function(scope) {
+BindUpdater.prototype.updateModel = function(scope) {};
+BindUpdater.prototype.updateView = function(scope) {
var html = [];
var parts = this.exp;
var length = parts.length;
for(var i=0; i<length; i++) {
var part = parts[i];
- var binding = nglr.Binder.binding(part);
+ var binding = Binder.binding(part);
if (binding) {
scope.evalWidget(this, binding, this.scopeSelf, function(value){
- html.push(nglr.BindUpdater.toText(value));
+ html.push(BindUpdater.toText(value));
}, function(e, text){
- nglr.setHtml(this.view, text);
+ setHtml(this.view, text);
});
if (this.hasError) {
return;
}
} else {
- html.push(nglr.escapeHtml(part));
+ html.push(escapeHtml(part));
}
}
- nglr.setHtml(this.view, html.join(''));
+ setHtml(this.view, html.join(''));
};
-nglr.BindAttrUpdater = function(view, attrs) {
+BindAttrUpdater = function(view, attrs) {
this.view = view;
this.attrs = attrs;
};
-nglr.BindAttrUpdater.prototype.updateModel = function(scope) {};
-nglr.BindAttrUpdater.prototype.updateView = function(scope) {
+BindAttrUpdater.prototype.updateModel = function(scope) {};
+BindAttrUpdater.prototype.updateView = function(scope) {
var jNode = jQuery(this.view);
var attributeTemplates = this.attrs;
if (this.hasError) {
@@ -508,19 +508,19 @@ nglr.BindAttrUpdater.prototype.updateView = function(scope) {
}
var isImage = jNode.is('img');
for (var attrName in attributeTemplates) {
- var attributeTemplate = nglr.Binder.parseBindings(attributeTemplates[attrName]);
+ var attributeTemplate = Binder.parseBindings(attributeTemplates[attrName]);
var attrValues = [];
for ( var i = 0; i < attributeTemplate.length; i++) {
- var binding = nglr.Binder.binding(attributeTemplate[i]);
+ var binding = Binder.binding(attributeTemplate[i]);
if (binding) {
try {
var value = scope.eval(binding, {element:jNode[0], attrName:attrName});
- if (value && (value.constructor !== nglr.array || value.length !== 0))
+ if (value && (value.constructor !== array || value.length !== 0))
attrValues.push(value);
} catch (e) {
this.hasError = true;
console.error('BindAttrUpdater', e);
- var jsonError = nglr.toJson(e, true);
+ var jsonError = toJson(e, true);
attrValues.push('[' + jsonError + ']');
jNode.
addClass('ng-exception').
@@ -537,22 +537,22 @@ nglr.BindAttrUpdater.prototype.updateView = function(scope) {
}
};
-nglr.EvalUpdater = function(view, exp) {
+EvalUpdater = function(view, exp) {
this.view = view;
this.exp = exp;
this.hasError = false;
};
-nglr.EvalUpdater.prototype.updateModel = function(scope) {};
-nglr.EvalUpdater.prototype.updateView = function(scope) {
+EvalUpdater.prototype.updateModel = function(scope) {};
+EvalUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp);
};
-nglr.HideUpdater = function(view, exp) { this.view = view; this.exp = exp; };
-nglr.HideUpdater.prototype.updateModel = function(scope) {};
-nglr.HideUpdater.prototype.updateView = function(scope) {
+HideUpdater = function(view, exp) { this.view = view; this.exp = exp; };
+HideUpdater.prototype.updateModel = function(scope) {};
+HideUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(hideValue){
var view = jQuery(this.view);
- if (nglr.toBoolean(hideValue)) {
+ if (toBoolean(hideValue)) {
view.hide();
} else {
view.show();
@@ -560,12 +560,12 @@ nglr.HideUpdater.prototype.updateView = function(scope) {
});
};
-nglr.ShowUpdater = function(view, exp) { this.view = view; this.exp = exp; };
-nglr.ShowUpdater.prototype.updateModel = function(scope) {};
-nglr.ShowUpdater.prototype.updateView = function(scope) {
+ShowUpdater = function(view, exp) { this.view = view; this.exp = exp; };
+ShowUpdater.prototype.updateModel = function(scope) {};
+ShowUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(hideValue){
var view = jQuery(this.view);
- if (nglr.toBoolean(hideValue)) {
+ if (toBoolean(hideValue)) {
view.show();
} else {
view.hide();
@@ -573,9 +573,9 @@ nglr.ShowUpdater.prototype.updateView = function(scope) {
});
};
-nglr.ClassUpdater = function(view, exp) { this.view = view; this.exp = exp; };
-nglr.ClassUpdater.prototype.updateModel = function(scope) {};
-nglr.ClassUpdater.prototype.updateView = function(scope) {
+ClassUpdater = function(view, exp) { this.view = view; this.exp = exp; };
+ClassUpdater.prototype.updateModel = function(scope) {};
+ClassUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(classValue){
if (classValue !== null && classValue !== undefined) {
this.view.className = classValue;
@@ -583,27 +583,27 @@ nglr.ClassUpdater.prototype.updateView = function(scope) {
});
};
-nglr.ClassEvenUpdater = function(view, exp) { this.view = view; this.exp = exp; };
-nglr.ClassEvenUpdater.prototype.updateModel = function(scope) {};
-nglr.ClassEvenUpdater.prototype.updateView = function(scope) {
+ClassEvenUpdater = function(view, exp) { this.view = view; this.exp = exp; };
+ClassEvenUpdater.prototype.updateModel = function(scope) {};
+ClassEvenUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(classValue){
var index = scope.get('$index');
jQuery(this.view).toggleClass(classValue, index % 2 === 1);
});
};
-nglr.ClassOddUpdater = function(view, exp) { this.view = view; this.exp = exp; };
-nglr.ClassOddUpdater.prototype.updateModel = function(scope) {};
-nglr.ClassOddUpdater.prototype.updateView = function(scope) {
+ClassOddUpdater = function(view, exp) { this.view = view; this.exp = exp; };
+ClassOddUpdater.prototype.updateModel = function(scope) {};
+ClassOddUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(classValue){
var index = scope.get('$index');
jQuery(this.view).toggleClass(classValue, index % 2 === 0);
});
};
-nglr.StyleUpdater = function(view, exp) { this.view = view; this.exp = exp; };
-nglr.StyleUpdater.prototype.updateModel = function(scope) {};
-nglr.StyleUpdater.prototype.updateView = function(scope) {
+StyleUpdater = function(view, exp) { this.view = view; this.exp = exp; };
+StyleUpdater.prototype.updateModel = function(scope) {};
+StyleUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(styleValue){
jQuery(this.view).attr('style', "").css(styleValue);
});
@@ -612,7 +612,7 @@ nglr.StyleUpdater.prototype.updateView = function(scope) {
///////////////////////
// RepeaterUpdater
///////////////////////
-nglr.RepeaterUpdater = function(view, repeaterExpression, template, prefix) {
+RepeaterUpdater = function(view, repeaterExpression, template, prefix) {
this.view = view;
this.template = template;
this.prefix = prefix;
@@ -633,8 +633,8 @@ nglr.RepeaterUpdater = function(view, repeaterExpression, template, prefix) {
this.keyExp = match[2];
};
-nglr.RepeaterUpdater.prototype.updateModel = function(scope) {};
-nglr.RepeaterUpdater.prototype.updateView = function(scope) {
+RepeaterUpdater.prototype.updateModel = function(scope) {};
+RepeaterUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.iteratorExp, {}, function(iterator){
var self = this;
if (!iterator) {
@@ -660,7 +660,7 @@ nglr.RepeaterUpdater.prototype.updateView = function(scope) {
// grow children
var name = self.prefix +
valueExp + " in " + self.iteratorExp + "[" + i + "]";
- var childScope = new nglr.Scope(scope.state, name);
+ var childScope = new Scope(scope.state, name);
childScope.set('$index', i);
if (keyExp)
childScope.set(keyExp, key);
@@ -696,22 +696,22 @@ nglr.RepeaterUpdater.prototype.updateView = function(scope) {
// PopUp
//////////////////////////////////
-nglr.PopUp = function(doc) {
+PopUp = function(doc) {
this.doc = doc;
};
-nglr.PopUp.OUT_EVENT = "mouseleave mouseout click dblclick keypress keyup";
+PopUp.OUT_EVENT = "mouseleave mouseout click dblclick keypress keyup";
-nglr.PopUp.prototype.bind = function () {
+PopUp.prototype.bind = function () {
var self = this;
this.doc.find('.ng-validation-error,.ng-exception').
- live("mouseover", nglr.PopUp.onOver);
+ live("mouseover", PopUp.onOver);
};
-nglr.PopUp.onOver = function(e) {
- nglr.PopUp.onOut();
+PopUp.onOver = function(e) {
+ PopUp.onOut();
var jNode = jQuery(this);
- jNode.bind(nglr.PopUp.OUT_EVENT, nglr.PopUp.onOut);
+ jNode.bind(PopUp.OUT_EVENT, PopUp.onOut);
var position = jNode.position();
var de = document.documentElement;
var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
@@ -740,9 +740,9 @@ nglr.PopUp.onOver = function(e) {
return true;
};
-nglr.PopUp.onOut = function() {
+PopUp.onOut = function() {
jQuery('#ng-callout').
- unbind(nglr.PopUp.OUT_EVENT, nglr.PopUp.onOut).
+ unbind(PopUp.OUT_EVENT, PopUp.onOut).
remove();
return true;
};
@@ -752,21 +752,21 @@ nglr.PopUp.onOut = function() {
//////////////////////////////////
-nglr.Status = function(body) {
- this.loader = body.append(nglr.Status.DOM).find("#ng-loading");
+Status = function(body) {
+ this.loader = body.append(Status.DOM).find("#ng-loading");
this.requestCount = 0;
};
-nglr.Status.DOM ='<div id="ng-spacer"></div><div id="ng-loading">loading....</div>';
+Status.DOM ='<div id="ng-spacer"></div><div id="ng-loading">loading....</div>';
-nglr.Status.prototype.beginRequest = function () {
+Status.prototype.beginRequest = function () {
if (this.requestCount === 0) {
this.loader.show();
}
this.requestCount++;
};
-nglr.Status.prototype.endRequest = function () {
+Status.prototype.endRequest = function () {
this.requestCount--;
if (this.requestCount === 0) {
this.loader.hide("fold");
diff --git a/src/Widgets.js.orig b/src/Widgets.js.orig
deleted file mode 100644
index df1d3e40..00000000
--- a/src/Widgets.js.orig
+++ /dev/null
@@ -1,764 +0,0 @@
- // Copyright (C) 2009 BRAT Tech LLC
-
-
-nglr.WidgetFactory = function(serverUrl) {
- this.nextUploadId = 0;
- this.serverUrl = serverUrl;
- this.createSWF = swfobject.createSWF;
- this.onChangeListener = function(){};
-};
-
-nglr.WidgetFactory.prototype.createController = function(input, scope) {
- var controller;
- var type = input.attr('type').toLowerCase();
- var exp = input.attr('name');
- if (exp) exp = exp.split(':').pop();
- var event = "change";
- var bubbleEvent = true;
- if (type == 'button' || type == 'submit' || type == 'reset') {
- controller = new nglr.ButtonController(input[0], exp);
- event = "click";
- bubbleEvent = false;
- } else if (type == 'text' || type == 'textarea') {
- controller = new nglr.TextController(input[0], exp);
- event = "keyup change";
- } else if (type == 'checkbox') {
- controller = new nglr.CheckboxController(input[0], exp);
- event = "click";
- } else if (type == 'radio') {
- controller = new nglr.RadioController(input[0], exp);
- event="click";
- } else if (type == 'select-one') {
- controller = new nglr.SelectController(input[0], exp);
- } else if (type == 'select-multiple') {
- controller = new nglr.MultiSelectController(input[0], exp);
- } else if (type == 'file') {
- controller = this.createFileController(input, exp);
- } else {
- throw 'Unknown type: ' + type;
- }
- input.data('controller', controller);
- var binder = scope.get('$binder');
- var action = function() {
- if (controller.updateModel(scope)) {
- var action = jQuery(controller.view).attr('ng-action') || "";
- if (scope.evalWidget(controller, action)) {
- binder.updateView(scope);
- }
- }
- return bubbleEvent;
- };
- jQuery(controller.view, ":input").
- bind(event, action);
- return controller;
-};
-
-nglr.WidgetFactory.prototype.createFileController = function(fileInput) {
- var uploadId = '__uploadWidget_' + (this.nextUploadId++);
- var view = nglr.FileController.template(uploadId);
- fileInput.after(view);
- var att = {
- data:this.serverUrl + "/admin/ServerAPI.swf",
- width:"95", height:"20", align:"top",
- wmode:"transparent"};
- var par = {
- flashvars:"uploadWidgetId=" + uploadId,
- allowScriptAccess:"always"};
- var swfNode = this.createSWF(att, par, uploadId);
- fileInput.remove();
- var cntl = new nglr.FileController(view, fileInput[0].name, swfNode, this.serverUrl);
- jQuery(swfNode).data('controller', cntl);
- return cntl;
-};
-
-nglr.WidgetFactory.prototype.createTextWidget = function(textInput) {
- var controller = new nglr.TextController(textInput);
- controller.onChange(this.onChangeListener);
- return controller;
-};
-
-/////////////////////
-// FileController
-///////////////////////
-
-nglr.FileController = function(view, scopeName, uploader, serverUrl) {
- this.view = view;
- this.uploader = uploader;
- this.scopeName = scopeName;
- this.uploadUrl = serverUrl + '/upload';
- this.attachmentBase = serverUrl + '/attachments';
- this.value = null;
- this.lastValue = undefined;
-};
-
-nglr.FileController.dispatchEvent = function(id, event, args) {
- var object = document.getElementById(id);
- var controller = jQuery(object).data("controller");
- nglr.FileController.prototype['_on_' + event].apply(controller, args);
-};
-
-nglr.FileController.template = function(id) {
- return jQuery('<span class="ng-upload-widget">' +
- '<input type="checkbox" ng-non-bindable="true"/>' +
- '<object id="' + id + '" />' +
- '<a></a>' +
- '<span/>' +
- '</span>');
-};
-
-nglr.FileController.prototype._on_cancel = function() {
-};
-
-nglr.FileController.prototype._on_complete = function() {
-};
-
-nglr.FileController.prototype._on_httpStatus = function(status) {
- nglr.alert("httpStatus:" + this.scopeName + " status:" + status);
-};
-
-nglr.FileController.prototype._on_ioError = function() {
- nglr.alert("ioError:" + this.scopeName);
-};
-
-nglr.FileController.prototype._on_open = function() {
- nglr.alert("open:" + this.scopeName);
-};
-
-nglr.FileController.prototype._on_progress = function(bytesLoaded, bytesTotal) {
-};
-
-nglr.FileController.prototype._on_securityError = function() {
- nglr.alert("securityError:" + this.scopeName);
-};
-
-nglr.FileController.prototype._on_uploadCompleteData = function(data) {
- this.value = nglr.fromJson(data);
- this.value.url = this.attachmentBase + '/' + this.value.id + '/' + this.value.text;
- this.view.find("input").attr('checked', true);
- var scope = this.view.scope();
- this.updateModel(scope);
- scope.get('$binder').updateView();
-};
-
-nglr.FileController.prototype._on_select = function(name, size, type) {
- this.name = name;
- this.view.find("a").text(name).attr('href', name);
- this.view.find("span").text(filters.bytes(size));
- this.upload();
-};
-
-nglr.FileController.prototype.updateModel = function(scope) {
- var isChecked = this.view.find("input").attr('checked');
- var value = isChecked ? this.value : null;
- if (this.lastValue === value) {
- return false;
- } else {
- scope.set(this.scopeName, value);
- return true;
- }
-};
-
-nglr.FileController.prototype.updateView = function(scope) {
- var modelValue = scope.get(this.scopeName);
- if (modelValue && this.value !== modelValue) {
- this.value = modelValue;
- this.view.find("a").
- attr("href", this.value.url).
- text(this.value.name);
- this.view.find("span").text(filters.bytes(this.value.size));
- }
- this.view.find("input").attr('checked', !!modelValue);
-};
-
-nglr.FileController.prototype.upload = function() {
- if (this.name) {
- this.uploader.uploadFile(this.uploadUrl);
- }
-};
-
-
-///////////////////////
-// NullController
-///////////////////////
-nglr.NullController = function(view) {this.view = view;};
-nglr.NullController.prototype.updateModel = function() { return true; };
-nglr.NullController.prototype.updateView = function() { };
-nglr.NullController.instance = new nglr.NullController();
-
-
-///////////////////////
-// ButtonController
-///////////////////////
-nglr.ButtonController = function(view) {this.view = view;};
-nglr.ButtonController.prototype.updateModel = function(scope) { return true; };
-nglr.ButtonController.prototype.updateView = function(scope) {};
-
-///////////////////////
-// TextController
-///////////////////////
-nglr.TextController = function(view, exp) {
- this.view = view;
- this.exp = exp;
- this.validator = view.getAttribute('ng-validate');
- this.required = typeof view.attributes['ng-required'] != "undefined";
- this.lastErrorText = null;
- this.lastValue = undefined;
- this.initialValue = view.value;
- var widget = view.getAttribute('ng-widget');
- if (widget === 'datepicker') {
- jQuery(view).datepicker();
- }
-};
-
-nglr.TextController.prototype.updateModel = function(scope) {
- var value = this.view.value;
- if (this.lastValue === value) {
- return false;
- } else {
- scope.set(this.exp, value);
- this.lastValue = value;
- return true;
- }
-};
-
-nglr.TextController.prototype.updateView = function(scope) {
- var view = this.view;
- var value = scope.get(this.exp);
- if (typeof value === "undefined") {
- value = this.initialValue;
- scope.set(this.exp, value);
- }
- value = value ? value : '';
- if (this.lastValue != value) {
- view.value = value;
- this.lastValue = value;
- }
- var isValidationError = false;
- view.removeAttribute('ng-error');
- if (this.required) {
- isValidationError = !(value && value.length > 0);
- }
- var errorText = isValidationError ? "Required Value" : null;
- if (!isValidationError && this.validator && value) {
- errorText = scope.validate(this.validator, value);
- isValidationError = !!errorText;
- }
- if (this.lastErrorText !== errorText) {
- this.lastErrorText = isValidationError;
- if (errorText !== null) {
- view.setAttribute('ng-error', errorText);
- scope.markInvalid(this);
- }
- jQuery(view).toggleClass('ng-validation-error', isValidationError);
- }
-};
-
-///////////////////////
-// CheckboxController
-///////////////////////
-nglr.CheckboxController = function(view, exp) {
- this.view = view;
- this.exp = exp;
- this.lastValue = undefined;
- this.initialValue = view.checked ? view.value : "";
-};
-
-nglr.CheckboxController.prototype.updateModel = function(scope) {
- var input = this.view;
- var value = input.checked ? input.value : '';
- if (this.lastValue === value) {
- return false;
- } else {
- scope.setEval(this.exp, value);
- this.lastValue = value;
- return true;
- }
-};
-
-nglr.CheckboxController.prototype.updateView = function(scope) {
- var input = this.view;
- var value = scope.eval(this.exp);
- if (typeof value === "undefined") {
- value = this.initialValue;
- scope.setEval(this.exp, value);
- }
- input.checked = input.value == (''+value);
-};
-
-///////////////////////
-// SelectController
-///////////////////////
-nglr.SelectController = function(view, exp) {
- this.view = view;
- this.exp = exp;
- this.lastValue = undefined;
- this.initialValue = view.value;
-};
-
-nglr.SelectController.prototype.updateModel = function(scope) {
- var input = this.view;
- if (input.selectedIndex < 0) {
- scope.set(this.exp, null);
- } else {
- var value = this.view.value;
- if (this.lastValue === value) {
- return false;
- } else {
- scope.set(this.exp, value);
- this.lastValue = value;
- return true;
- }
- }
-};
-
-nglr.SelectController.prototype.updateView = function(scope) {
- var input = this.view;
- var value = scope.get(this.exp);
- if (typeof value === 'undefined') {
- value = this.initialValue;
- scope.set(this.exp, value);
- }
- if (value !== this.lastValue) {
- input.value = value ? value : "";
- this.lastValue = value;
- }
-};
-
-///////////////////////
-// MultiSelectController
-///////////////////////
-nglr.MultiSelectController = function(view, exp) {
- this.view = view;
- this.exp = exp;
- this.lastValue = undefined;
- this.initialValue = this.selected();
-};
-
-nglr.MultiSelectController.prototype.selected = function () {
- var value = [];
- var options = this.view.options;
- for ( var i = 0; i < options.length; i++) {
- var option = options[i];
- if (option.selected) {
- value.push(option.value);
- }
- }
- return value;
-};
-
-nglr.MultiSelectController.prototype.updateModel = function(scope) {
- var value = this.selected();
- // TODO: This is wrong! no caching going on here as we are always comparing arrays
- if (this.lastValue === value) {
- return false;
- } else {
- scope.set(this.exp, value);
- this.lastValue = value;
- return true;
- }
-};
-
-nglr.MultiSelectController.prototype.updateView = function(scope) {
- var input = this.view;
- var selected = scope.get(this.exp);
- if (typeof selected === "undefined") {
- selected = this.initialValue;
- scope.set(this.exp, selected);
- }
- if (selected !== this.lastValue) {
- var options = input.options;
- for ( var i = 0; i < options.length; i++) {
- var option = options[i];
- option.selected = selected.contains(option.value);
- }
- this.lastValue = selected;
- }
-};
-
-///////////////////////
-// RadioController
-///////////////////////
-nglr.RadioController = function(view, exp) {
- this.view = view;
- this.exp = exp;
- this.lastChecked = undefined;
- this.lastValue = undefined;
- this.inputValue = view.value;
- this.initialValue = view.checked ? view.value : null;
-};
-
-nglr.RadioController.prototype.updateModel = function(scope) {
- var input = this.view;
- if (this.lastChecked) {
- return false;
- } else {
- input.checked = true;
- this.lastValue = scope.set(this.exp, this.inputValue);
- this.lastChecked = true;
- return true;
- }
-};
-
-nglr.RadioController.prototype.updateView = function(scope) {
- var input = this.view;
- var value = scope.get(this.exp);
- if (this.initialValue && typeof value === "undefined") {
- value = this.initialValue;
- scope.set(this.exp, value);
- }
- if (this.lastValue != value) {
- this.lastChecked = input.checked = this.inputValue == (''+value);
- this.lastValue = value;
- }
-};
-
-///////////////////////
-//ElementController
-///////////////////////
-nglr.BindUpdater = function(view, exp) {
- this.view = view;
- this.exp = exp.parseBindings();
- this.hasError = false;
- this.scopeSelf = {element:view};
-};
-
-nglr.BindUpdater.toText = function(obj) {
- var e = nglr.escapeHtml;
- switch(typeof obj) {
- case "string":
- case "boolean":
- case "number":
- return e(obj);
- case "function":
- return nglr.BindUpdater.toText(obj());
- case "object":
- if (nglr.isNode(obj)) {
- return nglr.outerHTML(obj);
- } else if (obj && obj.TAG === filters.Meta.TAG) {
- switch(typeof obj.html) {
- case "string":
- case "number":
- return obj.html;
- case "function":
- return obj.html();
- default:
- break;
- }
- switch(typeof obj.text) {
- case "string":
- case "number":
- return e(obj.text);
- case "function":
- return e(obj.text());
- default:
- break;
- }
- }
- if (obj === null)
- return "";
- return e(nglr.toJson(obj, true));
- default:
- return "";
- }
-};
-
-nglr.BindUpdater.prototype.updateModel = function(scope) {};
-nglr.BindUpdater.prototype.updateView = function(scope) {
- var html = [];
- var parts = this.exp;
- var length = parts.length;
- for(var i=0; i<length; i++) {
- var part = parts[i];
- var binding = part.binding();
- if (binding) {
- scope.evalWidget(this, binding, this.scopeSelf, function(value){
- html.push(nglr.BindUpdater.toText(value));
- }, function(e, text){
- nglr.setHtml(this.view, text);
- });
- if (this.hasError) {
- return;
- }
- } else {
- html.push(nglr.escapeHtml(part));
- }
- }
- nglr.setHtml(this.view, html.join(''));
-};
-
-nglr.BindAttrUpdater = function(view, attrs) {
- this.view = view;
- this.attrs = attrs;
-};
-
-nglr.BindAttrUpdater.prototype.updateModel = function(scope) {};
-nglr.BindAttrUpdater.prototype.updateView = function(scope) {
- var jNode = jQuery(this.view);
- var attributeTemplates = this.attrs;
- if (this.hasError) {
- this.hasError = false;
- jNode.
- removeClass('ng-exception').
- removeAttr('ng-error');
- }
- var isImage = jNode.is('img');
- for (var attrName in attributeTemplates) {
- var attributeTemplate = attributeTemplates[attrName].parseBindings();
- var attrValues = [];
- for ( var i = 0; i < attributeTemplate.length; i++) {
- var binding = attributeTemplate[i].binding();
- if (binding) {
- try {
- var value = scope.eval(binding, {element:jNode[0], attrName:attrName});
- if (value && (value.constructor !== nglr.array || value.length !== 0))
- attrValues.push(value);
- } catch (e) {
- this.hasError = true;
- console.error('BindAttrUpdater', e);
- var jsonError = nglr.toJson(e, true);
- attrValues.push('[' + jsonError + ']');
- jNode.
- addClass('ng-exception').
- attr('ng-error', jsonError);
- }
- } else {
- attrValues.push(attributeTemplate[i]);
- }
- }
- var attrValue = attrValues.length ? attrValues.join('') : null;
- if(isImage && attrName == 'src' && !attrValue)
- attrValue = scope.get('config.server') + '/images/blank.gif';
- jNode.attr(attrName, attrValue);
- }
-};
-
-nglr.EvalUpdater = function(view, exp) {
- this.view = view;
- this.exp = exp;
- this.hasError = false;
-};
-nglr.EvalUpdater.prototype.updateModel = function(scope) {};
-nglr.EvalUpdater.prototype.updateView = function(scope) {
- scope.evalWidget(this, this.exp);
-};
-
-nglr.HideUpdater = function(view, exp) { this.view = view; this.exp = exp; };
-nglr.HideUpdater.prototype.updateModel = function(scope) {};
-nglr.HideUpdater.prototype.updateView = function(scope) {
- scope.evalWidget(this, this.exp, {}, function(hideValue){
- var view = jQuery(this.view);
- if (nglr.toBoolean(hideValue)) {
- view.hide();
- } else {
- view.show();
- }
- });
-};
-
-nglr.ShowUpdater = function(view, exp) { this.view = view; this.exp = exp; };
-nglr.ShowUpdater.prototype.updateModel = function(scope) {};
-nglr.ShowUpdater.prototype.updateView = function(scope) {
- scope.evalWidget(this, this.exp, {}, function(hideValue){
- var view = jQuery(this.view);
- if (nglr.toBoolean(hideValue)) {
- view.show();
- } else {
- view.hide();
- }
- });
-};
-
-nglr.ClassUpdater = function(view, exp) { this.view = view; this.exp = exp; };
-nglr.ClassUpdater.prototype.updateModel = function(scope) {};
-nglr.ClassUpdater.prototype.updateView = function(scope) {
- scope.evalWidget(this, this.exp, {}, function(classValue){
- if (classValue !== null && classValue !== undefined) {
- this.view.className = classValue;
- }
- });
-};
-
-nglr.ClassEvenUpdater = function(view, exp) { this.view = view; this.exp = exp; };
-nglr.ClassEvenUpdater.prototype.updateModel = function(scope) {};
-nglr.ClassEvenUpdater.prototype.updateView = function(scope) {
- scope.evalWidget(this, this.exp, {}, function(classValue){
- var index = scope.get('$index');
- jQuery(this.view).toggleClass(classValue, index % 2 === 1);
- });
-};
-
-nglr.ClassOddUpdater = function(view, exp) { this.view = view; this.exp = exp; };
-nglr.ClassOddUpdater.prototype.updateModel = function(scope) {};
-nglr.ClassOddUpdater.prototype.updateView = function(scope) {
- scope.evalWidget(this, this.exp, {}, function(classValue){
- var index = scope.get('$index');
- jQuery(this.view).toggleClass(classValue, index % 2 === 0);
- });
-};
-
-nglr.StyleUpdater = function(view, exp) { this.view = view; this.exp = exp; };
-nglr.StyleUpdater.prototype.updateModel = function(scope) {};
-nglr.StyleUpdater.prototype.updateView = function(scope) {
- scope.evalWidget(this, this.exp, {}, function(styleValue){
- jQuery(this.view).attr('style', "").css(styleValue);
- });
-};
-
-///////////////////////
-// RepeaterUpdater
-///////////////////////
-nglr.RepeaterUpdater = function(view, repeaterExpression, template, prefix) {
- this.view = view;
- this.template = template;
- this.prefix = prefix;
- this.children = [];
- var match = repeaterExpression.match(/^\s*(.+)\s+in\s+(.*)\s*$/);
- if (! match) {
- throw "Expected ng-repeat in form of 'item in collection' but got '" + repeaterExpression + "'.";
- }
- this.itemExp = match[1];
- this.iteratorExp = match[2];
-};
-
-nglr.RepeaterUpdater.prototype.updateModel = function(scope) {};
-nglr.RepeaterUpdater.prototype.updateView = function(scope) {
- scope.evalWidget(this, this.iteratorExp, {}, function(iterator){
- if (!iterator) {
- iterator = [];
- if (scope.isProperty(this.iteratorExp)) {
- scope.set(this.iteratorExp, iterator);
- }
- }
- var iteratorLength = iterator.length;
- var childrenLength = this.children.length;
- var cursor = this.view;
- var time = 0;
- var child = null;
- var itemExp = this.itemExp;
- for ( var i = 0; i < iteratorLength; i++) {
- if (i < iteratorLength) {
- if (i < childrenLength) { // reuse children
- child = this.children[i];
- child.scope.set(itemExp, iterator[i]);
- } else { // grow children
- var name = this.prefix +
- itemExp + " in " + this.iteratorExp + "[" + i + "]";
- var childScope = new nglr.Scope(scope.state, name);
- childScope.set('$index', i);
- childScope.set(itemExp, iterator[i]);
- child = { scope:childScope, element:this.template(childScope, this.prefix, i) };
- cursor.after(child.element);
- this.children.push(child);
- }
- cursor = child.element;
- var s = new Date().getTime();
- child.scope.updateView();
- time += new Date().getTime() - s;
- }
- }
- // shrink children
- for ( var r = childrenLength; r > iteratorLength; --r) {
- var unneeded = this.children.pop();
- unneeded.element.removeNode();
- }
- // Special case for option in select
- if (child && child.element[0].nodeName === "OPTION") {
- var select = jQuery(child.element[0].parentNode);
- var cntl = select.data('controller');
- if (cntl) {
- cntl.lastValue = undefined;
- cntl.updateView(scope);
- }
- }
- });
-};
-
-//////////////////////////////////
-// PopUp
-//////////////////////////////////
-
-nglr.PopUp = function(doc) {
- this.doc = doc;
-};
-
-nglr.PopUp.OUT_EVENT = "mouseleave mouseout click dblclick keypress keyup";
-
-nglr.PopUp.prototype.bind = function () {
- var self = this;
- this.doc.find('.ng-validation-error,.ng-exception').
- live("mouseover", nglr.PopUp.onOver);
-};
-
-nglr.PopUp.onOver = function(e) {
- nglr.PopUp.onOut();
- var jNode = jQuery(this);
- jNode.bind(nglr.PopUp.OUT_EVENT, nglr.PopUp.onOut);
- var position = jNode.position();
- var de = document.documentElement;
- var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
- var hasArea = w - position.left;
- var width = 300;
- var title = jNode.hasClass("ng-exception") ? "EXCEPTION:" : "Validation error...";
- var msg = jNode.attr("ng-error");
-
- var x;
- var arrowPos = hasArea>(width+75) ? "left" : "right";
- var tip = jQuery(
- "<div id='ng-callout' style='width:"+width+"px'>" +
- "<div class='ng-arrow-"+arrowPos+"'/>" +
- "<div class='ng-title'>"+title+"</div>" +
- "<div class='ng-content'>"+msg+"</div>" +
- "</div>");
- jQuery("body").append(tip);
- if(arrowPos === 'left'){
- x = position.left + this.offsetWidth + 11;
- }else{
- x = position.left - (width + 15);
- tip.find('.ng-arrow-right').css({left:width+1});
- }
-
- tip.css({left: x+"px", top: (position.top - 3)+"px"});
- return true;
-};
-
-nglr.PopUp.onOut = function() {
- jQuery('#ng-callout').
- unbind(nglr.PopUp.OUT_EVENT, nglr.PopUp.onOut).
- remove();
- return true;
-};
-
-//////////////////////////////////
-// Status
-//////////////////////////////////
-
-nglr.Status = function (body) {
- this.body = body;
- this.requestCount = 0;
-};
-nglr.Status.ANGULAR = "&lt;a class='ng-angular-logo' href='http://www.getangular.com'&gt;&amp;lt;angular/&amp;gt;&lt;/a&gt;&trade;";
-
-nglr.Status.prototype.beginRequest = function () {
- if (this.requestCount === 0) {
-<<<<<<< HEAD:public/javascripts/nglr/Widgets.js
- this.dialogView = jQuery('<div class="ng-dialog" title="'+nglr.ControlBar.ANGULAR+' Server Communication:">Please Wait...<div/><div class="loader"></div></div>');
-=======
- this.dialogView = jQuery('<div title="'+nglr.Status.ANGULAR+' Server Communication:">Please Wait...<div/></div>');
- this.progressWidget = this.dialogView.find("div");
- this.progressWidget.progressbar({value:0});
->>>>>>> master:public/javascripts/nglr/Widgets.js
- this.dialogView.dialog({bgiframe:true, minHeight:50, modal:true});
- this.maxRequestCount = 0;
- }
- this.requestCount++;
- this.maxRequestCount++;
-};
-
-nglr.Status.prototype.endRequest = function () {
- this.requestCount--;
- if (this.requestCount === 0) {
- this.dialogView.dialog("destroy");
- this.dialogView.remove();
- this.dialogView = null;
- }
-};
diff --git a/src/XSitePost.js b/src/XSitePost.js
deleted file mode 100644
index 7d81e207..00000000
--- a/src/XSitePost.js
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright (C) 2008,2009 BRAT Tech LLC
-
-if (typeof nglr == 'undefined') nglr = {};
-
-if (typeof console == 'undefined') console = {};
-if (typeof console.log == 'undefined')
- console.log = function() {};
-if (typeof console.error == 'undefined')
- console.error = function() {};
-
-nglr.XSitePost = function(baseUrl, window, prefix) {
- this.baseUrl = baseUrl;
- this.post = jQuery.post;
- this.window = window;
- this.inQueue = {};
- this.outQueue = [];
- this.maxMsgSize = 100000;
- this.delay = 20;
- this.prefix = prefix;
- this.setTimeout=function(fn, delay){window.setTimeout(fn, delay);};
-};
-
-nglr.XSitePost.prototype.init = function() {
- this.window.name = '';
- this.response('ready', 'null');
-};
-
-nglr.XSitePost.prototype.incomingFragment = function(fragment) {
- var parts = fragment.split(";");
- this.incomingMsg(parts.shift(), 1*parts.shift(), 1*parts.shift(), parts.shift());
-};
-
-nglr.XSitePost.prototype.incomingMsg = function(id, partNo, totalParts, msgPart) {
- var msg = this.inQueue[id];
- if (!msg) {
- msg = {id:id, parts:[], count:0};
- this.inQueue[id] = msg;
- }
- msg.parts[partNo] = msgPart;
- msg.count++;
- if (totalParts === msg.count) {
- delete this.inQueue[id];
- var request = this.decodePost(msg.parts.join(''));
- var self = this;
- this.post(this.baseUrl + request.url, request.params, function(response, status){
- self.response(id, response, status);
- });
- }
-};
-
-nglr.XSitePost.prototype.response = function(id, response, status) {
- var start = 0;
- var end;
- var msg = Base64.encode(response);
- var msgLen = msg.length;
- var total = Math.ceil(msgLen / this.maxMsgSize);
- var part = 0;
- while (start < msgLen) {
- end = Math.min(msgLen, start + this.maxMsgSize);
- this.outQueue.push(id + ':'+part+':'+total+':' + msg.substring(start, end));
- start = end;
- part++;
- }
-};
-
-nglr.XSitePost.prototype.decodePost = function(post) {
- var parts = post.split(':');
- var url = Base64.decode(parts.shift());
- var params = {};
- while(parts.length !== 0) {
- var key = parts.shift();
- var value = Base64.decode(parts.shift());
- params[key] = value;
- }
- return {url:url, params:params};
-};
-
-nglr.XSitePost.prototype.listen = function() {
- console.log("listen()");
- var self = this;
- var window = this.window;
- var outQueue = this.outQueue;
- var setTimeout = this.setTimeout;
- var prefix = this.prefix;
- var prefixLen = prefix.length;
- var prefixRec = prefix + '>';
- var prefixRecLen = prefixRec.length;
- window.name = prefix;
- var pull = function(){
- var value = window.name;
- if (value == prefix && outQueue.length > 0) {
- window.name = prefix + '<' + outQueue.shift();
- } else if (value.substr(0, prefixRecLen) == prefixRec) {
- self.incomingFragment(value.substr(prefixRecLen));
- window.name = prefix;
- }
- setTimeout(pull, self.delay);
- };
- pull();
-};
diff --git a/src/angular-bootstrap.js b/src/angular-bootstrap.js
index 8ac4f9f3..b13bbf34 100644
--- a/src/angular-bootstrap.js
+++ b/src/angular-bootstrap.js
@@ -80,9 +80,8 @@
doc = window.document.getElementById(id);
}
}
- var angular = window.angularFactory(scriptConfig);
if (scriptConfig.autoBind && doc) {
- window.angularScope = angular.compile(doc);
+ window.angularScope = angular.compile(doc, scriptConfig);
}
if (typeof previousOnLoad === 'function') {
try {
diff --git a/src/angular.prefix b/src/angular.prefix
new file mode 100644
index 00000000..522c17bf
--- /dev/null
+++ b/src/angular.prefix
@@ -0,0 +1,2 @@
+
+(function(window, document){ \ No newline at end of file
diff --git a/src/angular.suffix b/src/angular.suffix
new file mode 100644
index 00000000..4b3cc37b
--- /dev/null
+++ b/src/angular.suffix
@@ -0,0 +1 @@
+})(window, document); \ No newline at end of file
diff --git a/src/test/Runner.js b/src/test/Runner.js
index c7dd431a..5840282e 100644
--- a/src/test/Runner.js
+++ b/src/test/Runner.js
@@ -1,11 +1,11 @@
-if (!nglr.test) nglr.test = {};
+if (typeof test == 'undefined') test = {};
-nglr.test.ScenarioRunner = function(scenarios, body) {
+test.ScenarioRunner = function(scenarios, body) {
this.scenarios = scenarios;
this.body = body;
};
-nglr.test.ScenarioRunner.prototype = {
+test.ScenarioRunner.prototype = {
run:function(){
this.setUpUI();
this.runScenarios();
@@ -25,22 +25,22 @@ nglr.test.ScenarioRunner.prototype = {
});
},
runScenarios:function(){
- var runner = new nglr.test.Runner(this.console, this.testFrame);
+ var runner = new test.Runner(this.console, this.testFrame);
_.stepper(this.scenarios, function(next, scenario, name){
- new nglr.test.Scenario(name, scenario).run(runner, next);
+ new test.Scenario(name, scenario).run(runner, next);
}, function(){
}
);
}
};
-nglr.test.Runner = function(console, frame){
+test.Runner = function(console, frame){
this.console = console;
this.current = null;
this.tests = [];
this.frame = frame;
};
-nglr.test.Runner.prototype = {
+test.Runner.prototype = {
start:function(name){
var current = this.current = {
name:name,
@@ -75,7 +75,7 @@ nglr.test.Runner.prototype = {
var buf = [];
for ( var i = 1; i < arguments.length; i++) {
var arg = arguments[i];
- buf.push(typeof arg == "string" ?arg:nglr.toJson(arg));
+ buf.push(typeof arg == "string" ?arg:toJson(arg));
}
var log = jQuery('<div class="' + level + '"></div>');
log.text(buf.join(" "));
@@ -86,11 +86,11 @@ nglr.test.Runner.prototype = {
}
};
-nglr.test.Scenario = function(name, scenario){
+test.Scenario = function(name, scenario){
this.name = name;
this.scenario = scenario;
};
-nglr.test.Scenario.prototype = {
+test.Scenario.prototype = {
run:function(runner, callback) {
var self = this;
_.stepper(this.scenario, function(next, steps, name){
@@ -115,7 +115,7 @@ nglr.test.Scenario.prototype = {
else if (step.When) fn = angular.test.WHEN[step.When];
else if (step.Then) fn = angular.test.THEN[step.Then];
return fn || function (){
- throw "ERROR: Need Given/When/Then got: " + nglr.toJson(step);
+ throw "ERROR: Need Given/When/Then got: " + toJson(step);
};
},
context: function(runner) {
@@ -149,14 +149,14 @@ nglr.test.Scenario.prototype = {
callback();
return;
}
- runner.log("info", nglr.toJson(step));
+ runner.log("info", toJson(step));
var fn = this.verb(step);
var context = this.context(runner);
_.extend(context, step);
try {
(fn.call(context)||function(c){c();})(callback);
} catch (e) {
- runner.log("error", "ERROR: " + nglr.toJson(e));
+ runner.log("error", "ERROR: " + toJson(e));
}
}
};
diff --git a/src/test/Steps.js b/src/test/Steps.js
index af4b84d6..cc9ff549 100644
--- a/src/test/Steps.js
+++ b/src/test/Steps.js
@@ -14,7 +14,7 @@ angular.test.GIVEN = {
};
},
dataset:function(){
- this.frame.name="$DATASET:" + nglr.toJson({dataset:this.dataset});
+ this.frame.name="$DATASET:" + toJson({dataset:this.dataset});
}
};
angular.test.WHEN = {