MERGE Added scrollbarwidth plugin (AIR-17)

This commit is contained in:
Ingo Schommer 2011-09-22 12:24:07 +02:00
parent eb35f4f4ae
commit f969ecf51d
5 changed files with 74 additions and 0 deletions

View File

@ -281,6 +281,7 @@ class LeftAndMain extends Controller {
THIRDPARTY_DIR . '/scriptaculous/controls.js',
THIRDPARTY_DIR . '/greybox/AmiJS.js',
THIRDPARTY_DIR . '/greybox/greybox.js',
CMS_DIR . '/thirdparty/jquery-getscrollbarwidth/jquery.getscrollbarwidth.js',
CMS_DIR . '/javascript/LeftAndMain.js',
CMS_DIR . '/javascript/LeftAndMain_left.js',
CMS_DIR . '/javascript/LeftAndMain_right.js',

View File

@ -0,0 +1,8 @@
---
format: 1
handler:
commit: d04ef8794e8459cd65529efa3e623a9f3764d142
branch: master
lock: false
repository_class: Piston::Git::Repository
repository_url: https://github.com/brandonaaron/jquery-getscrollbarwidth.git

View File

@ -0,0 +1,10 @@
# Get Scrollbar Width
A jQuery plugin to retrieve the width of a system scrollbar.
## License
The Get Scrollbar Width plugin is dual licensed *(just like jQuery)* under the [MIT](http://www.opensource.org/licenses/mit-license.php) and [GPL](http://www.opensource.org/licenses/gpl-license.php) licenses.
Copyright (c) 2008 [Brandon Aaron](http://brandonaaron.net)

View File

@ -0,0 +1,24 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>jQuery getScrollBarWidth example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.getScrollbarWidth.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(function() {
$('#width').text( $.getScrollbarWidth() );
});
</script>
<style type="text/css" media="screen">
#example { width: 100px; height: 100px; overflow: auto; }
#example div { width: 100%; height: 200px; background: #ccc; border: 1px solid #000; }
</style>
</head>
<body>
<h1>jQuery <code>getScrollbarWidth</code> Snippet Example</h1>
<p>The scrollbar width is <span id="width"></span></p>
<div id="example"><div></div></div>
</body>
</html>

View File

@ -0,0 +1,31 @@
/*! Copyright (c) 2008 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*/
/**
* Gets the width of the OS scrollbar
*/
(function($) {
var scrollbarWidth = 0;
$.getScrollbarWidth = function() {
if ( !scrollbarWidth ) {
if ( $.browser.msie ) {
var $textarea1 = $('<textarea cols="10" rows="2"></textarea>')
.css({ position: 'absolute', top: -1000, left: -1000 }).appendTo('body'),
$textarea2 = $('<textarea cols="10" rows="2" style="overflow: hidden;"></textarea>')
.css({ position: 'absolute', top: -1000, left: -1000 }).appendTo('body');
scrollbarWidth = $textarea1.width() - $textarea2.width();
$textarea1.add($textarea2).remove();
} else {
var $div = $('<div />')
.css({ width: 100, height: 100, overflow: 'auto', position: 'absolute', top: -1000, left: -1000 })
.prependTo('body').append('<div />').find('div')
.css({ width: '100%', height: 200 });
scrollbarWidth = 100 - $div.width();
$div.parent().remove();
}
}
return scrollbarWidth;
};
})(jQuery);