From ca47a8c7fd5eb9f34ac00a2f1a843859d6123dd8 Mon Sep 17 00:00:00 2001 From: wei <> Date: Mon, 16 Jan 2006 02:43:30 +0000 Subject: --- framework/Web/Javascripts/base/controls.js | 194 ----------------------------- 1 file changed, 194 deletions(-) delete mode 100644 framework/Web/Javascripts/base/controls.js (limited to 'framework/Web/Javascripts/base/controls.js') diff --git a/framework/Web/Javascripts/base/controls.js b/framework/Web/Javascripts/base/controls.js deleted file mode 100644 index ad5b8abe..00000000 --- a/framework/Web/Javascripts/base/controls.js +++ /dev/null @@ -1,194 +0,0 @@ -/** - * Auto complete textbox via AJAX. - */ -Prado.AutoCompleter = Class.create(); - - -/** - * Overrides parent implementation of updateElement by trimming the value. - */ -Prado.AutoCompleter.Base = function(){}; -Prado.AutoCompleter.Base.prototype = Object.extend(Autocompleter.Base.prototype, -{ - updateElement: function(selectedElement) - { - if (this.options.updateElement) { - this.options.updateElement(selectedElement); - return; - } - - var value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal'); - var lastTokenPos = this.findLastToken(); - if (lastTokenPos != -1) { - var newValue = this.element.value.substr(0, lastTokenPos + 1); - var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/); - if (whitespace) - newValue += whitespace[0]; - this.element.value = (newValue + value).trim(); - } else { - this.element.value = value.trim(); - } - this.element.focus(); - - if (this.options.afterUpdateElement) - this.options.afterUpdateElement(this.element, selectedElement); - } -}); - -/** - * Based on the Prototype Autocompleter class. - * This client-side component should be instantiated from a Prado component. - * Usage: new Prado.AutoCompleter('textboxID', 'updateDivID', {callbackID : '...'}); - */ -Prado.AutoCompleter.prototype = Object.extend(new Autocompleter.Base(), -{ - /** - * This component is initialized by - * new Prado.AutoCompleter(...) - * @param string the ID of the textbox element to observe - * @param string the ID of the div to display the auto-complete options - * @param array a hash of options, e.g. auto-completion token separator. - */ - initialize : function(element, update, options) - { - this.baseInitialize(element, update, options); - }, - - /** - * The callback function, i.e., function called on successful AJAX return. - * Calls update choices in the Autocompleter. - * @param string new auto-complete options for display - */ - onUpdateReturn : function(result) - { - if(isString(result) && result.length > 0) - this.updateChoices(result); - }, - - /** - * Requesting new choices using Prado's client-side callback scheme. - */ - getUpdatedChoices : function() - { - Prado.Callback(this.element.id, this.getToken(), this.onUpdateReturn.bind(this)); - } -}); - -/** - * Prado TActivePanel client javascript. Usage - * - * Prado.ActivePanel.register("id", options); - * Prado.ActivePanel.update("id", "hello"); - * - */ -Prado.ActivePanel = -{ - callbacks : {}, - - register : function(id, options) - { - Prado.ActivePanel.callbacks[id] = options; - }, - - update : function(id, param) - { - var request = new Prado.ActivePanel.Request(id, - Prado.ActivePanel.callbacks[id]); - request.callback(param); - } -} - -/** - * Client-script for TActivePanel. Uses Callback to notify the server - * for updates, if update option is set, the innerHTML of the update ID - * is set to the returned output. - */ -Prado.ActivePanel.Request = Class.create(); -Prado.ActivePanel.Request.prototype = -{ - initialize : function(element, options) - { - this.element = element; - this.setOptions(options); - }, - - /** - * Set some options. - */ - setOptions : function(options) - { - this.options = - { - onSuccess : this.onSuccess.bind(this) - } - Object.extend(this.options, options || {}); - }, - - /** - * Make the callback request - */ - callback : function(param) - { - this.options.params = [param]; - new Prado.AJAX.Callback(this.element, this.options); - }, - - /** - * Callback onSuccess handler, update the element innerHTML if necessary - */ - onSuccess : function(result, output) - { - if(this.options.update) - { - if (!this.options.evalScripts) - output = output.stripScripts(); - Element.update(this.options.update, output); - } - } -} - -/** - * Drop container to accept draggable component drops. - */ -Prado.DropContainer = Class.create(); -Prado.DropContainer.prototype = Object.extend(new Prado.ActivePanel.Request(), -{ - initialize : function(element, options) - { - this.element = element; - this.setOptions(options); - Object.extend(this.options, - { - onDrop : this.onDrop.bind(this), - evalScripts : true, - onSuccess : options.onSuccess || this.onSuccess.bind(this) - }); - Droppables.add(element, this.options); - }, - - onDrop : function(draggable, droppable) - { - this.callback(draggable.id) - } -}); - -Prado.ActiveImageButton = Class.create(); -Prado.ActiveImageButton.prototype = -{ - initialize : function(element, options) - { - this.element = $(element); - this.options = options; - Event.observe(this.element, "click", this.click.bind(this)); - }, - - click : function(e) - { - var el = $('{$this->ClientID}'); - var imagePos = Position.cumulativeOffset(this.element); - var clickedPos = [e.clientX, e.clientY]; - var param = (clickedPos[0]-imagePos[0]+1)+","+(clickedPos[1]-imagePos[1]+1); - Prado.Callback(this.element, param, null, this.options); - Event.stop(e); - } -} \ No newline at end of file -- cgit v1.2.3