From: Michael J. Rubinsky Date: Fri, 3 Apr 2009 04:44:35 +0000 (-0400) Subject: Just assign the whole object instead of a single function. We'll X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=e68169f43e79867ab213308d1c239d6c0d153aa7;p=horde.git Just assign the whole object instead of a single function. We'll need it later for things like reseting the state of the box and hidden field etc... --- diff --git a/kronolith/js/src/kronolith.js b/kronolith/js/src/kronolith.js index 37f8bf621..a6edd16a9 100644 --- a/kronolith/js/src/kronolith.js +++ b/kronolith/js/src/kronolith.js @@ -1106,7 +1106,7 @@ KronolithCore = { e.stop(); return; } else if (elt.hasClassName('kronolithEventTag')) { - $('kronolithTagACTrigger').forceTaggerUpdate(elt.getText()); + $('kronolithTagACTrigger').kronolithTagger.addNewTagNode(elt.getText()); e.stop(); return; } diff --git a/kronolith/js/src/taggerAutoCompleter.js b/kronolith/js/src/taggerAutoCompleter.js index f74d7e57e..49f2a6e95 100644 --- a/kronolith/js/src/taggerAutoCompleter.js +++ b/kronolith/js/src/taggerAutoCompleter.js @@ -2,38 +2,40 @@ var KronolithTagger = Class.create({ initialize: function(params) { this.p = params; - + trigger = $(this.p.trigger); trigger.observe('keydown', this._onKeyDown.bindAsEventListener(this)); - trigger.forceTaggerUpdate = function(item) { - this.addNewTagNode(item); - }.bind(this); + + // Bind this object to the trigger so we can call it's methods + // from client code. + trigger.kronolithTagger = this; + // Make sure the right dom elements are styled correctly. $(this.p.container).addClassName('kronolithACListItem kronolithTagACContainer'); - + // Make sure the p.tags element is hidden if (!this.p.debug) { $(this.p.tags).hide(); } - + // Set the updateElement callback this.p.params.updateElement = this._updateElement.bind(this); - + // Look for clicks on the box to simulate clicking in an input box $(this.p.box).observe('click', function() {$(this.p.trigger).focus()}.bindAsEventListener(this)); - + // Create the underlaying Autocompleter new Ajax.Autocompleter(params.trigger, params.resultsId, params.uri, params.params); - + // Prepopulate the tags and the container elements? if (this.p.existing) { for (var i = 0, l = this.p.existing.length; i < l; i++) { this.addNewTagNode(this.p.existing[i]); } } - + }, - + _onKeyDown: function(e) { // Check for a comma @@ -48,16 +50,16 @@ var KronolithTagger = Class.create({ this.addNewTagNode(value); } e.stop(); - } + } }, - + // Used as the updateElement callback. _updateElement: function(item) { var value = item.collectTextNodesIgnoreClass('informal'); this.addNewTagNode(value); }, - + addNewTagNode: function(value) { // Don't add if it's already present. @@ -66,7 +68,7 @@ var KronolithTagger = Class.create({ return; } } - + var newTag = new Element('li', {class: 'kronolithACListItem kronolithTagACListItem'}).update(value); var x = new Element('img', {class: 'kronolithTagACRemove', src:this.p.URI_IMG_HORDE + "/delete-small.png"}); x.observe('click', this._removeTag.bindAsEventListener(this)); @@ -84,13 +86,13 @@ var KronolithTagger = Class.create({ // ...and keep the selectedTags array up to date. this.p.selectedTags.push(value); }, - + _removeTag: function(e) { item = Event.element(e).up(); // The value to remove from the hidden textbox var value = item.collectTextNodesIgnoreClass('informal'); - + for (var x = 0, len = this.p.selectedTags.length; x < len; x++) { if (this.p.selectedTags[x] == value) { this.p.selectedTags.splice(x, 1); @@ -101,5 +103,5 @@ var KronolithTagger = Class.create({ // Nuke the node. item.remove(); - } + } }); \ No newline at end of file