Guest User

Untitled

a guest
Mar 6th, 2018
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. // +---------------------------------------------------------------------------+
  2. // | This file is part of the Agavi and Mootools Extension package. |
  3. // | Copyright (c) 2006, 2007 Jean-Philippe Dery |
  4. // | |
  5. // | For the full copyright and license information, please view the LICENSE |
  6. // | file that was distributed with this source code. |
  7. // +---------------------------------------------------------------------------+
  8.  
  9. /**
  10. * Amxpanel is a class used to convert a link from a tab and return the
  11. * page content into a panel using ajax.
  12. *
  13. * @package amx
  14. * @subpackage nav
  15. * @author Jean-Philippe Dery (jeanphilippe_dery@hotmail.com)
  16. * @copyright Jean-Philippe Dery (jeanphilippe_dery@hotmail.com)
  17. * @since 1.0.0
  18. * @version 1.0.0
  19. */
  20. var AmxPanel = AmxTabGroup.extend(
  21. {
  22. /**
  23. * @var object The panel to put the content in.
  24. */
  25. panel : null,
  26.  
  27. /**
  28. * @var array The panels cache array.
  29. */
  30. cache : [],
  31.  
  32. /**
  33. * @var object The layer placed on top of the panel on loading.
  34. */
  35. layer : null,
  36.  
  37. /**
  38. * @var object The class options parameters.
  39. */
  40. options : {},
  41.  
  42. /**
  43. * Constructor. Set the panel id.
  44. * @return void
  45. * @author Jean-Philippe Dery (jeanphilippe_dery@hotmail.com)
  46. * @since 1.0.0
  47. */
  48. initialize : function(panel, options)
  49. {
  50. this.panel = $(panel);
  51. this.layer = new AmxLoadingLayer(this.panel).activate();
  52. this.options = Object.extend({
  53. cache : true,
  54. anim : false
  55. }, options || {});
  56. return this;
  57. },
  58.  
  59. /**
  60. * Add a tab in the group using the tab id.
  61. * @param string The tab id.
  62. * @param bool True if the tab link will be copied to the tab.
  63. * @return void
  64. * @author Jean-Philippe Dery (jeanphilippe_dery@hotmail.com)
  65. * @since 1.0.0
  66. */
  67. addTab : function(tab, finder)
  68. {
  69. tab = this.parent(tab, {addLinks : false});
  70. // create the main event which will load the panel content when the tab
  71. // is clicked. a loading layer will be placed on top while loading
  72. var that = this;
  73. var link = $E('a', tab.element);
  74. tab.addEvent('mousedown', function() {
  75. // load the panel content from the cache first
  76. if (this.options.cache) {
  77. if (this.cache[tab.getId()]) {
  78. this.panel.empty();
  79. this.panel.adopt(that.cache[tab.getId()]);
  80. return;
  81. }
  82. }
  83. console.log(this.layer.element.setProperty);
  84. this.showLayer();
  85. /*new Ajax(link.getProperty('href'), {onComplete : function(html) {
  86. this.hideLayer();
  87. finder.setHaystack(html);
  88. var result = finder.find();
  89. if (this.options.anim) {
  90. result.setOpacity(0);
  91. new Fx.Style(result, 'opacity', {duration : 500}).start(0, 1);
  92. }
  93. this.panel.empty();
  94. this.panel.adopt(result);
  95. if (this.options.cache) {
  96. this.cache[tab.getId()] = result;
  97. }
  98. }.bind(this)}).request();*/
  99. var test = function() {
  100. this.hideLayer();
  101. }.bind(this);
  102. test.delay(2000);
  103. }.bind(this));
  104. // remove the link element so the browser will not change the location
  105. link.getParent().setText(link.getText());
  106. },
  107.  
  108. showLayer : function()
  109. {
  110. this.layer.show();
  111. },
  112.  
  113. hideLayer : function()
  114. {
  115. this.layer.hide();
  116. }
  117. });
Add Comment
Please, Sign In to add comment