PageRenderTime 32ms CodeModel.GetById 28ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/src/main/resources/template/simple/yuiautocompleter.ftl

http://struts2yuiplugin.googlecode.com/
Freemarker Template | 59 lines | 58 code | 1 blank | 0 comment | 15 complexity | 5510fa07d63f45365d7027648c7ef8fe MD5 | raw file
 1<input name="${parameters.name}" type="text" id="${parameters.id}InputVisible"
 2<#if parameters.cssClass??>
 3  class="${parameters.cssClass}"
 4</#if>
 5<#if parameters.cssStyle??>
 6  style="${parameters.cssStyle}"
 7</#if>
 8>
 9<#if parameters.keyName??>
10  <input name="${parameters.keyName}" type="hidden" id="${parameters.id}Input">
11<#else>
12  <input name="${parameters.name}Key" type="hidden" id="${parameters.id}Input">
13</#if>
14<div id="${parameters.id}Container"
15<#if parameters.containerCssClass??>
16  class="${parameters.containerCssClass}"
17<#else>
18  class="ysearchcontainer"
19</#if>
20<#if parameters.containerCssStyle??>
21  style="${parameters.containerCssStyle}"
22</#if>
23></div>
24<script type="text/javascript">
25    YAHOO.util.Event.addListener(window, "load", function() {
26        <#if parameters.href??>
27          var dataSource = new YAHOO.widget.DS_XHR("${parameters.href}", ["${parameters.dataFieldName!"results"}", "value", "key"] );
28        </#if>  
29        YAHOO.namespace("autocompleters").${parameters.id} = 
30          new YAHOO.widget.AutoComplete("${parameters.id}InputVisible","${parameters.id}Container", dataSource);
31        var ac = YAHOO.namespace("autocompleters").${parameters.id};
32        <#if parameters.resultsLimit??>
33          ac.maxResultsDisplayed = ${parameters.resultsLimit};
34        </#if>
35        <#if parameters.minQueryLength??>
36          ac.minQueryLength = ${parameters.minQueryLength};
37        </#if>
38        <#if parameters.queryDelay??>
39          ac.queryDelay = ${parameters.queryDelay};
40        </#if>
41        <#if parameters.autoHighlight??>
42          ac.autoHighlight = ${parameters.autoHighlight};
43        </#if>
44        <#if parameters.useShadow??>
45          ac.useShadow = ${parameters.useShadow};
46        </#if>
47        <#if parameters.forceSelection??>
48          ac.forceSelection = ${parameters.forceSelection};
49        </#if>
50        <#if parameters.typeAhead??>
51          ac.typeAhead = ${parameters.typeAhead};
52        </#if>
53        ac.itemSelectEvent.subscribe(function(type, args) {
54          var values = args[2];
55          YAHOO.util.Dom.get("${parameters.id}Input").value = values[1]; 
56        });   
57    });
58</script>
59