'use strict';
/**
 * Implements directive for qusion.org component.
 */
angular.module('qusion.ui.org', [])
    .directive('qnOrg', [
        function() {
            return {
                require: '?ngModel',
                link: function(scope, element, attr, ngModel) {
                    var container;
                    var settings = { };
                    var getOptions = function() {
                        return angular.extend({ }, settings, scope.$eval(attr.qnOrg));
                    };

                    var init = function() {
                        var options = getOptions();
                        element.org(options);
                    };

                    var refresh = function() {
                        element.org("destroy");
                        element.org(options);
                    };

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