/com_joomleague/components/com_joomleague/modules/mod_joomleague_matches/assets/js/mod_joomleague_matches.js

https://gitlab.com/volleyuisp/joomleague · JavaScript · 157 lines · 133 code · 21 blank · 3 comment · 8 complexity · 8d6b2f5332d950b106ad5e2ca135ba31 MD5 · raw file

  1. function jlmlnewAjax()
  2. {
  3. /* THIS CREATES THE AJAX OBJECT */
  4. var xmlhttp=false;
  5. try
  6. {
  7. // ajax object for non IE navigators
  8. xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
  9. }
  10. catch(e)
  11. {
  12. try
  13. {
  14. // ajax object for IE
  15. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  16. }
  17. catch(E) { xmlhttp=false; }
  18. }
  19. if (!xmlhttp && typeof XMLHttpRequest!="undefined") { xmlhttp=new XMLHttpRequest(); }
  20. return xmlhttp;
  21. }
  22. function jlml_loadMatch(usedteam, matchid, moduleid, nr, origin) {
  23. var classadd = 'modJLML'+moduleid+'_row'+nr;
  24. var myFx = new Fx.Morph(classadd);
  25. myFx.start({'opacity':0});
  26. $(classadd).addClass('ajaxloading');
  27. var myFx = new Fx.Morph(classadd);
  28. myFx.start({'opacity':1});
  29. var ajax=jlmlnewAjax();
  30. ajax.open("POST", location.href, true);
  31. ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  32. ajax.send('ajaxMListMod=1&ajaxmodid='+moduleid+'&match_id='+matchid+'&nr='+nr+'&usedteam='+usedteam+'&origin='+origin);
  33. ajax.onreadystatechange=function()
  34. {
  35. if (ajax.readyState==4)
  36. {
  37. var response = ajax.responseText;
  38. var start = response.indexOf('<!--jlml-mod'+moduleid+'nr'+nr+' start-->');
  39. var finish = response.indexOf('<!--jlml-mod'+moduleid+'nr'+nr+' end-->');
  40. justMatch= response.substring(start,finish);
  41. var myFx = new Fx.Morph(classadd);
  42. myFx.start({'opacity':1});
  43. $(classadd).innerHTML=justMatch;
  44. }
  45. addJLMLtips('.jlmlTeamname', 'over');
  46. };
  47. return false;
  48. }
  49. var JLMLToolTip = new Class({
  50. initialize: function(options) {
  51. this.options = Object.extend({
  52. tipper: options.tipper, // element displaying the tooltip
  53. message: options.message, // some predefined message
  54. ajax:null, // show message from ajax / if message is not null, this will override it
  55. ToolTipClass:'tool', // tooltip display class
  56. followMouse:false, // follow mouse on move
  57. sticky: options.sticky, // remove tooltip if closed
  58. fromTop: -15, // distance from mouse or object
  59. duration: 300, // fade effect transition duration
  60. fadeDistance: 20, // the distance the tooltip sarts fading in/out
  61. closeOn: 'click' // all options to close: click, mouseover, mouseleave
  62. }, options || {});
  63. this.el = this.options.tipper;
  64. this.start();
  65. this.visible = 0;
  66. },
  67. start: function(){
  68. this.createContainer();
  69. this.header.set('html',this.el.title);
  70. this.el.set({'title':''});
  71. if(!this.options.ajax){
  72. this.message.set('html',this.options.message);
  73. }else{
  74. this.message.set('html', this.options.message);
  75. this.message.addClass('message_loading');
  76. new Ajax(this.options.ajax, {
  77. method: 'get',
  78. onComplete: function() {
  79. this.message.removeClass('message_loading');
  80. this.message.addClass('message');
  81. }.bind(this),
  82. update: this.message
  83. }).request();
  84. }
  85. this.fx = new Fx.Morph(this.container, {duration:this.options.duration, wait:false, transition:Fx.Transitions.Sine.easeOut});
  86. this.el.addEvent( this.options.followMouse ? 'mousemove' : 'mouseenter', this.showToolTip.bind(this) );
  87. if(!this.options.sticky){
  88. this.el.addEvent('mouseleave', this.hideToolTip.bind(this));
  89. }
  90. else{
  91. this.closeTip = new Element('a').set({'class':'sticky_close','href':'javascript:void(0);'}).setStyles({'position':'absolute','top':3,'right':3});
  92. this.closeTip.injectInside(this.header);
  93. this.closeTip.addEvent(this.options.closeOn, this.hideToolTip.bind(this));
  94. this.container.addEvent('mouseleave', this.hideToolTip.bind(this));
  95. }
  96. },
  97. showToolTip: function(ev){
  98. var event = new Event(ev);
  99. $$('.tmp_sticky_tip').each(function(handle){handle.setStyles({'display': 'none'});});
  100. this.container.addClass('tmp_sticky_tip');
  101. this.elemHeight = this.el.getCoordinates().height;
  102. this.top = this.options.followMouse ? event.client.y : this.el.getPosition().y;
  103. var left = this.options.followMouse ? event.client.x : this.el.getPosition().x;
  104. var top_dist = this.visible == 1 ?
  105. this.top + this.options.fromTop + this.elemHeight :
  106. this.top + this.options.fromTop + this.elemHeight + this.options.fadeDistance;
  107. this.container.setStyles({'top': top_dist,'left':left,'display':'block', 'z-index':'110000'});
  108. this.fx.start({'opacity':1, 'top':this.top + this.options.fromTop + this.elemHeight});
  109. this.visible = 1;
  110. },
  111. hideToolTip: function(){
  112. this.container.setStyles({'z-index':'100000'});
  113. this.fx.start({'opacity':0,'top': this.top + this.options.fromTop + this.elemHeight + this.options.fadeDistance});
  114. this.visible = 0;
  115. },
  116. createContainer: function(){
  117. this.container = new Element('div');
  118. this.container.addClass(this.options.ToolTipClass+'-tip');
  119. this.container.setStyles({'position':'absolute','opacity':0,'display':'none','z-index':'100000'});
  120. this.container.injectInside(document.body);
  121. this.wrapper=new Element('div').inject(this.container);
  122. this.header = new Element('span').inject(new Element('div',{'class':this.options.ToolTipClass+'-title'}).inject(this.wrapper));
  123. this.message = new Element('span').inject(new Element('div',{'class':this.options.ToolTipClass+'-text'}).inject(this.wrapper));
  124. }
  125. });
  126. function addJLMLtips (els, suffix) {
  127. $$(els).each(function(el) {
  128. var tipsource = el.id+'_'+suffix;
  129. if($(tipsource)) {
  130. new JLMLToolTip({tipper: $(tipsource),
  131. sticky: true,
  132. message: $(tipsource).innerHTML}
  133. );
  134. }
  135. });
  136. }