Показать сообщение отдельно
  #2 (permalink)  
Старый 11.01.2009, 21:47
Новичок на форуме
Отправить личное сообщение для abix Посмотреть профиль Найти все сообщения от abix
 
Регистрация: 11.01.2009
Сообщений: 3

и скрипт шаблона
/*------------------------------------------------------------------------
# JA Vauxite for Joomla 1.5 - Version 1.0 - Licence Owner JA108425
# ------------------------------------------------------------------------
# Copyright (C) 2004-2008 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
# @license - Copyrighted Commercial Software	
# Author: J.O.O.M Solutions Co., Ltd
# Websites:  [url]http://www.joomlart.com[/url] -  [url]http://www.joomlancers.com[/url]
# This file may not be redistributed in whole or significant part.
-------------------------------------------------------------------------*/

var src_collap_1 = tmplurl_1 + "/images/icon-min.gif";	
var src_collap_2 = tmplurl_1 + "/images/icon-max.gif";
new Asset.images ([src_collap_1, src_collap_2]);

var JADDModules = new Class({

	options: {
		handles: false,
		containers: false,
		onStart: Class.empty,
		onComplete: Class.empty,
		ghost: true,
		snap: 3,
		title: 'h3',
		src_collap_1:'',
		src_collap_2:'',
		cookieprefix: '',
		
		onDragStart: function(element, ghost){
			ghost.setStyles({'opacity':0.7, 'z-index':100});
			element.getChildren().setStyles({'opacity':0.3, 'z-index':1});
			element.addClass('moving');
		},
		onDragComplete: function(element, ghost){
			element.getChildren().setStyle('opacity', 1);
			element.removeClass('moving');
			ghost.remove();
			this.trash.remove();
		}
	},

	initialize: function(lists, options){			
			//console.log(encodeURIComponent("h%E1%BB%93ng%20c%C3%B4ng"));
		this.setOptions(options);
		this.lists = $$(lists);
		this.lists.sort(function(a,b){return a.getCoordinates().left - b.getCoordinates().left;});
		this.elements = [];
		this.handles = [];				
		
		/*	Get cookies	*/
		this.hc = '';
		if((this.hc=Cookie.get(this.options.cookieprefix+'ja-ordercolumn'))){
			if (this.hc == '-') {
				this.hc = '';
				Cookie.set(this.options.cookieprefix+"ja-ordercolumn", '',{path:'/'});				
			} else {
				this.hc = this.hc.split(',');
				if(this.hc!=''){
					this.hc.each(function(cc,k){
						this.hc[k] = this.hc[k].split("_");
					},this);
				}
			}
		}
		
		this.lists.each(function(list){			
			var elements = list.getChildren();
			elements.each(function(el,i){
				el._p = list;	
				if(this.options.title){
					el._h = el.getElement(this.options.title);
					if (!el._h) return;
					tmp = el._h.getParent();
					el._h.remove();
					
					//add wrap div
					/*
					var tmpwrap = new Element('div', {'class':'ja-mod-content'});
					var tmpwrap2 = new Element('div', {'class':'ja-mod-inner'}).inject (tmpwrap);
					tmp.getChildren().each (function(elc){
						elc.remove().inject(tmpwrap2);
					});
					tmpwrap.inject (tmp);
					*/
					tmp.innerHTML = "<div class=\"ja-mod-content\"><div class=\"ja-mod-inner\">"+tmp.innerHTML+"</div></div>";
					el._h.injectTop (tmp);										
					//el._h._el = el;	
					
					el._pos = i;
					
					if(this.hc){
						//element property: position, container, ...
						this.hc.each(function(val){
							if (val[1] == el._h.getText().trim().substr(0,20)) {
								el._p 			= $(val[0]);
								el._pos 		= parseInt(val[2]);
								el._h.addClass (val[3]);				
							}
						},this);
					}					
					
					if(el._h.className.test("hide")){						
						src_collap = this.options.src_collap_1;
					}
					else{
						if (!el._h.className.test('show')) el._h.addClass ('show');
						src_collap = this.options.src_collap_2;
					}
					
					//create handler for moveable and collapsible hotspot	
					divmd = new Element('span',{'class':'ja-mdtool'});
					divmd.inject(el._h);	
					chdl = new Element('img',{'src':src_collap});
					chdl.setStyle('cursor','pointer');
					chdl.inject (divmd);
					el._h._chdl = chdl;
													
					this.handles.push(el._h);
				}
			},this);

			this.elements.merge(elements);
			
			this.lists.setStyle('visibility','visible');
			
		},this);
		
		
		
		this.elements.each (function (el){
			
			el.remove();
			p = $(el._p);
			if(!p) return ;
			tmp = p.getChildren().length > el._pos ? p.getChildren()[el._pos]:null;
			if (tmp) {
				if (tmp._pos > el._pos) el.injectBefore(tmp);
				else el.injectAfter(tmp);
			}
			else el.inject (p);
			
		});
		
		//this.elements = $$(list);
		this.handles = (this.options.handles) ? $$(this.options.handles) : (this.handles.length?this.handles:this.elements);
		//this.handles.setStyle('cursor', 'move');
		this.bound = {
			'start': [],
			'moveGhost': this.moveGhost.bindWithEvent(this)
		};
		for (var i = 0, l = this.handles.length; i < l; i++){
			this.bound.start[i] = this.start.bindWithEvent(this, this.elements[i]);
		}	
									
		this.attach();
		this.collap();
		
		if (this.options.initialize) this.options.initialize.call(this);
		this.bound.move = this.move.bindWithEvent(this);
		this.bound.end = this.end.bind(this);			
									
		//if (window.opera) window.addEvent("unload", this.saveCookies.bind(this));
		//else window.addEvent("beforeunload", this.saveCookies.bind(this));

	},

	collap: function(){
		this.lists.each(function(list){
			var elements = list.getChildren();
			elements.each(function(el,i){
				/*	For collap		*/
						
				el.elmain = el.getElement('.ja-mod-inner');				
				if(!el._h) return;

				el.maxH = el.elmain.getStyle('height').toInt();
//console.log (el.elmain.getStyle('height').toInt() + ' ' + el.maxH);
				el.elmain.setStyles ({
					'overflow':'hidden',
					'padding':'0',
					'margin':'0'
					});
						
				el._h._chdl.addEvent('mousedown', function(e){
					e = new Event(e).stop();
				});
				el._h._chdl.addEvent('click', function(e){
					e = new Event(e).stop();
					this.toggle(el);
				}.bind(this));	
											
				if(el._h.className.test('hide')) {
					this.hide(el);
				}
				else{
					this.show(el);
				}
				
			}, this);
		}, this);
	},
	
	toggle: function(el){
		if (el._h.className.test('hide')){
			this.show(el);
		}
		else this.hide(el);
	},	
	
	show: function(el) {
		el._h.removeClass('hide');
		if (!el._h.className.test('show')) el._h.addClass('show');
		el._h._chdl.src = src_collap_2;					
		new Fx.Style(el.elmain,'height',{onComplete:this.toggleStatus.bind(this,el)}).start(el.elmain.offsetHeight,el.elmain.scrollHeight);
	},	
	hide: function(el) {
		el._h.removeClass('show');
		if (!el._h.className.test('hide')) el._h.addClass('hide');
		el._h._chdl.src = src_collap_1;
		new Fx.Style(el.elmain,'height',{onComplete:this.toggleStatus.bind(this,el)}).start(el.elmain.offsetHeight,0);				
	},
	toggleStatus: function (el) {					
		el._status=(el._status=='hide')?'show':'hide';
		//this.fireEvent('onComplete', this.active);
		this.saveCookies();
	},				
	
	
	attach: function(){
		this.handles.each(function(handle, i){
			//handle.addEvent('mousedown', this.bound.start[i]);
			handle.addEvent('mousedown', this.bound.start[i]);
			handle.setStyle('cursor','move');
		}, this);
	},

	detach: function(){
		this.handles.each(function(handle, i){
			handle.removeEvent('mousedown', this.bound.start[i]);
		}, this);
	},

	start: function(event, el){
		this.active = el;
		//this.coordinates = this.list.getCoordinates();
		if (this.options.ghost){
			this.previous = 0;
			var position = el.getPosition();
			this.offsetX = event.page.x - position.x;
			this.offsetY = event.page.y - position.y;
			this.trash = new Element('div', {'class':'ja-ghost'}).inject(document.body);
			this.ghost = el.clone().inject(this.trash).setStyles({
				'position': 'absolute',
				'left': event.page.x - this.offsetX,
				'top': event.page.y - this.offsetY,
				'width': el.offsetWidth
			});			

			document.addListener('mousemove', this.bound.moveGhost);
			this.fireEvent('onDragStart', [el, this.ghost]);
		}
		document.addListener('mousemove', this.bound.move);
		document.addListener('mouseup', this.bound.end);
		this.fireEvent('onStart', el);
		event.stop();
	},
Ответить с цитированием