Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // +---------------------------------------------------------------------------+
- // | This file is part of the Agavi and Mootools Extension package. |
- // | Copyright (c) 2006, 2007 Jean-Philippe Dery |
- // | |
- // | For the full copyright and license information, please view the LICENSE |
- // | file that was distributed with this source code. |
- // +---------------------------------------------------------------------------+
- /**
- * Amxpanel is a class used to convert a link from a tab and return the
- * page content into a panel using ajax.
- *
- * @package amx
- * @subpackage nav
- * @author Jean-Philippe Dery (jeanphilippe_dery@hotmail.com)
- * @copyright Jean-Philippe Dery (jeanphilippe_dery@hotmail.com)
- * @since 1.0.0
- * @version 1.0.0
- */
- var AmxPanel = AmxTabGroup.extend(
- {
- /**
- * @var object The panel to put the content in.
- */
- panel : null,
- /**
- * @var array The panels cache array.
- */
- cache : [],
- /**
- * @var object The layer placed on top of the panel on loading.
- */
- layer : null,
- /**
- * @var object The class options parameters.
- */
- options : {},
- /**
- * Constructor. Set the panel id.
- * @return void
- * @author Jean-Philippe Dery (jeanphilippe_dery@hotmail.com)
- * @since 1.0.0
- */
- initialize : function(panel, options)
- {
- this.panel = $(panel);
- this.layer = new AmxLoadingLayer(this.panel).activate();
- this.options = Object.extend({
- cache : true,
- anim : false
- }, options || {});
- return this;
- },
- /**
- * Add a tab in the group using the tab id.
- * @param string The tab id.
- * @param bool True if the tab link will be copied to the tab.
- * @return void
- * @author Jean-Philippe Dery (jeanphilippe_dery@hotmail.com)
- * @since 1.0.0
- */
- addTab : function(tab, finder)
- {
- tab = this.parent(tab, {addLinks : false});
- // create the main event which will load the panel content when the tab
- // is clicked. a loading layer will be placed on top while loading
- var that = this;
- var link = $E('a', tab.element);
- tab.addEvent('mousedown', function() {
- // load the panel content from the cache first
- if (this.options.cache) {
- if (this.cache[tab.getId()]) {
- this.panel.empty();
- this.panel.adopt(that.cache[tab.getId()]);
- return;
- }
- }
- console.log(this.layer.element.setProperty);
- this.showLayer();
- /*new Ajax(link.getProperty('href'), {onComplete : function(html) {
- this.hideLayer();
- finder.setHaystack(html);
- var result = finder.find();
- if (this.options.anim) {
- result.setOpacity(0);
- new Fx.Style(result, 'opacity', {duration : 500}).start(0, 1);
- }
- this.panel.empty();
- this.panel.adopt(result);
- if (this.options.cache) {
- this.cache[tab.getId()] = result;
- }
- }.bind(this)}).request();*/
- var test = function() {
- this.hideLayer();
- }.bind(this);
- test.delay(2000);
- }.bind(this));
- // remove the link element so the browser will not change the location
- link.getParent().setText(link.getText());
- },
- showLayer : function()
- {
- this.layer.show();
- },
- hideLayer : function()
- {
- this.layer.hide();
- }
- });
Add Comment
Please, Sign In to add comment