'use strict';
/**
 * Implements directive for jqueryUI dialog component.
 */
angular.module('qusion.ui.dialog', [])
    .directive('qnDialog', [
        '$timeout',
        function ($timeout) {
            return {
                link: function(scope, element, attr) {
                    var settings = { autoOpen: false, modal: true };
                    var getOptions = function() {
                        return angular.extend({ }, settings, scope.$eval(attr.qnDialog));
                    };

                    var init = function() {
                        var options = getOptions();
                        $timeout(function () {
                            element.dialog(options);
                        }, 20);
                    };

                    scope.$watch(getOptions, init, true);
                }
            };
        }
    ]);