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

moveGhost: function(event){
		this.ghost.setStyles({'left': event.page.x-this.offsetX,
													'top': event.page.y-this.offsetY
													});
		event.stop();
	},

	move: function(event){
		var cor = this.active.getCoordinates();
		if(cor.left < event.page.x && event.page.x < cor.right && event.page.y > cor.top && event.page.y < cor.bottom) return;
		/*Find out the hover element*/
		var now = event.page.x;
		var clist = this.lists[0];
		this.lists.each(function(list){
			if (now > list.getCoordinates().left) clist = list;
		}, this);
		
		if(clist == this.active._p) {
			var now = event.page.y;
			this.previous = this.previous || now;
			var up = ((this.previous - now) > 0);
			var prev = this.active.getPrevious();
			var next = this.active.getNext();
			if (prev && up && now < prev._h.getCoordinates().bottom) this.active.injectBefore(prev);
			if (next && !up && now > next._h.getCoordinates().top) this.active.injectAfter(next);
			this.previous = now;
		}else{
			var now = event.page.y;
			
			//Get correct position
			var els = clist.getChildren();
			if(els.length) {
				var cel = els[0];
				els.each(function(el, idx){
					if (now > el._h.getCoordinates().bottom)
					{
						if(idx < els.length - 1) cel = els[idx+1];
						else cel = null;
					}
				},this);

				if(cel) this.active.injectBefore(cel);
				else this.active.inject(clist);
			} else {
				this.active.inject(clist);
			}
			this.active._p = clist;
			this.previous = now;
		}

	},

	serialize: function(converter){
		return this.list.getChildren().map(converter || function(el){
			return this.elements.indexOf(el);
		}, this);
	},

	end: function(){
		this.previous = null;
		document.removeListener('mousemove', this.bound.move);
		document.removeListener('mouseup', this.bound.end);
		if (this.options.ghost){
			document.removeListener('mousemove', this.bound.moveGhost);
			this.fireEvent('onDragComplete', [this.active, this.ghost]);
		}
		this.fireEvent('onComplete', this.active);
		this.saveCookies();
	},
	
	saveCookies: function() {
		if ((this.hc=Cookie.get(this.options.cookieprefix+"ja-ordercolumn")) == '-') {
			return;
		}
		if (this.hc) {
			this.hc = this.hc.split(',');
			if(this.hc){
				this.hc.each(function(cc,k){
					this.hc[k] = this.hc[k].split("_");
				},this);
			}
		}
		
		c = '';
		this.lists.each(function(list){			
			var elements = list.getChildren();			
			if (!elements){
				return;
			}
			elements.each(function(el,i){
				c += el._p.id + "_" + el._h.getText().trim().substr(0,20) + "_" + i + "_" + (el._h.className.test('hide')?'hide':'show')+",";
			},this);
		},this);
		
		if (this.hc) {
			this.hc.each(function(value, k){
				if (!c.test ('_' + value[1] + '_')) {
					c += value[0] + "_" + value[1] + "_" + value[2] + "_" + value[3]+",";
				}
			},this);
		}	
		c = c.substr(0, (c.length-1));
		Cookie.set(this.options.cookieprefix+"ja-ordercolumn", c, {duration: 365,path:'/'});
	}
});

document.write('<style type="text/css">.ja-movable-container{visibility: hidden;}</style>');
window.addEvent('load', function(){	
	new JADDModules($$("#jazin-wrap .ja-movable-container"), {src_collap_1:src_collap_1, src_collap_2:src_collap_2, 'cookieprefix':''});
	new JADDModules($$("#ja-cols .ja-movable-container"), {src_collap_1:src_collap_1, src_collap_2:src_collap_2, 'cookieprefix':''});
});

JADDModules.implement(new Events, new Options);

JAResizer = new Class({
	initialize: function(els, options){
		this.options = Object.extend({
			min: 100,
			max: 0
		}, options || {});
		$$(els).each(function(el){
			el.onmouseover = function(){
				this.addClass('ja-colresizehover');
			};
			
			resizemouseout = function(){
				//console.log('call mouse out event for ' + this);
				this.removeClass('ja-colresizehover');
			}
			el.onmouseout = resizemouseout;

			var prev = el.getPrevious();
			var next = el.getNext();
			prev.makeResizableNew ({handle: el, modifiers:{y:false}, limit:{width:[100]}});
			next.makeResizableNew ({handle: el, modifiers:{y:false}, dir: -1, limit:{width:[100]}});
			var eld = el.makeDraggable({modifiers:{y:false}});

			eld.addEvent('onStart', function (el) {
				//console.log('Remove mouse out for ' + eld.element);
				el.onmouseout = null;
				this._next = el.getNext();
				this._prev = el.getPrevious();
				this._w = this._prev.getStyle('width').toFloat() + this._next.getStyle('width').toFloat();
			});

			eld.addEvent('onComplete', function (el) {
				el.onmouseout = resizemouseout;

				var w1 = this._prev.offsetWidth;
				var w2 = this._next.offsetWidth;
				var w1p = w1/(w1+w2)*this._w;
				var w2p = w2/(w1+w2)*this._w;
				var elwp = el.offsetLeft * this._w / (w1+w2);
				this._prev.setStyle('width', w1p + '%');
				this._next.setStyle('width', w2p + '%');
				el.setStyle ('left', elwp + '%');

				el = el.getCoordinates(this.options.overflown);
				var now = this.mouse.now;
				if (!(now.x > el.left && now.x < el.right && now.y < el.bottom && now.y > el.top)) resizemouseout.call(this.element);

			});
		}.bind( this));
	}
});


Drag.Resize = Drag.Base.extend({

	options: {
		dir: 1
	},

	initialize: function(el, options){
		this.setOptions(options);
		this.parent(el);
	},


	start: function(event){
		this.fireEvent('onBeforeStart', this.element);
		this.mouse.start = event.page;
		var limit = this.options.limit;
		this.limit = {'x': [], 'y': []};
		for (var z in this.options.modifiers){
			if (!this.options.modifiers[z]) continue;
			this.value.now[z] = this.element.getCoordinates()[this.options.modifiers[z]].toInt();
			this.mouse.pos[z] = event.page[z] - this.value.now[z]*this.options.dir;
			if (limit && limit[z]){
				for (var i = 0; i < 2; i++){
					if ($chk(limit[z][i])) this.limit[z][i] = ($type(limit[z][i]) == 'function') ? limit[z][i]() : limit[z][i];
				}
			}
		}
		if ($type(this.options.grid) == 'number') this.options.grid = {'x': this.options.grid, 'y': this.options.grid};
		document.addListener('mousemove', this.bound.check);
		document.addListener('mouseup', this.bound.stop);
		this.fireEvent('onStart', this.element);
		event.stop();
	},

	drag: function(event){
		this.out = false;
		this.mouse.now = event.page;
		for (var z in this.options.modifiers){
			if (!this.options.modifiers[z]) continue;
			//this.value.now[z] = this.mouse.now[z] - this.mouse.pos[z];
			this.value.now[z] = (this.mouse.now[z] - this.mouse.pos[z])*this.options.dir;
			if (this.limit[z]){
				if ($chk(this.limit[z][1]) && (this.value.now[z] > this.limit[z][1])){
					this.value.now[z] = this.limit[z][1];
					this.out = true;
				} else if ($chk(this.limit[z][0]) && (this.value.now[z] < this.limit[z][0])){
					this.value.now[z] = this.limit[z][0];
					this.out = true;
				}
			}
			if (this.options.grid[z]) this.value.now[z] -= (this.value.now[z] % this.options.grid[z]);
			this.element.setStyle(this.options.modifiers[z], this.value.now[z] + this.options.unit);
		}
		this.fireEvent('onDrag', this.element);
		event.stop();
	}

});

/*
Class: Element
	Custom class to allow all of its methods to be used with any DOM element via the dollar function <$>.
*/

Element.extend({

	/*
	Property: makeDraggable
		Makes an element draggable with the supplied options.

	Arguments:
		options - see <Drag.Move> and <Drag.Base> for acceptable options.
	*/

	makeResizableNew: function(options){
		return new Drag.Resize(this, $merge({modifiers: {x: 'width', y: 'height'}}, options));
	}

});
Ответить с цитированием