Skip to content

Commit ed3591b

Browse files
committed
v 2.0.0
1 parent b804bfd commit ed3591b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+22039
-2499
lines changed

Gruntfile.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,25 @@ module.exports = function(grunt) {
99
banner: '/*! JStion — <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
1010
},
1111
'build/JStion-<%= pkg.version %>.js' :[ '_src/core/*.js' ],
12+
'build/JStion.Plans-<%= pkg.version %>.js' :[ '_src/plan/*.js' ],
13+
'build/JStion.Exts-<%= pkg.version %>.js' :[ '_src/ext/*.js' ],
1214
'build/JStion.UI-backbone-<%= pkg.version %>.js':[ '_src/backbone/*.js' ]
1315
},
1416

1517
uglify: {
16-
'build/JStion.min.js': 'build/JStion-<%= pkg.version %>.js',
17-
'build/JStion.UI-backbone.min.js': 'build/JStion.UI-backbone-<%= pkg.version %>.js'
18+
'build/JStion.min.js' : 'build/JStion-<%= pkg.version %>.js',
19+
'build/JStion.Plans.min.js' : 'build/JStion.Plans-<%= pkg.version %>.js',
20+
'build/JStion.Exts.min.js' :'build/JStion.Exts-<%= pkg.version %>.js',
21+
'build/JStion.UI-backbone.min.js' : 'build/JStion.UI-backbone-<%= pkg.version %>.js'
1822
},
1923

2024
jshint: {
21-
files:[ 'build/JStion-<%= pkg.version %>.js', 'build/JStion.UI-backbone-<%= pkg.version %>.js' ]
25+
files:[
26+
'build/JStion-<%= pkg.version %>.js',
27+
'build/JStion.Plans-<%= pkg.version %>.js',
28+
'build/JStion.Exts-<%= pkg.version %>.js',
29+
'build/JStion.UI-backbone-<%= pkg.version %>.js'
30+
]
2231
},
2332

2433
karma: {
@@ -31,13 +40,15 @@ module.exports = function(grunt) {
3140
autoWatch: false,
3241
captureTimeout: 60000
3342
},
34-
JStion:{
43+
JStion_behaviours:{
3544
src: [],
36-
files: [ '_dep/rollups/hmac-sha1.js', 'build/JStion.min.js', '_t/core/*.js' ],
45+
files: [ '_dep/rollups/hmac-sha1.js', '_t/bind.js', 'build/JStion-<%= pkg.version %>.js', 'build/JStion.Plans-<%= pkg.version %>.js', 'build/JStion.Exts-<%= pkg.version %>.js', '_t/behaviours/*.js' ],
46+
},
47+
JStion_internals:{
48+
src: [],
49+
files: [ '_dep/rollups/hmac-sha1.js', '_t/bind.js', 'build/JStion-<%= pkg.version %>.js', 'build/JStion.Plans-<%= pkg.version %>.js', '_t/internals/*.js' ],
3750
}
38-
3951
}
40-
4152
});
4253

4354
grunt.loadNpmTasks('grunt-contrib-uglify');

_src/backbone/20-model-entite.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
$fi.fn.m.Entite=
22
Backbone.Model.extend({
33
history:function( ){ return this.get('entite').history(); },
4+
checkout:function(i ){ return this.get('entite').checkout(i); },
45
back: function(i ){ return this.get('entite').back(i); },
56
current:function( ){ return this.get('entite').back(0); },
67
nom: function( ){ return this.get('entite').nom; },

_src/backbone/40-view-balance.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
$fi.fn.v.is_empty=function(v){
2+
//console.log([v, Number(v)]);
3+
return (Number(v) === 0);
4+
};
5+
16
$fi.fn.v.b2=
2-
_.template('<tr><th><%=account%><td><%=debit%><td><%=credit%><td><%=solde_debit%><td><%=solde_credit%></tr><% _.each( subaccounts, function(c){%><%= window.$fi.v.b2(c) %><% }); %>');
7+
_.template('<% if(_.filter(data, window.$fi.fn.v.is_empty).length != data.length ) { %>'+
8+
'<tr><th><%=account%>' +
9+
'<% _.each( data, function(f){%><td><%= (window.$fi.fn.v.is_empty(f))?"":f %></td><% }) %>'+
10+
'<% _.each( solde, function(f){%><td><%= (window.$fi.fn.v.is_empty(f))?"":f %></td><% }) %>'+
11+
'</tr>'+'<% } %>'+
12+
'<% _.each( subaccounts, function(c){%><%= window.$fi.v.b2(c) %><% }); %>');
313

414
$fi.fn.v.Balance=
515
Backbone.View.extend({
616
el:'<table>',
7-
template:_.template('<caption><%=nom%> — <%=message%></caption>'+
17+
template:_.template('<caption><%=nom%> — <%=meta.message%></caption>'+
818
'<tr><th>compte<th>debit<th>credit<th>Solde débiteur<th>Solde créditeur</tr><% _.each( livre.accounts, function(c){ %><%= window.$fi.v.b2(c) %><% }); %>'),
919

1020
render:function(ev){ $(this.el).html(this.template(this.model.toVSON())); return this; },

_src/backbone/40-view-ecriture.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
$fi.fn.v.Ecriture=
22
Backbone.View.extend({
33
el:'<table>',
4-
template:_.template('<caption><%= message %></caption>'+
4+
template:_.template('<caption><%= meta.message %></caption>'+
55
'<tr><th>compte</th><th>debit</th><th>credit</th></tr>'+
6-
'<% _.each( mouvement, function(l){ %><tr><th><%= l[0] %></th><td><%= l[1]?l[1].toFixed(window.$fi.fix):"" %></td><td><%= l[2]?l[2].toFixed(window.$fi.fix):"" %></td></tr> <% }) %></table>' ),
6+
'<% _.each( mouvement, function(l){ %><tr><th><%= l[0] %></th><td><%= (window.$fi.fn.v.is_empty(f))?"":f %></td><td><%= (window.$fi.fn.v.is_empty(f))?"":f %></td></tr> <% }) %></table>' ),
77

88
render:function(ev){ $(this.el).html(this.template(this.model.toVSON())); return this; },
99
});

_src/backbone/40-view-fragment.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ $fi.fn.v.Fragment=
33
el:'<table>',
44
template:_.template(
55
'<tr><th>compte</th><th>debit</th><th>credit</th></tr>'+
6-
'<% _.each( d, function(l){ %><tr><th><%= l[0] %></th><td><%= l[1] %></td><td><%= l[2] %></td></tr> <% }) %></table>' ),
6+
'<% _.each( d, function(l){ %><tr><th><%= l[0] %></th>'+
7+
'<% _.each( l[1], function(f){%><td><%= (window.$fi.fn.v.is_empty(f))?"":f %></td><% }) %>'+
8+
'</tr> <% }) %></table>' ),
79

810
render:function(ev){ $(this.el).html(this.template({d:this.model.toVSON()})); return this; },
911
});

_src/backbone/40-view-journal.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
$fi.fn.v.Journal=
22
Backbone.View.extend({
33
el:'<dl>',
4-
template:_.template('<dt><%=message%><% if(mouvement.length){%><dd><table><tr><th>compte<th>debit<th>crédit</tr>'+
5-
'<% _.each( mouvement, function(l){ %><tr><th><%= l[0] %></th><td><%= l[1]?l[1].toFixed(window.$fi.fix):"" %></td><td><%= l[2]?l[2].toFixed(window.$fi.fix):"" %></td></tr> <% }) %>'+
4+
template:_.template('<dt><%= meta.date %> : <%= meta.message %><% if(mouvement.length){%><dd><table><tr><th>compte<th>debit<th>crédit</tr>'+
5+
'<% _.each( mouvement, function(l){ %><tr><th><%= l[0] %></th>'+
6+
'<% _.each( l[1], function(f){%><td><%= (window.$fi.fn.v.is_empty(f))?"":f %></td><% }) %>'+
7+
'</tr> <% }) %>'+
68
'</table><% } %>'),
79

810
render:function(ev){
911
var view = this;
1012
var model = this.model;
11-
var livre = model.current();
1213
var el = $(this.el);
13-
_.each(model.history(),function(log){
14+
_.each(model.history().slice().reverse(),function(log){
15+
if(log.parents === undefined ) return;
16+
var livre = model.checkout(log.id);
1417
el.append(view.template( livre.diff( livre.back(1) ).toVSON() ));
15-
livre = livre.back(1);
1618
});
1719
return this;
1820
},

_src/core/00-header.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
(function(window,undefined){
2-
2+
"use strict";
33

44
/**
55
* [instanciable description]
66
* @type {Object}
77
*/
88
var instanciable={};
99

10+
var pcg={};
1011

1112
/**
1213
* Handler for several kind of Storage
1314
* @type {Object}
1415
*/
1516
var StorageEngine={
1617
fake:(function(){
17-
var f=function(){
18+
var F=function(){
1819
this.store={};
1920
};
20-
f.prototype={
21+
F.prototype={
2122
setItem: function(k,v){
2223
this.store[k]=v;
2324
},
@@ -31,7 +32,7 @@ var StorageEngine={
3132
this.store={};
3233
},
3334
};
34-
return new f();
35+
return new F();
3536
})(),
3637
local:window.localStorage,
3738
session:window.sessionStorage,

_src/core/00-helpers.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function to_array(arg){
2+
return [].slice.call( arg || [] );
3+
}
4+
5+
function copy_array(arr){
6+
return arr.slice();
7+
}
8+
9+
function idem(e){
10+
return e;
11+
}
12+
13+
function filter_and_dispatch( filter, exact ) {
14+
return function (set){
15+
return set.filter( filter ).reduce(function(resp,e){
16+
if(exact(e)) return {
17+
exact: resp.exact.concat([e]),
18+
sub: resp.sub
19+
};
20+
return {
21+
exact: resp.exact,
22+
sub: resp.sub.concat([e])
23+
};
24+
}, { exact:[], sub:[] } );
25+
};
26+
}

_src/core/05-PGC.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

_src/core/05-create_class.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/**
22
* create a class
3-
*
3+
*
44
* @param {function|object} constructor function or default value
55
* @param {object} prototype
6-
*
6+
*
77
* @return {function} constructor
88
*/
99
var create_class=function(constructor,prototype,inheritance){
10-
if(typeof constructor !== 'function')console.error('wrong parameter');
10+
if(typeof constructor !== 'function') console.error('wrong parameter');
1111

1212
var f=function(){
1313
constructor.apply(this,arguments);
@@ -16,8 +16,9 @@ var create_class=function(constructor,prototype,inheritance){
1616

1717
f.prototype = Object.create( inheritance===undefined ? Object.prototype: inheritance.prototype);
1818

19-
for (var k in prototype) f.prototype[k] = prototype[k];
19+
if(prototype instanceof Function) prototype=prototype(f);
20+
21+
for(var k in prototype) f.prototype[k] = prototype[k];
2022

2123
return f;
2224
};
23-

0 commit comments

Comments
 (0)