Guest User

Untitled

a guest
Jun 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. $(document).ready(function(){
  2. if (!Array.prototype.indexOf) {
  3. Array.prototype.indexOf = function (obj, fromIndex) {
  4. if (fromIndex == null) {
  5. fromIndex = 0;
  6. } else if (fromIndex < 0) {
  7. fromIndex = Math.max(0, this.length + fromIndex);
  8. }
  9. for (var i = fromIndex, j = this.length; i < j; i++) {
  10. if (this[i] === obj)
  11. return i;
  12. }
  13. return -1;
  14. };
  15. }
  16. });
  17.  
  18. (function( $ ) {
  19. $.fn.smartResize = function(options) {
  20. var element = this;
  21. element.bgWRatio = (element.width() / element.height());
  22. element.bgHRatio = (element.height() / element.width());
  23. //var bgWRatio = ((this).width() / (this).height());
  24. //var bgHRatio = ((this).height() / (this).width());
  25. function getDocSize(){
  26. var docAttr = { height: $(window).height(), width: $(window).width() }
  27. return docAttr;
  28. }
  29. function _resizeBG(){
  30. var obj = getDocSize();
  31. /*For debugging purposes*/
  32. obj.wratio = (obj.width / obj.height);
  33. //obj.hratio = (obj.height / obj.width);
  34. //console.log('width '+obj.wratio+','+bgWRatio);
  35. //console.log('height '+obj.hratio+','+bgHRatio);
  36. var xtraX = ((element.width() - $(window).width()));
  37. var xtraY = ((element.height() - $(window).height()));
  38. if (obj.wratio < element.bgWRatio) {
  39. element.attr('height', obj.height);
  40. element.attr('width', ((obj.height / element.bgHRatio)));
  41. } else {
  42. element.attr('width', obj.width);
  43. element.attr('height', ((obj.width / element.bgWRatio)));
  44. }
  45.  
  46. }
  47. _resizeBG();
  48. $(window).resize(_resizeBG);
  49. }
  50. $.fn.imageAdvance = function() {
  51. var imgArray = []
  52. $('#PRELOADAN-GAEMS img').each(function(){ imgArray.push($(this).attr('src')); });
  53. var counter = 0;
  54. this.click(function() {
  55. var indicii = (imgArray.indexOf($('#alycia').attr('src'))+1)
  56. if (indicii > (imgArray.length - 1) ) {
  57. indicii = 0
  58. }
  59. $('#alycia').fadeOut(function(){
  60. $(this).attr('src', imgArray[indicii]);
  61. $(this).fadeIn();
  62. })
  63.  
  64. })
  65. }
  66.  
  67. }) ( jQuery );
Add Comment
Please, Sign In to add comment