client/js/router.js
author durandn
Thu, 21 Apr 2016 15:18:19 +0200
changeset 605 13d355fd09bf
parent 510 a8f02d66bf02
permissions -rw-r--r--
updated uri to allow optional trailing slash on single resource URIs (django automatic redirects don't carry over the Authorization header that can sometimes be needed, for instance with OAuth)
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);