| author | Anthony Ly <anthonyly.com@gmail.com> |
| Thu, 27 Jun 2013 15:38:21 +0200 | |
| changeset 176 | 96d470b37c65 |
| parent 164 | 09ad16c9fee5 |
| child 180 | 928583c82325 |
| child 186 | 26dddb3f5804 |
| permissions | -rwxr-xr-x |
| 115 | 1 |
$(function(){ |
| 133 | 2 |
//filters |
3 |
$('.filters a').each(function(){ |
|
4 |
var text = $.trim($(this).text()); |
|
5 |
if(text.length > 30){ |
|
6 |
$(this).text(text.substr(0, 30) + '...') |
|
7 |
} |
|
8 |
}); |
|
| 119 | 9 |
//masonry |
| 132 | 10 |
var masonry465 = $('.masonry-465'); |
11 |
masonry465.masonry({ |
|
| 118 | 12 |
columnWidth: 465, |
| 132 | 13 |
itemSelector: '.item-masonry', |
| 118 | 14 |
gutter : 20 |
15 |
}); |
|
| 132 | 16 |
|
17 |
var masonry225 = $('.masonry-225'); |
|
18 |
masonry225.masonry({ |
|
19 |
columnWidth: 225, |
|
20 |
itemSelector: '.item-masonry', |
|
21 |
gutter : 16 |
|
22 |
}); |
|
| 138 | 23 |
|
24 |
function masonry177(){ |
|
25 |
var masonry177 = $('.masonry-177'); |
|
26 |
masonry177.masonry({ |
|
27 |
columnWidth: 177, |
|
28 |
itemSelector: '.item-masonry' |
|
29 |
}); |
|
30 |
} |
|
31 |
masonry177(); |
|
| 119 | 32 |
//popin |
| 131 | 33 |
$('.open-popin').bind('click', function(e){ |
| 118 | 34 |
e.preventDefault(); |
| 119 | 35 |
var target = $(this).attr('href'); |
36 |
$('.popin-wrap').fadeIn(function(){ |
|
37 |
$(target).show(); |
|
38 |
}); |
|
39 |
}); |
|
40 |
||
41 |
$('.close-popin, .popin-wrap').bind('click', function(e){ |
|
42 |
e.preventDefault(); |
|
43 |
e.stopPropagation(); |
|
44 |
$('.popin-wrap').fadeOut(function(){ |
|
45 |
$('.popin').hide(); |
|
46 |
}); |
|
47 |
}); |
|
48 |
||
49 |
$('.popin').bind('click', function(e){ |
|
50 |
e.stopPropagation(); |
|
| 118 | 51 |
}); |
| 128 | 52 |
//tag it |
| 132 | 53 |
if($('.tag-it').length){ |
54 |
var keywordsTagIt = $('.tag-it').tagit({ |
|
55 |
allowSpaces : true |
|
56 |
}); |
|
57 |
$('.list-key-add a').bind('click', function(e){ |
|
58 |
e.preventDefault(); |
|
59 |
var tag = $(this).attr('data-tag'); |
|
60 |
keywordsTagIt.tagit("createTag", tag); |
|
61 |
}); |
|
62 |
} |
|
| 138 | 63 |
//mosaic |
64 |
$('.toggle-comment').bind('click', function(e){ |
|
65 |
e.preventDefault(); |
|
66 |
$('.show-comment, .hide-comment').hide(); |
|
67 |
if($('.mosaic').length){ |
|
68 |
$('.mosaic').removeClass('mosaic').addClass('mosaic-comment'); |
|
69 |
$('.hide-comment').show(); |
|
70 |
}else{ |
|
71 |
$('.mosaic-comment').removeClass('mosaic-comment').addClass('mosaic'); |
|
72 |
$('.show-comment').show(); |
|
73 |
} |
|
74 |
masonry177(); |
|
75 |
}); |
|
| 133 | 76 |
|
| 138 | 77 |
$('.display-keyword').bind('click', function(e){ |
78 |
e.preventDefault(); |
|
|
146
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
79 |
var ul = $(this).parents('ul'), |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
80 |
li = $(this).parents('li'), |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
81 |
iconAction = li.find('.icon-action'), |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
82 |
index = li.index(), |
| 138 | 83 |
keyword = $(this).attr('data-keyword'); |
| 164 | 84 |
|
|
176
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
85 |
if(!li.hasClass('disabled') && ul.find('li.disabled').length){ |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
86 |
ul.find('li').each(function(k, v){ |
|
146
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
87 |
var displayKeyword = $(v).find('.display-keyword'), |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
88 |
iconAction = $(v).find('.icon-action'), |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
89 |
keyword = displayKeyword.attr('data-keyword'); |
|
176
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
90 |
enabledDisplayKeyword($(v), keyword, iconAction); |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
91 |
}); |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
92 |
}else{ |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
93 |
ul.find('li').each(function(k, v){ |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
94 |
if(index != k){ |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
95 |
var displayKeyword = $(v).find('.display-keyword'), |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
96 |
iconAction = $(v).find('.icon-action'), |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
97 |
keyword = displayKeyword.attr('data-keyword'); |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
98 |
disabledDisplayKeyword($(v), keyword, iconAction); |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
99 |
} |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
100 |
}); |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
101 |
enabledDisplayKeyword(li, keyword, iconAction); |
|
96d470b37c65
enabled back all mosaic
Anthony Ly <anthonyly.com@gmail.com>
parents:
164
diff
changeset
|
102 |
} |
|
146
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
103 |
}); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
104 |
$('.icon-action').bind('click', function(e){ |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
105 |
e.preventDefault(); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
106 |
var li = $(this).parents('li'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
107 |
toggleDisplayKeyword(li); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
108 |
}); |
| 164 | 109 |
/* |
|
146
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
110 |
function toggleDisplayKeyword(li){ |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
111 |
var displayKeyword = li.find('.display-keyword'), |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
112 |
iconAction = li.find('.icon-action'), |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
113 |
keyword = displayKeyword.attr('data-keyword'); |
| 138 | 114 |
if(li.hasClass('disabled')){ |
|
146
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
115 |
enabledDisplayKeyword(li, keyword, iconAction); |
| 138 | 116 |
}else{ |
|
146
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
117 |
disabledDisplayKeyword(li, keyword, iconAction); |
| 138 | 118 |
} |
|
146
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
119 |
} |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
120 |
function enabledDisplayKeyword(li, keyword, iconAction){ |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
121 |
iconAction.removeClass('cross').removeClass('circle'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
122 |
li.removeClass('disabled'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
123 |
$('li.keyword-'+keyword).find('.curtain').hide(); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
124 |
iconAction.addClass('cross'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
125 |
} |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
126 |
function disabledDisplayKeyword(li, keyword, iconAction){ |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
127 |
iconAction.removeClass('cross').removeClass('circle'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
128 |
li.addClass('disabled'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
129 |
$('li.keyword-'+keyword).find('.curtain').show(); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
130 |
iconAction.addClass('circle'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
131 |
} |
| 164 | 132 |
*/ |
133 |
function toggleDisplayKeyword(li){ |
|
134 |
var displayKeyword = li.find('.display-keyword'), |
|
135 |
iconAction = li.find('.icon-action'), |
|
136 |
keyword = displayKeyword.attr('data-keyword'); |
|
137 |
if(li.hasClass('disabled')){ |
|
138 |
enabledDisplayKeyword(li, keyword, iconAction); |
|
139 |
}else{ |
|
140 |
disabledDisplayKeyword(li, keyword, iconAction); |
|
141 |
} |
|
142 |
} |
|
143 |
function enabledDisplayKeyword(li, keyword, iconAction){ |
|
144 |
iconAction.removeClass('cross').removeClass('circle'); |
|
145 |
li.removeClass('disabled'); |
|
146 |
$('ul.mosaic > li').each(function(k, v){ |
|
147 |
||
148 |
var keywords = $(v).attr('data-keywords'), |
|
149 |
item = $(v); |
|
150 |
keywords = keywords.split(','); |
|
151 |
for(var i=0; i<= keywords.length; i++){ |
|
152 |
if($.trim(keywords[i]) == keyword){ |
|
153 |
item.find('.curtain').hide(); |
|
154 |
} |
|
155 |
} |
|
156 |
}); |
|
157 |
$('li.keyword-'+keyword).find('.curtain').hide(); |
|
158 |
iconAction.addClass('cross'); |
|
159 |
} |
|
160 |
function disabledDisplayKeyword(li, keyword, iconAction){ |
|
161 |
iconAction.removeClass('cross').removeClass('circle'); |
|
162 |
li.addClass('disabled'); |
|
163 |
$('ul.mosaic > li').each(function(k, v){ |
|
164 |
||
165 |
var keywords = $(v).attr('data-keywords'), |
|
166 |
item = $(v); |
|
167 |
keywords = keywords.split(','); |
|
168 |
for(var i=0; i<= keywords.length; i++){ |
|
169 |
if($.trim(keywords[i]) == keyword){ |
|
170 |
item.find('.curtain').show(); |
|
171 |
} |
|
172 |
} |
|
173 |
}); |
|
174 |
iconAction.addClass('circle'); |
|
175 |
} |
|
| 155 | 176 |
//map |
177 |
if($('#map').length){ |
|
| 160 | 178 |
initmap() |
| 155 | 179 |
} |
| 160 | 180 |
function initmap() { |
181 |
// set up the map |
|
182 |
map = new L.Map('map'); |
|
183 |
||
184 |
// create the tile layer with correct attribution |
|
185 |
var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; |
|
186 |
var osm = new L.TileLayer(osmUrl, {minZoom: 3, maxZoom: 20}); |
|
187 |
||
188 |
// start the map in South-East England |
|
189 |
map.setView(new L.LatLng(48.833, 2.333),4); |
|
190 |
map.addLayer(osm); |
|
191 |
||
192 |
// markers |
|
193 |
var marker1 = L.marker([48.833, 2.333]).addTo(map); |
|
194 |
marker1.bindPopup("Beaux-Arts de Paris"); |
|
195 |
var marker2 = L.marker([47.233,-1.583]).addTo(map); |
|
196 |
marker2.bindPopup("Beaux-Arts de Nantes"); |
|
197 |
} |
|
198 |
||
| 115 | 199 |
});//ready |