/**
 * Created by Benny on 14.11.2014.
 */

"use strict";

var TB = TB || {};

TB.Ext = TB.Ext || {};

/**
 * Notification system
 * Currently using http://ericprieto.com/freebie/simply-toast/
 * @type {{TYPE_DANGER: number, TYPE_WARNING: number, TYPE_INFO: number, TYPE_SUCCESS: number, init: Function, show: Function}}
 */
TB.Ext.Notification = {

    TYPE_DANGER : 4,
    TYPE_WARNING : 3,
    TYPE_INFO : 0,
    TYPE_SUCCESS : 1,

    init : function() {
        // Refer: http://codeseven.github.io/toastr/demo.html
        toastr.options = {
            "closeButton": false,
            "debug": false,
            "progressBar": false,
            "positionClass": "toast-top-center",
            "onclick": null,
            "showDuration": "300",
            "hideDuration": "1000",
            "timeOut": "2000",
            "extendedTimeOut": "1000",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut"
        }
    },

    show : function( txt, typeCode ) {
        var type = 'info';
        switch( typeCode ) {
            case 4:
                type = 'error';
            break;

            case 3:
                type = 'warning';
            break;

            case 1:
                type = 'success';
            break;

            default:
                type = 'info';
            break;
        }

        toastr[ type ]( txt );
    }

};