(function() {
    'use strict';

    angular
        .module('appMessage')
        .directive('qrcode', Directive);
    Directive.$inject = ['Utilities'];

    function Directive(Utilities) {
        // Usage:
        //
        // Creates:
        //
        var directive = {
            link: link,
            restrict: 'A',
            scope: {
                user: '=ngUser'
            }
        };
        return directive;

        function link($scope, element, attrs) {
            var codeText = "BEGIN:VCARD \r\n" +
                "VERSION:3.0" + "\r\n" +
                "FN:" + $scope.user.name + "\r\n" +
                "TEL;HOME:" + $scope.user.sMob + "\r\n" +
                "TEL;WORK:" + $scope.user.tel + "\r\n" +
                "TEL;CELL:" + $scope.user.mob + "\r\n" +
                "ORG:" + $scope.user.comp + "\r\n" +
                "TITLE:" + $scope.user.duty + "\r\n" +
                "EMAIL:" + $scope.user.email + "\r\n" +
                "END:VCARD\r\n";
            element.qrcode({
                render: "canvas",
                text: Utilities.toUtf8(codeText),
                width: 140,
                height: 140,
                typeNumber: -1, //计算模式  
                correctLevel: 0, //纠错等级 
                background: "#ffffff",
                foreground: "#2D7B94"
            });
            // jQuery('#code')
        }
    }
})();