app-message-box.ctrl.js 1.86 KB
Newer Older
eddie.woo's avatar
eddie.woo committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
/// <reference path="../../../Scripts/underscore.js" />
/// <reference path="../../common/utils/enums.js" />
/// <reference path="../nav-bar-util.js" />

// AppNavBarController controller for the navigation bar of the application. This controller is responsible for 
// manage the different types of the tabs and corresponding menus.
frameworkModule.controller('AppMessageBoxController', ['$scope', '$log',
function ($scope, $log) {
        'use strict';
        $log.debug('AppNavController.ctor()...');          

        var mlist = [];
        $scope.size = 0;

        var addMessage = function (Title, Message, Content, CssClass) {
            mlist.push({ message: Message , title: Title ,content: Content , cssClass: CssClass });
            $scope.messageList = mlist;
            $scope.size = mlist.length;
        };

        

        // Just test code

        (function initialize() {
            

            // Reference the auto-generated proxy for the hub.
            var chat = $.connection.messageBoxHub;
            // Create a function that the hub can call back to display messages.

            chat.client.addNewMessageToPage = function (title, message, cssClass) {

                //Add the message to the page.
                var content = message;

                if(message.length > 20){
                    message = message.substring(0, 19) + '...';
                    cssClass += ' cursorpointer';
                }

                $('.cursorpointer').popover({ placement: "right", container: 'body' });

                addMessage(title, message, content, cssClass);
                $scope.$apply();
            };

            $.connection.hub.start().done(function () {              
                // Call the Send method on the hub.
                chat.server.send('hello', 'test Info', 'alert-info');
            });


           

        })();
    }
]);