Skip to content

Instantly share code, notes, and snippets.

function createSongItenView(id) {
var itemView = $('<li>').addClass('song')
.data('id', id).find('.download')
.click(function() {
panel.download($(this).parent().data('id'));
});
return listView;
}
var SongItemView = Backbone.View.extend({
template: 'song/item',
className: 'song',
events: {
'click .download': download
},
donwload: function() {
panel.download(this.model.get('id'));
.background-size(@size) {
// -webkit-background-size: @size !important;
background-size: @size;
}
.player-btn-bg(@name, @size, @x: 0, @y: 0) {
.square(@size);
.background-size(@size);
background: url('@{imgPath}/ui/player/@{name}.png') no-repeat @x @y;
&.on {
var navigate = app.router.navigate,
clearCurrentViews = function() {
_.each(_currentViews, function(view) {
view.unbind();
if (view.model instanceof Backbone.Model) {
view.model.off(null, null, view);
}
if (view.collection instanceof Backbone.Collection) {
view.collection.off(null, null, view);
'libs/underscore.deferred': {
deps: ['lodash', 'zepto'],
exports: '_',
init: function() {
$.Deferred = _.Deferred;
$.when = _.when;
}
}
scrollTo: function(ms) {
// ...
// find current line
var line = -1;
$.each(this.data('parsed'), function(i, item) {
if (item[0] > ms) {
return false;
}
line = i;
});
_findLine: function(ms) {
var parsed = this.data('parsed');
if (!parsed || !parsed.length) return -1;
var head = 0,
tail = parsed.length,
mid = Math.floor(tail / 2);
if (ms < parsed[0][0]) {
_findLine: function(ms) {
var parsed = this.data('parsed');
if (!parsed || !parsed.length) {
return -1;
}
var head = 0,
tail = parsed.length,
mid = Math.floor(tail / 2),
_findLine: function(ms) {
var parsed = this.data('parsed');
if (!parsed || !parsed.length) {
return -1;
}
var head = 0,
tail = parsed.length,
mid = Math.floor(tail / 2),
scrollTo: _.throttle(function(ms) {
// ...
// find current line
var line = this._findLine(ms);
//...
}, 500)