jazz-jss 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,73 @@
1
+ Jazz.Route = {
2
+ routes: {},
3
+ initialize: function(){
4
+ Jazz.Route.navigate();
5
+ $(window).hashchange(
6
+ function(){
7
+ Jazz.Route.navigate()
8
+ }
9
+ );
10
+
11
+ },
12
+
13
+ draw: function(routes){
14
+ if (!routes) return this;
15
+ var now = this.routes;
16
+
17
+ // Update attributes.
18
+ for (var route in routes) {
19
+ var val = routes[route];
20
+
21
+ if (!_.isEqual(now[route], val)) {
22
+ now[route] = val;
23
+ }
24
+
25
+ }
26
+
27
+ return this;
28
+ },
29
+
30
+ navigate: function(){
31
+
32
+ action = this.getActionForRoute(location.hash.replace( /^#/, '' ))
33
+
34
+ if (!action) {
35
+ this.rescue();
36
+ return this
37
+ };
38
+
39
+ var parts = action.split('#');
40
+ Jazz.Now.controller = parts[0];
41
+ Jazz.Now.action = parts[1];
42
+
43
+ func = new Function(Jazz.Now.controller + '.' + Jazz.Now.action + '()');
44
+
45
+ try {
46
+ return func();
47
+ }
48
+ catch(err)
49
+ {
50
+ this.rescue();
51
+ }
52
+ },
53
+
54
+ getActionForRoute: function(route){
55
+
56
+ Jazz.Now.url = route;
57
+
58
+ action = route == "" ? '/' : route;
59
+ action = this.routes[route] ? this.routes[route] : false;
60
+ return action;
61
+ },
62
+
63
+ redirect: function(to){
64
+
65
+ },
66
+
67
+ rescue: function(){
68
+ delete Jazz.Now.controller;
69
+ delete Jazz.Now.action;
70
+ Jazz.Helper.showError('Cannot Find Route Or Action');
71
+ },
72
+
73
+ };
@@ -0,0 +1 @@
1
+ Jazz.View = {}
data/dist/jazz/main.js ADDED
@@ -0,0 +1,76 @@
1
+ var Jazz = {
2
+ _:{
3
+ requires:[
4
+ 'vendor/jquery/jquery.js',
5
+ 'vendor/hashchange/jquery.ba-hashchange.js',
6
+ 'vendor/mustache/mustache.js',
7
+ 'vendor/underscore/underscore.js',
8
+ 'lib/jazz/lib/helper.js',
9
+ 'lib/jazz/lib/model.js',
10
+ 'lib/jazz/lib/db.js',
11
+ 'lib/jazz/lib/route.js',
12
+ 'lib/jazz/lib/view.js',
13
+ 'lib/jazz/lib/controller.js',
14
+ 'config/application.js',
15
+ 'config/routes.js',
16
+ 'config/glue.js'
17
+ ]
18
+ },
19
+ Helper:{
20
+ addOrderToRequires:function (collection, path) {
21
+ path = path ? path : '';
22
+ //Load order is importent so add it by default
23
+ for (file in collection) {
24
+ collection[file] = collection[file] != "" ? 'vendor/require/order!' + path + collection[file] : "";
25
+ }
26
+ return collection;
27
+ }
28
+ },
29
+ Now:{},
30
+ Config:{}
31
+ }
32
+
33
+
34
+ require(
35
+ {
36
+ baseUrl:""
37
+ },
38
+ Jazz.Helper.addOrderToRequires(Jazz._.requires),
39
+ function () {
40
+ _.extend(
41
+ Jazz.Helper.getApp(),
42
+ {
43
+ _:{
44
+ requires:[]
45
+ }
46
+ }
47
+ );
48
+
49
+ _.each(
50
+ Glue,
51
+ function (val, key) {
52
+ var path;
53
+ switch (key) {
54
+ case "Db":
55
+ path = "db/"
56
+ break;
57
+ default:
58
+ path = "app/" + key + '/'
59
+ break;
60
+ }
61
+
62
+ Jazz.Helper.getApp()._.requires.push(Jazz.Helper.addOrderToRequires(val, path));
63
+ }
64
+ );
65
+
66
+ Jazz.Helper.getApp()._.requires = _.flatten(Jazz.Helper.getApp()._.requires);
67
+
68
+ require(
69
+ Jazz.Helper.getApp()._.requires,
70
+ function () {
71
+ eval(Jazz.Config.appName + '.initialize()');
72
+ Jazz.Route.initialize();
73
+ }
74
+ );
75
+ }
76
+ );