19
19
init : function (url) {
20
20
this._container = $("#user-video-gallery-main");
21
21
this._loader = $("#user-video-gallery-spinner");
22
this._nextPageBtn = $("#user-video-gallery-next");
23
this._prevPageBtn = $("#user-video-gallery-prev");
23
25
this._working = false;
26
28
this.url = url || Helioviewer.api;
31
this._pageSize = this._choosePageSize();
28
34
// Remote (may differ from local due to deleted videos, etc)
39
this._setupEventHandlers();
33
40
this._fetchVideos();
35
42
// Auto-refresh every couple minutes
44
51
* Updates video gallery to show new entries
46
53
_updateGallery: function () {
47
this._buildHTML(this._videos);
54
var endIndex = Math.min(this._startIndex + this._pageSize,
57
this._buildHTML(this._videos.slice(this._startIndex, endIndex));
134
144
html += "<a target='_blank' href='" + vid.url + "' " +
135
145
"alt='video thumbnail'>" +
136
"<div id='user-video-thumbnail-container'>" +
137
"<img class='user-video-thumbnail' src='" + img + "' alt='user video thumbnail' />" +
138
"<div style='text-align: center;'>" +
146
"<div class='user-video-thumbnail-container'>" +
147
"<div style='text-align: left; margin-left: 25px;'>" +
139
148
when + "</div>" +
149
"<img src='" + img + "' alt='user video thumbnail' />" +
140
150
"</div></a><br />";
146
156
this._loader.hide();
147
157
this._container.append(html);
158
//this._container.fadeIn();
149
160
this._working = false;
164
* Go to the previous page
166
_prevPage: function () {
171
if (this._startIndex + this._pageSize < this._videos.length) {
172
this._startIndex += this._pageSize;
173
this._updateGallery();
180
* Go to the next page
182
_nextPage: function () {
187
if (this._startIndex > 0) {
188
this._startIndex = Math.max(0, this._startIndex - this._pageSize);
189
this._updateGallery();
196
* Performs a quick check on the browser height to decide how many video
197
* thumbnails to show at once
199
_choosePageSize: function () {
200
var height = $(window).height();
204
} else if (height > 780) {
211
* Enables scrolling through video gallery pages using the mouse wheel
213
_onMouseWheelMove: function (e, delta) {
223
* Resize user video gallery to use up any available space
225
_onResize: function (e) {
226
var oldPageSize = this._pageSize;
228
// Determine new optimal pageSize
229
this._pageSize = this._choosePageSize();
231
// Don't update HTML no videos have been retrieved yet
232
if (this._videos.length === 0) {
236
// Only update HTML if the page size has changed
237
if (this._pageSize !== oldPageSize) {
238
// Expand gallery size when currently displaying last page and
240
if (this._startIndex + this._pageSize > this._videos.length) {
241
this._startIndex = this._videos.length - this._pageSize;
243
this._updateGallery();
153
248
* Hover event handler
155
250
_onVideoHover: function (event) {
159
254
$(this).find("img").removeClass("video-glow");
259
* Setup event handlers
261
_setupEventHandlers: function () {
262
this._nextPageBtn.click($.proxy(this._nextPage, this));
263
this._prevPageBtn.click($.proxy(this._prevPage, this));
265
$(window).resize($.proxy(this._onResize, this));
267
// Setup hover event handler
268
//this._container.find("a")
269
// .live('mouseover mouseout', this._onVideoHover);
271
this._container.mousewheel($.proxy(this._onMouseWheelMove, this));