This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createSongItenView(id) { | |
| var itemView = $('<li>').addClass('song') | |
| .data('id', id).find('.download') | |
| .click(function() { | |
| panel.download($(this).parent().data('id')); | |
| }); | |
| return listView; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var SongItemView = Backbone.View.extend({ | |
| template: 'song/item', | |
| className: 'song', | |
| events: { | |
| 'click .download': download | |
| }, | |
| donwload: function() { | |
| panel.download(this.model.get('id')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'libs/underscore.deferred': { | |
| deps: ['lodash', 'zepto'], | |
| exports: '_', | |
| init: function() { | |
| $.Deferred = _.Deferred; | |
| $.when = _.when; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scrollTo: function(ms) { | |
| // ... | |
| // find current line | |
| var line = -1; | |
| $.each(this.data('parsed'), function(i, item) { | |
| if (item[0] > ms) { | |
| return false; | |
| } | |
| line = i; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _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]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _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), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _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), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scrollTo: _.throttle(function(ms) { | |
| // ... | |
| // find current line | |
| var line = this._findLine(ms); | |
| //... | |
| }, 500) |