1 | (function($){
|
2 | $(function(){
|
3 |
|
4 | var window_width = $(window).width();
|
5 |
|
6 |
|
7 | function rgb2hex(rgb) {
|
8 | if (/^#[0-9A-F]{6}$/i.test(rgb)) { return rgb; }
|
9 |
|
10 | rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
11 |
|
12 | if (rgb === null) { return "N/A"; }
|
13 |
|
14 | function hex(x) {
|
15 | return ("0" + parseInt(x).toString(16)).slice(-2);
|
16 | }
|
17 |
|
18 | return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
|
19 | }
|
20 |
|
21 | $('.dynamic-color .col').each(function () {
|
22 | $(this).children().each(function () {
|
23 | var color = $(this).css('background-color'),
|
24 | classes = $(this).attr('class');
|
25 | $(this).html(rgb2hex(color) + " " + classes);
|
26 | if (classes.indexOf("darken") >= 0 || $(this).hasClass('black')) {
|
27 | $(this).css('color', 'rgba(255,255,255,.9');
|
28 | }
|
29 | });
|
30 | });
|
31 |
|
32 |
|
33 |
|
34 | if ($('nav').length) {
|
35 | $('.toc-wrapper').pushpin({ top: $('nav').height() });
|
36 | }
|
37 | else if ($('#index-banner').length) {
|
38 | $('.toc-wrapper').pushpin({ top: $('#index-banner').height() });
|
39 | }
|
40 | else {
|
41 | $('.toc-wrapper').pushpin({ top: 0 });
|
42 | }
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | var $bsa = $(".buysellads"),
|
48 | $timesToCheck = 3;
|
49 | function checkForChanges() {
|
50 | if (!$bsa.find('#carbonads').length) {
|
51 | $timesToCheck -= 1;
|
52 | if ($timesToCheck >= 0) {
|
53 | setTimeout(checkForChanges, 500);
|
54 | }
|
55 | else {
|
56 | var donateAd = $('<div id="carbonads"><span><a class="carbon-text" href="#!" onclick="document.getElementById(\'paypal-donate\').submit();"><img src="images/donate.png" /> Help support us by turning off adblock. If you still prefer to keep adblock on for this page but still want to support us, feel free to donate. Any little bit helps.</a></form></span></div>');
|
57 |
|
58 | $bsa.append(donateAd);
|
59 | }
|
60 | }
|
61 |
|
62 | }
|
63 | checkForChanges();
|
64 |
|
65 |
|
66 |
|
67 | if ($('.github-commit').length) {
|
68 | $.ajax({
|
69 | url: "https://api.github.com/repos/dogfalo/materialize/commits/master",
|
70 | dataType: "json",
|
71 | success: function (data) {
|
72 | var sha = data.sha,
|
73 | date = jQuery.timeago(data.commit.author.date);
|
74 | if (window_width < 1120) {
|
75 | sha = sha.substring(0,7);
|
76 | }
|
77 | $('.github-commit').find('.date').html(date);
|
78 | $('.github-commit').find('.sha').html(sha).attr('href', data.html_url);
|
79 | }
|
80 | });
|
81 | }
|
82 |
|
83 |
|
84 | var toggleFlowTextButton = $('#flow-toggle');
|
85 | toggleFlowTextButton.click( function(){
|
86 | $('#flow-text-demo').children('p').each(function(){
|
87 | $(this).toggleClass('flow-text');
|
88 | });
|
89 | });
|
90 |
|
91 |
|
92 | var toggleContainersButton = $('#container-toggle-button');
|
93 | toggleContainersButton.click(function(){
|
94 | $('body .browser-window .container, .had-container').each(function(){
|
95 | $(this).toggleClass('had-container');
|
96 | $(this).toggleClass('container');
|
97 | if ($(this).hasClass('container')) {
|
98 | toggleContainersButton.text("Turn off Containers");
|
99 | }
|
100 | else {
|
101 | toggleContainersButton.text("Turn on Containers");
|
102 | }
|
103 | });
|
104 | });
|
105 |
|
106 |
|
107 | function is_touch_device() {
|
108 | try {
|
109 | document.createEvent("TouchEvent");
|
110 | return true;
|
111 | } catch (e) {
|
112 | return false;
|
113 | }
|
114 | }
|
115 | if (is_touch_device()) {
|
116 | $('#nav-mobile').css({ overflow: 'auto'});
|
117 | }
|
118 |
|
119 |
|
120 | var indeterminateCheckbox = document.getElementById('indeterminate-checkbox');
|
121 | if (indeterminateCheckbox !== null)
|
122 | indeterminateCheckbox.indeterminate = true;
|
123 |
|
124 |
|
125 |
|
126 | $('.slider').slider({full_width: true});
|
127 | $('.parallax').parallax();
|
128 | $('.modal-trigger').leanModal();
|
129 | $('.scrollspy').scrollSpy();
|
130 | $('.button-collapse').sideNav({'edge': 'left'});
|
131 | $('.datepicker').pickadate({selectYears: 20});
|
132 | $('select').not('.disabled').material_select();
|
133 |
|
134 |
|
135 | });
|
136 | })(jQuery);
|