Gazelle/static/functions/collage.js

148 lines
3.5 KiB
JavaScript
Raw Normal View History

2011-03-28 14:21:28 +00:00
function Add(input) {
2013-05-04 08:00:48 +00:00
if (input.checked == false) {
2011-03-28 14:21:28 +00:00
Cancel();
} else {
2013-05-16 16:15:57 +00:00
if (document.getElementById("choices").raw().value == "") {
2011-03-28 14:21:28 +00:00
document.getElementById("choices").raw().value += input.name;
} else {
document.getElementById("choices").raw().value += "|" + input.name;
}
}
}
function Cancel() {
var e=document.getElementsByTagName("input");
2013-05-04 08:00:48 +00:00
for (i = 0; i < e.length; i++) {
if (e[i].type == "checkbox") {
2013-10-24 08:01:05 +00:00
e[i].checked = false;
2011-03-28 14:21:28 +00:00
}
}
document.getElementById("choices").raw().value = "";
}
function CollageSubscribe(collageid) {
ajax.get("userhistory.php?action=collage_subscribe&collageid=" + collageid + "&auth=" + authkey, function() {
var subscribeLink = $("#subscribelink" + collageid).raw();
2013-05-04 08:00:48 +00:00
if (subscribeLink) {
2013-02-06 08:00:17 +00:00
subscribeLink.firstChild.nodeValue = subscribeLink.firstChild.nodeValue.charAt(0) == 'U'
? "Subscribe"
: "Unsubscribe";
}
});
2011-11-20 08:00:18 +00:00
}
var collageShow = {
pg:0,
pages:false,
wrap:false,
2013-05-04 08:00:48 +00:00
init:function(collagePages) {
2011-11-20 08:00:18 +00:00
this.wrap = document.getElementById('coverart');
this.pages = collagePages;
2013-05-04 08:00:48 +00:00
this.max = this.pages.length - 1;
2011-11-20 08:00:18 +00:00
},
2013-05-04 08:00:48 +00:00
selected:function() {
2011-11-20 08:00:18 +00:00
return $('.linkbox .selected').raw();
},
2013-05-04 08:00:48 +00:00
createUL:function(data) {
2011-11-20 08:00:18 +00:00
var ul = document.createElement('ul');
$(ul).add_class('collage_images');
2013-10-24 08:01:05 +00:00
ul.id = 'collage_page' + this.pg;
2011-11-20 08:00:18 +00:00
$(ul).html(data);
2013-11-10 08:00:49 +00:00
if ($.fn.tooltipster) {
$('.tooltip_interactive', ul).tooltipster({
interactive: true,
interactiveTolerance: 500,
delay: tooltip_delay,
updateAnimation: false,
maxWidth: 400
});
} else {
$('.tooltip_interactive', ul).each(function() {
if ($(this).data('title-plain')) {
$(this).attr('title', $(this).data('title-plain')).removeData('title-plain');
}
});
}
2011-11-20 08:00:18 +00:00
this.wrap.appendChild(ul);
return ul;
},
2013-10-24 08:01:05 +00:00
page:function(num, el) {
var ul = $('#collage_page' + num).raw(), s = this.selected(), covers, lists, i;
2011-11-20 08:00:18 +00:00
this.pg = num;
2013-02-22 08:00:24 +00:00
2013-05-04 08:00:48 +00:00
if (!ul) {
2011-11-20 08:00:18 +00:00
covers = this.pages[num];
2013-05-04 08:00:48 +00:00
if (covers) {
2011-11-20 08:00:18 +00:00
ul = this.createUL(covers);
}
}
2013-02-22 08:00:24 +00:00
2013-06-27 08:01:06 +00:00
$('.collage_images').ghide();
2013-02-22 08:00:24 +00:00
2013-06-17 08:01:02 +00:00
$(ul).gshow();
2013-05-04 08:00:48 +00:00
if (s) {
$(s).remove_class('selected');
}
if (el) {
$(el.parentNode).add_class('selected');
}
2013-02-22 08:00:24 +00:00
2011-11-20 08:00:18 +00:00
// Toggle the page number links
first = Math.max(0, this.pg - 2);
if (this.max - this.pg < 2) {
first = Math.max(this.max - 4, 0);
}
2014-01-18 08:01:25 +00:00
last = Math.min(first + 4, this.max);
2011-11-20 08:00:18 +00:00
for (i = 0; i < first; i++) {
2013-06-17 08:01:02 +00:00
$('#pagelink' + i).ghide();
2011-11-20 08:00:18 +00:00
}
for (i = first; i <= last; i++) {
2013-06-17 08:01:02 +00:00
$('#pagelink' + i).gshow();
2011-11-20 08:00:18 +00:00
}
for (i = last + 1; i <= this.max; i++) {
2013-06-17 08:01:02 +00:00
$('#pagelink' + i).ghide();
2011-11-20 08:00:18 +00:00
}
2013-02-22 08:00:24 +00:00
2011-11-20 08:00:18 +00:00
// Toggle the first, prev, next, and last links
if (this.pg > 0) {
$('#prevpage').remove_class('invisible');
} else {
$('#prevpage').add_class('invisible');
}
if (this.pg > 1) {
$('#firstpage').remove_class('invisible');
} else {
$('#firstpage').add_class('invisible');
}
if (this.pg < this.max) {
$('#nextpage').remove_class('invisible');
} else {
$('#nextpage').add_class('invisible');
}
if (this.pg < this.max - 1) {
$('#lastpage').remove_class('invisible');
} else {
$('#lastpage').add_class('invisible');
}
2013-02-22 08:00:24 +00:00
2011-11-20 08:00:18 +00:00
// Toggle the bar
if ((last == this.max) && (this.pg != this.max)) {
2013-06-17 08:01:02 +00:00
$('#nextbar').gshow();
2011-11-20 08:00:18 +00:00
} else {
2013-06-17 08:01:02 +00:00
$('#nextbar').ghide();
2011-11-20 08:00:18 +00:00
}
},
2013-05-04 08:00:48 +00:00
nextPage:function() {
2014-01-18 08:01:25 +00:00
this.pg = this.pg < this.max ? this.pg + 1 : this.pg;
2011-11-20 08:00:18 +00:00
this.pager();
},
2013-05-04 08:00:48 +00:00
prevPage:function() {
this.pg = this.pg > 0 ? this.pg - 1 : this.pg;
2011-11-20 08:00:18 +00:00
this.pager();
},
2013-05-04 08:00:48 +00:00
pager:function() {
2013-10-24 08:01:05 +00:00
this.page(this.pg, $('#pagelink' + this.pg).raw().firstChild);
2011-11-20 08:00:18 +00:00
}
2013-05-04 08:00:48 +00:00
};