Permalink
Browse files

Events: Remove undefined from arguments list.

  • Loading branch information...
1 parent 38072d7 commit cb7566c34aa3e4513b052ea640d3183c09dbadc6 @jayarjo jayarjo committed Mar 24, 2013
Showing with 42 additions and 20 deletions.
  1. +38 −16 bin/js/moxie.js
  2. +3 −3 bin/js/moxie.min.js
  3. +1 −1 src/javascript/core/utils/Events.js
View
@@ -5690,7 +5690,7 @@ define("moxie/runtime/html5/file/Blob", [
define('moxie/core/utils/Events', [
'moxie/core/utils/Basic'
], function(o) {
- var eventhash = {}, uid;
+ var eventhash = {}, uid = 'moxie_' + o.guid();
// IE W3C like event funcs
function preventDefault() {
@@ -5719,11 +5719,6 @@ define('moxie/core/utils/Events', [
key = arguments[3];
name = name.toLowerCase();
-
- // Initialize unique identifier if needed
- if (uid === undefined) {
- uid = 'Moxie_' + o.guid();
- }
// Add event listener
if (obj.addEventListener) {
@@ -5748,7 +5743,7 @@ define('moxie/core/utils/Events', [
}
// Log event handler to objects internal mOxie registry
- if (obj[uid] === undefined) {
+ if (!obj[uid]) {
obj[uid] = o.guid();
}
@@ -5851,7 +5846,7 @@ define('moxie/core/utils/Events', [
var removeAllEvents = function(obj) {
var key = arguments[1];
- if (obj[uid] === undefined || !obj[uid]) {
+ if (!obj || !obj[uid]) {
return;
}
@@ -5895,21 +5890,23 @@ define("moxie/runtime/html5/file/FileInput", [
], function(extensions, Basic, Dom, Events, Mime) {
function FileInput() {
- var _files = [];
+ var _files = [], _options;
Basic.extend(this, {
init: function(options) {
var comp = this, I = comp.getRuntime(), input, shimContainer, mimes;
+ _options = options;
_files = [];
// figure out accept string
- mimes = options.accept.mimes || Mime.extList2mimes(options.accept);
+ mimes = _options.accept.mimes || Mime.extList2mimes(_options.accept);
shimContainer = I.getShimContainer();
shimContainer.innerHTML = '<input id="' + I.uid +'" type="file" style="font-size:999px;opacity:0;"' +
- (options.multiple && I.can('select_multiple') ? 'multiple="multiple"' : '') + ' accept="' + mimes.join(',') + '" />';
+ (_options.multiple && I.can('select_multiple') ? 'multiple webkitdirectory' : '') +
+ ' accept="' + mimes.join(',') + '" />';
input = Dom.get(I.uid);
@@ -5925,7 +5922,7 @@ define("moxie/runtime/html5/file/FileInput", [
(function() {
var browseButton, zIndex, top;
- browseButton = Dom.get(options.browse_button);
+ browseButton = Dom.get(_options.browse_button);
// Route click event to the input[type=file] element for browsers that support such behavior
if (I.can('summon_file_dialog')) {
@@ -5962,14 +5959,26 @@ define("moxie/runtime/html5/file/FileInput", [
comp.trigger('mousedown');
}, comp.uid);
- Events.addEvent(Dom.get(options.container), 'mouseup', function() {
+ Events.addEvent(Dom.get(_options.container), 'mouseup', function() {
comp.trigger('mouseup');
}, comp.uid);
}());
input.onchange = function() { // there should be only one handler for this
- _files = [].slice.call(this.files);
+ _files = [];
+
+ if (_options.multiple) {
+ // folders are represented by dots, filter them out (Chrome 21+)
+ Basic.each(this.files, function(file) {
+ if (file.name !== ".") { // if it doesn't looks like a folder
+ _files.push(file);
+ }
+ });
+ } else {
+ _files = [].slice.call(this.files);
+ }
+
// Clearing the value enables the user to select the same file again if they want to
this.value = '';
comp.trigger('change');
@@ -5986,6 +5995,18 @@ define("moxie/runtime/html5/file/FileInput", [
if ((input = Dom.get(I.uid))) {
input.disabled = !!state;
}
+ },
+
+ destroy: function() {
+ var I = this.getRuntime(), shimContainer = I.getShimContainer();
+
+ Events.removeAllEvents(shimContainer, this.uid);
+ Events.removeAllEvents(Dom.get(_options.container), this.uid);
+ Events.removeAllEvents(Dom.get(_options.browse_button), this.uid);
+
+ shimContainer.innerHTML = '';
+
+ _files = _options = null;
}
});
}
@@ -8472,7 +8493,8 @@ define("moxie/runtime/flash/xhr/XMLHttpRequest", [
}
}
} else if (data instanceof Blob) {
- data = data.uid; // something wrong here
+ data = data.uid;
+ send();
} else {
send();
}
@@ -8801,7 +8823,7 @@ define("moxie/runtime/silverlight/Runtime", [
return isVersionSupported;
}
- Runtime.call(this, type, Basic.extend({}, { xap_url: Env.xap_url }));
+ Runtime.call(this, type, Basic.extend({}, { xap_url: Env.xap_url }, options));
Basic.extend(this, {
Oops, something went wrong.

0 comments on commit cb7566c

Please sign in to comment.