materialize-sass 0.95.1

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.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +50 -0
  6. data/Rakefile +1 -0
  7. data/app/assets/fonts/material-design-icons/LICENSE.txt +428 -0
  8. data/app/assets/fonts/material-design-icons/Material-Design-Icons.eot +0 -0
  9. data/app/assets/fonts/material-design-icons/Material-Design-Icons.svg +751 -0
  10. data/app/assets/fonts/material-design-icons/Material-Design-Icons.ttf +0 -0
  11. data/app/assets/fonts/material-design-icons/Material-Design-Icons.woff +0 -0
  12. data/app/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
  13. data/app/assets/fonts/roboto/Roboto-Light.ttf +0 -0
  14. data/app/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
  15. data/app/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
  16. data/app/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
  17. data/app/assets/javascripts/materialize-sprokets.js +21 -0
  18. data/app/assets/javascripts/materialize.js +5327 -0
  19. data/app/assets/javascripts/materialize/cards.js +19 -0
  20. data/app/assets/javascripts/materialize/collapsible.js +87 -0
  21. data/app/assets/javascripts/materialize/date_picker/picker.date.js +1427 -0
  22. data/app/assets/javascripts/materialize/date_picker/picker.js +1123 -0
  23. data/app/assets/javascripts/materialize/dropdown.js +168 -0
  24. data/app/assets/javascripts/materialize/forms.js +245 -0
  25. data/app/assets/javascripts/materialize/hammer.min.js +1 -0
  26. data/app/assets/javascripts/materialize/init.js +152 -0
  27. data/app/assets/javascripts/materialize/jquery.easing.1.3.js +205 -0
  28. data/app/assets/javascripts/materialize/jquery.hammer.js +33 -0
  29. data/app/assets/javascripts/materialize/jquery.timeago.min.js +1 -0
  30. data/app/assets/javascripts/materialize/leanModal.js +96 -0
  31. data/app/assets/javascripts/materialize/materialbox.js +237 -0
  32. data/app/assets/javascripts/materialize/parallax.js +50 -0
  33. data/app/assets/javascripts/materialize/prism.js +8 -0
  34. data/app/assets/javascripts/materialize/pushpin.js +87 -0
  35. data/app/assets/javascripts/materialize/scrollspy.js +287 -0
  36. data/app/assets/javascripts/materialize/sideNav.js +278 -0
  37. data/app/assets/javascripts/materialize/slider.js +257 -0
  38. data/app/assets/javascripts/materialize/tabs.js +130 -0
  39. data/app/assets/javascripts/materialize/toasts.js +100 -0
  40. data/app/assets/javascripts/materialize/tooltip.js +167 -0
  41. data/app/assets/javascripts/materialize/velocity.min.js +4 -0
  42. data/app/assets/javascripts/materialize/waves.js +335 -0
  43. data/app/assets/stylesheets/components/_buttons.scss +111 -0
  44. data/app/assets/stylesheets/components/_cards.scss +121 -0
  45. data/app/assets/stylesheets/components/_collapsible.scss +78 -0
  46. data/app/assets/stylesheets/components/_color.scss +411 -0
  47. data/app/assets/stylesheets/components/_dropdown.scss +31 -0
  48. data/app/assets/stylesheets/components/_form.scss +641 -0
  49. data/app/assets/stylesheets/components/_global.scss +582 -0
  50. data/app/assets/stylesheets/components/_grid.scss +119 -0
  51. data/app/assets/stylesheets/components/_icons-material-design.scss +2247 -0
  52. data/app/assets/stylesheets/components/_materialbox.scss +42 -0
  53. data/app/assets/stylesheets/components/_mixins.scss +5 -0
  54. data/app/assets/stylesheets/components/_modal.scss +50 -0
  55. data/app/assets/stylesheets/components/_navbar.scss +129 -0
  56. data/app/assets/stylesheets/components/_normalize.scss +427 -0
  57. data/app/assets/stylesheets/components/_prefixer.scss +417 -0
  58. data/app/assets/stylesheets/components/_preloader.scss +320 -0
  59. data/app/assets/stylesheets/components/_roboto.scss +28 -0
  60. data/app/assets/stylesheets/components/_sideNav.scss +143 -0
  61. data/app/assets/stylesheets/components/_slider.scss +87 -0
  62. data/app/assets/stylesheets/components/_table_of_contents.scss +33 -0
  63. data/app/assets/stylesheets/components/_tabs.scss +43 -0
  64. data/app/assets/stylesheets/components/_toast.scss +64 -0
  65. data/app/assets/stylesheets/components/_tooltip.scss +34 -0
  66. data/app/assets/stylesheets/components/_typography.scss +55 -0
  67. data/app/assets/stylesheets/components/_variables.scss +128 -0
  68. data/app/assets/stylesheets/components/_waves.scss +167 -0
  69. data/app/assets/stylesheets/components/date_picker/_default.date.scss +431 -0
  70. data/app/assets/stylesheets/components/date_picker/_default.scss +201 -0
  71. data/app/assets/stylesheets/components/date_picker/_default.time.scss +125 -0
  72. data/app/assets/stylesheets/materialize.scss +38 -0
  73. data/lib/materialize-sass.rb +8 -0
  74. data/lib/materialize-sass/version.rb +6 -0
  75. data/materialize-sass.gemspec +23 -0
  76. metadata +146 -0
@@ -0,0 +1,50 @@
1
+ (function ($) {
2
+
3
+ $.fn.parallax = function () {
4
+ var window_width = $(window).width();
5
+ // Parallax Scripts
6
+ return this.each(function(i) {
7
+ var $this = $(this);
8
+ $this.addClass('parallax');
9
+
10
+ function updateParallax(initial) {
11
+ var container_height;
12
+ if (window_width < 992) {
13
+ container_height = ($this.height() > 0) ? $this.height() : $this.children("img").height();
14
+ }
15
+ else {
16
+ container_height = ($this.height() > 0) ? $this.height() : 500;
17
+ }
18
+ var img_height = $this.children("img").height();
19
+ var parallax_dist = img_height - container_height;
20
+ var bottom = $this.offset().top + container_height;
21
+ var top = $this.offset().top;
22
+ var scrollTop = $(window).scrollTop();
23
+ var windowHeight = window.innerHeight;
24
+ var windowBottom = scrollTop + windowHeight;
25
+ var percentScrolled = (windowBottom - top) / (container_height + windowHeight);
26
+ var parallax = -1 * parallax_dist * percentScrolled;
27
+
28
+ if ((bottom > scrollTop) && (top < (scrollTop + windowHeight))) {
29
+ $this.children("img").first().css('bottom', parallax + "px");
30
+ }
31
+ if (initial) {
32
+ $this.children("img").first().css('display', 'block');
33
+ }
34
+ }
35
+ updateParallax(true);
36
+
37
+ $(window).scroll(function() {
38
+ window_width = $(window).width();
39
+ updateParallax(false);
40
+ });
41
+
42
+ $(window).resize(function() {
43
+ window_width = $(window).width();
44
+ updateParallax(false);
45
+ });
46
+
47
+ });
48
+
49
+ };
50
+ }( jQuery ));
@@ -0,0 +1,8 @@
1
+ /* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+scss+bash */
2
+ self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{};var Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var a={};for(var r in e)e.hasOwnProperty(r)&&(a[r]=t.util.clone(e[r]));return a;case"Array":return e.slice()}return e}},languages:{extend:function(e,n){var a=t.util.clone(t.languages[e]);for(var r in n)a[r]=n[r];return a},insertBefore:function(e,n,a,r){r=r||t.languages;var i=r[e];if(2==arguments.length){a=arguments[1];for(var l in a)a.hasOwnProperty(l)&&(i[l]=a[l]);return i}var s={};for(var o in i)if(i.hasOwnProperty(o)){if(o==n)for(var l in a)a.hasOwnProperty(l)&&(s[l]=a[l]);s[o]=i[o]}return t.languages.DFS(t.languages,function(t,n){n===r[e]&&t!=e&&(this[t]=s)}),r[e]=s},DFS:function(e,n,a){for(var r in e)e.hasOwnProperty(r)&&(n.call(e,r,e[r],a||r),"Object"===t.util.type(e[r])?t.languages.DFS(e[r],n):"Array"===t.util.type(e[r])&&t.languages.DFS(e[r],n,r))}},highlightAll:function(e,n){for(var a,r=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'),i=0;a=r[i++];)t.highlightElement(a,e===!0,n)},highlightElement:function(a,r,i){for(var l,s,o=a;o&&!e.test(o.className);)o=o.parentNode;if(o&&(l=(o.className.match(e)||[,""])[1],s=t.languages[l]),s){a.className=a.className.replace(e,"").replace(/\s+/g," ")+" language-"+l,o=a.parentNode,/pre/i.test(o.nodeName)&&(o.className=o.className.replace(e,"").replace(/\s+/g," ")+" language-"+l);var g=a.textContent;if(g){var u={element:a,language:l,grammar:s,code:g};if(t.hooks.run("before-highlight",u),r&&self.Worker){var c=new Worker(t.filename);c.onmessage=function(e){u.highlightedCode=n.stringify(JSON.parse(e.data),l),t.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,i&&i.call(u.element),t.hooks.run("after-highlight",u)},c.postMessage(JSON.stringify({language:u.language,code:u.code}))}else u.highlightedCode=t.highlight(u.code,u.grammar,u.language),t.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,i&&i.call(a),t.hooks.run("after-highlight",u)}}},highlight:function(e,a,r){var i=t.tokenize(e,a);return n.stringify(t.util.encode(i),r)},tokenize:function(e,n){var a=t.Token,r=[e],i=n.rest;if(i){for(var l in i)n[l]=i[l];delete n.rest}e:for(var l in n)if(n.hasOwnProperty(l)&&n[l]){var s=n[l];s="Array"===t.util.type(s)?s:[s];for(var o=0;o<s.length;++o){var g=s[o],u=g.inside,c=!!g.lookbehind,f=0,h=g.alias;g=g.pattern||g;for(var p=0;p<r.length;p++){var d=r[p];if(r.length>e.length)break e;if(!(d instanceof a)){g.lastIndex=0;var m=g.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),O=[p,1];b&&O.push(b);var N=new a(l,u?t.tokenize(m,u):m,h);O.push(N),w&&O.push(w),Array.prototype.splice.apply(r,O)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("[object Array]"==Object.prototype.toString.call(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var s="";for(var o in i.attributes)s+=o+'="'+(i.attributes[o]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+s+">"+i.content+"</"+i.tag+">"},!self.document)return self.addEventListener?(self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),self.close()},!1),self.Prism):self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism);;
3
+ Prism.languages.markup={comment:/<!--[\w\W]*?-->/g,prolog:/<\?.+?\?>/,doctype:/<!DOCTYPE.+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,inside:{punctuation:/=|>|"/g}},punctuation:/\/?>/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/\&#?[\da-z]{1,8};/gi},Prism.hooks.add("wrap",function(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&amp;/,"&"))});;
4
+ Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*{))/gi,inside:{punctuation:/[;:]/g}},url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/g,property:/(\b|\B)[\w-]+(?=\s*:)/gi,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,punctuation:/[\{\};:]/g,"function":/[-a-z0-9]+(?=\()/gi},Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/<style[\w\W]*?>[\w\W]*?<\/style>/gi,inside:{tag:{pattern:/<style[\w\W]*?>|<\/style>/gi,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').+?\1/gi,inside:{"attr-name":{pattern:/^\s*style/gi,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/gi,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag));;
5
+ Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//g,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*?(\r?\n|$)/g,lookbehind:!0}],string:/("|')(\\?.)*?\1/g,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/gi,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,"function":{pattern:/[a-z0-9_]+\(/gi,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|\~|\^|\%/g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g};;
6
+ Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/g,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/g,"function":/(?!\d)[a-z0-9_$]+(?=\()/gi}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,lookbehind:!0}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/<script[\w\W]*?>[\w\W]*?<\/script>/gi,inside:{tag:{pattern:/<script[\w\W]*?>|<\/script>/gi,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}});;
7
+ Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/g,lookbehind:!0},atrule:/@[\w-]+(?=\s+(\(|\{|;))/gi,url:/([-a-z]+-)*url(?=\()/gi,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|\#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/gm}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","ignore",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/gi,"boolean":/\b(true|false)\b/g,"null":/\b(null)\b/g,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|\%)\s+/g});;
8
+ Prism.languages.bash=Prism.languages.extend("clike",{comment:{pattern:/(^|[^"{\\])(#.*?(\r?\n|$))/g,lookbehind:!0},string:{pattern:/("|')(\\?[\s\S])*?\1/g,inside:{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^\}]+\})/g}},keyword:/\b(if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)\b/g}),Prism.languages.insertBefore("bash","keyword",{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^}]+\})/g}),Prism.languages.insertBefore("bash","comment",{important:/(^#!\s*\/bin\/bash)|(^#!\s*\/bin\/sh)/g});;
@@ -0,0 +1,87 @@
1
+ (function ($) {
2
+ $(document).ready(function() {
3
+
4
+ // Unique ID
5
+ var guid = (function() {
6
+ function s4() {
7
+ return Math.floor((1 + Math.random()) * 0x10000)
8
+ .toString(16)
9
+ .substring(1);
10
+ }
11
+ return function() {
12
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
13
+ s4() + '-' + s4() + s4() + s4();
14
+ };
15
+ })();
16
+
17
+ $.fn.pushpin = function (options) {
18
+
19
+ var defaults = {
20
+ top: 0,
21
+ bottom: Infinity,
22
+ offset: 0
23
+ }
24
+ options = $.extend(defaults, options);
25
+
26
+ $index = 0;
27
+ return this.each(function() {
28
+ var $uniqueId = guid(),
29
+ $this = $(this),
30
+ $original_offset = $(this).offset().top;
31
+ // console.log(options.top, options.bottom, $(this).offset().top);
32
+
33
+ function removePinClasses(object) {
34
+ object.removeClass('pin-top');
35
+ object.removeClass('pinned');
36
+ object.removeClass('pin-bottom');
37
+ }
38
+
39
+ function updateElements(objects, scrolled) {
40
+ // console.log("OBJECTS", objects);
41
+ objects.each(function () {
42
+ // Add position fixed (because its between top and bottom)
43
+ if (options.top <= scrolled && options.bottom >= scrolled && !$(this).hasClass('pinned')) {
44
+ removePinClasses($(this));
45
+ $(this).css('top', options.offset);
46
+ $(this).addClass('pinned');
47
+ // console.log("Pinned!", $(this));
48
+ }
49
+
50
+ // Add pin-top (when scrolled position is above top)
51
+ if (scrolled < options.top && !$(this).hasClass('pin-top')) {
52
+ removePinClasses($(this));
53
+ $(this).css('top', 0);
54
+ $(this).addClass('pin-top');
55
+ // console.log("Pin Top!", $(this));
56
+ }
57
+
58
+ // Add pin-bottom (when scrolled position is below bottom)
59
+ if (scrolled > options.bottom && !$(this).hasClass('pin-bottom')) {
60
+ removePinClasses($(this));
61
+ $(this).addClass('pin-bottom');
62
+ $(this).css('top', options.bottom - $original_offset);
63
+ // console.log("Pin Bottom!", $(this));
64
+ }
65
+ });
66
+ }
67
+
68
+
69
+
70
+ updateElements($this, $(window).scrollTop());
71
+ $(window).on('scroll.' + $uniqueId, function () {
72
+ var $scrolled = $(window).scrollTop() + options.offset;
73
+ // console.log($(window).scrollTop(), $scrolled);
74
+ updateElements($this, $scrolled);
75
+ });
76
+
77
+ });
78
+
79
+
80
+
81
+ };
82
+
83
+
84
+
85
+
86
+ });
87
+ }( jQuery ));
@@ -0,0 +1,287 @@
1
+ /**
2
+ * Extend jquery with a scrollspy plugin.
3
+ * This watches the window scroll and fires events when elements are scrolled into viewport.
4
+ *
5
+ * throttle() and getTime() taken from Underscore.js
6
+ * https://github.com/jashkenas/underscore
7
+ *
8
+ * @author Copyright 2013 John Smart
9
+ * @license https://raw.github.com/thesmart/jquery-scrollspy/master/LICENSE
10
+ * @see https://github.com/thesmart
11
+ * @version 0.1.2
12
+ */
13
+ (function($) {
14
+
15
+ var jWindow = $(window);
16
+ var elements = [];
17
+ var elementsInView = [];
18
+ var isSpying = false;
19
+ var ticks = 0;
20
+ var unique_id = 1;
21
+ var offset = {
22
+ top : 0,
23
+ right : 0,
24
+ bottom : 0,
25
+ left : 0,
26
+ }
27
+
28
+ /**
29
+ * Find elements that are within the boundary
30
+ * @param {number} top
31
+ * @param {number} right
32
+ * @param {number} bottom
33
+ * @param {number} left
34
+ * @return {jQuery} A collection of elements
35
+ */
36
+ function findElements(top, right, bottom, left) {
37
+ var hits = $();
38
+ $.each(elements, function(i, element) {
39
+ if (element.height() > 0) {
40
+ var elTop = element.offset().top,
41
+ elLeft = element.offset().left,
42
+ elRight = elLeft + element.width(),
43
+ elBottom = elTop + element.height();
44
+
45
+ var isIntersect = !(elLeft > right ||
46
+ elRight < left ||
47
+ elTop > bottom ||
48
+ elBottom < top);
49
+
50
+ if (isIntersect) {
51
+ hits.push(element);
52
+ }
53
+ }
54
+ });
55
+
56
+ return hits;
57
+ }
58
+
59
+
60
+ /**
61
+ * Called when the user scrolls the window
62
+ */
63
+ function onScroll() {
64
+ // unique tick id
65
+ ++ticks;
66
+
67
+ // viewport rectangle
68
+ var top = jWindow.scrollTop(),
69
+ left = jWindow.scrollLeft(),
70
+ right = left + jWindow.width(),
71
+ bottom = top + jWindow.height();
72
+
73
+ // determine which elements are in view
74
+ // + 60 accounts for fixed nav
75
+ var intersections = findElements(top+offset.top + 200, right+offset.right, bottom+offset.bottom, left+offset.left);
76
+ $.each(intersections, function(i, element) {
77
+
78
+ var lastTick = element.data('scrollSpy:ticks');
79
+ if (typeof lastTick != 'number') {
80
+ // entered into view
81
+ element.triggerHandler('scrollSpy:enter');
82
+ }
83
+
84
+ // update tick id
85
+ element.data('scrollSpy:ticks', ticks);
86
+ });
87
+
88
+ // determine which elements are no longer in view
89
+ $.each(elementsInView, function(i, element) {
90
+ var lastTick = element.data('scrollSpy:ticks');
91
+ if (typeof lastTick == 'number' && lastTick !== ticks) {
92
+ // exited from view
93
+ element.triggerHandler('scrollSpy:exit');
94
+ element.data('scrollSpy:ticks', null);
95
+ }
96
+ });
97
+
98
+ // remember elements in view for next tick
99
+ elementsInView = intersections;
100
+ }
101
+
102
+ /**
103
+ * Called when window is resized
104
+ */
105
+ function onWinSize() {
106
+ jWindow.trigger('scrollSpy:winSize');
107
+ }
108
+
109
+ /**
110
+ * Get time in ms
111
+ * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
112
+ * @type {function}
113
+ * @return {number}
114
+ */
115
+ var getTime = (Date.now || function () {
116
+ return new Date().getTime();
117
+ });
118
+
119
+ /**
120
+ * Returns a function, that, when invoked, will only be triggered at most once
121
+ * during a given window of time. Normally, the throttled function will run
122
+ * as much as it can, without ever going more than once per `wait` duration;
123
+ * but if you'd like to disable the execution on the leading edge, pass
124
+ * `{leading: false}`. To disable execution on the trailing edge, ditto.
125
+ * @license https://raw.github.com/jashkenas/underscore/master/LICENSE
126
+ * @param {function} func
127
+ * @param {number} wait
128
+ * @param {Object=} options
129
+ * @returns {Function}
130
+ */
131
+ function throttle(func, wait, options) {
132
+ var context, args, result;
133
+ var timeout = null;
134
+ var previous = 0;
135
+ options || (options = {});
136
+ var later = function () {
137
+ previous = options.leading === false ? 0 : getTime();
138
+ timeout = null;
139
+ result = func.apply(context, args);
140
+ context = args = null;
141
+ };
142
+ return function () {
143
+ var now = getTime();
144
+ if (!previous && options.leading === false) previous = now;
145
+ var remaining = wait - (now - previous);
146
+ context = this;
147
+ args = arguments;
148
+ if (remaining <= 0) {
149
+ clearTimeout(timeout);
150
+ timeout = null;
151
+ previous = now;
152
+ result = func.apply(context, args);
153
+ context = args = null;
154
+ } else if (!timeout && options.trailing !== false) {
155
+ timeout = setTimeout(later, remaining);
156
+ }
157
+ return result;
158
+ };
159
+ };
160
+
161
+ /**
162
+ * Enables ScrollSpy using a selector
163
+ * @param {jQuery|string} selector The elements collection, or a selector
164
+ * @param {Object=} options Optional.
165
+ throttle : number -> scrollspy throttling. Default: 100 ms
166
+ offsetTop : number -> offset from top. Default: 0
167
+ offsetRight : number -> offset from right. Default: 0
168
+ offsetBottom : number -> offset from bottom. Default: 0
169
+ offsetLeft : number -> offset from left. Default: 0
170
+ * @returns {jQuery}
171
+ */
172
+ $.scrollSpy = function(selector, options) {
173
+ var visible = [];
174
+ selector = $(selector);
175
+ selector.each(function(i, element) {
176
+ elements.push($(element));
177
+ $(element).data("scrollSpy:id", i);
178
+ // Smooth scroll to section
179
+ $('a[href=#' + $(element).attr('id') + ']').click(function(e) {
180
+ e.preventDefault();
181
+ var offset = $(this.hash).offset().top + 1;
182
+
183
+ // offset-60 to handle floating fixed tab bar
184
+ if ($('.tabs-wrapper').length) {
185
+ $('html, body').animate({ scrollTop: offset-60 }, {duration: 400, easing: 'easeOutCubic'});
186
+ }
187
+ else {
188
+ $('html, body').animate({ scrollTop: offset }, {duration: 400, easing: 'easeOutCubic'});
189
+ }
190
+ });
191
+ });
192
+ options = options || {
193
+ throttle: 100
194
+ };
195
+
196
+ offset.top = options.offsetTop || 0;
197
+ offset.right = options.offsetRight || 0;
198
+ offset.bottom = options.offsetBottom || 0;
199
+ offset.left = options.offsetLeft || 0;
200
+
201
+ var throttledScroll = throttle(onScroll, options.throttle || 100);
202
+ var readyScroll = function(){
203
+ $(document).ready(throttledScroll);
204
+ };
205
+
206
+ if (!isSpying) {
207
+ jWindow.on('scroll', readyScroll);
208
+ jWindow.on('resize', readyScroll);
209
+ isSpying = true;
210
+ }
211
+
212
+ // perform a scan once, after current execution context, and after dom is ready
213
+ setTimeout(readyScroll, 0);
214
+
215
+
216
+ selector.on('scrollSpy:enter', function() {
217
+ visible = $.grep(visible, function(value) {
218
+ return value.height() != 0;
219
+ });
220
+
221
+ var $this = $(this);
222
+
223
+ if (visible[0]) {
224
+ $('a[href=#' + visible[0].attr('id') + ']').removeClass('active');
225
+ if ($this.data('scrollSpy:id') < visible[0].data('scrollSpy:id')) {
226
+ visible.unshift($(this));
227
+ }
228
+ else {
229
+ visible.push($(this));
230
+ }
231
+ }
232
+ else {
233
+ visible.push($(this));
234
+ }
235
+
236
+
237
+ $('a[href=#' + visible[0].attr('id') + ']').addClass('active');
238
+ });
239
+ selector.on('scrollSpy:exit', function() {
240
+ visible = $.grep(visible, function(value) {
241
+ return value.height() != 0;
242
+ });
243
+
244
+ if (visible[0]) {
245
+ $('a[href=#' + visible[0].attr('id') + ']').removeClass('active');
246
+ var $this = $(this);
247
+ visible = $.grep(visible, function(value) {
248
+ return value.attr('id') != $this.attr('id');
249
+ });
250
+ if (visible[0]) { // Check if empty
251
+ $('a[href=#' + visible[0].attr('id') + ']').addClass('active');
252
+ }
253
+ }
254
+ });
255
+
256
+ return selector;
257
+ };
258
+
259
+ /**
260
+ * Listen for window resize events
261
+ * @param {Object=} options Optional. Set { throttle: number } to change throttling. Default: 100 ms
262
+ * @returns {jQuery} $(window)
263
+ */
264
+ $.winSizeSpy = function(options) {
265
+ $.winSizeSpy = function() { return jWindow; }; // lock from multiple calls
266
+ options = options || {
267
+ throttle: 100
268
+ };
269
+ return jWindow.on('resize', throttle(onWinSize, options.throttle || 100));
270
+ };
271
+
272
+ /**
273
+ * Enables ScrollSpy on a collection of elements
274
+ * e.g. $('.scrollSpy').scrollSpy()
275
+ * @param {Object=} options Optional.
276
+ throttle : number -> scrollspy throttling. Default: 100 ms
277
+ offsetTop : number -> offset from top. Default: 0
278
+ offsetRight : number -> offset from right. Default: 0
279
+ offsetBottom : number -> offset from bottom. Default: 0
280
+ offsetLeft : number -> offset from left. Default: 0
281
+ * @returns {jQuery}
282
+ */
283
+ $.fn.scrollSpy = function(options) {
284
+ return $.scrollSpy($(this), options);
285
+ };
286
+
287
+ })(jQuery);
@@ -0,0 +1,278 @@
1
+ (function ($) {
2
+ // left: 37, up: 38, right: 39, down: 40,
3
+ // spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
4
+ // var keys = [32, 33, 34, 35, 36, 37, 38, 39, 40];
5
+
6
+ // function preventDefault(e) {
7
+ // e = e || window.event;
8
+ // if (e.preventDefault)
9
+ // e.preventDefault();
10
+ // e.returnValue = false;
11
+ // }
12
+
13
+ // function keydown(e) {
14
+ // for (var i = keys.length; i--;) {
15
+ // if (e.keyCode === keys[i]) {
16
+ // preventDefault(e);
17
+ // return;
18
+ // }
19
+ // }
20
+ // }
21
+
22
+ // function wheel(e) {
23
+ // preventDefault(e);
24
+ // }
25
+
26
+ // function disable_scroll() {
27
+ // if (window.addEventListener) {
28
+ // window.addEventListener('DOMMouseScroll', wheel, false);
29
+ // }
30
+ // window.onmousewheel = document.onmousewheel = wheel;
31
+ // document.onkeydown = keydown;
32
+ // $('body').css({'overflow-y' : 'hidden'});
33
+ // }
34
+
35
+ // function enable_scroll() {
36
+ // if (window.removeEventListener) {
37
+ // window.removeEventListener('DOMMouseScroll', wheel, false);
38
+ // }
39
+ // window.onmousewheel = document.onmousewheel = document.onkeydown = null;
40
+ // $('body').css({'overflow-y' : ''});
41
+
42
+ // }
43
+
44
+ var methods = {
45
+ init : function(options) {
46
+ var defaults = {
47
+ activationWidth: 70,
48
+ edge: 'left'
49
+ }
50
+ options = $.extend(defaults, options);
51
+
52
+ $(this).each(function(){
53
+ var $this = $(this);
54
+ var menu_id = $("#"+ $this.attr('data-activates'));
55
+ var menuWidth = 240;
56
+
57
+ // Add alignment
58
+ if (options.edge != 'left') {
59
+ menu_id.addClass('right-aligned');
60
+ }
61
+
62
+ // Add Touch Area
63
+ $('body').append($('<div class="drag-target"></div>'));
64
+ if (options.edge === 'left') {
65
+ $('.drag-target').css({'left': 0})
66
+ }
67
+ else {
68
+ $('.drag-target').css({'right': 0})
69
+ }
70
+
71
+ // Window resize to reset on large screens fixed
72
+ if (menu_id.hasClass('fixed')) {
73
+ $(window).resize( function() {
74
+ if ($(window).width() > 1200) {
75
+ if (menu_id.attr('style')) {
76
+ menu_id.removeAttr('style');
77
+ }
78
+ }
79
+ if ($('#sidenav-overlay').css('opacity') != 0 && menuOut) {
80
+ $('#sidenav-overlay').trigger('click');
81
+ }
82
+ });
83
+ }
84
+
85
+ function removeMenu() {
86
+ panning = false;
87
+ menuOut = false;
88
+ $('#sidenav-overlay').velocity({opacity: 0}, {duration: 200, queue: false, easing: 'easeOutQuad',
89
+ complete: function() {
90
+ $(this).remove();
91
+ } });
92
+ if (options.edge === 'left') {
93
+ // Reset phantom div
94
+ $('.drag-target').css({width: '', right: '', left: '0'});
95
+ menu_id.velocity({left: -1 * (menuWidth + 10)}, {duration: 200, queue: false, easing: 'easeOutCubic'});
96
+ }
97
+ else {
98
+ // Reset phantom div
99
+ $('.drag-target').css({width: '', right: '0', left: ''});
100
+ menu_id.velocity({right: -1 * (menuWidth + 10)}, {duration: 200, queue: false, easing: 'easeOutCubic'});
101
+ }
102
+
103
+ // enable_scroll();
104
+ }
105
+
106
+
107
+
108
+ // Touch Event
109
+ var panning = false;
110
+ var menuOut = false;
111
+
112
+ $('.drag-target').hammer({
113
+ prevent_default: false
114
+ }).bind('tap', function(e) {
115
+ // capture overlay click on drag target
116
+ // if (menuOut && !panning) {
117
+ $('#sidenav-overlay').trigger('click');
118
+ // }
119
+ }).bind('pan', function(e) {
120
+
121
+ if (e.gesture.pointerType === "touch") {
122
+
123
+ var direction = e.gesture.direction;
124
+ var x = e.gesture.center.x;
125
+ var y = e.gesture.center.y;
126
+ var velocityX = e.gesture.velocityX;
127
+
128
+ if (!$('#sidenav-overlay').length) {
129
+ var overlay = $('<div id="sidenav-overlay"></div>');
130
+ overlay.css('opacity', 0).click(function(){ removeMenu(); });
131
+ $('body').append(overlay);
132
+ }
133
+
134
+ // Keep within boundaries
135
+ if (options.edge === 'left') {
136
+ if (x > menuWidth) { x = menuWidth; }
137
+ else if (x < 0) { x = 0; }
138
+ }
139
+ else {
140
+ if (x < $(window).width() - menuWidth) { x = $(window).width() - menuWidth; }
141
+ }
142
+
143
+ if (options.edge === 'left') {
144
+ // Left Direction
145
+ if (x < (menuWidth / 2)) { menuOut = false; }
146
+ // Right Direction
147
+ else if (x >= (menuWidth / 2)) { menuOut = true; }
148
+ }
149
+ else {
150
+ // Left Direction
151
+ if (x < ($(window).width() - menuWidth / 2)) { menuOut = true; }
152
+ // Right Direction
153
+ else if (x >= ($(window).width() - menuWidth / 2)) { menuOut = false; }
154
+ }
155
+
156
+
157
+ if (options.edge === 'left') {
158
+ menu_id.css('left', (x - menuWidth));
159
+ }
160
+ else {
161
+ menu_id.css('right', -1 *(x - menuWidth / 2));
162
+ }
163
+
164
+ // Percentage overlay
165
+ if (options.edge === 'left') {
166
+ var overlayPerc = x / menuWidth;
167
+ $('#sidenav-overlay').velocity({opacity: overlayPerc }, {duration: 50, queue: false, easing: 'easeOutQuad'});
168
+ }
169
+ else {
170
+ var overlayPerc = Math.abs((x - $(window).width()) / menuWidth);
171
+ $('#sidenav-overlay').velocity({opacity: overlayPerc }, {duration: 50, queue: false, easing: 'easeOutQuad'});
172
+ }
173
+ }
174
+ }).bind('panend', function(e) {
175
+ if (e.gesture.pointerType === "touch") {
176
+ var velocityX = e.gesture.velocityX;
177
+ panning = false;
178
+
179
+ if (options.edge === 'left') {
180
+ if (menuOut || velocityX < -0.5) {
181
+ menu_id.velocity({left: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
182
+ $('#sidenav-overlay').velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
183
+ $('.drag-target').css({width: '50%', right: 0, left: ''});
184
+ }
185
+ else if (!menuOut || velocityX > 0.3) {
186
+ menu_id.velocity({left: -240}, {duration: 300, queue: false, easing: 'easeOutQuad'});
187
+ $('#sidenav-overlay').velocity({opacity: 0 }, {duration: 50, queue: false, easing: 'easeOutQuad',
188
+ complete: function () {
189
+ $(this).remove();
190
+ }});
191
+ $('.drag-target').css({width: '10%', right: '', left: 0});
192
+ }
193
+ }
194
+ else {
195
+ if (menuOut || velocityX > 0.5) {
196
+ menu_id.velocity({right: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
197
+ $('#sidenav-overlay').velocity({opacity: 1 }, {duration: 50, queue: false, easing: 'easeOutQuad'});
198
+ $('.drag-target').css({width: '50%', right: '', left: 0});
199
+ }
200
+ else if (!menuOut || velocityX < -0.3) {
201
+ menu_id.velocity({right: -240}, {duration: 300, queue: false, easing: 'easeOutQuad'});
202
+ $('#sidenav-overlay').velocity({opacity: 0 }, {duration: 50, queue: false, easing: 'easeOutQuad',
203
+ complete: function () {
204
+ $(this).remove();
205
+ }});
206
+ $('.drag-target').css({width: '10%', right: 0, left: ''});
207
+ }
208
+ }
209
+
210
+
211
+ }
212
+ });
213
+
214
+ $this.click(function() {
215
+ if (menu_id.hasClass('active')) {
216
+ menuOut = false;
217
+ panning = false;
218
+ removeMenu();
219
+ }
220
+ else {
221
+ // disable_scroll();
222
+
223
+ if (options.edge === 'left') {
224
+ $('.drag-target').css({width: '50%', right: 0, left: ''});
225
+ menu_id.velocity({left: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
226
+ }
227
+ else {
228
+ $('.drag-target').css({width: '50%', right: '', left: 0});
229
+ menu_id.velocity({right: 0}, {duration: 300, queue: false, easing: 'easeOutQuad'});
230
+ }
231
+
232
+ var overlay = $('<div id="sidenav-overlay"></div>');
233
+ overlay.css('opacity', 0)
234
+ .click(function(){
235
+ menuOut = false;
236
+ panning = false;
237
+ removeMenu();
238
+ overlay.animate({opacity: 0}, {duration: 300, queue: false, easing: 'easeOutQuad',
239
+ complete: function() {
240
+ $(this).remove();
241
+ } });
242
+
243
+ });
244
+ $('body').append(overlay);
245
+ overlay.animate({opacity: 1}, {duration: 300, queue: false, easing: 'easeOutQuad',
246
+ complete: function () {
247
+ menuOut = true;
248
+ panning = false;
249
+ }
250
+ });
251
+ }
252
+
253
+ return false;
254
+ });
255
+ });
256
+
257
+
258
+ },
259
+ show : function() {
260
+ this.trigger('click');
261
+ },
262
+ hide : function() {
263
+ $('#sidenav-overlay').trigger('click');
264
+ }
265
+ };
266
+
267
+
268
+ $.fn.sideNav = function(methodOrOptions) {
269
+ if ( methods[methodOrOptions] ) {
270
+ return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
271
+ } else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
272
+ // Default to "init"
273
+ return methods.init.apply( this, arguments );
274
+ } else {
275
+ $.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.tooltip' );
276
+ }
277
+ }; // PLugin end
278
+ }( jQuery ));