'use strict';
/**
 * Implements directive for confirm window. 
 * Datepicker component: http://jqueryui.com/confirm/
 */
angular.module('qusion.ui.confirm', [])
    .directive('qnConfirm', [
        function() {
            return {
                link: function(scope, element, attr) {

                    var settings = { };

                    var getOptions = function() {
                        return angular.extend({ }, settings, scope.$eval(attr.qnConfirm));
                    };
                    var init = function() {
                        var options = getOptions();
                        // Create the new datepicker widget
                        element.bind('click', function(e) {
                            scope.$eval(attr.uiConfirm); // calls action() on the scope
                        });
                    };
                    // Watch for changes to the directives options
                    scope.$watch(getOptions, init, true);
                }
            };
        }
    ]);