jquery-actual-rails 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/lib/jquery/actual/rails.rb +2 -7
- data/lib/jquery/actual/rails/engine.rb +11 -0
- data/lib/jquery/actual/rails/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.actual.js +107 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef014b7b4d5e1e726ad19892ecd49ae6e73a996b
|
4
|
+
data.tar.gz: 410aab2873da52e5d5905313b983179ce721c490
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0451ae24d7b945325e1cddee7a7bc56866084777af6ae3aa01ec9af63be95fa1cf254355ec62b5eacaafad8d58c65843b9d8a80dd66119d3859c020fdb16a76
|
7
|
+
data.tar.gz: 43025c65092fb2aa8d27335be3e53d414f0cd9f9929396887e3f8c7415063d003093130c66ff95d18e6dbe0029b1ff1ddb303c1f55c5cc3d29b669609dee6b44
|
data/lib/jquery/actual/rails.rb
CHANGED
@@ -1,13 +1,8 @@
|
|
1
|
-
require "jquery/actual/rails/version"
|
2
|
-
|
3
1
|
module Jquery
|
4
2
|
module Actual
|
5
3
|
module Rails
|
6
|
-
|
7
|
-
|
8
|
-
app.config.assets.precompile += ['jquery.actual.js']
|
9
|
-
end
|
10
|
-
end
|
4
|
+
require 'jquery/actual/rails/engine'
|
5
|
+
require 'jquery/actual/rails/version'
|
11
6
|
end
|
12
7
|
end
|
13
8
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
/*! Copyright 2012, Ben Lin (http://dreamerslab.com/)
|
2
|
+
* Licensed under the MIT License (LICENSE.txt).
|
3
|
+
*
|
4
|
+
* Version: 1.0.19
|
5
|
+
*
|
6
|
+
* Requires: jQuery >= 1.2.3
|
7
|
+
*/
|
8
|
+
;( function ( factory ) {
|
9
|
+
if ( typeof define === 'function' && define.amd ) {
|
10
|
+
// AMD. Register module depending on jQuery using requirejs define.
|
11
|
+
define( ['jquery'], factory );
|
12
|
+
} else {
|
13
|
+
// No AMD.
|
14
|
+
factory( jQuery );
|
15
|
+
}
|
16
|
+
}( function ( $ ){
|
17
|
+
$.fn.addBack = $.fn.addBack || $.fn.andSelf;
|
18
|
+
|
19
|
+
$.fn.extend({
|
20
|
+
|
21
|
+
actual : function ( method, options ){
|
22
|
+
// check if the jQuery method exist
|
23
|
+
if( !this[ method ]){
|
24
|
+
throw '$.actual => The jQuery method "' + method + '" you called does not exist';
|
25
|
+
}
|
26
|
+
|
27
|
+
var defaults = {
|
28
|
+
absolute : false,
|
29
|
+
clone : false,
|
30
|
+
includeMargin : false,
|
31
|
+
display : 'block'
|
32
|
+
};
|
33
|
+
|
34
|
+
var configs = $.extend( defaults, options );
|
35
|
+
|
36
|
+
var $target = this.eq( 0 );
|
37
|
+
var fix, restore;
|
38
|
+
|
39
|
+
if( configs.clone === true ){
|
40
|
+
fix = function (){
|
41
|
+
var style = 'position: absolute !important; top: -1000 !important; ';
|
42
|
+
|
43
|
+
// this is useful with css3pie
|
44
|
+
$target = $target.
|
45
|
+
clone().
|
46
|
+
attr( 'style', style ).
|
47
|
+
appendTo( 'body' );
|
48
|
+
};
|
49
|
+
|
50
|
+
restore = function (){
|
51
|
+
// remove DOM element after getting the width
|
52
|
+
$target.remove();
|
53
|
+
};
|
54
|
+
}else{
|
55
|
+
var tmp = [];
|
56
|
+
var style = '';
|
57
|
+
var $hidden;
|
58
|
+
|
59
|
+
fix = function (){
|
60
|
+
// get all hidden parents
|
61
|
+
$hidden = $target.parents().addBack().filter( ':hidden' );
|
62
|
+
style += 'visibility: hidden !important; display: ' + configs.display + ' !important; ';
|
63
|
+
|
64
|
+
if( configs.absolute === true ) style += 'position: absolute !important; ';
|
65
|
+
|
66
|
+
// save the origin style props
|
67
|
+
// set the hidden el css to be got the actual value later
|
68
|
+
$hidden.each( function (){
|
69
|
+
// Save original style. If no style was set, attr() returns undefined
|
70
|
+
var $this = $( this );
|
71
|
+
var thisStyle = $this.attr( 'style' );
|
72
|
+
|
73
|
+
tmp.push( thisStyle );
|
74
|
+
// Retain as much of the original style as possible, if there is one
|
75
|
+
$this.attr( 'style', thisStyle ? thisStyle + ';' + style : style );
|
76
|
+
});
|
77
|
+
};
|
78
|
+
|
79
|
+
restore = function (){
|
80
|
+
// restore origin style values
|
81
|
+
$hidden.each( function ( i ){
|
82
|
+
var $this = $( this );
|
83
|
+
var _tmp = tmp[ i ];
|
84
|
+
|
85
|
+
if( _tmp === undefined ){
|
86
|
+
$this.removeAttr( 'style' );
|
87
|
+
}else{
|
88
|
+
$this.attr( 'style', _tmp );
|
89
|
+
}
|
90
|
+
});
|
91
|
+
};
|
92
|
+
}
|
93
|
+
|
94
|
+
fix();
|
95
|
+
// get the actual value with user specific methed
|
96
|
+
// it can be 'width', 'height', 'outerWidth', 'innerWidth'... etc
|
97
|
+
// configs.includeMargin only works for 'outerWidth' and 'outerHeight'
|
98
|
+
var actual = /(outer)/.test( method ) ?
|
99
|
+
$target[ method ]( configs.includeMargin ) :
|
100
|
+
$target[ method ]();
|
101
|
+
|
102
|
+
restore();
|
103
|
+
// IMPORTANT, this plugin only return the value of the first element
|
104
|
+
return actual;
|
105
|
+
}
|
106
|
+
});
|
107
|
+
}));
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-actual-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill
|
@@ -69,9 +69,12 @@ files:
|
|
69
69
|
- Rakefile
|
70
70
|
- bin/console
|
71
71
|
- bin/setup
|
72
|
+
- jquery-actual-rails-0.1.0.gem
|
72
73
|
- jquery-actual-rails.gemspec
|
73
74
|
- lib/jquery/actual/rails.rb
|
75
|
+
- lib/jquery/actual/rails/engine.rb
|
74
76
|
- lib/jquery/actual/rails/version.rb
|
77
|
+
- vendor/assets/javascripts/jquery.actual.js
|
75
78
|
homepage: https://github.com/cderche/jquery-actual-rails
|
76
79
|
licenses:
|
77
80
|
- MIT
|