Sha256: 08b38248304197b138524005b33f3072c0f8259d4835bdf6774a7bd84cb66b27

Contents?: true

Size: 1.52 KB

Versions: 22

Compression:

Stored size: 1.52 KB

Contents

var AjaxEditStack = new Class({
	version: 0.1,

	options: {
	},
	bricksArray: [],
	bricksIndex: 0,

	Implements: [Options, Events],

	initialize: function(_options) {
		this.setOptions(_options);
	},
	addEditBrick: function(editOptions, link, linkParent){
		var qi = this.bricksIndex;
		var qe = this.bricksArray[qi];
		if ( ! qe) {
			qe = new AjaxEdit(editOptions);
			this.bricksArray.push(qe);
		}
		
		this.bricksArray.each(function(b, i){
			if (i === qi) {
				b.show();
			}
			else if (i > qi) {
				b.close();
			}
		});
		
		var fadeTm;
		qe.addEvents({
			startRequest: function(){
				this.wrapElement.addClass('live_edit');
				setTimeout(function(){
					this.wrapElement.addClass('live_edit');
				}.bind(this), 10);
			},
			closed: function(){
				this.wrapElement.addClass('animate');
				setTimeout(function(){
					this.wrapElement.removeClass('live_edit');
				}.bind(this));
				setTimeout(function(){
					this.wrapElement.removeClass('animate');
				}.bind(this), 600);
			}
		});
		qe.startEdit(link, linkParent);
	},
	addStack: function(){
		this.bricksIndex = this.bricksIndex + 1;
		this.bricksArray.each(function(b){
			b.hide();
		});
	},
	removeStack: function(){
		this.bricksArray[this.bricksIndex] = undefined;
		this.bricksIndex = this.bricksIndex - 1;
		this.bricksArray = this.bricksArray.clean();
		(this.bricksArray.getLast() || {show: function(){}}).show();
	},
	removeAllStacks: function(){
		this.bricksArray.clean().each(function(b, i){
			b.close();
		});
		this.bricksArray = [];
		this.bricksIndex = 0;
	}
});

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
bhf-0.6.24 app/assets/javascripts/bhf/classes/AjaxEditStack.js
bhf-0.6.23 app/assets/javascripts/bhf/classes/AjaxEditStack.js