-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.js
164 lines (129 loc) · 4.73 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
$(document).ready(function(){
// Only for the demo
$('#reload').on('click', function(e){
$('.hierarchical-timing > *').css('transform', 'scale(0)');
setTimeout(function(){
$('.hierarchical-timing > *').css('transform', 'scale(1)');
}, 3500)
});
function closeToggle(){
$('[data-action="close-toggle"]').on('click', function(e){
var $this = $(this);
var panel = $this.closest('.part').find('.toggle');
panel.toggleClass('open');
if($this.hasClass('material-btn-blue')){
$this.removeClass('material-btn-blue').addClass('material-btn-red').text('close');
}
else{
$this.removeClass('material-btn-red').addClass('material-btn-blue').text('open');
}
})
}
function download(){
var css = $.ajax({
type: "HEAD",
url: "styles/main.min.css",
success: function(msg){
$('#download').attr('data-size-css',(css.getResponseHeader('Content-Length')[0] + css.getResponseHeader('Content-Length')[1]) );
}
});
var js = $.ajax({
type: "HEAD",
url: "scripts/framaterial.min.js",
success: function(msg){
$('#download').attr('data-size-js', (js.getResponseHeader('Content-Length')[0] + js.getResponseHeader('Content-Length')[1]) );
}
});
setTimeout(function(){
var numOne = $('#download').attr('data-size-css');
var numTwo = $('#download').attr('data-size-js');
var res = parseInt(numOne) + parseInt(numTwo);
$('#download ~ .tooltip_content').empty().append( res + 'Ko')
}, 150)
}
// function detectGithub(){
// var pathArray = window.location.href.split( '/' );
// var protocol = pathArray[0];
// var host = pathArray[2];
// var url = protocol + '//' + host;
// var url = url.replace('http://lukyvj.','');
// var url = url.replace('.io','');
// if(url == 'github'){
// $('body').attr('data-host','github')
// }
// }
// detectGithub()
function activeSideNav(){
var pageTitle = jQuery(location).attr('href');
var pageTitle = pageTitle.split('/');
var pageTitle = pageTitle[3].replace('.html','');
var pageTitle = pageTitle.replace('#','');
var backColor = $("[class*='sidebar']").attr('background')
$("[class*='sidebar'] ul li a[href*='"+pageTitle+"']").parent().css({
'background':'rgba(255,255,255,.2)'
})
$("[class*='sidebar'] ul li a[href*='"+pageTitle+"']").css({
'color': backColor + '!important'
})
}
function toggleComponents(){
var trig = $('.navigation-side li a');
var component = $('.panel');
trig.on('click',function(){
var $this = $(this);
var c_url = $this.attr('href');
var c_url = c_url.replace('#','');
var componentSelected = $('.panel[data-component="'+ c_url +'"]');
component.removeClass('on-screen');
componentSelected.addClass('on-screen');
});
}
function sampleLinker(){
var compo_section = $('[data-linker*="on"] header h3');
var sample_root = '/examples/';
compo_section.each(function(){
var $this = $(this);
var sample = $this.text().toLowerCase();
//var sample = sample.replace('#','');
var linkToSample = ' <a href="'+sample_root+sample+'.html" class="lts material-btn-blue right">Example</a>';
$this.append(linkToSample);
});
}
function identifier(){
var elms = $('[data-component]');
elms.each(function(){
var $this = $(this);
$this.attr('id', $this.attr('data-component'));
})
}
// $('a').click(function(){
// $('html, body').animate({
// scrollTop: $( $.attr(this, 'href') ).offset().top
// }, 500);
// return false;
// });
if(window.location.href.indexOf("examples") > -1) {
$('header').addClass('documentation')
}
function appendAboutModal(){
var modalStr = '<div class="m-card bit-2 off-screen" data-type="main-modal" data-background-text="about" data-background-color="#03a9f4" data-curtain="true" data-depth="4" id="about"><header data-background></header><section class="inner__card"><h2 class="title">Framaterial V0.1 (RC.1.3)</h2><p>Framaterial - A Framework to create Material Design projects </p><ul><li>Creation : <code>Decemember 3 2014</code></li><li>Author : <code>@LukyVj</code></li><li>Contributions : <code>@Dervonderbengen</code></li><li>On Github : <code>ramaterial.github.io/framaterial</code></li></ul></section><footer><a href="#" data-btn-type="toggle" class="material-btn-flat-black">Cancel</a><a href="#" class="material-btn-flat-lightblue">Ok</a></footer></div>';
$('.material-design-layout').append(modalStr);
}
function removeShrunk(){
setTimeout(function(){
$('.demo .sub-navigation').attr('style', '').removeClass('shrunked')
}, 05)
$('*').on('click', function(){
setTimeout(function(){
$('.demo .sub-navigation').attr('style', '').removeClass('shrunked')
}, 001)
})
}
toggleComponents()
closeToggle()
download()
sampleLinker()
identifier()
appendAboutModal()
removeShrunk();
});