Skip to content

Commit

Permalink
More jshinting and whitespace fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Dec 9, 2011
1 parent cf5cc5b commit dc79b10
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 79 deletions.
6 changes: 3 additions & 3 deletions build/jshintrc.json
Expand Up @@ -14,7 +14,7 @@
"bitwise": true,
"boss": false,
"curly": true,
"eqeqeq": true,
"eqeqeq": false, // todo
"eqnull": false,
"evil": false,
"expr": false,
Expand All @@ -37,7 +37,7 @@
"onevar": false,
"plusplus": false,
"sub": false,
"trailing": false,
"white": false,
"trailing": false, // todo
"white": false, // todo
"indent": 4
}
25 changes: 13 additions & 12 deletions src/core/Browser.js
Expand Up @@ -5,28 +5,29 @@
mobile = typeof orientation != 'undefined' ? true : false,
android = ua.indexOf("android") != -1,
opera = window.opera;

L.Browser = {
ie: ie,
ie6: ie && !window.XMLHttpRequest,

webkit: webkit,
webkit3d: webkit && ('WebKitCSSMatrix' in window) && ('m11' in new WebKitCSSMatrix()),
webkit3d: webkit && ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()),

gecko: ua.indexOf("gecko") != -1,

opera: opera,

android: android,
mobileWebkit: mobile && webkit,
mobileOpera: mobile && opera,

mobile: mobile,
touch: (function() {
var touchSupported = false;
var touchSupported = false,
startName = 'ontouchstart';

// WebKit, etc
if ('ontouchstart' in document.documentElement) {
if (startName in document.documentElement) {
return true;
}

Expand All @@ -38,12 +39,12 @@
return false;
}

e.setAttribute('ontouchstart', 'return;');
if (typeof e['ontouchstart'] == 'function') {
e.setAttribute(startName, 'return;');
if (typeof e[startName] === 'function') {
touchSupported = true;
}

e.removeAttribute('ontouchstart');
e.removeAttribute(startName);
e = null;

return touchSupported;
Expand Down
26 changes: 13 additions & 13 deletions src/core/Class.js
Expand Up @@ -2,10 +2,10 @@
* Class powers the OOP facilities of the library. Thanks to John Resig and Dean Edwards for inspiration!
*/

L.Class = function() {};
L.Class = function() {};

L.Class.extend = function(/*Object*/ props) /*-> Class*/ {

// extended class with the new prototype
var NewClass = function() {
if (this.initialize) {
Expand All @@ -17,16 +17,16 @@ L.Class.extend = function(/*Object*/ props) /*-> Class*/ {
var F = function() {};
F.prototype = this.prototype;
var proto = new F();

proto.constructor = NewClass;
NewClass.prototype = proto;

// add superclass access
NewClass.superclass = this.prototype;

// add class name
//proto.className = props;

//inherit parent's statics
for (var i in this) {
if (this.hasOwnProperty(i) && i != 'prototype' && i != 'superclass') {
Expand All @@ -39,28 +39,28 @@ L.Class.extend = function(/*Object*/ props) /*-> Class*/ {
L.Util.extend(NewClass, props.statics);
delete props.statics;
}

// mix includes into the prototype
if (props.includes) {
L.Util.extend.apply(null, [proto].concat(props.includes));
delete props.includes;
}

// merge options
if (props.options && proto.options) {
props.options = L.Util.extend({}, proto.options, props.options);
}

// mix given properties into the prototype
L.Util.extend(proto, props);

// allow inheriting further
NewClass.extend = arguments.callee;
NewClass.extend = L.Class.extend;

// method for adding properties to prototype
NewClass.include = function(props) {
L.Util.extend(this.prototype, props);
};

return NewClass;
};
};
32 changes: 16 additions & 16 deletions src/core/Util.js
Expand Up @@ -29,19 +29,19 @@ L.Util = {
return obj[key];
};
})(),

requestAnimFrame: (function() {
function timeoutDefer(callback) {
window.setTimeout(callback, 1000 / 60);
}
var requestFn = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||

var requestFn = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
timeoutDefer;

return function(callback, context, immediate, contextEl) {
callback = context ? L.Util.bind(callback, context) : callback;
if (immediate && requestFn === timeoutDefer) {
Expand All @@ -52,7 +52,7 @@ L.Util = {
};
})(),

limitExecByInterval: function(fn, time, context) {
limitExecByInterval: function(fn, time, context) {
var lock, execOnUnlock, args;
function exec(){
lock = false;
Expand All @@ -63,7 +63,7 @@ L.Util = {
}
return function() {
args = arguments;
if (!lock) {
if (!lock) {
lock = true;
setTimeout(exec, time);
fn.apply(context, args);
Expand All @@ -72,18 +72,18 @@ L.Util = {
}
};
},

falseFn: function() { return false; },

formatNum: function(num, digits) {
var pow = Math.pow(10, digits || 5);
return Math.round(num * pow) / pow;
},

setOptions: function(obj, options) {
obj.options = L.Util.extend({}, obj.options, options);
},

getParamString: function(obj) {
var params = [];
for (var i in obj) {
Expand All @@ -95,12 +95,12 @@ L.Util = {
},

template: function (str, data) {
return str.replace(/\{ *([^} ]+) *\}/g, function (str, key) {
return str.replace(/\{ *([\w_]+) *\}/g, function (str, key) {
var value = data[key];
if (!data.hasOwnProperty(key)) {
throw new Error('No value provided for variable ' + str);
}
return value;
});
}
};
};
4 changes: 3 additions & 1 deletion src/dom/DomEvent.js
Expand Up @@ -40,7 +40,7 @@ L.DomEvent = {

removeListener: function(/*HTMLElement*/ obj, /*String*/ type, /*Function*/ fn) {
var id = L.Util.stamp(fn),
key = '_leaflet_' + type + id;
key = '_leaflet_' + type + id,
handler = obj[key];

if (!handler) { return; }
Expand Down Expand Up @@ -76,6 +76,7 @@ L.DomEvent = {
return (related != el);
},

/*jshint noarg:false */ // evil magic for IE
_getEvent: function()/*->Event*/ {
var e = window.event;
if (!e) {
Expand All @@ -88,6 +89,7 @@ L.DomEvent = {
}
return e;
},
/*jshint noarg:false */

stopPropagation: function(/*Event*/ e) {
if (e.stopPropagation) {
Expand Down

0 comments on commit dc79b10

Please sign in to comment.