mirror of
https://github.com/wassname/HackFlowy.git
synced 2026-06-27 16:00:04 +08:00
Merge branch 'master' into gh-pages
Conflicts: javascripts/vendor/custom.modernizr.js javascripts/vendor/zepto.js mockup.html stylesheets/normalize.css
This commit is contained in:
@@ -21,23 +21,33 @@ localforageBackbone
|
||||
initialize: function(){
|
||||
// update order on add, remove.
|
||||
// Ref: http://stackoverflow.com/a/11665085/221742
|
||||
this.on('add remove', this.updateModelPriority);
|
||||
this.on('add remove sort', this.updateModelPriority);
|
||||
},
|
||||
|
||||
/**
|
||||
* Move a model in the list up. Only a sort event is emitted
|
||||
* @param {Backbone.Model} model - Model to be moved
|
||||
*/
|
||||
moveUp: function(model) { // I see move up as the -1
|
||||
var index = this.indexOf(model);
|
||||
if (index > 0) {
|
||||
this.remove(model, {silent: true}); // silence this to stop excess event triggers
|
||||
this.add(model, {at: index-1});
|
||||
this.remove(model, {silent: true});
|
||||
this.add(model, {at: index-1, silent: true});
|
||||
}
|
||||
this.trigger('sort', this, {});
|
||||
},
|
||||
|
||||
/**
|
||||
* Move a model in the list up. Only a sort event is emitted
|
||||
* @param {Backbone.Model} model - Model to be moved
|
||||
*/
|
||||
moveDown: function(model) { // I see move up as the -1
|
||||
var index = this.indexOf(model);
|
||||
if (index < this.models.length) {
|
||||
this.remove(model, {silent: true}); // silence this to stop excess event triggers
|
||||
this.add(model, {at: index+1});
|
||||
this.remove(model, {silent: true});
|
||||
this.add(model, {at: index+1, silent: true});
|
||||
}
|
||||
this.trigger('sort', this, {});
|
||||
},
|
||||
|
||||
/** Updated priority of each member of list **/
|
||||
|
||||
Reference in New Issue
Block a user