mirror of
https://github.com/bodyrep/bodyrep-sandpit.git
synced 2026-01-25 14:21:40 +00:00
Style updates
Removed chosen & tasty pie hack
This commit is contained in:
@@ -1,104 +0,0 @@
|
|||||||
(function($, _, Backbone) {
|
|
||||||
Backbone.Tastypie = {
|
|
||||||
defaultLimit: 20
|
|
||||||
};
|
|
||||||
|
|
||||||
Backbone.Tastypie.Model = Backbone.Model.extend({
|
|
||||||
idAttribute: 'resource_uri',
|
|
||||||
|
|
||||||
url: function() {
|
|
||||||
var url = getValue(this, 'urlRoot') || getValue(this.collection, 'urlRoot') || urlError();
|
|
||||||
|
|
||||||
if (this.isNew())
|
|
||||||
return url;
|
|
||||||
|
|
||||||
return this.get('resource_uri');
|
|
||||||
},
|
|
||||||
_getId: function() {
|
|
||||||
if (this.has('id'))
|
|
||||||
return this.get('id');
|
|
||||||
|
|
||||||
return _.chain(this.get('resource_uri').split('/')).compact().last().value();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Backbone.Tastypie.Collection = Backbone.Collection.extend({
|
|
||||||
constructor: function(models, options) {
|
|
||||||
Backbone.Collection.prototype.constructor.apply(this, arguments);
|
|
||||||
|
|
||||||
this.meta = {};
|
|
||||||
this.filters = {
|
|
||||||
limit: Backbone.Tastypie.defaultLimit,
|
|
||||||
offset: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
if (options && options.filters)
|
|
||||||
_.extend(this.filters, options.filters);
|
|
||||||
},
|
|
||||||
url: function(models) {
|
|
||||||
var url = this.urlRoot;
|
|
||||||
|
|
||||||
if (models) {
|
|
||||||
var ids = _.map(models, function(model) {
|
|
||||||
return model._getId();
|
|
||||||
});
|
|
||||||
|
|
||||||
url += 'set/' + ids.join(';') + '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
return url + this._getQueryString();
|
|
||||||
},
|
|
||||||
parse: function(response) {
|
|
||||||
if (response && response.meta)
|
|
||||||
this.meta = response.meta;
|
|
||||||
|
|
||||||
return response && response.objects;
|
|
||||||
},
|
|
||||||
fetchNext: function(options) {
|
|
||||||
options = options || {};
|
|
||||||
options.add = true;
|
|
||||||
|
|
||||||
this.filters.limit = this.meta.limit;
|
|
||||||
this.filters.offset = this.meta.offset + this.meta.limit;
|
|
||||||
|
|
||||||
if (this.filters.offset > this.meta.total_count)
|
|
||||||
this.filters.offset = this.meta.total_count;
|
|
||||||
|
|
||||||
return this.fetch.call(this, options);
|
|
||||||
},
|
|
||||||
fetchPrevious: function(options) {
|
|
||||||
options = options || {};
|
|
||||||
options.add = true;
|
|
||||||
options.at = 0;
|
|
||||||
|
|
||||||
this.filters.limit = this.meta.limit;
|
|
||||||
this.filters.offset = this.meta.offset - this.meta.limit;
|
|
||||||
|
|
||||||
if (this.filters.offset < 0){
|
|
||||||
this.filters.limit += this.filters.offset;
|
|
||||||
this.filters.offset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.fetch.call(this, options);
|
|
||||||
},
|
|
||||||
_getQueryString: function() {
|
|
||||||
if (!this.filters)
|
|
||||||
return '';
|
|
||||||
|
|
||||||
return '?' + $.param(this.filters);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Helper function from Backbone to get a value from a Backbone
|
|
||||||
// object as a property or as a function.
|
|
||||||
var getValue = function(object, prop) {
|
|
||||||
if ((object && object[prop]))
|
|
||||||
return _.isFunction(object[prop]) ? object[prop]() : object[prop];
|
|
||||||
};
|
|
||||||
|
|
||||||
// Helper function from Backbone that raises error when a model's
|
|
||||||
// url cannot be determined.
|
|
||||||
var urlError = function() {
|
|
||||||
throw new Error('A "url" property or function must be specified');
|
|
||||||
};
|
|
||||||
})(window.$, window._, window.Backbone);
|
|
||||||
@@ -23,9 +23,8 @@
|
|||||||
<link rel="stylesheet" href="/s/css/bootstrap-responsive.css" />
|
<link rel="stylesheet" href="/s/css/bootstrap-responsive.css" />
|
||||||
|
|
||||||
<link rel="stylesheet" href="/s/css/jquery-ui.css" />
|
<link rel="stylesheet" href="/s/css/jquery-ui.css" />
|
||||||
<link rel="stylesheet" href="/s/css/site.css" />
|
<link rel="stylesheet" href="/s/css/site.css" />
|
||||||
|
|
||||||
<link rel="stylesheet" href="/s/css/chosen.css" />
|
|
||||||
<script type="text/javascript" src="/s/js/LAB.js"></script>
|
<script type="text/javascript" src="/s/js/LAB.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var loadb;
|
var loadb;
|
||||||
@@ -34,8 +33,6 @@
|
|||||||
.script("/s/js/application.js")
|
.script("/s/js/application.js")
|
||||||
.script("/s/js/underscore.js")
|
.script("/s/js/underscore.js")
|
||||||
.script("/s/js/backbone.js")
|
.script("/s/js/backbone.js")
|
||||||
.script("/s/js/backbone-tastypie.js")
|
|
||||||
.script("/s/js/jquery.chosen.min.js")
|
|
||||||
.script("/s/js/bootstrap.js").wait(function() {
|
.script("/s/js/bootstrap.js").wait(function() {
|
||||||
clearTimeout(loadb);
|
clearTimeout(loadb);
|
||||||
$('#loadmast').hide();
|
$('#loadmast').hide();
|
||||||
@@ -47,7 +44,7 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id='mast' class='hidden'>
|
<div id='mast' class='hidden'>
|
||||||
<div class="container-fluid symfony-content">
|
<div class="container-fluid symfony-content">
|
||||||
|
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
<hr>
|
<hr>
|
||||||
@@ -58,7 +55,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='loadmast'><img align="absmiddle" style="margin-left: 10px; margin-bottom: 3px;" src="/s/img/progress.gif"> Loading</div>
|
<div id='loadmast'><img align="absmiddle" style="margin-left: 10px; margin-bottom: 3px;" src="/s/img/progress.gif" /> Loading</div>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user