| author | Anthony Ly <anthonyly.com@gmail.com> |
| Tue, 25 Jun 2013 16:38:25 +0200 | |
| changeset 146 | 6691086f43fd |
| parent 138 | f694df1f57a6 |
| child 155 | 551ae48cdf0b |
| 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'); |
|
146
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
84 |
enabledDisplayKeyword(li, keyword, iconAction); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
85 |
|
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
86 |
ul.find('li').each(function(k, v){ |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
87 |
if(index != k){ |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
88 |
var displayKeyword = $(v).find('.display-keyword'), |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
89 |
iconAction = $(v).find('.icon-action'), |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
90 |
keyword = displayKeyword.attr('data-keyword'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
91 |
disabledDisplayKeyword($(v), keyword, iconAction); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
92 |
} |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
93 |
}); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
94 |
}); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
95 |
$('.icon-action').bind('click', function(e){ |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
96 |
e.preventDefault(); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
97 |
var li = $(this).parents('li'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
98 |
toggleDisplayKeyword(li); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
99 |
}); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
100 |
function toggleDisplayKeyword(li){ |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
101 |
var displayKeyword = li.find('.display-keyword'), |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
102 |
iconAction = li.find('.icon-action'), |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
103 |
keyword = displayKeyword.attr('data-keyword'); |
| 138 | 104 |
if(li.hasClass('disabled')){ |
|
146
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
105 |
enabledDisplayKeyword(li, keyword, iconAction); |
| 138 | 106 |
}else{ |
|
146
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
107 |
disabledDisplayKeyword(li, keyword, iconAction); |
| 138 | 108 |
} |
|
146
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
109 |
} |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
110 |
function enabledDisplayKeyword(li, keyword, iconAction){ |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
111 |
iconAction.removeClass('cross').removeClass('circle'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
112 |
li.removeClass('disabled'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
113 |
$('li.keyword-'+keyword).find('.curtain').hide(); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
114 |
iconAction.addClass('cross'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
115 |
} |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
116 |
function disabledDisplayKeyword(li, keyword, iconAction){ |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
117 |
iconAction.removeClass('cross').removeClass('circle'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
118 |
li.addClass('disabled'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
119 |
$('li.keyword-'+keyword).find('.curtain').show(); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
120 |
iconAction.addClass('circle'); |
|
6691086f43fd
update mosaic behavior
Anthony Ly <anthonyly.com@gmail.com>
parents:
138
diff
changeset
|
121 |
} |
| 128 | 122 |
|
| 115 | 123 |
});//ready |