Skip to content
This repository
Browse code

Update JavaScript binaries.

  • Loading branch information...
commit f75dfbd9c152521ecaf376615ec26e7f7778d308 1 parent fff516f
Davit Barbakadze jayarjo authored

Showing 2 changed files with 57 additions and 32 deletions. Show diff stats Hide diff stats

  1. +54 29 bin/js/moxie.js
  2. +3 3 bin/js/moxie.min.js
83 bin/js/moxie.js
@@ -509,12 +509,12 @@ define("moxie/core/utils/Mime", [
509 509 "application/vnd.openxmlformats-officedocument.presentationml.slideshow,ppsx," +
510 510 "application/x-javascript,js," +
511 511 "application/json,json," +
512   - "audio/mpeg,mpga mpega mp2 mp3," +
  512 + "audio/mpeg,mp3 mpga mpega mp2," +
513 513 "audio/x-wav,wav," +
514 514 "audio/mp4,m4a," +
515 515 "image/bmp,bmp," +
516 516 "image/gif,gif," +
517   - "image/jpeg,jpeg jpg jpe," +
  517 + "image/jpeg,jpg jpeg jpe," +
518 518 "image/photoshop,psd," +
519 519 "image/png,png," +
520 520 "image/svg+xml,svg svgz," +
@@ -615,7 +615,11 @@ define("moxie/core/utils/Mime", [
615 615 },
616 616
617 617 getFileExtension: function(fileName) {
618   - return fileName.replace(/^.+\.([^\.]+)$/, "$1").toLowerCase();
  618 + var matches = fileName && fileName.match(/\.([^.]+)$/);
  619 + if (matches) {
  620 + return matches[1].toLowerCase();
  621 + }
  622 + return '';
619 623 },
620 624
621 625 getFileMime: function(fileName) {
@@ -2072,7 +2076,6 @@ define('moxie/file/Blob', [
2072 2076 if (!blobpool[this.uid]) {
2073 2077 return null;
2074 2078 }
2075   -
2076 2079 return blobpool[this.uid];
2077 2080 },
2078 2081
@@ -2086,6 +2089,7 @@ define('moxie/file/Blob', [
2086 2089 detach: function(data) {
2087 2090 if (this.ruid) {
2088 2091 _getRuntime.call(this).exec.call(this, 'Blob', 'destroy', blobpool[this.uid]);
  2092 + this.disconnectRuntime();
2089 2093 this.ruid = null;
2090 2094 }
2091 2095
@@ -2156,33 +2160,36 @@ define('moxie/file/File', [
2156 2160 @param {Object} file Object "Native" file object, as it is represented in the runtime
2157 2161 */
2158 2162 function File(ruid, file) {
2159   - var name, ext, type;
  2163 + var name, type;
2160 2164
2161 2165 if (!file) { // avoid extra errors in case we overlooked something
2162 2166 file = {};
2163 2167 }
2164 2168
2165   - // extract extension
2166   - ext = file.name && file.name.match(/[^\.]+$/);
2167   -
2168 2169 // figure out the type
2169   - if (!file.type) {
2170   - type = ext && Mime.mimes[ext[0].toLowerCase()] || 'application/octet-stream';
  2170 + if (file.type && file.type !== '') {
  2171 + type = file.type;
  2172 + } else {
  2173 + type = Mime.getFileMime(file.name);
2171 2174 }
2172 2175
2173 2176 // sanitize file name or generate new one
2174 2177 if (file.name) {
2175 2178 name = file.name.replace(/\\/g, '/');
2176 2179 name = name.substr(name.lastIndexOf('/') + 1);
2177   - } else if (file.type && Mime.extensions[file.type]) {
2178   - ext = Mime.extensions[file.type][0];
2179   - name = Basic.guid(file.type.split('/')[0] + '_' || 'file_') + '.' + ext;
  2180 + } else {
  2181 + var prefix = type.split('/')[0];
  2182 + name = Basic.guid((prefix !== '' ? prefix : 'file') + '_');
  2183 +
  2184 + if (Mime.extensions[type]) {
  2185 + name += '.' + Mime.extensions[type][0]; // append proper extension if possible
  2186 + }
2180 2187 }
2181 2188
2182 2189 Blob.apply(this, arguments);
2183 2190
2184 2191 Basic.extend(this, {
2185   - type: file.type || type,
  2192 + type: type || '',
2186 2193
2187 2194 /**
2188 2195 File name
@@ -2191,7 +2198,7 @@ define('moxie/file/File', [
2191 2198 @type {String}
2192 2199 @default ''
2193 2200 */
2194   - name: name || '',
  2201 + name: name || Basic.guid('file_'),
2195 2202
2196 2203 /**
2197 2204 Date of last modification
@@ -2426,6 +2433,7 @@ define('moxie/file/FileInput', [
2426 2433 self.files = [];
2427 2434
2428 2435 Basic.each(files, function(file) {
  2436 + runtime.clients++;
2429 2437 self.files.push(new File(self.ruid, file));
2430 2438 });
2431 2439 }, 999);
@@ -4204,8 +4212,9 @@ define("moxie/xhr/XMLHttpRequest", [
4204 4212
4205 4213 function loadEnd() {
4206 4214 _xhr.destroy();
  4215 + _xhr = null;
4207 4216 self.dispatchEvent('loadend');
4208   - _xhr = self = null;
  4217 + self = null;
4209 4218 }
4210 4219
4211 4220 function exec(runtime) {
@@ -4411,9 +4420,9 @@ define('moxie/file/FileReaderSync', [
4411 4420 return txt;
4412 4421 }
4413 4422 } else {
4414   - try { // runtime is not required to have this method
4415   - return this.connectRuntime(blob.ruid).exec.call(this, 'FileReaderSync', 'read', op, blob);
4416   - } catch(ex) {}
  4423 + var result = this.connectRuntime(blob.ruid).exec.call(this, 'FileReaderSync', 'read', op, blob);
  4424 + this.disconnectRuntime();
  4425 + return result;
4417 4426 }
4418 4427 }
4419 4428 };
@@ -5143,11 +5152,12 @@ define("moxie/image/Image", [
5143 5152 }
5144 5153
5145 5154 crop = (crop === undefined ? false : !!crop);
5146   - preserveHeaders = (preserveHeaders === undefined ? true : !!preserveHeaders);
  5155 + preserveHeaders = (Basic.typeOf(preserveHeaders) === 'undefined' ? true : !!preserveHeaders);
5147 5156
5148 5157 runtime = this.connectRuntime(this.ruid);
5149 5158 this.bind('Resize', function(e, info) {
5150 5159 _updateInfo.call(this, info);
  5160 + this.disconnectRuntime();
5151 5161 }, 999);
5152 5162 runtime.exec.call(this, 'Image', 'resize', width, height, crop, preserveHeaders);
5153 5163 },
@@ -5183,6 +5193,8 @@ define("moxie/image/Image", [
5183 5193 @return {Blob} Image as Blob
5184 5194 */
5185 5195 getAsBlob: function(type, quality) {
  5196 + var blob;
  5197 +
5186 5198 if (!this.size) {
5187 5199 throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
5188 5200 }
@@ -5195,7 +5207,9 @@ define("moxie/image/Image", [
5195 5207 quality = 90;
5196 5208 }
5197 5209
5198   - return this.connectRuntime(this.ruid).exec.call(self, 'Image', 'getAsBlob', type, quality);
  5210 + blob = this.connectRuntime(this.ruid).exec.call(self, 'Image', 'getAsBlob', type, quality);
  5211 + this.disconnectRuntime();
  5212 + return blob;
5199 5213 },
5200 5214
5201 5215 /**
@@ -5208,10 +5222,14 @@ define("moxie/image/Image", [
5208 5222 @return {String} Image as dataURL string
5209 5223 */
5210 5224 getAsDataURL: function(type, quality) {
  5225 + var dataUrl;
  5226 +
5211 5227 if (!this.size) {
5212 5228 throw new x.DOMException(x.DOMException.INVALID_STATE_ERR);
5213 5229 }
5214   - return this.connectRuntime(this.ruid).exec.call(self, 'Image', 'getAsDataURL', type, quality);
  5230 + dataUrl = this.connectRuntime(this.ruid).exec.call(self, 'Image', 'getAsDataURL', type, quality);
  5231 + this.disconnectRuntime();
  5232 + return dataUrl;
5215 5233 },
5216 5234
5217 5235 /**
@@ -5296,6 +5314,9 @@ define("moxie/image/Image", [
5296 5314 runtime.destroy();
5297 5315 onResize.call(self); // re-feed our image data
5298 5316 });*/
  5317 +
  5318 + self.disconnectRuntime();
  5319 + runtime = null;
5299 5320 }, 999);
5300 5321
5301 5322 runtime.exec.call(self, "ImageView", "display", this.result.getSource().id, width, height);
@@ -5359,8 +5380,8 @@ define("moxie/image/Image", [
5359 5380 */
5360 5381 destroy: function() {
5361 5382 if (this.ruid) {
5362   - var runtime = this.connectRuntime(this.ruid);
5363   - runtime.exec.call(self, 'Image', 'destroy');
  5383 + this.connectRuntime(this.ruid).exec.call(self, 'Image', 'destroy');
  5384 + this.disconnectRuntime();
5364 5385 }
5365 5386 this.unbindAll();
5366 5387 self = null;
@@ -5374,6 +5395,7 @@ define("moxie/image/Image", [
5374 5395 function _updateInfo(info) {
5375 5396 if (!info) {
5376 5397 info = this.connectRuntime(this.ruid).exec.call(this, 'Image', 'getInfo');
  5398 + this.disconnectRuntime();
5377 5399 }
5378 5400
5379 5401 if (info) {
@@ -5404,6 +5426,7 @@ define("moxie/image/Image", [
5404 5426 var runtime = this.connectRuntime(img.ruid);
5405 5427 this.ruid = runtime.uid;
5406 5428 runtime.exec.call(self, 'Image', 'loadFromImage', img, (exact === undefined ? true : exact));
  5429 + this.disconnectRuntime();
5407 5430 }
5408 5431
5409 5432
@@ -5414,6 +5437,7 @@ define("moxie/image/Image", [
5414 5437 function exec(runtime) {
5415 5438 self.ruid = runtime.uid;
5416 5439 runtime.exec.call(self, 'Image', 'loadFromBlob', blob, asBinary);
  5440 + self.disconnectRuntime();
5417 5441 }
5418 5442
5419 5443 if (blob.isDetached()) {
@@ -7811,7 +7835,7 @@ define("moxie/runtime/html5/image/Image", [
7811 7835 info = {
7812 7836 width: _img && _img.width || 0,
7813 7837 height: _img && _img.height || 0,
7814   - type: (_srcBlob.type || _srcBlob.name && Mime.mimes[_srcBlob.name.replace(/^.+\.([^\.]+)$/, "$1").toLowerCase()]) || '',
  7838 + type: _srcBlob.type || Mime.getFileMime(_srcBlob.name),
7815 7839 size: _binStr && _binStr.length || _srcBlob.size || 0,
7816 7840 name: _srcBlob.name || '',
7817 7841 meta: _imgInfo && _imgInfo.meta || this.meta || {}
@@ -8071,7 +8095,7 @@ define("moxie/runtime/html5/image/Image", [
8071 8095
8072 8096
8073 8097 function _drawToCanvas(img, canvas, x, y, w, h) {
8074   - if (Env.OS === 'iOS' || Env.OS === 'Android') {
  8098 + if (Env.OS === 'iOS') {
8075 8099 // avoid squish bug in iOS6
8076 8100 MegaPixel.renderTo(img, canvas, { width: w, height: h, x: x, y: y });
8077 8101 } else {
@@ -9951,7 +9975,7 @@ Globally exposed namespace with the most frequently used public classes and hand
9951 9975 (function() {
9952 9976 "use strict";
9953 9977
9954   - var o = {};
  9978 + var o = {}, inArray = moxie.core.utils.Basic.inArray;
9955 9979
9956 9980 // directly add some public classes
9957 9981 // (we do it dynamically here, since for custom builds we cannot know beforehand what modules were included)
@@ -9959,7 +9983,7 @@ Globally exposed namespace with the most frequently used public classes and hand
9959 9983 var name, itemType;
9960 9984 for (name in ns) {
9961 9985 itemType = typeof(ns[name]);
9962   - if (itemType === 'object' && name !== 'Exceptions') {
  9986 + if (itemType === 'object' && !~inArray(name, ['Exceptions', 'Env', 'Mime'])) {
9963 9987 addAlias(ns[name]);
9964 9988 } else if (itemType === 'function') {
9965 9989 o[name] = ns[name];
@@ -9967,8 +9991,9 @@ Globally exposed namespace with the most frequently used public classes and hand
9967 9991 }
9968 9992 })(window.moxie);
9969 9993
9970   - // add Env manually
  9994 + // add some manually
9971 9995 o.Env = window.moxie.core.utils.Env;
  9996 + o.Mime = window.moxie.core.utils.Mime;
9972 9997 o.Exceptions = window.moxie.core.Exceptions;
9973 9998
9974 9999 // expose globally
6 bin/js/moxie.min.js
3 additions, 3 deletions not shown

0 comments on commit f75dfbd

Please sign in to comment.
Something went wrong with that request. Please try again.