-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
executable file
·146 lines (108 loc) · 3.38 KB
/
index.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
//allTags definito in index.php
$(function() {
var tags$ = $('#tags'),
boxes$ = $(".box");
var locationTags = location.hash ? $.unique(location.hash.split('#')[1].split(',')) : [];
var allTagsFalse = true;
var allTagsFalseFade = true,
findappssize = $('#findapps').attr('size'),
findlabel = 'search by title...';
function checkAllTagsFalse() //se tutti i tag sono disattivi mostra tutto!
{
var allFalse = true;
for(var t in allTags)
if(allTags[t])
allFalse = false;
allTagsFalse = allFalse;
}
function filterBox(box$, active)
{
if(active)
{
if(box$.parent().is('#deactives'))
box$.fadeOut('fast',function() { box$.appendTo('#actives').fadeIn('slow'); });
}else{
if(box$.parent().is('#actives'))
box$.fadeOut('fast',function() { box$.appendTo('#deactives').fadeIn('slow'); });
}
}
function filterBoxesForTags() //mostra/nasconde box che hanno/non hanno tag tra quelli attivi
{
boxes$.each(function() {
var boxTags = $(this).data('tags').split(',');
//i tags del box
var active = false;
for(var t in boxTags)
if(allTags[boxTags[t]])
active = true;
//se il tag e' tra quell attivi show=true senno show RIMANE INVARIATO al valore precedente
if(allTagsFalse) //se tutti i tags sono disattivi non filtra nulla! e li mostra tutti
active = true;
filterBox($(this), active);
});//*/
}
function filterBoxesForTitle(tit) //nasconde i box tra quelli attivi che non contengono tit nel titolo
{
boxes$.each(function() {
var boxTitle = $(this).data('title');
var reg = new RegExp(tit,'ig');
var hastit = boxTitle.search(reg)>-1;
if( $(this).parent().attr('id')=='actives' )
filterBox($(this),hastit);
});
}
$('article').on('click', '.tag', function(e) {
e.preventDefault();
var tag = $(this).children('span').text();
allTags[tag] = allTags[tag] ? 0 : 1;
if(allTags[tag])
locationTags.push(tag);
else
locationTags.splice(locationTags.indexOf(tag),1);
checkAllTagsFalse(); //se tutti i tag sono disattivi mostra tutto!
filterBoxesForTags();
$(".tag[href='#"+tag+"']").toggleClass('sel');
if(locationTags.length>0) {
window.location.hash = $.unique(locationTags).join();
}
});
$('#findapps') // Ricerca tags
.on('keyup', function() {
var t = $(this).val();
if(t.length<1) {
checkAllTagsFalse(); //se tutti i tag sono disattivi mostra tutto!
filterBoxesForTags();
//mostra tutte le apps!!!
//boxes$.fadeTo(0,1);
return false;
}
if(t.length > parseInt(findappssize))
$(this).attr('size',t.length+1);
filterBoxesForTitle(t);
//nasconde le apps che non contengono la parola!!
})
.on('click',function() {
$(this).removeClass('inactive').val('');
})
.on('blur', function() {
tf = setTimeout(function() { //senza non funziona il link agli album nell'albero
checkAllTagsFalse(); //se tutti i tag sono disattivi mostra tutto!
filterBoxesForTags();
//mostra tutte le apps!!!
//boxes$.fadeTo(0,1);
},500);
$(this).addClass('inactive').val(findlabel).attr('size',findappssize);
})
.addClass('inactive').val(findlabel);
for(var t in locationTags)
{
var tag = locationTags[t];
allTags[tag] = 1;
$(".tag[href='#"+tag+"']").addClass('sel');
}
checkAllTagsFalse();
filterBoxesForTags();
setTimeout(()=>{
$('h1').addClass('hover')
},2000)
});