client/js/router.js
author rougeronj
Tue, 22 Sep 2015 15:14:10 +0200
changeset 543 5f7bebdcfc0d
parent 510 a8f02d66bf02
permissions -rw-r--r--
Improve the way we init the view. The data loader send a "loaded" event, hooked by the scene.py and initializing the backbone.history and the view. We don't use redraw_active in save-once and full-json, because it was making the view initialization dependent of these file which are externals. Small fix to hide the "set saved view" button when there is only one view.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
471
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     1
(function(root) {
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     2
    "use strict";
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     3
    
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     4
    var Backbone = root.Backbone;
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     5
    
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     6
    var Router = root.Rkns.Router = Backbone.Router.extend({
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     7
        routes: {
473
6649d2d75a87 update router
rougeronj
parents: 471
diff changeset
     8
            '': 'index'
471
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
     9
        },
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
    10
        
473
6649d2d75a87 update router
rougeronj
parents: 471
diff changeset
    11
        index: function (parameters) {
471
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
    12
            
473
6649d2d75a87 update router
rougeronj
parents: 471
diff changeset
    13
            var result = {};
510
a8f02d66bf02 adapt the viewRepr to support a temp View (a representation without a model)
rougeronj
parents: 473
diff changeset
    14
            if (parameters !== null){
a8f02d66bf02 adapt the viewRepr to support a temp View (a representation without a model)
rougeronj
parents: 473
diff changeset
    15
                parameters.split("&").forEach(function(part) {
a8f02d66bf02 adapt the viewRepr to support a temp View (a representation without a model)
rougeronj
parents: 473
diff changeset
    16
                    var item = part.split("=");
a8f02d66bf02 adapt the viewRepr to support a temp View (a representation without a model)
rougeronj
parents: 473
diff changeset
    17
                    result[item[0]] = decodeURIComponent(item[1]);
a8f02d66bf02 adapt the viewRepr to support a temp View (a representation without a model)
rougeronj
parents: 473
diff changeset
    18
                });
473
6649d2d75a87 update router
rougeronj
parents: 471
diff changeset
    19
            }
510
a8f02d66bf02 adapt the viewRepr to support a temp View (a representation without a model)
rougeronj
parents: 473
diff changeset
    20
            this.trigger('router', result);        
471
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
    21
        }  
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
    22
    });
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
    23
e0c7be5dc02c Add a router to handle fragment identifier
rougeronj
parents:
diff changeset
    24
})(window);