webshims-rails 1.14.6 → 1.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webshims-rails/version.rb +2 -2
- data/vendor/assets/javascripts/webshims/polyfiller.js +145 -139
- data/vendor/assets/javascripts/webshims/shims/canvas-blob.js +97 -0
- data/vendor/assets/javascripts/webshims/shims/combos/1.js +13 -15
- data/vendor/assets/javascripts/webshims/shims/combos/10.js +29 -28
- data/vendor/assets/javascripts/webshims/shims/combos/11.js +2 -1
- data/vendor/assets/javascripts/webshims/shims/combos/12.js +22 -10
- data/vendor/assets/javascripts/webshims/shims/combos/13.js +22 -10
- data/vendor/assets/javascripts/webshims/shims/combos/15.js +28 -43
- data/vendor/assets/javascripts/webshims/shims/combos/16.js +41 -44
- data/vendor/assets/javascripts/webshims/shims/combos/17.js +2 -1
- data/vendor/assets/javascripts/webshims/shims/combos/2.js +40 -42
- data/vendor/assets/javascripts/webshims/shims/combos/21.js +98 -71
- data/vendor/assets/javascripts/webshims/shims/combos/22.js +9 -9
- data/vendor/assets/javascripts/webshims/shims/combos/23.js +13 -1
- data/vendor/assets/javascripts/webshims/shims/combos/25.js +141 -51
- data/vendor/assets/javascripts/webshims/shims/combos/27.js +66 -12
- data/vendor/assets/javascripts/webshims/shims/combos/28.js +1 -2
- data/vendor/assets/javascripts/webshims/shims/combos/3.js +27 -41
- data/vendor/assets/javascripts/webshims/shims/combos/30.js +27 -41
- data/vendor/assets/javascripts/webshims/shims/combos/31.js +27 -41
- data/vendor/assets/javascripts/webshims/shims/combos/34.js +36 -36
- data/vendor/assets/javascripts/webshims/shims/combos/4.js +27 -27
- data/vendor/assets/javascripts/webshims/shims/combos/5.js +2 -1
- data/vendor/assets/javascripts/webshims/shims/combos/6.js +2 -1
- data/vendor/assets/javascripts/webshims/shims/combos/7.js +40 -42
- data/vendor/assets/javascripts/webshims/shims/combos/8.js +40 -42
- data/vendor/assets/javascripts/webshims/shims/combos/9.js +29 -28
- data/vendor/assets/javascripts/webshims/shims/combos/98.js +4 -2
- data/vendor/assets/javascripts/webshims/shims/combos/99.js +4 -2
- data/vendor/assets/javascripts/webshims/shims/dom-extend.js +27 -27
- data/vendor/assets/javascripts/webshims/shims/es6.js +23 -29
- data/vendor/assets/javascripts/webshims/shims/{filereader.js → filereader-xhr.js} +66 -12
- data/vendor/assets/javascripts/webshims/shims/form-core.js +0 -14
- data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +2 -1
- data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +1 -2
- data/vendor/assets/javascripts/webshims/shims/form-validation.js +18 -5
- data/vendor/assets/javascripts/webshims/shims/form-validators.js +15 -14
- data/vendor/assets/javascripts/webshims/shims/geolocation.js +41 -50
- data/vendor/assets/javascripts/webshims/shims/jme/controls.css +4 -4
- data/vendor/assets/javascripts/webshims/shims/jme/controls.scss +2 -1
- data/vendor/assets/javascripts/webshims/shims/jme/mediacontrols.js +4 -2
- data/vendor/assets/javascripts/webshims/shims/mediacapture-picker.js +42 -0
- data/vendor/assets/javascripts/webshims/shims/mediacapture.js +159 -0
- data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +13 -1
- data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +48 -12
- data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +20 -8
- data/vendor/assets/javascripts/webshims/shims/{combos/26.js → moxie/js/moxie-html4.js} +2121 -1257
- data/vendor/assets/javascripts/webshims/shims/moxie/js/{moxie.js → moxie-swf.js} +1125 -1741
- data/vendor/assets/javascripts/webshims/shims/sticky.js +585 -0
- data/vendor/assets/javascripts/webshims/shims/styles/forms-picker.css +20 -0
- data/vendor/assets/javascripts/webshims/shims/styles/scss/forms-picker.scss +23 -0
- data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +74 -34
- data/vendor/assets/javascripts/webshims/shims/styles/shim-ext.css +78 -31
- data/vendor/assets/javascripts/webshims/shims/styles/shim.css +78 -31
- data/vendor/assets/javascripts/webshims/shims/swf/JarisFLVPlayer.swf +0 -0
- data/vendor/assets/javascripts/webshims/shims/track-ui.js +214 -111
- data/vendor/assets/javascripts/webshims/shims/track.js +9 -9
- data/vendor/assets/javascripts/webshims/shims/usermedia-core.js +27 -0
- data/vendor/assets/javascripts/webshims/shims/usermedia-shim.js +34 -37
- metadata +9 -8
- data/vendor/assets/javascripts/webshims/shims/jajax.js +0 -1262
- data/vendor/assets/javascripts/webshims/shims/moxie/silverlight/Moxie.cdn.xap +0 -0
- data/vendor/assets/javascripts/webshims/shims/moxie/silverlight/Moxie.min.xap +0 -0
@@ -5131,1001 +5131,10 @@ define("moxie/xhr/XMLHttpRequest", [
|
|
5131
5131
|
return XMLHttpRequest;
|
5132
5132
|
});
|
5133
5133
|
|
5134
|
-
// Included from: src/javascript/runtime/
|
5135
|
-
|
5136
|
-
/**
|
5137
|
-
* Runtime.js
|
5138
|
-
*
|
5139
|
-
* Copyright 2013, Moxiecode Systems AB
|
5140
|
-
* Released under GPL License.
|
5141
|
-
*
|
5142
|
-
* License: http://www.plupload.com/license
|
5143
|
-
* Contributing: http://www.plupload.com/contributing
|
5144
|
-
*/
|
5145
|
-
|
5146
|
-
/*global ActiveXObject:true */
|
5147
|
-
|
5148
|
-
/**
|
5149
|
-
Defines constructor for Flash runtime.
|
5150
|
-
|
5151
|
-
@class moxie/runtime/flash/Runtime
|
5152
|
-
@private
|
5153
|
-
*/
|
5154
|
-
define("moxie/runtime/flash/Runtime", [
|
5155
|
-
"moxie/core/utils/Basic",
|
5156
|
-
"moxie/core/utils/Env",
|
5157
|
-
"moxie/core/utils/Dom",
|
5158
|
-
"moxie/core/Exceptions",
|
5159
|
-
"moxie/runtime/Runtime"
|
5160
|
-
], function(Basic, Env, Dom, x, Runtime) {
|
5161
|
-
|
5162
|
-
var type = 'flash', extensions = {};
|
5163
|
-
|
5164
|
-
/**
|
5165
|
-
Get the version of the Flash Player
|
5166
|
-
|
5167
|
-
@method getShimVersion
|
5168
|
-
@private
|
5169
|
-
@return {Number} Flash Player version
|
5170
|
-
*/
|
5171
|
-
function getShimVersion() {
|
5172
|
-
var version;
|
5173
|
-
|
5174
|
-
try {
|
5175
|
-
version = navigator.plugins['Shockwave Flash'];
|
5176
|
-
version = version.description;
|
5177
|
-
} catch (e1) {
|
5178
|
-
try {
|
5179
|
-
version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
|
5180
|
-
} catch (e2) {
|
5181
|
-
version = '0.0';
|
5182
|
-
}
|
5183
|
-
}
|
5184
|
-
version = version.match(/\d+/g);
|
5185
|
-
return parseFloat(version[0] + '.' + version[1]);
|
5186
|
-
}
|
5187
|
-
|
5188
|
-
/**
|
5189
|
-
Constructor for the Flash Runtime
|
5190
|
-
|
5191
|
-
@class FlashRuntime
|
5192
|
-
@extends Runtime
|
5193
|
-
*/
|
5194
|
-
function FlashRuntime(options) {
|
5195
|
-
var I = this, initTimer;
|
5196
|
-
|
5197
|
-
options = Basic.extend({ swf_url: Env.swf_url }, options);
|
5198
|
-
|
5199
|
-
Runtime.call(this, options, type, {
|
5200
|
-
access_binary: function(value) {
|
5201
|
-
return value && I.mode === 'browser';
|
5202
|
-
},
|
5203
|
-
access_image_binary: function(value) {
|
5204
|
-
return value && I.mode === 'browser';
|
5205
|
-
},
|
5206
|
-
display_media: Runtime.capTrue,
|
5207
|
-
do_cors: Runtime.capTrue,
|
5208
|
-
drag_and_drop: false,
|
5209
|
-
report_upload_progress: function() {
|
5210
|
-
return I.mode === 'client';
|
5211
|
-
},
|
5212
|
-
resize_image: Runtime.capTrue,
|
5213
|
-
return_response_headers: false,
|
5214
|
-
return_response_type: function(responseType) {
|
5215
|
-
if (responseType === 'json' && !!window.JSON) {
|
5216
|
-
return true;
|
5217
|
-
}
|
5218
|
-
return !Basic.arrayDiff(responseType, ['', 'text', 'document']) || I.mode === 'browser';
|
5219
|
-
},
|
5220
|
-
return_status_code: function(code) {
|
5221
|
-
return I.mode === 'browser' || !Basic.arrayDiff(code, [200, 404]);
|
5222
|
-
},
|
5223
|
-
select_file: Runtime.capTrue,
|
5224
|
-
select_multiple: Runtime.capTrue,
|
5225
|
-
send_binary_string: function(value) {
|
5226
|
-
return value && I.mode === 'browser';
|
5227
|
-
},
|
5228
|
-
send_browser_cookies: function(value) {
|
5229
|
-
return value && I.mode === 'browser';
|
5230
|
-
},
|
5231
|
-
send_custom_headers: function(value) {
|
5232
|
-
return value && I.mode === 'browser';
|
5233
|
-
},
|
5234
|
-
send_multipart: Runtime.capTrue,
|
5235
|
-
slice_blob: function(value) {
|
5236
|
-
return value && I.mode === 'browser';
|
5237
|
-
},
|
5238
|
-
stream_upload: function(value) {
|
5239
|
-
return value && I.mode === 'browser';
|
5240
|
-
},
|
5241
|
-
summon_file_dialog: false,
|
5242
|
-
upload_filesize: function(size) {
|
5243
|
-
return Basic.parseSizeStr(size) <= 2097152 || I.mode === 'client';
|
5244
|
-
},
|
5245
|
-
use_http_method: function(methods) {
|
5246
|
-
return !Basic.arrayDiff(methods, ['GET', 'POST']);
|
5247
|
-
}
|
5248
|
-
}, {
|
5249
|
-
// capabilities that require specific mode
|
5250
|
-
access_binary: function(value) {
|
5251
|
-
return value ? 'browser' : 'client';
|
5252
|
-
},
|
5253
|
-
access_image_binary: function(value) {
|
5254
|
-
return value ? 'browser' : 'client';
|
5255
|
-
},
|
5256
|
-
report_upload_progress: function(value) {
|
5257
|
-
return value ? 'browser' : 'client';
|
5258
|
-
},
|
5259
|
-
return_response_type: function(responseType) {
|
5260
|
-
return Basic.arrayDiff(responseType, ['', 'text', 'json', 'document']) ? 'browser' : ['client', 'browser'];
|
5261
|
-
},
|
5262
|
-
return_status_code: function(code) {
|
5263
|
-
return Basic.arrayDiff(code, [200, 404]) ? 'browser' : ['client', 'browser'];
|
5264
|
-
},
|
5265
|
-
send_binary_string: function(value) {
|
5266
|
-
return value ? 'browser' : 'client';
|
5267
|
-
},
|
5268
|
-
send_browser_cookies: function(value) {
|
5269
|
-
return value ? 'browser' : 'client';
|
5270
|
-
},
|
5271
|
-
send_custom_headers: function(value) {
|
5272
|
-
return value ? 'browser' : 'client';
|
5273
|
-
},
|
5274
|
-
stream_upload: function(value) {
|
5275
|
-
return value ? 'client' : 'browser';
|
5276
|
-
},
|
5277
|
-
upload_filesize: function(size) {
|
5278
|
-
return Basic.parseSizeStr(size) >= 2097152 ? 'client' : 'browser';
|
5279
|
-
}
|
5280
|
-
}, 'client');
|
5281
|
-
|
5282
|
-
|
5283
|
-
// minimal requirement for Flash Player version
|
5284
|
-
if (getShimVersion() < 10) {
|
5285
|
-
this.mode = false; // with falsy mode, runtime won't operable, no matter what the mode was before
|
5286
|
-
}
|
5287
|
-
|
5288
|
-
|
5289
|
-
Basic.extend(this, {
|
5290
|
-
|
5291
|
-
getShim: function() {
|
5292
|
-
return Dom.get(this.uid);
|
5293
|
-
},
|
5294
|
-
|
5295
|
-
shimExec: function(component, action) {
|
5296
|
-
var args = [].slice.call(arguments, 2);
|
5297
|
-
return I.getShim().exec(this.uid, component, action, args);
|
5298
|
-
},
|
5299
|
-
|
5300
|
-
init: function() {
|
5301
|
-
var html, el, container;
|
5302
|
-
|
5303
|
-
container = this.getShimContainer();
|
5304
|
-
|
5305
|
-
// if not the minimal height, shims are not initialized in older browsers (e.g FF3.6, IE6,7,8, Safari 4.0,5.0, etc)
|
5306
|
-
Basic.extend(container.style, {
|
5307
|
-
position: 'absolute',
|
5308
|
-
top: '-8px',
|
5309
|
-
left: '-8px',
|
5310
|
-
width: '9px',
|
5311
|
-
height: '9px',
|
5312
|
-
overflow: 'hidden'
|
5313
|
-
});
|
5314
|
-
|
5315
|
-
// insert flash object
|
5316
|
-
html = '<object id="' + this.uid + '" type="application/x-shockwave-flash" data="' + options.swf_url + '" ';
|
5317
|
-
|
5318
|
-
if (Env.browser === 'IE') {
|
5319
|
-
html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
|
5320
|
-
}
|
5321
|
-
|
5322
|
-
html += 'width="100%" height="100%" style="outline:0">' +
|
5323
|
-
'<param name="movie" value="' + options.swf_url + '" />' +
|
5324
|
-
'<param name="flashvars" value="uid=' + escape(this.uid) + '&target=' + Env.global_event_dispatcher + '" />' +
|
5325
|
-
'<param name="wmode" value="transparent" />' +
|
5326
|
-
'<param name="allowscriptaccess" value="always" />' +
|
5327
|
-
'</object>';
|
5328
|
-
|
5329
|
-
if (Env.browser === 'IE') {
|
5330
|
-
el = document.createElement('div');
|
5331
|
-
container.appendChild(el);
|
5332
|
-
el.outerHTML = html;
|
5333
|
-
el = container = null; // just in case
|
5334
|
-
} else {
|
5335
|
-
container.innerHTML = html;
|
5336
|
-
}
|
5337
|
-
|
5338
|
-
// Init is dispatched by the shim
|
5339
|
-
initTimer = setTimeout(function() {
|
5340
|
-
if (I && !I.initialized) { // runtime might be already destroyed by this moment
|
5341
|
-
I.trigger("Error", new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR));
|
5342
|
-
}
|
5343
|
-
}, 5000);
|
5344
|
-
},
|
5345
|
-
|
5346
|
-
destroy: (function(destroy) { // extend default destroy method
|
5347
|
-
return function() {
|
5348
|
-
destroy.call(I);
|
5349
|
-
clearTimeout(initTimer); // initialization check might be still onwait
|
5350
|
-
options = initTimer = destroy = I = null;
|
5351
|
-
};
|
5352
|
-
}(this.destroy))
|
5353
|
-
|
5354
|
-
}, extensions);
|
5355
|
-
}
|
5356
|
-
|
5357
|
-
Runtime.addConstructor(type, FlashRuntime);
|
5358
|
-
|
5359
|
-
return extensions;
|
5360
|
-
});
|
5361
|
-
|
5362
|
-
// Included from: src/javascript/runtime/flash/file/Blob.js
|
5363
|
-
|
5364
|
-
/**
|
5365
|
-
* Blob.js
|
5366
|
-
*
|
5367
|
-
* Copyright 2013, Moxiecode Systems AB
|
5368
|
-
* Released under GPL License.
|
5369
|
-
*
|
5370
|
-
* License: http://www.plupload.com/license
|
5371
|
-
* Contributing: http://www.plupload.com/contributing
|
5372
|
-
*/
|
5373
|
-
|
5374
|
-
/**
|
5375
|
-
@class moxie/runtime/flash/file/Blob
|
5376
|
-
@private
|
5377
|
-
*/
|
5378
|
-
define("moxie/runtime/flash/file/Blob", [
|
5379
|
-
"moxie/runtime/flash/Runtime",
|
5380
|
-
"moxie/file/Blob"
|
5381
|
-
], function(extensions, Blob) {
|
5382
|
-
|
5383
|
-
var FlashBlob = {
|
5384
|
-
slice: function(blob, start, end, type) {
|
5385
|
-
var self = this.getRuntime();
|
5386
|
-
|
5387
|
-
if (start < 0) {
|
5388
|
-
start = Math.max(blob.size + start, 0);
|
5389
|
-
} else if (start > 0) {
|
5390
|
-
start = Math.min(start, blob.size);
|
5391
|
-
}
|
5392
|
-
|
5393
|
-
if (end < 0) {
|
5394
|
-
end = Math.max(blob.size + end, 0);
|
5395
|
-
} else if (end > 0) {
|
5396
|
-
end = Math.min(end, blob.size);
|
5397
|
-
}
|
5398
|
-
|
5399
|
-
blob = self.shimExec.call(this, 'Blob', 'slice', start, end, type || '');
|
5400
|
-
|
5401
|
-
if (blob) {
|
5402
|
-
blob = new Blob(self.uid, blob);
|
5403
|
-
}
|
5404
|
-
return blob;
|
5405
|
-
}
|
5406
|
-
};
|
5407
|
-
|
5408
|
-
return (extensions.Blob = FlashBlob);
|
5409
|
-
});
|
5410
|
-
|
5411
|
-
// Included from: src/javascript/runtime/flash/file/FileInput.js
|
5412
|
-
|
5413
|
-
/**
|
5414
|
-
* FileInput.js
|
5415
|
-
*
|
5416
|
-
* Copyright 2013, Moxiecode Systems AB
|
5417
|
-
* Released under GPL License.
|
5418
|
-
*
|
5419
|
-
* License: http://www.plupload.com/license
|
5420
|
-
* Contributing: http://www.plupload.com/contributing
|
5421
|
-
*/
|
5422
|
-
|
5423
|
-
/**
|
5424
|
-
@class moxie/runtime/flash/file/FileInput
|
5425
|
-
@private
|
5426
|
-
*/
|
5427
|
-
define("moxie/runtime/flash/file/FileInput", [
|
5428
|
-
"moxie/runtime/flash/Runtime"
|
5429
|
-
], function(extensions) {
|
5430
|
-
|
5431
|
-
var FileInput = {
|
5432
|
-
init: function(options) {
|
5433
|
-
this.getRuntime().shimExec.call(this, 'FileInput', 'init', {
|
5434
|
-
name: options.name,
|
5435
|
-
accept: options.accept,
|
5436
|
-
multiple: options.multiple
|
5437
|
-
});
|
5438
|
-
this.trigger('ready');
|
5439
|
-
}
|
5440
|
-
};
|
5441
|
-
|
5442
|
-
return (extensions.FileInput = FileInput);
|
5443
|
-
});
|
5444
|
-
|
5445
|
-
// Included from: src/javascript/runtime/flash/file/FileReader.js
|
5446
|
-
|
5447
|
-
/**
|
5448
|
-
* FileReader.js
|
5449
|
-
*
|
5450
|
-
* Copyright 2013, Moxiecode Systems AB
|
5451
|
-
* Released under GPL License.
|
5452
|
-
*
|
5453
|
-
* License: http://www.plupload.com/license
|
5454
|
-
* Contributing: http://www.plupload.com/contributing
|
5455
|
-
*/
|
5456
|
-
|
5457
|
-
/**
|
5458
|
-
@class moxie/runtime/flash/file/FileReader
|
5459
|
-
@private
|
5460
|
-
*/
|
5461
|
-
define("moxie/runtime/flash/file/FileReader", [
|
5462
|
-
"moxie/runtime/flash/Runtime",
|
5463
|
-
"moxie/core/utils/Encode"
|
5464
|
-
], function(extensions, Encode) {
|
5465
|
-
|
5466
|
-
var _result = '';
|
5467
|
-
|
5468
|
-
function _formatData(data, op) {
|
5469
|
-
switch (op) {
|
5470
|
-
case 'readAsText':
|
5471
|
-
return Encode.atob(data, 'utf8');
|
5472
|
-
case 'readAsBinaryString':
|
5473
|
-
return Encode.atob(data);
|
5474
|
-
case 'readAsDataURL':
|
5475
|
-
return data;
|
5476
|
-
}
|
5477
|
-
return null;
|
5478
|
-
}
|
5479
|
-
|
5480
|
-
var FileReader = {
|
5481
|
-
read: function(op, blob) {
|
5482
|
-
var target = this, self = target.getRuntime();
|
5483
|
-
|
5484
|
-
// special prefix for DataURL read mode
|
5485
|
-
if (op === 'readAsDataURL') {
|
5486
|
-
_result = 'data:' + (blob.type || '') + ';base64,';
|
5487
|
-
}
|
5488
|
-
|
5489
|
-
target.bind('Progress', function(e, data) {
|
5490
|
-
if (data) {
|
5491
|
-
_result += _formatData(data, op);
|
5492
|
-
}
|
5493
|
-
});
|
5494
|
-
|
5495
|
-
return self.shimExec.call(this, 'FileReader', 'readAsBase64', blob.uid);
|
5496
|
-
},
|
5497
|
-
|
5498
|
-
getResult: function() {
|
5499
|
-
return _result;
|
5500
|
-
},
|
5501
|
-
|
5502
|
-
destroy: function() {
|
5503
|
-
_result = null;
|
5504
|
-
}
|
5505
|
-
};
|
5506
|
-
|
5507
|
-
return (extensions.FileReader = FileReader);
|
5508
|
-
});
|
5509
|
-
|
5510
|
-
// Included from: src/javascript/runtime/flash/file/FileReaderSync.js
|
5511
|
-
|
5512
|
-
/**
|
5513
|
-
* FileReaderSync.js
|
5514
|
-
*
|
5515
|
-
* Copyright 2013, Moxiecode Systems AB
|
5516
|
-
* Released under GPL License.
|
5517
|
-
*
|
5518
|
-
* License: http://www.plupload.com/license
|
5519
|
-
* Contributing: http://www.plupload.com/contributing
|
5520
|
-
*/
|
5521
|
-
|
5522
|
-
/**
|
5523
|
-
@class moxie/runtime/flash/file/FileReaderSync
|
5524
|
-
@private
|
5525
|
-
*/
|
5526
|
-
define("moxie/runtime/flash/file/FileReaderSync", [
|
5527
|
-
"moxie/runtime/flash/Runtime",
|
5528
|
-
"moxie/core/utils/Encode"
|
5529
|
-
], function(extensions, Encode) {
|
5530
|
-
|
5531
|
-
function _formatData(data, op) {
|
5532
|
-
switch (op) {
|
5533
|
-
case 'readAsText':
|
5534
|
-
return Encode.atob(data, 'utf8');
|
5535
|
-
case 'readAsBinaryString':
|
5536
|
-
return Encode.atob(data);
|
5537
|
-
case 'readAsDataURL':
|
5538
|
-
return data;
|
5539
|
-
}
|
5540
|
-
return null;
|
5541
|
-
}
|
5542
|
-
|
5543
|
-
var FileReaderSync = {
|
5544
|
-
read: function(op, blob) {
|
5545
|
-
var result, self = this.getRuntime();
|
5546
|
-
|
5547
|
-
result = self.shimExec.call(this, 'FileReaderSync', 'readAsBase64', blob.uid);
|
5548
|
-
if (!result) {
|
5549
|
-
return null; // or throw ex
|
5550
|
-
}
|
5551
|
-
|
5552
|
-
// special prefix for DataURL read mode
|
5553
|
-
if (op === 'readAsDataURL') {
|
5554
|
-
result = 'data:' + (blob.type || '') + ';base64,' + result;
|
5555
|
-
}
|
5556
|
-
|
5557
|
-
return _formatData(result, op, blob.type);
|
5558
|
-
}
|
5559
|
-
};
|
5560
|
-
|
5561
|
-
return (extensions.FileReaderSync = FileReaderSync);
|
5562
|
-
});
|
5563
|
-
|
5564
|
-
// Included from: src/javascript/runtime/Transporter.js
|
5565
|
-
|
5566
|
-
/**
|
5567
|
-
* Transporter.js
|
5568
|
-
*
|
5569
|
-
* Copyright 2013, Moxiecode Systems AB
|
5570
|
-
* Released under GPL License.
|
5571
|
-
*
|
5572
|
-
* License: http://www.plupload.com/license
|
5573
|
-
* Contributing: http://www.plupload.com/contributing
|
5574
|
-
*/
|
5575
|
-
|
5576
|
-
define("moxie/runtime/Transporter", [
|
5577
|
-
"moxie/core/utils/Basic",
|
5578
|
-
"moxie/core/utils/Encode",
|
5579
|
-
"moxie/runtime/RuntimeClient",
|
5580
|
-
"moxie/core/EventTarget"
|
5581
|
-
], function(Basic, Encode, RuntimeClient, EventTarget) {
|
5582
|
-
function Transporter() {
|
5583
|
-
var mod, _runtime, _data, _size, _pos, _chunk_size;
|
5584
|
-
|
5585
|
-
RuntimeClient.call(this);
|
5586
|
-
|
5587
|
-
Basic.extend(this, {
|
5588
|
-
uid: Basic.guid('uid_'),
|
5589
|
-
|
5590
|
-
state: Transporter.IDLE,
|
5591
|
-
|
5592
|
-
result: null,
|
5593
|
-
|
5594
|
-
transport: function(data, type, options) {
|
5595
|
-
var self = this;
|
5596
|
-
|
5597
|
-
options = Basic.extend({
|
5598
|
-
chunk_size: 204798
|
5599
|
-
}, options);
|
5600
|
-
|
5601
|
-
// should divide by three, base64 requires this
|
5602
|
-
if ((mod = options.chunk_size % 3)) {
|
5603
|
-
options.chunk_size += 3 - mod;
|
5604
|
-
}
|
5605
|
-
|
5606
|
-
_chunk_size = options.chunk_size;
|
5607
|
-
|
5608
|
-
_reset.call(this);
|
5609
|
-
_data = data;
|
5610
|
-
_size = data.length;
|
5611
|
-
|
5612
|
-
if (Basic.typeOf(options) === 'string' || options.ruid) {
|
5613
|
-
_run.call(self, type, this.connectRuntime(options));
|
5614
|
-
} else {
|
5615
|
-
// we require this to run only once
|
5616
|
-
var cb = function(e, runtime) {
|
5617
|
-
self.unbind("RuntimeInit", cb);
|
5618
|
-
_run.call(self, type, runtime);
|
5619
|
-
};
|
5620
|
-
this.bind("RuntimeInit", cb);
|
5621
|
-
this.connectRuntime(options);
|
5622
|
-
}
|
5623
|
-
},
|
5624
|
-
|
5625
|
-
abort: function() {
|
5626
|
-
var self = this;
|
5627
|
-
|
5628
|
-
self.state = Transporter.IDLE;
|
5629
|
-
if (_runtime) {
|
5630
|
-
_runtime.exec.call(self, 'Transporter', 'clear');
|
5631
|
-
self.trigger("TransportingAborted");
|
5632
|
-
}
|
5633
|
-
|
5634
|
-
_reset.call(self);
|
5635
|
-
},
|
5636
|
-
|
5637
|
-
|
5638
|
-
destroy: function() {
|
5639
|
-
this.unbindAll();
|
5640
|
-
_runtime = null;
|
5641
|
-
this.disconnectRuntime();
|
5642
|
-
_reset.call(this);
|
5643
|
-
}
|
5644
|
-
});
|
5645
|
-
|
5646
|
-
function _reset() {
|
5647
|
-
_size = _pos = 0;
|
5648
|
-
_data = this.result = null;
|
5649
|
-
}
|
5650
|
-
|
5651
|
-
function _run(type, runtime) {
|
5652
|
-
var self = this;
|
5653
|
-
|
5654
|
-
_runtime = runtime;
|
5655
|
-
|
5656
|
-
//self.unbind("RuntimeInit");
|
5657
|
-
|
5658
|
-
self.bind("TransportingProgress", function(e) {
|
5659
|
-
_pos = e.loaded;
|
5660
|
-
|
5661
|
-
if (_pos < _size && Basic.inArray(self.state, [Transporter.IDLE, Transporter.DONE]) === -1) {
|
5662
|
-
_transport.call(self);
|
5663
|
-
}
|
5664
|
-
}, 999);
|
5665
|
-
|
5666
|
-
self.bind("TransportingComplete", function() {
|
5667
|
-
_pos = _size;
|
5668
|
-
self.state = Transporter.DONE;
|
5669
|
-
_data = null; // clean a bit
|
5670
|
-
self.result = _runtime.exec.call(self, 'Transporter', 'getAsBlob', type || '');
|
5671
|
-
}, 999);
|
5672
|
-
|
5673
|
-
self.state = Transporter.BUSY;
|
5674
|
-
self.trigger("TransportingStarted");
|
5675
|
-
_transport.call(self);
|
5676
|
-
}
|
5677
|
-
|
5678
|
-
function _transport() {
|
5679
|
-
var self = this,
|
5680
|
-
chunk,
|
5681
|
-
bytesLeft = _size - _pos;
|
5682
|
-
|
5683
|
-
if (_chunk_size > bytesLeft) {
|
5684
|
-
_chunk_size = bytesLeft;
|
5685
|
-
}
|
5686
|
-
|
5687
|
-
chunk = Encode.btoa(_data.substr(_pos, _chunk_size));
|
5688
|
-
_runtime.exec.call(self, 'Transporter', 'receive', chunk, _size);
|
5689
|
-
}
|
5690
|
-
}
|
5691
|
-
|
5692
|
-
Transporter.IDLE = 0;
|
5693
|
-
Transporter.BUSY = 1;
|
5694
|
-
Transporter.DONE = 2;
|
5695
|
-
|
5696
|
-
Transporter.prototype = EventTarget.instance;
|
5697
|
-
|
5698
|
-
return Transporter;
|
5699
|
-
});
|
5700
|
-
|
5701
|
-
// Included from: src/javascript/runtime/flash/xhr/XMLHttpRequest.js
|
5702
|
-
|
5703
|
-
/**
|
5704
|
-
* XMLHttpRequest.js
|
5705
|
-
*
|
5706
|
-
* Copyright 2013, Moxiecode Systems AB
|
5707
|
-
* Released under GPL License.
|
5708
|
-
*
|
5709
|
-
* License: http://www.plupload.com/license
|
5710
|
-
* Contributing: http://www.plupload.com/contributing
|
5711
|
-
*/
|
5712
|
-
|
5713
|
-
/**
|
5714
|
-
@class moxie/runtime/flash/xhr/XMLHttpRequest
|
5715
|
-
@private
|
5716
|
-
*/
|
5717
|
-
define("moxie/runtime/flash/xhr/XMLHttpRequest", [
|
5718
|
-
"moxie/runtime/flash/Runtime",
|
5719
|
-
"moxie/core/utils/Basic",
|
5720
|
-
"moxie/file/Blob",
|
5721
|
-
"moxie/file/File",
|
5722
|
-
"moxie/file/FileReaderSync",
|
5723
|
-
"moxie/xhr/FormData",
|
5724
|
-
"moxie/runtime/Transporter"
|
5725
|
-
], function(extensions, Basic, Blob, File, FileReaderSync, FormData, Transporter) {
|
5726
|
-
|
5727
|
-
var XMLHttpRequest = {
|
5728
|
-
|
5729
|
-
send: function(meta, data) {
|
5730
|
-
var target = this, self = target.getRuntime();
|
5731
|
-
|
5732
|
-
function send() {
|
5733
|
-
meta.transport = self.mode;
|
5734
|
-
self.shimExec.call(target, 'XMLHttpRequest', 'send', meta, data);
|
5735
|
-
}
|
5736
|
-
|
5737
|
-
|
5738
|
-
function appendBlob(name, blob) {
|
5739
|
-
self.shimExec.call(target, 'XMLHttpRequest', 'appendBlob', name, blob.uid);
|
5740
|
-
data = null;
|
5741
|
-
send();
|
5742
|
-
}
|
5743
|
-
|
5744
|
-
|
5745
|
-
function attachBlob(blob, cb) {
|
5746
|
-
var tr = new Transporter();
|
5747
|
-
|
5748
|
-
tr.bind("TransportingComplete", function() {
|
5749
|
-
cb(this.result);
|
5750
|
-
});
|
5751
|
-
|
5752
|
-
tr.transport(blob.getSource(), blob.type, {
|
5753
|
-
ruid: self.uid
|
5754
|
-
});
|
5755
|
-
}
|
5756
|
-
|
5757
|
-
// copy over the headers if any
|
5758
|
-
if (!Basic.isEmptyObj(meta.headers)) {
|
5759
|
-
Basic.each(meta.headers, function(value, header) {
|
5760
|
-
self.shimExec.call(target, 'XMLHttpRequest', 'setRequestHeader', header, value.toString()); // Silverlight doesn't accept integers into the arguments of type object
|
5761
|
-
});
|
5762
|
-
}
|
5763
|
-
|
5764
|
-
// transfer over multipart params and blob itself
|
5765
|
-
if (data instanceof FormData) {
|
5766
|
-
var blobField;
|
5767
|
-
data.each(function(value, name) {
|
5768
|
-
if (value instanceof Blob) {
|
5769
|
-
blobField = name;
|
5770
|
-
} else {
|
5771
|
-
self.shimExec.call(target, 'XMLHttpRequest', 'append', name, value);
|
5772
|
-
}
|
5773
|
-
});
|
5774
|
-
|
5775
|
-
if (!data.hasBlob()) {
|
5776
|
-
data = null;
|
5777
|
-
send();
|
5778
|
-
} else {
|
5779
|
-
var blob = data.getBlob();
|
5780
|
-
if (blob.isDetached()) {
|
5781
|
-
attachBlob(blob, function(attachedBlob) {
|
5782
|
-
blob.destroy();
|
5783
|
-
appendBlob(blobField, attachedBlob);
|
5784
|
-
});
|
5785
|
-
} else {
|
5786
|
-
appendBlob(blobField, blob);
|
5787
|
-
}
|
5788
|
-
}
|
5789
|
-
} else if (data instanceof Blob) {
|
5790
|
-
if (data.isDetached()) {
|
5791
|
-
attachBlob(data, function(attachedBlob) {
|
5792
|
-
data.destroy();
|
5793
|
-
data = attachedBlob.uid;
|
5794
|
-
send();
|
5795
|
-
});
|
5796
|
-
} else {
|
5797
|
-
data = data.uid;
|
5798
|
-
send();
|
5799
|
-
}
|
5800
|
-
} else {
|
5801
|
-
send();
|
5802
|
-
}
|
5803
|
-
},
|
5804
|
-
|
5805
|
-
getResponse: function(responseType) {
|
5806
|
-
var frs, blob, self = this.getRuntime();
|
5807
|
-
|
5808
|
-
blob = self.shimExec.call(this, 'XMLHttpRequest', 'getResponseAsBlob');
|
5809
|
-
|
5810
|
-
if (blob) {
|
5811
|
-
blob = new File(self.uid, blob);
|
5812
|
-
|
5813
|
-
if ('blob' === responseType) {
|
5814
|
-
return blob;
|
5815
|
-
}
|
5816
|
-
|
5817
|
-
try {
|
5818
|
-
frs = new FileReaderSync();
|
5819
|
-
|
5820
|
-
if (!!~Basic.inArray(responseType, ["", "text"])) {
|
5821
|
-
return frs.readAsText(blob);
|
5822
|
-
} else if ('json' === responseType && !!window.JSON) {
|
5823
|
-
return JSON.parse(frs.readAsText(blob));
|
5824
|
-
}
|
5825
|
-
} finally {
|
5826
|
-
blob.destroy();
|
5827
|
-
}
|
5828
|
-
}
|
5829
|
-
return null;
|
5830
|
-
},
|
5831
|
-
|
5832
|
-
abort: function(upload_complete_flag) {
|
5833
|
-
var self = this.getRuntime();
|
5834
|
-
|
5835
|
-
self.shimExec.call(this, 'XMLHttpRequest', 'abort');
|
5836
|
-
|
5837
|
-
this.dispatchEvent('readystatechange');
|
5838
|
-
// this.dispatchEvent('progress');
|
5839
|
-
this.dispatchEvent('abort');
|
5840
|
-
|
5841
|
-
//if (!upload_complete_flag) {
|
5842
|
-
// this.dispatchEvent('uploadprogress');
|
5843
|
-
//}
|
5844
|
-
}
|
5845
|
-
};
|
5846
|
-
|
5847
|
-
return (extensions.XMLHttpRequest = XMLHttpRequest);
|
5848
|
-
});
|
5849
|
-
|
5850
|
-
// Included from: src/javascript/runtime/html4/Runtime.js
|
5851
|
-
|
5852
|
-
/**
|
5853
|
-
* Runtime.js
|
5854
|
-
*
|
5855
|
-
* Copyright 2013, Moxiecode Systems AB
|
5856
|
-
* Released under GPL License.
|
5857
|
-
*
|
5858
|
-
* License: http://www.plupload.com/license
|
5859
|
-
* Contributing: http://www.plupload.com/contributing
|
5860
|
-
*/
|
5861
|
-
|
5862
|
-
/*global File:true */
|
5863
|
-
|
5864
|
-
/**
|
5865
|
-
Defines constructor for HTML4 runtime.
|
5866
|
-
|
5867
|
-
@class moxie/runtime/html4/Runtime
|
5868
|
-
@private
|
5869
|
-
*/
|
5870
|
-
define("moxie/runtime/html4/Runtime", [
|
5871
|
-
"moxie/core/utils/Basic",
|
5872
|
-
"moxie/core/Exceptions",
|
5873
|
-
"moxie/runtime/Runtime",
|
5874
|
-
"moxie/core/utils/Env"
|
5875
|
-
], function(Basic, x, Runtime, Env) {
|
5876
|
-
|
5877
|
-
var type = 'html4', extensions = {};
|
5878
|
-
|
5879
|
-
function Html4Runtime(options) {
|
5880
|
-
var I = this
|
5881
|
-
, Test = Runtime.capTest
|
5882
|
-
, True = Runtime.capTrue
|
5883
|
-
;
|
5884
|
-
|
5885
|
-
Runtime.call(this, options, type, {
|
5886
|
-
access_binary: Test(window.FileReader || window.File && File.getAsDataURL),
|
5887
|
-
access_image_binary: false,
|
5888
|
-
display_media: Test(extensions.Image && (Env.can('create_canvas') || Env.can('use_data_uri_over32kb'))),
|
5889
|
-
do_cors: false,
|
5890
|
-
drag_and_drop: false,
|
5891
|
-
filter_by_extension: Test(function() { // if you know how to feature-detect this, please suggest
|
5892
|
-
return (Env.browser === 'Chrome' && Env.version >= 28) || (Env.browser === 'IE' && Env.version >= 10);
|
5893
|
-
}()),
|
5894
|
-
resize_image: function() {
|
5895
|
-
return extensions.Image && I.can('access_binary') && Env.can('create_canvas');
|
5896
|
-
},
|
5897
|
-
report_upload_progress: false,
|
5898
|
-
return_response_headers: false,
|
5899
|
-
return_response_type: function(responseType) {
|
5900
|
-
if (responseType === 'json' && !!window.JSON) {
|
5901
|
-
return true;
|
5902
|
-
}
|
5903
|
-
return !!~Basic.inArray(responseType, ['text', 'document', '']);
|
5904
|
-
},
|
5905
|
-
return_status_code: function(code) {
|
5906
|
-
return !Basic.arrayDiff(code, [200, 404]);
|
5907
|
-
},
|
5908
|
-
select_file: function() {
|
5909
|
-
return Env.can('use_fileinput');
|
5910
|
-
},
|
5911
|
-
select_multiple: false,
|
5912
|
-
send_binary_string: false,
|
5913
|
-
send_custom_headers: false,
|
5914
|
-
send_multipart: true,
|
5915
|
-
slice_blob: false,
|
5916
|
-
stream_upload: function() {
|
5917
|
-
return I.can('select_file');
|
5918
|
-
},
|
5919
|
-
summon_file_dialog: Test(function() { // yeah... some dirty sniffing here...
|
5920
|
-
return (Env.browser === 'Firefox' && Env.version >= 4) ||
|
5921
|
-
(Env.browser === 'Opera' && Env.version >= 12) ||
|
5922
|
-
!!~Basic.inArray(Env.browser, ['Chrome', 'Safari']);
|
5923
|
-
}()),
|
5924
|
-
upload_filesize: True,
|
5925
|
-
use_http_method: function(methods) {
|
5926
|
-
return !Basic.arrayDiff(methods, ['GET', 'POST']);
|
5927
|
-
}
|
5928
|
-
});
|
5929
|
-
|
5930
|
-
|
5931
|
-
Basic.extend(this, {
|
5932
|
-
init : function() {
|
5933
|
-
this.trigger("Init");
|
5934
|
-
},
|
5935
|
-
|
5936
|
-
destroy: (function(destroy) { // extend default destroy method
|
5937
|
-
return function() {
|
5938
|
-
destroy.call(I);
|
5939
|
-
destroy = I = null;
|
5940
|
-
};
|
5941
|
-
}(this.destroy))
|
5942
|
-
});
|
5943
|
-
|
5944
|
-
Basic.extend(this.getShim(), extensions);
|
5945
|
-
}
|
5946
|
-
|
5947
|
-
Runtime.addConstructor(type, Html4Runtime);
|
5948
|
-
|
5949
|
-
return extensions;
|
5950
|
-
});
|
5951
|
-
|
5952
|
-
// Included from: src/javascript/core/utils/Events.js
|
5953
|
-
|
5954
|
-
/**
|
5955
|
-
* Events.js
|
5956
|
-
*
|
5957
|
-
* Copyright 2013, Moxiecode Systems AB
|
5958
|
-
* Released under GPL License.
|
5959
|
-
*
|
5960
|
-
* License: http://www.plupload.com/license
|
5961
|
-
* Contributing: http://www.plupload.com/contributing
|
5962
|
-
*/
|
5963
|
-
|
5964
|
-
define('moxie/core/utils/Events', [
|
5965
|
-
'moxie/core/utils/Basic'
|
5966
|
-
], function(Basic) {
|
5967
|
-
var eventhash = {}, uid = 'moxie_' + Basic.guid();
|
5968
|
-
|
5969
|
-
// IE W3C like event funcs
|
5970
|
-
function preventDefault() {
|
5971
|
-
this.returnValue = false;
|
5972
|
-
}
|
5973
|
-
|
5974
|
-
function stopPropagation() {
|
5975
|
-
this.cancelBubble = true;
|
5976
|
-
}
|
5977
|
-
|
5978
|
-
/**
|
5979
|
-
Adds an event handler to the specified object and store reference to the handler
|
5980
|
-
in objects internal Plupload registry (@see removeEvent).
|
5981
|
-
|
5982
|
-
@method addEvent
|
5983
|
-
@for Utils
|
5984
|
-
@static
|
5985
|
-
@param {Object} obj DOM element like object to add handler to.
|
5986
|
-
@param {String} name Name to add event listener to.
|
5987
|
-
@param {Function} callback Function to call when event occurs.
|
5988
|
-
@param {String} [key] that might be used to add specifity to the event record.
|
5989
|
-
*/
|
5990
|
-
var addEvent = function(obj, name, callback, key) {
|
5991
|
-
var func, events;
|
5992
|
-
|
5993
|
-
name = name.toLowerCase();
|
5994
|
-
|
5995
|
-
// Add event listener
|
5996
|
-
if (obj.addEventListener) {
|
5997
|
-
func = callback;
|
5998
|
-
|
5999
|
-
obj.addEventListener(name, func, false);
|
6000
|
-
} else if (obj.attachEvent) {
|
6001
|
-
func = function() {
|
6002
|
-
var evt = window.event;
|
6003
|
-
|
6004
|
-
if (!evt.target) {
|
6005
|
-
evt.target = evt.srcElement;
|
6006
|
-
}
|
6007
|
-
|
6008
|
-
evt.preventDefault = preventDefault;
|
6009
|
-
evt.stopPropagation = stopPropagation;
|
6010
|
-
|
6011
|
-
callback(evt);
|
6012
|
-
};
|
6013
|
-
|
6014
|
-
obj.attachEvent('on' + name, func);
|
6015
|
-
}
|
6016
|
-
|
6017
|
-
// Log event handler to objects internal mOxie registry
|
6018
|
-
if (!obj[uid]) {
|
6019
|
-
obj[uid] = Basic.guid();
|
6020
|
-
}
|
6021
|
-
|
6022
|
-
if (!eventhash.hasOwnProperty(obj[uid])) {
|
6023
|
-
eventhash[obj[uid]] = {};
|
6024
|
-
}
|
6025
|
-
|
6026
|
-
events = eventhash[obj[uid]];
|
6027
|
-
|
6028
|
-
if (!events.hasOwnProperty(name)) {
|
6029
|
-
events[name] = [];
|
6030
|
-
}
|
6031
|
-
|
6032
|
-
events[name].push({
|
6033
|
-
func: func,
|
6034
|
-
orig: callback, // store original callback for IE
|
6035
|
-
key: key
|
6036
|
-
});
|
6037
|
-
};
|
6038
|
-
|
6039
|
-
|
6040
|
-
/**
|
6041
|
-
Remove event handler from the specified object. If third argument (callback)
|
6042
|
-
is not specified remove all events with the specified name.
|
6043
|
-
|
6044
|
-
@method removeEvent
|
6045
|
-
@static
|
6046
|
-
@param {Object} obj DOM element to remove event listener(s) from.
|
6047
|
-
@param {String} name Name of event listener to remove.
|
6048
|
-
@param {Function|String} [callback] might be a callback or unique key to match.
|
6049
|
-
*/
|
6050
|
-
var removeEvent = function(obj, name, callback) {
|
6051
|
-
var type, undef;
|
6052
|
-
|
6053
|
-
name = name.toLowerCase();
|
6054
|
-
|
6055
|
-
if (obj[uid] && eventhash[obj[uid]] && eventhash[obj[uid]][name]) {
|
6056
|
-
type = eventhash[obj[uid]][name];
|
6057
|
-
} else {
|
6058
|
-
return;
|
6059
|
-
}
|
6060
|
-
|
6061
|
-
for (var i = type.length - 1; i >= 0; i--) {
|
6062
|
-
// undefined or not, key should match
|
6063
|
-
if (type[i].orig === callback || type[i].key === callback) {
|
6064
|
-
if (obj.removeEventListener) {
|
6065
|
-
obj.removeEventListener(name, type[i].func, false);
|
6066
|
-
} else if (obj.detachEvent) {
|
6067
|
-
obj.detachEvent('on'+name, type[i].func);
|
6068
|
-
}
|
6069
|
-
|
6070
|
-
type[i].orig = null;
|
6071
|
-
type[i].func = null;
|
6072
|
-
type.splice(i, 1);
|
6073
|
-
|
6074
|
-
// If callback was passed we are done here, otherwise proceed
|
6075
|
-
if (callback !== undef) {
|
6076
|
-
break;
|
6077
|
-
}
|
6078
|
-
}
|
6079
|
-
}
|
6080
|
-
|
6081
|
-
// If event array got empty, remove it
|
6082
|
-
if (!type.length) {
|
6083
|
-
delete eventhash[obj[uid]][name];
|
6084
|
-
}
|
6085
|
-
|
6086
|
-
// If mOxie registry has become empty, remove it
|
6087
|
-
if (Basic.isEmptyObj(eventhash[obj[uid]])) {
|
6088
|
-
delete eventhash[obj[uid]];
|
6089
|
-
|
6090
|
-
// IE doesn't let you remove DOM object property with - delete
|
6091
|
-
try {
|
6092
|
-
delete obj[uid];
|
6093
|
-
} catch(e) {
|
6094
|
-
obj[uid] = undef;
|
6095
|
-
}
|
6096
|
-
}
|
6097
|
-
};
|
6098
|
-
|
6099
|
-
|
6100
|
-
/**
|
6101
|
-
Remove all kind of events from the specified object
|
6102
|
-
|
6103
|
-
@method removeAllEvents
|
6104
|
-
@static
|
6105
|
-
@param {Object} obj DOM element to remove event listeners from.
|
6106
|
-
@param {String} [key] unique key to match, when removing events.
|
6107
|
-
*/
|
6108
|
-
var removeAllEvents = function(obj, key) {
|
6109
|
-
if (!obj || !obj[uid]) {
|
6110
|
-
return;
|
6111
|
-
}
|
6112
|
-
|
6113
|
-
Basic.each(eventhash[obj[uid]], function(events, name) {
|
6114
|
-
removeEvent(obj, name, key);
|
6115
|
-
});
|
6116
|
-
};
|
6117
|
-
|
6118
|
-
return {
|
6119
|
-
addEvent: addEvent,
|
6120
|
-
removeEvent: removeEvent,
|
6121
|
-
removeAllEvents: removeAllEvents
|
6122
|
-
};
|
6123
|
-
});
|
6124
|
-
|
6125
|
-
// Included from: src/javascript/runtime/html4/file/FileInput.js
|
5134
|
+
// Included from: src/javascript/runtime/Transporter.js
|
6126
5135
|
|
6127
5136
|
/**
|
6128
|
-
*
|
5137
|
+
* Transporter.js
|
6129
5138
|
*
|
6130
5139
|
* Copyright 2013, Moxiecode Systems AB
|
6131
5140
|
* Released under GPL License.
|
@@ -6134,712 +5143,741 @@ define('moxie/core/utils/Events', [
|
|
6134
5143
|
* Contributing: http://www.plupload.com/contributing
|
6135
5144
|
*/
|
6136
5145
|
|
6137
|
-
|
6138
|
-
@class moxie/runtime/html4/file/FileInput
|
6139
|
-
@private
|
6140
|
-
*/
|
6141
|
-
define("moxie/runtime/html4/file/FileInput", [
|
6142
|
-
"moxie/runtime/html4/Runtime",
|
5146
|
+
define("moxie/runtime/Transporter", [
|
6143
5147
|
"moxie/core/utils/Basic",
|
6144
|
-
"moxie/core/utils/
|
6145
|
-
"moxie/
|
6146
|
-
"moxie/core/
|
6147
|
-
|
6148
|
-
|
6149
|
-
|
6150
|
-
function FileInput() {
|
6151
|
-
var _uid, _files = [], _mimes = [], _options;
|
5148
|
+
"moxie/core/utils/Encode",
|
5149
|
+
"moxie/runtime/RuntimeClient",
|
5150
|
+
"moxie/core/EventTarget"
|
5151
|
+
], function(Basic, Encode, RuntimeClient, EventTarget) {
|
5152
|
+
function Transporter() {
|
5153
|
+
var mod, _runtime, _data, _size, _pos, _chunk_size;
|
6152
5154
|
|
6153
|
-
|
6154
|
-
var comp = this, I = comp.getRuntime(), shimContainer, browseButton, currForm, form, input, uid;
|
5155
|
+
RuntimeClient.call(this);
|
6155
5156
|
|
6156
|
-
|
5157
|
+
Basic.extend(this, {
|
5158
|
+
uid: Basic.guid('uid_'),
|
6157
5159
|
|
6158
|
-
|
5160
|
+
state: Transporter.IDLE,
|
6159
5161
|
|
6160
|
-
|
6161
|
-
currForm = Dom.get(_uid + '_form');
|
6162
|
-
if (currForm) {
|
6163
|
-
Basic.extend(currForm.style, { top: '100%' });
|
6164
|
-
}
|
6165
|
-
}
|
5162
|
+
result: null,
|
6166
5163
|
|
6167
|
-
|
6168
|
-
|
6169
|
-
form.setAttribute('id', uid + '_form');
|
6170
|
-
form.setAttribute('method', 'post');
|
6171
|
-
form.setAttribute('enctype', 'multipart/form-data');
|
6172
|
-
form.setAttribute('encoding', 'multipart/form-data');
|
6173
|
-
|
6174
|
-
Basic.extend(form.style, {
|
6175
|
-
overflow: 'hidden',
|
6176
|
-
position: 'absolute',
|
6177
|
-
top: 0,
|
6178
|
-
left: 0,
|
6179
|
-
width: '100%',
|
6180
|
-
height: '100%'
|
6181
|
-
});
|
5164
|
+
transport: function(data, type, options) {
|
5165
|
+
var self = this;
|
6182
5166
|
|
6183
|
-
|
6184
|
-
|
6185
|
-
|
6186
|
-
input.setAttribute('name', _options.name || 'Filedata');
|
6187
|
-
input.setAttribute('accept', _mimes.join(','));
|
5167
|
+
options = Basic.extend({
|
5168
|
+
chunk_size: 204798
|
5169
|
+
}, options);
|
6188
5170
|
|
6189
|
-
|
6190
|
-
|
6191
|
-
|
6192
|
-
|
5171
|
+
// should divide by three, base64 requires this
|
5172
|
+
if ((mod = options.chunk_size % 3)) {
|
5173
|
+
options.chunk_size += 3 - mod;
|
5174
|
+
}
|
6193
5175
|
|
6194
|
-
|
6195
|
-
shimContainer.appendChild(form);
|
5176
|
+
_chunk_size = options.chunk_size;
|
6196
5177
|
|
6197
|
-
|
6198
|
-
|
6199
|
-
|
6200
|
-
top: 0,
|
6201
|
-
left: 0,
|
6202
|
-
width: '100%',
|
6203
|
-
height: '100%'
|
6204
|
-
});
|
5178
|
+
_reset.call(this);
|
5179
|
+
_data = data;
|
5180
|
+
_size = data.length;
|
6205
5181
|
|
6206
|
-
|
6207
|
-
|
6208
|
-
|
6209
|
-
|
6210
|
-
|
5182
|
+
if (Basic.typeOf(options) === 'string' || options.ruid) {
|
5183
|
+
_run.call(self, type, this.connectRuntime(options));
|
5184
|
+
} else {
|
5185
|
+
// we require this to run only once
|
5186
|
+
var cb = function(e, runtime) {
|
5187
|
+
self.unbind("RuntimeInit", cb);
|
5188
|
+
_run.call(self, type, runtime);
|
5189
|
+
};
|
5190
|
+
this.bind("RuntimeInit", cb);
|
5191
|
+
this.connectRuntime(options);
|
5192
|
+
}
|
5193
|
+
},
|
6211
5194
|
|
6212
|
-
|
6213
|
-
var
|
5195
|
+
abort: function() {
|
5196
|
+
var self = this;
|
6214
5197
|
|
6215
|
-
|
6216
|
-
|
5198
|
+
self.state = Transporter.IDLE;
|
5199
|
+
if (_runtime) {
|
5200
|
+
_runtime.exec.call(self, 'Transporter', 'clear');
|
5201
|
+
self.trigger("TransportingAborted");
|
6217
5202
|
}
|
6218
5203
|
|
6219
|
-
|
6220
|
-
|
6221
|
-
} else {
|
6222
|
-
file = {
|
6223
|
-
name: this.value
|
6224
|
-
};
|
6225
|
-
}
|
5204
|
+
_reset.call(self);
|
5205
|
+
},
|
6226
5206
|
|
6227
|
-
_files = [file];
|
6228
5207
|
|
6229
|
-
|
6230
|
-
|
5208
|
+
destroy: function() {
|
5209
|
+
this.unbindAll();
|
5210
|
+
_runtime = null;
|
5211
|
+
this.disconnectRuntime();
|
5212
|
+
_reset.call(this);
|
5213
|
+
}
|
5214
|
+
});
|
6231
5215
|
|
6232
|
-
|
6233
|
-
|
6234
|
-
|
5216
|
+
function _reset() {
|
5217
|
+
_size = _pos = 0;
|
5218
|
+
_data = this.result = null;
|
5219
|
+
}
|
6235
5220
|
|
6236
|
-
|
5221
|
+
function _run(type, runtime) {
|
5222
|
+
var self = this;
|
6237
5223
|
|
6238
|
-
|
6239
|
-
file = comp.files[0];
|
5224
|
+
_runtime = runtime;
|
6240
5225
|
|
6241
|
-
|
6242
|
-
form.setAttribute('id', file.uid + '_form');
|
5226
|
+
//self.unbind("RuntimeInit");
|
6243
5227
|
|
6244
|
-
|
6245
|
-
|
6246
|
-
}
|
6247
|
-
input = form = null;
|
6248
|
-
}, 998);
|
5228
|
+
self.bind("TransportingProgress", function(e) {
|
5229
|
+
_pos = e.loaded;
|
6249
5230
|
|
6250
|
-
|
6251
|
-
|
6252
|
-
|
5231
|
+
if (_pos < _size && Basic.inArray(self.state, [Transporter.IDLE, Transporter.DONE]) === -1) {
|
5232
|
+
_transport.call(self);
|
5233
|
+
}
|
5234
|
+
}, 999);
|
6253
5235
|
|
5236
|
+
self.bind("TransportingComplete", function() {
|
5237
|
+
_pos = _size;
|
5238
|
+
self.state = Transporter.DONE;
|
5239
|
+
_data = null; // clean a bit
|
5240
|
+
self.result = _runtime.exec.call(self, 'Transporter', 'getAsBlob', type || '');
|
5241
|
+
}, 999);
|
6254
5242
|
|
6255
|
-
|
6256
|
-
|
6257
|
-
|
6258
|
-
|
6259
|
-
|
6260
|
-
|
6261
|
-
|
6262
|
-
|
6263
|
-
|
6264
|
-
}, comp.uid);
|
6265
|
-
}
|
5243
|
+
self.state = Transporter.BUSY;
|
5244
|
+
self.trigger("TransportingStarted");
|
5245
|
+
_transport.call(self);
|
5246
|
+
}
|
5247
|
+
|
5248
|
+
function _transport() {
|
5249
|
+
var self = this,
|
5250
|
+
chunk,
|
5251
|
+
bytesLeft = _size - _pos;
|
6266
5252
|
|
6267
|
-
|
5253
|
+
if (_chunk_size > bytesLeft) {
|
5254
|
+
_chunk_size = bytesLeft;
|
5255
|
+
}
|
6268
5256
|
|
6269
|
-
|
5257
|
+
chunk = Encode.btoa(_data.substr(_pos, _chunk_size));
|
5258
|
+
_runtime.exec.call(self, 'Transporter', 'receive', chunk, _size);
|
6270
5259
|
}
|
5260
|
+
}
|
6271
5261
|
|
6272
|
-
|
6273
|
-
|
6274
|
-
|
5262
|
+
Transporter.IDLE = 0;
|
5263
|
+
Transporter.BUSY = 1;
|
5264
|
+
Transporter.DONE = 2;
|
5265
|
+
|
5266
|
+
Transporter.prototype = EventTarget.instance;
|
5267
|
+
|
5268
|
+
return Transporter;
|
5269
|
+
});
|
6275
5270
|
|
6276
|
-
|
6277
|
-
_options = options;
|
6278
|
-
_mimes = options.accept.mimes || Mime.extList2mimes(options.accept, I.can('filter_by_extension'));
|
5271
|
+
// Included from: src/javascript/image/Image.js
|
6279
5272
|
|
6280
|
-
|
5273
|
+
/**
|
5274
|
+
* Image.js
|
5275
|
+
*
|
5276
|
+
* Copyright 2013, Moxiecode Systems AB
|
5277
|
+
* Released under GPL License.
|
5278
|
+
*
|
5279
|
+
* License: http://www.plupload.com/license
|
5280
|
+
* Contributing: http://www.plupload.com/contributing
|
5281
|
+
*/
|
6281
5282
|
|
6282
|
-
|
6283
|
-
|
5283
|
+
define("moxie/image/Image", [
|
5284
|
+
"moxie/core/utils/Basic",
|
5285
|
+
"moxie/core/utils/Dom",
|
5286
|
+
"moxie/core/Exceptions",
|
5287
|
+
"moxie/file/FileReaderSync",
|
5288
|
+
"moxie/xhr/XMLHttpRequest",
|
5289
|
+
"moxie/runtime/Runtime",
|
5290
|
+
"moxie/runtime/RuntimeClient",
|
5291
|
+
"moxie/runtime/Transporter",
|
5292
|
+
"moxie/core/utils/Env",
|
5293
|
+
"moxie/core/EventTarget",
|
5294
|
+
"moxie/file/Blob",
|
5295
|
+
"moxie/file/File",
|
5296
|
+
"moxie/core/utils/Encode"
|
5297
|
+
], function(Basic, Dom, x, FileReaderSync, XMLHttpRequest, Runtime, RuntimeClient, Transporter, Env, EventTarget, Blob, File, Encode) {
|
5298
|
+
/**
|
5299
|
+
Image preloading and manipulation utility. Additionally it provides access to image meta info (Exif, GPS) and raw binary data.
|
6284
5300
|
|
6285
|
-
|
5301
|
+
@class Image
|
5302
|
+
@constructor
|
5303
|
+
@extends EventTarget
|
5304
|
+
*/
|
5305
|
+
var dispatches = [
|
5306
|
+
'progress',
|
6286
5307
|
|
6287
|
-
|
6288
|
-
|
6289
|
-
if (Dom.getStyle(browseButton, 'position') === 'static') {
|
6290
|
-
browseButton.style.position = 'relative';
|
6291
|
-
}
|
5308
|
+
/**
|
5309
|
+
Dispatched when loading is complete.
|
6292
5310
|
|
6293
|
-
|
5311
|
+
@event load
|
5312
|
+
@param {Object} event
|
5313
|
+
*/
|
5314
|
+
'load',
|
6294
5315
|
|
6295
|
-
|
6296
|
-
shimContainer.style.zIndex = zIndex - 1;
|
6297
|
-
}
|
5316
|
+
'error',
|
6298
5317
|
|
6299
|
-
|
6300
|
-
|
6301
|
-
|
5318
|
+
/**
|
5319
|
+
Dispatched when resize operation is complete.
|
5320
|
+
|
5321
|
+
@event resize
|
5322
|
+
@param {Object} event
|
5323
|
+
*/
|
5324
|
+
'resize',
|
6302
5325
|
|
6303
|
-
|
6304
|
-
|
6305
|
-
|
5326
|
+
/**
|
5327
|
+
Dispatched when visual representation of the image is successfully embedded
|
5328
|
+
into the corresponsing container.
|
6306
5329
|
|
6307
|
-
|
6308
|
-
|
6309
|
-
|
5330
|
+
@event embedded
|
5331
|
+
@param {Object} event
|
5332
|
+
*/
|
5333
|
+
'embedded'
|
5334
|
+
];
|
6310
5335
|
|
6311
|
-
|
6312
|
-
|
6313
|
-
}, comp.uid);
|
5336
|
+
function Image() {
|
5337
|
+
RuntimeClient.call(this);
|
6314
5338
|
|
6315
|
-
|
6316
|
-
|
6317
|
-
|
5339
|
+
Basic.extend(this, {
|
5340
|
+
/**
|
5341
|
+
Unique id of the component
|
6318
5342
|
|
6319
|
-
|
6320
|
-
|
5343
|
+
@property uid
|
5344
|
+
@type {String}
|
5345
|
+
*/
|
5346
|
+
uid: Basic.guid('uid_'),
|
6321
5347
|
|
6322
|
-
|
5348
|
+
/**
|
5349
|
+
Unique id of the connected runtime, if any.
|
6323
5350
|
|
6324
|
-
|
5351
|
+
@property ruid
|
5352
|
+
@type {String}
|
5353
|
+
*/
|
5354
|
+
ruid: null,
|
6325
5355
|
|
6326
|
-
|
6327
|
-
|
6328
|
-
type: 'ready',
|
6329
|
-
async: true
|
6330
|
-
});
|
6331
|
-
},
|
5356
|
+
/**
|
5357
|
+
Name of the file, that was used to create an image, if available. If not equals to empty string.
|
6332
5358
|
|
6333
|
-
|
6334
|
-
|
6335
|
-
|
5359
|
+
@property name
|
5360
|
+
@type {String}
|
5361
|
+
@default ""
|
5362
|
+
*/
|
5363
|
+
name: "",
|
6336
5364
|
|
6337
|
-
|
6338
|
-
|
5365
|
+
/**
|
5366
|
+
Size of the image in bytes. Actual value is set only after image is preloaded.
|
6339
5367
|
|
6340
|
-
|
6341
|
-
|
6342
|
-
|
6343
|
-
|
5368
|
+
@property size
|
5369
|
+
@type {Number}
|
5370
|
+
@default 0
|
5371
|
+
*/
|
5372
|
+
size: 0,
|
6344
5373
|
|
6345
|
-
|
6346
|
-
|
6347
|
-
, shim = I.getShim()
|
6348
|
-
, shimContainer = I.getShimContainer()
|
6349
|
-
;
|
6350
|
-
|
6351
|
-
Events.removeAllEvents(shimContainer, this.uid);
|
6352
|
-
Events.removeAllEvents(_options && Dom.get(_options.container), this.uid);
|
6353
|
-
Events.removeAllEvents(_options && Dom.get(_options.browse_button), this.uid);
|
6354
|
-
|
6355
|
-
if (shimContainer) {
|
6356
|
-
shimContainer.innerHTML = '';
|
6357
|
-
}
|
5374
|
+
/**
|
5375
|
+
Width of the image. Actual value is set only after image is preloaded.
|
6358
5376
|
|
6359
|
-
|
5377
|
+
@property width
|
5378
|
+
@type {Number}
|
5379
|
+
@default 0
|
5380
|
+
*/
|
5381
|
+
width: 0,
|
6360
5382
|
|
6361
|
-
|
6362
|
-
|
6363
|
-
});
|
6364
|
-
}
|
5383
|
+
/**
|
5384
|
+
Height of the image. Actual value is set only after image is preloaded.
|
6365
5385
|
|
6366
|
-
|
6367
|
-
}
|
5386
|
+
@property height
|
5387
|
+
@type {Number}
|
5388
|
+
@default 0
|
5389
|
+
*/
|
5390
|
+
height: 0,
|
6368
5391
|
|
6369
|
-
|
5392
|
+
/**
|
5393
|
+
Mime type of the image. Currently only image/jpeg and image/png are supported. Actual value is set only after image is preloaded.
|
6370
5394
|
|
6371
|
-
|
6372
|
-
|
6373
|
-
|
6374
|
-
|
6375
|
-
|
6376
|
-
*
|
6377
|
-
* License: http://www.plupload.com/license
|
6378
|
-
* Contributing: http://www.plupload.com/contributing
|
6379
|
-
*/
|
5395
|
+
@property type
|
5396
|
+
@type {String}
|
5397
|
+
@default ""
|
5398
|
+
*/
|
5399
|
+
type: "",
|
6380
5400
|
|
6381
|
-
|
5401
|
+
/**
|
5402
|
+
Holds meta info (Exif, GPS). Is populated only for image/jpeg. Actual value is set only after image is preloaded.
|
6382
5403
|
|
6383
|
-
|
6384
|
-
|
5404
|
+
@property meta
|
5405
|
+
@type {Object}
|
5406
|
+
@default {}
|
5407
|
+
*/
|
5408
|
+
meta: {},
|
6385
5409
|
|
6386
|
-
|
6387
|
-
|
6388
|
-
*/
|
6389
|
-
define("moxie/runtime/html5/Runtime", [
|
6390
|
-
"moxie/core/utils/Basic",
|
6391
|
-
"moxie/core/Exceptions",
|
6392
|
-
"moxie/runtime/Runtime",
|
6393
|
-
"moxie/core/utils/Env"
|
6394
|
-
], function(Basic, x, Runtime, Env) {
|
6395
|
-
|
6396
|
-
var type = "html5", extensions = {};
|
6397
|
-
|
6398
|
-
function Html5Runtime(options) {
|
6399
|
-
var I = this
|
6400
|
-
, Test = Runtime.capTest
|
6401
|
-
, True = Runtime.capTrue
|
6402
|
-
;
|
5410
|
+
/**
|
5411
|
+
Alias for load method, that takes another mOxie.Image object as a source (see load).
|
6403
5412
|
|
6404
|
-
|
6405
|
-
|
6406
|
-
|
6407
|
-
|
6408
|
-
|
6409
|
-
|
6410
|
-
|
6411
|
-
drag_and_drop: Test(function() {
|
6412
|
-
// this comes directly from Modernizr: http://www.modernizr.com/
|
6413
|
-
var div = document.createElement('div');
|
6414
|
-
// IE has support for drag and drop since version 5, but doesn't support dropping files from desktop
|
6415
|
-
return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div)) && (Env.browser !== 'IE' || Env.version > 9);
|
6416
|
-
}()),
|
6417
|
-
filter_by_extension: Test(function() { // if you know how to feature-detect this, please suggest
|
6418
|
-
return (Env.browser === 'Chrome' && Env.version >= 28) || (Env.browser === 'IE' && Env.version >= 10);
|
6419
|
-
}()),
|
6420
|
-
return_response_headers: True,
|
6421
|
-
return_response_type: function(responseType) {
|
6422
|
-
if (responseType === 'json' && !!window.JSON) { // we can fake this one even if it's not supported
|
6423
|
-
return true;
|
6424
|
-
}
|
6425
|
-
return Env.can('return_response_type', responseType);
|
6426
|
-
},
|
6427
|
-
return_status_code: True,
|
6428
|
-
report_upload_progress: Test(window.XMLHttpRequest && new XMLHttpRequest().upload),
|
6429
|
-
resize_image: function() {
|
6430
|
-
return I.can('access_binary') && Env.can('create_canvas');
|
6431
|
-
},
|
6432
|
-
select_file: function() {
|
6433
|
-
return Env.can('use_fileinput') && window.File;
|
6434
|
-
},
|
6435
|
-
select_folder: function() {
|
6436
|
-
return I.can('select_file') && Env.browser === 'Chrome' && Env.version >= 21;
|
6437
|
-
},
|
6438
|
-
select_multiple: function() {
|
6439
|
-
// it is buggy on Safari Windows and iOS
|
6440
|
-
return I.can('select_file') &&
|
6441
|
-
!(Env.browser === 'Safari' && Env.os === 'Windows') &&
|
6442
|
-
!(Env.os === 'iOS' && Env.verComp(Env.osVersion, "7.0.4", '<'));
|
6443
|
-
},
|
6444
|
-
send_binary_string: Test(window.XMLHttpRequest && (new XMLHttpRequest().sendAsBinary || (window.Uint8Array && window.ArrayBuffer))),
|
6445
|
-
send_custom_headers: Test(window.XMLHttpRequest),
|
6446
|
-
send_multipart: function() {
|
6447
|
-
return !!(window.XMLHttpRequest && new XMLHttpRequest().upload && window.FormData) || I.can('send_binary_string');
|
6448
|
-
},
|
6449
|
-
slice_blob: Test(window.File && (File.prototype.mozSlice || File.prototype.webkitSlice || File.prototype.slice)),
|
6450
|
-
stream_upload: function(){
|
6451
|
-
return I.can('slice_blob') && I.can('send_multipart');
|
6452
|
-
},
|
6453
|
-
summon_file_dialog: Test(function() { // yeah... some dirty sniffing here...
|
6454
|
-
return (Env.browser === 'Firefox' && Env.version >= 4) ||
|
6455
|
-
(Env.browser === 'Opera' && Env.version >= 12) ||
|
6456
|
-
(Env.browser === 'IE' && Env.version >= 10) ||
|
6457
|
-
!!~Basic.inArray(Env.browser, ['Chrome', 'Safari']);
|
6458
|
-
}()),
|
6459
|
-
upload_filesize: True
|
6460
|
-
},
|
6461
|
-
arguments[2]
|
6462
|
-
);
|
5413
|
+
@method clone
|
5414
|
+
@param {Image} src Source for the image
|
5415
|
+
@param {Boolean} [exact=false] Whether to activate in-depth clone mode
|
5416
|
+
*/
|
5417
|
+
clone: function() {
|
5418
|
+
this.load.apply(this, arguments);
|
5419
|
+
},
|
6463
5420
|
|
6464
|
-
|
5421
|
+
/**
|
5422
|
+
Loads image from various sources. Currently the source for new image can be: mOxie.Image, mOxie.Blob/mOxie.File,
|
5423
|
+
native Blob/File, dataUrl or URL. Depending on the type of the source, arguments - differ. When source is URL,
|
5424
|
+
Image will be downloaded from remote destination and loaded in memory.
|
5425
|
+
|
5426
|
+
@example
|
5427
|
+
var img = new mOxie.Image();
|
5428
|
+
img.onload = function() {
|
5429
|
+
var blob = img.getAsBlob();
|
5430
|
+
|
5431
|
+
var formData = new mOxie.FormData();
|
5432
|
+
formData.append('file', blob);
|
5433
|
+
|
5434
|
+
var xhr = new mOxie.XMLHttpRequest();
|
5435
|
+
xhr.onload = function() {
|
5436
|
+
// upload complete
|
5437
|
+
};
|
5438
|
+
xhr.open('post', 'upload.php');
|
5439
|
+
xhr.send(formData);
|
5440
|
+
};
|
5441
|
+
img.load("http://www.moxiecode.com/images/mox-logo.jpg"); // notice file extension (.jpg)
|
5442
|
+
|
6465
5443
|
|
5444
|
+
@method load
|
5445
|
+
@param {Image|Blob|File|String} src Source for the image
|
5446
|
+
@param {Boolean|Object} [mixed]
|
5447
|
+
*/
|
5448
|
+
load: function() {
|
5449
|
+
// this is here because to bind properly we need an uid first, which is created above
|
5450
|
+
this.bind('Load Resize', function() {
|
5451
|
+
_updateInfo.call(this);
|
5452
|
+
}, 999);
|
6466
5453
|
|
6467
|
-
|
5454
|
+
this.convertEventPropsToHandlers(dispatches);
|
6468
5455
|
|
6469
|
-
|
6470
|
-
this.trigger("Init");
|
5456
|
+
_load.apply(this, arguments);
|
6471
5457
|
},
|
6472
5458
|
|
6473
|
-
|
6474
|
-
|
6475
|
-
|
6476
|
-
|
5459
|
+
/**
|
5460
|
+
Downsizes the image to fit the specified width/height. If crop is supplied, image will be cropped to exact dimensions.
|
5461
|
+
|
5462
|
+
@method downsize
|
5463
|
+
@param {Number} width Resulting width
|
5464
|
+
@param {Number} [height=width] Resulting height (optional, if not supplied will default to width)
|
5465
|
+
@param {Boolean} [crop=false] Whether to crop the image to exact dimensions
|
5466
|
+
@param {Boolean} [preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize)
|
5467
|
+
*/
|
5468
|
+
downsize: function(opts) {
|
5469
|
+
var defaults = {
|
5470
|
+
width: this.width,
|
5471
|
+
height: this.height,
|
5472
|
+
crop: false,
|
5473
|
+
preserveHeaders: true
|
6477
5474
|
};
|
6478
|
-
}(this.destroy))
|
6479
|
-
});
|
6480
5475
|
|
6481
|
-
|
6482
|
-
|
5476
|
+
if (typeof(opts) === 'object') {
|
5477
|
+
opts = Basic.extend(defaults, opts);
|
5478
|
+
} else {
|
5479
|
+
opts = Basic.extend(defaults, {
|
5480
|
+
width: arguments[0],
|
5481
|
+
height: arguments[1],
|
5482
|
+
crop: arguments[2],
|
5483
|
+
preserveHeaders: arguments[3]
|
5484
|
+
});
|
5485
|
+
}
|
6483
5486
|
|
6484
|
-
|
5487
|
+
try {
|
5488
|
+
if (!this.size) { // only preloaded image objects can be used as source
|
5489
|
+
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
|
5490
|
+
}
|
6485
5491
|
|
6486
|
-
|
6487
|
-
|
5492
|
+
// no way to reliably intercept the crash due to high resolution, so we simply avoid it
|
5493
|
+
if (this.width > Image.MAX_RESIZE_WIDTH || this.height > Image.MAX_RESIZE_HEIGHT) {
|
5494
|
+
throw new x.ImageError(x.ImageError.MAX_RESOLUTION_ERR);
|
5495
|
+
}
|
6488
5496
|
|
6489
|
-
|
5497
|
+
this.getRuntime().exec.call(this, 'Image', 'downsize', opts.width, opts.height, opts.crop, opts.preserveHeaders);
|
5498
|
+
} catch(ex) {
|
5499
|
+
// for now simply trigger error event
|
5500
|
+
this.trigger('error', ex.code);
|
5501
|
+
}
|
5502
|
+
},
|
6490
5503
|
|
6491
|
-
/**
|
6492
|
-
|
6493
|
-
|
6494
|
-
|
6495
|
-
|
6496
|
-
|
6497
|
-
|
6498
|
-
|
6499
|
-
|
5504
|
+
/**
|
5505
|
+
Alias for downsize(width, height, true). (see downsize)
|
5506
|
+
|
5507
|
+
@method crop
|
5508
|
+
@param {Number} width Resulting width
|
5509
|
+
@param {Number} [height=width] Resulting height (optional, if not supplied will default to width)
|
5510
|
+
@param {Boolean} [preserveHeaders=true] Whether to preserve meta headers (on JPEGs after resize)
|
5511
|
+
*/
|
5512
|
+
crop: function(width, height, preserveHeaders) {
|
5513
|
+
this.downsize(width, height, true, preserveHeaders);
|
5514
|
+
},
|
6500
5515
|
|
6501
|
-
|
6502
|
-
|
6503
|
-
|
6504
|
-
|
6505
|
-
define("moxie/runtime/html5/file/FileReader", [
|
6506
|
-
"moxie/runtime/html5/Runtime",
|
6507
|
-
"moxie/core/utils/Encode",
|
6508
|
-
"moxie/core/utils/Basic"
|
6509
|
-
], function(extensions, Encode, Basic) {
|
6510
|
-
|
6511
|
-
function FileReader() {
|
6512
|
-
var _fr, _convertToBinary = false;
|
5516
|
+
getAsCanvas: function() {
|
5517
|
+
if (!Env.can('create_canvas')) {
|
5518
|
+
throw new x.RuntimeError(x.RuntimeError.NOT_SUPPORTED_ERR);
|
5519
|
+
}
|
6513
5520
|
|
6514
|
-
|
5521
|
+
var runtime = this.connectRuntime(this.ruid);
|
5522
|
+
return runtime.exec.call(this, 'Image', 'getAsCanvas');
|
5523
|
+
},
|
6515
5524
|
|
6516
|
-
|
6517
|
-
|
5525
|
+
/**
|
5526
|
+
Retrieves image in it's current state as mOxie.Blob object. Cannot be run on empty or image in progress (throws
|
5527
|
+
DOMException.INVALID_STATE_ERR).
|
6518
5528
|
|
6519
|
-
|
5529
|
+
@method getAsBlob
|
5530
|
+
@param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png
|
5531
|
+
@param {Number} [quality=90] Applicable only together with mime type image/jpeg
|
5532
|
+
@return {Blob} Image as Blob
|
5533
|
+
*/
|
5534
|
+
getAsBlob: function(type, quality) {
|
5535
|
+
if (!this.size) {
|
5536
|
+
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
|
5537
|
+
}
|
6520
5538
|
|
6521
|
-
|
6522
|
-
|
6523
|
-
}
|
5539
|
+
if (!type) {
|
5540
|
+
type = 'image/jpeg';
|
5541
|
+
}
|
6524
5542
|
|
6525
|
-
|
6526
|
-
|
6527
|
-
}
|
5543
|
+
if (type === 'image/jpeg' && !quality) {
|
5544
|
+
quality = 90;
|
5545
|
+
}
|
6528
5546
|
|
6529
|
-
|
6530
|
-
|
6531
|
-
});
|
5547
|
+
return this.getRuntime().exec.call(this, 'Image', 'getAsBlob', type, quality);
|
5548
|
+
},
|
6532
5549
|
|
6533
|
-
|
6534
|
-
|
6535
|
-
|
5550
|
+
/**
|
5551
|
+
Retrieves image in it's current state as dataURL string. Cannot be run on empty or image in progress (throws
|
5552
|
+
DOMException.INVALID_STATE_ERR).
|
6536
5553
|
|
6537
|
-
|
6538
|
-
|
6539
|
-
|
6540
|
-
|
6541
|
-
|
6542
|
-
|
5554
|
+
@method getAsDataURL
|
5555
|
+
@param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png
|
5556
|
+
@param {Number} [quality=90] Applicable only together with mime type image/jpeg
|
5557
|
+
@return {String} Image as dataURL string
|
5558
|
+
*/
|
5559
|
+
getAsDataURL: function(type, quality) {
|
5560
|
+
if (!this.size) {
|
5561
|
+
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
|
6543
5562
|
}
|
5563
|
+
return this.getRuntime().exec.call(this, 'Image', 'getAsDataURL', type, quality);
|
6544
5564
|
},
|
6545
5565
|
|
6546
|
-
|
6547
|
-
|
6548
|
-
|
5566
|
+
/**
|
5567
|
+
Retrieves image in it's current state as binary string. Cannot be run on empty or image in progress (throws
|
5568
|
+
DOMException.INVALID_STATE_ERR).
|
6549
5569
|
|
6550
|
-
|
6551
|
-
|
6552
|
-
|
6553
|
-
|
5570
|
+
@method getAsBinaryString
|
5571
|
+
@param {String} [type="image/jpeg"] Mime type of resulting blob. Can either be image/jpeg or image/png
|
5572
|
+
@param {Number} [quality=90] Applicable only together with mime type image/jpeg
|
5573
|
+
@return {String} Image as binary string
|
5574
|
+
*/
|
5575
|
+
getAsBinaryString: function(type, quality) {
|
5576
|
+
var dataUrl = this.getAsDataURL(type, quality);
|
5577
|
+
return Encode.atob(dataUrl.substring(dataUrl.indexOf('base64,') + 7));
|
6554
5578
|
},
|
6555
5579
|
|
6556
|
-
|
6557
|
-
|
6558
|
-
|
6559
|
-
|
6560
|
-
|
6561
|
-
|
6562
|
-
|
6563
|
-
|
6564
|
-
|
5580
|
+
/**
|
5581
|
+
Embeds a visual representation of the image into the specified node. Depending on the runtime,
|
5582
|
+
it might be a canvas, an img node or a thrid party shim object (Flash or SilverLight - very rare,
|
5583
|
+
can be used in legacy browsers that do not have canvas or proper dataURI support).
|
5584
|
+
|
5585
|
+
@method embed
|
5586
|
+
@param {DOMElement} el DOM element to insert the image object into
|
5587
|
+
@param {Object} [options]
|
5588
|
+
@param {Number} [options.width] The width of an embed (defaults to the image width)
|
5589
|
+
@param {Number} [options.height] The height of an embed (defaults to the image height)
|
5590
|
+
@param {String} [type="image/jpeg"] Mime type
|
5591
|
+
@param {Number} [quality=90] Quality of an embed, if mime type is image/jpeg
|
5592
|
+
@param {Boolean} [crop=false] Whether to crop an embed to the specified dimensions
|
5593
|
+
*/
|
5594
|
+
embed: function(el) {
|
5595
|
+
var self = this
|
5596
|
+
, imgCopy
|
5597
|
+
, type, quality, crop
|
5598
|
+
, options = arguments[1] || {}
|
5599
|
+
, width = this.width
|
5600
|
+
, height = this.height
|
5601
|
+
, runtime // this has to be outside of all the closures to contain proper runtime
|
5602
|
+
;
|
6565
5603
|
|
6566
|
-
|
6567
|
-
|
5604
|
+
function onResize() {
|
5605
|
+
// if possible, embed a canvas element directly
|
5606
|
+
if (Env.can('create_canvas')) {
|
5607
|
+
var canvas = imgCopy.getAsCanvas();
|
5608
|
+
if (canvas) {
|
5609
|
+
el.appendChild(canvas);
|
5610
|
+
canvas = null;
|
5611
|
+
imgCopy.destroy();
|
5612
|
+
self.trigger('embedded');
|
5613
|
+
return;
|
5614
|
+
}
|
5615
|
+
}
|
6568
5616
|
|
6569
|
-
|
5617
|
+
var dataUrl = imgCopy.getAsDataURL(type, quality);
|
5618
|
+
if (!dataUrl) {
|
5619
|
+
throw new x.ImageError(x.ImageError.WRONG_FORMAT);
|
5620
|
+
}
|
6570
5621
|
|
6571
|
-
|
6572
|
-
|
6573
|
-
|
6574
|
-
|
6575
|
-
|
6576
|
-
|
6577
|
-
|
6578
|
-
|
6579
|
-
|
5622
|
+
if (Env.can('use_data_uri_of', dataUrl.length)) {
|
5623
|
+
el.innerHTML = '<img src="' + dataUrl + '" width="' + imgCopy.width + '" height="' + imgCopy.height + '" />';
|
5624
|
+
imgCopy.destroy();
|
5625
|
+
self.trigger('embedded');
|
5626
|
+
} else {
|
5627
|
+
var tr = new Transporter();
|
5628
|
+
|
5629
|
+
tr.bind("TransportingComplete", function() {
|
5630
|
+
runtime = self.connectRuntime(this.result.ruid);
|
5631
|
+
|
5632
|
+
self.bind("Embedded", function() {
|
5633
|
+
// position and size properly
|
5634
|
+
Basic.extend(runtime.getShimContainer().style, {
|
5635
|
+
//position: 'relative',
|
5636
|
+
top: '0px',
|
5637
|
+
left: '0px',
|
5638
|
+
width: imgCopy.width + 'px',
|
5639
|
+
height: imgCopy.height + 'px'
|
5640
|
+
});
|
6580
5641
|
|
6581
|
-
|
6582
|
-
|
6583
|
-
|
6584
|
-
|
6585
|
-
|
6586
|
-
|
6587
|
-
|
6588
|
-
|
6589
|
-
return (extensions.FileReader = FileReader);
|
6590
|
-
});
|
5642
|
+
// some shims (Flash/SilverLight) reinitialize, if parent element is hidden, reordered or it's
|
5643
|
+
// position type changes (in Gecko), but since we basically need this only in IEs 6/7 and
|
5644
|
+
// sometimes 8 and they do not have this problem, we can comment this for now
|
5645
|
+
/*tr.bind("RuntimeInit", function(e, runtime) {
|
5646
|
+
tr.destroy();
|
5647
|
+
runtime.destroy();
|
5648
|
+
onResize.call(self); // re-feed our image data
|
5649
|
+
});*/
|
6591
5650
|
|
6592
|
-
|
5651
|
+
runtime = null;
|
5652
|
+
}, 999);
|
6593
5653
|
|
6594
|
-
|
6595
|
-
|
6596
|
-
|
6597
|
-
* Copyright 2013, Moxiecode Systems AB
|
6598
|
-
* Released under GPL License.
|
6599
|
-
*
|
6600
|
-
* License: http://www.plupload.com/license
|
6601
|
-
* Contributing: http://www.plupload.com/contributing
|
6602
|
-
*/
|
5654
|
+
runtime.exec.call(self, "ImageView", "display", this.result.uid, width, height);
|
5655
|
+
imgCopy.destroy();
|
5656
|
+
});
|
6603
5657
|
|
6604
|
-
|
6605
|
-
|
6606
|
-
|
6607
|
-
|
6608
|
-
|
6609
|
-
|
6610
|
-
|
6611
|
-
|
6612
|
-
|
6613
|
-
"moxie/core/Exceptions",
|
6614
|
-
"moxie/core/utils/Events",
|
6615
|
-
"moxie/file/Blob",
|
6616
|
-
"moxie/xhr/FormData"
|
6617
|
-
], function(extensions, Basic, Dom, Url, x, Events, Blob, FormData) {
|
6618
|
-
|
6619
|
-
function XMLHttpRequest() {
|
6620
|
-
var _status, _response, _iframe;
|
5658
|
+
tr.transport(Encode.atob(dataUrl.substring(dataUrl.indexOf('base64,') + 7)), type, Basic.extend({}, options, {
|
5659
|
+
required_caps: {
|
5660
|
+
display_media: true
|
5661
|
+
},
|
5662
|
+
runtime_order: 'flash,silverlight',
|
5663
|
+
container: el
|
5664
|
+
}));
|
5665
|
+
}
|
5666
|
+
}
|
6621
5667
|
|
6622
|
-
|
6623
|
-
|
5668
|
+
try {
|
5669
|
+
if (!(el = Dom.get(el))) {
|
5670
|
+
throw new x.DOMException(x.DOMException.INVALID_NODE_TYPE_ERR);
|
5671
|
+
}
|
6624
5672
|
|
6625
|
-
|
6626
|
-
|
6627
|
-
|
5673
|
+
if (!this.size) { // only preloaded image objects can be used as source
|
5674
|
+
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
|
5675
|
+
}
|
6628
5676
|
|
6629
|
-
|
5677
|
+
if (this.width > Image.MAX_RESIZE_WIDTH || this.height > Image.MAX_RESIZE_HEIGHT) {
|
5678
|
+
throw new x.ImageError(x.ImageError.MAX_RESOLUTION_ERR);
|
5679
|
+
}
|
6630
5680
|
|
6631
|
-
|
6632
|
-
|
6633
|
-
|
6634
|
-
i = inputs.length;
|
5681
|
+
type = options.type || this.type || 'image/jpeg';
|
5682
|
+
quality = options.quality || 90;
|
5683
|
+
crop = Basic.typeOf(options.crop) !== 'undefined' ? options.crop : false;
|
6635
5684
|
|
6636
|
-
|
6637
|
-
|
6638
|
-
|
6639
|
-
|
6640
|
-
|
6641
|
-
|
6642
|
-
|
6643
|
-
|
5685
|
+
// figure out dimensions for the thumb
|
5686
|
+
if (options.width) {
|
5687
|
+
width = options.width;
|
5688
|
+
height = options.height || width;
|
5689
|
+
} else {
|
5690
|
+
// if container element has measurable dimensions, use them
|
5691
|
+
var dimensions = Dom.getSize(el);
|
5692
|
+
if (dimensions.w && dimensions.h) { // both should be > 0
|
5693
|
+
width = dimensions.w;
|
5694
|
+
height = dimensions.h;
|
5695
|
+
}
|
6644
5696
|
}
|
5697
|
+
|
5698
|
+
imgCopy = new Image();
|
5699
|
+
|
5700
|
+
imgCopy.bind("Resize", function() {
|
5701
|
+
onResize.call(self);
|
5702
|
+
});
|
5703
|
+
|
5704
|
+
imgCopy.bind("Load", function() {
|
5705
|
+
imgCopy.downsize(width, height, crop, false);
|
5706
|
+
});
|
5707
|
+
|
5708
|
+
imgCopy.clone(this, false);
|
5709
|
+
|
5710
|
+
return imgCopy;
|
5711
|
+
} catch(ex) {
|
5712
|
+
// for now simply trigger error event
|
5713
|
+
this.trigger('error', ex.code);
|
6645
5714
|
}
|
6646
|
-
|
5715
|
+
},
|
5716
|
+
|
5717
|
+
/**
|
5718
|
+
Properly destroys the image and frees resources in use. If any. Recommended way to dispose mOxie.Image object.
|
6647
5719
|
|
6648
|
-
|
6649
|
-
|
5720
|
+
@method destroy
|
5721
|
+
*/
|
5722
|
+
destroy: function() {
|
5723
|
+
if (this.ruid) {
|
5724
|
+
this.getRuntime().exec.call(this, 'Image', 'destroy');
|
5725
|
+
this.disconnectRuntime();
|
6650
5726
|
}
|
6651
|
-
|
5727
|
+
this.unbindAll();
|
6652
5728
|
}
|
5729
|
+
});
|
6653
5730
|
|
6654
|
-
// without timeout, request is marked as canceled (in console)
|
6655
|
-
setTimeout(function() {
|
6656
|
-
Events.removeEvent(_iframe, 'load', target.uid);
|
6657
|
-
if (_iframe.parentNode) { // #382
|
6658
|
-
_iframe.parentNode.removeChild(_iframe);
|
6659
|
-
}
|
6660
5731
|
|
6661
|
-
|
6662
|
-
|
6663
|
-
|
6664
|
-
|
6665
|
-
}
|
5732
|
+
function _updateInfo(info) {
|
5733
|
+
if (!info) {
|
5734
|
+
info = this.getRuntime().exec.call(this, 'Image', 'getInfo');
|
5735
|
+
}
|
6666
5736
|
|
6667
|
-
|
6668
|
-
|
6669
|
-
|
5737
|
+
this.size = info.size;
|
5738
|
+
this.width = info.width;
|
5739
|
+
this.height = info.height;
|
5740
|
+
this.type = info.type;
|
5741
|
+
this.meta = info.meta;
|
5742
|
+
|
5743
|
+
// update file name, only if empty
|
5744
|
+
if (this.name === '') {
|
5745
|
+
this.name = info.name;
|
5746
|
+
}
|
6670
5747
|
}
|
5748
|
+
|
6671
5749
|
|
6672
|
-
|
6673
|
-
|
6674
|
-
var target = this, I = target.getRuntime(), uid, form, input, blob;
|
6675
|
-
|
6676
|
-
_status = _response = null;
|
6677
|
-
|
6678
|
-
function createIframe() {
|
6679
|
-
var container = I.getShimContainer() || document.body
|
6680
|
-
, temp = document.createElement('div')
|
6681
|
-
;
|
6682
|
-
|
6683
|
-
// IE 6 won't be able to set the name using setAttribute or iframe.name
|
6684
|
-
temp.innerHTML = '<iframe id="' + uid + '_iframe" name="' + uid + '_iframe" src="javascript:""" style="display:none"></iframe>';
|
6685
|
-
_iframe = temp.firstChild;
|
6686
|
-
container.appendChild(_iframe);
|
6687
|
-
|
6688
|
-
/* _iframe.onreadystatechange = function() {
|
6689
|
-
console.info(_iframe.readyState);
|
6690
|
-
};*/
|
6691
|
-
|
6692
|
-
Events.addEvent(_iframe, 'load', function() { // _iframe.onload doesn't work in IE lte 8
|
6693
|
-
var el;
|
6694
|
-
|
6695
|
-
try {
|
6696
|
-
el = _iframe.contentWindow.document || _iframe.contentDocument || window.frames[_iframe.id].document;
|
6697
|
-
|
6698
|
-
// try to detect some standard error pages
|
6699
|
-
if (/^4(0[0-9]|1[0-7]|2[2346])\s/.test(el.title)) { // test if title starts with 4xx HTTP error
|
6700
|
-
_status = el.title.replace(/^(\d+).*$/, '$1');
|
6701
|
-
} else {
|
6702
|
-
_status = 200;
|
6703
|
-
// get result
|
6704
|
-
_response = Basic.trim(el.body.innerHTML);
|
6705
|
-
|
6706
|
-
// we need to fire these at least once
|
6707
|
-
target.trigger({
|
6708
|
-
type: 'progress',
|
6709
|
-
loaded: _response.length,
|
6710
|
-
total: _response.length
|
6711
|
-
});
|
5750
|
+
function _load(src) {
|
5751
|
+
var srcType = Basic.typeOf(src);
|
6712
5752
|
|
6713
|
-
|
6714
|
-
|
6715
|
-
|
6716
|
-
|
6717
|
-
|
6718
|
-
});
|
6719
|
-
}
|
6720
|
-
}
|
6721
|
-
} catch (ex) {
|
6722
|
-
if (Url.hasSameOrigin(meta.url)) {
|
6723
|
-
// if response is sent with error code, iframe in IE gets redirected to res://ieframe.dll/http_x.htm
|
6724
|
-
// which obviously results to cross domain error (wtf?)
|
6725
|
-
_status = 404;
|
6726
|
-
} else {
|
6727
|
-
cleanup.call(target, function() {
|
6728
|
-
target.trigger('error');
|
6729
|
-
});
|
6730
|
-
return;
|
6731
|
-
}
|
6732
|
-
}
|
6733
|
-
|
6734
|
-
cleanup.call(target, function() {
|
6735
|
-
target.trigger('load');
|
6736
|
-
});
|
6737
|
-
}, target.uid);
|
6738
|
-
} // end createIframe
|
6739
|
-
|
6740
|
-
// prepare data to be sent and convert if required
|
6741
|
-
if (data instanceof FormData && data.hasBlob()) {
|
6742
|
-
blob = data.getBlob();
|
6743
|
-
uid = blob.uid;
|
6744
|
-
input = Dom.get(uid);
|
6745
|
-
form = Dom.get(uid + '_form');
|
6746
|
-
if (!form) {
|
6747
|
-
throw new x.DOMException(x.DOMException.NOT_FOUND_ERR);
|
5753
|
+
try {
|
5754
|
+
// if source is Image
|
5755
|
+
if (src instanceof Image) {
|
5756
|
+
if (!src.size) { // only preloaded image objects can be used as source
|
5757
|
+
throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
|
6748
5758
|
}
|
6749
|
-
|
6750
|
-
|
5759
|
+
_loadFromImage.apply(this, arguments);
|
5760
|
+
}
|
5761
|
+
// if source is o.Blob/o.File
|
5762
|
+
else if (src instanceof Blob) {
|
5763
|
+
if (!~Basic.inArray(src.type, ['image/jpeg', 'image/png'])) {
|
5764
|
+
throw new x.ImageError(x.ImageError.WRONG_FORMAT);
|
5765
|
+
}
|
5766
|
+
_loadFromBlob.apply(this, arguments);
|
5767
|
+
}
|
5768
|
+
// if native blob/file
|
5769
|
+
else if (Basic.inArray(srcType, ['blob', 'file']) !== -1) {
|
5770
|
+
_load.call(this, new File(null, src), arguments[1]);
|
5771
|
+
}
|
5772
|
+
// if String
|
5773
|
+
else if (srcType === 'string') {
|
5774
|
+
// if dataUrl String
|
5775
|
+
if (/^data:[^;]*;base64,/.test(src)) {
|
5776
|
+
_load.call(this, new Blob(null, { data: src }), arguments[1]);
|
5777
|
+
}
|
5778
|
+
// else assume Url, either relative or absolute
|
5779
|
+
else {
|
5780
|
+
_loadFromUrl.apply(this, arguments);
|
5781
|
+
}
|
5782
|
+
}
|
5783
|
+
// if source seems to be an img node
|
5784
|
+
else if (srcType === 'node' && src.nodeName.toLowerCase() === 'img') {
|
5785
|
+
_load.call(this, src.src, arguments[1]);
|
5786
|
+
}
|
5787
|
+
else {
|
5788
|
+
throw new x.DOMException(x.DOMException.TYPE_MISMATCH_ERR);
|
5789
|
+
}
|
5790
|
+
} catch(ex) {
|
5791
|
+
// for now simply trigger error event
|
5792
|
+
this.trigger('error', ex.code);
|
5793
|
+
}
|
5794
|
+
}
|
6751
5795
|
|
6752
|
-
form = document.createElement('form');
|
6753
|
-
form.setAttribute('id', uid + '_form');
|
6754
|
-
form.setAttribute('method', meta.method);
|
6755
|
-
form.setAttribute('enctype', 'multipart/form-data');
|
6756
|
-
form.setAttribute('encoding', 'multipart/form-data');
|
6757
|
-
form.setAttribute('target', uid + '_iframe');
|
6758
5796
|
|
6759
|
-
|
6760
|
-
|
5797
|
+
function _loadFromImage(img, exact) {
|
5798
|
+
var runtime = this.connectRuntime(img.ruid);
|
5799
|
+
this.ruid = runtime.uid;
|
5800
|
+
runtime.exec.call(this, 'Image', 'loadFromImage', img, (Basic.typeOf(exact) === 'undefined' ? true : exact));
|
5801
|
+
}
|
6761
5802
|
|
6762
|
-
if (data instanceof FormData) {
|
6763
|
-
data.each(function(value, name) {
|
6764
|
-
if (value instanceof Blob) {
|
6765
|
-
if (input) {
|
6766
|
-
input.setAttribute('name', name);
|
6767
|
-
}
|
6768
|
-
} else {
|
6769
|
-
var hidden = document.createElement('input');
|
6770
5803
|
|
6771
|
-
|
6772
|
-
|
6773
|
-
name : name,
|
6774
|
-
value : value
|
6775
|
-
});
|
5804
|
+
function _loadFromBlob(blob, options) {
|
5805
|
+
var self = this;
|
6776
5806
|
|
6777
|
-
|
6778
|
-
|
6779
|
-
|
6780
|
-
|
6781
|
-
|
6782
|
-
|
6783
|
-
|
6784
|
-
|
5807
|
+
self.name = blob.name || '';
|
5808
|
+
|
5809
|
+
function exec(runtime) {
|
5810
|
+
self.ruid = runtime.uid;
|
5811
|
+
runtime.exec.call(self, 'Image', 'loadFromBlob', blob);
|
5812
|
+
}
|
5813
|
+
|
5814
|
+
if (blob.isDetached()) {
|
5815
|
+
this.bind('RuntimeInit', function(e, runtime) {
|
5816
|
+
exec(runtime);
|
5817
|
+
});
|
5818
|
+
|
5819
|
+
// convert to object representation
|
5820
|
+
if (options && typeof(options.required_caps) === 'string') {
|
5821
|
+
options.required_caps = Runtime.parseCaps(options.required_caps);
|
6785
5822
|
}
|
6786
5823
|
|
6787
|
-
|
6788
|
-
|
5824
|
+
this.connectRuntime(Basic.extend({
|
5825
|
+
required_caps: {
|
5826
|
+
access_image_binary: true,
|
5827
|
+
resize_image: true
|
5828
|
+
}
|
5829
|
+
}, options));
|
5830
|
+
} else {
|
5831
|
+
exec(this.connectRuntime(blob.ruid));
|
5832
|
+
}
|
5833
|
+
}
|
6789
5834
|
|
6790
|
-
createIframe();
|
6791
|
-
form.submit();
|
6792
|
-
target.trigger('loadstart');
|
6793
|
-
},
|
6794
5835
|
|
6795
|
-
|
6796
|
-
|
6797
|
-
},
|
5836
|
+
function _loadFromUrl(url, options) {
|
5837
|
+
var self = this, xhr;
|
6798
5838
|
|
6799
|
-
|
6800
|
-
if ('json' === responseType) {
|
6801
|
-
// strip off <pre>..</pre> tags that might be enclosing the response
|
6802
|
-
if (Basic.typeOf(_response) === 'string' && !!window.JSON) {
|
6803
|
-
try {
|
6804
|
-
return JSON.parse(_response.replace(/^\s*<pre[^>]*>/, '').replace(/<\/pre>\s*$/, ''));
|
6805
|
-
} catch (ex) {
|
6806
|
-
return null;
|
6807
|
-
}
|
6808
|
-
}
|
6809
|
-
} else if ('document' === responseType) {
|
5839
|
+
xhr = new XMLHttpRequest();
|
6810
5840
|
|
6811
|
-
|
6812
|
-
|
6813
|
-
},
|
5841
|
+
xhr.open('get', url);
|
5842
|
+
xhr.responseType = 'blob';
|
6814
5843
|
|
6815
|
-
|
6816
|
-
|
5844
|
+
xhr.onprogress = function(e) {
|
5845
|
+
self.trigger(e);
|
5846
|
+
};
|
6817
5847
|
|
6818
|
-
|
6819
|
-
|
6820
|
-
|
6821
|
-
} else if (_iframe.contentWindow.document.execCommand) { // IE
|
6822
|
-
_iframe.contentWindow.document.execCommand('Stop');
|
6823
|
-
} else {
|
6824
|
-
_iframe.src = "about:blank";
|
6825
|
-
}
|
6826
|
-
}
|
5848
|
+
xhr.onload = function() {
|
5849
|
+
_loadFromBlob.call(self, xhr.response, true);
|
5850
|
+
};
|
6827
5851
|
|
6828
|
-
|
6829
|
-
|
6830
|
-
|
6831
|
-
|
6832
|
-
|
6833
|
-
|
5852
|
+
xhr.onerror = function(e) {
|
5853
|
+
self.trigger(e);
|
5854
|
+
};
|
5855
|
+
|
5856
|
+
xhr.onloadend = function() {
|
5857
|
+
xhr.destroy();
|
5858
|
+
};
|
5859
|
+
|
5860
|
+
xhr.bind('RuntimeError', function(e, err) {
|
5861
|
+
self.trigger('RuntimeError', err);
|
5862
|
+
});
|
5863
|
+
|
5864
|
+
xhr.send(null, options);
|
5865
|
+
}
|
6834
5866
|
}
|
6835
5867
|
|
6836
|
-
|
5868
|
+
// virtual world will crash on you if image has a resolution higher than this:
|
5869
|
+
Image.MAX_RESIZE_WIDTH = 6500;
|
5870
|
+
Image.MAX_RESIZE_HEIGHT = 6500;
|
5871
|
+
|
5872
|
+
Image.prototype = EventTarget.instance;
|
5873
|
+
|
5874
|
+
return Image;
|
6837
5875
|
});
|
6838
5876
|
|
6839
|
-
// Included from: src/javascript/runtime/
|
5877
|
+
// Included from: src/javascript/runtime/flash/Runtime.js
|
6840
5878
|
|
6841
5879
|
/**
|
6842
|
-
*
|
5880
|
+
* Runtime.js
|
6843
5881
|
*
|
6844
5882
|
* Copyright 2013, Moxiecode Systems AB
|
6845
5883
|
* Released under GPL License.
|
@@ -6851,12 +5889,12 @@ define("moxie/runtime/html4/xhr/XMLHttpRequest", [
|
|
6851
5889
|
/*global ActiveXObject:true */
|
6852
5890
|
|
6853
5891
|
/**
|
6854
|
-
Defines constructor for
|
5892
|
+
Defines constructor for Flash runtime.
|
6855
5893
|
|
6856
|
-
@class moxie/runtime/
|
5894
|
+
@class moxie/runtime/flash/Runtime
|
6857
5895
|
@private
|
6858
5896
|
*/
|
6859
|
-
define("moxie/runtime/
|
5897
|
+
define("moxie/runtime/flash/Runtime", [
|
6860
5898
|
"moxie/core/utils/Basic",
|
6861
5899
|
"moxie/core/utils/Env",
|
6862
5900
|
"moxie/core/utils/Dom",
|
@@ -6864,143 +5902,137 @@ define("moxie/runtime/silverlight/Runtime", [
|
|
6864
5902
|
"moxie/runtime/Runtime"
|
6865
5903
|
], function(Basic, Env, Dom, x, Runtime) {
|
6866
5904
|
|
6867
|
-
var type =
|
6868
|
-
|
6869
|
-
function isInstalled(version) {
|
6870
|
-
var isVersionSupported = false, control = null, actualVer,
|
6871
|
-
actualVerArray, reqVerArray, requiredVersionPart, actualVersionPart, index = 0;
|
6872
|
-
|
6873
|
-
try {
|
6874
|
-
try {
|
6875
|
-
control = new ActiveXObject('AgControl.AgControl');
|
6876
|
-
|
6877
|
-
if (control.IsVersionSupported(version)) {
|
6878
|
-
isVersionSupported = true;
|
6879
|
-
}
|
6880
|
-
|
6881
|
-
control = null;
|
6882
|
-
} catch (e) {
|
6883
|
-
var plugin = navigator.plugins["Silverlight Plug-In"];
|
6884
|
-
|
6885
|
-
if (plugin) {
|
6886
|
-
actualVer = plugin.description;
|
6887
|
-
|
6888
|
-
if (actualVer === "1.0.30226.2") {
|
6889
|
-
actualVer = "2.0.30226.2";
|
6890
|
-
}
|
6891
|
-
|
6892
|
-
actualVerArray = actualVer.split(".");
|
6893
|
-
|
6894
|
-
while (actualVerArray.length > 3) {
|
6895
|
-
actualVerArray.pop();
|
6896
|
-
}
|
6897
|
-
|
6898
|
-
while ( actualVerArray.length < 4) {
|
6899
|
-
actualVerArray.push(0);
|
6900
|
-
}
|
6901
|
-
|
6902
|
-
reqVerArray = version.split(".");
|
5905
|
+
var type = 'flash', extensions = {};
|
6903
5906
|
|
6904
|
-
|
6905
|
-
|
6906
|
-
}
|
5907
|
+
/**
|
5908
|
+
Get the version of the Flash Player
|
6907
5909
|
|
6908
|
-
|
6909
|
-
|
6910
|
-
|
6911
|
-
|
6912
|
-
|
5910
|
+
@method getShimVersion
|
5911
|
+
@private
|
5912
|
+
@return {Number} Flash Player version
|
5913
|
+
*/
|
5914
|
+
function getShimVersion() {
|
5915
|
+
var version;
|
6913
5916
|
|
6914
|
-
|
6915
|
-
|
6916
|
-
|
6917
|
-
|
5917
|
+
try {
|
5918
|
+
version = navigator.plugins['Shockwave Flash'];
|
5919
|
+
version = version.description;
|
5920
|
+
} catch (e1) {
|
5921
|
+
try {
|
5922
|
+
version = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
|
5923
|
+
} catch (e2) {
|
5924
|
+
version = '0.0';
|
6918
5925
|
}
|
6919
|
-
} catch (e2) {
|
6920
|
-
isVersionSupported = false;
|
6921
5926
|
}
|
6922
|
-
|
6923
|
-
return
|
5927
|
+
version = version.match(/\d+/g);
|
5928
|
+
return parseFloat(version[0] + '.' + version[1]);
|
6924
5929
|
}
|
6925
5930
|
|
6926
5931
|
/**
|
6927
|
-
Constructor for the
|
5932
|
+
Constructor for the Flash Runtime
|
6928
5933
|
|
6929
|
-
@class
|
5934
|
+
@class FlashRuntime
|
6930
5935
|
@extends Runtime
|
6931
5936
|
*/
|
6932
|
-
function
|
5937
|
+
function FlashRuntime(options) {
|
6933
5938
|
var I = this, initTimer;
|
6934
5939
|
|
6935
|
-
options = Basic.extend({
|
5940
|
+
options = Basic.extend({ swf_url: Env.swf_url }, options);
|
6936
5941
|
|
6937
5942
|
Runtime.call(this, options, type, {
|
6938
|
-
access_binary:
|
6939
|
-
|
5943
|
+
access_binary: function(value) {
|
5944
|
+
return value && I.mode === 'browser';
|
5945
|
+
},
|
5946
|
+
access_image_binary: function(value) {
|
5947
|
+
return value && I.mode === 'browser';
|
5948
|
+
},
|
6940
5949
|
display_media: Runtime.capTrue,
|
6941
5950
|
do_cors: Runtime.capTrue,
|
6942
5951
|
drag_and_drop: false,
|
6943
|
-
report_upload_progress:
|
6944
|
-
|
6945
|
-
return_response_headers: function(value) {
|
6946
|
-
return value && I.mode === 'client';
|
5952
|
+
report_upload_progress: function() {
|
5953
|
+
return I.mode === 'client';
|
6947
5954
|
},
|
5955
|
+
resize_image: Runtime.capTrue,
|
5956
|
+
return_response_headers: false,
|
6948
5957
|
return_response_type: function(responseType) {
|
6949
|
-
if (responseType
|
5958
|
+
if (responseType === 'json' && !!window.JSON) {
|
6950
5959
|
return true;
|
6951
|
-
}
|
6952
|
-
|
6953
|
-
}
|
5960
|
+
}
|
5961
|
+
return !Basic.arrayDiff(responseType, ['', 'text', 'document']) || I.mode === 'browser';
|
6954
5962
|
},
|
6955
5963
|
return_status_code: function(code) {
|
6956
|
-
return I.mode === '
|
5964
|
+
return I.mode === 'browser' || !Basic.arrayDiff(code, [200, 404]);
|
6957
5965
|
},
|
6958
5966
|
select_file: Runtime.capTrue,
|
6959
5967
|
select_multiple: Runtime.capTrue,
|
6960
|
-
send_binary_string:
|
5968
|
+
send_binary_string: function(value) {
|
5969
|
+
return value && I.mode === 'browser';
|
5970
|
+
},
|
6961
5971
|
send_browser_cookies: function(value) {
|
6962
5972
|
return value && I.mode === 'browser';
|
6963
5973
|
},
|
6964
5974
|
send_custom_headers: function(value) {
|
6965
|
-
return value && I.mode === '
|
5975
|
+
return value && I.mode === 'browser';
|
6966
5976
|
},
|
6967
5977
|
send_multipart: Runtime.capTrue,
|
6968
|
-
slice_blob:
|
6969
|
-
|
5978
|
+
slice_blob: function(value) {
|
5979
|
+
return value && I.mode === 'browser';
|
5980
|
+
},
|
5981
|
+
stream_upload: function(value) {
|
5982
|
+
return value && I.mode === 'browser';
|
5983
|
+
},
|
6970
5984
|
summon_file_dialog: false,
|
6971
|
-
upload_filesize:
|
5985
|
+
upload_filesize: function(size) {
|
5986
|
+
return Basic.parseSizeStr(size) <= 2097152 || I.mode === 'client';
|
5987
|
+
},
|
6972
5988
|
use_http_method: function(methods) {
|
6973
|
-
return
|
5989
|
+
return !Basic.arrayDiff(methods, ['GET', 'POST']);
|
6974
5990
|
}
|
6975
5991
|
}, {
|
6976
5992
|
// capabilities that require specific mode
|
6977
|
-
|
6978
|
-
return value ? '
|
5993
|
+
access_binary: function(value) {
|
5994
|
+
return value ? 'browser' : 'client';
|
5995
|
+
},
|
5996
|
+
access_image_binary: function(value) {
|
5997
|
+
return value ? 'browser' : 'client';
|
5998
|
+
},
|
5999
|
+
report_upload_progress: function(value) {
|
6000
|
+
return value ? 'browser' : 'client';
|
6001
|
+
},
|
6002
|
+
return_response_type: function(responseType) {
|
6003
|
+
return Basic.arrayDiff(responseType, ['', 'text', 'json', 'document']) ? 'browser' : ['client', 'browser'];
|
6979
6004
|
},
|
6980
6005
|
return_status_code: function(code) {
|
6981
|
-
return Basic.arrayDiff(code, [200, 404]) ? '
|
6006
|
+
return Basic.arrayDiff(code, [200, 404]) ? 'browser' : ['client', 'browser'];
|
6007
|
+
},
|
6008
|
+
send_binary_string: function(value) {
|
6009
|
+
return value ? 'browser' : 'client';
|
6982
6010
|
},
|
6983
6011
|
send_browser_cookies: function(value) {
|
6984
6012
|
return value ? 'browser' : 'client';
|
6985
6013
|
},
|
6986
6014
|
send_custom_headers: function(value) {
|
6015
|
+
return value ? 'browser' : 'client';
|
6016
|
+
},
|
6017
|
+
stream_upload: function(value) {
|
6987
6018
|
return value ? 'client' : 'browser';
|
6988
6019
|
},
|
6989
|
-
|
6990
|
-
return Basic.
|
6020
|
+
upload_filesize: function(size) {
|
6021
|
+
return Basic.parseSizeStr(size) >= 2097152 ? 'client' : 'browser';
|
6991
6022
|
}
|
6992
|
-
});
|
6023
|
+
}, 'client');
|
6993
6024
|
|
6994
6025
|
|
6995
|
-
// minimal requirement
|
6996
|
-
if (
|
6997
|
-
this.mode = false;
|
6026
|
+
// minimal requirement for Flash Player version
|
6027
|
+
if (getShimVersion() < 10) {
|
6028
|
+
this.mode = false; // with falsy mode, runtime won't operable, no matter what the mode was before
|
6998
6029
|
}
|
6999
6030
|
|
7000
6031
|
|
7001
6032
|
Basic.extend(this, {
|
6033
|
+
|
7002
6034
|
getShim: function() {
|
7003
|
-
return Dom.get(this.uid)
|
6035
|
+
return Dom.get(this.uid);
|
7004
6036
|
},
|
7005
6037
|
|
7006
6038
|
shimExec: function(component, action) {
|
@@ -7008,47 +6040,220 @@ define("moxie/runtime/silverlight/Runtime", [
|
|
7008
6040
|
return I.getShim().exec(this.uid, component, action, args);
|
7009
6041
|
},
|
7010
6042
|
|
7011
|
-
init
|
7012
|
-
var container;
|
6043
|
+
init: function() {
|
6044
|
+
var html, el, container;
|
7013
6045
|
|
7014
6046
|
container = this.getShimContainer();
|
7015
6047
|
|
7016
|
-
|
7017
|
-
|
7018
|
-
|
7019
|
-
|
7020
|
-
|
7021
|
-
|
6048
|
+
// if not the minimal height, shims are not initialized in older browsers (e.g FF3.6, IE6,7,8, Safari 4.0,5.0, etc)
|
6049
|
+
Basic.extend(container.style, {
|
6050
|
+
position: 'absolute',
|
6051
|
+
top: '-8px',
|
6052
|
+
left: '-8px',
|
6053
|
+
width: '9px',
|
6054
|
+
height: '9px',
|
6055
|
+
overflow: 'hidden'
|
6056
|
+
});
|
6057
|
+
|
6058
|
+
// insert flash object
|
6059
|
+
html = '<object id="' + this.uid + '" type="application/x-shockwave-flash" data="' + options.swf_url + '" ';
|
6060
|
+
|
6061
|
+
if (Env.browser === 'IE') {
|
6062
|
+
html += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ';
|
6063
|
+
}
|
6064
|
+
|
6065
|
+
html += 'width="100%" height="100%" style="outline:0">' +
|
6066
|
+
'<param name="movie" value="' + options.swf_url + '" />' +
|
6067
|
+
'<param name="flashvars" value="uid=' + escape(this.uid) + '&target=' + Env.global_event_dispatcher + '" />' +
|
6068
|
+
'<param name="wmode" value="transparent" />' +
|
6069
|
+
'<param name="allowscriptaccess" value="always" />' +
|
7022
6070
|
'</object>';
|
7023
6071
|
|
6072
|
+
if (Env.browser === 'IE') {
|
6073
|
+
el = document.createElement('div');
|
6074
|
+
container.appendChild(el);
|
6075
|
+
el.outerHTML = html;
|
6076
|
+
el = container = null; // just in case
|
6077
|
+
} else {
|
6078
|
+
container.innerHTML = html;
|
6079
|
+
}
|
6080
|
+
|
7024
6081
|
// Init is dispatched by the shim
|
7025
6082
|
initTimer = setTimeout(function() {
|
7026
6083
|
if (I && !I.initialized) { // runtime might be already destroyed by this moment
|
7027
6084
|
I.trigger("Error", new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR));
|
7028
6085
|
}
|
7029
|
-
},
|
6086
|
+
}, 5000);
|
7030
6087
|
},
|
7031
6088
|
|
7032
|
-
destroy: (function(destroy) { // extend default destroy method
|
7033
|
-
return function() {
|
7034
|
-
destroy.call(I);
|
7035
|
-
clearTimeout(initTimer); // initialization check might be still onwait
|
7036
|
-
options = initTimer = destroy = I = null;
|
7037
|
-
};
|
7038
|
-
}(this.destroy))
|
6089
|
+
destroy: (function(destroy) { // extend default destroy method
|
6090
|
+
return function() {
|
6091
|
+
destroy.call(I);
|
6092
|
+
clearTimeout(initTimer); // initialization check might be still onwait
|
6093
|
+
options = initTimer = destroy = I = null;
|
6094
|
+
};
|
6095
|
+
}(this.destroy))
|
6096
|
+
|
6097
|
+
}, extensions);
|
6098
|
+
}
|
6099
|
+
|
6100
|
+
Runtime.addConstructor(type, FlashRuntime);
|
6101
|
+
|
6102
|
+
return extensions;
|
6103
|
+
});
|
6104
|
+
|
6105
|
+
// Included from: src/javascript/runtime/flash/file/Blob.js
|
6106
|
+
|
6107
|
+
/**
|
6108
|
+
* Blob.js
|
6109
|
+
*
|
6110
|
+
* Copyright 2013, Moxiecode Systems AB
|
6111
|
+
* Released under GPL License.
|
6112
|
+
*
|
6113
|
+
* License: http://www.plupload.com/license
|
6114
|
+
* Contributing: http://www.plupload.com/contributing
|
6115
|
+
*/
|
6116
|
+
|
6117
|
+
/**
|
6118
|
+
@class moxie/runtime/flash/file/Blob
|
6119
|
+
@private
|
6120
|
+
*/
|
6121
|
+
define("moxie/runtime/flash/file/Blob", [
|
6122
|
+
"moxie/runtime/flash/Runtime",
|
6123
|
+
"moxie/file/Blob"
|
6124
|
+
], function(extensions, Blob) {
|
6125
|
+
|
6126
|
+
var FlashBlob = {
|
6127
|
+
slice: function(blob, start, end, type) {
|
6128
|
+
var self = this.getRuntime();
|
6129
|
+
|
6130
|
+
if (start < 0) {
|
6131
|
+
start = Math.max(blob.size + start, 0);
|
6132
|
+
} else if (start > 0) {
|
6133
|
+
start = Math.min(start, blob.size);
|
6134
|
+
}
|
6135
|
+
|
6136
|
+
if (end < 0) {
|
6137
|
+
end = Math.max(blob.size + end, 0);
|
6138
|
+
} else if (end > 0) {
|
6139
|
+
end = Math.min(end, blob.size);
|
6140
|
+
}
|
6141
|
+
|
6142
|
+
blob = self.shimExec.call(this, 'Blob', 'slice', start, end, type || '');
|
6143
|
+
|
6144
|
+
if (blob) {
|
6145
|
+
blob = new Blob(self.uid, blob);
|
6146
|
+
}
|
6147
|
+
return blob;
|
6148
|
+
}
|
6149
|
+
};
|
6150
|
+
|
6151
|
+
return (extensions.Blob = FlashBlob);
|
6152
|
+
});
|
6153
|
+
|
6154
|
+
// Included from: src/javascript/runtime/flash/file/FileInput.js
|
6155
|
+
|
6156
|
+
/**
|
6157
|
+
* FileInput.js
|
6158
|
+
*
|
6159
|
+
* Copyright 2013, Moxiecode Systems AB
|
6160
|
+
* Released under GPL License.
|
6161
|
+
*
|
6162
|
+
* License: http://www.plupload.com/license
|
6163
|
+
* Contributing: http://www.plupload.com/contributing
|
6164
|
+
*/
|
6165
|
+
|
6166
|
+
/**
|
6167
|
+
@class moxie/runtime/flash/file/FileInput
|
6168
|
+
@private
|
6169
|
+
*/
|
6170
|
+
define("moxie/runtime/flash/file/FileInput", [
|
6171
|
+
"moxie/runtime/flash/Runtime"
|
6172
|
+
], function(extensions) {
|
6173
|
+
|
6174
|
+
var FileInput = {
|
6175
|
+
init: function(options) {
|
6176
|
+
this.getRuntime().shimExec.call(this, 'FileInput', 'init', {
|
6177
|
+
name: options.name,
|
6178
|
+
accept: options.accept,
|
6179
|
+
multiple: options.multiple
|
6180
|
+
});
|
6181
|
+
this.trigger('ready');
|
6182
|
+
}
|
6183
|
+
};
|
6184
|
+
|
6185
|
+
return (extensions.FileInput = FileInput);
|
6186
|
+
});
|
6187
|
+
|
6188
|
+
// Included from: src/javascript/runtime/flash/file/FileReader.js
|
6189
|
+
|
6190
|
+
/**
|
6191
|
+
* FileReader.js
|
6192
|
+
*
|
6193
|
+
* Copyright 2013, Moxiecode Systems AB
|
6194
|
+
* Released under GPL License.
|
6195
|
+
*
|
6196
|
+
* License: http://www.plupload.com/license
|
6197
|
+
* Contributing: http://www.plupload.com/contributing
|
6198
|
+
*/
|
6199
|
+
|
6200
|
+
/**
|
6201
|
+
@class moxie/runtime/flash/file/FileReader
|
6202
|
+
@private
|
6203
|
+
*/
|
6204
|
+
define("moxie/runtime/flash/file/FileReader", [
|
6205
|
+
"moxie/runtime/flash/Runtime",
|
6206
|
+
"moxie/core/utils/Encode"
|
6207
|
+
], function(extensions, Encode) {
|
6208
|
+
|
6209
|
+
var _result = '';
|
6210
|
+
|
6211
|
+
function _formatData(data, op) {
|
6212
|
+
switch (op) {
|
6213
|
+
case 'readAsText':
|
6214
|
+
return Encode.atob(data, 'utf8');
|
6215
|
+
case 'readAsBinaryString':
|
6216
|
+
return Encode.atob(data);
|
6217
|
+
case 'readAsDataURL':
|
6218
|
+
return data;
|
6219
|
+
}
|
6220
|
+
return null;
|
6221
|
+
}
|
6222
|
+
|
6223
|
+
var FileReader = {
|
6224
|
+
read: function(op, blob) {
|
6225
|
+
var target = this, self = target.getRuntime();
|
6226
|
+
|
6227
|
+
// special prefix for DataURL read mode
|
6228
|
+
if (op === 'readAsDataURL') {
|
6229
|
+
_result = 'data:' + (blob.type || '') + ';base64,';
|
6230
|
+
}
|
6231
|
+
|
6232
|
+
target.bind('Progress', function(e, data) {
|
6233
|
+
if (data) {
|
6234
|
+
_result += _formatData(data, op);
|
6235
|
+
}
|
6236
|
+
});
|
7039
6237
|
|
7040
|
-
|
7041
|
-
|
6238
|
+
return self.shimExec.call(this, 'FileReader', 'readAsBase64', blob.uid);
|
6239
|
+
},
|
7042
6240
|
|
7043
|
-
|
6241
|
+
getResult: function() {
|
6242
|
+
return _result;
|
6243
|
+
},
|
7044
6244
|
|
7045
|
-
|
6245
|
+
destroy: function() {
|
6246
|
+
_result = null;
|
6247
|
+
}
|
6248
|
+
};
|
6249
|
+
|
6250
|
+
return (extensions.FileReader = FileReader);
|
7046
6251
|
});
|
7047
6252
|
|
7048
|
-
// Included from: src/javascript/runtime/
|
6253
|
+
// Included from: src/javascript/runtime/flash/file/FileReaderSync.js
|
7049
6254
|
|
7050
6255
|
/**
|
7051
|
-
*
|
6256
|
+
* FileReaderSync.js
|
7052
6257
|
*
|
7053
6258
|
* Copyright 2013, Moxiecode Systems AB
|
7054
6259
|
* Released under GPL License.
|
@@ -7058,21 +6263,51 @@ define("moxie/runtime/silverlight/Runtime", [
|
|
7058
6263
|
*/
|
7059
6264
|
|
7060
6265
|
/**
|
7061
|
-
@class moxie/runtime/
|
6266
|
+
@class moxie/runtime/flash/file/FileReaderSync
|
7062
6267
|
@private
|
7063
6268
|
*/
|
7064
|
-
define("moxie/runtime/
|
7065
|
-
"moxie/runtime/
|
7066
|
-
"moxie/core/utils/
|
7067
|
-
|
7068
|
-
|
7069
|
-
|
6269
|
+
define("moxie/runtime/flash/file/FileReaderSync", [
|
6270
|
+
"moxie/runtime/flash/Runtime",
|
6271
|
+
"moxie/core/utils/Encode"
|
6272
|
+
], function(extensions, Encode) {
|
6273
|
+
|
6274
|
+
function _formatData(data, op) {
|
6275
|
+
switch (op) {
|
6276
|
+
case 'readAsText':
|
6277
|
+
return Encode.atob(data, 'utf8');
|
6278
|
+
case 'readAsBinaryString':
|
6279
|
+
return Encode.atob(data);
|
6280
|
+
case 'readAsDataURL':
|
6281
|
+
return data;
|
6282
|
+
}
|
6283
|
+
return null;
|
6284
|
+
}
|
6285
|
+
|
6286
|
+
var FileReaderSync = {
|
6287
|
+
read: function(op, blob) {
|
6288
|
+
var result, self = this.getRuntime();
|
6289
|
+
|
6290
|
+
result = self.shimExec.call(this, 'FileReaderSync', 'readAsBase64', blob.uid);
|
6291
|
+
if (!result) {
|
6292
|
+
return null; // or throw ex
|
6293
|
+
}
|
6294
|
+
|
6295
|
+
// special prefix for DataURL read mode
|
6296
|
+
if (op === 'readAsDataURL') {
|
6297
|
+
result = 'data:' + (blob.type || '') + ';base64,' + result;
|
6298
|
+
}
|
6299
|
+
|
6300
|
+
return _formatData(result, op, blob.type);
|
6301
|
+
}
|
6302
|
+
};
|
6303
|
+
|
6304
|
+
return (extensions.FileReaderSync = FileReaderSync);
|
7070
6305
|
});
|
7071
6306
|
|
7072
|
-
// Included from: src/javascript/runtime/
|
6307
|
+
// Included from: src/javascript/runtime/flash/xhr/XMLHttpRequest.js
|
7073
6308
|
|
7074
6309
|
/**
|
7075
|
-
*
|
6310
|
+
* XMLHttpRequest.js
|
7076
6311
|
*
|
7077
6312
|
* Copyright 2013, Moxiecode Systems AB
|
7078
6313
|
* Released under GPL License.
|
@@ -7082,36 +6317,146 @@ define("moxie/runtime/silverlight/file/Blob", [
|
|
7082
6317
|
*/
|
7083
6318
|
|
7084
6319
|
/**
|
7085
|
-
@class moxie/runtime/
|
6320
|
+
@class moxie/runtime/flash/xhr/XMLHttpRequest
|
7086
6321
|
@private
|
7087
6322
|
*/
|
7088
|
-
define("moxie/runtime/
|
7089
|
-
"moxie/runtime/
|
7090
|
-
|
6323
|
+
define("moxie/runtime/flash/xhr/XMLHttpRequest", [
|
6324
|
+
"moxie/runtime/flash/Runtime",
|
6325
|
+
"moxie/core/utils/Basic",
|
6326
|
+
"moxie/file/Blob",
|
6327
|
+
"moxie/file/File",
|
6328
|
+
"moxie/file/FileReaderSync",
|
6329
|
+
"moxie/xhr/FormData",
|
6330
|
+
"moxie/runtime/Transporter"
|
6331
|
+
], function(extensions, Basic, Blob, File, FileReaderSync, FormData, Transporter) {
|
7091
6332
|
|
7092
|
-
var
|
7093
|
-
|
6333
|
+
var XMLHttpRequest = {
|
6334
|
+
|
6335
|
+
send: function(meta, data) {
|
6336
|
+
var target = this, self = target.getRuntime();
|
6337
|
+
|
6338
|
+
function send() {
|
6339
|
+
meta.transport = self.mode;
|
6340
|
+
self.shimExec.call(target, 'XMLHttpRequest', 'send', meta, data);
|
6341
|
+
}
|
6342
|
+
|
6343
|
+
|
6344
|
+
function appendBlob(name, blob) {
|
6345
|
+
self.shimExec.call(target, 'XMLHttpRequest', 'appendBlob', name, blob.uid);
|
6346
|
+
data = null;
|
6347
|
+
send();
|
6348
|
+
}
|
6349
|
+
|
6350
|
+
|
6351
|
+
function attachBlob(blob, cb) {
|
6352
|
+
var tr = new Transporter();
|
6353
|
+
|
6354
|
+
tr.bind("TransportingComplete", function() {
|
6355
|
+
cb(this.result);
|
6356
|
+
});
|
6357
|
+
|
6358
|
+
tr.transport(blob.getSource(), blob.type, {
|
6359
|
+
ruid: self.uid
|
6360
|
+
});
|
6361
|
+
}
|
6362
|
+
|
6363
|
+
// copy over the headers if any
|
6364
|
+
if (!Basic.isEmptyObj(meta.headers)) {
|
6365
|
+
Basic.each(meta.headers, function(value, header) {
|
6366
|
+
self.shimExec.call(target, 'XMLHttpRequest', 'setRequestHeader', header, value.toString()); // Silverlight doesn't accept integers into the arguments of type object
|
6367
|
+
});
|
6368
|
+
}
|
6369
|
+
|
6370
|
+
// transfer over multipart params and blob itself
|
6371
|
+
if (data instanceof FormData) {
|
6372
|
+
var blobField;
|
6373
|
+
data.each(function(value, name) {
|
6374
|
+
if (value instanceof Blob) {
|
6375
|
+
blobField = name;
|
6376
|
+
} else {
|
6377
|
+
self.shimExec.call(target, 'XMLHttpRequest', 'append', name, value);
|
6378
|
+
}
|
6379
|
+
});
|
7094
6380
|
|
7095
|
-
|
7096
|
-
|
7097
|
-
|
7098
|
-
|
6381
|
+
if (!data.hasBlob()) {
|
6382
|
+
data = null;
|
6383
|
+
send();
|
6384
|
+
} else {
|
6385
|
+
var blob = data.getBlob();
|
6386
|
+
if (blob.isDetached()) {
|
6387
|
+
attachBlob(blob, function(attachedBlob) {
|
6388
|
+
blob.destroy();
|
6389
|
+
appendBlob(blobField, attachedBlob);
|
6390
|
+
});
|
6391
|
+
} else {
|
6392
|
+
appendBlob(blobField, blob);
|
6393
|
+
}
|
7099
6394
|
}
|
7100
|
-
|
6395
|
+
} else if (data instanceof Blob) {
|
6396
|
+
if (data.isDetached()) {
|
6397
|
+
attachBlob(data, function(attachedBlob) {
|
6398
|
+
data.destroy();
|
6399
|
+
data = attachedBlob.uid;
|
6400
|
+
send();
|
6401
|
+
});
|
6402
|
+
} else {
|
6403
|
+
data = data.uid;
|
6404
|
+
send();
|
6405
|
+
}
|
6406
|
+
} else {
|
6407
|
+
send();
|
7101
6408
|
}
|
7102
|
-
|
7103
|
-
|
7104
|
-
|
6409
|
+
},
|
6410
|
+
|
6411
|
+
getResponse: function(responseType) {
|
6412
|
+
var frs, blob, self = this.getRuntime();
|
6413
|
+
|
6414
|
+
blob = self.shimExec.call(this, 'XMLHttpRequest', 'getResponseAsBlob');
|
6415
|
+
|
6416
|
+
if (blob) {
|
6417
|
+
blob = new File(self.uid, blob);
|
6418
|
+
|
6419
|
+
if ('blob' === responseType) {
|
6420
|
+
return blob;
|
6421
|
+
}
|
6422
|
+
|
6423
|
+
try {
|
6424
|
+
frs = new FileReaderSync();
|
6425
|
+
|
6426
|
+
if (!!~Basic.inArray(responseType, ["", "text"])) {
|
6427
|
+
return frs.readAsText(blob);
|
6428
|
+
} else if ('json' === responseType && !!window.JSON) {
|
6429
|
+
return JSON.parse(frs.readAsText(blob));
|
6430
|
+
}
|
6431
|
+
} finally {
|
6432
|
+
blob.destroy();
|
6433
|
+
}
|
6434
|
+
}
|
6435
|
+
return null;
|
6436
|
+
},
|
6437
|
+
|
6438
|
+
abort: function(upload_complete_flag) {
|
6439
|
+
var self = this.getRuntime();
|
6440
|
+
|
6441
|
+
self.shimExec.call(this, 'XMLHttpRequest', 'abort');
|
6442
|
+
|
6443
|
+
this.dispatchEvent('readystatechange');
|
6444
|
+
// this.dispatchEvent('progress');
|
6445
|
+
this.dispatchEvent('abort');
|
6446
|
+
|
6447
|
+
//if (!upload_complete_flag) {
|
6448
|
+
// this.dispatchEvent('uploadprogress');
|
6449
|
+
//}
|
7105
6450
|
}
|
7106
6451
|
};
|
7107
6452
|
|
7108
|
-
return (extensions.
|
6453
|
+
return (extensions.XMLHttpRequest = XMLHttpRequest);
|
7109
6454
|
});
|
7110
6455
|
|
7111
|
-
// Included from: src/javascript/runtime/
|
6456
|
+
// Included from: src/javascript/runtime/flash/runtime/Transporter.js
|
7112
6457
|
|
7113
6458
|
/**
|
7114
|
-
*
|
6459
|
+
* Transporter.js
|
7115
6460
|
*
|
7116
6461
|
* Copyright 2013, Moxiecode Systems AB
|
7117
6462
|
* Released under GPL License.
|
@@ -7121,21 +6466,33 @@ define("moxie/runtime/silverlight/file/FileInput", [
|
|
7121
6466
|
*/
|
7122
6467
|
|
7123
6468
|
/**
|
7124
|
-
@class moxie/runtime/
|
6469
|
+
@class moxie/runtime/flash/runtime/Transporter
|
7125
6470
|
@private
|
7126
6471
|
*/
|
7127
|
-
define("moxie/runtime/
|
7128
|
-
"moxie/runtime/
|
7129
|
-
"moxie/
|
7130
|
-
|
7131
|
-
|
7132
|
-
|
6472
|
+
define("moxie/runtime/flash/runtime/Transporter", [
|
6473
|
+
"moxie/runtime/flash/Runtime",
|
6474
|
+
"moxie/file/Blob"
|
6475
|
+
], function(extensions, Blob) {
|
6476
|
+
|
6477
|
+
var Transporter = {
|
6478
|
+
getAsBlob: function(type) {
|
6479
|
+
var self = this.getRuntime()
|
6480
|
+
, blob = self.shimExec.call(this, 'Transporter', 'getAsBlob', type)
|
6481
|
+
;
|
6482
|
+
if (blob) {
|
6483
|
+
return new Blob(self.uid, blob);
|
6484
|
+
}
|
6485
|
+
return null;
|
6486
|
+
}
|
6487
|
+
};
|
6488
|
+
|
6489
|
+
return (extensions.Transporter = Transporter);
|
7133
6490
|
});
|
7134
6491
|
|
7135
|
-
// Included from: src/javascript/runtime/
|
6492
|
+
// Included from: src/javascript/runtime/flash/image/Image.js
|
7136
6493
|
|
7137
6494
|
/**
|
7138
|
-
*
|
6495
|
+
* Image.js
|
7139
6496
|
*
|
7140
6497
|
* Copyright 2013, Moxiecode Systems AB
|
7141
6498
|
* Released under GPL License.
|
@@ -7145,42 +6502,69 @@ define("moxie/runtime/silverlight/file/FileReader", [
|
|
7145
6502
|
*/
|
7146
6503
|
|
7147
6504
|
/**
|
7148
|
-
@class moxie/runtime/
|
6505
|
+
@class moxie/runtime/flash/image/Image
|
7149
6506
|
@private
|
7150
6507
|
*/
|
7151
|
-
define("moxie/runtime/
|
7152
|
-
"moxie/runtime/
|
6508
|
+
define("moxie/runtime/flash/image/Image", [
|
6509
|
+
"moxie/runtime/flash/Runtime",
|
7153
6510
|
"moxie/core/utils/Basic",
|
7154
|
-
"moxie/runtime/
|
7155
|
-
|
7156
|
-
|
7157
|
-
|
6511
|
+
"moxie/runtime/Transporter",
|
6512
|
+
"moxie/file/Blob",
|
6513
|
+
"moxie/file/FileReaderSync"
|
6514
|
+
], function(extensions, Basic, Transporter, Blob, FileReaderSync) {
|
6515
|
+
|
6516
|
+
var Image = {
|
6517
|
+
loadFromBlob: function(blob) {
|
6518
|
+
var comp = this, self = comp.getRuntime();
|
7158
6519
|
|
7159
|
-
|
6520
|
+
function exec(srcBlob) {
|
6521
|
+
self.shimExec.call(comp, 'Image', 'loadFromBlob', srcBlob.uid);
|
6522
|
+
comp = self = null;
|
6523
|
+
}
|
7160
6524
|
|
7161
|
-
|
7162
|
-
|
7163
|
-
|
7164
|
-
|
7165
|
-
|
7166
|
-
|
7167
|
-
|
7168
|
-
|
7169
|
-
|
6525
|
+
if (blob.isDetached()) { // binary string
|
6526
|
+
var tr = new Transporter();
|
6527
|
+
tr.bind("TransportingComplete", function() {
|
6528
|
+
exec(tr.result.getSource());
|
6529
|
+
});
|
6530
|
+
tr.transport(blob.getSource(), blob.type, { ruid: self.uid });
|
6531
|
+
} else {
|
6532
|
+
exec(blob.getSource());
|
6533
|
+
}
|
6534
|
+
},
|
7170
6535
|
|
7171
|
-
|
7172
|
-
|
7173
|
-
|
7174
|
-
|
7175
|
-
|
7176
|
-
|
7177
|
-
|
7178
|
-
|
7179
|
-
|
7180
|
-
|
6536
|
+
loadFromImage: function(img) {
|
6537
|
+
var self = this.getRuntime();
|
6538
|
+
return self.shimExec.call(this, 'Image', 'loadFromImage', img.uid);
|
6539
|
+
},
|
6540
|
+
|
6541
|
+
getAsBlob: function(type, quality) {
|
6542
|
+
var self = this.getRuntime()
|
6543
|
+
, blob = self.shimExec.call(this, 'Image', 'getAsBlob', type, quality)
|
6544
|
+
;
|
6545
|
+
if (blob) {
|
6546
|
+
return new Blob(self.uid, blob);
|
6547
|
+
}
|
6548
|
+
return null;
|
6549
|
+
},
|
6550
|
+
|
6551
|
+
getAsDataURL: function() {
|
6552
|
+
var self = this.getRuntime()
|
6553
|
+
, blob = self.Image.getAsBlob.apply(this, arguments)
|
6554
|
+
, frs
|
6555
|
+
;
|
6556
|
+
if (!blob) {
|
6557
|
+
return null;
|
6558
|
+
}
|
6559
|
+
frs = new FileReaderSync();
|
6560
|
+
return frs.readAsDataURL(blob);
|
6561
|
+
}
|
6562
|
+
};
|
6563
|
+
|
6564
|
+
return (extensions.Image = Image);
|
7181
6565
|
});
|
7182
6566
|
|
7183
|
-
expose(["moxie/core/utils/Basic","moxie/core/I18n","moxie/core/utils/Mime","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/core/EventTarget","moxie/core/utils/Encode","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/Blob","moxie/file/File","moxie/file/FileInput","moxie/runtime/RuntimeTarget","moxie/file/FileReader","moxie/core/utils/Url","moxie/file/FileReaderSync","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/runtime/Transporter","moxie/
|
6567
|
+
expose(["moxie/core/utils/Basic","moxie/core/I18n","moxie/core/utils/Mime","moxie/core/utils/Env","moxie/core/utils/Dom","moxie/core/Exceptions","moxie/core/EventTarget","moxie/core/utils/Encode","moxie/runtime/Runtime","moxie/runtime/RuntimeClient","moxie/file/Blob","moxie/file/File","moxie/file/FileInput","moxie/runtime/RuntimeTarget","moxie/file/FileReader","moxie/core/utils/Url","moxie/file/FileReaderSync","moxie/xhr/FormData","moxie/xhr/XMLHttpRequest","moxie/runtime/Transporter","moxie/image/Image"]);
|
7184
6568
|
})(this);/**
|
7185
6569
|
* o.js
|
7186
6570
|
*
|