+++ /dev/null
-var Autocompleter={};Autocompleter.Base=Class.create({baseInitialize:function(b,c,a){this.element=$(b);this.update=$(c).hide();this.active=this.changed=this.hasFocus=false;this.entryCount=this.index=0;this.observer=null;this.oldval=$F(this.element);this.options=Object.extend({paramName:this.element.name,tokens:[],frequency:0.4,minChars:1,onHide:this._onHide.bind(this),onShow:this._onShow.bind(this)},(this._setOptions?this._setOptions(a):(a||{})));if(!this.options.tokens.include("\n")){this.options.tokens.push("\n")}this.element.writeAttribute("autocomplete","off").observe("blur",this._onBlur.bindAsEventListener(this)).observe(Prototype.Browser.Gecko?"keypress":"keydown",this._onKeyPress.bindAsEventListener(this))},_onShow:function(a,e){var d,b=e.getStyle("position");if(!b||b=="absolute"){d=(Prototype.Browser.IE)?a.cumulativeScrollOffset():[0];e.setStyle({position:"absolute"}).clonePosition(a,{setHeight:false,offsetTop:a.offsetHeight,offsetLeft:d[0]})}new Effect.Appear(e,{duration:0.15})},_onHide:function(a,b){new Effect.Fade(b,{duration:0.15})},show:function(){if(!this.update.visible()){this.options.onShow(this.element,this.update)}if(Prototype.Browser.IE&&!this.iefix&&this.update.getStyle("position")=="absolute"){this.iefix=new Element("IFRAME",{src:"javascript:false;",frameborder:0,scrolling:"no"}).setStyle({position:"absolute",filter:"progid:DXImageTransform.Microsoft.Alpha(opactiy=0)",zIndex:1}).hide();this.update.setStyle({zIndex:2}).insert({after:this.iefix})}if(this.iefix){this._fixIEOverlapping.bind(this).delay(0.05)}},_fixIEOverlapping:function(){this.iefix.clonePosition(this.update).show()},hide:function(){this.stopIndicator();if(this.update.visible()){this.options.onHide(this.element,this.update);if(this.iefix){this.iefix.hide()}}},startIndicator:function(){if(this.options.indicator){$(this.options.indicator).show()}},stopIndicator:function(){if(this.options.indicator){$(this.options.indicator).hide()}},_onKeyPress:function(a){if(this.active){switch(a.keyCode){case Event.KEY_TAB:case Event.KEY_RETURN:this.selectEntry();a.stop();return;case Event.KEY_ESC:this.hide();this.active=false;a.stop();return;case Event.KEY_LEFT:case Event.KEY_RIGHT:return;case Event.KEY_UP:case Event.KEY_DOWN:if(a.keyCode==Event.KEY_UP){this.markPrevious()}else{this.markNext()}this.render();a.stop();return}}else{switch(a.keyCode){case 0:if(!Prototype.Browser.WebKit){break}case Event.KEY_TAB:case Event.KEY_RETURN:return}}this.changed=this.hasFocus=true;if(this.observer){clearTimeout(this.observer)}this.observer=this.onObserverEvent.bind(this).delay(this.options.frequency)},_onHover:function(c){var b=c.findElement("LI"),a=b.readAttribute("acIndex");if(this.index!=a){this.index=a;this.render()}c.stop()},_onClick:function(a){this.index=a.findElement("LI").readAttribute("acIndex");this.selectEntry()},_onBlur:function(a){this.hide.bind(this).delay(0.25);this.active=this.hasFocus=false},render:function(){var a=0;if(this.entryCount){this.update.down().childElements().each(function(b){[b].invoke(this.index==a++?"addClassName":"removeClassName","selected")},this);if(this.hasFocus){this.show();this.active=true}}else{this.active=false;this.hide()}},markPrevious:function(){if(this.index){--this.index}else{this.index=this.entryCount-1}this.getEntry(this.index).scrollIntoView(true)},markNext:function(){if(this.index<this.entryCount-1){++this.index}else{this.index=0}this.getEntry(this.index).scrollIntoView(false)},getEntry:function(a){return this.update.down().childElements()[a]},selectEntry:function(){this.active=false;this.updateElement(this.getEntry(this.index));this.hide()},updateElement:function(d){var e,g,b,c,a,h=this.options,f="";if(h.updateElement){h.updateElement(d);return}if(h.select){b=$(d).select("."+h.select)||[];if(b.size()){f=b[0].collectTextNodes(h.select)}}else{f=d.collectTextNodesIgnoreClass("informal")}e=this.getTokenBounds();if(e[0]!=-1){a=$F(this.element);g=a.substr(0,e[0]);c=a.substr(e[0]).match(/^\s+/);if(c){g+=c[0]}this.element.setValue(g+f+a.substr(e[1]))}else{this.element.setValue(f)}this.element.focus();if(h.afterUpdateElement){h.afterUpdateElement(this.element,d)}this.oldval=$F(this.element)},updateChoices:function(e){var a,d,c,b=0;if(!this.changed&&this.hasFocus){a=new Element("LI");c=new Element("UL");d=new RegExp("("+this.getToken()+")","i");e.each(function(f){c.insert(a.cloneNode(false).writeAttribute("acIndex",b++).update(f.gsub(d,"<strong>#{1}</strong>")))});this.update.update(c);this.entryCount=e.size();c.childElements().each(this.addObservers.bind(this));this.stopIndicator();this.index=0;if(this.entryCount==1&&this.options.autoSelect){this.selectEntry()}else{this.render()}}},addObservers:function(a){$(a).observe("mouseover",this._onHover.bindAsEventListener(this)).observe("click",this._onClick.bindAsEventListener(this))},onObserverEvent:function(){this.changed=false;if(this.getToken().length>=this.options.minChars){this.getUpdatedChoices()}else{this.active=false;this.hide()}this.oldval=$F(this.element)},getToken:function(){var a=this.getTokenBounds();return $F(this.element).substring(a[0],a[1]).strip()},getTokenBounds:function(){var j,e,f,c,d,g,m=this.options.tokens,k=$F(this.element),h=k.length,b=-1,a=Math.min(h,this.oldval.length);if(k.strip().empty()){return[-1,0]}j=a;for(e=0;e<a;++e){if(k[e]!=this.oldval[e]){j=e;break}}d=(j==this.oldval.length?1:0);for(f=0,c=m.length;f<c;++f){g=k.lastIndexOf(m[f],j+d-1);if(g>b){b=g}g=k.indexOf(m[f],j+d);if(g!=-1&&g<h){h=g}}return[b+1,h]}});Ajax.Autocompleter=Class.create(Autocompleter.Base,{initialize:function(c,d,b,a){this.baseInitialize(c,d,a);this.options=Object.extend(this.options,{asynchronous:true,onComplete:this._onComplete.bind(this),defaultParams:$H(this.options.parameters)});this.url=b;this.cache=$H()},getUpdatedChoices:function(){var b,d=this.options,a=this.getToken(),e=this.cache.get(a);if(e){this.updateChoices(e)}else{b=Object.clone(d.defaultParams);this.startIndicator();b.set(d.paramName,a);d.parameters=b.toQueryString();new Ajax.Request(this.url,d)}},_onComplete:function(a){this.updateChoices(this.cache.set(this.getToken(),a.responseJSON))}});Autocompleter.Local=Class.create(Autocompleter.Base,{initialize:function(c,d,a,b){this.baseInitialize(c,d,b);this.options.arr=a},getUpdatedChoices:function(){this.updateChoices(this._selector())},_setOptions:function(a){return Object.extend({choices:10,partialSearch:true,partialChars:2,ignoreCase:true,fullSearch:false},a||{})},_selector:function(){var b=this.getToken(),c=b.length,a=0,d=this.options;if(d.ignoreCase){b=b.toLowerCase()}return d.arr.findAll(function(e){if(a==d.choices){throw $break}if(d.ignoreCase){e=e.toLowerCase()}e=e.unescapeHTML();var f=e.indexOf(b);if(f!=-1&&((f==0&&e.length!=c)||(c>=d.partialChars&&d.partialSearch&&(d.fullSearch||/\s/.test(e.substr(f-1,1)))))){++a;return true}return false},this)}});
\ No newline at end of file
+++ /dev/null
-/**
- * autocomplete.js - A javascript library which implements autocomplete.
- * Requires prototype.js v1.6.0.2+ and scriptaculous v1.8.0+ (effects.js)
- *
- * Adapted from script.aculo.us controls.js v1.8.0
- * (c) 2005-2007 Thomas Fuchs, Ivan Krstic, and Jon Tirsen
- * Contributors: Richard Livsey, Rahul Bhargava, Rob Wills
- * http://script.aculo.us/
- *
- * The original script was freely distributable under the terms of an
- * MIT-style license.
- *
- * Copyright 2007-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- */
-
-var Autocompleter = {};
-Autocompleter.Base = Class.create({
- baseInitialize: function(element, update, options)
- {
- this.element = $(element);
- this.update = $(update).hide();
- this.active = this.changed = this.hasFocus = false;
- this.entryCount = this.index = 0;
- this.observer = null;
- this.oldval = $F(this.element);
-
- this.options = Object.extend({
- paramName: this.element.name,
- tokens: [],
- frequency: 0.4,
- minChars: 1,
- onHide: this._onHide.bind(this),
- onShow: this._onShow.bind(this)
- }, (this._setOptions ? this._setOptions(options) : (options || {})));
-
- // Force carriage returns as token delimiters anyway
- if (!this.options.tokens.include('\n')) {
- this.options.tokens.push('\n');
- }
-
- this.element.writeAttribute('autocomplete', 'off').observe("blur", this._onBlur.bindAsEventListener(this)).observe(Prototype.Browser.Gecko ? "keypress" : "keydown", this._onKeyPress.bindAsEventListener(this));
- },
-
- _onShow: function(elt, update)
- {
- var c, p = update.getStyle('position');
- if (!p || p == 'absolute') {
- // Temporary fix for Bug #7074 - Fixed as of prototypejs 1.6.0.3
- c = (Prototype.Browser.IE) ? elt.cumulativeScrollOffset() : [ 0 ];
- update.setStyle({ position: 'absolute' }).clonePosition(elt, {
- setHeight: false,
- offsetTop: elt.offsetHeight,
- offsetLeft: c[0]
- });
- }
- new Effect.Appear(update, { duration: 0.15 });
- },
-
- _onHide: function(elt, update)
- {
- new Effect.Fade(update, { duration: 0.15 });
- },
-
- show: function()
- {
- if (!this.update.visible()) {
- this.options.onShow(this.element, this.update);
- }
-
- if (Prototype.Browser.IE &&
- !this.iefix &&
- this.update.getStyle('position') == 'absolute') {
- this.iefix = new Element('IFRAME', { src: 'javascript:false;', frameborder: 0, scrolling: 'no' }).setStyle({ position: 'absolute', filter: 'progid:DXImageTransform.Microsoft.Alpha(opactiy=0)', zIndex: 1 }).hide();
- this.update.setStyle({ zIndex: 2 }).insert({ after: this.iefix });
- }
-
- if (this.iefix) {
- this._fixIEOverlapping.bind(this).delay(0.05);
- }
- },
-
- _fixIEOverlapping: function()
- {
- this.iefix.clonePosition(this.update).show();
- },
-
- hide: function()
- {
- this.stopIndicator();
- if (this.update.visible()) {
- this.options.onHide(this.element, this.update);
- if (this.iefix) {
- this.iefix.hide();
- }
- }
- },
-
- startIndicator: function()
- {
- if (this.options.indicator) {
- $(this.options.indicator).show();
- }
- },
-
- stopIndicator: function()
- {
- if (this.options.indicator) {
- $(this.options.indicator).hide();
- }
- },
-
- _onKeyPress: function(e)
- {
- if (this.active) {
- switch (e.keyCode) {
- case Event.KEY_TAB:
- case Event.KEY_RETURN:
- this.selectEntry();
- e.stop();
- return;
-
- case Event.KEY_ESC:
- this.hide();
- this.active = false;
- e.stop();
- return;
-
- case Event.KEY_LEFT:
- case Event.KEY_RIGHT:
- return;
-
- case Event.KEY_UP:
- case Event.KEY_DOWN:
- if (e.keyCode == Event.KEY_UP) {
- this.markPrevious();
- } else {
- this.markNext();
- }
- this.render();
- e.stop();
- return;
- }
- } else {
- switch (e.keyCode) {
- case 0:
- if (!Prototype.Browser.WebKit) {
- break;
- }
- // Fall through to below case
- //
- case Event.KEY_TAB:
- case Event.KEY_RETURN:
- return;
- }
- }
-
- this.changed = this.hasFocus = true;
-
- if (this.observer) {
- clearTimeout(this.observer);
- }
- this.observer = this.onObserverEvent.bind(this).delay(this.options.frequency);
- },
-
- _onHover: function(e)
- {
- var elt = e.findElement('LI'),
- index = elt.readAttribute('acIndex');
- if (this.index != index) {
- this.index = index;
- this.render();
- }
- e.stop();
- },
-
- _onClick: function(e)
- {
- this.index = e.findElement('LI').readAttribute('acIndex');
- this.selectEntry();
- },
-
- _onBlur: function(e)
- {
- // Needed to make click events work
- this.hide.bind(this).delay(0.25);
- this.active = this.hasFocus = false;
- },
-
- render: function()
- {
- var i = 0;
-
- if (this.entryCount) {
- this.update.down().childElements().each(function(e) {
- [ e ].invoke(this.index == i++ ? 'addClassName' : 'removeClassName', 'selected');
- }, this);
- if (this.hasFocus) {
- this.show();
- this.active = true;
- }
- } else {
- this.active = false;
- this.hide();
- }
- },
-
- markPrevious: function()
- {
- if (this.index) {
- --this.index;
- } else {
- this.index = this.entryCount - 1;
- }
- this.getEntry(this.index).scrollIntoView(true);
- },
-
- markNext: function()
- {
- if (this.index < this.entryCount - 1) {
- ++this.index;
- } else {
- this.index = 0;
- }
- this.getEntry(this.index).scrollIntoView(false);
- },
-
- getEntry: function(index)
- {
- return this.update.down().childElements()[index];
- },
-
- selectEntry: function()
- {
- this.active = false;
- this.updateElement(this.getEntry(this.index));
- this.hide();
- },
-
- updateElement: function(elt)
- {
- var bounds, newValue, nodes, whitespace, v,
- o = this.options,
- value = '';
-
- if (o.updateElement) {
- o.updateElement(elt);
- return;
- }
-
- if (o.select) {
- nodes = $(elt).select('.' + o.select) || [];
- if (nodes.size()) {
- value = nodes[0].collectTextNodes(o.select);
- }
- } else {
- value = elt.collectTextNodesIgnoreClass('informal');
- }
-
- bounds = this.getTokenBounds();
- if (bounds[0] != -1) {
- v = $F(this.element);
- newValue = v.substr(0, bounds[0]);
- whitespace = v.substr(bounds[0]).match(/^\s+/);
- if (whitespace) {
- newValue += whitespace[0];
- }
- this.element.setValue(newValue + value + v.substr(bounds[1]));
- } else {
- this.element.setValue(value);
- }
- this.element.focus();
-
- if (o.afterUpdateElement) {
- o.afterUpdateElement(this.element, elt);
- }
-
- this.oldval = $F(this.element);
- },
-
- updateChoices: function(choices)
- {
- var li, re, ul,
- i = 0;
-
- if (!this.changed && this.hasFocus) {
- li = new Element('LI');
- ul = new Element('UL');
- re = new RegExp("(" + this.getToken() + ")", "i");
-
- choices.each(function(n) {
- ul.insert(li.cloneNode(false).writeAttribute('acIndex', i++).update(n.gsub(re, '<strong>#{1}</strong>')));
- });
-
- this.update.update(ul);
- this.entryCount = choices.size();
- ul.childElements().each(this.addObservers.bind(this));
-
- this.stopIndicator();
- this.index = 0;
-
- if (this.entryCount == 1 && this.options.autoSelect) {
- this.selectEntry();
- } else {
- this.render();
- }
- }
- },
-
- addObservers: function(elt)
- {
- $(elt).observe("mouseover", this._onHover.bindAsEventListener(this)).observe("click", this._onClick.bindAsEventListener(this));
- },
-
- onObserverEvent: function()
- {
- this.changed = false;
- if (this.getToken().length >= this.options.minChars) {
- this.getUpdatedChoices();
- } else {
- this.active = false;
- this.hide();
- }
- this.oldval = $F(this.element);
- },
-
- getToken: function()
- {
- var bounds = this.getTokenBounds();
- return $F(this.element).substring(bounds[0], bounds[1]).strip();
- },
-
- getTokenBounds: function()
- {
- var diff, i, index, l, offset, tp,
- t = this.options.tokens,
- value = $F(this.element),
- nextTokenPos = value.length,
- prevTokenPos = -1,
- boundary = Math.min(nextTokenPos, this.oldval.length);
-
- if (value.strip().empty()) {
- return [ -1, 0 ];
- }
-
- diff = boundary;
- for (i = 0; i < boundary; ++i) {
- if (value[i] != this.oldval[i]) {
- diff = i;
- break;
- }
- }
-
- offset = (diff == this.oldval.length ? 1 : 0);
-
- for (index = 0, l = t.length; index < l; ++index) {
- tp = value.lastIndexOf(t[index], diff + offset - 1);
- if (tp > prevTokenPos) {
- prevTokenPos = tp;
- }
- tp = value.indexOf(t[index], diff + offset);
- if (tp != -1 && tp < nextTokenPos) {
- nextTokenPos = tp;
- }
- }
- return [ prevTokenPos + 1, nextTokenPos ];
- }
-});
-
-Ajax.Autocompleter = Class.create(Autocompleter.Base, {
- initialize: function(element, update, url, options)
- {
- this.baseInitialize(element, update, options);
- this.options = Object.extend(this.options, {
- asynchronous: true,
- onComplete: this._onComplete.bind(this),
- defaultParams: $H(this.options.parameters)
- });
- this.url = url;
- this.cache = $H();
- },
-
- getUpdatedChoices: function()
- {
- var p,
- o = this.options,
- t = this.getToken(),
- c = this.cache.get(t);
-
- if (c) {
- this.updateChoices(c);
- } else {
- p = Object.clone(o.defaultParams);
- this.startIndicator();
- p.set(o.paramName, t);
- o.parameters = p.toQueryString();
- new Ajax.Request(this.url, o);
- }
- },
-
- _onComplete: function(request)
- {
- this.updateChoices(this.cache.set(this.getToken(), request.responseJSON));
- }
-});
-
-Autocompleter.Local = Class.create(Autocompleter.Base, {
- initialize: function(element, update, arr, options)
- {
- this.baseInitialize(element, update, options);
- this.options.arr = arr;
- },
-
- getUpdatedChoices: function()
- {
- this.updateChoices(this._selector());
- },
-
- _setOptions: function(options)
- {
- return Object.extend({
- choices: 10,
- partialSearch: true,
- partialChars: 2,
- ignoreCase: true,
- fullSearch: false
- }, options || {});
- },
-
- _selector: function()
- {
- var entry = this.getToken(),
- entry_len = entry.length,
- i = 0,
- o = this.options;
-
- if (o.ignoreCase) {
- entry = entry.toLowerCase();
- }
-
- return o.arr.findAll(function(t) {
- if (i == o.choices) {
- throw $break;
- }
-
- if (o.ignoreCase) {
- t = t.toLowerCase();
- }
- t = t.unescapeHTML();
-
- var pos = t.indexOf(entry);
- if (pos != -1 &&
- ((pos == 0 && t.length != entry_len) ||
- (entry_len >= o.partialChars &&
- o.partialSearch &&
- (o.fullSearch || /\s/.test(t.substr(pos - 1, 1)))))) {
- ++i;
- return true;
- }
- return false;
- }, this);
- }
-});
public function attach()
{
parent::attach();
- Horde::addScriptFile('autocomplete.js', 'imp', true);
+ Horde::addScriptFile('autocomplete.js', 'horde', true);
$params = array(
'"' . $this->_params['triggerId'] . '"',
+++ /dev/null
-var Autocompleter={};Autocompleter.Base=Class.create({baseInitialize:function(B,C,A){this.element=$(B);this.update=$(C).hide();this.active=this.changed=this.hasFocus=false;this.entryCount=this.index=0;this.observer=null;this.oldval=$F(this.element);this.options=Object.extend({paramName:this.element.name,tokens:[],frequency:0.4,minChars:1,onHide:this._onHide.bind(this),onShow:this._onShow.bind(this)},(this._setOptions?this._setOptions(A):(A||{})));if(!this.options.tokens.include("\n")){this.options.tokens.push("\n")}this.element.writeAttribute("autocomplete","off").observe("blur",this._onBlur.bindAsEventListener(this)).observe(Prototype.Browser.Gecko?"keypress":"keydown",this._onKeyPress.bindAsEventListener(this))},_onShow:function(A,D){var C,B=D.getStyle("position");if(!B||B=="absolute"){C=(Prototype.Browser.IE)?A.cumulativeScrollOffset():[0];D.setStyle({position:"absolute"}).clonePosition(A,{setHeight:false,offsetTop:A.offsetHeight,offsetLeft:C[0]})}new Effect.Appear(D,{duration:0.15})},_onHide:function(A,B){new Effect.Fade(B,{duration:0.15})},show:function(){if(!this.update.visible()){this.options.onShow(this.element,this.update)}if(Prototype.Browser.IE&&!this.iefix&&this.update.getStyle("position")=="absolute"){this.iefix=new Element("IFRAME",{src:"javascript:false;",frameborder:0,scrolling:"no"}).setStyle({position:"absolute",filter:"progid:DXImageTransform.Microsoft.Alpha(opactiy=0)",zIndex:1}).hide();this.update.setStyle({zIndex:2}).insert({after:this.iefix})}if(this.iefix){this._fixIEOverlapping.bind(this).delay(0.05)}},_fixIEOverlapping:function(){this.iefix.clonePosition(this.update).show()},hide:function(){this.stopIndicator();if(this.update.visible()){this.options.onHide(this.element,this.update);if(this.iefix){this.iefix.hide()}}},startIndicator:function(){if(this.options.indicator){$(this.options.indicator).show()}},stopIndicator:function(){if(this.options.indicator){$(this.options.indicator).hide()}},_onKeyPress:function(A){if(this.active){switch(A.keyCode){case Event.KEY_TAB:case Event.KEY_RETURN:this.selectEntry();A.stop();return;case Event.KEY_ESC:this.hide();this.active=false;A.stop();return;case Event.KEY_LEFT:case Event.KEY_RIGHT:return;case Event.KEY_UP:case Event.KEY_DOWN:if(A.keyCode==Event.KEY_UP){this.markPrevious()}else{this.markNext()}this.render();A.stop();return}}else{switch(A.keyCode){case 0:if(!Prototype.Browser.WebKit){break}case Event.KEY_TAB:case Event.KEY_RETURN:return}}this.changed=this.hasFocus=true;if(this.observer){clearTimeout(this.observer)}this.observer=this.onObserverEvent.bind(this).delay(this.options.frequency)},_onHover:function(C){var B=C.findElement("LI"),A=B.readAttribute("acIndex");if(this.index!=A){this.index=A;this.render()}C.stop()},_onClick:function(A){this.index=A.findElement("LI").readAttribute("acIndex");this.selectEntry()},_onBlur:function(A){this.hide.bind(this).delay(0.25);this.active=this.hasFocus=false},render:function(){var A=0;if(this.entryCount){this.update.down().childElements().each(function(B){[B].invoke(this.index==A++?"addClassName":"removeClassName","selected")},this);if(this.hasFocus){this.show();this.active=true}}else{this.active=false;this.hide()}},markPrevious:function(){if(this.index){--this.index}else{this.index=this.entryCount-1}this.getEntry(this.index).scrollIntoView(true)},markNext:function(){if(this.index<this.entryCount-1){++this.index}else{this.index=0}this.getEntry(this.index).scrollIntoView(false)},getEntry:function(A){return this.update.down().childElements()[A]},selectEntry:function(){this.active=false;this.updateElement(this.getEntry(this.index));this.hide()},updateElement:function(D){var E,G,B,C,A,H=this.options,F="";if(H.updateElement){H.updateElement(D);return}if(H.select){B=$(D).select("."+H.select)||[];if(B.size()){F=B[0].collectTextNodes(H.select)}}else{F=D.collectTextNodesIgnoreClass("informal")}E=this.getTokenBounds();if(E[0]!=-1){A=$F(this.element);G=A.substr(0,E[0]);C=A.substr(E[0]).match(/^\s+/);if(C){G+=C[0]}this.element.setValue(G+F+A.substr(E[1]))}else{this.element.setValue(F)}this.element.focus();if(H.afterUpdateElement){H.afterUpdateElement(this.element,D)}this.oldval=$F(this.element)},updateChoices:function(E){var A,D,C,B=0;if(!this.changed&&this.hasFocus){A=new Element("LI");C=new Element("UL");D=new RegExp("("+this.getToken()+")","i");E.each(function(F){C.insert(A.cloneNode(false).writeAttribute("acIndex",B++).update(F.gsub(D,"<strong>#{1}</strong>")))});this.update.update(C);this.entryCount=E.size();C.childElements().each(this.addObservers.bind(this));this.stopIndicator();this.index=0;if(this.entryCount==1&&this.options.autoSelect){this.selectEntry()}else{this.render()}}},addObservers:function(A){$(A).observe("mouseover",this._onHover.bindAsEventListener(this)).observe("click",this._onClick.bindAsEventListener(this))},onObserverEvent:function(){this.changed=false;if(this.getToken().length>=this.options.minChars){this.getUpdatedChoices()}else{this.active=false;this.hide()}this.oldval=$F(this.element)},getToken:function(){var A=this.getTokenBounds();return $F(this.element).substring(A[0],A[1]).strip()},getTokenBounds:function(){var I,E,F,C,D,G,K=this.options.tokens,J=$F(this.element),H=J.length,B=-1,A=Math.min(H,this.oldval.length);if(J.strip().empty()){return[-1,0]}I=A;for(E=0;E<A;++E){if(J[E]!=this.oldval[E]){I=E;break}}D=(I==this.oldval.length?1:0);for(F=0,C=K.length;F<C;++F){G=J.lastIndexOf(K[F],I+D-1);if(G>B){B=G}G=J.indexOf(K[F],I+D);if(G!=-1&&G<H){H=G}}return[B+1,H]}});Ajax.Autocompleter=Class.create(Autocompleter.Base,{initialize:function(C,D,B,A){this.baseInitialize(C,D,A);this.options=Object.extend(this.options,{asynchronous:true,onComplete:this._onComplete.bind(this),defaultParams:$H(this.options.parameters)});this.url=B;this.cache=$H()},getUpdatedChoices:function(){var B,C=this.options,A=this.getToken(),D=this.cache.get(A);if(D){this.updateChoices(D)}else{B=Object.clone(C.defaultParams);this.startIndicator();B.set(C.paramName,A);C.parameters=B.toQueryString();new Ajax.Request(this.url,C)}},_onComplete:function(A){this.updateChoices(this.cache.set(this.getToken(),A.responseJSON))}});Autocompleter.Local=Class.create(Autocompleter.Base,{initialize:function(C,D,A,B){this.baseInitialize(C,D,B);this.options.arr=A},getUpdatedChoices:function(){this.updateChoices(this._selector())},_setOptions:function(A){return Object.extend({choices:10,partialSearch:true,partialChars:2,ignoreCase:true,fullSearch:false},A||{})},_selector:function(){var B=this.getToken(),C=B.length,A=0,D=this.options;if(D.ignoreCase){B=B.toLowerCase()}return D.arr.findAll(function(E){if(A==D.choices){throw $break}if(D.ignoreCase){E=E.toLowerCase()}E=E.unescapeHTML();var F=E.indexOf(B);if(F!=-1&&((F==0&&E.length!=C)||(C>=D.partialChars&&D.partialSearch&&(D.fullSearch||/\s/.test(E.substr(F-1,1)))))){++A;return true}return false},this)}});
\ No newline at end of file
+++ /dev/null
-/**
- * autocomplete.js - A javascript library which implements autocomplete.
- * Requires prototype.js v1.6.0.2+ and scriptaculous v1.8.0+ (effects.js)
- *
- * Adapted from script.aculo.us controls.js v1.8.0
- * (c) 2005-2007 Thomas Fuchs, Ivan Krstic, and Jon Tirsen
- * Contributors: Richard Livsey, Rahul Bhargava, Rob Wills
- * http://script.aculo.us/
- *
- * The original script was freely distributable under the terms of an
- * MIT-style license.
- *
- * Copyright 2007-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- */
-
-var Autocompleter = {};
-Autocompleter.Base = Class.create({
- baseInitialize: function(element, update, options)
- {
- this.element = $(element);
- this.update = $(update).hide();
- this.active = this.changed = this.hasFocus = false;
- this.entryCount = this.index = 0;
- this.observer = null;
- this.oldval = $F(this.element);
-
- this.options = Object.extend({
- paramName: this.element.name,
- tokens: [],
- frequency: 0.4,
- minChars: 1,
- onHide: this._onHide.bind(this),
- onShow: this._onShow.bind(this)
- }, (this._setOptions ? this._setOptions(options) : (options || {})));
-
- // Force carriage returns as token delimiters anyway
- if (!this.options.tokens.include('\n')) {
- this.options.tokens.push('\n');
- }
-
- this.element.writeAttribute('autocomplete', 'off').observe("blur", this._onBlur.bindAsEventListener(this)).observe(Prototype.Browser.Gecko ? "keypress" : "keydown", this._onKeyPress.bindAsEventListener(this));
- },
-
- _onShow: function(elt, update)
- {
- var c, p = update.getStyle('position');
- if (!p || p == 'absolute') {
- // Temporary fix for Bug #7074 - Fixed as of prototypejs 1.6.0.3
- c = (Prototype.Browser.IE) ? elt.cumulativeScrollOffset() : [ 0 ];
- update.setStyle({ position: 'absolute' }).clonePosition(elt, {
- setHeight: false,
- offsetTop: elt.offsetHeight,
- offsetLeft: c[0]
- });
- }
- new Effect.Appear(update, { duration: 0.15 });
- },
-
- _onHide: function(elt, update)
- {
- new Effect.Fade(update, { duration: 0.15 });
- },
-
- show: function()
- {
- if (!this.update.visible()) {
- this.options.onShow(this.element, this.update);
- }
-
- if (Prototype.Browser.IE &&
- !this.iefix &&
- this.update.getStyle('position') == 'absolute') {
- this.iefix = new Element('IFRAME', { src: 'javascript:false;', frameborder: 0, scrolling: 'no' }).setStyle({ position: 'absolute', filter: 'progid:DXImageTransform.Microsoft.Alpha(opactiy=0)', zIndex: 1 }).hide();
- this.update.setStyle({ zIndex: 2 }).insert({ after: this.iefix });
- }
-
- if (this.iefix) {
- this._fixIEOverlapping.bind(this).delay(0.05);
- }
- },
-
- _fixIEOverlapping: function()
- {
- this.iefix.clonePosition(this.update).show();
- },
-
- hide: function()
- {
- this.stopIndicator();
- if (this.update.visible()) {
- this.options.onHide(this.element, this.update);
- if (this.iefix) {
- this.iefix.hide();
- }
- }
- },
-
- startIndicator: function()
- {
- if (this.options.indicator) {
- $(this.options.indicator).show();
- }
- },
-
- stopIndicator: function()
- {
- if (this.options.indicator) {
- $(this.options.indicator).hide();
- }
- },
-
- _onKeyPress: function(e)
- {
- if (this.active) {
- switch (e.keyCode) {
- case Event.KEY_TAB:
- case Event.KEY_RETURN:
- this.selectEntry();
- e.stop();
- return;
-
- case Event.KEY_ESC:
- this.hide();
- this.active = false;
- e.stop();
- return;
-
- case Event.KEY_LEFT:
- case Event.KEY_RIGHT:
- return;
-
- case Event.KEY_UP:
- case Event.KEY_DOWN:
- if (e.keyCode == Event.KEY_UP) {
- this.markPrevious();
- } else {
- this.markNext();
- }
- this.render();
- e.stop();
- return;
- }
- } else {
- switch (e.keyCode) {
- case 0:
- if (!Prototype.Browser.WebKit) {
- break;
- }
- // Fall through to below case
- //
- case Event.KEY_TAB:
- case Event.KEY_RETURN:
- return;
- }
- }
-
- this.changed = this.hasFocus = true;
-
- if (this.observer) {
- clearTimeout(this.observer);
- }
- this.observer = this.onObserverEvent.bind(this).delay(this.options.frequency);
- },
-
- _onHover: function(e)
- {
- var elt = e.findElement('LI'),
- index = elt.readAttribute('acIndex');
- if (this.index != index) {
- this.index = index;
- this.render();
- }
- e.stop();
- },
-
- _onClick: function(e)
- {
- this.index = e.findElement('LI').readAttribute('acIndex');
- this.selectEntry();
- },
-
- _onBlur: function(e)
- {
- // Needed to make click events work
- this.hide.bind(this).delay(0.25);
- this.active = this.hasFocus = false;
- },
-
- render: function()
- {
- var i = 0;
-
- if (this.entryCount) {
- this.update.down().childElements().each(function(e) {
- [ e ].invoke(this.index == i++ ? 'addClassName' : 'removeClassName', 'selected');
- }, this);
- if (this.hasFocus) {
- this.show();
- this.active = true;
- }
- } else {
- this.active = false;
- this.hide();
- }
- },
-
- markPrevious: function()
- {
- if (this.index) {
- --this.index;
- } else {
- this.index = this.entryCount - 1;
- }
- this.getEntry(this.index).scrollIntoView(true);
- },
-
- markNext: function()
- {
- if (this.index < this.entryCount - 1) {
- ++this.index;
- } else {
- this.index = 0;
- }
- this.getEntry(this.index).scrollIntoView(false);
- },
-
- getEntry: function(index)
- {
- return this.update.down().childElements()[index];
- },
-
- selectEntry: function()
- {
- this.active = false;
- this.updateElement(this.getEntry(this.index));
- this.hide();
- },
-
- updateElement: function(elt)
- {
- var bounds, newValue, nodes, whitespace, v,
- o = this.options,
- value = '';
-
- if (o.updateElement) {
- o.updateElement(elt);
- return;
- }
-
- if (o.select) {
- nodes = $(elt).select('.' + o.select) || [];
- if (nodes.size()) {
- value = nodes[0].collectTextNodes(o.select);
- }
- } else {
- value = elt.collectTextNodesIgnoreClass('informal');
- }
-
- bounds = this.getTokenBounds();
- if (bounds[0] != -1) {
- v = $F(this.element);
- newValue = v.substr(0, bounds[0]);
- whitespace = v.substr(bounds[0]).match(/^\s+/);
- if (whitespace) {
- newValue += whitespace[0];
- }
- this.element.setValue(newValue + value + v.substr(bounds[1]));
- } else {
- this.element.setValue(value);
- }
- this.element.focus();
-
- if (o.afterUpdateElement) {
- o.afterUpdateElement(this.element, elt);
- }
-
- this.oldval = $F(this.element);
- },
-
- updateChoices: function(choices)
- {
- var li, re, ul,
- i = 0;
-
- if (!this.changed && this.hasFocus) {
- li = new Element('LI');
- ul = new Element('UL');
- re = new RegExp("(" + this.getToken() + ")", "i");
-
- choices.each(function(n) {
- ul.insert(li.cloneNode(false).writeAttribute('acIndex', i++).update(n.gsub(re, '<strong>#{1}</strong>')));
- });
-
- this.update.update(ul);
- this.entryCount = choices.size();
- ul.childElements().each(this.addObservers.bind(this));
-
- this.stopIndicator();
- this.index = 0;
-
- if (this.entryCount == 1 && this.options.autoSelect) {
- this.selectEntry();
- } else {
- this.render();
- }
- }
- },
-
- addObservers: function(elt)
- {
- $(elt).observe("mouseover", this._onHover.bindAsEventListener(this)).observe("click", this._onClick.bindAsEventListener(this));
- },
-
- onObserverEvent: function()
- {
- this.changed = false;
- if (this.getToken().length >= this.options.minChars) {
- this.getUpdatedChoices();
- } else {
- this.active = false;
- this.hide();
- }
- this.oldval = $F(this.element);
- },
-
- getToken: function()
- {
- var bounds = this.getTokenBounds();
- return $F(this.element).substring(bounds[0], bounds[1]).strip();
- },
-
- getTokenBounds: function()
- {
- var diff, i, index, l, offset, tp,
- t = this.options.tokens,
- value = $F(this.element),
- nextTokenPos = value.length,
- prevTokenPos = -1,
- boundary = Math.min(nextTokenPos, this.oldval.length);
-
- if (value.strip().empty()) {
- return [ -1, 0 ];
- }
-
- diff = boundary;
- for (i = 0; i < boundary; ++i) {
- if (value[i] != this.oldval[i]) {
- diff = i;
- break;
- }
- }
-
- offset = (diff == this.oldval.length ? 1 : 0);
-
- for (index = 0, l = t.length; index < l; ++index) {
- tp = value.lastIndexOf(t[index], diff + offset - 1);
- if (tp > prevTokenPos) {
- prevTokenPos = tp;
- }
- tp = value.indexOf(t[index], diff + offset);
- if (tp != -1 && tp < nextTokenPos) {
- nextTokenPos = tp;
- }
- }
- return [ prevTokenPos + 1, nextTokenPos ];
- }
-});
-
-Ajax.Autocompleter = Class.create(Autocompleter.Base, {
- initialize: function(element, update, url, options)
- {
- this.baseInitialize(element, update, options);
- this.options = Object.extend(this.options, {
- asynchronous: true,
- onComplete: this._onComplete.bind(this),
- defaultParams: $H(this.options.parameters)
- });
- this.url = url;
- this.cache = $H();
- },
-
- getUpdatedChoices: function()
- {
- var p,
- o = this.options,
- t = this.getToken(),
- c = this.cache.get(t);
-
- if (c) {
- this.updateChoices(c);
- } else {
- p = Object.clone(o.defaultParams);
- this.startIndicator();
- p.set(o.paramName, t);
- o.parameters = p.toQueryString();
- new Ajax.Request(this.url, o);
- }
- },
-
- _onComplete: function(request)
- {
- this.updateChoices(this.cache.set(this.getToken(), request.responseJSON));
- }
-});
-
-Autocompleter.Local = Class.create(Autocompleter.Base, {
- initialize: function(element, update, arr, options)
- {
- this.baseInitialize(element, update, options);
- this.options.arr = arr;
- },
-
- getUpdatedChoices: function()
- {
- this.updateChoices(this._selector());
- },
-
- _setOptions: function(options)
- {
- return Object.extend({
- choices: 10,
- partialSearch: true,
- partialChars: 2,
- ignoreCase: true,
- fullSearch: false
- }, options || {});
- },
-
- _selector: function()
- {
- var entry = this.getToken(),
- entry_len = entry.length,
- i = 0,
- o = this.options;
-
- if (o.ignoreCase) {
- entry = entry.toLowerCase();
- }
-
- return o.arr.findAll(function(t) {
- if (i == o.choices) {
- throw $break;
- }
-
- if (o.ignoreCase) {
- t = t.toLowerCase();
- }
- t = t.unescapeHTML();
-
- var pos = t.indexOf(entry);
- if (pos != -1 &&
- ((pos == 0 && t.length != entry_len) ||
- (entry_len >= o.partialChars &&
- o.partialSearch &&
- (o.fullSearch || /\s/.test(t.substr(pos - 1, 1)))))) {
- ++i;
- return true;
- }
- return false;
- }, this);
- }
-});
public function attach()
{
parent::attach();
- Horde::addScriptFile('autocomplete.js', 'kronolith', true);
+ Horde::addScriptFile('autocomplete.js', 'horde', true);
$params = array(
'"' . $this->_params['triggerId'] . '"',
public function attach()
{
parent::attach();
- Horde::addScriptFile('autocomplete.js', 'kronolith', true);
+ Horde::addScriptFile('autocomplete.js', 'horde', true);
$params = array(
'"' . $this->_params['triggerId'] . '"',