mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
fix
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
# jQuery Actual Plugin CHANGELOG
|
||||
|
||||
## 1.0.19
|
||||
|
||||
- Add `main` property to `package.json`
|
||||
|
||||
|
||||
|
||||
## 1.0.18
|
||||
|
||||
- Depend on jQuery as a peer
|
||||
|
||||
|
||||
|
||||
## 1.0.17
|
||||
|
||||
- Added display inline support
|
||||
|
||||
|
||||
|
||||
## 1.0.16
|
||||
|
||||
- [refactoring] Keep original element styles as far as possible
|
||||
|
||||
|
||||
|
||||
## 1.0.15
|
||||
|
||||
- [bug fix] Replaced jQuery version detection with feature detection. Previously this would not properly detect jQuery 1.10+
|
||||
|
||||
|
||||
|
||||
## 1.0.14
|
||||
|
||||
- Added support for jQuery 1.9.0
|
||||
|
||||
|
||||
|
||||
## 1.0.13
|
||||
|
||||
- [bug fix] Local variable `style` not initialized, thanks to [Searle](https://github.com/Searle)
|
||||
|
||||
|
||||
|
||||
## 1.0.12
|
||||
|
||||
- [refactoring] Use `.eq( 0 )` instead of `.filter( ':first' )` for better performance, thanks to Matt Hinchliffe
|
||||
|
||||
|
||||
|
||||
## 1.0.11
|
||||
|
||||
- [refactoring] Select only the first hidden element to improve the perfomance
|
||||
|
||||
|
||||
|
||||
## 1.0.10
|
||||
|
||||
- [bug fix] Override `!imporant` css declarations
|
||||
|
||||
|
||||
|
||||
## 1.0.9
|
||||
|
||||
- [bug fix] jQuery 1.8.0 compatibility
|
||||
|
||||
|
||||
|
||||
## 1.0.8
|
||||
|
||||
- [bug fix] Inverted code lines
|
||||
|
||||
|
||||
|
||||
## 1.0.7
|
||||
|
||||
- [refactoring] Save/restore element style rather than individual CSS attributes( thanks to Jon Tara )
|
||||
|
||||
|
||||
|
||||
## 1.0.6
|
||||
|
||||
- [bug fixed] Pass `configs.includeMargin` to only `outerWidth` and `outerHeight` so it does not break in $ 1.7.2
|
||||
|
||||
|
||||
|
||||
## 1.0.5
|
||||
|
||||
- Add package.json for new jquery plugin site
|
||||
|
||||
|
||||
|
||||
## 1.0.4
|
||||
|
||||
- Add `includeMargin` for `outerWidth`( thanks to Erwin Derksen )
|
||||
|
||||
|
||||
|
||||
## 1.0.3
|
||||
|
||||
- [bug fixed] `$` namespace conflict
|
||||
|
||||
|
||||
|
||||
## 1.0.2
|
||||
|
||||
- [bug fixed] Typo
|
||||
|
||||
|
||||
|
||||
## 1.0.1
|
||||
|
||||
- [bug fixed] Typo
|
||||
|
||||
|
||||
|
||||
## 1.0.0
|
||||
|
||||
- First stable release
|
||||
@@ -0,0 +1,20 @@
|
||||
Copyright 2011, Ben Lin (http://dreamerslab.com/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,115 @@
|
||||
# jQuery Actual Plugin
|
||||
|
||||
Get the actual width/height of invisible DOM elements with jQuery.
|
||||
|
||||
|
||||
|
||||
## Description
|
||||
|
||||
jQuery has trouble finding the width/height of invisible DOM elements. With element or its parent element has css property 'display' set to 'none'. `$('.hidden').width();` will return 0 instead of the actual width; This plugin simply fix it.
|
||||
|
||||
|
||||
|
||||
## Demo
|
||||
|
||||
- Normal usage see demo/normal.html
|
||||
- If you use [css3pie](http://css3pie.com/) you might also want to take a look at another demo( demo/css3pie.html )
|
||||
- Live demo please take a look at [this](http://dreamerslab.com/demos/get-hidden-element-width-with-jquery-actual-plugin) and [this](http://dreamerslab.com/demos/get-hidden-element-width-with-jquery-actual-plugin-with-css3pie/)
|
||||
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
- There is a syntax highlight version, please see [this post](http://dreamerslab.com/blog/en/get-hidden-elements-width-and-height-with-jquery/)
|
||||
- For chinese version please go [here](http://dreamerslab.com/blog/tw/get-hidden-elements-width-and-height-with-jquery/)
|
||||
|
||||
|
||||
|
||||
## Requires
|
||||
|
||||
- jQuery >= 1.2.3
|
||||
|
||||
|
||||
|
||||
## Browser Compatibility
|
||||
|
||||
- [Firefox](http://mzl.la/RNaI) 2.0+
|
||||
- [Internet Explorer](http://bit.ly/9fMgIQ) 6+
|
||||
- [Safari](http://bit.ly/gMhzVR) 3+
|
||||
- [Opera](http://bit.ly/fWJzaC) 10.6+
|
||||
- [Chrome](http://bit.ly/ePHvYZ) 8+
|
||||
|
||||
|
||||
|
||||
## Installation
|
||||
- First, make sure you are using valid [DOCTYPE](http://bit.ly/hQK1Rk)
|
||||
- Include necessary JS files
|
||||
|
||||
<!-- -->
|
||||
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="path-to-file/jquery.actual.js"></script>
|
||||
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Example code:
|
||||
|
||||
// get hidden element actual width
|
||||
$( '.hidden' ).actual( 'width' );
|
||||
|
||||
// get hidden element actual innerWidth
|
||||
$( '.hidden' ).actual( 'innerWidth' );
|
||||
|
||||
// get hidden element actual outerWidth
|
||||
$( '.hidden' ).actual( 'outerWidth' );
|
||||
|
||||
// get hidden element actual outerWidth and set the `includeMargin` argument
|
||||
$( '.hidden' ).actual( 'outerWidth', { includeMargin : true });
|
||||
|
||||
// get hidden element actual height
|
||||
$( '.hidden' ).actual( 'height' );
|
||||
|
||||
// get hidden element actual innerHeight
|
||||
$( '.hidden' ).actual( 'innerHeight' );
|
||||
|
||||
// get hidden element actual outerHeight
|
||||
$( '.hidden' ).actual( 'outerHeight' );
|
||||
|
||||
// get hidden element actual outerHeight and set the `includeMargin` argument
|
||||
$( '.hidden' ).actual( 'outerHeight', { includeMargin : true });
|
||||
|
||||
// if the page jumps or blinks, pass a attribute '{ absolute : true }'
|
||||
// be very careful, you might get a wrong result depends on how you makrup your html and css
|
||||
$( '.hidden' ).actual( 'height', { absolute : true });
|
||||
|
||||
// if you use css3pie with a float element
|
||||
// for example a rounded corner navigation menu you can also try to pass a attribute '{ clone : true }'
|
||||
// please see demo/css3pie in action
|
||||
$( '.hidden' ).actual( 'width', { clone : true });
|
||||
|
||||
// if it is not a block element. By default { display: 'block' }.
|
||||
// for example a inline element
|
||||
$( '.hidden' ).actual( 'width', { display: 'inline-block' });
|
||||
|
||||
|
||||
|
||||
## Credits
|
||||
|
||||
- Erwin Derksen
|
||||
- [Jon Tara](https://github.com/jtara)
|
||||
- [Matt Hinchliffe](https://github.com/i-like-robots)
|
||||
- [Ryan Millikin](https://github.com/dhamma)
|
||||
- [Jacob Quant](https://github.com/jacobq)
|
||||
- [ejn](https://github.com/ejn)
|
||||
- [Rudolf](https://github.com/qakovalyov)
|
||||
- [jamesallchin](https://github.com/jamesallchin)
|
||||
|
||||
|
||||
|
||||
## License
|
||||
|
||||
The expandable plugin is licensed under the MIT License (LICENSE.txt).
|
||||
|
||||
Copyright (c) 2012 [Ben Lin](http://dreamerslab.com)
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"author": "dreamerslab",
|
||||
"name": "jquery.actual",
|
||||
"version": "1.0.19",
|
||||
"description": "Get the actual width/height of invisible DOM elements with jQuery.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dreamerslab/jquery.actual"
|
||||
},
|
||||
"keywords": [
|
||||
"jquery",
|
||||
"actual"
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": ">= 1.2.3"
|
||||
},
|
||||
"main": "jquery.actual.js",
|
||||
"license": "MIT"
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*! Copyright 2012, Ben Lin (http://dreamerslab.com/)
|
||||
* Licensed under the MIT License (LICENSE.txt).
|
||||
*
|
||||
* Version: 1.0.19
|
||||
*
|
||||
* Requires: jQuery >= 1.2.3
|
||||
*/
|
||||
;( function ( factory ) {
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
// AMD. Register module depending on jQuery using requirejs define.
|
||||
define( ['jquery'], factory );
|
||||
} else {
|
||||
// No AMD.
|
||||
factory( jQuery );
|
||||
}
|
||||
}( function ( $ ){
|
||||
$.fn.addBack = $.fn.addBack || $.fn.andSelf;
|
||||
|
||||
$.fn.extend({
|
||||
|
||||
actual : function ( method, options ){
|
||||
// check if the jQuery method exist
|
||||
if( !this[ method ]){
|
||||
throw '$.actual => The jQuery method "' + method + '" you called does not exist';
|
||||
}
|
||||
|
||||
var defaults = {
|
||||
absolute : false,
|
||||
clone : false,
|
||||
includeMargin : false,
|
||||
display : 'block'
|
||||
};
|
||||
|
||||
var configs = $.extend( defaults, options );
|
||||
|
||||
var $target = this.eq( 0 );
|
||||
var fix, restore;
|
||||
|
||||
if( configs.clone === true ){
|
||||
fix = function (){
|
||||
var style = 'position: absolute !important; top: -1000 !important; ';
|
||||
|
||||
// this is useful with css3pie
|
||||
$target = $target.
|
||||
clone().
|
||||
attr( 'style', style ).
|
||||
appendTo( 'body' );
|
||||
};
|
||||
|
||||
restore = function (){
|
||||
// remove DOM element after getting the width
|
||||
$target.remove();
|
||||
};
|
||||
}else{
|
||||
var tmp = [];
|
||||
var style = '';
|
||||
var $hidden;
|
||||
|
||||
fix = function (){
|
||||
// get all hidden parents
|
||||
$hidden = $target.parents().addBack().filter( ':hidden' );
|
||||
style += 'visibility: hidden !important; display: ' + configs.display + ' !important; ';
|
||||
|
||||
if( configs.absolute === true ) style += 'position: absolute !important; ';
|
||||
|
||||
// save the origin style props
|
||||
// set the hidden el css to be got the actual value later
|
||||
$hidden.each( function (){
|
||||
// Save original style. If no style was set, attr() returns undefined
|
||||
var $this = $( this );
|
||||
var thisStyle = $this.attr( 'style' );
|
||||
|
||||
tmp.push( thisStyle );
|
||||
// Retain as much of the original style as possible, if there is one
|
||||
$this.attr( 'style', thisStyle ? thisStyle + ';' + style : style );
|
||||
});
|
||||
};
|
||||
|
||||
restore = function (){
|
||||
// restore origin style values
|
||||
$hidden.each( function ( i ){
|
||||
var $this = $( this );
|
||||
var _tmp = tmp[ i ];
|
||||
|
||||
if( _tmp === undefined ){
|
||||
$this.removeAttr( 'style' );
|
||||
}else{
|
||||
$this.attr( 'style', _tmp );
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
fix();
|
||||
// get the actual value with user specific methed
|
||||
// it can be 'width', 'height', 'outerWidth', 'innerWidth'... etc
|
||||
// configs.includeMargin only works for 'outerWidth' and 'outerHeight'
|
||||
var actual = /(outer)/.test( method ) ?
|
||||
$target[ method ]( configs.includeMargin ) :
|
||||
$target[ method ]();
|
||||
|
||||
restore();
|
||||
// IMPORTANT, this plugin only return the value of the first element
|
||||
return actual;
|
||||
}
|
||||
});
|
||||
}));
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/*! Copyright 2012, Ben Lin (http://dreamerslab.com/)
|
||||
* Licensed under the MIT License (LICENSE.txt).
|
||||
*
|
||||
* Version: 1.0.19
|
||||
*
|
||||
* Requires: jQuery >= 1.2.3
|
||||
*/
|
||||
(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a);
|
||||
}else{a(jQuery);}}(function(a){a.fn.addBack=a.fn.addBack||a.fn.andSelf;a.fn.extend({actual:function(b,l){if(!this[b]){throw'$.actual => The jQuery method "'+b+'" you called does not exist';
|
||||
}var f={absolute:false,clone:false,includeMargin:false,display:"block"};var i=a.extend(f,l);var e=this.eq(0);var h,j;if(i.clone===true){h=function(){var m="position: absolute !important; top: -1000 !important; ";
|
||||
e=e.clone().attr("style",m).appendTo("body");};j=function(){e.remove();};}else{var g=[];var d="";var c;h=function(){c=e.parents().addBack().filter(":hidden");
|
||||
d+="visibility: hidden !important; display: "+i.display+" !important; ";if(i.absolute===true){d+="position: absolute !important; ";}c.each(function(){var m=a(this);
|
||||
var n=m.attr("style");g.push(n);m.attr("style",n?n+";"+d:d);});};j=function(){c.each(function(m){var o=a(this);var n=g[m];if(n===undefined){o.removeAttr("style");
|
||||
}else{o.attr("style",n);}});};}h();var k=/(outer)/.test(b)?e[b](i.includeMargin):e[b]();j();return k;}});}));
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
// package metadata file for Meteor.js
|
||||
'use strict';
|
||||
|
||||
var packageName = 'dreamerslab:jquery.actual'; // https://atmospherejs.com/mediatainment/switchery
|
||||
var where = 'client'; // where to install: 'client' or 'server'. For both, pass nothing.
|
||||
|
||||
Package.describe({
|
||||
name: packageName,
|
||||
version: '1.0.19',
|
||||
// Brief, one-line summary of the package.
|
||||
summary: 'Get the actual width/height of invisible DOM elements with jQuery.',
|
||||
// URL to the Git repository containing the source code for this package.
|
||||
git: 'https://github.com/dreamerslab/jquery.actual'
|
||||
});
|
||||
|
||||
Package.onUse(function (api) {
|
||||
api.versionsFrom(['METEOR@0.9.0', 'METEOR@1.0']);
|
||||
api.use('jquery', where);
|
||||
api.addFiles('jquery.actual.js', where);
|
||||
});
|
||||
|
||||
Package.onTest(function (api) {
|
||||
api.use([packageName, 'sanjo:jasmine'], where);
|
||||
api.use(['webapp','tinytest'], where);
|
||||
api.addFiles('meteor/tests.js', where); // testing specific files
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name" : "jquery.actual",
|
||||
"version" : "1.0.19",
|
||||
"title" : "jQuery Actual Plugin",
|
||||
"author" : "dreamerslab <ben@dreamerslab.com>",
|
||||
"description": "Older version of jQuery has trouble finding the width/height of invisible DOM elements. With element or its parent element has css property 'display' set to 'none'. `$('.hidden').width();` will return 0 instead of the actual width; This plugin simply fix it.",
|
||||
"keywords": [
|
||||
"width", "height", "hidden element width", "hidden element height", "actual"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"jquery": ">=1.2.3"
|
||||
},
|
||||
"contributors": [
|
||||
{ "name": "Ben Lin", "email": "ben@dreamerslab.com" },
|
||||
{ "name": "Erwin Derksen" },
|
||||
{ "name": "Jon Tara", "email": "jtara-github-public@spamex.com" },
|
||||
{ "name": "Matt Hinchliffe", "email": "matt@maketea.co.uk" },
|
||||
{ "name": "Ryan Millikin" },
|
||||
{ "name": "Jacob Quant" },
|
||||
{ "name": "ejn" },
|
||||
{ "name": "Rudolf", "email": "qa.kovalyov@gmail.com" },
|
||||
{ "name": "jamesallchin" }
|
||||
],
|
||||
"licenses": [{
|
||||
"type" : "MIT",
|
||||
"url" : "LICENSE.txt"
|
||||
}],
|
||||
"main": "jquery.actual.js",
|
||||
"homepage": "http://dreamerslab.com/blog/get-hidden-elements-width-and-height-with-jquery/"
|
||||
}
|
||||
Reference in New Issue
Block a user