Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

collage.js 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. function Add(input) {
  2. if (input.checked == false) {
  3. Cancel();
  4. } else {
  5. if (document.getElementById("choices").raw().value == "") {
  6. document.getElementById("choices").raw().value += input.name;
  7. } else {
  8. document.getElementById("choices").raw().value += "|" + input.name;
  9. }
  10. }
  11. }
  12. function Cancel() {
  13. var e=document.getElementsByTagName("input");
  14. for (i = 0; i < e.length; i++) {
  15. if (e[i].type == "checkbox") {
  16. e[i].checked = false;
  17. }
  18. }
  19. document.getElementById("choices").raw().value = "";
  20. }
  21. function CollageSubscribe(collageid) {
  22. ajax.get("userhistory.php?action=collage_subscribe&collageid=" + collageid + "&auth=" + authkey, function() {
  23. var subscribeLink = $("#subscribelink" + collageid).raw();
  24. if (subscribeLink) {
  25. subscribeLink.firstChild.nodeValue = subscribeLink.firstChild.nodeValue.charAt(0) == 'U'
  26. ? "Subscribe"
  27. : "Unsubscribe";
  28. }
  29. });
  30. }
  31. var collageShow = {
  32. pg:0,
  33. pages:false,
  34. wrap:false,
  35. init:function(collagePages) {
  36. this.wrap = document.getElementById('coverart');
  37. this.pages = collagePages;
  38. this.max = this.pages.length - 1;
  39. },
  40. selected:function() {
  41. return $('.linkbox .selected').raw();
  42. },
  43. createUL:function(data) {
  44. var ul = document.createElement('div');
  45. $(ul).add_class('collage_images');
  46. ul.id = 'collage_page' + this.pg;
  47. $(ul).html(data);
  48. if ($.fn.tooltipster) {
  49. $('.tooltip_interactive', ul).tooltipster({
  50. interactive: true,
  51. interactiveTolerance: 500,
  52. delay: tooltip_delay,
  53. updateAnimation: false,
  54. maxWidth: 400
  55. });
  56. } else {
  57. $('.tooltip_interactive', ul).each(function() {
  58. if ($(this).data('title-plain')) {
  59. $(this).attr('title', $(this).data('title-plain')).removeData('title-plain');
  60. }
  61. });
  62. }
  63. this.wrap.appendChild(ul);
  64. return ul;
  65. },
  66. page:function(num, el) {
  67. var ul = $('#collage_page' + num).raw(), s = this.selected(), covers, lists, i;
  68. this.pg = num;
  69. if (!ul) {
  70. covers = this.pages[num];
  71. if (covers) {
  72. ul = this.createUL(covers);
  73. }
  74. }
  75. $('.collage_images').ghide();
  76. $(ul).gshow();
  77. if (s) {
  78. $(s).remove_class('selected');
  79. }
  80. if (el) {
  81. $(el.parentNode).add_class('selected');
  82. }
  83. /*
  84. wall = new freewall(ul)
  85. wall.reset({
  86. selector: '.collage_image',
  87. cellW: 150,
  88. cellH: 'auto',
  89. gutterX: 2,
  90. gutterY: 2
  91. })
  92. var cells = wall.container.find('.collage_image')
  93. cells.find('img').load(function(){wall.fitWidth()})
  94. */
  95. $('.collage_image img').load(function() {
  96. var test = true;
  97. $('.collage_image img').toArray().forEach(function(el) {
  98. if (!el.complete) test = false
  99. })
  100. if (test) wall('.collage_images', '.collage_image', 4)
  101. })
  102. console.log('fired')
  103. wall('.collage_images', '.collage_image', 4)
  104. // Toggle the page number links
  105. first = Math.max(0, this.pg - 2);
  106. if (this.max - this.pg < 2) {
  107. first = Math.max(this.max - 4, 0);
  108. }
  109. last = Math.min(first + 4, this.max);
  110. for (i = 0; i < first; i++) {
  111. $('#pagelink' + i).ghide();
  112. }
  113. for (i = first; i <= last; i++) {
  114. $('#pagelink' + i).gshow();
  115. }
  116. for (i = last + 1; i <= this.max; i++) {
  117. $('#pagelink' + i).ghide();
  118. }
  119. // Toggle the first, prev, next, and last links
  120. if (this.pg > 0) {
  121. $('#prevpage').remove_class('invisible');
  122. } else {
  123. $('#prevpage').add_class('invisible');
  124. }
  125. if (this.pg > 1) {
  126. $('#firstpage').remove_class('invisible');
  127. } else {
  128. $('#firstpage').add_class('invisible');
  129. }
  130. if (this.pg < this.max) {
  131. $('#nextpage').remove_class('invisible');
  132. } else {
  133. $('#nextpage').add_class('invisible');
  134. }
  135. if (this.pg < this.max - 1) {
  136. $('#lastpage').remove_class('invisible');
  137. } else {
  138. $('#lastpage').add_class('invisible');
  139. }
  140. // Toggle the bar
  141. if ((last == this.max) && (this.pg != this.max)) {
  142. $('#nextbar').gshow();
  143. } else {
  144. $('#nextbar').ghide();
  145. }
  146. },
  147. nextPage:function() {
  148. this.pg = this.pg < this.max ? this.pg + 1 : this.pg;
  149. this.pager();
  150. },
  151. prevPage:function() {
  152. this.pg = this.pg > 0 ? this.pg - 1 : this.pg;
  153. this.pager();
  154. },
  155. pager:function() {
  156. this.page(this.pg, $('#pagelink' + this.pg).raw().firstChild);
  157. }
  158. };