Sha256: 0f4d97b3d2ab6455d53353fcb18b5791cb9ecd48a7feddc160b939b370acdb7f
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
angular.module('EssayApp.directives').directive "weburlUploader", ['$timeout', '$window', 'FileKeeper', ($timeout, $window, FileKeeper) -> restrict: 'A' scope: true require: "ngModel" link: (scope, element, attrs, ngModel) -> $timeout (-> scope.root = element scope.root = element.closest(attrs.uploaderRoot) if attrs.uploaderRoot? scope.guid = attrs.guid scope.endpoint = attrs.url scope.deepScan = attrs.deepScan || false scope.keeper = FileKeeper.build(scope, element, attrs, ngModel) scope.upload = (evt, link, name = undefined)-> evt?.preventDefault() link = scope.$eval(name) if !link? && name? if /^\s*$/.test(link || '') console.log 'not added', link return link = 'https://' + link unless /^(http(s)?|ftp):\/\//.test(link) return unless /^(http(s)?|ftp):\/\/([a-z0-9\.\-_]+)(\/)?/.test(link) file = { link: link name: link } $timeout (-> scope.keeper._add_pending(file) ), 0, false scope.$eval("#{name}=''") if name? $.post( scope.endpoint, $.param( 'url': file.link 'name': file.name 'guid': scope.guid 'deep': scope.deepScan ) ).then ((data)-> uploaded = data.files[0] uploaded.filename = link.replace(/\/$/, '') scope.keeper.addUploadedFile(data.files[0], file) ), (err)-> scope.keeper._remove_pending(file) scope.$apply() return return ), 0, false ]
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
translation_cms-0.1.5 | app/assets/javascripts/app/directives/weburl_uploader.js.coffee |