mix-rails-core 0.23.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/app/assets/images/blank.gif +0 -0
- data/app/assets/images/jqzoom/advertise.jpg +0 -0
- data/app/assets/images/jqzoom/zoomloader.gif +0 -0
- data/app/assets/images/loadinfo.net.gif +0 -0
- data/app/assets/javascripts/angular-google-maps.js +531 -0
- data/app/assets/javascripts/angular-ui.min.js +7 -0
- data/app/assets/javascripts/angular.min.js +161 -0
- data/app/assets/javascripts/gmaps.js +1909 -0
- data/app/assets/javascripts/jquery-gmaps-latlon-picker.js +231 -0
- data/app/assets/javascripts/jquery.jqzoom.js +1 -0
- data/app/assets/javascripts/jquery.krioImageLoader.js +47 -0
- data/app/assets/javascripts/jquery.lazyload.js +227 -0
- data/app/assets/javascripts/jquery.maskedinput.js +290 -0
- data/app/assets/javascripts/jquery.meio.mask.min.js +1 -0
- data/app/assets/javascripts/jquery.ui.addresspicker.js +194 -0
- data/app/assets/javascripts/jquery/jquery.jqzoom-core.js +733 -0
- data/app/assets/javascripts/multizoom.js +388 -0
- data/app/assets/stylesheets/angular-ui.min.css +1 -0
- data/app/assets/stylesheets/jquery-gmaps-latlon-picker.css +2 -0
- data/app/assets/stylesheets/jquery.jqzoom.css +3 -0
- data/app/assets/stylesheets/jquery/jquery.jqzoom.css.erb +120 -0
- data/app/assets/stylesheets/multizoom.css +48 -0
- data/app/helpers/core_helper.rb +4 -0
- data/app/inputs/cell_input.rb +5 -0
- data/app/inputs/cep_input.rb +5 -0
- data/app/inputs/phone_input.rb +5 -0
- data/app/inputs/state_input.rb +5 -0
- data/app/models/attachment.rb +4 -1
- data/app/models/category.rb +4 -1
- data/app/models/ckeditor/asset.rb +7 -0
- data/app/models/ckeditor/attachment_file.rb +7 -0
- data/app/models/ckeditor/picture.rb +7 -0
- data/app/uploaders/ckeditor_attachment_file_uploader.rb +36 -0
- data/app/uploaders/ckeditor_picture_uploader.rb +47 -0
- data/app/views/admix/categories/_form_config.haml +3 -0
- data/config/initializers/ckeditor.rb +21 -0
- data/config/initializers/defaults_rails.rb +10 -1
- data/config/locales/core.pt-BR.yml +25 -2
- data/config/routes.rb +2 -0
- data/db/migrate/20130226152256_create_ckeditor_assets.rb +26 -0
- data/lib/mix-rails-core.rb +3 -0
- data/lib/mix-rails-core/version.rb +2 -2
- metadata +73 -120
- data/app/assets/javascripts/jquery/jquery.maskedinput-1.3.min.js +0 -7
- data/app/models/admix/categories_datagrid.rb +0 -14
- data/app/views/admix/categories/_form_fields.haml +0 -1
@@ -0,0 +1,231 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* A JQUERY GOOGLE MAPS LATITUDE AND LONGITUDE LOCATION PICKER
|
4
|
+
* version 1.1
|
5
|
+
*
|
6
|
+
* Supports multiple maps. Works on touchscreen. Easy to customize markup and CSS.
|
7
|
+
*
|
8
|
+
* To see a live demo, go to:
|
9
|
+
* http://wimagguc.hu/projects/jquery-latitude-longitude-picker-gmaps/
|
10
|
+
*
|
11
|
+
* by Richard Dancsi
|
12
|
+
* http://wimagguc.hu/
|
13
|
+
*
|
14
|
+
*/
|
15
|
+
|
16
|
+
// for ie9 doesn't support debug console >>>
|
17
|
+
if (!window.console) window.console = {};
|
18
|
+
if (!window.console.log) window.console.log = function () { };
|
19
|
+
// ^^^
|
20
|
+
|
21
|
+
var GMapsLatLonPicker = (function() {
|
22
|
+
|
23
|
+
var _self = this;
|
24
|
+
|
25
|
+
///////////////////////////////////////////////////////////////////////////////////////////////
|
26
|
+
// PARAMETERS (MODIFY THIS PART) //////////////////////////////////////////////////////////////
|
27
|
+
_self.params = {
|
28
|
+
defLat : 0,
|
29
|
+
defLng : 0,
|
30
|
+
defZoom : 1,
|
31
|
+
queryLocationNameWhenLatLngChanges: true,
|
32
|
+
queryElevationWhenLatLngChanges: true,
|
33
|
+
mapOptions : {
|
34
|
+
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
35
|
+
mapTypeControl: false,
|
36
|
+
disableDoubleClickZoom: true,
|
37
|
+
zoomControlOptions: true,
|
38
|
+
streetViewControl: false
|
39
|
+
},
|
40
|
+
strings : {
|
41
|
+
markerText : "Drag this Marker",
|
42
|
+
error_empty_field : "Couldn't find coordinates for this place",
|
43
|
+
error_no_results : "Couldn't find coordinates for this place"
|
44
|
+
}
|
45
|
+
};
|
46
|
+
|
47
|
+
|
48
|
+
///////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
+
// VARIABLES USED BY THE FUNCTION (DON'T MODIFY THIS PART) ////////////////////////////////////
|
50
|
+
_self.vars = {
|
51
|
+
ID : null,
|
52
|
+
LATLNG : null,
|
53
|
+
map : null,
|
54
|
+
marker : null,
|
55
|
+
geocoder : null
|
56
|
+
};
|
57
|
+
|
58
|
+
///////////////////////////////////////////////////////////////////////////////////////////////
|
59
|
+
// PRIVATE FUNCTIONS FOR MANIPULATING DATA ////////////////////////////////////////////////////
|
60
|
+
var setPosition = function(position) {
|
61
|
+
_self.vars.marker.setPosition(position);
|
62
|
+
_self.vars.map.panTo(position);
|
63
|
+
|
64
|
+
$(_self.vars.cssID + ".gllpZoom").val( _self.vars.map.getZoom() );
|
65
|
+
$(_self.vars.cssID + ".gllpLongitude").val( position.lng() );
|
66
|
+
$(_self.vars.cssID + ".gllpLatitude").val( position.lat() );
|
67
|
+
|
68
|
+
$(_self.vars.cssID).trigger("location_changed", $(_self.vars.cssID));
|
69
|
+
|
70
|
+
if (_self.params.queryLocationNameWhenLatLngChanges) {
|
71
|
+
getLocationName(position);
|
72
|
+
}
|
73
|
+
if (_self.params.queryElevationWhenLatLngChanges) {
|
74
|
+
getElevation(position);
|
75
|
+
}
|
76
|
+
};
|
77
|
+
|
78
|
+
// for reverse geocoding
|
79
|
+
var getLocationName = function(position) {
|
80
|
+
var latlng = new google.maps.LatLng(position.lat(), position.lng());
|
81
|
+
_self.vars.geocoder.geocode({'latLng': latlng}, function(results, status) {
|
82
|
+
if (status == google.maps.GeocoderStatus.OK && results[1]) {
|
83
|
+
$(_self.vars.cssID + ".gllpLocationName").val(results[1].formatted_address);
|
84
|
+
} else {
|
85
|
+
$(_self.vars.cssID + ".gllpLocationName").val("");
|
86
|
+
}
|
87
|
+
$(_self.vars.cssID).trigger("location_name_changed", $(_self.vars.cssID));
|
88
|
+
});
|
89
|
+
};
|
90
|
+
|
91
|
+
// for getting the elevation value for a position
|
92
|
+
var getElevation = function(position) {
|
93
|
+
var latlng = new google.maps.LatLng(position.lat(), position.lng());
|
94
|
+
|
95
|
+
var locations = [latlng];
|
96
|
+
|
97
|
+
var positionalRequest = { 'locations': locations };
|
98
|
+
|
99
|
+
_self.vars.elevator.getElevationForLocations(positionalRequest, function(results, status) {
|
100
|
+
if (status == google.maps.ElevationStatus.OK) {
|
101
|
+
if (results[0]) {
|
102
|
+
$(_self.vars.cssID + ".gllpElevation").val( results[0].elevation.toFixed(3));
|
103
|
+
} else {
|
104
|
+
$(_self.vars.cssID + ".gllpElevation").val("");
|
105
|
+
}
|
106
|
+
} else {
|
107
|
+
$(_self.vars.cssID + ".gllpElevation").val("");
|
108
|
+
}
|
109
|
+
$(_self.vars.cssID).trigger("elevation_changed", $(_self.vars.cssID));
|
110
|
+
});
|
111
|
+
};
|
112
|
+
|
113
|
+
// search function
|
114
|
+
var performSearch = function(string, silent) {
|
115
|
+
if (string == "") {
|
116
|
+
if (!silent) {
|
117
|
+
displayError( _self.params.strings.error_empty_field );
|
118
|
+
}
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
_self.vars.geocoder.geocode(
|
122
|
+
{"address": string},
|
123
|
+
function(results, status) {
|
124
|
+
if (status == google.maps.GeocoderStatus.OK) {
|
125
|
+
$(_self.vars.cssID + ".gllpZoom").val(11);
|
126
|
+
_self.vars.map.setZoom( parseInt($(_self.vars.cssID + ".gllpZoom").val()) );
|
127
|
+
setPosition( results[0].geometry.location );
|
128
|
+
} else {
|
129
|
+
if (!silent) {
|
130
|
+
displayError( _self.params.strings.error_no_results );
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
);
|
135
|
+
};
|
136
|
+
|
137
|
+
// error function
|
138
|
+
var displayError = function(message) {
|
139
|
+
alert(message);
|
140
|
+
};
|
141
|
+
|
142
|
+
///////////////////////////////////////////////////////////////////////////////////////////////
|
143
|
+
// PUBLIC FUNCTIONS //////////////////////////////////////////////////////////////////////////
|
144
|
+
var publicfunc = {
|
145
|
+
|
146
|
+
// INITIALIZE MAP ON DIV //////////////////////////////////////////////////////////////////
|
147
|
+
init : function(object) {
|
148
|
+
|
149
|
+
if ( !$(object).attr("id") ) {
|
150
|
+
if ( $(object).attr("name") ) {
|
151
|
+
$(object).attr("id", $(object).attr("name") );
|
152
|
+
} else {
|
153
|
+
$(object).attr("id", "_MAP_" + Math.ceil(Math.random() * 10000) );
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
_self.vars.ID = $(object).attr("id");
|
158
|
+
_self.vars.cssID = "#" + _self.vars.ID + " ";
|
159
|
+
|
160
|
+
_self.params.defLat = $(_self.vars.cssID + ".gllpLatitude").val() ? $(_self.vars.cssID + ".gllpLatitude").val() : _self.params.defLat;
|
161
|
+
_self.params.defLng = $(_self.vars.cssID + ".gllpLongitude").val() ? $(_self.vars.cssID + ".gllpLongitude").val() : _self.params.defLng;
|
162
|
+
_self.params.defZoom = $(_self.vars.cssID + ".gllpZoom").val() ? parseInt($(_self.vars.cssID + ".gllpZoom").val()) : _self.params.defZoom;
|
163
|
+
|
164
|
+
_self.vars.LATLNG = new google.maps.LatLng(_self.params.defLat, _self.params.defLng);
|
165
|
+
|
166
|
+
_self.vars.MAPOPTIONS = _self.params.mapOptions;
|
167
|
+
_self.vars.MAPOPTIONS.zoom = _self.params.defZoom;
|
168
|
+
_self.vars.MAPOPTIONS.center = _self.vars.LATLNG;
|
169
|
+
|
170
|
+
_self.vars.map = new google.maps.Map($(_self.vars.cssID + ".gllpMap").get(0), _self.vars.MAPOPTIONS);
|
171
|
+
_self.vars.geocoder = new google.maps.Geocoder();
|
172
|
+
_self.vars.elevator = new google.maps.ElevationService();
|
173
|
+
|
174
|
+
_self.vars.marker = new google.maps.Marker({
|
175
|
+
position: _self.vars.LATLNG,
|
176
|
+
map: _self.vars.map,
|
177
|
+
title: _self.params.strings.markerText,
|
178
|
+
draggable: true
|
179
|
+
});
|
180
|
+
|
181
|
+
// Set position on doubleclick
|
182
|
+
google.maps.event.addListener(_self.vars.map, 'dblclick', function(event) {
|
183
|
+
setPosition(event.latLng);
|
184
|
+
});
|
185
|
+
|
186
|
+
// Set position on marker move
|
187
|
+
google.maps.event.addListener(_self.vars.marker, 'dragend', function(event) {
|
188
|
+
setPosition(_self.vars.marker.position);
|
189
|
+
});
|
190
|
+
|
191
|
+
// Set zoom feld's value when user changes zoom on the map
|
192
|
+
google.maps.event.addListener(_self.vars.map, 'zoom_changed', function(event) {
|
193
|
+
$(_self.vars.cssID + ".gllpZoom").val( _self.vars.map.getZoom() );
|
194
|
+
$(_self.vars.cssID).trigger("location_changed", $(_self.vars.cssID));
|
195
|
+
});
|
196
|
+
|
197
|
+
// Update location and zoom values based on input field's value
|
198
|
+
$(_self.vars.cssID + ".gllpUpdateButton").bind("click", function() {
|
199
|
+
var lat = $(_self.vars.cssID + ".gllpLatitude").val();
|
200
|
+
var lng = $(_self.vars.cssID + ".gllpLongitude").val();
|
201
|
+
var latlng = new google.maps.LatLng(lat, lng);
|
202
|
+
_self.vars.map.setZoom( parseInt( $(_self.vars.cssID + ".gllpZoom").val() ) );
|
203
|
+
setPosition(latlng);
|
204
|
+
});
|
205
|
+
|
206
|
+
// Search function by search button
|
207
|
+
$(_self.vars.cssID + ".gllpSearchButton").bind("click", function() {
|
208
|
+
performSearch( $(_self.vars.cssID + ".gllpSearchField").val(), false );
|
209
|
+
});
|
210
|
+
|
211
|
+
// Search function by gllp_perform_search listener
|
212
|
+
$(document).bind("gllp_perform_search", function(event, object) {
|
213
|
+
performSearch( $(object).attr('string'), true );
|
214
|
+
});
|
215
|
+
}
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
return publicfunc;
|
220
|
+
});
|
221
|
+
|
222
|
+
|
223
|
+
$(document).ready( function() {
|
224
|
+
$(".gllpLatlonPicker").each(function() {
|
225
|
+
(new GMapsLatLonPicker()).init( $(this) );
|
226
|
+
});
|
227
|
+
});
|
228
|
+
|
229
|
+
$(document).bind("location_changed", function(event, object) {
|
230
|
+
console.log("changed: " + $(object).attr('id') );
|
231
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require ./jquery/jquery.jqzoom-core
|
@@ -0,0 +1,47 @@
|
|
1
|
+
/*
|
2
|
+
* Krio Image Loader Jquery Plugin v1
|
3
|
+
* http://krio.me/jquery-image-loader-plugin
|
4
|
+
* http://github.com/jquery-image-loader-plugin
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function($) {
|
8
|
+
|
9
|
+
$.fn.krioImageLoader = function(options) {
|
10
|
+
var opts = $.extend({}, $.fn.krioImageLoader.defaults, options);
|
11
|
+
var imagesToLoad = $(this).find("img")
|
12
|
+
.css({opacity: 0, visibility: "hidden"})
|
13
|
+
.addClass("krioImageLoader");
|
14
|
+
var imagesToLoadCount = imagesToLoad.size();
|
15
|
+
|
16
|
+
var checkIfLoadedTimer = setInterval(function() {
|
17
|
+
if(!imagesToLoadCount) {
|
18
|
+
clearInterval(checkIfLoadedTimer);
|
19
|
+
return;
|
20
|
+
} else {
|
21
|
+
imagesToLoad.filter(".krioImageLoader").each(function() {
|
22
|
+
if(this.complete) {
|
23
|
+
fadeImageIn(this);
|
24
|
+
imagesToLoadCount--;
|
25
|
+
}
|
26
|
+
});
|
27
|
+
}
|
28
|
+
}, opts.loadedCheckEvery);
|
29
|
+
|
30
|
+
var fadeImageIn = function(imageToLoad) {
|
31
|
+
$(imageToLoad).css({visibility: "visible"})
|
32
|
+
.animate({opacity: 1},
|
33
|
+
opts.imageEnterDelay,
|
34
|
+
removeKrioImageClass(imageToLoad));
|
35
|
+
};
|
36
|
+
|
37
|
+
var removeKrioImageClass = function(imageToRemoveClass) {
|
38
|
+
$(imageToRemoveClass).removeClass("krioImageLoader");
|
39
|
+
};
|
40
|
+
};
|
41
|
+
|
42
|
+
$.fn.krioImageLoader.defaults = {
|
43
|
+
loadedCheckEvery: 350,
|
44
|
+
imageEnterDelay: 900
|
45
|
+
};
|
46
|
+
|
47
|
+
})(jQuery);
|
@@ -0,0 +1,227 @@
|
|
1
|
+
/*
|
2
|
+
* Lazy Load - jQuery plugin for lazy loading images
|
3
|
+
*
|
4
|
+
* Copyright (c) 2007-2013 Mika Tuupola
|
5
|
+
*
|
6
|
+
* Licensed under the MIT license:
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
*
|
9
|
+
* Project home:
|
10
|
+
* http://www.appelsiini.net/projects/lazyload
|
11
|
+
*
|
12
|
+
* Version: 1.8.4
|
13
|
+
*
|
14
|
+
*/
|
15
|
+
(function($, window, document, undefined) {
|
16
|
+
var $window = $(window);
|
17
|
+
|
18
|
+
$.fn.lazyload = function(options) {
|
19
|
+
var elements = this;
|
20
|
+
var $container;
|
21
|
+
var settings = {
|
22
|
+
threshold : 0,
|
23
|
+
failure_limit : 0,
|
24
|
+
event : "scroll",
|
25
|
+
effect : "show",
|
26
|
+
container : window,
|
27
|
+
data_attribute : "original",
|
28
|
+
skip_invisible : true,
|
29
|
+
appear : null,
|
30
|
+
load : null
|
31
|
+
};
|
32
|
+
|
33
|
+
function update() {
|
34
|
+
var counter = 0;
|
35
|
+
|
36
|
+
elements.each(function() {
|
37
|
+
var $this = $(this);
|
38
|
+
if (settings.skip_invisible && !$this.is(":visible")) {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
if ($.abovethetop(this, settings) ||
|
42
|
+
$.leftofbegin(this, settings)) {
|
43
|
+
/* Nothing. */
|
44
|
+
} else if (!$.belowthefold(this, settings) &&
|
45
|
+
!$.rightoffold(this, settings)) {
|
46
|
+
$this.trigger("appear");
|
47
|
+
/* if we found an image we'll load, reset the counter */
|
48
|
+
counter = 0;
|
49
|
+
} else {
|
50
|
+
if (++counter > settings.failure_limit) {
|
51
|
+
return false;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
});
|
55
|
+
|
56
|
+
}
|
57
|
+
|
58
|
+
if(options) {
|
59
|
+
/* Maintain BC for a couple of versions. */
|
60
|
+
if (undefined !== options.failurelimit) {
|
61
|
+
options.failure_limit = options.failurelimit;
|
62
|
+
delete options.failurelimit;
|
63
|
+
}
|
64
|
+
if (undefined !== options.effectspeed) {
|
65
|
+
options.effect_speed = options.effectspeed;
|
66
|
+
delete options.effectspeed;
|
67
|
+
}
|
68
|
+
|
69
|
+
$.extend(settings, options);
|
70
|
+
}
|
71
|
+
|
72
|
+
/* Cache container as jQuery as object. */
|
73
|
+
$container = (settings.container === undefined ||
|
74
|
+
settings.container === window) ? $window : $(settings.container);
|
75
|
+
|
76
|
+
/* Fire one scroll event per scroll. Not one scroll event per image. */
|
77
|
+
if (0 === settings.event.indexOf("scroll")) {
|
78
|
+
$container.bind(settings.event, function(event) {
|
79
|
+
return update();
|
80
|
+
});
|
81
|
+
}
|
82
|
+
|
83
|
+
this.each(function() {
|
84
|
+
var self = this;
|
85
|
+
var $self = $(self);
|
86
|
+
|
87
|
+
self.loaded = false;
|
88
|
+
|
89
|
+
/* When appear is triggered load original image. */
|
90
|
+
$self.one("appear", function() {
|
91
|
+
if (!this.loaded) {
|
92
|
+
if (settings.appear) {
|
93
|
+
var elements_left = elements.length;
|
94
|
+
settings.appear.call(self, elements_left, settings);
|
95
|
+
}
|
96
|
+
$("<img />")
|
97
|
+
.bind("load", function() {
|
98
|
+
$self
|
99
|
+
.hide()
|
100
|
+
.attr("src", $self.data(settings.data_attribute))
|
101
|
+
[settings.effect](settings.effect_speed);
|
102
|
+
self.loaded = true;
|
103
|
+
|
104
|
+
/* Remove image from array so it is not looped next time. */
|
105
|
+
var temp = $.grep(elements, function(element) {
|
106
|
+
return !element.loaded;
|
107
|
+
});
|
108
|
+
elements = $(temp);
|
109
|
+
|
110
|
+
if (settings.load) {
|
111
|
+
var elements_left = elements.length;
|
112
|
+
settings.load.call(self, elements_left, settings);
|
113
|
+
}
|
114
|
+
})
|
115
|
+
.attr("src", $self.data(settings.data_attribute));
|
116
|
+
}
|
117
|
+
});
|
118
|
+
|
119
|
+
/* When wanted event is triggered load original image */
|
120
|
+
/* by triggering appear. */
|
121
|
+
if (0 !== settings.event.indexOf("scroll")) {
|
122
|
+
$self.bind(settings.event, function(event) {
|
123
|
+
if (!self.loaded) {
|
124
|
+
$self.trigger("appear");
|
125
|
+
}
|
126
|
+
});
|
127
|
+
}
|
128
|
+
});
|
129
|
+
|
130
|
+
/* Check if something appears when window is resized. */
|
131
|
+
$window.bind("resize", function(event) {
|
132
|
+
update();
|
133
|
+
});
|
134
|
+
|
135
|
+
/* With IOS5 force loading images when navigating with back button. */
|
136
|
+
/* Non optimal workaround. */
|
137
|
+
if ((/iphone|ipod|ipad.*os 5/gi).test(navigator.appVersion)) {
|
138
|
+
$window.bind("pageshow", function(event) {
|
139
|
+
if (event.originalEvent.persisted) {
|
140
|
+
elements.each(function() {
|
141
|
+
$(this).trigger("appear");
|
142
|
+
});
|
143
|
+
}
|
144
|
+
});
|
145
|
+
}
|
146
|
+
|
147
|
+
/* Force initial check if images should appear. */
|
148
|
+
$(window).load(function() {
|
149
|
+
update();
|
150
|
+
});
|
151
|
+
|
152
|
+
return this;
|
153
|
+
};
|
154
|
+
|
155
|
+
/* Convenience methods in jQuery namespace. */
|
156
|
+
/* Use as $.belowthefold(element, {threshold : 100, container : window}) */
|
157
|
+
|
158
|
+
$.belowthefold = function(element, settings) {
|
159
|
+
var fold;
|
160
|
+
|
161
|
+
if (settings.container === undefined || settings.container === window) {
|
162
|
+
fold = $window.height() + $window.scrollTop();
|
163
|
+
} else {
|
164
|
+
fold = $(settings.container).offset().top + $(settings.container).height();
|
165
|
+
}
|
166
|
+
|
167
|
+
return fold <= $(element).offset().top - settings.threshold;
|
168
|
+
};
|
169
|
+
|
170
|
+
$.rightoffold = function(element, settings) {
|
171
|
+
var fold;
|
172
|
+
|
173
|
+
if (settings.container === undefined || settings.container === window) {
|
174
|
+
fold = $window.width() + $window.scrollLeft();
|
175
|
+
} else {
|
176
|
+
fold = $(settings.container).offset().left + $(settings.container).width();
|
177
|
+
}
|
178
|
+
|
179
|
+
return fold <= $(element).offset().left - settings.threshold;
|
180
|
+
};
|
181
|
+
|
182
|
+
$.abovethetop = function(element, settings) {
|
183
|
+
var fold;
|
184
|
+
|
185
|
+
if (settings.container === undefined || settings.container === window) {
|
186
|
+
fold = $window.scrollTop();
|
187
|
+
} else {
|
188
|
+
fold = $(settings.container).offset().top;
|
189
|
+
}
|
190
|
+
|
191
|
+
return fold >= $(element).offset().top + settings.threshold + $(element).height();
|
192
|
+
};
|
193
|
+
|
194
|
+
$.leftofbegin = function(element, settings) {
|
195
|
+
var fold;
|
196
|
+
|
197
|
+
if (settings.container === undefined || settings.container === window) {
|
198
|
+
fold = $window.scrollLeft();
|
199
|
+
} else {
|
200
|
+
fold = $(settings.container).offset().left;
|
201
|
+
}
|
202
|
+
|
203
|
+
return fold >= $(element).offset().left + settings.threshold + $(element).width();
|
204
|
+
};
|
205
|
+
|
206
|
+
$.inviewport = function(element, settings) {
|
207
|
+
return !$.rightoffold(element, settings) && !$.leftofbegin(element, settings) &&
|
208
|
+
!$.belowthefold(element, settings) && !$.abovethetop(element, settings);
|
209
|
+
};
|
210
|
+
|
211
|
+
/* Custom selectors for your convenience. */
|
212
|
+
/* Use as $("img:below-the-fold").something() or */
|
213
|
+
/* $("img").filter(":below-the-fold").something() which is faster */
|
214
|
+
|
215
|
+
$.extend($.expr[':'], {
|
216
|
+
"below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); },
|
217
|
+
"above-the-top" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
|
218
|
+
"right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); },
|
219
|
+
"left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); },
|
220
|
+
"in-viewport" : function(a) { return $.inviewport(a, {threshold : 0}); },
|
221
|
+
/* Maintain BC for couple of versions. */
|
222
|
+
"above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
|
223
|
+
"right-of-fold" : function(a) { return $.rightoffold(a, {threshold : 0}); },
|
224
|
+
"left-of-fold" : function(a) { return !$.rightoffold(a, {threshold : 0}); }
|
225
|
+
});
|
226
|
+
|
227
|
+
})(jQuery, window, document);
|