-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved more JS from .ready to Mailpile.UI.init
- Loading branch information
Showing
5 changed files
with
99 additions
and
104 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,100 @@ | ||
/* UI */ | ||
|
||
Mailpile.UI = { | ||
ModalOptions: { backdrop: true, keyboard: true, show: true, remote: false } | ||
ModalOptions: { backdrop: true, keyboard: true, show: true, remote: false }, | ||
SidebarDroppableOptions: { | ||
accept: ['td.draggable', 'div.thread-draggable'], | ||
activeClass: 'sidebar-tags-draggable-hover', | ||
hoverClass: 'sidebar-tags-draggable-active', | ||
tolerance: 'pointer', | ||
over: function(event, ui) { | ||
var tid = $(this).find('a').data('tid'); | ||
setTimeout(function() { | ||
//Mailpile.ui_sidebar_toggle_subtags(tid, 'open'); | ||
}, 500); | ||
}, | ||
out: function(event, ui) { | ||
var tid = $(this).find('a').data('tid'); | ||
setTimeout(function() { | ||
//Mailpile.ui_sidebar_toggle_subtags(tid, 'close'); | ||
}, 1000); | ||
}, | ||
drop: function(event, ui) { | ||
|
||
var tid = $(this).find('a').data('tid'); | ||
|
||
// Add MID to Cache | ||
Mailpile.bulk_cache_add('messages_cache', ui.draggable.parent().data('mid')); | ||
|
||
// Add / Delete | ||
if (Mailpile.instance.state.command_url == '/message/') { | ||
var tags_delete = ['inbox']; | ||
} else { | ||
var tags_delete = Mailpile.instance.search_tag_ids; | ||
} | ||
|
||
Mailpile.API.tag_post({ add: tid, del: tags_delete, mid: Mailpile.messages_cache}, function(result) { | ||
|
||
// Show | ||
Mailpile.notification(result); | ||
|
||
// Update Pile View | ||
if (Mailpile.instance.state.command_url == '/search/') { | ||
$.each(Mailpile.messages_cache, function(key, mid) { | ||
$('#pile-message-' + mid).fadeOut('fast'); | ||
}); | ||
|
||
// Empty Bulk Cache | ||
Mailpile.messages_cache = []; | ||
|
||
// Update Bulk UI | ||
Mailpile.bulk_actions_update_ui(); | ||
|
||
// Hide Collapsible | ||
Mailpile.ui_sidebar_toggle_subtags(tid, 'close'); | ||
|
||
} else { | ||
// FIXME: this action is up for discussion | ||
// Github Issue - https://github.com/pagekite/Mailpile/issues/794 | ||
window.location.href = '/in/inbox/'; | ||
} | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
|
||
Mailpile.UI.init = function() { | ||
|
||
|
||
/* Make search items draggable to sidebar */ | ||
$('li.sidebar-tags-draggable').droppable(Mailpile.sidebar_tags_droppable_opts); | ||
$('li.sidebar-tags-draggable').droppable(Mailpile.UI.SidebarDroppableOptions); | ||
|
||
|
||
// Favicon | ||
var inbox = _.findWhere(Mailpile.instance.tags, {slug: 'inbox'}); | ||
var favicon = new Favico({animation:'popFade'}); | ||
favicon.badge(inbox.stats.new); | ||
|
||
// Show Typeahead | ||
Mailpile.activities.render_typeahead(); | ||
|
||
// Start Eventlog | ||
//EventLog.init(); | ||
setTimeout(function() { | ||
|
||
// make event log start async (e.g. for proper page load event handling) | ||
EventLog.timer = $.timer(); | ||
EventLog.timer.set({ time : 22500, autostart : false }); | ||
EventLog.poll(); | ||
|
||
// Run Composer Autosave | ||
if (Mailpile.instance.state.context_url === '/message/' || | ||
Mailpile.instance.state.context_url === '/message/draft/') { | ||
Mailpile.Composer.AutosaveTimer.play(); | ||
Mailpile.Composer.AutosaveTimer.set({ time : 20000, autostart : true }); | ||
} | ||
|
||
}, 1000); | ||
|
||
}; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
<!-- Javscript - just a lonely, empty file where there used to be some JS... might reuse --> | ||
<script> | ||
$(document).ready(function() { | ||
|
||
// Start It | ||
Mailpile.render(); | ||
|
||
Mailpile.UI.init(); | ||
|
||
}); | ||
</script> |