Skip to content

Instantly share code, notes, and snippets.

@martianboy
Created February 26, 2015 22:03
Show Gist options
  • Save martianboy/7df35cd6fbb0942357de to your computer and use it in GitHub Desktop.
Save martianboy/7df35cd6fbb0942357de to your computer and use it in GitHub Desktop.
directive.js
"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