Lines Matching full:this

15 // that's independent of the data source for autocompletion. This
21 // the text inside the monitored textbox changes. This method
23 // invoking this.getToken(), NOT by directly accessing
24 // this.element.value. This is to allow incremental tokenized
35 // enables autocompletion on multiple tokens. This is most
46 this.element = $(element);
47 this.update = $(update);
48 this.hasFocus = false;
49 this.changed = false;
50 this.active = false;
51 this.index = 0;
52 this.entryCount = 0;
54 if(this.setOptions)
55 this.setOptions(options);
57 this.options = options || {};
59 this.options.paramName = this.options.paramName || this.element.name;
60 this.options.tokens = this.options.tokens || [];
61 this.options.frequency = this.options.frequency || 0.4;
62 this.options.minChars = this.options.minChars || 1;
63 this.options.onShow = this.options.onShow ||
74 this.options.onHide = this.options.onHide ||
77 if(typeof(this.options.tokens) == 'string')
78 this.options.tokens = new Array(this.options.tokens);
80 this.observer = null;
82 this.element.setAttribute('autocomplete','off');
84 Element.hide(this.update);
86 Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this));
87 Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this));
91 …if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update…
92 if(!this.iefix &&
95 (Element.getStyle(this.update, 'position')=='absolute')) {
96 new Insertion.After(this.update,
97 '<iframe id="' + this.update.id + '_iefix" '+
100 this.iefix = $(this.update.id+'_iefix');
102 if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50);
106 Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
107 this.iefix.style.zIndex = 1;
108 this.update.style.zIndex = 2;
109 Element.show(this.iefix);
113 this.stopIndicator();
114 …if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update…
115 if(this.iefix) Element.hide(this.iefix);
119 if(this.options.indicator) Element.show(this.options.indicator);
123 if(this.options.indicator) Element.hide(this.options.indicator);
127 if(this.active)
131 this.selectEntry();
134 this.hide();
135 this.active = false;
142 this.markPrevious();
143 this.render();
147 this.markNext();
148 this.render();
156 this.changed = true;
157 this.hasFocus = true;
159 if(this.observer) clearTimeout(this.observer);
160 this.observer =
161 setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
165 this.changed = false;
166 this.hasFocus = true;
167 this.getUpdatedChoices();
172 if(this.index != element.autocompleteIndex)
174 this.index = element.autocompleteIndex;
175 this.render();
182 this.index = element.autocompleteIndex;
183 this.selectEntry();
184 this.hide();
189 setTimeout(this.hide.bind(this), 250);
190 this.hasFocus = false;
191 this.active = false;
195 if(this.entryCount > 0) {
196 for (var i = 0; i < this.entryCount; i++)
197 this.index==i ?
198 Element.addClassName(this.getEntry(i),"selected") :
199 Element.removeClassName(this.getEntry(i),"selected");
201 if(this.hasFocus) {
202 this.show();
203 this.active = true;
206 this.active = false;
207 this.hide();
212 if(this.index > 0) this.index--
213 else this.index = this.entryCount-1;
214 this.getEntry(this.index).scrollIntoView(true);
218 if(this.index < this.entryCount-1) this.index++
219 else this.index = 0;
220 this.getEntry(this.index).scrollIntoView(false);
224 return this.update.firstChild.childNodes[index];
228 return this.getEntry(this.index);
232 this.active = false;
233 this.updateElement(this.getCurrentEntry());
237 if (this.options.updateElement) {
238 this.options.updateElement(selectedElement);
242 if (this.options.select) {
243 var nodes = document.getElementsByClassName(this.options.select, selectedElement) || [];
244 if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
248 var lastTokenPos = this.findLastToken();
250 var newValue = this.element.value.substr(0, lastTokenPos + 1);
251 var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/);
254 this.element.value = newValue + value;
256 this.element.value = value;
258 this.element.focus();
260 if (this.options.afterUpdateElement)
261 this.options.afterUpdateElement(this.element, selectedElement);
265 if(!this.changed && this.hasFocus) {
266 this.update.innerHTML = choices;
267 Element.cleanWhitespace(this.update);
268 Element.cleanWhitespace(this.update.down());
270 if(this.update.firstChild && this.update.down().childNodes) {
271 this.entryCount =
272 this.update.down().childNodes.length;
273 for (var i = 0; i < this.entryCount; i++) {
274 var entry = this.getEntry(i);
276 this.addObservers(entry);
279 this.entryCount = 0;
282 this.stopIndicator();
283 this.index = 0;
285 if(this.entryCount==1 && this.options.autoSelect) {
286 this.selectEntry();
287 this.hide();
289 this.render();
295 Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));
296 Event.observe(element, "click", this.onClick.bindAsEventListener(this));
300 this.changed = false;
301 if(this.getToken().length>=this.options.minChars) {
302 this.startIndicator();
303 this.getUpdatedChoices();
305 this.active = false;
306 this.hide();
311 var tokenPos = this.findLastToken();
313 var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,'');
315 var ret = this.element.value;
323 for (var i=0; i<this.options.tokens.length; i++) {
324 var thisTokenPos = this.element.value.lastIndexOf(this.options.tokens[i]);
335 this.baseInitialize(element, update, options);
336 this.options.asynchronous = true;
337 this.options.onComplete = this.onComplete.bind(this);
338 this.options.defaultParams = this.options.parameters || null;
339 this.url = url;
343 entry = encodeURIComponent(this.options.paramName) + '=' +
344 encodeURIComponent(this.getToken());
346 this.options.parameters = this.options.callback ?
347 this.options.callback(this.element, entry) : entry;
349 if(this.options.defaultParams)
350 this.options.parameters += '&' + this.options.defaultParams;
352 new Ajax.Request(this.url, this.options);
356 this.updateChoices(request.responseText);
399 this.baseInitialize(element, update, options);
400 this.options.array = array;
404 this.updateChoices(this.options.selector(this));
408 this.options = Object.extend({
461 // Use this if you notice weird scrolling problems on some browsers,
462 // the DOM might be a bit confused when this gets called so do this
474 this.url = url;
475 this.element = $(element);
477 this.options = Object.extend({
488 new Effect.Highlight(element, {startcolor: this.options.highlightcolor});
509 if(!this.options.formId && this.element.id) {
510 this.options.formId = this.element.id + "-inplaceeditor";
511 if ($(this.options.formId)) {
513 this.options.formId = null;
517 if (this.options.externalControl) {
518 this.options.externalControl = $(this.options.externalControl);
521 this.originalBackground = Element.getStyle(this.element, 'background-color');
522 if (!this.originalBackground) {
523 this.originalBackground = "transparent";
526 this.element.title = this.options.clickToEditText;
528 this.onclickListener = this.enterEditMode.bindAsEventListener(this);
529 this.mouseoverListener = this.enterHover.bindAsEventListener(this);
530 this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
531 Event.observe(this.element, 'click', this.onclickListener);
532 Event.observe(this.element, 'mouseover', this.mouseoverListener);
533 Event.observe(this.element, 'mouseout', this.mouseoutListener);
534 if (this.options.externalControl) {
535 Event.observe(this.options.externalControl, 'click', this.onclickListener);
536 Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
537 Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
541 if (this.saving) return;
542 if (this.editing) return;
543 this.editing = true;
544 this.onEnterEditMode();
545 if (this.options.externalControl) {
546 Element.hide(this.options.externalControl);
548 Element.hide(this.element);
549 this.createForm();
550 this.element.parentNode.insertBefore(this.form, this.element);
551 if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField);
559 this.form = document.createElement("form");
560 this.form.id = this.options.formId;
561 Element.addClassName(this.form, this.options.formClassName)
562 this.form.onsubmit = this.onSubmit.bind(this);
564 this.createEditField();
566 if (this.options.textarea) {
568 this.form.appendChild(br);
571 if (this.options.okButton) {
574 okButton.value = this.options.okText;
576 this.form.appendChild(okButton);
579 if (this.options.cancelLink) {
582 cancelLink.appendChild(document.createTextNode(this.options.cancelText));
583 cancelLink.onclick = this.onclickCancel.bind(this);
585 this.form.appendChild(cancelLink);
589 if (!this.options.handleLineBreaks) return false;
597 if(this.options.loadTextURL) {
598 text = this.options.loadingText;
600 text = this.getText();
603 var obj = this;
605 if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
606 this.options.textarea = false;
608 textField.obj = this;
610 textField.name = this.options.paramName;
612 textField.style.backgroundColor = this.options.highlightcolor;
614 var size = this.options.size || this.options.cols || 0;
616 if (this.options.submitOnBlur)
617 textField.onblur = this.onSubmit.bind(this);
618 this.editField = textField;
620 this.options.textarea = true;
622 textArea.obj = this;
623 textArea.name = this.options.paramName;
624 textArea.value = this.convertHTMLLineBreaks(text);
625 textArea.rows = this.options.rows;
626 textArea.cols = this.options.cols || 40;
628 if (this.options.submitOnBlur)
629 textArea.onblur = this.onSubmit.bind(this);
630 this.editField = textArea;
633 if(this.options.loadTextURL) {
634 this.loadExternalText();
636 this.form.appendChild(this.editField);
639 return this.element.innerHTML;
642 Element.addClassName(this.form, this.options.loadingClassName);
643 this.editField.disabled = true;
645 this.options.loadTextURL,
648 onComplete: this.onLoadedExternalText.bind(this)
649 }, this.options.ajaxOptions)
653 Element.removeClassName(this.form, this.options.loadingClassName);
654 this.editField.disabled = false;
655 this.editField.value = transport.responseText.stripTags();
656 Field.scrollFreeActivate(this.editField);
659 this.onComplete();
660 this.leaveEditMode();
664 this.options.onFailure(transport);
665 if (this.oldInnerHTML) {
666 this.element.innerHTML = this.oldInnerHTML;
667 this.oldInnerHTML = null;
673 var form = this.form;
674 var value = this.editField.value;
676 // do this first, sometimes the ajax call returns before we get a chance to switch on Saving...
677 …// which means this will actually switch on Saving... *after* we've left edit mode causing Saving.…
679 this.onLoading();
681 if (this.options.evalScripts) {
683 this.url, Object.extend({
684 parameters: this.options.callback(form, value),
685 onComplete: this.onComplete.bind(this),
686 onFailure: this.onFailure.bind(this),
689 }, this.options.ajaxOptions));
692 { success: this.element,
693 // don't update on failure (this could be an option)
695 this.url, Object.extend({
696 parameters: this.options.callback(form, value),
697 onComplete: this.onComplete.bind(this),
698 onFailure: this.onFailure.bind(this)
699 }, this.options.ajaxOptions));
708 this.saving = true;
709 this.removeForm();
710 this.leaveHover();
711 this.showSaving();
714 this.oldInnerHTML = this.element.innerHTML;
715 this.element.innerHTML = this.options.savingText;
716 Element.addClassName(this.element, this.options.savingClassName);
717 this.element.style.backgroundColor = this.originalBackground;
718 Element.show(this.element);
721 if(this.form) {
722 if (this.form.parentNode) Element.remove(this.form);
723 this.form = null;
727 if (this.saving) return;
728 this.element.style.backgroundColor = this.options.highlightcolor;
729 if (this.effect) {
730 this.effect.cancel();
732 Element.addClassName(this.element, this.options.hoverClassName)
735 if (this.options.backgroundColor) {
736 this.element.style.backgroundColor = this.oldBackground;
738 Element.removeClassName(this.element, this.options.hoverClassName)
739 if (this.saving) return;
740 this.effect = new Effect.Highlight(this.element, {
741 startcolor: this.options.highlightcolor,
742 endcolor: this.options.highlightendcolor,
743 restorecolor: this.originalBackground
747 Element.removeClassName(this.element, this.options.savingClassName);
748 this.removeForm();
749 this.leaveHover();
750 this.element.style.backgroundColor = this.originalBackground;
751 Element.show(this.element);
752 if (this.options.externalControl) {
753 Element.show(this.options.externalControl);
755 this.editing = false;
756 this.saving = false;
757 this.oldInnerHTML = null;
758 this.onLeaveEditMode();
761 this.leaveEditMode();
762 this.options.onComplete.bind(this)(transport, this.element);
767 if (this.oldInnerHTML) {
768 this.element.innerHTML = this.oldInnerHTML;
770 this.leaveEditMode();
771 Event.stopObserving(this.element, 'click', this.onclickListener);
772 Event.stopObserving(this.element, 'mouseover', this.mouseoverListener);
773 Event.stopObserving(this.element, 'mouseout', this.mouseoutListener);
774 if (this.options.externalControl) {
775 Event.stopObserving(this.options.externalControl, 'click', this.onclickListener);
776 Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener);
777 Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener);
786 if (!this.cached_selectTag) {
788 var collection = this.options.collection || [];
793 if((typeof this.options.value == 'undefined') &&
794 …((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected…
795 if(this.options.value==optionTag.value) optionTag.selected = true;
798 }.bind(this));
799 this.cached_selectTag = selectTag;
802 this.editField = this.cached_selectTag;
803 if(this.options.loadTextURL) this.loadExternalText();
804 this.form.appendChild(this.editField);
805 this.options.callback = function(form, value) {
818 this.delay = delay || 0.5;
819 this.element = $(element);
820 this.callback = callback;
821 this.timer = null;
822 this.lastValue = $F(this.element);
823 Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
826 if(this.lastValue == $F(this.element)) return;
827 if(this.timer) clearTimeout(this.timer);
828 this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);
829 this.lastValue = $F(this.element);
832 this.timer = null;
833 this.callback(this.element, $F(this.element));