Skip to content

Commit

Permalink
Moved where JS things get instantiated, for moar bettah-ness #594
Browse files Browse the repository at this point in the history
  • Loading branch information
bnvk committed Oct 16, 2014
1 parent 83d9c85 commit 9e91cfa
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 58 deletions.
4 changes: 3 additions & 1 deletion static/default/html/jsapi/index-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
{% include("jsapi/crypto/gpg.js") %}

/* JS - Compose */
{% include("jsapi/compose/init.js") %}
{% include("jsapi/compose/crypto.js") %}
{% include("jsapi/compose/autosave.js") %}
{% include("jsapi/compose/attachments.js") %}
{% include("jsapi/compose/content.js") %}
{% include("jsapi/compose/recipients.js") %}
{% include("jsapi/compose/tooltips.js") %}
{% include("jsapi/compose/events.js") %}
{% include("jsapi/compose/ui.js") %}

/* JS - Contacts */
Expand Down
6 changes: 6 additions & 0 deletions static/default/html/partials/compose.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,9 @@
<input id="compose-signature" type="hidden" value="">
<input id="compose-encryption" type="hidden" value="">
</form>
<script>
$(document).ready(function() {
console.log('yo dawg');
Mailpile.compose_init('{{mid}}');
});
</script>
57 changes: 57 additions & 0 deletions static/default/html/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,61 @@
<script src="/static/js/libraries.min.js"></script>
{% if state.command_url not in ("/auth/login/", "/auth/logout/") %}
<script src="/api/0/jsapi/as.js"></script>
{% if state.command_url in ("/message/draft/", "/message/") %}
<script src="/static/js/plupload.full.min.js"></script>
{% endif %}
<script>
{% if result.data and result.data.addresses %}
{% set addresses_json = result.data.addresses|json %}
{% endif %}
{% if result.data and result.data.messages %}
{% set messages_json = result.data.messages|json %}
{% endif %}
{% if result.data and result.data.metadata %}
{% set metadata_json = result.data.metadata|json %}
{% endif %}
$(document).ready(function() {

// Start It
Mailpile.render();

// Print JSON for JS Use
Mailpile.instance = {
"command": "{{ command }}",
"state": {{state|json|safe}},
"args": "{{ args }}",
"addresses": {% if result.data and result.data.addresses %}{{ addresses_json|safe }}{% else %}{}{% endif %},
"messages": {% if result.data and result.data.messages %}{{ messages_json|safe }}{% else %}{}{% endif %},
"metadata": {% if result.data and result.data.metadata %}{{ metadata_json|safe }}{% else %}{}{% endif %},
"search_tag_ids": {% if result.search_tag_ids %}{{result.search_tag_ids|safe }}{% else %}[]{% endif %},
"search_addresses": []
};

// Nagifications
{% if show_nagification(config.web.nag_backup_key) %}
Mailpile.notification({
status: 'warning',
message: '{{_("Back up your encryption key & passphrase")}}',
type: 'nagify',
action: '/settings/backup-keys.html'
});
{% endif %}

// HTML5 Browser Notifications
if (Notification.permission == "granted") {
$('#notifications-permission-option').text("{{_("Browser notifications allowed")}}")
}

$('#notifications-permission-option').click(function() {
Notification.requestPermission();
});

});

/* Plugins */
$(document).ready(
{{ui_elements_setup('.plugin-activity-%(name)s', get_ui_elements('activities', state, '/'))}}
);
</script>
<script src="/api/0/jsapi/app.js"></script>
{% endif %}
58 changes: 1 addition & 57 deletions static/default/html/partials/javascript.html
Original file line number Diff line number Diff line change
@@ -1,57 +1 @@
{% if state.command_url in ("/message/draft/", "/message/") %}
<script src="/static/js/plupload.full.min.js"></script>
{% endif %}
<script>
{% if result.data and result.data.addresses %}
{% set addresses_json = result.data.addresses|json %}
{% endif %}
{% if result.data and result.data.messages %}
{% set messages_json = result.data.messages|json %}
{% endif %}
{% if result.data and result.data.metadata %}
{% set metadata_json = result.data.metadata|json %}
{% endif %}
$(document).ready(function() {

// Start It
Mailpile.render();

// Print JSON for JS Use
Mailpile.instance = {
"command": "{{ command }}",
"state": {{state|json|safe}},
"args": "{{ args }}",
"addresses": {% if result.data and result.data.addresses %}{{ addresses_json|safe }}{% else %}{}{% endif %},
"messages": {% if result.data and result.data.messages %}{{ messages_json|safe }}{% else %}{}{% endif %},
"metadata": {% if result.data and result.data.metadata %}{{ metadata_json|safe }}{% else %}{}{% endif %},
"search_tag_ids": {% if result.search_tag_ids %}{{result.search_tag_ids|safe }}{% else %}[]{% endif %},
"search_addresses": []
};

// Nagifications
{% if show_nagification(config.web.nag_backup_key) %}
Mailpile.notification({
status: 'warning',
message: '{{_("Back up your encryption key & passphrase")}}',
type: 'nagify',
action: '/settings/backup-keys.html'
});
{% endif %}

// HTML5 Browser Notifications
if (Notification.permission == "granted") {
$('#notifications-permission-option').text("{{_("Browser notifications allowed")}}")
}

$('#notifications-permission-option').click(function() {
Notification.requestPermission();
});

});

/* Plugins */
$(document).ready(
{{ui_elements_setup('.plugin-activity-%(name)s', get_ui_elements('activities', state, '/'))}}
);
</script>
<script src="/api/0/jsapi/app.js"></script>
<!-- Javscript - just a lonely, empty file where there used to be some JS... might reuse -->

0 comments on commit 9e91cfa

Please sign in to comment.