checkpoint for integration with angular
2
Rakefile
@@ -34,7 +34,7 @@ task :compile do
|
||||
concat = %x(cat \
|
||||
src/angular.prefix \
|
||||
lib/webtoolkit/webtoolkit.base64.js \
|
||||
src/Loader.js \
|
||||
src/Angular.js \
|
||||
src/API.js \
|
||||
src/Binder.js \
|
||||
src/ControlBar.js \
|
||||
|
||||
@@ -63,8 +63,8 @@ div.ui-widget {
|
||||
background-repeat: no-repeat;
|
||||
background-position: right;
|
||||
}
|
||||
.ng-ascend { background-image: url(images/arrow_ascend.png); }
|
||||
.ng-descend { background-image: url(images/arrow_descend.png); }
|
||||
.ng-ascend { background-image: url(angular_images/arrow_ascend.png); }
|
||||
.ng-descend { background-image: url(angular_images/arrow_descend.png); }
|
||||
|
||||
/*****************
|
||||
* TIP
|
||||
@@ -83,7 +83,7 @@ div.ui-widget {
|
||||
}
|
||||
|
||||
#ng-callout .ng-arrow-left{
|
||||
background-image: url(images/arrow_left.gif);
|
||||
background-image: url(angular_images/arrow_left.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: left top;
|
||||
position: absolute;
|
||||
@@ -95,7 +95,7 @@ div.ui-widget {
|
||||
}
|
||||
|
||||
#ng-callout .ng-arrow-right{
|
||||
background-image: url(images/arrow_right.gif);
|
||||
background-image: url(angular_images/arrow_right.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: left top;
|
||||
position: absolute;
|
||||
|
||||
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 102 B |
|
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 102 B |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
@@ -5,7 +5,7 @@ load:
|
||||
- lib/jquery/jquery-1.3.2.js
|
||||
- lib/jquery/jquery-ui-1.7.1.custom.min.js
|
||||
- lib/underscore/underscore.js
|
||||
- src/Loader.js
|
||||
- src/Angular.js
|
||||
- src/*.js
|
||||
- src/test/_namespace.js
|
||||
- src/test/*.js
|
||||
@@ -14,7 +14,5 @@ load:
|
||||
- test/*.js
|
||||
|
||||
exclude:
|
||||
- src/angular-bootstrap.js
|
||||
- src/angular.prefix
|
||||
- src/angular.suffix
|
||||
|
||||
96
lib/jasmine-jstd-adapter/JasmineAdapter.js
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @fileoverview Jasmine JsTestDriver Adapter.
|
||||
* @author ibolmo@gmail.com (Olmo Maldonado)
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
// Suite/TestCase before and after function stacks.
|
||||
var before = [];
|
||||
var after = [];
|
||||
|
||||
jasmine.Env.prototype.describe = (function(describe){
|
||||
|
||||
// TODO(ibolmo): Support nested describes.
|
||||
return function(description, specDefinitions){
|
||||
this.currentTestCase = TestCase(description);
|
||||
return describe.call(this, description, specDefinitions);
|
||||
};
|
||||
|
||||
})(jasmine.Env.prototype.describe);
|
||||
|
||||
|
||||
jasmine.Env.prototype.it = (function(it){
|
||||
|
||||
return function(desc, func){
|
||||
var spec = it.call(this, desc, func);
|
||||
this.currentTestCase.prototype['test that it ' + desc] = func;
|
||||
return spec;
|
||||
};
|
||||
|
||||
})(jasmine.Env.prototype.it);
|
||||
|
||||
|
||||
jasmine.Env.prototype.beforeEach = (function(beforeEach){
|
||||
|
||||
// TODO(ibolmo): Support beforeEach TestCase.
|
||||
return function(beforeEachFunction) {
|
||||
beforeEach.call(this, beforeEachFunction);
|
||||
if (this.currentTestCase) {
|
||||
this.currentTestCase.prototype.setUp = beforeEachFunction;
|
||||
} else {
|
||||
before.push(beforeEachFunction);
|
||||
}
|
||||
};
|
||||
|
||||
})(jasmine.Env.prototype.beforeEach);
|
||||
|
||||
|
||||
jasmine.Env.prototype.afterEach = (function(afterEach){
|
||||
|
||||
// TODO(ibolmo): Support afterEach TestCase.
|
||||
return function(afterEachFunction) {
|
||||
afterEach.call(this, afterEachFunction);
|
||||
if (this.currentTestCase) {
|
||||
this.currentTestCase.prototype.tearDown = afterEachFunction;
|
||||
} else {
|
||||
after.push(afterEachFunction);
|
||||
}
|
||||
};
|
||||
|
||||
})(jasmine.Env.prototype.afterEach);
|
||||
|
||||
|
||||
jasmine.NestedResults.prototype.addResult = (function(addResult){
|
||||
|
||||
return function(result) {
|
||||
addResult.call(this, result);
|
||||
if (result.type != 'MessageResult' && !result.passed()) fail(result.message);
|
||||
};
|
||||
|
||||
})(jasmine.NestedResults.prototype.addResult);
|
||||
|
||||
|
||||
jstestdriver.plugins.TestRunnerPlugin.prototype.runTestConfiguration = (function(runTestConfiguration){
|
||||
|
||||
return function(testRunConfiguration, onTestDone, onTestRunConfigurationComplete){
|
||||
for (var i = 0, l = before.length; i < l; i++) before[i]();
|
||||
onTestRunConfigurationComplete = (function(configurationComplete){
|
||||
|
||||
return function() {
|
||||
for (var i = 0, l = after.length; i < l; i++) after[i]();
|
||||
configurationComplete();
|
||||
};
|
||||
|
||||
})(onTestRunConfigurationComplete);
|
||||
runTestConfiguration.call(this, testRunConfiguration, onTestDone, onTestRunConfigurationComplete);
|
||||
};
|
||||
|
||||
})(jstestdriver.plugins.TestRunnerPlugin.prototype.runTestConfiguration);
|
||||
|
||||
|
||||
// Reset environment with overriden methods.
|
||||
jasmine.currentEnv_ = null;
|
||||
jasmine.getEnv();
|
||||
|
||||
})();
|
||||
2261
lib/jasmine/jasmine-0.10.0.js
Normal file
@@ -177,17 +177,17 @@ function merge(src, dst) {
|
||||
}
|
||||
|
||||
// ////////////////////////////
|
||||
// Loader
|
||||
// Angular
|
||||
// ////////////////////////////
|
||||
|
||||
function Loader(document, head, config) {
|
||||
function Angular(document, head, config) {
|
||||
this.document = jQuery(document);
|
||||
this.head = jQuery(head);
|
||||
this.config = config;
|
||||
this.location = window.location;
|
||||
}
|
||||
|
||||
Loader.prototype = {
|
||||
Angular.prototype = {
|
||||
load: function() {
|
||||
this.configureLogging();
|
||||
log("Server: " + this.config.server);
|
||||
@@ -197,7 +197,7 @@ Loader.prototype = {
|
||||
},
|
||||
|
||||
configureJQueryPlugins: function() {
|
||||
log('Loader.configureJQueryPlugins()');
|
||||
log('Angular.configureJQueryPlugins()');
|
||||
jQuery['fn']['scope'] = function() {
|
||||
var element = this;
|
||||
while (element && element.get(0)) {
|
||||
@@ -226,7 +226,7 @@ Loader.prototype = {
|
||||
},
|
||||
|
||||
bindHtml: function() {
|
||||
log('Loader.bindHtml()');
|
||||
log('Angular.bindHtml()');
|
||||
var watcher = new UrlWatcher(this.location);
|
||||
var document = this.document;
|
||||
var widgetFactory = new WidgetFactory(this.config.server, this.config.database);
|
||||
@@ -333,16 +333,6 @@ Loader.prototype = {
|
||||
consoleLog('ng-console-error', arguments);
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
loadCss: function(css) {
|
||||
var cssTag = document.createElement('link');
|
||||
cssTag.rel = "stylesheet";
|
||||
cssTag.type = "text/css";
|
||||
if (!css.match(/^http:/))
|
||||
css = this.config.server + css;
|
||||
cssTag.href = css;
|
||||
this.head[0].appendChild(cssTag);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -408,11 +398,11 @@ angular['compile'] = function(root, config) {
|
||||
'addUrlChangeListener': noop
|
||||
};
|
||||
//todo: don't start watcher
|
||||
var loader = new Loader(root, jQuery("head"), _(defaults).extend(config));
|
||||
var angular = new Angular(root, jQuery("head"), _(defaults).extend(config));
|
||||
//todo: don't load stylesheet by default
|
||||
// loader.loadCss('/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css');
|
||||
// loader.loadCss('/stylesheets/css');
|
||||
loader.load();
|
||||
angular.load();
|
||||
var scope = jQuery(root).scope();
|
||||
//TODO: cleanup
|
||||
return {
|
||||
115
src/angular-bootstrap.js
vendored
@@ -1,115 +0,0 @@
|
||||
/**
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 Adam Abrons and Misko Hevery http://getangular.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
(function(previousOnLoad){
|
||||
var filename = /(.*)\/angular-(.*).js(#(.*))?/;
|
||||
var scripts = document.getElementsByTagName("script");
|
||||
var scriptConfig = {
|
||||
autoSubmit:true,
|
||||
autoBind:true,
|
||||
autoLoadDependencies:false
|
||||
};
|
||||
for(var j = 0; j < scripts.length; j++) {
|
||||
var src = scripts[j].src;
|
||||
if (src && src.match(filename)) {
|
||||
var parts = src.match(filename);
|
||||
if (parts[2] == 'bootstrap') {
|
||||
scriptConfig.autoLoadDependencies = true;
|
||||
}
|
||||
scriptConfig.server = parts[1] || '';
|
||||
if (!scriptConfig.server) {
|
||||
scriptConfig.server = window.location.toString().split(window.location.pathname)[0];
|
||||
}
|
||||
if (parts[4]) {
|
||||
var directive = parts[4].split('&');
|
||||
for ( var i = 0; i < directive.length; i++) {
|
||||
var keyValue = directive[i].split('=');
|
||||
var key = keyValue[0];
|
||||
var value = keyValue.length == 1 ? true : keyValue[1];
|
||||
if (value == 'false') value = false;
|
||||
if (value == 'true') value = true;
|
||||
scriptConfig[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var addScript = function(path, server){
|
||||
server = server || scriptConfig.server;
|
||||
document.write('<script type="text/javascript" src="' + server + path +'"></script>');
|
||||
};
|
||||
|
||||
if (scriptConfig.autoLoadDependencies) {
|
||||
addScript("/../lib/webtoolkit/webtoolkit.base64.js");
|
||||
addScript("/../lib/swfobject/swfobject.js");
|
||||
addScript("/../lib/jquery/jquery-1.3.2.js");
|
||||
addScript("/../lib/jquery/jquery-ui-1.7.1.custom.min.js");
|
||||
addScript("/../lib/underscore/underscore.js");
|
||||
addScript("/Loader.js");
|
||||
addScript("/API.js");
|
||||
addScript("/Binder.js");
|
||||
addScript("/ControlBar.js");
|
||||
addScript("/DataStore.js");
|
||||
addScript("/Filters.js");
|
||||
addScript("/JSON.js");
|
||||
addScript("/Model.js");
|
||||
addScript("/Parser.js");
|
||||
addScript("/Scope.js");
|
||||
addScript("/Server.js");
|
||||
addScript("/Users.js");
|
||||
addScript("/Validators.js");
|
||||
addScript("/Widgets.js");
|
||||
} else {
|
||||
addScript("/ajax/libs/swfobject/2.2/swfobject.js", "http://ajax.googleapis.com");
|
||||
addScript("/ajax/libs/jquery/1.3.2/jquery.min.js", "http://ajax.googleapis.com");
|
||||
addScript("/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js", "http://ajax.googleapis.com");
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
var doc = window.document;
|
||||
if (scriptConfig.bindRootId) {
|
||||
doc = null;
|
||||
var ids = scriptConfig.bindRootId.split('|');
|
||||
for ( var i = 0; i < ids.length && !doc; i++) {
|
||||
var idCond = ids[i].split('?');
|
||||
var id = idCond[0];
|
||||
if (idCond.length > 1) {
|
||||
if (!window.document.getElementById(idCond[1])) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
doc = window.document.getElementById(id);
|
||||
}
|
||||
}
|
||||
if (scriptConfig.autoBind && doc) {
|
||||
window.angularScope = angular.compile(doc, scriptConfig);
|
||||
}
|
||||
if (typeof previousOnLoad === 'function') {
|
||||
try {
|
||||
previousOnLoad.apply(this, arguments);
|
||||
} catch (e) {}
|
||||
}
|
||||
};
|
||||
})(window.onload);
|
||||
|
||||
|
||||
@@ -1,25 +1,15 @@
|
||||
LoaderTest = TestCase('LoaderTest');
|
||||
AngularTest = TestCase('AngularTest');
|
||||
|
||||
LoaderTest.prototype.testLoadCss = function(){
|
||||
if ($.browser.safari) return;
|
||||
var head = jQuery('<head/>')[0];
|
||||
var loader = new Loader(document, head, {});
|
||||
var log = '';
|
||||
loader.config.server = 'http://';
|
||||
loader.loadCss('x');
|
||||
assertEquals($(head).find('link').attr('href'), 'http://x');
|
||||
};
|
||||
|
||||
LoaderTest.prototype.testDefaultDatabasePathFromSubdomain = function() {
|
||||
var loader = new Loader(null, null, {server:"http://account.getangular.com", database:"database"});
|
||||
AngularTest.prototype.testDefaultDatabasePathFromSubdomain = function() {
|
||||
var loader = new Angular(null, null, {server:"http://account.getangular.com", database:"database"});
|
||||
loader.computeConfiguration();
|
||||
assertEquals("database", loader.config.database);
|
||||
|
||||
loader = new Loader(null, null, {server:"http://account.getangular.com"});
|
||||
loader = new Angular(null, null, {server:"http://account.getangular.com"});
|
||||
loader.computeConfiguration();
|
||||
assertEquals("account", loader.config.database);
|
||||
|
||||
loader = new Loader(null, null, {server:"https://account.getangular.com"});
|
||||
loader = new Angular(null, null, {server:"https://account.getangular.com"});
|
||||
loader.computeConfiguration();
|
||||
assertEquals("account", loader.config.database);
|
||||
};
|
||||
@@ -96,7 +96,7 @@ function decode64(base64){
|
||||
return fromJson(Base64.decode(base64));
|
||||
}
|
||||
|
||||
Loader.prototype.configureJQueryPlugins();
|
||||
Angular.prototype.configureJQueryPlugins();
|
||||
|
||||
function assertHidden(node) {
|
||||
var display = node.css('display');
|
||||
|
||||