Emails Library
This library contains all the admin/emails page common functionality and is used by the page controllers. You might also use this library in other pages where you need to trigger specific email operations in the server.
You will need to provide the full URL in order to load this library as a dependency to a module:
gx.controller.module(
'my_custom_page',
[
gx.source + '/libs/emails'
],
function(data) {
// Module code ...
});
Required Translation Sections: 'admin_labels', 'buttons', 'db_backup', 'emails', 'lightbox_buttons', 'messages'
Methods
(static) colorizeButtonsForEditMode(event, ui)
Colorizes modal buttons for the edit mode
jQuery UI does not support direct addition of classes to the dialog buttons, so we need to apply the classes during the "create" event of the dialog.
Parameters:
Name | Type | Description |
---|---|---|
event |
event | Event to trigger this function. |
ui |
object | Dialog UI. |
(static) colorizeButtonsForPreviewMode(event, ui)
Colorizes modal buttons for preview mode
jQuery UI does not support direct addition of classes to the dialog buttons, so we need to apply the classes during the "create" event of the dialog.
Parameters:
Name | Type | Description |
---|---|---|
event |
object | Event to trigger this function. |
ui |
object | Dialog UI. |
(static) deleteCollection(collection, ajaxUrl) → {object}
Deletes an email collection
Provide an array of email objects and this method will delete them to the requested URL through AJAX POST. You can omit the url and the default EmailsController will be used.
Parameters:
Name | Type | Description |
---|---|---|
collection |
array | Array of email objects. |
ajaxUrl |
string | (optional) The AJAX URL for the POST request. |
Returns:
Returns a promise object that will provide the server's response.
- Type
- object
(static) deleteOldAttachments(removalDate, ajaxUrl) → {object}
Deletes old attachments from selected removal date and before.
Parameters:
Name | Type | Description |
---|---|---|
removalDate |
date | The date when the removal should start. |
ajaxUrl |
object | (optional) Specific ajaxUrl to be used for the request. |
Returns:
Returns a promise object to be used when the requests ends.
- Type
- object
(static) deleteOldEmails(removalDate, ajaxUrl) → {object}
Deletes old emails from selected removal date and before.
Parameters:
Name | Type | Description |
---|---|---|
removalDate |
string | The date when the removal should start. |
ajaxUrl |
object | (optional) Specific ajaxUrl to be used for the request. |
Returns:
Returns a promise object to be used when the requests ends.
- Type
- object
(static) getAttachmentsSize($target, ajaxUrl) → {object}
Returns the attachments size in MB and refreshes the UI.
This method will make a GET request to the server in order to fetch and display the total attachments size, so that users know when it is time to remove old attachments.
Parameters:
Name | Type | Description |
---|---|---|
$target |
object | jQuery selector for the element to contain the size info. |
ajaxUrl |
string | (optional) Specific ajaxUrl to be used for the request. |
Returns:
Returns the promise object for chaining callbacks.
- Type
- object
(static) getDefaultModalButtons($modal, $table) → {object}
Returns default modal buttons
Used by various sections of the admin/emails page. With the proper use of valueMapping object you can use this method in other pages too.
Parameters:
Name | Type | Description |
---|---|---|
$modal |
object | jQuery selector for the modal. |
$table |
object | jQuery selector for the main table. |
Returns:
Returns the dialog modal buttons.
- Type
- object
(static) getEmailFromModal($modal) → {object}
Returns the email information from modal (DOM).
The method will grab the values from the modal and bundle them in a single object. The returned object will have the same structure as the valueMapping object. This method is recursive.
Parameters:
Name | Type | Description |
---|---|---|
$modal |
object | jQuery selector for the modal. |
Returns:
Returns the email data of the modal.
- Type
- object
(static) getPreviewModalButtons($modal, $table) → {object}
Returns preview modal buttons
This method will return the preview modal buttons for the jQuery UI dialog widget. With the proper use of valueMapping object you can use this method in other pages too.
Parameters:
Name | Type | Description |
---|---|---|
$modal |
object | jQuery selector for the modal. |
$table |
object | jQuery selector for the main table. |
Returns:
Returns the dialog modal buttons.
- Type
- object
(static) getSelectedEmails($table) → {array}
Returns an object array with the selected emails of the main emails table.
Parameters:
Name | Type | Description |
---|---|---|
$table |
object | (optional) The main table selector, if omitted the "#emails-table" selector will be used. |
Returns:
Returns an array with the emails data (collection).
- Type
- array
(static) loadEmailOnModal(email, $modal)
Loads email data on modal (DOM).
Parameters:
Name | Type | Description |
---|---|---|
email |
object | Contains the email data. |
$modal |
object | jQuery selector for the modal. |
(static) queueCollection(collection, ajaxUrl) → {object}
Queues the email collection
Provide an array of email objects and this method will queue them to the requested URL through AJAX POST. You can omit the url and the default EmailsController will be used.
Parameters:
Name | Type | Description |
---|---|---|
collection |
array | Array of email objects. |
ajaxUrl |
string | (optional) The AJAX URL for the POST request. |
Returns:
Returns a promise object that will provide the server's response.
- Type
- object
(static) resetModal($modal)
Reset Modal (DOM)
This method will reset the emails modal back to its initial state. The default modal markup is used in the admin/emails page, but this method can work without all the elements too.
Parameters:
Name | Type | Description |
---|---|---|
$modal |
object | jQuery selector for the modal. |
(static) sendCollection(collection, ajaxUrl) → {object}
Sends an email collection
Provide an array of email objects and this method will send them to the requested URL through AJAX POST. You can omit the url and the default EmailsController will be used.
Parameters:
Name | Type | Description |
---|---|---|
collection |
array | Array of email objects. |
ajaxUrl |
string | (optional) The AJAX URL for the POST request. |
Returns:
Returns a promise object that will provide the server's response.
- Type
- object
(static) updateTabCounters($modal, $contactsTable, $contactsTab, $attachmentsTable, $attachmentsTab)
Updates modal tabs counters.
Displays item number on tabs so that users know how many items there are included in the contacts and attachments tables.
Parameters:
Name | Type | Description |
---|---|---|
$modal |
object | The modal selector to be updated. |
$contactsTable |
object | (optional) The contacts table selector, default selector: '#contacts-table'. |
$contactsTab |
object | (optional) The contacts tab selector, default selector: '.tab-headline.bcc-cc'. |
$attachmentsTable |
object | (optional) The attachments table selector, default selector: '#attachments-table'. |
$attachmentsTab |
object | (optional) The attachments tab selector, default selector: '.tab-headline.attachments'. |