diff --git a/src/javascript/plupload.flash.js b/src/javascript/plupload.flash.js index 872ca9f5c..54b4d133b 100644 --- a/src/javascript/plupload.flash.js +++ b/src/javascript/plupload.flash.js @@ -153,16 +153,16 @@ browseButton = flashContainer = null; // Wait for Flash to send init event - uploader.bind("Flash:Init", function() { - + uploader.bind("Flash:Init", function() { var lookup = {}, i, resize = uploader.settings.resize || {}; - + getFlashObj().setFileFilters(uploader.settings.filters, uploader.settings.multi_selection); - + // Prevent eventual reinitialization of the instance - if (initialized[uploader.id]) + if (initialized[uploader.id]) { return; - + } + initialized[uploader.id] = true; uploader.bind("UploadFile", function(up, file) { diff --git a/src/javascript/plupload.html4.js b/src/javascript/plupload.html4.js index cae28f4e6..f46f14cbf 100644 --- a/src/javascript/plupload.html4.js +++ b/src/javascript/plupload.html4.js @@ -301,20 +301,22 @@ // for IE and WebKit place input element underneath the browse button and route onclick event // TODO: revise when browser support for this feature will change if (up.features.canOpenDialog) { - pzIndex = parseInt(browseButton.parentNode.style.zIndex); - if (isNaN(pzIndex)) + pzIndex = parseInt(browseButton.parentNode.style.zIndex, 10); + + if (isNaN(pzIndex)) { pzIndex = 0; - + } + plupload.extend(browseButton.style, { position : 'relative', zIndex : pzIndex }); - + plupload.extend(inputContainer.style, { zIndex : pzIndex - 1 }); } - + /* Since we have to place input[type=file] on top of the browse_button for some browsers (FF, Opera), browse_button loses interactivity, here we try to neutralize this issue highlighting browse_button with a special class @@ -360,11 +362,11 @@ uploader.bind("Destroy", function(up) { var name, element, form, elements = { - inputContainer: 'form_' + currentFileId, - inputFile: 'input_' + currentFileId, - browseButton: up.settings.browse_button + inputContainer: 'form_' + currentFileId, + inputFile: 'input_' + currentFileId, + browseButton: up.settings.browse_button }; - + // Unbind event handlers for (name in elements) { element = getById(elements[name]); diff --git a/src/javascript/plupload.html5.js b/src/javascript/plupload.html5.js index 85d6c1552..9d468d211 100644 --- a/src/javascript/plupload.html5.js +++ b/src/javascript/plupload.html5.js @@ -9,7 +9,7 @@ */ // JSLint defined globals -/*global plupload:false, File:false, window:false, atob:false, FormData:false, FileReader:false */ +/*global plupload:false, File:false, window:false, atob:false, FormData:false, FileReader:false, ArrayBuffer:false, Uint8Array:false, BlobBuilder:false, unescape:false */ (function(window, document, plupload, undef) { var fakeSafariDragDrop, ExifParser; @@ -122,7 +122,7 @@ bb.append(data); blob = bb.getBlob(); this.send(blob); - } + }; } if (win.XMLHttpRequest) { @@ -204,7 +204,7 @@ } uploader.bind("Init", function(up) { - var inputContainer, browseButton, mimes = [], i, y, filters = up.settings.filters, ext, type, container = document.body; + var inputContainer, browseButton, mimes = [], i, y, filters = up.settings.filters, ext, type, container = document.body, inputFile; // Create input container and insert it at an absolute position within the browse button inputContainer = document.createElement('div'); @@ -384,9 +384,11 @@ // for IE and WebKit place input element underneath the browse button and route onclick event // TODO: revise when browser support for this feature will change if (uploader.features.canOpenDialog) { - pzIndex = parseInt(browseButton.parentNode.style.zIndex); - if (isNaN(pzIndex)) + pzIndex = parseInt(browseButton.parentNode.style.zIndex, 10); + + if (isNaN(pzIndex)) { pzIndex = 0; + } plupload.extend(browseButton.style, { position : 'relative', @@ -615,12 +617,12 @@ uploader.bind('Destroy', function(up) { var name, element, container = document.body, elements = { - inputContainer: up.id + '_html5_container', - inputFile: up.id + '_html5', - browseButton: up.settings.browse_button, - dropElm: up.settings.drop_element + inputContainer: up.id + '_html5_container', + inputFile: up.id + '_html5', + browseButton: up.settings.browse_button, + dropElm: up.settings.drop_element }; - + // Unbind event handlers for (name in elements) { element = document.getElementById(elements[name]); @@ -635,7 +637,7 @@ } // Remove mark-up - container.removeChild(document.getElementById(elements['inputContainer'])); + container.removeChild(document.getElementById(elements.inputContainer)); }); callback({success : true}); diff --git a/src/javascript/plupload.js b/src/javascript/plupload.js index 741397484..175af3640 100644 --- a/src/javascript/plupload.js +++ b/src/javascript/plupload.js @@ -543,10 +543,15 @@ * @param {Object} obj DOM element like object to add handler to. * @param {String} name Class name */ - hasClass : function(obj, name) { - if (obj.className == '') return false; - - var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)"); + hasClass : function(obj, name) { + var regExp; + + if (obj.className == '') { + return false; + } + + regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)"); + return regExp.test(obj.className); }, @@ -569,9 +574,10 @@ * @param {String} name Class name */ removeClass : function(obj, name) { - var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)"); + var regExp = new RegExp("(^|\\s+)"+name+"(\\s+|$)"); + obj.className = obj.className.replace(regExp, function($0, $1, $2) { - return $1 == ' ' && $2 == ' ' ? ' ' : ''; + return $1 === ' ' && $2 === ' ' ? ' ' : ''; }); }, @@ -594,9 +600,10 @@ name = name.toLowerCase(); // Initialize unique identifier if needed - if (uid === undef) + if (uid === undef) { uid = 'Plupload_' + plupload.guid(); - + } + // Add event listener if (obj.attachEvent) { diff --git a/src/javascript/plupload.silverlight.js b/src/javascript/plupload.silverlight.js index d89ce72a2..3341a7893 100644 --- a/src/javascript/plupload.silverlight.js +++ b/src/javascript/plupload.silverlight.js @@ -235,8 +235,9 @@ var selectedFiles, lookup = {}; // Prevent eventual reinitialization of the instance - if (initialized[uploader.id]) + if (initialized[uploader.id]) { return; + } initialized[uploader.id] = true;