jquerypp-rails 1.0.1.1.rc3 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +28 -31
- data/lib/jquerypp/rails/version.rb +1 -1
- metadata +2 -25
- data/vendor/assets/javascripts/lib/jquery.animate.js +0 -326
- data/vendor/assets/javascripts/lib/jquery.compare.js +0 -75
- data/vendor/assets/javascripts/lib/jquery.cookie.js +0 -118
- data/vendor/assets/javascripts/lib/jquery.dimensions.js +0 -191
- data/vendor/assets/javascripts/lib/jquery.event.default.js +0 -115
- data/vendor/assets/javascripts/lib/jquery.event.destroyed.js +0 -23
- data/vendor/assets/javascripts/lib/jquery.event.drag.js +0 -727
- data/vendor/assets/javascripts/lib/jquery.event.drop.js +0 -457
- data/vendor/assets/javascripts/lib/jquery.event.fastfix.js +0 -95
- data/vendor/assets/javascripts/lib/jquery.event.hover.js +0 -266
- data/vendor/assets/javascripts/lib/jquery.event.key.js +0 -156
- data/vendor/assets/javascripts/lib/jquery.event.livehack.js +0 -174
- data/vendor/assets/javascripts/lib/jquery.event.pause.js +0 -92
- data/vendor/assets/javascripts/lib/jquery.event.resize.js +0 -47
- data/vendor/assets/javascripts/lib/jquery.event.swipe.js +0 -133
- data/vendor/assets/javascripts/lib/jquery.fills.js +0 -249
- data/vendor/assets/javascripts/lib/jquery.form_params.js +0 -167
- data/vendor/assets/javascripts/lib/jquery.lang.json.js +0 -196
- data/vendor/assets/javascripts/lib/jquery.lang.vector.js +0 -214
- data/vendor/assets/javascripts/lib/jquery.range.js +0 -861
- data/vendor/assets/javascripts/lib/jquery.selection.js +0 -232
- data/vendor/assets/javascripts/lib/jquery.styles.js +0 -103
- data/vendor/assets/javascripts/lib/jquery.within.js +0 -94
@@ -1,174 +0,0 @@
|
|
1
|
-
// - jquery.event.livehack.js
|
2
|
-
(function() {
|
3
|
-
|
4
|
-
var event = jQuery.event,
|
5
|
-
|
6
|
-
//helper that finds handlers by type and calls back a function, this is basically handle
|
7
|
-
// events - the events object
|
8
|
-
// types - an array of event types to look for
|
9
|
-
// callback(type, handlerFunc, selector) - a callback
|
10
|
-
// selector - an optional selector to filter with, if there, matches by selector
|
11
|
-
// if null, matches anything, otherwise, matches with no selector
|
12
|
-
findHelper = function( events, types, callback, selector ) {
|
13
|
-
var t, type, typeHandlers, all, h, handle,
|
14
|
-
namespaces, namespace,
|
15
|
-
match;
|
16
|
-
for ( t = 0; t < types.length; t++ ) {
|
17
|
-
type = types[t];
|
18
|
-
all = type.indexOf(".") < 0;
|
19
|
-
if (!all ) {
|
20
|
-
namespaces = type.split(".");
|
21
|
-
type = namespaces.shift();
|
22
|
-
namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
|
23
|
-
}
|
24
|
-
typeHandlers = (events[type] || []).slice(0);
|
25
|
-
|
26
|
-
for ( h = 0; h < typeHandlers.length; h++ ) {
|
27
|
-
handle = typeHandlers[h];
|
28
|
-
|
29
|
-
match = (all || namespace.test(handle.namespace));
|
30
|
-
|
31
|
-
if(match){
|
32
|
-
if(selector){
|
33
|
-
if (handle.selector === selector ) {
|
34
|
-
callback(type, handle.origHandler || handle.handler);
|
35
|
-
}
|
36
|
-
} else if (selector === null){
|
37
|
-
callback(type, handle.origHandler || handle.handler, handle.selector);
|
38
|
-
}
|
39
|
-
else if (!handle.selector ) {
|
40
|
-
callback(type, handle.origHandler || handle.handler);
|
41
|
-
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
|
46
|
-
}
|
47
|
-
}
|
48
|
-
};
|
49
|
-
|
50
|
-
/**
|
51
|
-
* Finds event handlers of a given type on an element.
|
52
|
-
* @param {HTMLElement} el
|
53
|
-
* @param {Array} types an array of event names
|
54
|
-
* @param {String} [selector] optional selector
|
55
|
-
* @return {Array} an array of event handlers
|
56
|
-
*/
|
57
|
-
event.find = function( el, types, selector ) {
|
58
|
-
var events = ( $._data(el) || {} ).events,
|
59
|
-
handlers = [],
|
60
|
-
t, liver, live;
|
61
|
-
|
62
|
-
if (!events ) {
|
63
|
-
return handlers;
|
64
|
-
}
|
65
|
-
findHelper(events, types, function( type, handler ) {
|
66
|
-
handlers.push(handler);
|
67
|
-
}, selector);
|
68
|
-
return handlers;
|
69
|
-
};
|
70
|
-
/**
|
71
|
-
* Finds all events. Group by selector.
|
72
|
-
* @param {HTMLElement} el the element
|
73
|
-
* @param {Array} types event types
|
74
|
-
*/
|
75
|
-
event.findBySelector = function( el, types ) {
|
76
|
-
var events = $._data(el).events,
|
77
|
-
selectors = {},
|
78
|
-
//adds a handler for a given selector and event
|
79
|
-
add = function( selector, event, handler ) {
|
80
|
-
var select = selectors[selector] || (selectors[selector] = {}),
|
81
|
-
events = select[event] || (select[event] = []);
|
82
|
-
events.push(handler);
|
83
|
-
};
|
84
|
-
|
85
|
-
if (!events ) {
|
86
|
-
return selectors;
|
87
|
-
}
|
88
|
-
//first check live:
|
89
|
-
/*$.each(events.live || [], function( i, live ) {
|
90
|
-
if ( $.inArray(live.origType, types) !== -1 ) {
|
91
|
-
add(live.selector, live.origType, live.origHandler || live.handler);
|
92
|
-
}
|
93
|
-
});*/
|
94
|
-
//then check straight binds
|
95
|
-
findHelper(events, types, function( type, handler, selector ) {
|
96
|
-
add(selector || "", type, handler);
|
97
|
-
}, null);
|
98
|
-
|
99
|
-
return selectors;
|
100
|
-
};
|
101
|
-
event.supportTouch = "ontouchend" in document;
|
102
|
-
|
103
|
-
$.fn.respondsTo = function( events ) {
|
104
|
-
if (!this.length ) {
|
105
|
-
return false;
|
106
|
-
} else {
|
107
|
-
//add default ?
|
108
|
-
return event.find(this[0], $.isArray(events) ? events : [events]).length > 0;
|
109
|
-
}
|
110
|
-
};
|
111
|
-
$.fn.triggerHandled = function( event, data ) {
|
112
|
-
event = (typeof event == "string" ? $.Event(event) : event);
|
113
|
-
this.trigger(event, data);
|
114
|
-
return event.handled;
|
115
|
-
};
|
116
|
-
/**
|
117
|
-
* Only attaches one event handler for all types ...
|
118
|
-
* @param {Array} types llist of types that will delegate here
|
119
|
-
* @param {Object} startingEvent the first event to start listening to
|
120
|
-
* @param {Object} onFirst a function to call
|
121
|
-
*/
|
122
|
-
event.setupHelper = function( types, startingEvent, onFirst ) {
|
123
|
-
if (!onFirst ) {
|
124
|
-
onFirst = startingEvent;
|
125
|
-
startingEvent = null;
|
126
|
-
}
|
127
|
-
var add = function( handleObj ) {
|
128
|
-
|
129
|
-
var bySelector, selector = handleObj.selector || "";
|
130
|
-
if ( selector ) {
|
131
|
-
bySelector = event.find(this, types, selector);
|
132
|
-
if (!bySelector.length ) {
|
133
|
-
$(this).delegate(selector, startingEvent, onFirst);
|
134
|
-
}
|
135
|
-
}
|
136
|
-
else {
|
137
|
-
//var bySelector = event.find(this, types, selector);
|
138
|
-
if (!event.find(this, types, selector).length ) {
|
139
|
-
event.add(this, startingEvent, onFirst, {
|
140
|
-
selector: selector,
|
141
|
-
delegate: this
|
142
|
-
});
|
143
|
-
}
|
144
|
-
|
145
|
-
}
|
146
|
-
|
147
|
-
},
|
148
|
-
remove = function( handleObj ) {
|
149
|
-
var bySelector, selector = handleObj.selector || "";
|
150
|
-
if ( selector ) {
|
151
|
-
bySelector = event.find(this, types, selector);
|
152
|
-
if (!bySelector.length ) {
|
153
|
-
$(this).undelegate(selector, startingEvent, onFirst);
|
154
|
-
}
|
155
|
-
}
|
156
|
-
else {
|
157
|
-
if (!event.find(this, types, selector).length ) {
|
158
|
-
event.remove(this, startingEvent, onFirst, {
|
159
|
-
selector: selector,
|
160
|
-
delegate: this
|
161
|
-
});
|
162
|
-
}
|
163
|
-
}
|
164
|
-
};
|
165
|
-
$.each(types, function() {
|
166
|
-
event.special[this] = {
|
167
|
-
add: add,
|
168
|
-
remove: remove,
|
169
|
-
setup: function() {},
|
170
|
-
teardown: function() {}
|
171
|
-
};
|
172
|
-
});
|
173
|
-
};
|
174
|
-
})(jQuery)
|
@@ -1,92 +0,0 @@
|
|
1
|
-
// Dependencies:
|
2
|
-
//
|
3
|
-
// - jquery.event.pause.js
|
4
|
-
// - jquery.event.default.js
|
5
|
-
|
6
|
-
(function($){
|
7
|
-
|
8
|
-
|
9
|
-
var current,
|
10
|
-
rnamespaces = /\.(.*)$/,
|
11
|
-
returnFalse = function(){return false},
|
12
|
-
returnTrue = function(){return true};
|
13
|
-
|
14
|
-
$.Event.prototype.isPaused = returnFalse
|
15
|
-
|
16
|
-
/**
|
17
|
-
* @function jQuery.Event.prototype.pause
|
18
|
-
* @parent jQuery.event.pause
|
19
|
-
*
|
20
|
-
* `event.paused()` pauses an event (to be resumed later):
|
21
|
-
*
|
22
|
-
* $('.tab').on('show', function(ev) {
|
23
|
-
* ev.pause();
|
24
|
-
* // Resume the event after 1 second
|
25
|
-
* setTimeout(function() {
|
26
|
-
* ev.resume();
|
27
|
-
* }, 1000);
|
28
|
-
* });
|
29
|
-
*/
|
30
|
-
$.Event.prototype.pause = function(){
|
31
|
-
// stop the event from continuing temporarily
|
32
|
-
// keep the current state of the event ...
|
33
|
-
this.pausedState = {
|
34
|
-
isDefaultPrevented : this.isDefaultPrevented() ?
|
35
|
-
returnTrue : returnFalse,
|
36
|
-
isPropagationStopped : this.isPropagationStopped() ?
|
37
|
-
returnTrue : returnFalse
|
38
|
-
};
|
39
|
-
|
40
|
-
this.stopImmediatePropagation();
|
41
|
-
this.preventDefault();
|
42
|
-
this.isPaused = returnTrue;
|
43
|
-
};
|
44
|
-
|
45
|
-
/**
|
46
|
-
* @function jQuery.Event.prototype.resume
|
47
|
-
* @parent jQuery.event.pause
|
48
|
-
*
|
49
|
-
* `event.resume()` resumes a paused event:
|
50
|
-
*
|
51
|
-
* $('.tab').on('show', function(ev) {
|
52
|
-
* ev.pause();
|
53
|
-
* // Resume the event after 1 second
|
54
|
-
* setTimeout(function() {
|
55
|
-
* ev.resume();
|
56
|
-
* }, 1000);
|
57
|
-
* });
|
58
|
-
*/
|
59
|
-
$.Event.prototype.resume = function(){
|
60
|
-
// temporarily remove all event handlers of this type
|
61
|
-
var handleObj = this.handleObj,
|
62
|
-
currentTarget = this.currentTarget;
|
63
|
-
// temporarily overwrite special handle
|
64
|
-
var origType = jQuery.event.special[ handleObj.origType ],
|
65
|
-
origHandle = origType && origType.handle;
|
66
|
-
|
67
|
-
if(!origType){
|
68
|
-
jQuery.event.special[ handleObj.origType ] = {};
|
69
|
-
}
|
70
|
-
jQuery.event.special[ handleObj.origType ].handle = function(ev){
|
71
|
-
// remove this once we have passed the handleObj
|
72
|
-
if(ev.handleObj === handleObj && ev.currentTarget === currentTarget){
|
73
|
-
if(!origType){
|
74
|
-
delete jQuery.event.special[ handleObj.origType ];
|
75
|
-
} else {
|
76
|
-
jQuery.event.special[ handleObj.origType ].handle = origHandle;
|
77
|
-
}
|
78
|
-
}
|
79
|
-
}
|
80
|
-
delete this.pausedState;
|
81
|
-
// reset stuff
|
82
|
-
this.isPaused = this.isImmediatePropagationStopped = returnFalse;
|
83
|
-
|
84
|
-
if(!this.isPropagationStopped()){
|
85
|
-
// fire the event again, no events will get fired until
|
86
|
-
// same currentTarget / handler
|
87
|
-
$.event.trigger(this, [], this.target);
|
88
|
-
}
|
89
|
-
|
90
|
-
};
|
91
|
-
|
92
|
-
})(jQuery)
|
@@ -1,47 +0,0 @@
|
|
1
|
-
// Dependencies:
|
2
|
-
//
|
3
|
-
// - jquery.event.resize.js
|
4
|
-
// - jquery/event/reverse/reverse.js
|
5
|
-
|
6
|
-
(function( $ ) {
|
7
|
-
var
|
8
|
-
// bind on the window window resizes to happen
|
9
|
-
win = $(window),
|
10
|
-
windowWidth = 0,
|
11
|
-
windowHeight = 0,
|
12
|
-
timer;
|
13
|
-
|
14
|
-
$(function() {
|
15
|
-
windowWidth = win.width();
|
16
|
-
windowHeight = win.height();
|
17
|
-
});
|
18
|
-
|
19
|
-
$.event.reverse('resize', {
|
20
|
-
handler : function(ev, data) {
|
21
|
-
var isWindow = this === window;
|
22
|
-
|
23
|
-
// if we are the window and a real resize has happened
|
24
|
-
// then we check if the dimensions actually changed
|
25
|
-
// if they did, we will wait a brief timeout and
|
26
|
-
// trigger resize on the window
|
27
|
-
// this is for IE, to prevent window resize 'infinate' loop issues
|
28
|
-
if ( isWindow && ev.originalEvent ) {
|
29
|
-
var width = win.width(),
|
30
|
-
height = win.height();
|
31
|
-
|
32
|
-
|
33
|
-
if ((width != windowWidth || height != windowHeight)) {
|
34
|
-
//update the new dimensions
|
35
|
-
windowWidth = width;
|
36
|
-
windowHeight = height;
|
37
|
-
clearTimeout(timer)
|
38
|
-
timer = setTimeout(function() {
|
39
|
-
win.trigger("resize");
|
40
|
-
}, 1);
|
41
|
-
|
42
|
-
}
|
43
|
-
return true;
|
44
|
-
}
|
45
|
-
}
|
46
|
-
});
|
47
|
-
})(jQuery)
|
@@ -1,133 +0,0 @@
|
|
1
|
-
// Dependencies:
|
2
|
-
//
|
3
|
-
// - jquery.event.swipe.js
|
4
|
-
// - jquery.event.livehack.js
|
5
|
-
|
6
|
-
(function($){
|
7
|
-
var isPhantom = /Phantom/.test(navigator.userAgent),
|
8
|
-
supportTouch = !isPhantom && "ontouchend" in document,
|
9
|
-
scrollEvent = "touchmove scroll",
|
10
|
-
// Use touch events or map it to mouse events
|
11
|
-
touchStartEvent = supportTouch ? "touchstart" : "mousedown",
|
12
|
-
touchStopEvent = supportTouch ? "touchend" : "mouseup",
|
13
|
-
touchMoveEvent = supportTouch ? "touchmove" : "mousemove",
|
14
|
-
data = function(event){
|
15
|
-
var d = event.originalEvent.touches ?
|
16
|
-
event.originalEvent.touches[ 0 ] :
|
17
|
-
event;
|
18
|
-
return {
|
19
|
-
time: (new Date).getTime(),
|
20
|
-
coords: [ d.pageX, d.pageY ],
|
21
|
-
origin: $( event.target )
|
22
|
-
};
|
23
|
-
};
|
24
|
-
|
25
|
-
/**
|
26
|
-
* @add jQuery.event.swipe
|
27
|
-
*/
|
28
|
-
var swipe = $.event.swipe = {
|
29
|
-
/**
|
30
|
-
* @attribute delay
|
31
|
-
* Delay is the upper limit of time the swipe motion can take in milliseconds. This defaults to 500.
|
32
|
-
*
|
33
|
-
* A user must perform the swipe motion in this much time.
|
34
|
-
*/
|
35
|
-
delay : 500,
|
36
|
-
/**
|
37
|
-
* @attribute max
|
38
|
-
* The maximum distance the pointer must travel in pixels. The default is 75 pixels.
|
39
|
-
*/
|
40
|
-
max : 75,
|
41
|
-
/**
|
42
|
-
* @attribute min
|
43
|
-
* The minimum distance the pointer must travel in pixels. The default is 30 pixels.
|
44
|
-
*/
|
45
|
-
min : 30
|
46
|
-
};
|
47
|
-
|
48
|
-
$.event.setupHelper( [
|
49
|
-
|
50
|
-
/**
|
51
|
-
* @hide
|
52
|
-
* @attribute swipe
|
53
|
-
*/
|
54
|
-
"swipe",
|
55
|
-
/**
|
56
|
-
* @hide
|
57
|
-
* @attribute swipeleft
|
58
|
-
*/
|
59
|
-
'swipeleft',
|
60
|
-
/**
|
61
|
-
* @hide
|
62
|
-
* @attribute swiperight
|
63
|
-
*/
|
64
|
-
'swiperight',
|
65
|
-
/**
|
66
|
-
* @hide
|
67
|
-
* @attribute swipeup
|
68
|
-
*/
|
69
|
-
'swipeup',
|
70
|
-
/**
|
71
|
-
* @hide
|
72
|
-
* @attribute swipedown
|
73
|
-
*/
|
74
|
-
'swipedown'], touchStartEvent, function(ev){
|
75
|
-
var
|
76
|
-
// update with data when the event was started
|
77
|
-
start = data(ev),
|
78
|
-
stop,
|
79
|
-
delegate = ev.delegateTarget || ev.currentTarget,
|
80
|
-
selector = ev.handleObj.selector,
|
81
|
-
entered = this;
|
82
|
-
|
83
|
-
function moveHandler(event){
|
84
|
-
if ( !start ) {
|
85
|
-
return;
|
86
|
-
}
|
87
|
-
// update stop with the data from the current event
|
88
|
-
stop = data(event);
|
89
|
-
|
90
|
-
// prevent scrolling
|
91
|
-
if ( Math.abs( start.coords[0] - stop.coords[0] ) > 10 ) {
|
92
|
-
event.preventDefault();
|
93
|
-
}
|
94
|
-
};
|
95
|
-
|
96
|
-
// Attach to the touch move events
|
97
|
-
$(document.documentElement).bind(touchMoveEvent, moveHandler)
|
98
|
-
.one(touchStopEvent, function(event){
|
99
|
-
$(this).unbind( touchMoveEvent, moveHandler);
|
100
|
-
// if start and stop contain data figure out if we have a swipe event
|
101
|
-
if ( start && stop ) {
|
102
|
-
// calculate the distance between start and stop data
|
103
|
-
var deltaX = Math.abs(start.coords[0] - stop.coords[0]),
|
104
|
-
deltaY = Math.abs(start.coords[1] - stop.coords[1]),
|
105
|
-
distance = Math.sqrt(deltaX*deltaX+deltaY*deltaY);
|
106
|
-
|
107
|
-
// check if the delay and distance are matched
|
108
|
-
if ( stop.time - start.time < swipe.delay && distance >= swipe.min ) {
|
109
|
-
var events = ['swipe'];
|
110
|
-
// check if we moved horizontally
|
111
|
-
if( deltaX >= swipe.min && deltaY < swipe.min) {
|
112
|
-
// based on the x coordinate check if we moved left or right
|
113
|
-
events.push( start.coords[0] > stop.coords[0] ? "swipeleft" : "swiperight" );
|
114
|
-
} else
|
115
|
-
// check if we moved vertically
|
116
|
-
if(deltaY >= swipe.min && deltaX < swipe.min){
|
117
|
-
// based on the y coordinate check if we moved up or down
|
118
|
-
events.push( start.coords[1] < stop.coords[1] ? "swipedown" : "swipeup" );
|
119
|
-
}
|
120
|
-
|
121
|
-
// trigger swipe events on this guy
|
122
|
-
$.each($.event.find(delegate, events, selector), function(){
|
123
|
-
this.call(entered, ev, {start : start, end: stop})
|
124
|
-
})
|
125
|
-
|
126
|
-
}
|
127
|
-
}
|
128
|
-
// reset start and stop
|
129
|
-
start = stop = undefined;
|
130
|
-
})
|
131
|
-
});
|
132
|
-
|
133
|
-
})(jQuery)
|
@@ -1,249 +0,0 @@
|
|
1
|
-
// Dependencies:
|
2
|
-
//
|
3
|
-
// - jquery.fills.js
|
4
|
-
// - jquery.event.resize.js
|
5
|
-
// - jquery.dimensions.js
|
6
|
-
// - jquery/event/reverse/reverse.js
|
7
|
-
// - jquery.styles.js
|
8
|
-
|
9
|
-
(function( $ ) {
|
10
|
-
//evil things we should ignore
|
11
|
-
var matches = /script|td/,
|
12
|
-
|
13
|
-
// if we are trying to fill the page
|
14
|
-
isThePage = function( el ) {
|
15
|
-
return el === document || el === document.documentElement || el === window || el === document.body
|
16
|
-
},
|
17
|
-
//if something lets margins bleed through
|
18
|
-
bleeder = function( el ) {
|
19
|
-
if ( el[0] == window ) {
|
20
|
-
return false;
|
21
|
-
}
|
22
|
-
var styles = el.styles('borderBottomWidth', 'paddingBottom')
|
23
|
-
return !parseInt(styles.borderBottomWidth) && !parseInt(styles.paddingBottom)
|
24
|
-
},
|
25
|
-
//gets the bottom of this element
|
26
|
-
bottom = function( el, offset ) {
|
27
|
-
//where offsetTop starts
|
28
|
-
return el.outerHeight() + offset(el);
|
29
|
-
}
|
30
|
-
pageOffset = function( el ) {
|
31
|
-
return el.offset().top
|
32
|
-
},
|
33
|
-
offsetTop = function( el ) {
|
34
|
-
return el[0].offsetTop;
|
35
|
-
},
|
36
|
-
inFloat = function( el, parent ) {
|
37
|
-
while ( el && el != parent ) {
|
38
|
-
var flt = $(el).css('float')
|
39
|
-
if ( flt == 'left' || flt == 'right' ) {
|
40
|
-
return flt;
|
41
|
-
}
|
42
|
-
el = el.parentNode
|
43
|
-
}
|
44
|
-
},
|
45
|
-
/**
|
46
|
-
* @function jQuery.fn.fills
|
47
|
-
* @parent jQuery.fills
|
48
|
-
* @test jquery/dom/fills/funcunit.html
|
49
|
-
* @plugin jquery/dom/fills
|
50
|
-
*
|
51
|
-
* Fills a parent element's height with the current element.
|
52
|
-
* This is extremely useful for complex layout, especially when you want to account for line-wrapping.
|
53
|
-
*
|
54
|
-
* ## Basic Example
|
55
|
-
*
|
56
|
-
* If you have the following html:
|
57
|
-
*
|
58
|
-
* <div id='box'>
|
59
|
-
* <p>I am a long heading.</p>
|
60
|
-
* <div id='child'>I'm a child.</div>
|
61
|
-
* </div>
|
62
|
-
*
|
63
|
-
* The follow makes `#child` fill up `#box`:
|
64
|
-
*
|
65
|
-
* $('#child').can_ui_layout_fill("#box")
|
66
|
-
*
|
67
|
-
* ## Limitations
|
68
|
-
*
|
69
|
-
* Fill currently does not well with:
|
70
|
-
*
|
71
|
-
* - Bleeding margins - Where margins leak through parent elements
|
72
|
-
* because the parent elements do not have a padding or border.
|
73
|
-
*
|
74
|
-
* - Tables - You shouldn't be using tables to do layout anyway.
|
75
|
-
*
|
76
|
-
* - Floated Elements - the child element has `float: left` or `float: right`
|
77
|
-
*
|
78
|
-
*
|
79
|
-
* @param {HTMLElement|selector|Object} [parent] the parent element
|
80
|
-
* to fill, defaults to the element's parent.
|
81
|
-
*
|
82
|
-
* The following fills the parent to `#child`:
|
83
|
-
*
|
84
|
-
* $('#child').fills()
|
85
|
-
*
|
86
|
-
* A selector can also be pased. This selector is passed to jQuery's
|
87
|
-
* closet method. The following matches the first `#parent` element that
|
88
|
-
* is a parentNode of `#child`:
|
89
|
-
*
|
90
|
-
* $('#child').fills("#parent")
|
91
|
-
*
|
92
|
-
* An element or window can also be passed. The following will make
|
93
|
-
* `#child` big enough so the entire window is filled:
|
94
|
-
*
|
95
|
-
* $('#child').fills(window)
|
96
|
-
*
|
97
|
-
* If you pass an object, the following options are available:
|
98
|
-
*
|
99
|
-
* - __parent__ - The parent element selector or jQuery object
|
100
|
-
* - __className__ - A class name to add to the element that fills
|
101
|
-
* - __all__ - Reset the parents height when resizing
|
102
|
-
*
|
103
|
-
* @return {jQuery} the original jQuery collection for chaining.
|
104
|
-
*/
|
105
|
-
filler = $.fn.fills = function( parent ) {
|
106
|
-
var options = parent;
|
107
|
-
options || (options = {});
|
108
|
-
if(typeof options == 'string'){
|
109
|
-
options = this.closest(options)
|
110
|
-
}
|
111
|
-
if ( options.jquery || options.nodeName ) {
|
112
|
-
options = {parent: options };
|
113
|
-
}
|
114
|
-
// Set the parent
|
115
|
-
options.parent || (options.parent = $(this).parent());
|
116
|
-
options.parent = $(options.parent)
|
117
|
-
|
118
|
-
// setup stuff on every element
|
119
|
-
if(options.className) {
|
120
|
-
this.addClass(options.className)
|
121
|
-
}
|
122
|
-
|
123
|
-
var thePage = isThePage(options.parent[0]);
|
124
|
-
|
125
|
-
if ( thePage ) {
|
126
|
-
options.parent = $(window)
|
127
|
-
}
|
128
|
-
|
129
|
-
this.each(function(){
|
130
|
-
var evData = {
|
131
|
-
filler: $(this),
|
132
|
-
inFloat: inFloat(this, thePage ? document.body : options.parent[0]),
|
133
|
-
options: options
|
134
|
-
},
|
135
|
-
cb = function() {
|
136
|
-
filler.parentResize.apply(this, arguments)
|
137
|
-
}
|
138
|
-
// Attach to the `resize` event
|
139
|
-
$(options.parent).bind('resize', evData, cb);
|
140
|
-
|
141
|
-
$(this).bind('destroyed', evData, function( ev ) {
|
142
|
-
if(options.className) {
|
143
|
-
$(ev.target).removeClass(options.className)
|
144
|
-
}
|
145
|
-
$(options.parent).unbind('resize', cb)
|
146
|
-
});
|
147
|
-
|
148
|
-
});
|
149
|
-
|
150
|
-
// resize to get things going
|
151
|
-
var func = function() {
|
152
|
-
options.parent.resize();
|
153
|
-
}
|
154
|
-
|
155
|
-
if ( $.isReady ) {
|
156
|
-
func();
|
157
|
-
} else {
|
158
|
-
$(func)
|
159
|
-
}
|
160
|
-
return this;
|
161
|
-
};
|
162
|
-
|
163
|
-
|
164
|
-
$.extend(filler, {
|
165
|
-
parentResize : function( ev ) {
|
166
|
-
if (ev.data.filler.is(':hidden')) {
|
167
|
-
return;
|
168
|
-
}
|
169
|
-
|
170
|
-
var parent = $(this),
|
171
|
-
isWindow = this == window,
|
172
|
-
container = (isWindow ? $(document.body) : parent),
|
173
|
-
|
174
|
-
//if the parent bleeds margins, we don't care what the last element's margin is
|
175
|
-
isBleeder = bleeder(parent),
|
176
|
-
children = container.children().filter(function() {
|
177
|
-
if ( matches.test(this.nodeName.toLowerCase()) ) {
|
178
|
-
return false;
|
179
|
-
}
|
180
|
-
|
181
|
-
var get = $.styles(this, ['position', 'display']);
|
182
|
-
return get.position !== "absolute" && get.position !== "fixed"
|
183
|
-
&& get.display !== "none" && !jQuery.expr.filters.hidden(this)
|
184
|
-
}),
|
185
|
-
last = children.eq(-1),
|
186
|
-
first,
|
187
|
-
parentHeight = parent.height() - (isWindow ? parseInt(container.css('marginBottom'), 10) || 0 : 0),
|
188
|
-
currentSize;
|
189
|
-
var div = '<div style="height: 0px; line-height:0px;overflow:hidden;' + (ev.data.inFloat ? 'clear: both' : '') + ';"/>'
|
190
|
-
|
191
|
-
if ( isBleeder ) {
|
192
|
-
//temporarily add a small div to use to figure out the 'bleed-through' margin
|
193
|
-
//of the last element
|
194
|
-
last = $(div).appendTo(container);
|
195
|
-
|
196
|
-
}
|
197
|
-
|
198
|
-
//for performance, we want to figure out the currently used height of the parent element
|
199
|
-
// as quick as possible
|
200
|
-
// we can use either offsetTop or offset depending ...
|
201
|
-
if ( last && last.length > 0 ) {
|
202
|
-
if ( last.offsetParent()[0] === container[0] ) {
|
203
|
-
|
204
|
-
currentSize = last[0].offsetTop + last.outerHeight();
|
205
|
-
} else if (last.offsetParent()[0] === container.offsetParent()[0]) {
|
206
|
-
// add pos abs for IE7 but
|
207
|
-
// might need to adjust for the addition of first's hheight
|
208
|
-
var curLast =last[0].offsetTop;
|
209
|
-
first = $(div).prependTo(container);
|
210
|
-
|
211
|
-
currentSize = ( curLast + last.outerHeight() ) - first[0].offsetTop;
|
212
|
-
|
213
|
-
first.remove();
|
214
|
-
} else {
|
215
|
-
// add first so we know where to start from .. do not bleed in this case
|
216
|
-
first = $(div).prependTo(container);
|
217
|
-
|
218
|
-
currentSize = ( last.offset().top + last.outerHeight() ) - first.offset().top;
|
219
|
-
first.remove();
|
220
|
-
}
|
221
|
-
}
|
222
|
-
|
223
|
-
// what the difference between the parent height and what we are going to take up is
|
224
|
-
var delta = parentHeight - currentSize,
|
225
|
-
// the current height of the object
|
226
|
-
fillerHeight = ev.data.filler.height();
|
227
|
-
|
228
|
-
//adjust the height
|
229
|
-
if ( ev.data.options.all ) {
|
230
|
-
// we don't care about anything else, we are likely absolutely positioned
|
231
|
-
// we need to fill the parent width
|
232
|
-
// temporarily collapse, then expand
|
233
|
-
ev.data.filler.height(0).width(0);
|
234
|
-
var parentWidth = parent.width(),
|
235
|
-
parentHeight = parent.height();
|
236
|
-
|
237
|
-
ev.data.filler.outerHeight(parentHeight);
|
238
|
-
ev.data.filler.outerWidth(parentWidth);
|
239
|
-
} else {
|
240
|
-
ev.data.filler.height(fillerHeight + delta)
|
241
|
-
}
|
242
|
-
|
243
|
-
//remove the temporary element
|
244
|
-
if ( isBleeder ) {
|
245
|
-
last.remove();
|
246
|
-
}
|
247
|
-
}
|
248
|
-
});
|
249
|
-
})(jQuery)
|