Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
d2fbc5e
removed jquery dependency
gwendall Aug 20, 2014
8b57b49
removed jquery dependency 2
gwendall Aug 20, 2014
ec9cb71
clean up code
gwendall Aug 20, 2014
0272fdf
clean up code 2
gwendall Aug 20, 2014
8499701
support for AMD and commonjs
gwendall Aug 20, 2014
858bc2f
Genderfix
woodworker Aug 20, 2014
44bf3bd
dependency free
gwendall Aug 20, 2014
02e4b72
dependency free 2
gwendall Aug 20, 2014
b3b8c72
Merge pull request #18 from gwendall/nojquery
gwendall Aug 20, 2014
4992fdf
update doc
gwendall Aug 20, 2014
7170610
update doc 2
gwendall Aug 20, 2014
c4a8fe9
update demo
gwendall Aug 20, 2014
95d0540
update doc
gwendall Aug 20, 2014
83a1c88
update doc 2
gwendall Aug 20, 2014
4c8d897
update doc 3
gwendall Aug 20, 2014
cbbbf95
Merge pull request #17 from woodworker/patch-1
gwendall Aug 20, 2014
0becaf6
add bower
gwendall Aug 20, 2014
cf40e8e
Merge branch 'master' of https://github.com/Gwendall/way.js
gwendall Aug 20, 2014
360a7a4
update doc
gwendall Aug 20, 2014
f586c0d
update doc 2
gwendall Aug 20, 2014
7abd6bf
update doc 3
gwendall Aug 20, 2014
405f60e
added travis
gwendall Aug 20, 2014
982afa0
fix parent selectors for scope
gwendall Aug 21, 2014
91c4f81
fix parent selectors for scope 2
gwendall Aug 21, 2014
da040f6
added filters
gwendall Aug 21, 2014
22e8498
added filters 2
gwendall Aug 21, 2014
4206bbf
added filters 3
gwendall Aug 21, 2014
c305141
added filters 4
gwendall Aug 21, 2014
c0fcced
added filters 5
gwendall Aug 21, 2014
7fa77b2
added filters 6
gwendall Aug 21, 2014
045f6bc
added filters 7
gwendall Aug 21, 2014
7eba5b6
added filters 8
gwendall Aug 21, 2014
36df846
added filters 9
gwendall Aug 21, 2014
0920768
filters in minified doc
gwendall Aug 21, 2014
5a9bd10
renamed filters to transform and added filters for way-repeat
gwendall Aug 22, 2014
3bf9d17
renamed filters etc 2
gwendall Aug 22, 2014
24a3bc8
renamed filters etc 3
gwendall Aug 22, 2014
9dc34d0
renamed filters etc 4
gwendall Aug 22, 2014
a0b71f0
renamed filters etc 5
gwendall Aug 22, 2014
b7065cf
renamed filters etc 6
gwendall Aug 22, 2014
4b6d07d
renamed filters etc 7
gwendall Aug 22, 2014
bfd86bf
renamed filters etc 8
gwendall Aug 22, 2014
59a6165
nofilter
gwendall Aug 22, 2014
62f19e7
changed ready function
gwendall Aug 22, 2014
61331b2
changed ready function 2
gwendall Aug 22, 2014
3dd17f4
changed ready function 3
gwendall Aug 22, 2014
aad3e4d
Removed commas at the end of each way-repeat entry
ryan-scott-dev Aug 24, 2014
6a3f670
Merge pull request #25 from Archytaus/master
gwendall Aug 25, 2014
f6076ac
repeats items inserted as string vs array
gwendall Aug 25, 2014
87bd5fa
fixed DOM match selector to be cross-browser
gwendall Aug 25, 2014
b64dd69
fixed escape HTML fn
gwendall Sep 3, 2014
8761186
fixed escape HTML fn
gwendall Sep 3, 2014
f0eb500
fixed watcher
gwendall Sep 3, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .travis.yml
Empty file.
23 changes: 3 additions & 20 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,19 @@

module.exports = function(grunt) {
grunt.initConfig({
concat : {
bundle : {
src : [
'vendor/jquery.js',
'vendor/underscore.js',
'vendor/underscore.json.js',
'way.js'
],
dest : 'way.bundle.js'
}
},
uglify : {
bundle : {
files : {
'way.bundle.min.js' : [ 'way.bundle.js' ]
}
},
standalone : {
files : {
'way.min.js' : [ 'way.js' ]
}
}
},
watch : {
files : ['way.js', 'vendor/**/*'],
tasks : ['concat', 'uglify']
files : ['way.js'],
tasks : ['uglify']
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['concat:bundle', 'uglify:bundle', 'uglify:standalone', 'watch' ]);
grunt.registerTask('default', ['uglify:standalone', 'watch' ]);
};
109 changes: 92 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
way.js
======

Simple, lightweight, persistent, framework-agnostic two-way databinding Javascript library (with no to little JS code to write).
Simple, lightweight, persistent, framework-agnostic two-way databinding Javascript library.
With no to little JS code to write. And no dependencies.

[Demo](https://gwendall.github.io/way)
[Codepen](http://codepen.io/anon/pen/rihBs)
[jsFiddle](http://jsfiddle.net/gwendall/s5zzc84m/)

Buy us coffee: [Gittip](https://www.gittip.com/gwendall)
Follow us on Twitter: [@way_js](https://twitter.com/way_js)

## Quick start ##
Expand All @@ -32,23 +34,13 @@ Enough talk, [see it in action](https://gwendall.github.io/way).

## Installation ##

Step 1: Include the bundled library to your page.
**[Step 1]** Include the library to your page.

```html
<script src="/way.bundle.min.js"></script>
<script src="way.min.js"></script>
```

Step 2: There is no step 2. You are good to go.


Note: The bundled version contains the required dependencies (listed below). Feel free to include them separately.

```html
<script src="/vendor/jquery.js"></script>
<script src="/vendor/underscore.js"></script>
<script src="/vendor/underscore.json.js"></script>
<script src="/way.min.js"></script>
```
**[Step 2]** There is no step 2. You are good to go.

## Options ##

Expand Down Expand Up @@ -177,8 +169,91 @@ Will render that:
</div>
```

Demo:
[Codepen](http://codepen.io/anon/pen/CjbAh)
## Transforms ##

Transforms the displayed data bound to your DOM elements.

**[way-transform] attribute**
Pass transform functions by name. Add multiple transforms by separating them with the "|" symbol.
In case of conflicts between transforms, the last mentionned transform wins.
Some pre-build transforms **[PR welcome for more!]**

Name | Description | Example
----|------|----
uppercase | Sets a string to uppercase | "hello" becomes "HELLO"
lowercase | Sets a string to lowercase | "HELLO" becomes "hello"
reverse | Reverses a string | "hello" becomes "olleh"


```javascript
way.set("someData", "hello")
```

```html
<div way-data="someData" way-transform="uppercase"></div>
<!-- Renders "HELLO" -->
```

**registerTransform(name, transform) method**
Adds a new transform.

```javascript
way.set("someData", "hello");
way.registerTransform("lolify", function(data) {
return data + " lol";
});
```

```html
<div way-data="someData" way-transform="lolify|uppercase"></div>
<!-- Renders "HELLO LOL" -->
```

<!--
## Filters ## [experimental: bugs to fix]

Filters the displayed data within your "way-repeat" blocks.

**[way-filter] attribute**
Pass filter functions by name. Add multiple filters by separating them with the "|" symbol.
In case of conflicts between filters, the last mentionned filter wins.
Some pre-build filters **[PR welcome for more!] **

Name | Description
----|------
noDuplicates | Only displays HTML for unique DOM elements


```javascript
way.set("someArray", [
{ color: "red" },
{ color: "red" },
{ color: "blue" },
{ color: "green" }
{ color: "green" }
])
```

```html
<div way-repeat="someArray" way-filter="noDuplicates">
<div way-data="color"></div>
</div>
```

// Will render something like

```html
<div way-scope="someArray">
<div way-scope="0" way-data="color">red</div>
<div way-scope="2" way-data="color">blue</div>
<div way-scope="3" way-data="color">green</div>
</div>
```

**registerFilter(name, filter) method**
Adds a new filter.

-->

## Helper elements ##

Expand Down Expand Up @@ -231,7 +306,7 @@ way.set("image.url", "somethingThatsNotAnImageURL");
Everything should be done for you from the HTML tags. But if necessary, you can also use helper functions to interact with your stored data and DOM elements.

Notes:
- [element] refers to the jQuery selector of a DOM element
- [element] refers to the CSS selector of a DOM element.
- [options] is optional. By default, options are read from the HTML tags of the elements. But you can overwrite them, by passing this parameter.

### DOM methods
Expand Down
26 changes: 26 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "way.js",
"version": "0.1.0",
"homepage": "https://github.com/gwendall/way.js",
"authors": [
"Gwen <gwendall.esnault@gmail.com>"
],
"description": "Simple, lightweight, persistent, framework-agnostic two-way databinding",
"main": "way.min.js",
"keywords": [
"javascript",
"databinding",
"database",
"form",
"input",
"frontend"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
6 changes: 2 additions & 4 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="index.css">

<script src="../vendor/jquery.js"></script>
<script src="../vendor/underscore.js"></script>
<script src="../vendor/underscore.json.js"></script>
<script src="../way.js"></script>
<script src="../way.min.js"></script>
<script src="index.js"></script>

</head>
Expand Down Expand Up @@ -91,6 +88,7 @@ <h3 style="margin: 0px;margin-bottom: 20px;">Example</h3>
<select class="form-control" name="gender">
<option>Female</option>
<option>Male</option>
<option>Other</option>
</select>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions demo/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
$(document).ready(function() {
way.w.ready(function() {

way.watchAll(function(selector, value) {
console.log("Something changed.", {
selector: selector,
value: value
});
});

});
Loading