Permalink
Browse files

Specify container class for autocomplete

  • Loading branch information...
1 parent d64d1ac commit 2c589be187e78bfb82f8b8d3044e35b166159aca Szaby Grünwald committed Mar 29, 2012
Showing with 21 additions and 2 deletions.
  1. +7 −1 docs/vie.autocomplete.html
  2. +8 −1 lib/annotate.js
  3. +6 −0 src/vie.autocomplete.coffee
@@ -66,7 +66,8 @@
<span class="p">]</span></pre></div> </td> </tr> <tr id="section-13"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-13">&#182;</a> </div> <ul>
<li>If label and description is not available in the user's language
look for a fallback.</li>
-</ul> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">fallbackLanguage: </span><span class="s2">&quot;en&quot;</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <ul>
+</ul> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">fallbackLanguage: </span><span class="s2">&quot;en&quot;</span>
+ <span class="nv">styleClass: </span><span class="s2">&quot;vie-autocomplete&quot;</span></pre></div> </td> </tr> <tr id="section-14"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-14">&#182;</a> </div> <ul>
<li>type label definition</li>
</ul> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">getTypes: </span><span class="o">-&gt;</span>
<span class="p">[</span>
@@ -97,8 +98,12 @@
<span class="nv">warn: </span><span class="o">-&gt;</span>
<span class="nv">error: </span><span class="o">-&gt;</span>
<span class="nv">log: </span><span class="o">-&gt;</span>
+ <span class="vi">@menuContainer = </span><span class="nx">jQuery</span> <span class="s2">&quot;&lt;span class=&#39;#{@options.styleClass}&#39;/&gt;&quot;</span>
+ <span class="nx">@menuContainer</span><span class="p">.</span><span class="nx">appendTo</span> <span class="s1">&#39;body&#39;</span>
<span class="nx">@_instantiateAutocomplete</span><span class="p">()</span>
+ <span class="nv">_destroy: </span><span class="o">-&gt;</span>
+ <span class="nx">@menuContainer</span><span class="p">.</span><span class="nx">remove</span><span class="p">()</span>
<span class="nv">_instantiateAutocomplete: </span><span class="o">-&gt;</span>
<span class="nv">widget = </span><span class="err">@</span>
<span class="nx">@element</span>
@@ -155,6 +160,7 @@
<span class="nx">@_logger</span><span class="p">.</span><span class="nx">info</span> <span class="s2">&quot;autocomplete.select&quot;</span><span class="p">,</span> <span class="nx">e</span><span class="p">.</span><span class="nx">target</span><span class="p">,</span> <span class="nx">ui</span>
<span class="k">if</span> <span class="nx">widget</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">urifield</span>
<span class="nx">widget</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">urifield</span><span class="p">.</span><span class="nx">val</span> <span class="nx">ui</span><span class="p">.</span><span class="nx">item</span><span class="p">.</span><span class="nx">key</span>
+ <span class="nv">appendTo: </span><span class="nx">@menuContainer</span>
<span class="nv">_getUserLang: </span><span class="o">-&gt;</span>
<span class="nb">window</span><span class="p">.</span><span class="nx">navigator</span><span class="p">.</span><span class="nx">language</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span><span class="s2">&quot;-&quot;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
View
@@ -1395,6 +1395,7 @@
}
],
fallbackLanguage: "en",
+ styleClass: "vie-autocomplete",
getTypes: function() {
return [
{
@@ -1431,8 +1432,13 @@
error: function() {},
log: function() {}
};
+ this.menuContainer = jQuery("<span class='" + this.options.styleClass + "'/>");
+ this.menuContainer.appendTo('body');
return this._instantiateAutocomplete();
},
+ _destroy: function() {
+ return this.menuContainer.remove();
+ },
_instantiateAutocomplete: function() {
var widget,
_this = this;
@@ -1508,7 +1514,8 @@
if (widget.options.urifield) {
return widget.options.urifield.val(ui.item.key);
}
- }
+ },
+ appendTo: this.menuContainer
});
},
_getUserLang: function() {
@@ -75,6 +75,7 @@ jQuery.widget "IKS.vieAutocomplete",
# * If label and description is not available in the user's language
# look for a fallback.
fallbackLanguage: "en"
+ styleClass: "vie-autocomplete"
# * type label definition
getTypes: ->
[
@@ -105,8 +106,12 @@ jQuery.widget "IKS.vieAutocomplete",
warn: ->
error: ->
log: ->
+ @menuContainer = jQuery "<span class='#{@options.styleClass}'/>"
+ @menuContainer.appendTo 'body'
@_instantiateAutocomplete()
+ _destroy: ->
+ @menuContainer.remove()
_instantiateAutocomplete: ->
widget = @
@element
@@ -175,6 +180,7 @@ jQuery.widget "IKS.vieAutocomplete",
@_logger.info "autocomplete.select", e.target, ui
if widget.options.urifield
widget.options.urifield.val ui.item.key
+ appendTo: @menuContainer
_getUserLang: ->
window.navigator.language.split("-")[0]

0 comments on commit 2c589be

Please sign in to comment.