Guest User

Untitled

a guest
Jan 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.01 KB | None | 0 0
  1. var TINY = {};
  2.  
  3. function tid(i) {
  4. return document.getElementById(i)
  5. }
  6.  
  7. function tag(e, p) {
  8. p = p || document;
  9. return p.getElementsByTagName(e)
  10. }
  11. TINY.sgpro_slideshow = function(n) {
  12. this.infoSpeed = this.imgSpeed = this.speed = 10;
  13. this.thumbOpacity = this.navHover = 70;
  14. this.navOpacity = 25;
  15. this.scrollSpeed = 5;
  16. this.letterbox = '#000';
  17. this.n = n;
  18. this.c = 0;
  19. this.a = []
  20. };
  21. TINY.sgpro_slideshow.prototype = {
  22. init: function(s, z, b, f, q) {
  23. s = tid(s);
  24. var m = tag('li', s),
  25. i = 0,
  26. w = 0;
  27. this.l = m.length;
  28. this.q = tid(q);
  29. this.f = tid(z);
  30. this.r = tid(this.info);
  31. this.oh = parseInt(TINY.style.val(z, 'height'));
  32. this.o = parseInt(TINY.style.val(z, 'width'));
  33. if (this.thumbs) {
  34. var u = tid(this.left),
  35. r = tid(this.right);
  36. u.onmouseover = new Function('TINY.scroll.init("' + this.thumbs + '",-1,' + this.scrollSpeed + ')');
  37. u.onmouseout = r.onmouseout = new Function('TINY.scroll.cl("' + this.thumbs + '")');
  38. r.onmouseover = new Function('TINY.scroll.init("' + this.thumbs + '",1,' + this.scrollSpeed + ')');
  39. this.p = tid(this.thumbs)
  40. }
  41. for (i; i < this.l; i++) {
  42. this.a[i] = {};
  43. var h = m[i],
  44. a = this.a[i];
  45. a.t = tag('h5', h)[0].innerHTML;
  46. a.d = tag('p', h)[0].innerHTML;
  47. a.l = tag('a', h)[0] ? tag('a', h)[0].href : '';
  48. a.p = tag('span', h)[0].innerHTML;
  49. a.u = tag('h4', h)[0].innerHTML;
  50. if (this.thumbs) {
  51. var g = tag('img', h)[0];
  52. this.p.appendChild(g);
  53. var thw = g.offsetWidth;
  54. if (this.thumbHeight > thw) {
  55. thw = this.thumbHeight;
  56. }
  57. w += parseInt(thw);
  58. if (i != this.l - 1) {
  59. g.style.marginRight = this.spacing + 'px';
  60. w += this.spacing + 6;
  61. }
  62. this.p.style.width = w + this.spacing + 6 + 'px';
  63. g.style.opacity = this.thumbOpacity / 100;
  64. g.style.filter = 'alpha(opacity=' + this.thumbOpacity + ')';
  65. g.onmouseover = new Function('TINY.alpha.set(this,100,5)');
  66. g.onmouseout = new Function('TINY.alpha.set(this,' + this.thumbOpacity + ',5)');
  67. g.onclick = new Function(this.n + '.pr(' + i + ',1)')
  68. }
  69. }
  70. if (b && f) {
  71. b = tid(b);
  72. f = tid(f);
  73. b.style.opacity = f.style.opacity = this.navOpacity / 100;
  74. b.style.filter = f.style.filter = 'alpha(opacity=' + this.navOpacity + ')';
  75. b.onmouseover = f.onmouseover = new Function('TINY.alpha.set(this,' + this.navHover + ',5)');
  76. b.onmouseout = f.onmouseout = new Function('TINY.alpha.set(this,' + this.navOpacity + ',5)');
  77. b.onclick = new Function(this.n + '.mv(-1,1)');
  78. f.onclick = new Function(this.n + '.mv(1,1)')
  79. }
  80. if (this.info && this.infoShow == "H") {
  81. jQuery("#information").hide();
  82. jQuery('#' + this.wrap).hover(function() {
  83. jQuery("#information").fadeIn("slow");
  84. }, function() {
  85. jQuery("#information").fadeOut();
  86. });
  87. }
  88. this.auto ? this.is(0, 0) : this.is(0, 1)
  89. },
  90. striptlt: function(x) {
  91. x.value = x.value.replace(/['"]/g, '');
  92. },
  93.  
  94.  
  95. resize: function(i, w, h) {
  96. //console.log(jQuery(this.i));
  97. if (jQuery(this.i).is(":visible")) {
  98. //flynns code
  99.  
  100. /*
  101. var max = 575;
  102. var width = jQuery('#sgpro_image img').width();
  103. var height = jQuery('#sgpro_image img').height();
  104. var percentage;
  105. if(width > height ){
  106. percentage = (max/width);
  107. }else {
  108. percentage = (max/height);
  109. }
  110. revisedwidth = Math.round(width * percentage);
  111. revisedheight = Math.round(height * percentage);
  112.  
  113. if(height > width){
  114. $('#sgpro_image img').width(revisedwidth);
  115. $('#fullsize').width(revisedwidth+4);
  116. }else{
  117. $('#sgpro_image img').height(revisedheight);
  118. $('#fullsize').height(revisedheight+4);
  119. }
  120.  
  121.  
  122.  
  123. */
  124. //alert('asdasd');
  125. /*
  126. var width = jQuery('#sgpro_image img').width();
  127. var height = jQuery('#sgpro_image img').height();
  128. $('#fullsize').width(width+6);
  129. $('#fullsize').height(height+6);
  130. $('#sgpro_image').width(width);
  131. */
  132. // end of flynns code
  133.  
  134.  
  135.  
  136.  
  137. this.iwidth = this.i.width;
  138. this.iheight = this.i.height;
  139. if (this.iheight == 0) {
  140. this.iheight = jQuery(this.i).height();
  141. }
  142. } else {
  143. this.iwidth = (this.oh * this.i.width) / this.i.height;
  144. this.iheight = (this.o * this.i.height) / this.i.width;
  145. }
  146.  
  147.  
  148. if (w != null) {
  149. return this.iheight;
  150.  
  151. } else if (h != null) {
  152. return this.iwidth;
  153. }
  154. else {
  155. return null;
  156. }
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163. },
  164. mv: function(d, c) {
  165. var t = this.c + d;
  166. this.c = t = t < 0 ? this.l - 1 : t > this.l - 1 ? 0 : t;
  167. this.pr(t, c)
  168. },
  169. pr: function(t, c) {
  170. clearTimeout(this.lt);
  171. if (c) {
  172. clearTimeout(this.at)
  173. }
  174. this.c = t;
  175. this.is(t, c)
  176. },
  177. is: function(s, c) {
  178. if (this.info) {
  179. TINY.height.set(this.r, 1, this.infoSpeed / 2, -1, this.infoShow)
  180. }
  181. var i = new Image();
  182. i.style.opacity = 0;
  183. i.style.filter = 'alpha(opacity=0)';
  184. this.i = i;
  185. i.onload = new Function(this.n + '.le(' + s + ',' + c + ')');
  186. i.src = this.a[s].p;
  187. i.id = this.a[s].u;
  188. jQuery('#sgpro_image img').wrap('<div class="sgpro_holder" />');
  189. if (this.thumbs) {
  190. var a = tag('img', this.p),
  191. l = a.length,
  192. x = 0;
  193. for (x; x < l; x++) {
  194. a[x].style.borderColor = x != s ? '' : this.active
  195. }
  196. }
  197. },
  198. le: function(s, c) {
  199. this.f.appendChild(this.i);
  200.  
  201. var iheight = this.resize(this.i, this.o, null);
  202. var ht = this.oh - parseInt(iheight);
  203. var iwidth = this.resize(this.i, null, this.oh);
  204. var w = this.o - parseInt(iwidth);
  205.  
  206. var width = jQuery('#sgpro_image img').width();
  207. var height = jQuery('#sgpro_image img').height();
  208. $('#fullsize').width(width+6);
  209. $('#fullsize').height(height+6);
  210. $('#sgpro_image').width(width);
  211. console.log(width + ' ' + height)
  212.  
  213.  
  214. if (ht > 0) {
  215. var l = Math.floor(ht / 2);
  216. this.i.style.borderTop = (ht - l) + 'px solid ' + this.letterbox;
  217. this.i.style.borderBottom = (ht - l) + 'px solid ' + this.letterbox;
  218. }
  219. TINY.alpha.set(this.i, 100, this.imgSpeed);
  220. var n = new Function(this.n + '.nf(' + s + ')');
  221. this.lt = setTimeout(n, this.imgSpeed * 100);
  222. if (!c) {
  223. this.at = setTimeout(new Function(this.n + '.mv(1,0)'), this.speed * 1000)
  224. }
  225. if (this.a[s].l != "") {
  226. var baseURL = this.a[s].l;
  227. var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.swf$|\.bmp$/;
  228. var urlType = baseURL.toLowerCase().match(urlString);
  229. if ((this.nolink || this.imagesbox == "nolink") && (urlType == '.jpg' || urlType == '.JPG' || urlType == '.jpeg' || urlType == '.png' || urlType == '.PNG' || urlType == '.gif' || urlType == '.bmp' || urlType == '.swf')) {
  230. this.q.onclick = this.q.onmouseover = null;
  231. this.q.style.cursor = 'default';
  232. this.q.style.backgroundImage = 'none';
  233. } else if (this.imagesbox == "thickbox" && (urlType == '.jpg' || urlType == '.JPG' || urlType == '.jpeg' || urlType == '.png' || urlType == '.PNG' || urlType == '.gif' || urlType == '.bmp' || urlType == '.swf')) {
  234. var thickpath = ((this.a[s].p).replace(/\/wp-content.*/g, "/wp-includes/js/thickbox/"));
  235. tb_pathToImage = thickpath + "loadingAnimation.gif";
  236. tb_closeImage = thickpath + "tb-close.png";
  237. this.q.onclick = new Function('tb_show("' + this.a[s].t.replace(/['"]/g, '') + '", "' + this.a[s].l + '", "sgpro_slideshow" )');
  238. } else if (this.imagesbox == "shadowbox" && (urlType == '.jpg' || urlType == '.JPG' || urlType == '.jpeg' || urlType == '.png' || urlType == '.PNG' || urlType == '.gif' || urlType == '.bmp' || urlType == '.swf')) {
  239. this.q.onclick = new Function('Shadowbox.open({content: "' + this.a[s].l + '",player: "img",title: "' + this.a[s].t.replace(/['"]/g, '') + '",gallery:"' + this.gallery + '"})');
  240. } else if (this.imagesbox == "prettyphoto" && (urlType == '.jpg' || urlType == '.JPG' || urlType == '.jpeg' || urlType == '.png' || urlType == '.PNG' || urlType == '.gif' || urlType == '.bmp' || urlType == '.swf')) {
  241. this.q.onclick = new Function('jQuery.prettyPhoto.open("' + this.a[s].l + '","' + this.a[s].t.replace(/['"]/g, '') + '")');
  242. } else {
  243. if (this.pagelink == "self") {
  244. this.q.onclick = new Function('window.location="' + this.a[s].l + '"');
  245. }
  246. else {
  247. this.q.onclick = new Function('window.open("' + this.a[s].l + '")');
  248. }
  249. }
  250. this.q.onmouseover = new Function('this.className="' + this.linkclass + '"');
  251. this.q.onmouseout = new Function('this.className=""');
  252. this.q.style.cursor = 'pointer';
  253. this.q.style.height = '100%';
  254. } else {
  255. this.q.onclick = this.q.onmouseover = null;
  256. this.q.style.cursor = 'default';
  257. this.q.style.backgroundImage = 'none';
  258. }
  259. var m = tag('img', this.f);
  260. if (m.length > 1) {
  261. jQuery(m[0]).fadeOut('slow', function() {
  262. jQuery(m[0]).remove();
  263. if (m.length > 1) m[0].remove();
  264. });
  265. }
  266. },
  267. nf: function(s) {
  268. if (this.info) {
  269. s = this.a[s];
  270. tag('h5', this.r)[0].innerHTML = s.t;
  271. tag('p', this.r)[0].innerHTML = s.d;
  272. this.r.style.height = 'auto';
  273. var h = parseInt(this.r.offsetHeight);
  274. this.r.style.height = 0;
  275. TINY.height.set(this.r, h, this.infoSpeed, 0, this.infoShow)
  276. }
  277. }
  278. };
  279. TINY.scroll = function() {
  280. return {
  281. init: function(e, d, s) {
  282. e = typeof e == 'object' ? e : tid(e);
  283. var p = e.style.left || TINY.style.val(e, 'left');
  284. e.style.left = p;
  285. var l = d == 1 ? parseInt(e.offsetWidth) - parseInt(e.parentNode.offsetWidth) : 0;
  286. e.si = setInterval(function() {
  287. TINY.scroll.mv(e, l, d, s)
  288. }, 20)
  289. },
  290. mv: function(e, l, d, s) {
  291. var c = parseInt(e.style.left);
  292. if (c == l) {
  293. TINY.scroll.cl(e)
  294. } else {
  295. var i = Math.abs(l + c);
  296. i = i < s ? i : s;
  297. var n = c - i * d;
  298. e.style.left = n + 'px'
  299. }
  300. },
  301. cl: function(e) {
  302. e = typeof e == 'object' ? e : tid(e);
  303. clearInterval(e.si)
  304. }
  305. }
  306. }();
  307. TINY.height = function() {
  308. return {
  309. set: function(e, h, s, d, is) {
  310. e = typeof e == 'object' ? e : tid(e);
  311. var oh = e.offsetHeight,
  312. ho = e.style.height || TINY.style.val(e, 'height');
  313. ho = oh - parseInt(ho);
  314. var hd = oh - ho > h ? -1 : 1;
  315. clearInterval(e.si);
  316. if (is == "S") {
  317. e.si = setInterval(function() {
  318. TINY.height.tw(e, h, ho, hd, s)
  319. }, 20)
  320. } else {
  321. var oh = e.offsetHeight - ho - 1;
  322. if (oh + h > 1) {
  323. e.style.height = oh + (Math.abs(h)) + 'px';
  324. }
  325. }
  326. },
  327. tw: function(e, h, ho, hd, s) {
  328. var oh = e.offsetHeight - ho;
  329. if (oh == h) {
  330. clearInterval(e.si)
  331. } else {
  332. if (oh != h) {
  333. e.style.height = oh + (Math.ceil(Math.abs(h - oh) / s) * hd) + 'px'
  334. }
  335. }
  336. }
  337. }
  338. }();
  339. TINY.alpha = function() {
  340. return {
  341. set: function(e, a, s) {
  342. e = typeof e == 'object' ? e : tid(e);
  343. var o = e.style.opacity || TINY.style.val(e, 'opacity'),
  344. d = a > o * 100 ? 1 : -1;
  345. e.style.opacity = o;
  346. clearInterval(e.ai);
  347. e.ai = setInterval(function() {
  348. TINY.alpha.tw(e, a, d, s)
  349. }, 20)
  350. },
  351. tw: function(e, a, d, s) {
  352. var y = e.style.opacity;
  353. if (typeof y == 'string') {
  354. y = e.style.opacity.replace(',', '.');
  355. }
  356. var o = Math.round(parseFloat(y) * 100);
  357. if (o == a) {
  358. clearInterval(e.ai)
  359. }
  360. else {
  361. var n = o + Math.ceil(Math.abs(a - o) / s) * d;
  362. e.style.opacity = n / 100;
  363. e.style.filter = 'alpha(opacity=' + n + ')'
  364. }
  365. }
  366. }
  367. }($);
  368. TINY.style = function() {
  369. return {
  370. val: function(e, p) {
  371. e = typeof e == 'object' ? e : tid(e);
  372. return e.currentStyle ? e.currentStyle[p] : document.defaultView.getComputedStyle(e, null).getPropertyValue(p)
  373. }
  374. }
  375. }();
Add Comment
Please, Sign In to add comment