From e253a014bc2476409880ac8374db62e44196982b Mon Sep 17 00:00:00 2001 From: Craig Michael Thompson Date: Thu, 11 Jul 2013 18:09:29 +0100 Subject: [PATCH] Enable strict mode, and fix global variable problems. --- src/core/class.js | 7 ++++--- src/core/intro.js | 2 +- src/core/toggle.js | 2 +- src/tips/tips.js | 10 +++++----- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/core/class.js b/src/core/class.js index bb91b0bf..5293720d 100644 --- a/src/core/class.js +++ b/src/core/class.js @@ -6,7 +6,7 @@ function QTip(target, options, id, attr) { this.id = id; this.target = target; this.tooltip = NULL; - this.elements = elements = { target: target }; + this.elements = { target: target }; // Internal constructs this._id = NAMESPACE + '-' + id; @@ -15,7 +15,7 @@ function QTip(target, options, id, attr) { this.plugins = {}; // Cache object - this.cache = cache = { + this.cache = { event: {}, target: $(), disabled: FALSE, @@ -42,7 +42,8 @@ PROTOTYPE.render = function(show) { button = options.content.button, posOptions = options.position, namespace = '.'+this._id+' ', - deferreds = []; + deferreds = [], + tooltip; // Add ARIA attributes to target $.attr(this.target[0], 'aria-describedby', this._id); diff --git a/src/core/intro.js b/src/core/intro.js index 33672bfb..0d514dba 100644 --- a/src/core/intro.js +++ b/src/core/intro.js @@ -16,5 +16,5 @@ } (function($) { /* This currently causes issues with Safari 6, so for it's disabled */ - //"use strict"; // (Dis)able ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ + "use strict"; // (Dis)able ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ diff --git a/src/core/toggle.js b/src/core/toggle.js index ca29b9ca..68ca6644 100644 --- a/src/core/toggle.js +++ b/src/core/toggle.js @@ -32,7 +32,7 @@ PROTOTYPE.toggle = function(state, event) { visible = this.tooltip[0].offsetWidth > 0, animate = state || opts.target.length === 1, sameTarget = !event || opts.target.length < 2 || cache.target[0] === event.target, - identicalState, allow, showEvent, delay; + identicalState, allow, showEvent, delay, after; // Detect state if valid one isn't provided if((typeof state).search('boolean|number')) { state = !visible; } diff --git a/src/tips/tips.js b/src/tips/tips.js index b1fbd550..8ef2a628 100644 --- a/src/tips/tips.js +++ b/src/tips/tips.js @@ -140,7 +140,7 @@ $.extend(Tip.prototype, { return (use ? intCss(use, prop) : ( intCss(elements.content, prop) || intCss(this._useTitle(corner) && elements.titlebar || elements.content, prop) || - intCss(tooltip, prop) + intCss(elements.tooltip, prop) )) || 0; }, @@ -167,11 +167,11 @@ $.extend(Tip.prototype, { // Attempt to detect the background colour from various elements, left-to-right precedance color[0] = css(tip, BG_COLOR) || css(colorElem, BG_COLOR) || css(elements.content, BG_COLOR) || - css(tooltip, BG_COLOR) || tip.css(BG_COLOR); + css(elements.tooltip, BG_COLOR) || tip.css(BG_COLOR); // Attempt to detect the correct border side colour from various elements, left-to-right precedance color[1] = css(tip, borderSide, COLOR) || css(colorElem, borderSide, COLOR) || - css(elements.content, borderSide, COLOR) || css(tooltip, borderSide, COLOR) || tooltip.css(borderSide); + css(elements.content, borderSide, COLOR) || css(elements.tooltip, borderSide, COLOR) || elements.tooltip.css(borderSide); // Reset background and border colours $('*', tip).add(tip).css('cssText', BG_COLOR+':'+TRANSPARENT+IMPORTANT+';'+BORDER+':0'+IMPORTANT+';'); @@ -352,7 +352,7 @@ $.extend(Tip.prototype, { if(border) { // Make sure transparent borders are supported by doing a stroke // of the background colour before the stroke colour - if(tooltip.css('background-clip') === 'border-box') { + if(elements.tooltip.css('background-clip') === 'border-box') { context.strokeStyle = color[0]; context.stroke(); } @@ -412,7 +412,7 @@ $.extend(Tip.prototype, { elements = this.qtip.elements, tip = this.element, userOffset = this.options.offset, - isWidget = this.qtip.tooltip.hasClass('ui-widget'), + isWidget = elements.tooltip.hasClass('ui-widget'), position = { }, precedance, size, corners;