Sha256: a5023f8d0ba4c9ac293695c64cc1447b83e7a5548ed50c602e98b48d7e3b0006

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

// Concrete Model Editor
//
// Copyright (c) 2010 Martin Thiede
//
// Concrete is freely distributable under the terms of an MIT-style license.

Concrete.InlineEditor = Class.create(Concrete.BasicInlineEditor, {

	initialize: function(stateChangeFunc) {
		this.stateChangeFunc = stateChangeFunc;
	},
	
	edit: function(element, opt) {
		var init = opt.init || ""
		var partial = opt.partial || false
		if (opt.options instanceof Array) {
			this._options = opt.options
			this._regexp = undefined		
		}
		else if (opt.options instanceof RegExp) {
			this._options = []
			this._regexp = opt.options
		}
		else {
			this._options = []
		}
		this._successHandler = opt.onSuccess
		this._failureHandler = opt.onFailure
		this.isActive = true
		this.stateChangeFunc(this.isActive);
		this.show(element, init, partial, this._options)	
	},
	
	finish: function() {
		if ((this._options.size() == 0 || this._options.include(this.getText())) && (this._regexp == undefined || this._regexp.test(this.getText()))) {
			this.isActive = false
			this.stateChangeFunc(this.isActive);
			this.hide()
			if (this._successHandler) this._successHandler(this.getText())
		}
		else {
			this.setError()
		}
	},
	
	cancel: function() {
		this.isActive = false
		this.stateChangeFunc(this.isActive);
		this.hide()
		if (this._failureHandler) this._failureHandler()
	}
		
})


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
concrete-0.2.0 concrete/inline_editor.js