Skip to content

Commit 91fafa7

Browse files
committed
clean + added concat version
1 parent ef4e38c commit 91fafa7

File tree

10 files changed

+267
-31
lines changed

10 files changed

+267
-31
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ node_modules
2626

2727
# Users Environment Variables
2828
.lock-wscript
29-
src/**/*.js
29+
lib/**/*.js
3030
example/**/*.js
3131

3232
bower_components

Gruntfile.js

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ paths.base = Path.normalize(__dirname);
66

77
function Grunt(grunt) {
88
var tasks = [
9-
'grunt-6to5',
9+
'grunt-babel',
1010
'grunt-add-comment',
11+
'grunt-contrib-concat',
12+
'grunt-wrap',
1113
'grunt-contrib-uglify'
1214
];
1315

@@ -18,10 +20,10 @@ function Grunt(grunt) {
1820

1921
var pathOption = getPathOption(grunt);
2022

21-
Configuration = {};
23+
var Configuration = {};
2224
Configuration.package = grunt.file.readJSON('package.json');
2325

24-
Configuration['6to5'] = {
26+
Configuration.babel = {
2527
options: {
2628
sourceMap: false
2729
},
@@ -33,6 +35,18 @@ function Grunt(grunt) {
3335
src: (pathOption ? pathOption.name : ['**/*.es6']),
3436
dest: paths.base
3537
}]
38+
},
39+
dist: {
40+
options: {
41+
blacklist:['useStrict']
42+
},
43+
files: [{
44+
expand: true,
45+
cwd: paths.base,
46+
ext: '.js',
47+
src: (pathOption ? pathOption.name : ['**/*.es6']),
48+
dest: paths.base
49+
}]
3650
}
3751
};
3852

@@ -53,9 +67,9 @@ function Grunt(grunt) {
5367
dist: {
5468
options: {
5569
comments: [
56-
Configuration.package.name,
57-
'version: ' + Configuration.package.version,
58-
'author: ' + Configuration.package.author,
70+
'<%= package.name %>',
71+
'version: <%= package.version %>',
72+
'author: <%= package.author %>',
5973
'generated: ' + new Date(),
6074
'Autogenerated, do not edit. All changes will be undone.'],
6175
prepend: true,
@@ -67,6 +81,17 @@ function Grunt(grunt) {
6781
expand: true,
6882
src: ['dist/*.js'],
6983
}]
84+
},
85+
strict: {
86+
options: {
87+
comments: ['use strict;'],
88+
prepend: true,
89+
syntaxes: {
90+
'.js': ['"','";']
91+
}
92+
},
93+
src: ['dist/<%= package.name %>.js'],
94+
dest: 'dist/<%= package.name %>.js'
7095
}
7196
};
7297

@@ -82,17 +107,42 @@ function Grunt(grunt) {
82107
}
83108
},
84109
dist: {
85-
files: {
86-
'dist/angular-property-binder.min.js': ['src/core.js', 'src/providers/binder.js', 'src/services/binder.js']
87-
}
110+
src: 'dist/<%= package.name %>.js',
111+
dest: 'dist/<%= package.name %>.min.js'
88112
}
89-
}
113+
};
114+
115+
Configuration.concat = {
116+
dist: {
117+
src: [
118+
'lib/core.js',
119+
'lib/providers/binder.js',
120+
'lib/services/binder.js'
121+
],
122+
dest: 'dist/<%= package.name %>.js'
123+
}
124+
};
125+
126+
Configuration.wrap = {
127+
dist: {
128+
options: {
129+
seperator: '\n',
130+
indent: '\t',
131+
wrapper: ['(function (window,document,angular) {\n', '\n})(window,window.document,window.angular);']
132+
},
133+
src: [
134+
'dist/<%= package.name %>.js'
135+
],
136+
dest: 'dist/<%= package.name %>.js'
137+
}
138+
};
90139

91140
grunt.initConfig(Configuration);
92141

93-
grunt.registerTask('es6', ['6to5:all', 'add_comment:common']);
94-
grunt.registerTask('build', ['6to5:all', 'uglify:dist', 'add_comment:dist']);
95-
};
142+
grunt.registerTask('es6', ['babel:all', 'add_comment:common']);
143+
grunt.registerTask('dev', ['babel:all']);
144+
grunt.registerTask('build', ['babel:dist', 'concat:dist', 'add_comment:strict', 'uglify:dist', 'wrap:dist', 'add_comment:dist']);
145+
}
96146

97147
module.exports = Grunt;
98148

bower.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "angular-property-binder",
2+
"name": "angular-property-binder-source",
33
"description": "Angular element binding service, keep safe your object references.",
4-
"version": "0.1.5",
4+
"version": "0.1.12",
55
"authors": [
66
"Nicolas Gaignoux <[email protected]>"
77
],
@@ -27,6 +27,6 @@
2727
"lib/**/*.js"
2828
],
2929
"dependencies": {
30-
"angular": "~1.3.6"
30+
"angular": "~1.3.15"
3131
}
3232
}

dist/angular-property-binder.js

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
// angular-property-binder
2+
// version: 0.1.12
3+
// author: Gaignoux Nicolas
4+
// generated: Thu Apr 16 2015 19:20:53 GMT+0200 (Paris, Madrid (heure d’été))
5+
// Autogenerated, do not edit. All changes will be undone.
6+
(function (window,document,angular) {
7+
8+
" use strict; ";
9+
angular.module('PropertyBinder', []);
10+
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
11+
12+
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
13+
14+
angular.module('PropertyBinder').provider('PropertyBinder.providers.binder', function () {
15+
this.$get = function () {
16+
var Binder = (function () {
17+
function Binder() {
18+
var properties = arguments[0] === undefined ? [] : arguments[0];
19+
20+
_classCallCheck(this, Binder);
21+
22+
this._properties = properties instanceof Array ? properties : [properties];
23+
this._binded = false;
24+
this._sealed = false;
25+
this._to = undefined;
26+
this._from = undefined;
27+
this._path = [];
28+
this._aliases = {};
29+
this._change = function () {};
30+
}
31+
32+
_createClass(Binder, [{
33+
key: 'from',
34+
value: function from(scope) {
35+
var path = arguments[1] === undefined ? [] : arguments[1];
36+
37+
this._throwErrorIfAlreadyBinded();
38+
this._path = typeof path === 'string' ? path = path.split('.') : path;
39+
this._from = scope;
40+
return this;
41+
}
42+
}, {
43+
key: 'to',
44+
value: function to(scope) {
45+
this._throwErrorIfAlreadyBinded();
46+
47+
this._to = scope;
48+
return this;
49+
}
50+
}, {
51+
key: 'as',
52+
value: function as() {
53+
var aliases = arguments[0] === undefined ? {} : arguments[0];
54+
55+
this._throwErrorIfAlreadyBinded();
56+
57+
if (aliases instanceof Object) {
58+
59+
if (aliases instanceof Array) {
60+
for (var i = 0; i < aliases.length; i++) {
61+
if (!!this._properties[i]) this._aliases[this._properties[i]] = aliases[i];
62+
}
63+
} else this._aliases = aliases;
64+
} else {
65+
66+
if (typeof aliases === 'string') {
67+
if (this._properties.length === 1) {
68+
var alias = aliases;
69+
this._aliases = {};
70+
this._aliases[this._properties[0]] = alias;
71+
} else throw Error('Ambiguous aliases');
72+
}
73+
}
74+
75+
return this;
76+
}
77+
}, {
78+
key: 'onchange',
79+
value: function onchange() {
80+
var changeEvent = arguments[0] === undefined ? function () {} : arguments[0];
81+
82+
this._change = changeEvent;
83+
return this;
84+
}
85+
}, {
86+
key: 'seal',
87+
value: function seal() {
88+
this._sealed = true;
89+
return this;
90+
}
91+
}, {
92+
key: 'unseal',
93+
value: function unseal() {
94+
this._sealed = false;
95+
return this;
96+
}
97+
}, {
98+
key: 'toggleSealing',
99+
value: function toggleSealing() {
100+
this._sealed = !this._sealed;
101+
return this;
102+
}
103+
}, {
104+
key: 'apply',
105+
value: function apply() {
106+
107+
this._throwErrorIfAlreadyBinded();
108+
if (this._from && this._to && this._properties.length > 0) for (var i = 0; i < this._properties.length; i++) this._createProperty(this._properties[i]);
109+
110+
this._binded = true;
111+
return this;
112+
}
113+
}, {
114+
key: 'destroy',
115+
value: function destroy() {
116+
117+
for (var i = 0; i < this._properties.length; i++) this._deleteProperty(this._properties[i]);
118+
119+
this._binded = false;
120+
return this;
121+
}
122+
}, {
123+
key: '_deleteProperty',
124+
value: function _deleteProperty(property) {
125+
var alias = this._aliases[property] || property;
126+
delete this._to[alias];
127+
}
128+
}, {
129+
key: '_createProperty',
130+
value: function _createProperty(property) {
131+
var _this = this;
132+
133+
Object.defineProperty(this._to, this._aliases[property] || property, {
134+
enumerable: true,
135+
configurable: true,
136+
get: function get() {
137+
var src = _this._getSrc();
138+
return src[property] instanceof Function ? src[property].bind(src) : src[property];
139+
},
140+
set: function set(value) {
141+
if (!_this._sealed) {
142+
var src = _this._getSrc();
143+
var oldValue = src[property];
144+
src[property] = value;
145+
if (oldValue !== value) _this._change(value, oldValue);
146+
} else throw Error('Trying to update a sealed property');
147+
}
148+
});
149+
}
150+
}, {
151+
key: '_getSrc',
152+
value: function _getSrc() {
153+
var src = this._from;
154+
if (this._path.length > 0) for (var i = 0; i < this._path.length; i++) {
155+
src = src[this._path[i]];
156+
if (!src) throw Error('unable to acces to the given property');
157+
}
158+
return src;
159+
}
160+
}, {
161+
key: '_throwErrorIfAlreadyBinded',
162+
value: function _throwErrorIfAlreadyBinded() {
163+
if (this._binded) throw Error('Property already binded');
164+
}
165+
}]);
166+
167+
return Binder;
168+
})();
169+
170+
return Binder;
171+
};
172+
});
173+
var _bind = Function.prototype.bind;
174+
angular.module('PropertyBinder').service('PropertyBinder.services.binder', ['PropertyBinder.providers.binder', function (Binder) {
175+
return function () {
176+
for (var _len = arguments.length, parameters = Array(_len), _key = 0; _key < _len; _key++) {
177+
parameters[_key] = arguments[_key];
178+
}
179+
180+
return new (_bind.apply(Binder, [null].concat(parameters)))();
181+
};
182+
}]);
183+
184+
})(window,window.document,window.angular);

dist/angular-property-binder.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@
4747

4848
<!-- scripts -->
4949
<!-- libraries -->
50-
<script src="../dist/angular-property-binder.min.js"></script>
51-
<script src="../src/core.js"></script>
52-
<script src="../src/providers/binder.js"></script>
53-
<script src="../src/services/binder.js"></script>
50+
<script src="../bower_components/angular/angular.min.js"></script>
51+
<script src="../dist/angular-property-binder.js"></script>
52+
<!-- <script src="../dist/angular-property-binder.min.js"></script> -->
53+
<!-- <script src="../lib/core.js"></script> -->
54+
<!-- <script src="../lib/providers/binder.js"></script> -->
55+
<!-- <script src="../lib/services/binder.js"></script> -->
5456
<!-- libraries -->
5557
<!-- features -->
5658
<script src="modules/app/core.js"></script>
File renamed without changes.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-property-binder",
3-
"version": "0.1.10",
3+
"version": "0.1.12",
44
"description": "Bind property and keep safe the reference",
55
"keywords": [
66
"Angular",
@@ -17,13 +17,13 @@
1717
"url": "[email protected]:PillowPillow/angular-property-binder.git"
1818
},
1919
"devDependencies": {
20+
"babel": "^5.1.10",
2021
"grunt": "^0.4.5",
21-
"grunt-6to5": "^1.0.2",
2222
"grunt-add-comment": "^1.1.5",
23-
"time-grunt": "^1.0.0",
24-
"grunt-contrib-uglify": "^0.7.0"
25-
},
26-
"dependencies": {
27-
"6to5": "^3.0.15"
23+
"grunt-babel": "^5.0.0",
24+
"grunt-contrib-concat": "^0.5.1",
25+
"grunt-contrib-uglify": "^0.9.1",
26+
"grunt-wrap": "^0.3.0",
27+
"time-grunt": "^1.1.1"
2828
}
2929
}

0 commit comments

Comments
 (0)