MCPcopy
hub / github.com/moxiecode/plupload / FileDrop

Function FileDrop

js/moxie.js:4152–4223  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

4150 ];
4151
4152 function FileDrop(options) {
4153 if (MXI_DEBUG) {
4154 Env.log("Instantiating FileDrop...");
4155 }
4156
4157 var self = this, defaults;
4158
4159 // if flat argument passed it should be drop_zone id
4160 if (typeof(options) === 'string') {
4161 options = { drop_zone : options };
4162 }
4163
4164 // figure out the options
4165 defaults = {
4166 accept: [{
4167 title: I18n.translate('All Files'),
4168 extensions: '*'
4169 }],
4170 required_caps: {
4171 drag_and_drop: true
4172 }
4173 };
4174
4175 options = typeof(options) === 'object' ? Basic.extend({}, defaults, options) : defaults;
4176
4177 // this will help us to find proper default container
4178 options.container = Dom.get(options.drop_zone) || document.body;
4179
4180 // make container relative, if it is not
4181 if (Dom.getStyle(options.container, 'position') === 'static') {
4182 options.container.style.position = 'relative';
4183 }
4184
4185 // normalize accept option (could be list of mime types or array of title/extensions pairs)
4186 if (typeof(options.accept) === 'string') {
4187 options.accept = Mime.mimes2extList(options.accept);
4188 }
4189
4190 RuntimeClient.call(self);
4191
4192 Basic.extend(self, {
4193 uid: Basic.guid('uid_'),
4194
4195 ruid: null,
4196
4197 files: null,
4198
4199 init: function() {
4200 self.bind('RuntimeInit', function(e, runtime) {
4201 self.ruid = runtime.uid;
4202 runtime.exec.call(self, 'FileDrop', 'init', options);
4203 self.dispatchEvent('ready');
4204 });
4205
4206 // runtime needs: options.required_features, options.runtime_order and options.container
4207 self.connectRuntime(options); // throws RuntimeError
4208 },
4209

Callers

nothing calls this directly

Calls 4

_extractExtsFunction · 0.85
_hasFilesFunction · 0.85
_readItemsFunction · 0.85
_addFileFunction · 0.85

Tested by

no test coverage detected