Created
February 26, 2015 22:03
-
-
Save martianboy/7df35cd6fbb0942357de to your computer and use it in GitHub Desktop.
directive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
webioxApp.directive("fineuploaderCopy", ["$parse", function ($parse) { | |
return { | |
strict: "A", | |
require: "?ngModel", | |
scope: { | |
model: "=ngModel" | |
}, | |
link: function (scope, element, attrs, ngModel) { | |
var multipleFiles = (attrs.multipleUpload === "True"); | |
var virtualPaths = (scope.model == null ? [] : scope.model); | |
var codedPaths = []; | |
var options = { | |
element: element[0], | |
request: { | |
endpoint: attrs.uploadAction | |
}, | |
deleteFile: { | |
enabled: true, | |
method: "post", | |
endpoint: "/Files/Delete/" | |
}, | |
validation: { | |
allowedExtensions: ["jpeg", "jpg", "gif", "png"], | |
sizeLimit: 2048000, | |
itemLimit: attrs.itemsLimit | |
}, | |
multiple: multipleFiles, | |
autoUpload: true, | |
callbacks: { | |
onComplete: function (id, fileName, responseJson) { | |
if (responseJson.success) { | |
if (!multipleFiles) { | |
virtualPaths = []; | |
codedPaths = []; | |
} | |
virtualPaths.push(responseJson.virtualPath); | |
codedPaths.push(responseJson.codedPath); | |
ngModel.$setViewValue(virtualPaths); | |
ngModel.$render(); | |
} | |
} | |
} | |
}); | |
if(attrs.initialFilesAction === "true") | |
options.session = { | |
endpoint: attrs.initialFilesAction + "?id=" + (scope.model == null ? "0" : attrs.modelId) | |
} | |
var uploader = new qq.FineUploader(options); | |
} | |
} | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment