Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

jQuery 1.9.1 compatibility and other things #7

Merged
merged 3 commits into from Apr 15, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules/
3 changes: 2 additions & 1 deletion Gruntfile.js
Expand Up @@ -5,7 +5,8 @@ module.exports = function(grunt) {

concat: {
dist: {
src: ['jquery.alba.move.js',
src: ['jquery.browser.js',
'jquery.alba.move.js',
'jquery.alba.eclipse.js',
'jquery.alba.placeholder.js'
],
Expand Down
41 changes: 41 additions & 0 deletions dist/jquery.alba.js
@@ -1,3 +1,44 @@
jQuery(function($) {

// This is ripped right out of the jQuery source
var matched, browser;

// Use of jQuery.browser is frowned upon.
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();

var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];

return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};

matched = $.uaMatch( navigator.userAgent );
browser = {};

if ( matched.browser ) {
browser[ matched.browser ] = true;
browser.version = matched.version;
}

// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
browser.webkit = true;
} else if ( browser.webkit ) {
browser.safari = true;
}

jQuery.browser = browser;

});

/*
- requires jquery.js, ui.position.js
- doesn't work with .delegate yet, i don't think (but .live works)
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.alba.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions jquery.browser.js
@@ -0,0 +1,40 @@
jQuery(function($) {

// This is ripped right out of the jQuery source
var matched, browser;

// Use of jQuery.browser is frowned upon.
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();

var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];

return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};

matched = $.uaMatch( navigator.userAgent );
browser = {};

if ( matched.browser ) {
browser[ matched.browser ] = true;
browser.version = matched.version;
}

// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
browser.webkit = true;
} else if ( browser.webkit ) {
browser.safari = true;
}

jQuery.browser = browser;

});
2 changes: 1 addition & 1 deletion test.html
Expand Up @@ -4,7 +4,7 @@
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://raw.github.com/jquery/jquery-ui/master/ui/jquery.ui.position.js"></script>
<script src="https://raw.github.com/jquery/jquery-ui/master/ui/jquery.ui.widget.js"></script>
<script src="/dist/jquery.alba.js"></script>
<script src="dist/jquery.alba.js"></script>
<script>
$(function() {
for (var x in [1, 2, 3, 4, 5, 6, 7, 8]) {
Expand Down