Skip to content

Commit

Permalink
Moved sidebar to search D&D logic
Browse files Browse the repository at this point in the history
  • Loading branch information
bnvk committed Oct 23, 2014
1 parent 3b64659 commit 7f7ad67
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
1 change: 1 addition & 0 deletions static/default/html/jsapi/search/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Mailpile.Search.init = function() {

// Drag Items
Mailpile.Search.UI.Draggable();
Mailpile.Search.UI.ResultDropable();


// Render Display Size
Expand Down
31 changes: 31 additions & 0 deletions static/default/html/jsapi/search/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,34 @@ Mailpile.Search.UI.Draggable = function() {
});
};


Mailpile.Search.UI.ResultDropable = function() {

$('#pile-results tr').droppable({
accept: 'a.sidebar-tag',
hoverClass: 'result-hover',
tolerance: 'pointer',
drop: function(event, ui) {

// Update Cache
Mailpile.bulk_cache_add('messages_cache', $(event.target).data('mid'));

// Save Update
Mailpile.API.tag_post({ add: ui.draggable.data('tid'), mid: Mailpile.messages_cache }, function() {

var tag = _.findWhere(Mailpile.instance.tags, { tid: ui.draggable.data('tid').toString() });
var hex = Mailpile.theme.colors[tag.label_color];
var updated = [];

// Update Multiple Selected Messages
if (Mailpile.messages_cache.length > 0) {
$.each(Mailpile.messages_cache, function(key, mid) {
updated.push(mid);
$('#pile-message-' + mid).find('td.subject span.item-tags').append('<span class="pile-message-tag" style="color: ' + hex + ';"><span class="pile-message-tag-icon ' + tag.icon + '"></span> <span class="pile-message-tag-name">' + tag.name + '</span></span>');
});
}
});
}
});

};
27 changes: 0 additions & 27 deletions static/default/html/jsapi/ui/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,31 +152,4 @@ $(document).ready(function() {
});


$('#pile-results tr').droppable({
accept: 'a.sidebar-tag',
hoverClass: 'result-hover',
tolerance: 'pointer',
drop: function(event, ui) {

// Update Cache
Mailpile.bulk_cache_add('messages_cache', $(event.target).data('mid'));

// Save Update
Mailpile.API.tag_post({ add: ui.draggable.data('tid'), mid: Mailpile.messages_cache }, function() {

var tag = _.findWhere(Mailpile.instance.tags, { tid: ui.draggable.data('tid').toString() });
var hex = Mailpile.theme.colors[tag.label_color];
var updated = [];

// Update Multiple Selected Messages
if (Mailpile.messages_cache.length > 0) {
$.each(Mailpile.messages_cache, function(key, mid) {
updated.push(mid);
$('#pile-message-' + mid).find('td.subject span.item-tags').append('<span class="pile-message-tag" style="color: ' + hex + ';"><span class="pile-message-tag-icon ' + tag.icon + '"></span> <span class="pile-message-tag-name">' + tag.name + '</span></span>');
});
}
});
}
});

});

0 comments on commit 7f7ad67

Please sign in to comment.