// opts.test : (default true) function to test in the while test part
// opts.loop : (default empty) function to call in the while loop part
// opts.end : (default empty) function to call at the end of the while loop
-$.whileAsync = function(opts)
-{
+$.whileAsync = function(opts) {
var delay = Math.abs(opts.delay) || 10,
bulk = isNaN(opts.bulk) ? 500 : Math.abs(opts.bulk),
test = opts.test || function(){ return true; },
loop = opts.loop || function(){},
- end = opts.end || function(){};
+ end = opts.end || function(){};
(function(){
var t = false,
begin = new Date();
- while( t = test() )
- {
+ while( t = test() ) {
loop();
- if( bulk === 0 || (new Date() - begin) > bulk )
- {
+ if( bulk === 0 || (new Date() - begin) > bulk ) {
break;
}
}
- if( t )
- {
+ if( t ) {
setTimeout(arguments.callee, delay);
}
- else
- {
+ else {
end();
}
// opts.bulk : (default 500) delay during which the loop can continue synchronously without yielding the CPU
// opts.loop : (default empty) function to call in the each loop part, signature: function(index, value) this = value
// opts.end : (default empty) function to call at the end of the each loop
-$.eachAsync = function(array, opts)
-{
- var i = 0,
+$.eachAsync = function(array, opts) {
+ var i = 0,
l = array.length,
loop = opts.loop || function(){};
$.whileAsync(
$.extend(opts, {
- test: function(){ return i < l; },
- loop: function()
- {
+ test: function() { return i < l; },
+ loop: function() {
var val = array[i];
return loop.call(val, i++, val);
}
);
};
-$.fn.eachAsync = function(opts)
-{
+$.fn.eachAsync = function(opts) {
$.eachAsync(this, opts);
return this;
}
-})(jQuery);
-
+})(jQuery);
\ No newline at end of file
'matchText': null
}, options );
$(this).each( function() {
- var $this = $(this);
+ var $el = $(this);
if ( options.restoreText ) {
- if ( ! $this.data( 'autoEllipsis.originalText' ) ) {
- $this.data( 'autoEllipsis.originalText', $this.text() );
+ if ( !$el.data( 'autoEllipsis.originalText' ) ) {
+ $el.data( 'autoEllipsis.originalText', $el.text() );
} else {
- $this.text( $this.data( 'autoEllipsis.originalText' ) );
+ $el.text( $el.data( 'autoEllipsis.originalText' ) );
}
}
// container element - used for measuring against
- var $container = $this;
+ var $container = $el;
// trimmable text element - only the text within this element will be trimmed
var $trimmableText = null;
// protected text element - the width of this element is counted, but next is never trimmed from it
var $protectedText = null;
if ( options.hasSpan ) {
- $trimmableText = $this.children( options.selector );
+ $trimmableText = $el.children( options.selector );
} else {
$trimmableText = $( '<span />' )
.css( 'whiteSpace', 'nowrap' )
- .text( $this.text() );
- $this
+ .text( $el.text() );
+ $el
.empty()
.append( $trimmableText );
}
}
if ( !options.matchText && w in cache[text] ) {
$container.html( cache[text][w] );
- if ( options.tooltip )
+ if ( options.tooltip ) {
$container.attr( 'title', text );
+ }
return;
}
if( options.matchText && options.matchText in matchTextCache[text] && w in matchTextCache[text][options.matchText] ) {
$container.html( matchTextCache[text][options.matchText][w] );
- if ( options.tooltip )
+ if ( options.tooltip ) {
$container.attr( 'title', text );
+ }
return;
}
if ( $trimmableText.width() + pw > w ) {
while ( $trimmableText.outerWidth() + pw > w && i[0] > 0 ) {
$trimmableText.text( trimmableText.substr( 0, i[0] ) + '...' + trimmableText.substr( i[1] ) );
// Alternate between trimming the end and begining
- if ( side == 0 ) {
+ if ( side === 0 ) {
// Make the begining shorter
i[0]--;
side = 1;
/**
* User-agent detection
*/
- */
( function( $ ) {
$.client = new ( function() {
* Returns an object containing information about the browser
*
* The resulting client object will be in the following format:
- * {
- * 'name': 'firefox',
- * 'layout': 'gecko',
- * 'layoutVersion': '20101026',
- * 'platform': 'linux'
- * 'version': '3.5.1',
- * 'versionBase': '3',
- * 'versionNumber': 3.5,
- * }
+ * {
+ * 'name': 'firefox',
+ * 'layout': 'gecko',
+ * 'layoutVersion': '20101026',
+ * 'platform': 'linux'
+ * 'version': '3.5.1',
+ * 'versionBase': '3',
+ * 'versionNumber': 3.5,
+ * }
*/
this.profile = function() {
// Use the cached version if possible
// This helps keep differnt versions consistent
['Navigator', 'Netscape'],
// This prevents version extraction issues, otherwise translation would happen later
- ['PLAYSTATION 3', 'PS3'],
+ ['PLAYSTATION 3', 'PS3']
];
// Strings which precede a version number in a user agent string - combined and used as match 1 in
// version detectection
var versionSuffix = '(\\/|\\;?\\s|)([a-z0-9\\.\\+]*?)(\\;|dev|rel|\\)|\\s|$)';
// Names of known browsers
var names = [
- 'camino', 'chrome', 'firefox', 'netscape', 'konqueror', 'lynx', 'msie', 'opera', 'safari', 'ipod',
- 'iphone', 'blackberry', 'ps3'
+ 'camino', 'chrome', 'firefox', 'netscape', 'konqueror', 'lynx', 'msie', 'opera', 'safari', 'ipod',
+ 'iphone', 'blackberry', 'ps3'
];
// Tanslations for conforming browser names
var nameTranslations = [];
/* Methods */
// Performs multiple replacements on a string
- function translate( source, translations ) {
+ var translate = function( source, translations ) {
for ( var i = 0; i < translations.length; i++ ) {
source = source.replace( translations[i][0], translations[i][1] );
}
layout = translate( match[1], layoutTranslations );
}
if ( match = new RegExp( '(' + layoutVersions.join( '|' ) + ')\\\/(\\d+)').exec( navigator.userAgent.toLowerCase() ) ) {
- layoutversion = parseInt(match[2]);
+ layoutversion = parseInt( match[2], 10 );
}
if ( match = new RegExp( '(' + platforms.join( '|' ) + ')' ).exec( navigator.platform.toLowerCase() ) ) {
platform = translate( match[1], platformTranslations );
* element is classified as either "ltr" or "rtl". If neither is set, "ltr" is assumed.
*
* A browser map is in the following format:
- * {
- * 'ltr': {
- * // Multiple rules with configurable operators
- * 'msie': [['>=', 7], ['!=', 9]],
- * // Blocked entirely
- * 'iphone': false
- * },
- * 'rtl': {
- * // Test against a string
- * 'msie': [['!==', '8.1.2.3']],
- * // RTL rules do not fall through to LTR rules, you must explicity set each of them
- * 'iphone': false
- * }
- * }
+ * {
+ * 'ltr': {
+ * // Multiple rules with configurable operators
+ * 'msie': [['>=', 7], ['!=', 9]],
+ * // Blocked entirely
+ * 'iphone': false
+ * },
+ * 'rtl': {
+ * // Test against a string
+ * 'msie': [['!==', '8.1.2.3']],
+ * // RTL rules do not fall through to LTR rules, you must explicity set each of them
+ * 'iphone': false
+ * }
+ * }
*
* @param map Object of browser support map
*