Revision 3158d6f6 cloudcmsresources/static/cloudcmsresources/js/resources_list.js
b/cloudcmsresources/static/cloudcmsresources/js/resources_list.js | ||
---|---|---|
26 | 26 |
|
27 | 27 |
var self = this; |
28 | 28 |
$(window).bind('hashchange', function() { |
29 |
//self.selected_category = window.location.hash.substring(1); |
|
30 |
//self.update_page_objects(); |
|
29 |
self.selected_category = window.location.hash.substring(1); |
|
30 |
self.update_page_objects(); |
|
31 |
self.update_selected_category(); |
|
31 | 32 |
}) |
33 |
|
|
34 |
self.update_page_objects(); |
|
35 |
self.update_selected_category(); |
|
32 | 36 |
} |
33 | 37 |
|
34 | 38 |
ResourcesModule.prototype.switch = function(hide, show) { |
... | ... | |
42 | 46 |
}, |
43 | 47 |
{ |
44 | 48 |
complete:function(){ |
45 |
console.log("complete"); |
|
46 | 49 |
hide.remove(); |
47 | 50 |
newshow.css({top:0}); |
48 | 51 |
} |
... | ... | |
82 | 85 |
$(el).show(); |
83 | 86 |
} |
84 | 87 |
|
88 |
ResourcesModule.prototype.update_selected_category = function() { |
|
89 |
if (!this.selected_category) { |
|
90 |
this.categories.removeClass("inactive").removeClass("active"); |
|
91 |
} |
|
92 |
|
|
93 |
var to_hide = this.categories.filter("[data-id="+this.selected_category+"]"); |
|
94 |
var to_show = this.categories.filter("[data-id!="+this.selected_category+"]"); |
|
95 |
|
|
96 |
to_show.removeClass("active").addClass("inactive"); |
|
97 |
to_hide.removeClass("inactive").addClass("active"); |
|
98 |
} |
|
99 |
|
|
85 | 100 |
ResourcesModule.prototype.update_page_objects = function() { |
86 | 101 |
var to_show = this.resources().filter("[data-category="+this.selected_category+"]"); |
87 | 102 |
var to_hide = this.resources().filter("[data-category!="+this.selected_category+"]"); |
88 | 103 |
|
89 | 104 |
if (!this.selected_category) { to_show = this.resources(); } |
90 | 105 |
_.each(to_hide, function(el){ |
91 |
$(el).fadeOut(100); |
|
106 |
$(el).hide(); |
|
107 |
}); |
|
108 |
|
|
109 |
_.each(to_show, function(el, i){ |
|
110 |
if (i%3 == 0) { |
|
111 |
$(el).addClass("first"); |
|
112 |
} else { |
|
113 |
$(el).removeClass("first"); |
|
114 |
} |
|
115 |
$(el).fadeIn(40); |
|
92 | 116 |
}); |
93 |
|
|
94 |
var delay = this.selected_category ? 40 : 0; |
|
95 |
var self = this; |
|
96 |
window.setTimeout(function(){ |
|
97 |
_.each(to_show, function(el, i) { |
|
98 |
var new_main_height = (self.grid_height + self.grid_gap) * (Math.floor(to_show.length/3) + 1); |
|
99 |
if (self.el.height() < new_main_height) { |
|
100 |
self.el.height(new_main_height); |
|
101 |
} |
|
102 |
}) |
|
103 |
self.animate_els(to_show); |
|
104 |
}, delay) |
|
105 | 117 |
} |
106 | 118 |
|
107 | 119 |
$(document).ready(function(){ |
Also available in: Unified diff