Sha256: 89af989eda993d756f345b1f25114cf604609aa5c18aad531fdd12049e3d0e96
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
angular.module('EssayApp.directives').directive "dropboxUploader", ['$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.appKey = attrs.appKey scope.guid = attrs.guid scope.endpoint = attrs.url scope.keeper = FileKeeper.build(scope, element, attrs, ngModel) if $('#dropboxjs').length <= 0 dropboxjs = $('<script type="text/javascript"></script>') dropboxjs.attr('src', 'https://www.dropbox.com/static/api/2/dropins.js') dropboxjs.attr('id', 'dropboxjs') dropboxjs.attr('data-app-key', scope.appKey) $('body').append(dropboxjs) scope.openUploader = -> # console.log 'openUploader' return unless Dropbox? Dropbox.choose success: (files) -> $.each files, (_i, file) -> scope.keeper._add_pending(file) $.post( scope.endpoint, $.param( 'source': 'dropbox' 'link': file.link 'name': file.name 'guid': scope.guid ) ).then ((data)-> scope.keeper.addUploadedFile(data.files[0], file) ), (err)-> scope.keeper._remove_pending(file) cancel: -> # called when user canceled selection return linkType: 'direct' multiselect: true 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/dropbox_uploader.js.coffee |