Commit a0f2f8e6 authored by alexandre's avatar alexandre

cleaning pagination and backgrid related comments

parent 07850c80
......@@ -5,82 +5,6 @@ window.W = window.W || {};
(function (undefined) {
'use strict';
var MyDatetimeFormatter = _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function (rawValue, model) {
moment.locale('fr');
return moment(rawValue).calendar();
}
});
var MyDatetimeCell = Backgrid.DatetimeCell.extend({
formatter: MyDatetimeFormatter
});
var MyUriCell = Backgrid.StringCell.extend({
render: function () {
this.$el.empty();
var rawValue = this.model.get(this.column.get("name"));
var uri = "/partitions/" + this.model.get("id");
var formattedValue = this.formatter.fromRaw(rawValue, this.model);
this.$el.append($("<a>", {
tabIndex: -1,
href: uri,
title: this.title || formattedValue,
target: this.target
}).text(formattedValue));
this.delegateEvents();
return this;
}
});
var MarionetteGrid = Backgrid.Grid.extend(Marionette.Events);
var MarionettePaginator = Backgrid.Extension.Paginator.extend(Marionette.Events);
var columns = [
{
name: "title",
label: "Partition",
editable: false, // By default every cell in a column is editable, but *ID* shouldn't be
cell: MyUriCell
},
{
name: "created_at",
label: "Créée le",
editable: false, // By default every cell in a column is editable, but *ID* shouldn't be
cell: MyDatetimeCell
},
{
name: "updated_at",
label: "Mise à jour le",
editable: false, // By default every cell in a column is editable, but *ID* shouldn't be
cell: MyDatetimeCell
},
{
name: "language",
label: "Language",
editable: false, // By default every cell in a column is editable, but *ID* shouldn't be
cell: "string",
},
{
name: "tags",
label: "Tags",
editable: false, // By default every cell in a column is editable, but *ID* shouldn't be
cell: "string",
},
{
name: "score_type",
label: "Type",
cell: "string",
editable: false, // By default every cell in a column is editable, but *ID* shouldn't be
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function (rawValue, model) {
return ["transcription", "prescription", "traduction"][parseInt(rawValue)]
}
})
},
];
/**
* The queue stores a list of callbacks to be processed at a later time.
......@@ -249,8 +173,6 @@ window.W = window.W || {};
}, model.cid);
}
var rangeType = {
undetermined: '0',
exact: '1',
......@@ -2206,7 +2128,6 @@ window.W = window.W || {};
regions: {
list: '#list',
// pagination: '#pagination',
panel: {
el: '#search-panel',
replaceElement: true
......@@ -2228,57 +2149,13 @@ window.W = window.W || {};
}
});
// Provide Marionette event functions on Backgrid's grid
// var myListView = new MarionetteGrid({
// columns: columns,
// collection: scoreCollection
// });
//
var myListView = new W.ScoreListFooView({
collection: scoreCollection
});
// Provide Marionette event functions on Backgrid's paginator
// var myPaginationView = new MarionettePaginator({
// controls : {
// rewind: {
// label: "《",
// title: "First"
// },
// back: {
// label: "〈",
// title: "Previous"
// },
// forward: {
// label: "〉",
// title: "Next"
// },
// fastForward: {
// label: "》",
// title: "Last"
// }
// },
// // If you anticipate a large number of pages, you can adjust
// // the number of page handles to show. The sliding window
// // will automatically show the next set of page handles when
// // you click next at the end of a window.
// windowSize: 20, // Default is 10
// // Used to multiple windowSize to yield a number of pages to slide,
// // in the case the number is 5
// slideScale: 0.25, // Default is 0.5
// // Whether sorting should go back to the first page
// goBackFirstOnSort: false, // Default is true
// collection: scoreCollection
// });
var mySearchPanelView = new W.SearchPanelView({collection: scoreCollection});
this.showChildView('list', myListView);
// this.showChildView('pagination', myPaginationView);
this.showChildView('panel', mySearchPanelView);
scoreCollection.fetch();
......@@ -2305,7 +2182,6 @@ window.W = window.W || {};
regions: {
list: '#list',
pagination: '#pagination',
},
onRender: function () {
......@@ -2328,51 +2204,10 @@ window.W = window.W || {};
});
// var myListView = new MarionetteGrid({
// columns: columns,
// collection: scoreCollection
// });
var myListView = new W.ScoreListFooView({
collection: scoreCollection
});
var myPaginationView = new MarionettePaginator({
controls : {
rewind: {
label: "",
title: "First"
},
back: {
label: "",
title: "Previous"
},
forward: {
label: "",
title: "Next"
},
fastForward: {
label: "",
title: "Last"
}
},
// If you anticipate a large number of pages, you can adjust
// the number of page handles to show. The sliding window
// will automatically show the next set of page handles when
// you click next at the end of a window.
windowSize: 20, // Default is 10
// Used to multiple windowSize to yield a number of pages to slide,
// in the case the number is 5
slideScale: 0.25, // Default is 0.5
// Whether sorting should go back to the first page
goBackFirstOnSort: false, // Default is true
collection: scoreCollection
});
var that = this;
myListView.collection.fetch({
......@@ -2534,10 +2369,6 @@ window.W = window.W || {};
scoreCollection.queryParams.is_featured=true;
// var myListView = new MarionetteGrid({
// columns: columns,
// collection: scoreCollection
// });
var myListView = new W.ScoreListFooView({
collection: scoreCollection
});
......@@ -2562,10 +2393,6 @@ window.W = window.W || {};
scoreCollection2.queryParams.shared_with=true;
// var myListView2 = new MarionetteGrid({
// columns: columns,
// collection: scoreCollection2
// });
var myListView2 = new W.ScoreListFooView({
collection: scoreCollection2
});
......
......@@ -8,8 +8,6 @@
<title>Notation W</title>
<link rel="stylesheet" href="{% static 'playground/vendors/reset.css' %}">
<link rel="stylesheet" href="{% static 'playground/vendors/backgrid.css' %}">
<link rel="stylesheet" href="{% static 'playground/vendors/backgrid-paginator.min.css' %}">
<link rel="stylesheet" href="{% static 'playground/vendors/backbone.autocomplete.css' %}">
{% compress css %}
......@@ -164,9 +162,6 @@
<script src="{% static 'playground/vendors/backbone.marionette.approuter.min.js' %}"></script>
<script src="{% static 'playground/vendors/backbone-relational.min.js' %}"></script>
<script src="{% static 'playground/vendors/backbone.paginator.min.js' %}"></script>
<script src="{% static 'playground/vendors/backgrid.js' %}"></script>
<script src="{% static 'playground/vendors/backgrid-paginator.min.js' %}"></script>
<script src="{% static 'playground/vendors/backgrid-filter.min.js' %}"></script>
<script src="{% static 'playground/vendors/backbone.autocomplete.js' %}"></script>
<script src="{% static 'playground/vendors/moment-with-locales.min.js' %}"></script>
<script src="{% static 'playground/vendors/jquery-ui.min.js' %}"></script>
......
<div class="scores content">
<h1><%- t('Partitions existantes') %></h1>
<div id="list"></div>
<div id="pagination"></div>
</div>
<div id="search-panel" class="score-filters panel panel--right"></div>
......
<h2>Partitions partagées avec vous</h2>
<div id="list"></div>
<div id="pagination"></div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment