volt-semantic-ui 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/app/semanticui/assets/css/semantic.min.css +3 -3
- data/app/semanticui/assets/css/themes/basic/assets/fonts/icons.eot +0 -0
- data/app/semanticui/assets/css/themes/basic/assets/fonts/icons.svg +0 -0
- data/app/semanticui/assets/css/themes/basic/assets/fonts/icons.ttf +0 -0
- data/app/semanticui/assets/css/themes/basic/assets/fonts/icons.woff +0 -0
- data/app/semanticui/assets/css/themes/default/assets/fonts/icons.eot +0 -0
- data/app/semanticui/assets/css/themes/default/assets/fonts/icons.otf +0 -0
- data/app/semanticui/assets/css/themes/default/assets/fonts/icons.svg +526 -465
- data/app/semanticui/assets/css/themes/default/assets/fonts/icons.ttf +0 -0
- data/app/semanticui/assets/css/themes/default/assets/fonts/icons.woff +0 -0
- data/app/semanticui/assets/css/themes/default/assets/fonts/icons.woff2 +0 -0
- data/app/semanticui/assets/css/themes/default/assets/images/flags.png +0 -0
- data/app/semanticui/assets/js/components/accordion.css +256 -0
- data/app/semanticui/assets/js/components/accordion.js +578 -0
- data/app/semanticui/assets/js/components/accordion.min.css +10 -0
- data/app/semanticui/assets/js/components/accordion.min.js +11 -0
- data/app/semanticui/assets/js/components/ad.css +276 -0
- data/app/semanticui/assets/js/components/ad.min.css +10 -0
- data/app/semanticui/assets/js/components/api.js +871 -0
- data/app/semanticui/assets/js/components/api.min.js +11 -0
- data/app/semanticui/assets/js/components/breadcrumb.css +124 -0
- data/app/semanticui/assets/js/components/breadcrumb.min.css +10 -0
- data/app/semanticui/assets/js/components/button.css +2391 -0
- data/app/semanticui/assets/js/components/button.min.css +10 -0
- data/app/semanticui/assets/js/components/card.css +909 -0
- data/app/semanticui/assets/js/components/card.min.css +10 -0
- data/app/semanticui/assets/js/components/checkbox.css +513 -0
- data/app/semanticui/assets/js/components/checkbox.js +509 -0
- data/app/semanticui/assets/js/components/checkbox.min.css +10 -0
- data/app/semanticui/assets/js/components/checkbox.min.js +11 -0
- data/app/semanticui/assets/js/components/comment.css +259 -0
- data/app/semanticui/assets/js/components/comment.min.css +10 -0
- data/app/semanticui/assets/js/components/dimmer.css +186 -0
- data/app/semanticui/assets/js/components/dimmer.js +669 -0
- data/app/semanticui/assets/js/components/dimmer.min.css +10 -0
- data/app/semanticui/assets/js/components/dimmer.min.js +11 -0
- data/app/semanticui/assets/js/components/divider.css +241 -0
- data/app/semanticui/assets/js/components/divider.min.css +10 -0
- data/app/semanticui/assets/js/components/dropdown.css +1103 -0
- data/app/semanticui/assets/js/components/dropdown.js +1795 -0
- data/app/semanticui/assets/js/components/dropdown.min.css +10 -0
- data/app/semanticui/assets/js/components/dropdown.min.js +11 -0
- data/app/semanticui/assets/js/components/feed.css +276 -0
- data/app/semanticui/assets/js/components/feed.min.css +10 -0
- data/app/semanticui/assets/js/components/flag.css +1024 -0
- data/app/semanticui/assets/js/components/flag.min.css +10 -0
- data/app/semanticui/assets/js/components/form.css +891 -0
- data/app/semanticui/assets/js/components/form.js +1118 -0
- data/app/semanticui/assets/js/components/form.min.css +10 -0
- data/app/semanticui/assets/js/components/form.min.js +11 -0
- data/app/semanticui/assets/js/components/grid.css +1871 -0
- data/app/semanticui/assets/js/components/grid.min.css +10 -0
- data/app/semanticui/assets/js/components/header.css +596 -0
- data/app/semanticui/assets/js/components/header.min.css +10 -0
- data/app/semanticui/assets/js/components/icon.css +2467 -0
- data/app/semanticui/assets/js/components/icon.min.css +10 -0
- data/app/semanticui/assets/js/components/image.css +288 -0
- data/app/semanticui/assets/js/components/image.min.css +10 -0
- data/app/semanticui/assets/js/components/input.css +439 -0
- data/app/semanticui/assets/js/components/input.min.css +10 -0
- data/app/semanticui/assets/js/components/item.css +456 -0
- data/app/semanticui/assets/js/components/item.min.css +10 -0
- data/app/semanticui/assets/js/components/label.css +963 -0
- data/app/semanticui/assets/js/components/label.min.css +10 -0
- data/app/semanticui/assets/js/components/list.css +878 -0
- data/app/semanticui/assets/js/components/list.min.css +10 -0
- data/app/semanticui/assets/js/components/loader.css +284 -0
- data/app/semanticui/assets/js/components/loader.min.css +10 -0
- data/app/semanticui/assets/js/components/menu.css +1608 -0
- data/app/semanticui/assets/js/components/menu.min.css +10 -0
- data/app/semanticui/assets/js/components/message.css +421 -0
- data/app/semanticui/assets/js/components/message.min.css +10 -0
- data/app/semanticui/assets/js/components/modal.css +432 -0
- data/app/semanticui/assets/js/components/modal.js +860 -0
- data/app/semanticui/assets/js/components/modal.min.css +10 -0
- data/app/semanticui/assets/js/components/modal.min.js +11 -0
- data/app/semanticui/assets/js/components/nag.css +148 -0
- data/app/semanticui/assets/js/components/nag.js +477 -0
- data/app/semanticui/assets/js/components/nag.min.css +10 -0
- data/app/semanticui/assets/js/components/nag.min.js +11 -0
- data/app/semanticui/assets/js/components/popup.css +293 -0
- data/app/semanticui/assets/js/components/popup.js +1224 -0
- data/app/semanticui/assets/js/components/popup.min.css +10 -0
- data/app/semanticui/assets/js/components/popup.min.js +11 -0
- data/app/semanticui/assets/js/components/progress.css +461 -0
- data/app/semanticui/assets/js/components/progress.js +785 -0
- data/app/semanticui/assets/js/components/progress.min.css +10 -0
- data/app/semanticui/assets/js/components/progress.min.js +11 -0
- data/app/semanticui/assets/js/components/rail.css +124 -0
- data/app/semanticui/assets/js/components/rail.min.css +10 -0
- data/app/semanticui/assets/js/components/rating.css +251 -0
- data/app/semanticui/assets/js/components/rating.js +451 -0
- data/app/semanticui/assets/js/components/rating.min.css +10 -0
- data/app/semanticui/assets/js/components/rating.min.js +11 -0
- data/app/semanticui/assets/js/components/reset.css +429 -0
- data/app/semanticui/assets/js/components/reset.min.css +10 -0
- data/app/semanticui/assets/js/components/reveal.css +293 -0
- data/app/semanticui/assets/js/components/reveal.min.css +10 -0
- data/app/semanticui/assets/js/components/search.css +329 -0
- data/app/semanticui/assets/js/components/search.js +1096 -0
- data/app/semanticui/assets/js/components/search.min.css +10 -0
- data/app/semanticui/assets/js/components/search.min.js +11 -0
- data/app/semanticui/assets/js/components/segment.css +635 -0
- data/app/semanticui/assets/js/components/segment.min.css +10 -0
- data/app/semanticui/assets/js/components/shape.css +154 -0
- data/app/semanticui/assets/js/components/shape.js +830 -0
- data/app/semanticui/assets/js/components/shape.min.css +10 -0
- data/app/semanticui/assets/js/components/shape.min.js +11 -0
- data/app/semanticui/assets/js/components/sidebar.css +625 -0
- data/app/semanticui/assets/js/components/sidebar.js +1089 -0
- data/app/semanticui/assets/js/components/sidebar.min.css +10 -0
- data/app/semanticui/assets/js/components/sidebar.min.js +11 -0
- data/app/semanticui/assets/js/components/site.css +160 -0
- data/app/semanticui/assets/js/components/site.js +487 -0
- data/app/semanticui/assets/js/components/site.min.css +10 -0
- data/app/semanticui/assets/js/components/site.min.js +11 -0
- data/app/semanticui/assets/js/components/state.js +695 -0
- data/app/semanticui/assets/js/components/state.min.js +11 -0
- data/app/semanticui/assets/js/components/statistic.css +409 -0
- data/app/semanticui/assets/js/components/statistic.min.css +10 -0
- data/app/semanticui/assets/js/components/step.css +432 -0
- data/app/semanticui/assets/js/components/step.min.css +10 -0
- data/app/semanticui/assets/js/components/sticky.css +79 -0
- data/app/semanticui/assets/js/components/sticky.js +792 -0
- data/app/semanticui/assets/js/components/sticky.min.css +10 -0
- data/app/semanticui/assets/js/components/sticky.min.js +11 -0
- data/app/semanticui/assets/js/components/tab.css +92 -0
- data/app/semanticui/assets/js/components/tab.js +802 -0
- data/app/semanticui/assets/js/components/tab.min.css +10 -0
- data/app/semanticui/assets/js/components/tab.min.js +11 -0
- data/app/semanticui/assets/js/components/table.css +1000 -0
- data/app/semanticui/assets/js/components/table.min.css +10 -0
- data/app/semanticui/assets/js/components/transition.css +1990 -0
- data/app/semanticui/assets/js/components/transition.js +1038 -0
- data/app/semanticui/assets/js/components/transition.min.css +10 -0
- data/app/semanticui/assets/js/components/transition.min.js +11 -0
- data/app/semanticui/assets/js/components/video.css +125 -0
- data/app/semanticui/assets/js/components/video.js +540 -0
- data/app/semanticui/assets/js/components/video.min.css +10 -0
- data/app/semanticui/assets/js/components/video.min.js +11 -0
- data/app/semanticui/assets/js/components/visibility.js +1032 -0
- data/app/semanticui/assets/js/components/visibility.min.js +11 -0
- data/app/semanticui/assets/js/semantic.min.js +9 -9
- data/lib/volt/semanticui.rb +0 -0
- data/lib/volt/semanticui/version.rb +1 -1
- data/volt-semantic-ui-0.0.1.gem +0 -0
- data/volt-semanticui-0.0.1.gem +0 -0
- data/volt-semanticui.gemspec +0 -0
- metadata +141 -10
@@ -0,0 +1,10 @@
|
|
1
|
+
/*!
|
2
|
+
* # Semantic UI 1.11.4 - Video
|
3
|
+
* http://github.com/semantic-org/semantic-ui/
|
4
|
+
*
|
5
|
+
*
|
6
|
+
* Copyright 2014 Contributors
|
7
|
+
* Released under the MIT license
|
8
|
+
* http://opensource.org/licenses/MIT
|
9
|
+
*
|
10
|
+
*/.ui.video{background-color:#ddd;position:relative;max-width:100%;padding-bottom:56.25%;height:0;overflow:hidden}.ui.video .placeholder{background-color:#333}.ui.video .play{cursor:pointer;position:absolute;top:0;left:0;z-index:10;width:100%;height:100%;opacity:.8;-webkit-transition:opacity .3s;transition:opacity .3s}.ui.video .play.icon:before{position:absolute;top:50%;left:50%;z-index:11;background:rgba(0,0,0,.3);width:8rem;height:8rem;line-height:8rem;border-radius:500rem;color:#fff;font-size:8rem;text-shadow:none;-webkit-transform:translateX(-50%) translateY(-50%);-ms-transform:translateX(-50%) translateY(-50%);transform:translateX(-50%) translateY(-50%)}.ui.video .placeholder{position:absolute;top:0;left:0;display:block;width:100%;height:100%}.ui.video .embed embed,.ui.video .embed iframe,.ui.video .embed object{position:absolute;border:none;width:100%;height:100%;top:0;left:0;margin:0;padding:0}.ui.video .play:hover{opacity:1}.ui.video.active .placeholder,.ui.video.active .play{display:none}.ui.video.active .embed{display:inline}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/*!
|
2
|
+
* # Semantic UI 1.11.4 - Video
|
3
|
+
* http://github.com/semantic-org/semantic-ui/
|
4
|
+
*
|
5
|
+
*
|
6
|
+
* Copyright 2014 Contributorss
|
7
|
+
* Released under the MIT license
|
8
|
+
* http://opensource.org/licenses/MIT
|
9
|
+
*
|
10
|
+
*/
|
11
|
+
!function(e,o,t,n){"use strict";e.fn.video=function(t){{var a,i=e(this),r=i.selector||"",l=(new Date).getTime(),c=[],u=arguments[0],s="string"==typeof u,m=[].slice.call(arguments,1);o.requestAnimationFrame||o.mozRequestAnimationFrame||o.webkitRequestAnimationFrame||o.msRequestAnimationFrame||function(e){setTimeout(e,0)}}return i.each(function(){var d,p=e.isPlainObject(t)?e.extend(!0,{},e.fn.video.settings,t):e.extend({},e.fn.video.settings),f=p.selector,g=p.className,h=p.error,v=p.metadata,b=p.namespace,y=p.templates,w="."+b,x="module-"+b,F=(e(o),e(this)),C=F.find(f.placeholder),E=F.find(f.playButton),T=F.find(f.embed),A=this,P=F.data(x);d={initialize:function(){d.debug("Initializing video"),d.create(),C.on("click"+w,d.play),E.on("click"+w,d.play),d.instantiate()},instantiate:function(){d.verbose("Storing instance of module",d),P=d,F.data(x,d)},create:function(){var e=F.data(v.image),o=y.video(e);F.html(o),d.refresh(),e||d.play(),d.debug("Creating html for video element",o)},destroy:function(){d.verbose("Destroying previous instance of video"),d.reset(),F.removeData(x).off(w),C.off(w),E.off(w)},refresh:function(){d.verbose("Refreshing selector cache"),C=F.find(f.placeholder),E=F.find(f.playButton),T=F.find(f.embed)},change:function(e,o,t){d.debug("Changing video to ",e,o,t),F.data(v.source,e).data(v.id,o).data(v.url,t),p.onChange()},reset:function(){d.debug("Clearing video embed and showing placeholder"),F.removeClass(g.active),T.html(" "),C.show(),p.onReset()},play:function(){d.debug("Playing video");var e=F.data(v.source)||!1,o=F.data(v.url)||!1,t=F.data(v.id)||!1;T.html(d.generate.html(e,t,o)),F.addClass(g.active),p.onPlay()},get:{source:function(e){return"string"!=typeof e?!1:-1!==e.search("youtube.com")?"youtube":-1!==e.search("vimeo.com")?"vimeo":!1},id:function(e){return e.match(p.regExp.youtube)?e.match(p.regExp.youtube)[1]:e.match(p.regExp.vimeo)?e.match(p.regExp.vimeo)[2]:!1}},generate:{html:function(e,o,t){d.debug("Generating embed html");var n;return e=e||p.source,o=o||p.id,e&&o||t?(e&&o||(e=d.get.source(t),o=d.get.id(t)),"vimeo"==e?n='<iframe src="//player.vimeo.com/video/'+o+"?="+d.generate.url(e)+'" width="100%" height="100%" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>':"youtube"==e&&(n='<iframe src="//www.youtube.com/embed/'+o+"?="+d.generate.url(e)+'" width="100%" height="100%" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>')):d.error(h.noVideo),n},url:function(e){var o=p.api?1:0,t="auto"===p.autoplay?F.data("image")!==n:p.autoplay,a=p.hd?1:0,i=p.showUI?1:0,r=p.showUI?0:1,l="";return"vimeo"==e&&(l="api="+o+"&title="+i+"&byline="+i+"&portrait="+i+"&autoplay="+t,p.color&&(l+="&color="+p.color)),"ustream"==e?(l="autoplay="+t,p.color&&(l+="&color="+p.color)):"youtube"==e&&(l="enablejsapi="+o+"&autoplay="+t+"&autohide="+r+"&hq="+a+"&modestbranding=1",p.color&&(l+="&color="+p.color)),l}},setting:function(o,t){if(d.debug("Changing setting",o,t),e.isPlainObject(o))e.extend(!0,p,o);else{if(t===n)return p[o];p[o]=t}},internal:function(o,t){if(e.isPlainObject(o))e.extend(!0,d,o);else{if(t===n)return d[o];d[o]=t}},debug:function(){p.debug&&(p.performance?d.performance.log(arguments):(d.debug=Function.prototype.bind.call(console.info,console,p.name+":"),d.debug.apply(console,arguments)))},verbose:function(){p.verbose&&p.debug&&(p.performance?d.performance.log(arguments):(d.verbose=Function.prototype.bind.call(console.info,console,p.name+":"),d.verbose.apply(console,arguments)))},error:function(){d.error=Function.prototype.bind.call(console.error,console,p.name+":"),d.error.apply(console,arguments)},performance:{log:function(e){var o,t,n;p.performance&&(o=(new Date).getTime(),n=l||o,t=o-n,l=o,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:A,"Execution Time":t})),clearTimeout(d.performance.timer),d.performance.timer=setTimeout(d.performance.display,100)},display:function(){var o=p.name+":",t=0;l=!1,clearTimeout(d.performance.timer),e.each(c,function(e,o){t+=o["Execution Time"]}),o+=" "+t+"ms",r&&(o+=" '"+r+"'"),i.length>1&&(o+=" ("+i.length+")"),(console.group!==n||console.table!==n)&&c.length>0&&(console.groupCollapsed(o),console.table?console.table(c):e.each(c,function(e,o){console.log(o.Name+": "+o["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(o,t,i){var r,l,c,u=P;return t=t||m,i=A||i,"string"==typeof o&&u!==n&&(o=o.split(/[\. ]/),r=o.length-1,e.each(o,function(t,a){var i=t!=r?a+o[t+1].charAt(0).toUpperCase()+o[t+1].slice(1):o;if(e.isPlainObject(u[i])&&t!=r)u=u[i];else{if(u[i]!==n)return l=u[i],!1;if(!e.isPlainObject(u[a])||t==r)return u[a]!==n?(l=u[a],!1):(d.error(h.method,o),!1);u=u[a]}})),e.isFunction(l)?c=l.apply(i,t):l!==n&&(c=l),e.isArray(a)?a.push(c):a!==n?a=[a,c]:c!==n&&(a=c),l}},s?(P===n&&d.initialize(),d.invoke(u)):(P!==n&&P.invoke("destroy"),d.initialize())}),a!==n?a:this},e.fn.video.settings={name:"Video",namespace:"video",debug:!1,verbose:!0,performance:!0,metadata:{id:"id",image:"image",source:"source",url:"url"},source:!1,url:!1,id:!1,aspectRatio:16/9,onPlay:function(){},onReset:function(){},onChange:function(){},onPause:function(){},onStop:function(){},width:"auto",height:"auto",autoplay:"auto",color:"#442359",hd:!0,showUI:!1,api:!0,regExp:{youtube:/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/,vimeo:/http:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/},error:{noVideo:"No video specified",method:"The method you called is not defined"},className:{active:"active"},selector:{embed:".embed",placeholder:".placeholder",playButton:".play"}},e.fn.video.settings.templates={video:function(e){var o="";return e&&(o+='<i class="video play icon"></i><img class="placeholder" src="'+e+'">'),o+='<div class="embed"></div>'}}}(jQuery,window,document);
|
@@ -0,0 +1,1032 @@
|
|
1
|
+
/*!
|
2
|
+
* # Semantic UI 1.11.4 - Visibility
|
3
|
+
* http://github.com/semantic-org/semantic-ui/
|
4
|
+
*
|
5
|
+
*
|
6
|
+
* Copyright 2014 Contributors
|
7
|
+
* Released under the MIT license
|
8
|
+
* http://opensource.org/licenses/MIT
|
9
|
+
*
|
10
|
+
*/
|
11
|
+
|
12
|
+
;(function ( $, window, document, undefined ) {
|
13
|
+
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
$.fn.visibility = function(parameters) {
|
17
|
+
var
|
18
|
+
$allModules = $(this),
|
19
|
+
moduleSelector = $allModules.selector || '',
|
20
|
+
|
21
|
+
time = new Date().getTime(),
|
22
|
+
performance = [],
|
23
|
+
|
24
|
+
query = arguments[0],
|
25
|
+
methodInvoked = (typeof query == 'string'),
|
26
|
+
queryArguments = [].slice.call(arguments, 1),
|
27
|
+
returnedValue
|
28
|
+
;
|
29
|
+
|
30
|
+
$allModules
|
31
|
+
.each(function() {
|
32
|
+
var
|
33
|
+
settings = ( $.isPlainObject(parameters) )
|
34
|
+
? $.extend(true, {}, $.fn.visibility.settings, parameters)
|
35
|
+
: $.extend({}, $.fn.visibility.settings),
|
36
|
+
|
37
|
+
className = settings.className,
|
38
|
+
namespace = settings.namespace,
|
39
|
+
error = settings.error,
|
40
|
+
|
41
|
+
eventNamespace = '.' + namespace,
|
42
|
+
moduleNamespace = 'module-' + namespace,
|
43
|
+
|
44
|
+
$window = $(window),
|
45
|
+
$module = $(this),
|
46
|
+
$context = $(settings.context),
|
47
|
+
$container = $module.offsetParent(),
|
48
|
+
|
49
|
+
selector = $module.selector || '',
|
50
|
+
instance = $module.data(moduleNamespace),
|
51
|
+
|
52
|
+
requestAnimationFrame = window.requestAnimationFrame
|
53
|
+
|| window.mozRequestAnimationFrame
|
54
|
+
|| window.webkitRequestAnimationFrame
|
55
|
+
|| window.msRequestAnimationFrame
|
56
|
+
|| function(callback) { setTimeout(callback, 0); },
|
57
|
+
|
58
|
+
element = this,
|
59
|
+
observer,
|
60
|
+
module
|
61
|
+
;
|
62
|
+
|
63
|
+
module = {
|
64
|
+
|
65
|
+
initialize: function() {
|
66
|
+
module.debug('Initializing', settings);
|
67
|
+
|
68
|
+
module.setup.cache();
|
69
|
+
module.save.position();
|
70
|
+
|
71
|
+
if( module.should.trackChanges() ) {
|
72
|
+
module.bind.events();
|
73
|
+
if(settings.type == 'image') {
|
74
|
+
module.setup.image();
|
75
|
+
}
|
76
|
+
if(settings.type == 'fixed') {
|
77
|
+
module.setup.fixed();
|
78
|
+
}
|
79
|
+
}
|
80
|
+
if(settings.initialCheck) {
|
81
|
+
module.checkVisibility();
|
82
|
+
}
|
83
|
+
if(settings.observeChanges) {
|
84
|
+
module.observeChanges();
|
85
|
+
}
|
86
|
+
module.instantiate();
|
87
|
+
},
|
88
|
+
|
89
|
+
instantiate: function() {
|
90
|
+
module.debug('Storing instance', module);
|
91
|
+
$module
|
92
|
+
.data(moduleNamespace, module)
|
93
|
+
;
|
94
|
+
instance = module;
|
95
|
+
},
|
96
|
+
|
97
|
+
destroy: function() {
|
98
|
+
module.verbose('Destroying previous module');
|
99
|
+
$module
|
100
|
+
.off(eventNamespace)
|
101
|
+
.removeData(moduleNamespace)
|
102
|
+
;
|
103
|
+
$window.off('resize' + eventNamespace, module.event.refresh);
|
104
|
+
$context.off('scroll' + eventNamespace, module.event.scroll);
|
105
|
+
},
|
106
|
+
|
107
|
+
observeChanges: function() {
|
108
|
+
var
|
109
|
+
context = $context[0]
|
110
|
+
;
|
111
|
+
if('MutationObserver' in window) {
|
112
|
+
observer = new MutationObserver(function(mutations) {
|
113
|
+
module.verbose('DOM tree modified, updating visibility calculations');
|
114
|
+
module.refresh();
|
115
|
+
});
|
116
|
+
observer.observe(element, {
|
117
|
+
childList : true,
|
118
|
+
subtree : true
|
119
|
+
});
|
120
|
+
module.debug('Setting up mutation observer', observer);
|
121
|
+
}
|
122
|
+
},
|
123
|
+
|
124
|
+
bind: {
|
125
|
+
events: function() {
|
126
|
+
module.verbose('Binding visibility events to scroll and resize');
|
127
|
+
$window
|
128
|
+
.on('resize' + eventNamespace, module.event.refresh)
|
129
|
+
;
|
130
|
+
$context
|
131
|
+
.on('scroll' + eventNamespace, module.event.scroll)
|
132
|
+
;
|
133
|
+
}
|
134
|
+
},
|
135
|
+
|
136
|
+
event: {
|
137
|
+
refresh: function() {
|
138
|
+
requestAnimationFrame(module.refresh);
|
139
|
+
},
|
140
|
+
scroll: function() {
|
141
|
+
module.verbose('Scroll position changed');
|
142
|
+
if(settings.throttle) {
|
143
|
+
clearTimeout(module.timer);
|
144
|
+
module.timer = setTimeout(function() {
|
145
|
+
module.checkVisibility();
|
146
|
+
}, settings.throttle);
|
147
|
+
}
|
148
|
+
else {
|
149
|
+
requestAnimationFrame(function() {
|
150
|
+
module.checkVisibility();
|
151
|
+
});
|
152
|
+
}
|
153
|
+
}
|
154
|
+
},
|
155
|
+
|
156
|
+
precache: function(images, callback) {
|
157
|
+
if (!(images instanceof Array)) {
|
158
|
+
images = [images];
|
159
|
+
}
|
160
|
+
var
|
161
|
+
imagesLength = images.length,
|
162
|
+
loadedCounter = 0,
|
163
|
+
cache = [],
|
164
|
+
cacheImage = document.createElement('img'),
|
165
|
+
handleLoad = function() {
|
166
|
+
loadedCounter++;
|
167
|
+
if (loadedCounter >= images.length) {
|
168
|
+
if ($.isFunction(callback)) {
|
169
|
+
callback();
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
;
|
174
|
+
while (imagesLength--) {
|
175
|
+
cacheImage = document.createElement('img');
|
176
|
+
cacheImage.onload = handleLoad;
|
177
|
+
cacheImage.onerror = handleLoad;
|
178
|
+
cacheImage.src = images[imagesLength];
|
179
|
+
cache.push(cacheImage);
|
180
|
+
}
|
181
|
+
},
|
182
|
+
|
183
|
+
should: {
|
184
|
+
trackChanges: function() {
|
185
|
+
if(methodInvoked && queryArguments.length > 0) {
|
186
|
+
module.debug('One time query, no need to bind events');
|
187
|
+
return false;
|
188
|
+
}
|
189
|
+
module.debug('Callbacks being attached');
|
190
|
+
return true;
|
191
|
+
}
|
192
|
+
},
|
193
|
+
|
194
|
+
setup: {
|
195
|
+
cache: function() {
|
196
|
+
module.cache = {
|
197
|
+
occurred : {},
|
198
|
+
screen : {},
|
199
|
+
element : {},
|
200
|
+
};
|
201
|
+
},
|
202
|
+
image: function() {
|
203
|
+
var
|
204
|
+
src = $module.data('src')
|
205
|
+
;
|
206
|
+
if(src) {
|
207
|
+
module.verbose('Lazy loading image', src);
|
208
|
+
settings.observeChanges = false;
|
209
|
+
// show when top visible
|
210
|
+
module.topVisible(function() {
|
211
|
+
module.debug('Image top visible', element);
|
212
|
+
module.precache(src, function() {
|
213
|
+
module.set.image(src);
|
214
|
+
settings.onTopVisible = false;
|
215
|
+
});
|
216
|
+
});
|
217
|
+
}
|
218
|
+
},
|
219
|
+
fixed: function() {
|
220
|
+
module.verbose('Setting up fixed on element pass');
|
221
|
+
settings.once = false;
|
222
|
+
settings.onTopPassed = function() {
|
223
|
+
$module
|
224
|
+
.addClass(className.fixed)
|
225
|
+
.css({
|
226
|
+
top: settings.offset + 'px'
|
227
|
+
})
|
228
|
+
;
|
229
|
+
if(settings.transition) {
|
230
|
+
if($.fn.transition !== undefined) {
|
231
|
+
$module.transition(settings.transition, settings.duration);
|
232
|
+
}
|
233
|
+
}
|
234
|
+
};
|
235
|
+
settings.onTopPassedReverse = function() {
|
236
|
+
$module
|
237
|
+
.removeClass(className.fixed)
|
238
|
+
.css({
|
239
|
+
position: '',
|
240
|
+
top: ''
|
241
|
+
})
|
242
|
+
;
|
243
|
+
};
|
244
|
+
}
|
245
|
+
},
|
246
|
+
|
247
|
+
set: {
|
248
|
+
image: function(src) {
|
249
|
+
var
|
250
|
+
offScreen = (module.cache.screen.bottom < module.cache.element.top)
|
251
|
+
;
|
252
|
+
$module
|
253
|
+
.attr('src', src)
|
254
|
+
;
|
255
|
+
if(offScreen) {
|
256
|
+
module.verbose('Image outside browser, no show animation');
|
257
|
+
$module.show();
|
258
|
+
}
|
259
|
+
else {
|
260
|
+
if(settings.transition) {
|
261
|
+
if( $.fn.transition !== undefined ) {
|
262
|
+
$module.transition(settings.transition, settings.duration);
|
263
|
+
}
|
264
|
+
else {
|
265
|
+
$module.fadeIn(settings.duration);
|
266
|
+
}
|
267
|
+
}
|
268
|
+
else {
|
269
|
+
$module.show();
|
270
|
+
}
|
271
|
+
}
|
272
|
+
}
|
273
|
+
},
|
274
|
+
|
275
|
+
is: {
|
276
|
+
visible: function() {
|
277
|
+
if(module.cache && module.cache.element) {
|
278
|
+
return (module.cache.element.width > 0);
|
279
|
+
}
|
280
|
+
return false;
|
281
|
+
}
|
282
|
+
},
|
283
|
+
|
284
|
+
refresh: function() {
|
285
|
+
module.debug('Refreshing constants (element width/height)');
|
286
|
+
module.reset();
|
287
|
+
module.save.position();
|
288
|
+
module.checkVisibility();
|
289
|
+
settings.onRefresh.call(element);
|
290
|
+
},
|
291
|
+
|
292
|
+
reset: function() {
|
293
|
+
module.verbose('Reseting all cached values');
|
294
|
+
if( $.isPlainObject(module.cache) ) {
|
295
|
+
module.cache.screen = {};
|
296
|
+
module.cache.element = {};
|
297
|
+
}
|
298
|
+
},
|
299
|
+
|
300
|
+
checkVisibility: function() {
|
301
|
+
module.verbose('Checking visibility of element', module.cache.element);
|
302
|
+
|
303
|
+
if( module.is.visible() ) {
|
304
|
+
|
305
|
+
// update calculations derived from scroll
|
306
|
+
module.save.calculations();
|
307
|
+
|
308
|
+
// percentage
|
309
|
+
module.passed();
|
310
|
+
|
311
|
+
// reverse (must be first)
|
312
|
+
module.passingReverse();
|
313
|
+
module.topVisibleReverse();
|
314
|
+
module.bottomVisibleReverse();
|
315
|
+
module.topPassedReverse();
|
316
|
+
module.bottomPassedReverse();
|
317
|
+
|
318
|
+
// one time
|
319
|
+
module.passing();
|
320
|
+
module.topVisible();
|
321
|
+
module.bottomVisible();
|
322
|
+
module.topPassed();
|
323
|
+
module.bottomPassed();
|
324
|
+
|
325
|
+
// on update callback
|
326
|
+
if(settings.onUpdate) {
|
327
|
+
settings.onUpdate.call(element, module.get.elementCalculations());
|
328
|
+
}
|
329
|
+
}
|
330
|
+
},
|
331
|
+
|
332
|
+
passed: function(amount, newCallback) {
|
333
|
+
var
|
334
|
+
calculations = module.get.elementCalculations(),
|
335
|
+
amountInPixels
|
336
|
+
;
|
337
|
+
// assign callback
|
338
|
+
if(amount !== undefined && newCallback !== undefined) {
|
339
|
+
settings.onPassed[amount] = newCallback;
|
340
|
+
}
|
341
|
+
else if(amount !== undefined) {
|
342
|
+
return (module.get.pixelsPassed(amount) > calculations.pixelsPassed);
|
343
|
+
}
|
344
|
+
else if(calculations.passing) {
|
345
|
+
$.each(settings.onPassed, function(amount, callback) {
|
346
|
+
if(calculations.bottomVisible || calculations.pixelsPassed > module.get.pixelsPassed(amount)) {
|
347
|
+
module.execute(callback, amount);
|
348
|
+
}
|
349
|
+
else if(!settings.once) {
|
350
|
+
module.remove.occurred(callback);
|
351
|
+
}
|
352
|
+
});
|
353
|
+
}
|
354
|
+
},
|
355
|
+
|
356
|
+
passing: function(newCallback) {
|
357
|
+
var
|
358
|
+
calculations = module.get.elementCalculations(),
|
359
|
+
callback = newCallback || settings.onPassing,
|
360
|
+
callbackName = 'passing'
|
361
|
+
;
|
362
|
+
if(newCallback) {
|
363
|
+
module.debug('Adding callback for passing', newCallback);
|
364
|
+
settings.onPassing = newCallback;
|
365
|
+
}
|
366
|
+
if(calculations.passing) {
|
367
|
+
module.execute(callback, callbackName);
|
368
|
+
}
|
369
|
+
else if(!settings.once) {
|
370
|
+
module.remove.occurred(callbackName);
|
371
|
+
}
|
372
|
+
if(newCallback !== undefined) {
|
373
|
+
return calculations.passing;
|
374
|
+
}
|
375
|
+
},
|
376
|
+
|
377
|
+
|
378
|
+
topVisible: function(newCallback) {
|
379
|
+
var
|
380
|
+
calculations = module.get.elementCalculations(),
|
381
|
+
callback = newCallback || settings.onTopVisible,
|
382
|
+
callbackName = 'topVisible'
|
383
|
+
;
|
384
|
+
if(newCallback) {
|
385
|
+
module.debug('Adding callback for top visible', newCallback);
|
386
|
+
settings.onTopVisible = newCallback;
|
387
|
+
}
|
388
|
+
if(calculations.topVisible) {
|
389
|
+
module.execute(callback, callbackName);
|
390
|
+
}
|
391
|
+
else if(!settings.once) {
|
392
|
+
module.remove.occurred(callbackName);
|
393
|
+
}
|
394
|
+
if(newCallback === undefined) {
|
395
|
+
return calculations.topVisible;
|
396
|
+
}
|
397
|
+
},
|
398
|
+
|
399
|
+
bottomVisible: function(newCallback) {
|
400
|
+
var
|
401
|
+
calculations = module.get.elementCalculations(),
|
402
|
+
callback = newCallback || settings.onBottomVisible,
|
403
|
+
callbackName = 'bottomVisible'
|
404
|
+
;
|
405
|
+
if(newCallback) {
|
406
|
+
module.debug('Adding callback for bottom visible', newCallback);
|
407
|
+
settings.onBottomVisible = newCallback;
|
408
|
+
}
|
409
|
+
if(calculations.bottomVisible) {
|
410
|
+
module.execute(callback, callbackName);
|
411
|
+
}
|
412
|
+
else if(!settings.once) {
|
413
|
+
module.remove.occurred(callbackName);
|
414
|
+
}
|
415
|
+
if(newCallback === undefined) {
|
416
|
+
return calculations.bottomVisible;
|
417
|
+
}
|
418
|
+
},
|
419
|
+
|
420
|
+
topPassed: function(newCallback) {
|
421
|
+
var
|
422
|
+
calculations = module.get.elementCalculations(),
|
423
|
+
callback = newCallback || settings.onTopPassed,
|
424
|
+
callbackName = 'topPassed'
|
425
|
+
;
|
426
|
+
if(newCallback) {
|
427
|
+
module.debug('Adding callback for top passed', newCallback);
|
428
|
+
settings.onTopPassed = newCallback;
|
429
|
+
}
|
430
|
+
if(calculations.topPassed) {
|
431
|
+
module.execute(callback, callbackName);
|
432
|
+
}
|
433
|
+
else if(!settings.once) {
|
434
|
+
module.remove.occurred(callbackName);
|
435
|
+
}
|
436
|
+
if(newCallback === undefined) {
|
437
|
+
return calculations.topPassed;
|
438
|
+
}
|
439
|
+
},
|
440
|
+
|
441
|
+
bottomPassed: function(newCallback) {
|
442
|
+
var
|
443
|
+
calculations = module.get.elementCalculations(),
|
444
|
+
callback = newCallback || settings.onBottomPassed,
|
445
|
+
callbackName = 'bottomPassed'
|
446
|
+
;
|
447
|
+
if(newCallback) {
|
448
|
+
module.debug('Adding callback for bottom passed', newCallback);
|
449
|
+
settings.onBottomPassed = newCallback;
|
450
|
+
}
|
451
|
+
if(calculations.bottomPassed) {
|
452
|
+
module.execute(callback, callbackName);
|
453
|
+
}
|
454
|
+
else if(!settings.once) {
|
455
|
+
module.remove.occurred(callbackName);
|
456
|
+
}
|
457
|
+
if(newCallback === undefined) {
|
458
|
+
return calculations.bottomPassed;
|
459
|
+
}
|
460
|
+
},
|
461
|
+
|
462
|
+
passingReverse: function(newCallback) {
|
463
|
+
var
|
464
|
+
calculations = module.get.elementCalculations(),
|
465
|
+
callback = newCallback || settings.onPassingReverse,
|
466
|
+
callbackName = 'passingReverse'
|
467
|
+
;
|
468
|
+
if(newCallback) {
|
469
|
+
module.debug('Adding callback for passing reverse', newCallback);
|
470
|
+
settings.onPassingReverse = newCallback;
|
471
|
+
}
|
472
|
+
if(!calculations.passing) {
|
473
|
+
if(module.get.occurred('passing')) {
|
474
|
+
module.execute(callback, callbackName);
|
475
|
+
}
|
476
|
+
}
|
477
|
+
else if(!settings.once) {
|
478
|
+
module.remove.occurred(callbackName);
|
479
|
+
}
|
480
|
+
if(newCallback !== undefined) {
|
481
|
+
return !calculations.passing;
|
482
|
+
}
|
483
|
+
},
|
484
|
+
|
485
|
+
|
486
|
+
topVisibleReverse: function(newCallback) {
|
487
|
+
var
|
488
|
+
calculations = module.get.elementCalculations(),
|
489
|
+
callback = newCallback || settings.onTopVisibleReverse,
|
490
|
+
callbackName = 'topVisibleReverse'
|
491
|
+
;
|
492
|
+
if(newCallback) {
|
493
|
+
module.debug('Adding callback for top visible reverse', newCallback);
|
494
|
+
settings.onTopVisibleReverse = newCallback;
|
495
|
+
}
|
496
|
+
if(!calculations.topVisible) {
|
497
|
+
if(module.get.occurred('topVisible')) {
|
498
|
+
module.execute(callback, callbackName);
|
499
|
+
}
|
500
|
+
}
|
501
|
+
else if(!settings.once) {
|
502
|
+
module.remove.occurred(callbackName);
|
503
|
+
}
|
504
|
+
if(newCallback === undefined) {
|
505
|
+
return !calculations.topVisible;
|
506
|
+
}
|
507
|
+
},
|
508
|
+
|
509
|
+
bottomVisibleReverse: function(newCallback) {
|
510
|
+
var
|
511
|
+
calculations = module.get.elementCalculations(),
|
512
|
+
callback = newCallback || settings.onBottomVisibleReverse,
|
513
|
+
callbackName = 'bottomVisibleReverse'
|
514
|
+
;
|
515
|
+
if(newCallback) {
|
516
|
+
module.debug('Adding callback for bottom visible reverse', newCallback);
|
517
|
+
settings.onBottomVisibleReverse = newCallback;
|
518
|
+
}
|
519
|
+
if(!calculations.bottomVisible) {
|
520
|
+
if(module.get.occurred('bottomVisible')) {
|
521
|
+
module.execute(callback, callbackName);
|
522
|
+
}
|
523
|
+
}
|
524
|
+
else if(!settings.once) {
|
525
|
+
module.remove.occurred(callbackName);
|
526
|
+
}
|
527
|
+
if(newCallback === undefined) {
|
528
|
+
return !calculations.bottomVisible;
|
529
|
+
}
|
530
|
+
},
|
531
|
+
|
532
|
+
topPassedReverse: function(newCallback) {
|
533
|
+
var
|
534
|
+
calculations = module.get.elementCalculations(),
|
535
|
+
callback = newCallback || settings.onTopPassedReverse,
|
536
|
+
callbackName = 'topPassedReverse'
|
537
|
+
;
|
538
|
+
if(newCallback) {
|
539
|
+
module.debug('Adding callback for top passed reverse', newCallback);
|
540
|
+
settings.onTopPassedReverse = newCallback;
|
541
|
+
}
|
542
|
+
if(!calculations.topPassed) {
|
543
|
+
if(module.get.occurred('topPassed')) {
|
544
|
+
module.execute(callback, callbackName);
|
545
|
+
}
|
546
|
+
}
|
547
|
+
else if(!settings.once) {
|
548
|
+
module.remove.occurred(callbackName);
|
549
|
+
}
|
550
|
+
if(newCallback === undefined) {
|
551
|
+
return !calculations.onTopPassed;
|
552
|
+
}
|
553
|
+
},
|
554
|
+
|
555
|
+
bottomPassedReverse: function(newCallback) {
|
556
|
+
var
|
557
|
+
calculations = module.get.elementCalculations(),
|
558
|
+
callback = newCallback || settings.onBottomPassedReverse,
|
559
|
+
callbackName = 'bottomPassedReverse'
|
560
|
+
;
|
561
|
+
if(newCallback) {
|
562
|
+
module.debug('Adding callback for bottom passed reverse', newCallback);
|
563
|
+
settings.onBottomPassedReverse = newCallback;
|
564
|
+
}
|
565
|
+
if(!calculations.bottomPassed) {
|
566
|
+
if(module.get.occurred('bottomPassed')) {
|
567
|
+
module.execute(callback, callbackName);
|
568
|
+
}
|
569
|
+
}
|
570
|
+
else if(!settings.once) {
|
571
|
+
module.remove.occurred(callbackName);
|
572
|
+
}
|
573
|
+
if(newCallback === undefined) {
|
574
|
+
return !calculations.bottomPassed;
|
575
|
+
}
|
576
|
+
},
|
577
|
+
|
578
|
+
execute: function(callback, callbackName) {
|
579
|
+
var
|
580
|
+
calculations = module.get.elementCalculations(),
|
581
|
+
screen = module.get.screenCalculations()
|
582
|
+
;
|
583
|
+
callback = callback || false;
|
584
|
+
if(callback) {
|
585
|
+
if(settings.continuous) {
|
586
|
+
module.debug('Callback being called continuously', callbackName, calculations);
|
587
|
+
callback.call(element, calculations, screen);
|
588
|
+
}
|
589
|
+
else if(!module.get.occurred(callbackName)) {
|
590
|
+
module.debug('Conditions met', callbackName, calculations);
|
591
|
+
callback.call(element, calculations, screen);
|
592
|
+
}
|
593
|
+
}
|
594
|
+
module.save.occurred(callbackName);
|
595
|
+
},
|
596
|
+
|
597
|
+
remove: {
|
598
|
+
occurred: function(callback) {
|
599
|
+
if(callback) {
|
600
|
+
if(module.cache.occurred[callback] !== undefined && module.cache.occurred[callback] === true) {
|
601
|
+
module.debug('Callback can now be called again', callback);
|
602
|
+
module.cache.occurred[callback] = false;
|
603
|
+
}
|
604
|
+
}
|
605
|
+
else {
|
606
|
+
module.cache.occurred = {};
|
607
|
+
}
|
608
|
+
}
|
609
|
+
},
|
610
|
+
|
611
|
+
save: {
|
612
|
+
calculations: function() {
|
613
|
+
module.verbose('Saving all calculations necessary to determine positioning');
|
614
|
+
module.save.scroll();
|
615
|
+
module.save.direction();
|
616
|
+
module.save.screenCalculations();
|
617
|
+
module.save.elementCalculations();
|
618
|
+
},
|
619
|
+
occurred: function(callback) {
|
620
|
+
if(callback) {
|
621
|
+
if(module.cache.occurred[callback] === undefined || (module.cache.occurred[callback] !== true)) {
|
622
|
+
module.verbose('Saving callback occurred', callback);
|
623
|
+
module.cache.occurred[callback] = true;
|
624
|
+
}
|
625
|
+
}
|
626
|
+
},
|
627
|
+
scroll: function() {
|
628
|
+
module.cache.scroll = $context.scrollTop() + settings.offset;
|
629
|
+
},
|
630
|
+
direction: function() {
|
631
|
+
var
|
632
|
+
scroll = module.get.scroll(),
|
633
|
+
lastScroll = module.get.lastScroll(),
|
634
|
+
direction
|
635
|
+
;
|
636
|
+
if(scroll > lastScroll && lastScroll) {
|
637
|
+
direction = 'down';
|
638
|
+
}
|
639
|
+
else if(scroll < lastScroll && lastScroll) {
|
640
|
+
direction = 'up';
|
641
|
+
}
|
642
|
+
else {
|
643
|
+
direction = 'static';
|
644
|
+
}
|
645
|
+
module.cache.direction = direction;
|
646
|
+
return module.cache.direction;
|
647
|
+
},
|
648
|
+
elementPosition: function() {
|
649
|
+
var
|
650
|
+
element = module.cache.element,
|
651
|
+
screen = module.get.screenSize()
|
652
|
+
;
|
653
|
+
module.verbose('Saving element position');
|
654
|
+
// (quicker than $.extend)
|
655
|
+
element.fits = (element.height < screen.height);
|
656
|
+
element.offset = $module.offset();
|
657
|
+
element.width = $module.outerWidth();
|
658
|
+
element.height = $module.outerHeight();
|
659
|
+
// store
|
660
|
+
module.cache.element = element;
|
661
|
+
return element;
|
662
|
+
},
|
663
|
+
elementCalculations: function() {
|
664
|
+
var
|
665
|
+
screen = module.get.screenCalculations(),
|
666
|
+
element = module.get.elementPosition()
|
667
|
+
;
|
668
|
+
// offset
|
669
|
+
if(settings.includeMargin) {
|
670
|
+
element.margin = {};
|
671
|
+
element.margin.top = parseInt($module.css('margin-top'), 10);
|
672
|
+
element.margin.bottom = parseInt($module.css('margin-bottom'), 10);
|
673
|
+
element.top = element.offset.top - element.margin.top;
|
674
|
+
element.bottom = element.offset.top + element.height + element.margin.bottom;
|
675
|
+
}
|
676
|
+
else {
|
677
|
+
element.top = element.offset.top;
|
678
|
+
element.bottom = element.offset.top + element.height;
|
679
|
+
}
|
680
|
+
|
681
|
+
// visibility
|
682
|
+
element.topVisible = (screen.bottom >= element.top);
|
683
|
+
element.topPassed = (screen.top >= element.top);
|
684
|
+
element.bottomVisible = (screen.bottom >= element.bottom);
|
685
|
+
element.bottomPassed = (screen.top >= element.bottom);
|
686
|
+
element.pixelsPassed = 0;
|
687
|
+
element.percentagePassed = 0;
|
688
|
+
|
689
|
+
// meta calculations
|
690
|
+
element.visible = (element.topVisible || element.bottomVisible);
|
691
|
+
element.passing = (element.topPassed && !element.bottomPassed);
|
692
|
+
element.hidden = (!element.topVisible && !element.bottomVisible);
|
693
|
+
|
694
|
+
// passing calculations
|
695
|
+
if(element.passing) {
|
696
|
+
element.pixelsPassed = (screen.top - element.top);
|
697
|
+
element.percentagePassed = (screen.top - element.top) / element.height;
|
698
|
+
}
|
699
|
+
module.cache.element = element;
|
700
|
+
module.verbose('Updated element calculations', element);
|
701
|
+
return element;
|
702
|
+
},
|
703
|
+
screenCalculations: function() {
|
704
|
+
var
|
705
|
+
scroll = module.get.scroll()
|
706
|
+
;
|
707
|
+
module.save.direction();
|
708
|
+
module.cache.screen.top = scroll;
|
709
|
+
module.cache.screen.bottom = scroll + module.cache.screen.height;
|
710
|
+
return module.cache.screen;
|
711
|
+
},
|
712
|
+
screenSize: function() {
|
713
|
+
module.verbose('Saving window position');
|
714
|
+
module.cache.screen = {
|
715
|
+
height: $context.height()
|
716
|
+
};
|
717
|
+
},
|
718
|
+
position: function() {
|
719
|
+
module.save.screenSize();
|
720
|
+
module.save.elementPosition();
|
721
|
+
}
|
722
|
+
},
|
723
|
+
|
724
|
+
get: {
|
725
|
+
pixelsPassed: function(amount) {
|
726
|
+
var
|
727
|
+
element = module.get.elementCalculations()
|
728
|
+
;
|
729
|
+
if(amount.search('%') > -1) {
|
730
|
+
return ( element.height * (parseInt(amount, 10) / 100) );
|
731
|
+
}
|
732
|
+
return parseInt(amount, 10);
|
733
|
+
},
|
734
|
+
occurred: function(callback) {
|
735
|
+
return (module.cache.occurred !== undefined)
|
736
|
+
? module.cache.occurred[callback] || false
|
737
|
+
: false
|
738
|
+
;
|
739
|
+
},
|
740
|
+
direction: function() {
|
741
|
+
if(module.cache.direction === undefined) {
|
742
|
+
module.save.direction();
|
743
|
+
}
|
744
|
+
return module.cache.direction;
|
745
|
+
},
|
746
|
+
elementPosition: function() {
|
747
|
+
if(module.cache.element === undefined) {
|
748
|
+
module.save.elementPosition();
|
749
|
+
}
|
750
|
+
return module.cache.element;
|
751
|
+
},
|
752
|
+
elementCalculations: function() {
|
753
|
+
if(module.cache.element === undefined) {
|
754
|
+
module.save.elementCalculations();
|
755
|
+
}
|
756
|
+
return module.cache.element;
|
757
|
+
},
|
758
|
+
screenCalculations: function() {
|
759
|
+
if(module.cache.screen === undefined) {
|
760
|
+
module.save.screenCalculations();
|
761
|
+
}
|
762
|
+
return module.cache.screen;
|
763
|
+
},
|
764
|
+
screenSize: function() {
|
765
|
+
if(module.cache.screen === undefined) {
|
766
|
+
module.save.screenSize();
|
767
|
+
}
|
768
|
+
return module.cache.screen;
|
769
|
+
},
|
770
|
+
scroll: function() {
|
771
|
+
if(module.cache.scroll === undefined) {
|
772
|
+
module.save.scroll();
|
773
|
+
}
|
774
|
+
return module.cache.scroll;
|
775
|
+
},
|
776
|
+
lastScroll: function() {
|
777
|
+
if(module.cache.screen === undefined) {
|
778
|
+
module.debug('First scroll event, no last scroll could be found');
|
779
|
+
return false;
|
780
|
+
}
|
781
|
+
return module.cache.screen.top;
|
782
|
+
}
|
783
|
+
},
|
784
|
+
|
785
|
+
setting: function(name, value) {
|
786
|
+
if( $.isPlainObject(name) ) {
|
787
|
+
$.extend(true, settings, name);
|
788
|
+
}
|
789
|
+
else if(value !== undefined) {
|
790
|
+
settings[name] = value;
|
791
|
+
}
|
792
|
+
else {
|
793
|
+
return settings[name];
|
794
|
+
}
|
795
|
+
},
|
796
|
+
internal: function(name, value) {
|
797
|
+
if( $.isPlainObject(name) ) {
|
798
|
+
$.extend(true, module, name);
|
799
|
+
}
|
800
|
+
else if(value !== undefined) {
|
801
|
+
module[name] = value;
|
802
|
+
}
|
803
|
+
else {
|
804
|
+
return module[name];
|
805
|
+
}
|
806
|
+
},
|
807
|
+
debug: function() {
|
808
|
+
if(settings.debug) {
|
809
|
+
if(settings.performance) {
|
810
|
+
module.performance.log(arguments);
|
811
|
+
}
|
812
|
+
else {
|
813
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
814
|
+
module.debug.apply(console, arguments);
|
815
|
+
}
|
816
|
+
}
|
817
|
+
},
|
818
|
+
verbose: function() {
|
819
|
+
if(settings.verbose && settings.debug) {
|
820
|
+
if(settings.performance) {
|
821
|
+
module.performance.log(arguments);
|
822
|
+
}
|
823
|
+
else {
|
824
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
825
|
+
module.verbose.apply(console, arguments);
|
826
|
+
}
|
827
|
+
}
|
828
|
+
},
|
829
|
+
error: function() {
|
830
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
|
831
|
+
module.error.apply(console, arguments);
|
832
|
+
},
|
833
|
+
performance: {
|
834
|
+
log: function(message) {
|
835
|
+
var
|
836
|
+
currentTime,
|
837
|
+
executionTime,
|
838
|
+
previousTime
|
839
|
+
;
|
840
|
+
if(settings.performance) {
|
841
|
+
currentTime = new Date().getTime();
|
842
|
+
previousTime = time || currentTime;
|
843
|
+
executionTime = currentTime - previousTime;
|
844
|
+
time = currentTime;
|
845
|
+
performance.push({
|
846
|
+
'Name' : message[0],
|
847
|
+
'Arguments' : [].slice.call(message, 1) || '',
|
848
|
+
'Element' : element,
|
849
|
+
'Execution Time' : executionTime
|
850
|
+
});
|
851
|
+
}
|
852
|
+
clearTimeout(module.performance.timer);
|
853
|
+
module.performance.timer = setTimeout(module.performance.display, 100);
|
854
|
+
},
|
855
|
+
display: function() {
|
856
|
+
var
|
857
|
+
title = settings.name + ':',
|
858
|
+
totalTime = 0
|
859
|
+
;
|
860
|
+
time = false;
|
861
|
+
clearTimeout(module.performance.timer);
|
862
|
+
$.each(performance, function(index, data) {
|
863
|
+
totalTime += data['Execution Time'];
|
864
|
+
});
|
865
|
+
title += ' ' + totalTime + 'ms';
|
866
|
+
if(moduleSelector) {
|
867
|
+
title += ' \'' + moduleSelector + '\'';
|
868
|
+
}
|
869
|
+
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
870
|
+
console.groupCollapsed(title);
|
871
|
+
if(console.table) {
|
872
|
+
console.table(performance);
|
873
|
+
}
|
874
|
+
else {
|
875
|
+
$.each(performance, function(index, data) {
|
876
|
+
console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
|
877
|
+
});
|
878
|
+
}
|
879
|
+
console.groupEnd();
|
880
|
+
}
|
881
|
+
performance = [];
|
882
|
+
}
|
883
|
+
},
|
884
|
+
invoke: function(query, passedArguments, context) {
|
885
|
+
var
|
886
|
+
object = instance,
|
887
|
+
maxDepth,
|
888
|
+
found,
|
889
|
+
response
|
890
|
+
;
|
891
|
+
passedArguments = passedArguments || queryArguments;
|
892
|
+
context = element || context;
|
893
|
+
if(typeof query == 'string' && object !== undefined) {
|
894
|
+
query = query.split(/[\. ]/);
|
895
|
+
maxDepth = query.length - 1;
|
896
|
+
$.each(query, function(depth, value) {
|
897
|
+
var camelCaseValue = (depth != maxDepth)
|
898
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
899
|
+
: query
|
900
|
+
;
|
901
|
+
if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
|
902
|
+
object = object[camelCaseValue];
|
903
|
+
}
|
904
|
+
else if( object[camelCaseValue] !== undefined ) {
|
905
|
+
found = object[camelCaseValue];
|
906
|
+
return false;
|
907
|
+
}
|
908
|
+
else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
|
909
|
+
object = object[value];
|
910
|
+
}
|
911
|
+
else if( object[value] !== undefined ) {
|
912
|
+
found = object[value];
|
913
|
+
return false;
|
914
|
+
}
|
915
|
+
else {
|
916
|
+
module.error(error.method, query);
|
917
|
+
return false;
|
918
|
+
}
|
919
|
+
});
|
920
|
+
}
|
921
|
+
if ( $.isFunction( found ) ) {
|
922
|
+
response = found.apply(context, passedArguments);
|
923
|
+
}
|
924
|
+
else if(found !== undefined) {
|
925
|
+
response = found;
|
926
|
+
}
|
927
|
+
if($.isArray(returnedValue)) {
|
928
|
+
returnedValue.push(response);
|
929
|
+
}
|
930
|
+
else if(returnedValue !== undefined) {
|
931
|
+
returnedValue = [returnedValue, response];
|
932
|
+
}
|
933
|
+
else if(response !== undefined) {
|
934
|
+
returnedValue = response;
|
935
|
+
}
|
936
|
+
return found;
|
937
|
+
}
|
938
|
+
};
|
939
|
+
|
940
|
+
if(methodInvoked) {
|
941
|
+
if(instance === undefined) {
|
942
|
+
module.initialize();
|
943
|
+
}
|
944
|
+
module.invoke(query);
|
945
|
+
}
|
946
|
+
else {
|
947
|
+
if(instance !== undefined) {
|
948
|
+
instance.invoke('destroy');
|
949
|
+
}
|
950
|
+
module.initialize();
|
951
|
+
}
|
952
|
+
})
|
953
|
+
;
|
954
|
+
|
955
|
+
return (returnedValue !== undefined)
|
956
|
+
? returnedValue
|
957
|
+
: this
|
958
|
+
;
|
959
|
+
};
|
960
|
+
|
961
|
+
$.fn.visibility.settings = {
|
962
|
+
|
963
|
+
name : 'Visibility',
|
964
|
+
namespace : 'visibility',
|
965
|
+
|
966
|
+
debug : false,
|
967
|
+
verbose : false,
|
968
|
+
performance : true,
|
969
|
+
|
970
|
+
// whether to use mutation observers to follow changes
|
971
|
+
observeChanges : true,
|
972
|
+
|
973
|
+
// callback should only occur one time
|
974
|
+
once : true,
|
975
|
+
|
976
|
+
// callback should fire continuously whe evaluates to true
|
977
|
+
continuous : false,
|
978
|
+
|
979
|
+
// offset to use with scroll top
|
980
|
+
offset : 0,
|
981
|
+
|
982
|
+
// whether to include margin in elements position
|
983
|
+
includeMargin : false,
|
984
|
+
|
985
|
+
// scroll context for visibility checks
|
986
|
+
context : window,
|
987
|
+
|
988
|
+
// check position immediately on init
|
989
|
+
initialCheck : true,
|
990
|
+
|
991
|
+
// visibility check delay in ms (defaults to animationFrame)
|
992
|
+
throttle : false,
|
993
|
+
|
994
|
+
// special visibility type (image, fixed)
|
995
|
+
type : false,
|
996
|
+
|
997
|
+
// image only animation settings
|
998
|
+
transition : false,
|
999
|
+
duration : 1000,
|
1000
|
+
|
1001
|
+
// array of callbacks for percentage
|
1002
|
+
onPassed : {},
|
1003
|
+
|
1004
|
+
// standard callbacks
|
1005
|
+
onPassing : false,
|
1006
|
+
onTopVisible : false,
|
1007
|
+
onBottomVisible : false,
|
1008
|
+
onTopPassed : false,
|
1009
|
+
onBottomPassed : false,
|
1010
|
+
|
1011
|
+
// reverse callbacks
|
1012
|
+
onPassingReverse : false,
|
1013
|
+
onTopVisibleReverse : false,
|
1014
|
+
onBottomVisibleReverse : false,
|
1015
|
+
onTopPassedReverse : false,
|
1016
|
+
onBottomPassedReverse : false,
|
1017
|
+
|
1018
|
+
// utility callbacks
|
1019
|
+
onUpdate : false, // disabled by default for performance
|
1020
|
+
onRefresh : function(){},
|
1021
|
+
|
1022
|
+
className: {
|
1023
|
+
fixed: 'fixed'
|
1024
|
+
},
|
1025
|
+
|
1026
|
+
error : {
|
1027
|
+
method : 'The method you called is not defined.'
|
1028
|
+
}
|
1029
|
+
|
1030
|
+
};
|
1031
|
+
|
1032
|
+
})( jQuery, window , document );
|