Sha256: a5dc43cf94255db7994f6e9b8d78dcef8557a789df27484ecf823dea73c2635e

Contents?: true

Size: 1.95 KB

Versions: 39

Compression:

Stored size: 1.95 KB

Contents

/**
* Theme: Ubold Admin Template
* Author: Coderthemes
* Chat application 
*/

!function($) {
    "use strict";

    var ChatApp = function() {
        this.$body = $("body"),
        this.$chatInput = $('.chat-input'),
        this.$chatList = $('.conversation-list'),
        this.$chatSendBtn = $('.chat-send .btn')
    };

    //saves chat entry - You should send ajax call to server in order to save chat enrty
    ChatApp.prototype.save = function() {
        var chatText = this.$chatInput.val();
        var chatTime = moment().format("h:mm");
        if (chatText == "") {
            sweetAlert("Oops...", "You forgot to enter your chat message", "error");
            this.$chatInput.focus();
        } else {
            $('<li class="clearfix"><div class="chat-avatar"><img src="assets/images/avatar-1.jpg" alt="male"><i>' + chatTime + '</i></div><div class="conversation-text"><div class="ctext-wrap"><i>John Deo</i><p>' + chatText + '</p></div></div></li>').appendTo('.conversation-list');
            this.$chatInput.val('');
            this.$chatInput.focus();
            this.$chatList.scrollTo('100%', '100%', {
                easing: 'swing'
            });
        }
    },
    ChatApp.prototype.init = function () {
        var $this = this;
        //binding keypress event on chat input box - on enter we are adding the chat into chat list - 
        $this.$chatInput.keypress(function (ev) {
            var p = ev.which;
            if (p == 13) {
                $this.save();
                return false;
            }
        });


        //binding send button click
        $this.$chatSendBtn.click(function (ev) {
           $this.save();
           return false;
        });
    },
    //init ChatApp
    $.ChatApp = new ChatApp, $.ChatApp.Constructor = ChatApp
    
}(window.jQuery),

//initializing main application module
function($) {
    "use strict";
    $.ChatApp.init();
}(window.jQuery);

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
wbase-0.3.20 lib/vendor/admin/jquery.chat.js
wbase-0.3.19 lib/vendor/admin/jquery.chat.js
wbase-0.3.18 lib/vendor/admin/jquery.chat.js
wbase-0.3.17 lib/vendor/admin/jquery.chat.js
wbase-0.3.16 lib/vendor/admin/jquery.chat.js
wbase-0.3.15 lib/vendor/admin/jquery.chat.js
wbase-0.3.14 lib/vendor/admin/jquery.chat.js
wbase-0.3.13 lib/vendor/admin/jquery.chat.js
wbase-0.3.12 lib/vendor/admin/jquery.chat.js
wbase-0.3.11 lib/vendor/admin/jquery.chat.js
wbase-0.3.10 lib/vendor/admin/jquery.chat.js
wbase-0.3.9 lib/vendor/admin/jquery.chat.js
wbase-0.3.8 lib/vendor/admin/jquery.chat.js
wbase-0.3.7 lib/vendor/admin/jquery.chat.js
wbase-0.3.6 lib/vendor/admin/jquery.chat.js
wbase-0.3.5 lib/vendor/admin/jquery.chat.js
wbase-0.3.4 lib/vendor/admin/jquery.chat.js
wbase-0.3.3 lib/vendor/admin/jquery.chat.js
wbase-0.3.2 lib/vendor/admin/jquery.chat.js
wbase-0.3.1 lib/vendor/admin/jquery.chat.js