'user strict';
angular.module('qusion.ui.upload', [
])
    .directive('qnUpload', function () {
        return {
            require: '?ngModel',
            scope: {
                options: "=qnUpload",
                upload: "=ngModel"
            },
            link: function (scope, element, attrs, ngModel) {
                var opts;
                
                var settings = {
                    extensions: ['gif', 'jpg', 'png', 'jpeg', 'doc', 'docx','pdf', 'xls', 'xlsx', 'ppt', 'pptx'],
                    multiple: false
                };

                if (ngModel) {
                    scope.$watch('options', function (value) {
                        if(value) {
                            opts = angular.extend({}, settings, scope.$eval(attrs.qnUpload));
                            scope.upload = element.upload(opts).data("qusion-upload");
                        }
                        });
                    
                    
                }
            }
        };

    });
