-
Notifications
You must be signed in to change notification settings - Fork 0
/
design.js
190 lines (158 loc) · 4.75 KB
/
design.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/**
* Polaris
*/
var Design = {
bindKeys : function() {
Cargo.Core.KeyboardShortcut.Add("Left", 37, function() {
Action.Project.Prev();
return false;
});
Cargo.Core.KeyboardShortcut.Add("Right", 39, function() {
Action.Project.Next();
return false;
});
},
hoverProject: function() {
// Thumbnail hover
$(".thumbnails")
.on("mouseenter", ".project_thumb", function(e) {
$(".project_link[data-id='" + $(this).attr("data-id") +"'] a").addClass("hover");
})
.on("mouseleave", ".project_thumb", function(e) {
$(".project_link[data-id='" + $(this).attr("data-id") +"'] a").removeClass("hover");
});
// Navigation
$(".navigation")
.on("mouseenter", ".project_link a", function(e) {
$(".project_thumb[data-id='" + $(this).closest('.project_link').attr("data-id") +"']").addClass("hover");
})
.on("mouseleave", ".project_link a", function(e) {
$(".project_thumb[data-id='" + $(this).closest('.project_link').attr("data-id") +"']").removeClass("hover");
});
},
checkNavigationHeight: function() {
var navigation = $(".navigation");
if (navigation.length > 0) {
if (navigation.height() + navigation.position().top > $(window).height()) {
if (!navigation.hasClass("scroll")) {
navigation.add(".site_header").removeClass("fixed").addClass("scroll");
}
} else {
if (!navigation.hasClass("fixed")) {
navigation.add(".site_header").removeClass("scroll").addClass("fixed");
}
}
}
},
checkSetVisibility: function() {
// Find the active set based on the project ID
var parentSet = $("[data-setid='" + Cargo.Model.Project.GetSetId() + "']"),
otherSets = $("[data-setid]").not(parentSet);
// If the set exists, set active/inactive
if (parentSet.length > 0) {
otherSets.removeClass("active").addClass("inactive");
parentSet.removeClass("inactive").addClass("active");
// Show the footer link
$(".set_footer").show();
} else {
$(".set_footer").hide();
}
},
checkSetSpacing: function() {
$(".set_link").removeClass("first-set last-set spacer");
var first_set = $(".set_link:first"),
last_set = $(".set_link:last");
first_set.addClass("first-set");
last_set.addClass("last-set");
if (Cargo.Model.DisplayOptions.attributes.use_set_links) {
var setLinksPosition = Cargo.Model.DisplayOptions.GetSetLinksPosition();
if (first_set.attr("id") == last_set.attr("id")) {
// Only one set
if (setLinksPosition == "top") {
last_set.addClass("spacer").removeClass("first-set");
} else if (setLinksPosition == "bottom") {
first_set.addClass("spacer");
}
} else {
if (setLinksPosition == "top") {
last_set.addClass("spacer");
} else if (setLinksPosition == "bottom") {
first_set.add(last_set).addClass("spacer");
}
}
}
}
};
/**
* Events
*/
$(function() {
Cargo.Core.ReplaceLoadingAnims.init();
Design.bindKeys();
Design.hoverProject();
Design.checkSetSpacing();
Design.checkNavigationHeight();
});
// Window Resize
$(window).resize(function() {
Design.checkNavigationHeight();
});
// Project Load Complete
Cargo.Event.on("project_load_complete", function(pid) {
Design.checkSetVisibility();
/*
* Move the project navigation if the default image width is > 670px.
*/
var defaultImageWidth = parseInt(Cargo.Model.DisplayOptions.GetImageWidth());
if (defaultImageWidth < 670) {
defaultImageWidth = 670;
}
defaultImageWidth += 305;
$(".project_navigation").css("left", defaultImageWidth + "px");
});
// Project Close Complete
Cargo.Event.on("show_index_complete", function(pid) {
setTimeout(function() {
// Reset sets
$("[data-setid]").removeClass("active inactive");
$(".set_footer").hide();
}, 20);
});
Cargo.Event.on("navigation_reset", function(new_page) {
Design.checkSetSpacing();
});
Cargo.Event.on("navigation_set_toggle", function() {
Design.checkNavigationHeight();
});
// Pagination
Cargo.Event.on("pagination_complete", function(new_page) {
Design.checkSetVisibility();
Design.checkSetSpacing();
window.setTimeout(function() {
Design.checkNavigationHeight();
}, 10);
});
Cargo.Event.on("project_collection_reset", function(new_page) {
Design.checkSetVisibility();
Design.checkSetSpacing();
window.setTimeout(function() {
Design.checkNavigationHeight();
}, 10);
});
Cargo.Event.on("fullscreen_destroy_hotkeys", function() {
Design.bindKeys();
});
/**
* Typography
*/
WebFontConfig = {
google: { families: ["Istok+Web:400,700,400italic,700italic:latin"] }
};
(function() {
var wf = document.createElement("script");
wf.src = ("https:" == document.location.protocol ? "https" : "http") + "://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js";
wf.type = "text/javascript";
wf.async = "true";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(wf, s);
})();