/*
* Title                   : Pinpoint Booking System WordPress Plugin (PRO)
* Version                 : 2.1.2
* File                    : assets/js/emails/backend-emails.js
* File Version            : 1.0.4
* Created / Last Modified : 11 October 2015
* Author                  : Dot on Paper
* Copyright               : © 2012 Dot on Paper
* Website                 : http://www.dotonpaper.net
* Description             : Back end emails JavaScript class.
*/

var DOPBSPBackEndEmails = new function(){
    'use strict';

    /*
     * Private variables.
     */
    var $ = jQuery.noConflict();

    /*
     * Constructor
     */
    this.__construct = function(){
    };

    /*
     * Display emails list.
     */
    this.display = function(){
        DOPBSPBackEnd.clearColumns(1);
        DOPBSPBackEnd.toggleMessages('active',
                                     DOPBSPBackEnd.text('MESSAGES_LOADING'));

        $.post(ajaxurl,
               {
                   action: 'dopbsp_emails_display',
                   nonce : DOPBSP_user_nonce
               },
               function(data){
                   $('#DOPBSP-column1 .dopbsp-column-content')
                   .html(data);
                   $('.DOPBSP-admin .dopbsp-main')
                   .css('display',
                        'block');
                   DOPBSPBackEnd.toggleMessages('success',
                                                DOPBSPBackEnd.text('EMAILS_LOAD_SUCCESS'));
               })
         .fail(function(data){
             DOPBSPBackEnd.toggleMessages('error',
                                          data.status+': '+data.statusText);
         });
    };

    return this.__construct();
};