-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(*): set up the project structure and build
This commit adds the initial source code, sets up the project structure, creates the gulp build file and configures karma.
- Loading branch information
1 parent
ef7e89f
commit d36ce30
Showing
34 changed files
with
2,010 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
# 2 space indentation | ||
[**.*] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
jspm_packages | ||
bower_components | ||
.idea | ||
.DS_STORE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
jspm_packages | ||
bower_components | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,69 @@ | ||
templating-resources | ||
==================== | ||
# aurelia-templating-resources | ||
|
||
A standard set of behaviors, converters and other resources for use with the Aurelia templating library. | ||
This library is part of the [Aurelia](http://www.aurelia.io/) platform and contains a standard set of behaviors, converters and other resources for use with the Aurelia templating library. | ||
|
||
> To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.durandal.io/). If you have questions, we invite you to join us on [our Gitter Channel](https://gitter.im/Aurelia/Discuss). | ||
## Dependencies | ||
|
||
* [aurelia-templating](https://github.com/aurelia/templating) | ||
* [aurelia-dependency-injection](https://github.com/aurelia/dependency-injection) | ||
* [aurelia-binding](https://github.com/aurelia/binding) | ||
|
||
## Platform Support | ||
|
||
This library can be used in the **browser** only. | ||
|
||
## Building The Code | ||
|
||
To build the code, follow these steps. | ||
|
||
1. Ensure that [NodeJS](http://nodejs.org/) is installed. This provides the platform on which the build tooling runs. | ||
2. From the project folder, execute the following command: | ||
|
||
```shell | ||
npm install | ||
``` | ||
3. Ensure that [Gulp](http://gulpjs.com/) is installed. If you need to install it, use the following command: | ||
|
||
```shell | ||
npm install -g gulp | ||
``` | ||
4. To build the code, you can now run: | ||
|
||
```shell | ||
gulp build | ||
``` | ||
5. You will find the compiled code in the `dist` folder, available in three module formats: AMD, CommonJS and ES6. | ||
|
||
6. See `gulpfile.js` for other tasks related to generating the docs and linting. | ||
|
||
## Running The Tests | ||
|
||
To run the unit tests, first ensure that you have followed the steps above in order to install all dependencies and successfully build the library. Once you have done that, proceed with these additional steps: | ||
|
||
1. Ensure that the [Karma](http://karma-runner.github.io/) CLI is installed. If you need to install it, use the following command: | ||
|
||
```shell | ||
npm install -g karma-cli | ||
``` | ||
2. Ensure that [jspm](http://jspm.io/) is installed. If you need to install it, use the following commnand: | ||
|
||
```shell | ||
npm install -g jspm | ||
``` | ||
3. Install the client-side dependencies with jspm: | ||
|
||
```shell | ||
jspm install | ||
``` | ||
|
||
4. You can now run the tests with this command: | ||
|
||
```shell | ||
karma start | ||
``` | ||
|
||
## Contributing | ||
|
||
We'd love for you to contribute to our source code and to make this project even better than it is today! If this interests you, please begin by reading [our contributing guidelines](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). The contributing document will provide you with all the information you need to get started. Once you have read that, you will need to also [sign our CLA](http://goo.gl/forms/dI8QDDSyKR) before we can accepts a Pull Request from you. More information on the process is including in the [contributor's guide](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
System.config({ | ||
"paths": { | ||
"*": "*.js", | ||
"github:*": "jspm_packages/github/*.js" | ||
} | ||
}); | ||
|
||
System.config({ | ||
"map": { | ||
"aurelia-binding": "github:aurelia/[email protected]", | ||
"aurelia-dependency-injection": "github:aurelia/[email protected]", | ||
"aurelia-templating": "github:aurelia/[email protected]", | ||
"github:aurelia/[email protected]": { | ||
"aurelia-metadata": "github:aurelia/[email protected]", | ||
"aurelia-task-queue": "github:aurelia/[email protected]" | ||
}, | ||
"github:aurelia/[email protected]": { | ||
"aurelia-metadata": "github:aurelia/[email protected]" | ||
}, | ||
"github:aurelia/[email protected]": { | ||
"aurelia-path": "github:aurelia/[email protected]" | ||
}, | ||
"github:aurelia/[email protected]": { | ||
"aurelia-binding": "github:aurelia/[email protected]", | ||
"aurelia-dependency-injection": "github:aurelia/[email protected]", | ||
"aurelia-loader": "github:aurelia/[email protected]", | ||
"aurelia-logging": "github:aurelia/[email protected]", | ||
"aurelia-metadata": "github:aurelia/[email protected]", | ||
"aurelia-path": "github:aurelia/[email protected]", | ||
"aurelia-task-queue": "github:aurelia/[email protected]" | ||
} | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
define(["exports", "aurelia-dependency-injection", "aurelia-templating"], function (exports, _aureliaDependencyInjection, _aureliaTemplating) { | ||
"use strict"; | ||
|
||
var Container = _aureliaDependencyInjection.Container; | ||
var CustomElement = _aureliaTemplating.CustomElement; | ||
var ResourceCoordinator = _aureliaTemplating.ResourceCoordinator; | ||
var Property = _aureliaTemplating.Property; | ||
var ViewSlot = _aureliaTemplating.ViewSlot; | ||
var NoView = _aureliaTemplating.NoView; | ||
var UseView = _aureliaTemplating.UseView; | ||
var ViewEngine = _aureliaTemplating.ViewEngine; | ||
var Compose = (function () { | ||
var Compose = function Compose(container, resourceCoordinator, viewEngine, viewSlot) { | ||
this.container = container; | ||
this.resourceCoordinator = resourceCoordinator; | ||
this.viewEngine = viewEngine; | ||
this.viewSlot = viewSlot; | ||
}; | ||
|
||
Compose.annotations = function () { | ||
return [new CustomElement("compose"), new Property("model"), new Property("view"), new Property("viewModel"), new NoView()]; | ||
}; | ||
|
||
Compose.inject = function () { | ||
return [Container, ResourceCoordinator, ViewEngine, ViewSlot]; | ||
}; | ||
|
||
Compose.prototype.bind = function (executionContext) { | ||
this.executionContext = executionContext; | ||
processInstruction(this, { | ||
view: this.view, | ||
viewModel: this.viewModel, | ||
model: this.model | ||
}); | ||
}; | ||
|
||
Compose.prototype.modelChanged = function (newValue, oldValue) { | ||
if (this.viewModel && this.viewModel.activate) { | ||
this.viewModel.activate(newValue); | ||
} | ||
}; | ||
|
||
Compose.prototype.viewChanged = function (newValue, oldValue) { | ||
processInstruction(this, { view: newValue }); | ||
}; | ||
|
||
Compose.prototype.viewModelChanged = function (newValue, oldValue) { | ||
processInstruction(this, { viewModel: newValue }); | ||
}; | ||
|
||
return Compose; | ||
})(); | ||
|
||
exports.Compose = Compose; | ||
|
||
|
||
function swap(composer, behavior) { | ||
behavior.bind(behavior.executionContext); | ||
composer.viewSlot.swap(behavior.view); | ||
|
||
if (composer.current) { | ||
composer.current.unbind(); | ||
} | ||
|
||
composer.current = behavior; | ||
} | ||
|
||
function processBehavior(composer, instruction, behavior) { | ||
if (instruction.model && "activate" in instruction.viewModel) { | ||
var activated = instruction.viewModel.activate(instruction.model) || Promise.resolve(); | ||
activated.then(function () { | ||
return swap(composer, behavior); | ||
}); | ||
} else { | ||
swap(composer, behavior); | ||
} | ||
} | ||
|
||
function processInstruction(composer, instruction) { | ||
var useView, result, options, childContainer; | ||
|
||
if (typeof instruction.viewModel == "string") { | ||
composer.resourceCoordinator.loadAnonymousElement(composer.viewModel, null, instruction.view).then(function (type) { | ||
childContainer = composer.container.createChild(); | ||
options = { suppressBind: true }; | ||
result = type.create(childContainer, options); | ||
instruction.viewModel = result.executionContext; | ||
processBehavior(composer, instruction, result); | ||
}); | ||
} else { | ||
if (instruction.view) { | ||
useView = new UseView(instruction.view); | ||
} | ||
|
||
if (instruction.viewModel) { | ||
CustomElement.anonymous(composer.container, instruction.viewModel, useView).then(function (type) { | ||
childContainer = composer.container.createChild(); | ||
options = { executionContext: instruction.viewModel, suppressBind: true }; | ||
result = type.create(childContainer, options); | ||
processBehavior(composer, instruction, result); | ||
}); | ||
} else if (useView) { | ||
useView.loadViewFactory(composer.viewEngine).then(function (viewFactory) { | ||
childContainer = composer.container.createChild(); | ||
result = viewFactory.create(childContainer, composer.executionContext); | ||
composer.viewSlot.swap(result); | ||
}); | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
define(["exports", "aurelia-templating"], function (exports, _aureliaTemplating) { | ||
"use strict"; | ||
|
||
var TemplateController = _aureliaTemplating.TemplateController; | ||
var Property = _aureliaTemplating.Property; | ||
var BoundViewFactory = _aureliaTemplating.BoundViewFactory; | ||
var ViewSlot = _aureliaTemplating.ViewSlot; | ||
var If = (function () { | ||
var If = function If(viewFactory, viewSlot) { | ||
this.viewFactory = viewFactory; | ||
this.viewSlot = viewSlot; | ||
this.showing = false; | ||
}; | ||
|
||
If.annotations = function () { | ||
return [new TemplateController("if"), new Property("value", "valueChanged", "if")]; | ||
}; | ||
|
||
If.inject = function () { | ||
return [BoundViewFactory, ViewSlot]; | ||
}; | ||
|
||
If.prototype.valueChanged = function (newValue) { | ||
if (!newValue) { | ||
if (this.view) { | ||
this.viewSlot.remove(this.view); | ||
this.view.unbind(); | ||
} | ||
|
||
this.showing = false; | ||
return; | ||
} | ||
|
||
if (!this.view) { | ||
this.view = this.viewFactory.create(); | ||
} | ||
|
||
if (!this.showing) { | ||
this.showing = true; | ||
|
||
if (!this.view.bound) { | ||
this.view.bind(); | ||
} | ||
|
||
this.viewSlot.add(this.view); | ||
} | ||
}; | ||
|
||
return If; | ||
})(); | ||
|
||
exports.If = If; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
define(["exports", "./compose", "./if", "./repeat", "./show", "./selected-item"], function (exports, _compose, _if, _repeat, _show, _selectedItem) { | ||
"use strict"; | ||
|
||
exports.Compose = _compose.Compose; | ||
exports.If = _if.If; | ||
exports.Repeat = _repeat.Repeat; | ||
exports.Show = _show.Show; | ||
exports.SelectedItem = _selectedItem.SelectedItem; | ||
}); |
Oops, something went wrong.