Skip to content

Commit

Permalink
Fixed some jslint issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
spocke committed Jan 28, 2011
1 parent 2c45190 commit 3866e91
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 35 deletions.
12 changes: 6 additions & 6 deletions src/javascript/plupload.flash.js
Expand Up @@ -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) {
Expand Down
20 changes: 11 additions & 9 deletions src/javascript/plupload.html4.js
Expand Up @@ -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
Expand Down Expand Up @@ -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]);
Expand Down
24 changes: 13 additions & 11 deletions src/javascript/plupload.html5.js
Expand Up @@ -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;
Expand Down Expand Up @@ -122,7 +122,7 @@
bb.append(data);
blob = bb.getBlob();
this.send(blob);
}
};
}

if (win.XMLHttpRequest) {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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]);
Expand All @@ -635,7 +637,7 @@
}

// Remove mark-up
container.removeChild(document.getElementById(elements['inputContainer']));
container.removeChild(document.getElementById(elements.inputContainer));
});

callback({success : true});
Expand Down
23 changes: 15 additions & 8 deletions src/javascript/plupload.js
Expand Up @@ -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);
},

Expand All @@ -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 === ' ' ? ' ' : '';
});
},

Expand All @@ -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) {

Expand Down
3 changes: 2 additions & 1 deletion src/javascript/plupload.silverlight.js
Expand Up @@ -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;

Expand Down

0 comments on commit 3866e91

Please sign in to comment.