Permalink
Browse files

Initial Import

  • Loading branch information...
0 parents commit f7d17ee6f77771c72c79e0e0f248b42173b1fbe4 @davglass committed Nov 2, 2009
Showing with 19,838 additions and 0 deletions.
  1. +26 −0 README
  2. +12 −0 alloy-builder/bootstrap.xml
  3. +96 −0 alloy-builder/module.xml
  4. +5 −0 alloy-builder/moduletemplate.txt
  5. +40 −0 alloy-builder/rollup.xml
  6. +7 −0 build.xml
  7. +1,465 −0 build/alloy-autocomplete/alloy-autocomplete-debug.js
  8. +3 −0 build/alloy-autocomplete/alloy-autocomplete-min.js
  9. +1,465 −0 build/alloy-autocomplete/alloy-autocomplete.js
  10. 0 build/alloy-autocomplete/assets/.keep
  11. +54 −0 setup.php
  12. 0 src/alloy-autocomplete/assets/.keep
  13. +4 −0 src/alloy-autocomplete/build.properties
  14. +7 −0 src/alloy-autocomplete/build.xml
  15. +1,465 −0 src/alloy-autocomplete/build_tmp/alloy-autocomplete-debug.js
  16. +3 −0 src/alloy-autocomplete/build_tmp/alloy-autocomplete-min.js
  17. +1,465 −0 src/alloy-autocomplete/build_tmp/alloy-autocomplete.js
  18. +1,460 −0 src/alloy-autocomplete/js/autocomplete.js
  19. 0 src/alloy-autocomplete/tests/.keep
  20. 0 src/alloy-base/assets/.keep
  21. +3 −0 src/alloy-base/build.properties
  22. +7 −0 src/alloy-base/build.xml
  23. +554 −0 src/alloy-base/js/base.js
  24. 0 src/alloy-base/tests/.keep
  25. 0 src/alloy-calendar/assets/.keep
  26. +3 −0 src/alloy-calendar/build.properties
  27. +7 −0 src/alloy-calendar/build.xml
  28. +762 −0 src/alloy-calendar/js/calendar.js
  29. 0 src/alloy-calendar/tests/.keep
  30. 0 src/alloy-color-picker/assets/.keep
  31. +3 −0 src/alloy-color-picker/build.properties
  32. +7 −0 src/alloy-color-picker/build.xml
  33. +978 −0 src/alloy-color-picker/js/color-picker.js
  34. 0 src/alloy-color-picker/tests/.keep
  35. 0 src/alloy-combobox/assets/.keep
  36. +3 −0 src/alloy-combobox/build.properties
  37. +7 −0 src/alloy-combobox/build.xml
  38. +94 −0 src/alloy-combobox/js/combobox.js
  39. 0 src/alloy-combobox/tests/.keep
  40. 0 src/alloy-context-overlay/assets/.keep
  41. +3 −0 src/alloy-context-overlay/build.properties
  42. +7 −0 src/alloy-context-overlay/build.xml
  43. +414 −0 src/alloy-context-overlay/js/context-overlay.js
  44. 0 src/alloy-context-overlay/tests/.keep
  45. 0 src/alloy-context-panel/assets/.keep
  46. +3 −0 src/alloy-context-panel/build.properties
  47. +7 −0 src/alloy-context-panel/build.xml
  48. +339 −0 src/alloy-context-panel/js/context-panel.js
  49. 0 src/alloy-context-panel/tests/.keep
  50. 0 src/alloy-core/assets/.keep
  51. +3 −0 src/alloy-core/build.properties
  52. +7 −0 src/alloy-core/build.xml
  53. +370 −0 src/alloy-core/js/core.js
  54. 0 src/alloy-core/tests/.keep
  55. 0 src/alloy-data-set/assets/.keep
  56. +3 −0 src/alloy-data-set/build.properties
  57. +7 −0 src/alloy-data-set/build.xml
  58. +624 −0 src/alloy-data-set/js/data-set.js
  59. 0 src/alloy-data-set/tests/.keep
  60. 0 src/alloy-date-picker-select/assets/.keep
  61. +3 −0 src/alloy-date-picker-select/build.properties
  62. +7 −0 src/alloy-date-picker-select/build.xml
  63. +415 −0 src/alloy-date-picker-select/js/date-picker-select.js
  64. 0 src/alloy-date-picker-select/tests/.keep
  65. 0 src/alloy-defaults/assets/.keep
  66. +3 −0 src/alloy-defaults/build.properties
  67. +7 −0 src/alloy-defaults/build.xml
  68. +411 −0 src/alloy-defaults/js/defaults.js
  69. 0 src/alloy-defaults/tests/.keep
  70. 0 src/alloy-dialog/assets/.keep
  71. +3 −0 src/alloy-dialog/build.properties
  72. +7 −0 src/alloy-dialog/build.xml
  73. +460 −0 src/alloy-dialog/js/dialog.js
  74. 0 src/alloy-dialog/tests/.keep
  75. 0 src/alloy-editable/assets/.keep
  76. +3 −0 src/alloy-editable/build.properties
  77. +7 −0 src/alloy-editable/build.xml
  78. +471 −0 src/alloy-editable/js/editable.js
  79. 0 src/alloy-editable/tests/.keep
  80. 0 src/alloy-field/assets/.keep
  81. +3 −0 src/alloy-field/build.properties
  82. +7 −0 src/alloy-field/build.xml
  83. +567 −0 src/alloy-field/js/field.js
  84. 0 src/alloy-field/tests/.keep
  85. 0 src/alloy-fieldset/assets/.keep
  86. +3 −0 src/alloy-fieldset/build.properties
  87. +7 −0 src/alloy-fieldset/build.xml
  88. +11 −0 src/alloy-fieldset/js/fieldset.js
  89. 0 src/alloy-fieldset/tests/.keep
  90. 0 src/alloy-form/assets/.keep
  91. +3 −0 src/alloy-form/build.properties
  92. +7 −0 src/alloy-form/build.xml
  93. +533 −0 src/alloy-form/js/form.js
  94. 0 src/alloy-form/tests/.keep
  95. 0 src/alloy-io-stdmod/assets/.keep
  96. +3 −0 src/alloy-io-stdmod/build.properties
  97. +7 −0 src/alloy-io-stdmod/build.xml
  98. +146 −0 src/alloy-io-stdmod/js/io-stdmod.js
  99. 0 src/alloy-io-stdmod/tests/.keep
  100. 0 src/alloy-live-search/assets/.keep
  101. +3 −0 src/alloy-live-search/build.properties
  102. +7 −0 src/alloy-live-search/build.xml
  103. +243 −0 src/alloy-live-search/js/live-search.js
  104. 0 src/alloy-live-search/tests/.keep
  105. 0 src/alloy-nested-list/assets/.keep
  106. +3 −0 src/alloy-nested-list/build.properties
  107. +7 −0 src/alloy-nested-list/build.xml
  108. +334 −0 src/alloy-nested-list/js/nested-list.js
  109. 0 src/alloy-nested-list/tests/.keep
  110. 0 src/alloy-overlay-manager/assets/.keep
  111. +3 −0 src/alloy-overlay-manager/build.properties
  112. +7 −0 src/alloy-overlay-manager/build.xml
  113. +186 −0 src/alloy-overlay-manager/js/overlay-manager.js
  114. 0 src/alloy-overlay-manager/tests/.keep
  115. 0 src/alloy-overlay-mask/assets/.keep
  116. +3 −0 src/alloy-overlay-mask/build.properties
  117. +7 −0 src/alloy-overlay-mask/build.xml
  118. +150 −0 src/alloy-overlay-mask/js/overlay-mask.js
  119. 0 src/alloy-overlay-mask/tests/.keep
  120. 0 src/alloy-paginator/assets/.keep
  121. +3 −0 src/alloy-paginator/build.properties
  122. +7 −0 src/alloy-paginator/build.xml
  123. +709 −0 src/alloy-paginator/js/paginator.js
  124. 0 src/alloy-paginator/tests/.keep
  125. 0 src/alloy-panel/assets/.keep
  126. +3 −0 src/alloy-panel/build.properties
  127. +7 −0 src/alloy-panel/build.xml
  128. +207 −0 src/alloy-panel/js/panel.js
  129. 0 src/alloy-panel/tests/.keep
  130. 0 src/alloy-rating/assets/.keep
  131. +3 −0 src/alloy-rating/build.properties
  132. +7 −0 src/alloy-rating/build.xml
  133. +412 −0 src/alloy-rating/js/rating.js
  134. 0 src/alloy-rating/tests/.keep
  135. 0 src/alloy-resize/assets/.keep
  136. +3 −0 src/alloy-resize/build.properties
  137. +7 −0 src/alloy-resize/build.xml
  138. +1,410 −0 src/alloy-resize/js/resize.js
  139. 0 src/alloy-resize/tests/.keep
  140. 0 src/alloy-sortable/assets/.keep
  141. +3 −0 src/alloy-sortable/build.properties
  142. +7 −0 src/alloy-sortable/build.xml
  143. +347 −0 src/alloy-sortable/js/sortable.js
  144. 0 src/alloy-sortable/tests/.keep
  145. 0 src/alloy-state-interaction/assets/.keep
  146. +3 −0 src/alloy-state-interaction/build.properties
  147. +7 −0 src/alloy-state-interaction/build.xml
  148. +204 −0 src/alloy-state-interaction/js/state-interaction.js
  149. 0 src/alloy-state-interaction/tests/.keep
  150. 0 src/alloy-tabs/assets/.keep
  151. +3 −0 src/alloy-tabs/build.properties
  152. +7 −0 src/alloy-tabs/build.xml
  153. +630 −0 src/alloy-tabs/js/tabs.js
  154. 0 src/alloy-tabs/tests/.keep
  155. 0 src/alloy-textarea/assets/.keep
  156. +3 −0 src/alloy-textarea/build.properties
  157. +7 −0 src/alloy-textarea/build.xml
Sorry, we could not display the entire diff because it was too big.
26 README
@@ -0,0 +1,26 @@
+Component Build for AlloyUI
+
+Steps:
+
+ Directories:
+ /builder: git clone git://github.com/yui/builder.git
+ /trunk: The trunk of your SVN source tree (can be a symlink)
+ /alloy This repository
+ /alloy-builder
+ Contains the build scripts to build AlloyUI
+ This folder needs to be symlinked to:
+ /builder/alloy
+ /build
+ This is where the build output goes
+ /src
+ This is where the raw source files go
+
+ Files:
+ setup.php
+ This is a hacked PHP file to move the files from /trunk to
+ /src, create the build.* files and create a directory structure
+ **IT WILL REMOVE ALL THE FILES UNDER /src and /build SO BE CAREFUL**
+
+ build.xml
+ The template copied with the setup.php file
+
12 alloy-builder/bootstrap.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="YuiDefaultProperties">
+
+ <!-- Default Library Version Build -->
+ <property name="yui.version" value="3"/>
+ <property name="yui.variable" value="A"/>
+ <property name="component.logger.regex" value="^.*?(?:logger|Y.log).*?(?:;|\).*;|(?:\r?\n.*?)*?\).*;).*;?.*?\r?\n" />
+
+ <import file="${builddir}/shared/properties.xml" description="Properties common to yui2/yui3" />
+
+ <import file="${targets}" description="Build Targets" />
+</project>
96 alloy-builder/module.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="YuiModuleTargets">
+
+ <import file="${builddir}/shared/targets.xml" description="Targets common to Rollup/Module" />
+
+ <target name="build" depends="buildcore, -rollupjs, buildskins" />
+ <target name="buildskins" depends="-buildskins, -rollupcss" />
+
+ <!-- CORE -->
+ <target name="buildcore" depends="builddebug, -createcore, -loggerregex" description="Create component.js">
+ <fixcrlf srcdir="${component.builddir}" includes="${component.basefilename}.js" eol="${buildfiles.eol}" />
+ </target>
+
+ <target name="-createcore">
+ <copy file="${component.builddir}/${component.basefilename}-debug.js" tofile="${component.builddir}/${component.basefilename}.js" />
+ </target>
+
+ <target name="-loggerregex" description="Replace logger statements" unless="component.logger.regex.skip">
+ <echo level="info">Replacing Logger Statements in ${component.builddir}/${component.basefilename}.js</echo>
+ <replaceregexp file="${component.builddir}/${component.basefilename}.js"
+ byline="${component.logger.regex.byline}"
+ match="${component.logger.regex}"
+ replace="${component.logger.regex.replace}"
+ flags="${component.logger.regex.flags}" />
+ </target>
+
+ <!-- DEBUG -->
+ <target name="builddebug" depends="-concatdebug, -registerdebug, -prependdebug, -appenddebug" description="Create component-debug.js">
+ <fixcrlf srcdir="${component.builddir}" includes="${component.basefilename}-debug.js" eol="${buildfiles.eol}" />
+ </target>
+
+ <target name="-concatdebug">
+ <concatsource destfile="${component.builddir}/${component.basefilename}-debug.js" sourcedir="${component.jsfiles.base}" sourcefiles="${component.jsfiles}" />
+ </target>
+
+ <target name="-registerdebug" unless="register.skip">
+ <addmodule module="${component.module}" file="${component.builddir}/${component.basefilename}-debug.js" details="${component.details.hash}" />
+ </target>
+
+ <target name="-rollupjs" if="rollup">
+ <echo level="info">Rolling up ${component.basefilename}-debug.js into ${rollup.component.basefilename}-debug.js</echo>
+ <concat destfile="${rollup.builddir}/${rollup.component.basefilename}.js" append="true" fixlastline="true">
+ <filelist dir="${component.builddir}" files="${component.basefilename}.js" />
+ </concat>
+ <concat destfile="${rollup.builddir}/${rollup.component.basefilename}-debug.js" append="true" fixlastline="true">
+ <filelist dir="${component.builddir}" files="${component.basefilename}-debug.js" />
+ </concat>
+ </target>
+
+ <!-- SKINS -->
+ <target name="-buildskins" depends="-concatskins" description="Create skin rollup in local component build directory" if="component.skins.exist">
+ <fixcrlf srcdir="${component.builddir}/assets/skins/sam" includes="${component}.css" eol="${buildfiles.eol}" />
+ </target>
+
+ <target name="-concatskins" if="component.skins.exist">
+ <concatsource destfile="${component.builddir}/assets/skins/sam/${component}.css" sourcedir="${component.assets.base}" sourcefiles="${component}-core.css, skins/sam/${component}-skin.css" />
+ <yuicompress src="${component.builddir}/assets/skins/sam/${component}.css" dest="${component.builddir}/assets/skins/sam/${component}.css" args="${yuicompressor.css.args.internal}" />
+ </target>
+
+ <target name="-rollupcss" if="rollup.skins.exist">
+ <echo level="info">Rolling up ${component}.css into ${rollup.component}.css</echo>
+ <concat destfile="${rollup.builddir}/assets/skins/sam/${rollup.component}.css" append="true" fixlastline="true">
+ <filelist dir="${component.builddir}/assets/skins/sam" files="${component}.css" />
+ </concat>
+ </target>
+
+ <macrodef name="addmodule">
+ <attribute name="file" />
+ <attribute name="module" />
+ <attribute name="details" default="" />
+
+ <sequential>
+ <if>
+ <equals arg1="@{details}" arg2="" />
+ <then>
+ <property name="@{module}-details" value="" />
+ </then>
+ <else>
+ <property name="@{module}-details" value=",@{details}" />
+ </else>
+ </if>
+ <loadfile srcfile="@{file}" property="@{module}-@{file}-code" />
+ <echo level="info">Wrapping @{file} in AUI.add module</echo>
+ <copy file="${builddir}/alloy/moduletemplate.txt" tofile="@{file}" overwrite="true">
+ <filterset>
+ <filter token="CODE" value="${@{module}-@{file}-code}" />
+ <filter token="YUIVAR" value="${yui.variable}" />
+ <filter token="MODULE" value="@{module}" />
+ <filter token="DETAILS" value="${@{module}-details}" />
+ </filterset>
+ </copy>
+ </sequential>
+ </macrodef>
+
+</project>
5 alloy-builder/moduletemplate.txt
@@ -0,0 +1,5 @@
+AUI.add('@MODULE@', function(@YUIVAR@) {
+
+@CODE@
+
+}, '@VERSION@' @DETAILS@);
40 alloy-builder/rollup.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="YuiRollupTargets">
+
+ <import file="${builddir}/shared/targets.xml" description="Targets common to Rollup/Module" />
+
+ <target name="build" depends="buildmodules" description="Create component.js"></target>
+
+ <target name="buildmodules" depends="-buildmodules, -registerall, -prependall, -appendall, -rollupjs">
+ <fixcrlf srcdir="${component.builddir}" eol="${buildfiles.eol}" />
+ </target>
+
+ <target name="-buildmodules">
+ <subant target="${component.rollup.target}" inheritall="false" >
+ <filelist dir="${buildfile.dir}" files="${component.rollup.modules.buildfiles}" />
+ <property name="rollup" value="true" />
+ <property name="rollup.builddir" value="${component.builddir}" />
+ <property name="rollup.component" value="${component}" />
+ <property name="rollup.component.basefilename" value="${component.basefilename}" />
+ </subant>
+ </target>
+
+ <target name="-rollupjs" if="rollup">
+ <echo level="info">Rolling up ${component.basefilename}-debug.js into ${rollup.component.basefilename}-debug.js</echo>
+ <concat destfile="${rollup.builddir}/${rollup.component.basefilename}.js" append="true" fixlastline="true">
+ <filelist dir="${component.builddir}" files="${component.basefilename}.js" />
+ </concat>
+ <concat destfile="${rollup.builddir}/${rollup.component.basefilename}-debug.js" append="true" fixlastline="true">
+ <filelist dir="${component.builddir}" files="${component.basefilename}-debug.js" />
+ </concat>
+ </target>
+
+ <target name="-prependall" depends="-prependdebug, -prepend" if="component.prependfiles" />
+ <target name="-appendall" depends="-appenddebug, -append" if="component.appendfiles" />
+
+ <target name="-registerall" unless="register.skip">
+ <addrollup module="${component.module}" file="${component.builddir}/${component.basefilename}-debug.js" details="${component.details.hash}" />
+ <addrollup module="${component.module}" file="${component.builddir}/${component.basefilename}.js" details="${component.details.hash}" />
+ </target>
+</project>
7 build.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- YUI 3 Gallery Component Build File -->
+<project name="Alloy Module" default="local">
+ <description>Alloy Build File</description>
+ <property file="build.properties" />
+ <import file="${builddir}/alloy/bootstrap.xml" description="Default Build Properties and Targets" />
+</project>
1,465 build/alloy-autocomplete/alloy-autocomplete-debug.js
@@ -0,0 +1,1465 @@
+AUI.add('alloy-autocomplete', function(A) {
+
+
+var Lang = A.Lang,
+ isArray = Lang.isArray,
+ isString = Lang.isString,
+ isNull = Lang.isNull,
+ isFunction = Lang.isFunction,
+
+ getClassName = A.ClassNameManager.getClassName,
+
+ ALERT = 'alert',
+ CIRCLE = 'circle',
+ CONTENT = 'content',
+ HELPER = 'helper',
+ ICON = 'icon',
+ ITEM = 'item',
+ LIST = 'list',
+ LOADING = 'loading',
+ NAME = 'autocomplete',
+ NO = 'no',
+ RESET = 'reset',
+ RESULTS = 'results',
+ S = 's',
+ SELECTED = 'selected',
+
+ ICON_DEFAULT = 'circle-triangle-b',
+ ICON_ERROR = ALERT,
+ ICON_LOADING = LOADING,
+
+ CSS_HIGLIGHT = getClassName(NAME, SELECTED),
+ CSS_LIST_ITEM = getClassName(NAME, LIST, ITEM),
+ CSS_NO_RESULTS = getClassName(NAME, NO, RESULTS),
+ CSS_RESULTS_LIST = getClassName(HELPER, RESET),
+ CSS_RESULTS_OVERLAY = getClassName(NAME, RESULTS),
+ CSS_RESULTS_OVERLAY_CONTENT = getClassName(NAME, RESULTS, CONTENT),
+
+ KEY_BACKSPACE = 8,
+ KEY_TAB = 9,
+ KEY_ENTER = 13,
+ KEY_SHIFT = 16,
+ KEY_CTRL = 17,
+ KEY_ALT = 18,
+ KEY_CAPS_LOCK = 20,
+ KEY_ESC = 27,
+ KEY_PAGEUP = 33,
+ KEY_END = 35,
+ KEY_HOME = 36,
+ KEY_UP = 38,
+ KEY_DOWN = 40,
+ KEY_RIGHT = 39,
+ KEY_LEFT = 37,
+ KEY_PRINT_SCREEN = 44,
+ KEY_INSERT = 44,
+ KEY_KOREAN_IME = 229,
+
+ OVERLAY_ALIGN = {
+ node: null,
+ points: ['tl', 'bl']
+ },
+
+ BOUNDING_BOX = 'boundingBox',
+ CONTENT_BOX = 'contentBox';
+
+ var AutoComplete = function() {
+ AutoComplete.superclass.constructor.apply(this, arguments);
+ };
+
+ AutoComplete.NAME = NAME;
+
+ AutoComplete.ATTRS = {
+
+ allowBrowserAutocomplete: {
+ value: true
+ },
+
+ alwaysShowContainer: {
+ value: false
+ },
+
+ autoHighlight: {
+ value: true
+ },
+
+ applyLocalFilter: {
+ value: null
+ },
+
+ button: {
+ value: true
+ },
+
+ dataSource: {
+ value: null
+ },
+
+ dataSourceType: {
+ value: null
+ },
+
+ delimChar: {
+ value: null,
+ setter: function(value) {
+ if (isString(value) && (value.length > 0)) {
+ value = [value];
+ }
+ else if (!isArray(value)) {
+ value = A.Attribute.INVALID_VALUE;
+ }
+
+ return value;
+ }
+ },
+
+ forceSelection: {
+ value: false
+ },
+
+ input: {
+ value: null
+ },
+
+ matchKey: {
+ value: ''
+ },
+
+ maxResultsDisplayed: {
+ value: 10
+ },
+
+ minQueryLength: {
+ value: 1
+ },
+
+ queryDelay: {
+ value: 0.2,
+ getter: function(value) {
+ return value * 1000;
+ }
+ },
+
+ queryInterval: {
+ value: 0.5,
+ getter: function(value) {
+ var instance = this;
+
+ return value * 1000;
+ }
+ },
+
+ queryMatchCase: {
+ value: false
+ },
+
+ queryMatchContains: {
+ value: false
+ },
+
+ queryQuestionMark: {
+ value: true
+ },
+
+ resultTypeList: {
+ value: true
+ },
+
+ schema: {
+ value: null
+ },
+
+ schemaType: {
+ value: '',
+ validator: isString
+ },
+
+ suppressInputUpdate: {
+ value: false
+ },
+
+ typeAhead: {
+ value: false
+ },
+
+ typeAheadDelay: {
+ value: 0.2,
+ getter: function(value) {
+ return value * 1000;
+ }
+ },
+
+ uniqueName: {
+ value: null
+ }
+ };
+
+ A.extend(
+ AutoComplete,
+ A.Widget,
+ {
+ initializer: function(config) {
+ var instance = this;
+
+ instance._createDataSource();
+ },
+
+ renderUI: function() {
+ var instance = this;
+
+ instance._renderInput();
+ instance._renderOverlay();
+ },
+
+ bindUI: function() {
+ var instance = this;
+
+ var button = instance.button;
+ var inputNode = instance.inputNode;
+
+ instance.dataSource.on('request', A.bind(button.set, button, ICON, ICON_LOADING));
+
+ inputNode.on('blur', instance._onTextboxBlur, instance);
+ inputNode.on('focus', instance._onTextboxFocus, instance);
+ inputNode.on('keydown', instance._onTextboxKeyDown, instance);
+ inputNode.on('keypress', instance._onTextboxKeyPress, instance);
+ inputNode.on('keyup', instance._onTextboxKeyUp, instance);
+
+ var overlayBoundingBox = instance.overlay.get(BOUNDING_BOX);
+
+ overlayBoundingBox.on('click', instance._onContainerClick, instance);
+ overlayBoundingBox.on('mouseout', instance._onContainerMouseout, instance);
+ overlayBoundingBox.on('mouseover', instance._onContainerMouseover, instance);
+ overlayBoundingBox.on('scroll', instance._onContainerScroll, instance);
+
+ instance.publish('containerCollapse');
+ instance.publish('containerExpand');
+ instance.publish('containerPopulate');
+
+ instance.publish('dataError');
+ instance.publish('dataRequest');
+ instance.publish('dataReturn');
+
+ instance.publish('itemArrowFrom');
+ instance.publish('itemArrowTo');
+ instance.publish('itemMouseOut');
+ instance.publish('itemMouseOver');
+ instance.publish('itemSelect');
+
+ instance.publish('selectionEnforce');
+
+ instance.publish('textboxBlur');
+ instance.publish('textboxChange');
+ instance.publish('textboxFocus');
+ instance.publish('textboxKey');
+
+ instance.publish('typeAhead');
+
+ instance.publish('unmatchedItemSelect');
+
+ instance.overlay.on('visibleChange', instance._realignContainer);
+ },
+
+ syncUI: function() {
+ var instance = this;
+
+ instance.inputNode.setAttribute('autocomplete', 'off');
+ },
+
+ doBeforeExpandContainer: function() {
+ return true;
+ },
+
+ doBeforeLoadData: function(event) {
+ return true;
+ },
+
+ filterResults: function(event) {
+ var instance = this;
+
+ var callback = event.callback;
+ var query = event.request;
+ var response = event.response;
+
+ if (callback && callback.argument && callback.argument.query) {
+ query = callback.argument.query;
+ }
+
+ if (query) {
+ var dataSource = instance.dataSource;
+ var allResults = response.results;
+ var filteredResults = [];
+ var matchFound = false;
+ var matchKey = instance.get('matchKey') || 0;
+ var matchCase = instance.get('queryMatchCase');
+ var matchContains = instance.get('queryMatchContains');
+ var showAll = (query == '*');
+
+ var fields = instance.get('schema.resultFields');
+
+ for (var i = allResults.length - 1; i >= 0; i--){
+ var result = allResults[i];
+
+ var strResult = null;
+
+ if (isString(result)) {
+ strResult = result;
+ }
+ else if (isArray(result)) {
+ strResult = result[0];
+ }
+ else if (fields) {
+ strResult = result[matchKey || fields[0]];
+ }
+
+ if (isString(strResult)) {
+ var keyIndex = -1;
+
+ if (matchCase) {
+ keyIndex = strResult.indexOf(decodeURIComponent(query));
+ }
+ else {
+ keyIndex = strResult.toLowerCase().indexOf(decodeURIComponent(query).toLowerCase());
+ }
+
+ if (
+ (showAll) ||
+ (!matchContains && (keyIndex === 0)) ||
+ (matchContains && (keyIndex > -1)
+ )
+ ) {
+ filteredResults.unshift(result);
+ }
+ }
+ }
+
+ response.results = filteredResults;
+ }
+
+ return response;
+ },
+
+ formatResult: function(result, request, resultMatch) {
+ return resultMatch || '';
+ },
+
+ generateRequest: function(query) {
+ return query;
+ },
+
+ handleResponse: function(event) {
+ var instance = this;
+
+ instance._populateList(event);
+
+ var iconClass = ICON_DEFAULT;
+
+ if (event.error) {
+ iconClass = ICON_ERROR;
+ }
+
+ instance.button.set(ICON, iconClass);
+ },
+
+ preparseRawResponse: function(event) {
+ },
+
+ sendQuery: function(query) {
+ var instance = this;
+
+ instance.set('focused', null);
+
+ var newQuery = query;
+
+ if (instance.get('delimChar')) {
+ query = instance.inputNode.get('value') + query;
+ }
+
+ instance._sendQuery(newQuery);
+ },
+
+ _clearInterval: function() {
+ var instance = this;
+
+ if (instance._queryIntervalId) {
+ clearInterval(instance._queryIntervalId);
+
+ instance._queryIntervalId = null;
+ }
+ },
+
+ _clearSelection: function() {
+ var instance = this;
+
+ var delimChar = instance.get('delimChar');
+ var extraction = {
+ previous: '',
+ query: instance.inputNode.get('value')
+ };
+
+ if (delimChar) {
+ extraction = instance._extractQuery(instance.inputNode.get('value'));
+ }
+
+ instance.fire('selectionEnforce', extraction.query);
+ },
+
+ _createDataSource: function() {
+ var instance = this;
+
+ var dataSource = instance.get('dataSource');
+ var data = dataSource;
+
+ var dataSourceType = instance.get('dataSourceType');
+
+ if (!(dataSource instanceof A.DataSource.Local)) {
+ if (!dataSourceType) {
+ dataSourceType = 'Local';
+
+ if (isFunction(data)) {
+ dataSourceType = 'Function'
+ }
+ else if (isString(data)) {
+ dataSourceType = 'IO'
+ }
+ }
+
+ dataSource = new A.DataSource[dataSourceType](
+ {
+ source: data
+ }
+ );
+ }
+
+ dataSource.on('error', instance.handleResponse, instance);
+ dataSource.after('response', instance.handleResponse, instance);
+
+ dataSourceType = dataSource.name;
+
+ if (dataSourceType == 'dataSourceLocal') {
+ instance.set('applyLocalFilter', true);
+ }
+
+ instance.set('dataSource', dataSource);
+ instance.set('dataSource', dataSourceType);
+
+ instance.dataSource = dataSource;
+
+ var schema = instance.get('schema');
+
+ if (schema) {
+ if (schema.fn) {
+ instance.dataSource.plug(schema);
+ }
+ else {
+ var schemaType = instance.get('schemaType');
+
+ var schemaTypes = {
+ array: A.Plugin.DataSourceArraySchema,
+ json: A.Plugin.DataSourceJSONSchema,
+ text: A.Plugin.DataSourceTextSchema,
+ xml: A.Plugin.DataSourceXMLSchema
+ };
+
+ schemaType = schemaType.toLowerCase() || 'array';
+
+ instance.dataSource.plug(
+ {
+ fn: schemaTypes[schemaType],
+ cfg: {
+ schema: schema
+ }
+ }
+ );
+ }
+ }
+
+ instance.set('schema', schema);
+ },
+
+ _enableIntervalDetection: function() {
+ var instance = this;
+
+ var queryInterval = instance.get('queryInterval');
+
+ if (!instance._queryIntervalId && queryInterval) {
+ instance._queryInterval = setInterval(A.bind(instance._onInterval, instance), queryInterval);
+ }
+ },
+
+ _extractQuery: function(query) {
+ var instance = this;
+
+ var delimChar = instance.get('delimChar');
+ var delimIndex = -1;
+ var i = delimChar.length - 1;
+
+ var newIndex, queryStart, previous;
+
+ for (; i >= 0; i--) {
+ newIndex = query.lastIndexOf(delimChar[i]);
+
+ if (newIndex > delimIndex) {
+ delimIndex = newIndex;
+ }
+ }
+
+ if (delimChar[i] == ' ') {
+ for (var j = delimChar.length - 1; j >= 0; j--){
+ if (query[delimIndex - 1] == delimChar[j]) {
+ delimIndex--;
+
+ break;
+ }
+ }
+ }
+
+ if (delimIndex > -1) {
+ queryStart = delimIndex + 1;
+
+ while (query.charAt(queryStart) == ' ') {
+ queryStart += 1;
+ }
+
+ previous = query.substring(0, queryStart);
+
+ query = query.substring(queryStart);
+ }
+ else {
+ previous = '';
+ }
+
+ return {
+ previous: previous,
+ query: query
+ };
+ },
+
+ _focus: function() {
+ var instance = this;
+
+ setTimeout(
+ function() {
+ instance.inputNode.focus();
+ },
+ 0
+ );
+ },
+
+ _isIgnoreKey: function(keyCode) {
+ var instance = this;
+
+ if (
+ (keyCode == KEY_TAB) ||
+ (keyCode == KEY_ENTER) ||
+ (keyCode == KEY_SHIFT) ||
+ (keyCode == KEY_CTRL) ||
+ (keyCode >= KEY_ALT && keyCode <= KEY_CAPS_LOCK) ||
+ (keyCode == KEY_ESC) ||
+ (keyCode >= KEY_PAGEUP && keyCode <= KEY_END) ||
+ (keyCode >= KEY_HOME && keyCode <= KEY_DOWN) ||
+ (keyCode >= KEY_PRINT_SCREEN && keyCode <= KEY_INSERT) ||
+ (keyCode == KEY_KOREAN_IME)
+ ) {
+ return true;
+ }
+
+ return false;
+ },
+
+ _jumpSelection: function() {
+ var instance = this;
+
+ if (instance._elCurListItem) {
+ instance._selectItem(instance._elCurListItem);
+ }
+ else {
+ instance._toggleContainer(false);
+ }
+ },
+
+ _moveSelection: function(keyCode) {
+ var instance = this;
+
+ if (instance.overlay.get('visible')) {
+ var elCurListItem = instance._elCurListItem;
+ var curItemIndex = -1;
+
+ if (elCurListItem) {
+ curItemIndex = Number(elCurListItem.getAttribute('data-listItemIndex'));
+ }
+
+ var newItemIndex = curItemIndex - 1;
+
+ if (keyCode == KEY_DOWN) {
+ newItemIndex = curItemIndex + 1;
+ }
+
+ if (newItemIndex == -1) {
+ newItemIndex = instance._displayedItems - 1;
+ }
+
+ if (newItemIndex >= instance._displayedItems) {
+ newItemIndex = 0;
+ }
+
+ if (newItemIndex < -2) {
+ return;
+ }
+
+ if (elCurListItem) {
+ instance._toggleHighlight(elCurListItem, 'from');
+
+ instance.fire('itemArrowFrom', elCurListItem);
+ }
+
+ if (newItemIndex == -1) {
+ if (instance.get('delimChar')) {
+ instance.inputNode.set('value', instance._pastSelections + instance._currentQuery);
+ }
+ else {
+ instance.inputNode.set('value', instance._currentQuery);
+ }
+
+ return;
+ }
+
+ if (newItemIndex == -2) {
+ instance._toggleContainer(false);
+
+ return;
+ }
+
+ var elNewListItem = instance.resultList.get('childNodes').item(newItemIndex);
+
+ var elContent = instance.overlay.get(CONTENT_BOX);
+
+ var contentOverflow = elContent.getStyle('overflow');
+ var contentOverflowY = elContent.getStyle('overflowY');
+
+ var scrollOn = (contentOverflow == 'auto') || (contentOverflow == 'scroll') || (contentOverflowY == 'auto') || (contentOverflowY == 'scroll');
+
+ if (scrollOn &&
+ (newItemIndex > -1) &&
+ (newItemIndex < instance._displayedItems)) {
+
+ var newScrollTop = -1;
+ var liTop = elNewListItem.get('offsetTop');
+ var liBottom = liTop + elNewListItem.get('offsetHeight');
+
+ var contentHeight = elContent.get('offsetHeight');
+ var contentScrollTop = elContent.get('scrollTop');
+ var contentBottom = contentHeight + contentScrollTop;
+
+ if (keyCode == KEY_DOWN) {
+ if (liBottom > contentBottom) {
+ newScrollTop = (liBottom - contentHeight);
+ }
+ else if (liBottom < contentScrollTop) {
+ newScrollTop = liTop;
+ }
+ }
+ else {
+ if (liTop < contentHeight) {
+ newScrollTop = liTop;
+ }
+ else if (liTop > contentBottom) {
+ newScrollTop = (liBottom - contentHeight);
+ }
+ }
+
+ if (newScrollTop > -1) {
+ elContent.set('scrollTop', newScrollTop);
+ }
+ }
+
+ instance._toggleHighlight(elNewListItem, 'to');
+
+ instance.fire('itemArrowTo', elNewListItem);
+
+ if (instance.get('typeAhead')) {
+ instance._updateValue(elNewListItem);
+ }
+ }
+ },
+
+ _onButtonMouseDown: function(event) {
+ var instance = this;
+
+ event.halt();
+
+ instance._focus();
+
+ instance._sendQuery(instance.inputNode.get('value') + '*');
+
+ },
+
+ _onContainerClick: function(event) {
+ var instance = this;
+
+ var target = event.target;
+ var tagName = target.get('nodeName').toLowerCase();
+
+ event.halt();
+
+ while (target && (tagName != 'table')) {
+ switch (tagName) {
+ case 'body':
+ return;
+
+ case 'li':
+ instance._toggleHighlight(target, 'to');
+ instance._selectItem(target);
+ return;
+
+ default:
+ break;
+ }
+
+ target = target.get('parentNode');
+
+ if (target) {
+ tagName.get('nodeName').toLowerCase();
+ }
+ }
+ },
+
+ _onContainerMouseout: function(event) {
+ var instance = this;
+
+ var target = event.target;
+ var tagName = target.get('nodeName').toLowerCase();
+
+ while (target && (tagName != 'table')) {
+ switch (tagName) {
+ case 'body':
+ return;
+
+ case 'li':
+ instance._toggleHighlight(target, 'from');
+ instance.fire('itemMouseOut', target);
+ break;
+
+ case 'ul':
+ instance._toggleHighlight(instance._elCurListItem, 'to');
+ break;
+
+ case 'div':
+ if (target.hasClass(CSS_RESULTS_OVERLAY)) {
+ instance._overContainer = false;
+
+ return;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ target = target.get('parentNode');
+
+ if (target) {
+ tagName = target.get('nodeName').toLowerCase();
+ }
+ }
+ },
+
+ _onContainerMouseover: function(event) {
+ var instance = this;
+
+ var target = event.target;
+ var tagName = target.get('nodeName').toLowerCase();
+
+ while (target && (tagName != 'table')) {
+ switch (tagName) {
+ case 'body':
+ return;
+
+ case 'li':
+ instance._toggleHighlight(target, 'to');
+ instance.fire('itemMouseOut', target);
+ break;
+
+ case 'div':
+ if (target.hasClass(CSS_RESULTS_OVERLAY)) {
+ instance._overContainer = true;
+ return;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ target = target.get('parentNode');
+
+ if (target) {
+ tagName = target.get('nodeName').toLowerCase();
+ }
+ }
+ },
+
+ _onContainerScroll: function(event) {
+ var instance = this;
+
+ instance._focus();
+ },
+
+ _onInterval: function() {
+ var instance = this;
+
+ var curValue = instance.inputNode.get('value');
+ var lastValue = instance._lastValue;
+
+ if (curValue != lastValue) {
+ instance._lastValue = curValue;
+
+ instance._sendQuery(curValue);
+ }
+ },
+
+ _onTextboxBlur: function(event) {
+ var instance = this;
+
+ if (!instance._overContainer || (instance._keyCode == KEY_TAB)) {
+ if (!instance._itemSelected) {
+ var elMatchListItem = instance._textMatchesOption();
+
+ var overlayVisible = instance.overlay.get('visible');
+
+ if (!overlayVisible || (overlayVisible && isNull(elMatchListItem))) {
+ if (instance.get('forceSelection')) {
+ instance._clearSelection();
+ }
+ else {
+ instance.fire('unmatchedItemSelect', instance._currentQuery);
+ }
+ }
+ else {
+ if (instance.get('forceSelection')) {
+ instance._selectItem(elMatchListItem);
+ }
+ }
+ }
+
+ instance._clearInterval();
+
+ instance.blur();
+
+ if (instance._initInputValue !== instance.inputNode.get('value')) {
+ instance.fire('textboxChange');
+ }
+
+ instance.fire('textboxBlur');
+
+ instance._toggleContainer(false);
+ }
+ else {
+ instance._focus();
+ }
+ },
+
+ _onTextboxFocus: function(event) {
+ var instance = this;
+
+ if (!instance.get('focused')) {
+ instance.inputNode.setAttribute('autocomplete', 'off');
+ instance.focus();
+ instance._initInputValue = instance.inputNode.get('value');
+
+ instance.fire('textboxFocus');
+ }
+ },
+
+ _onTextboxKeyDown: function(event) {
+ var instance = this;
+
+ var keyCode = event.keyCode;
+
+ if (instance._typeAheadDelayId != -1) {
+ clearTimeout(instance._typeAheadDelayId);
+ }
+
+ switch (keyCode) {
+ case KEY_TAB:
+ if (instance._elCurListItem) {
+ if (instance.get('delimChar') && instance._keyCode != keyCode) {
+ if (instance.overlay.get('visible')) {
+ event.halt();
+ }
+ }
+
+ instance._selectItem(instance._elCurListItem);
+ }
+ else {
+ instance._toggleContainer(false);
+ }
+ break;
+
+ case KEY_ENTER:
+ if (instance._elCurListItem) {
+ if (instance._keyCode != keyCode) {
+ if (instance.overlay.get('visible')) {
+ event.halt();
+ }
+ }
+
+ instance._selectItem(instance._elCurListItem);
+ }
+ else {
+ instance._toggleContainer(false);
+ }
+ break;
+
+ case KEY_ESC:
+ instance._toggleContainer(false);
+ return;
+
+ case KEY_UP:
+ if (instance.overlay.get('visible')) {
+ event.halt();
+
+ instance._moveSelection(keyCode);
+ }
+ break;
+
+ case KEY_RIGHT:
+ instance._jumpSelection();
+ break;
+
+ case KEY_DOWN:
+ if (instance.overlay.get('visible')) {
+ event.halt();
+
+ instance._moveSelection(keyCode);
+ }
+ break;
+
+ default:
+ instance._itemSelected = false;
+ instance._toggleHighlight(instance._elCurListItem, 'from');
+
+ instance.fire('textboxKey', keyCode);
+ break;
+ }
+
+ if (keyCode == KEY_ALT) {
+ instance._enableIntervalDetection();
+ }
+
+ instance._keyCode = keyCode;
+ },
+
+ _onTextboxKeyPress: function(event) {
+ var instance = this;
+
+ var keyCode = event.keyCode;
+
+ switch (keyCode) {
+ case KEY_TAB:
+ if (instance.overlay.get('visible')) {
+ if (instance.get('delimChar')) {
+ event.halt();
+ }
+
+ if (instance._elCurListItem) {
+ instance._selectItem(instance._elCurListItem);
+ }
+ else {
+ instance._toggleContainer(false);
+ }
+ }
+ break;
+
+ case 13:
+ if (instance.overlay.get('visible')) {
+ event.halt();
+
+ if (instance._elCurListItem) {
+ instance._selectItem(instance._elCurListItem);
+ }
+ else {
+ instance._toggleContainer(false);
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (keyCode == KEY_KOREAN_IME) {
+ instance._enableIntervalDetection();
+ }
+ },
+
+ _onTextboxKeyUp: function(event) {
+ var instance = this;
+
+ var input = instance.inputNode;
+
+ var value = input.get('value');
+ var keyCode = event.keyCode;
+
+ if (instance._isIgnoreKey(keyCode)) {
+ return;
+ }
+
+ if (instance._delayId != -1) {
+ clearTimeout(instance._delayId);
+ }
+
+ instance._delayId = setTimeout(
+ function() {
+ instance._sendQuery(value);
+ },
+ instance.get('queryDelay')
+ );
+ },
+
+ _populateList: function(event) {
+ var instance = this;
+
+ if (instance._typeAheadDelayId != -1) {
+ clearTimeout(instance._typeAheadDelayId);
+ }
+
+ var query = event.request;
+ var response = event.response;
+ var callback = event.callback;
+ var showAll = (query == '*');
+
+ if (callback && callback.argument && callback.argument.query) {
+ event.request = query = callback.argument.query;
+ }
+
+ var ok = instance.doBeforeLoadData(event);
+
+ if (ok && !event.error) {
+ instance.fire('dataReturn', event);
+
+ var focused = instance.get('focused');
+
+ if (showAll || focused || focused === null) {
+ var currentQuery = decodeURIComponent(query);
+
+ instance._currentQuery = currentQuery;
+ instance._itemSelected = false;
+
+ var allResults = event.response.results;
+ var itemsToShow = Math.min(allResults.length, instance.get('maxResultsDisplayed'));
+ var fields = instance.get('schema.resultFields');
+ var matchKey = instance.get('matchKey');
+
+ if (!matchKey && fields) {
+ matchKey = fields[0];
+ }
+ else {
+ matchKey = matchKey || 0;
+ }
+
+ if (itemsToShow > 0) {
+ var allListItemEls = instance.resultList.get('childNodes');
+
+ allListItemEls.each(
+ function(node, i, nodeList) {
+ if (i < itemsToShow) {
+ var result = allResults[i];
+
+ var resultMatch = '';
+
+ if (isString(result)) {
+ resultMatch = result;
+ }
+ else if (isArray(result)) {
+ resultMatch = result[0]
+ }
+ else {
+ resultMatch = result[matchKey];
+ }
+
+ node._resultMatch = resultMatch;
+
+ node._resultData = result;
+ node.html(instance.formatResult(result, currentQuery, resultMatch));
+
+ node.removeClass('aui-helper-hidden');
+ }
+ else {
+ node.addClass('aui-helper-hidden');
+ }
+ }
+ );
+
+ instance._displayedItems = itemsToShow;
+
+ instance.fire('containerPopulate', query, allResults);
+
+ if (query != '*' && instance.get('autoHighlight')) {
+ var elFirstListItem = instance.resultList.get('firstChild');
+
+ instance._toggleHighlight(elFirstListItem, 'to');
+ instance.fire('itemArrowTo', elFirstListItem);
+
+ instance._typeAhead(elFirstListItem, query);
+ }
+ else {
+ instance._toggleHighlight(instance._elCurListItem, 'from');
+ }
+
+ ok = instance.doBeforeExpandContainer(query, allResults);
+
+ instance._toggleContainer(ok);
+ }
+ else {
+ instance._toggleContainer(false);
+ }
+
+ return;
+ }
+
+ }
+ else {
+ instance.fire('dataError', query);
+ }
+ },
+
+ _realignContainer: function(event) {
+ var instance = this;
+
+ instance._uiSetAlign(OVERLAY_ALIGN.node, OVERLAY_ALIGN.points);
+ },
+
+ _renderInput: function() {
+ var instance = this;
+
+ var contentBox = instance.get(CONTENT_BOX);
+ var input = instance.get('input');
+
+ var comboConfig = {
+ field: {
+ labelText: false
+ },
+ tools: [
+ {
+ icon: 'circle-triangle-b',
+ id: 'trigger',
+ handler: {
+ fn: instance._onButtonMouseDown,
+ context: instance
+ }
+ }
+ ]
+ };
+
+ var inputReference = null;
+ var inputParent = null;
+
+ if (input) {
+ input = A.get(input);
+
+ comboConfig.field.node = input;
+
+ inputReference = input.next();
+ inputParent = input.get('parentNode');
+ }
+
+ var comboBox = new A.Combobox(comboConfig).render(contentBox);
+
+ if (inputParent) {
+ var comboBoundingBox = comboBox.get('boundingBox');
+
+ inputParent.insertBefore(comboBoundingBox, inputReference);
+ }
+
+ instance.inputNode = comboBox.get('node');
+ instance.button = comboBox.toolset.tools.item('trigger');
+
+ instance.set('uniqueName', A.stamp(instance.inputNode));
+ },
+
+ _renderListElements: function() {
+ var instance = this;
+
+ var maxResultsDisplayed = instance.get('maxResultsDisplayed');
+
+ var resultList = instance.resultList;
+
+ var listItems = [];
+
+ while (maxResultsDisplayed--) {
+ listItems[maxResultsDisplayed] = '<li class="aui-helper-hidden ' + CSS_LIST_ITEM + '" data-listItemIndex="' + maxResultsDisplayed + '"></li>';
+ }
+
+ resultList.html(listItems.join(''));
+ },
+
+ _renderOverlay: function() {
+ var instance = this;
+
+ OVERLAY_ALIGN.node = instance.inputNode;
+
+ var overlay = new A.Overlay(
+ {
+ align: OVERLAY_ALIGN,
+ bodyContent: '<ul></ul>',
+ visible: false,
+ width: instance.inputNode.get('offsetWidth')
+ }
+ );
+
+ var contentBox = overlay.get(CONTENT_BOX);
+
+ overlay.get(BOUNDING_BOX).addClass(CSS_RESULTS_OVERLAY);
+
+ contentBox.addClass(CSS_RESULTS_OVERLAY_CONTENT);
+
+ overlay.render(document.body);
+
+ overlay.addTarget(instance);
+
+ instance.overlay = overlay;
+ instance.resultList = contentBox.query('ul');
+
+ instance.resultList.addClass(CSS_RESULTS_LIST);
+
+ instance._renderListElements();
+ },
+
+ _selectItem: function(elListItem) {
+ var instance = this;
+
+ instance._itemSelected = true;
+
+ instance._updateValue(elListItem);
+
+ instance._pastSelections = instance.inputNode.get('value');
+
+ instance._clearInterval();
+
+ instance.fire('itemSelect', elListItem, elListItem._resultData);
+
+ instance._toggleContainer(false);
+ },
+
+ _selectText: function(el, start, end) {
+ var instance = this;
+
+ var rawEl = A.Node.getDOMNode(el);
+ var value = el.get('value');
+
+ if (rawEl.setSelectionRange) {
+ rawEl.setSelectionRange(start, end);
+ }
+ else if (rawEl.createTextRange) {
+ var range = rawEl.createTextRange();
+
+ range.moveStart('character', start);
+ range.moveEnd('character', end - value.length);
+
+ range.select();
+ }
+ else {
+ rawEl.select();
+ }
+ },
+
+ _sendQuery: function(query) {
+ var instance = this;
+
+ if (instance.get('disabled')) {
+ instance._toggleContainer(false);
+
+ return;
+ }
+
+ var delimChar = instance.get('delimChar');
+ var minQueryLength = instance.get('minQueryLength');
+
+ if (delimChar) {
+ var extraction = instance._extractQuery(query);
+
+ query = extraction.query;
+
+ instance._pastSelections = extraction.previous;
+ }
+
+ if ((query && (query.length < minQueryLength)) || (!query && minQueryLength > 0)) {
+ if (instance._delayId != -1) {
+ clearTimeout(instance._delayId);
+ }
+
+ instance._toggleContainer(false);
+
+ return;
+ }
+
+ query = encodeURIComponent(query);
+
+ instance._delayId = -1;
+
+ if (instance.get('applyLocalFilter')) {
+ instance.dataSource.on('response', instance.filterResults, instance);
+ }
+
+ var request = instance.generateRequest(query);
+
+ instance.fire('dataRequest', query, request);
+
+ instance.dataSource.sendRequest(request);
+ },
+
+ _textMatchesOption: function() {
+ var instance = this;
+
+ var elMatch = null;
+ var displayedItems = instance._displayedItems;
+ var listItems = instance.resultList.get('childNodes');
+
+ for (var i=0; i < displayedItems.length; i++) {
+ var elListItem = listItems.item(i);
+
+ var match = ('' + elListItem._resultMatch).toLowerCase();
+
+ if (match == instance._currentQuery.toLowerCase()) {
+ elMatch = elListItem;
+
+ break;
+ }
+ }
+
+ return elMatch;
+ },
+
+ _toggleContainer: function(show) {
+ var instance = this;
+
+ var overlay = instance.overlay;
+
+ if (instance.get('alwaysShowContainer') && overlay.get('visible')) {
+ return;
+ }
+
+ if (!show) {
+ instance._toggleHighlight(instance._elCurListItem, 'from');
+
+ instance._displayedItems = 0;
+ instance._currentQuery = null;
+ }
+
+ if (show) {
+ overlay.show();
+ instance.fire('containerExpand');
+ }
+ else {
+ overlay.hide();
+ instance.fire('containerCollapse');
+ }
+ },
+
+ _toggleHighlight: function(elNewListItem, action) {
+ var instance = this;
+
+ if (elNewListItem) {
+ if (instance._elCurListItem) {
+ instance._elCurListItem.removeClass(CSS_HIGLIGHT);
+ instance._elCurListItem = null;
+ }
+
+ if (action == 'to') {
+ elNewListItem.addClass(CSS_HIGLIGHT);
+
+ instance._elCurListItem = elNewListItem;
+ }
+ }
+ },
+
+ _typeAhead: function(elListItem, query) {
+ var instance = this;
+
+ if (!instance.get('typeAhead') || instance._keyCode == KEY_BACKSPACE) {
+ return;
+ }
+
+ var inputEl = A.Node.getDOMNode(instance.inputNode);
+
+ if (inputEl.setSelectionRange || inputEl.createTextRange) {
+ instance._typeAheadDelayId = setTimeout(
+ function() {
+ var value = inputEl.value;
+
+ var start = value.length;
+
+ instance._updateValue(elListItem);
+
+ var end = inputEl.value.length;
+
+ instance._selectText(instance.inputNode, start, end);
+
+ var prefill = inputEl.value.substr(start, end);
+
+ instance.fire('typeAhead', query, prefill);
+ },
+ instance.get('typeAheadDelay')
+ );
+ }
+ },
+
+ _updateValue: function(elListItem) {
+ var instance = this;
+
+ if (!instance.get('suppressInputUpdate')) {
+ var input = instance.inputNode;
+ var resultMatch = elListItem._resultMatch;
+
+ var delimChar = instance.get('delimChar');
+
+ delimChar = (delimChar && delimChar[0]) || delimChar;
+
+ var newValue = '';
+
+ if (delimChar) {
+ newValue = instance._pastSelections;
+
+ newValue += resultMatch + delimChar;
+
+ if (delimChar != ' ') {
+ newValue += ' ';
+ }
+ }
+ else {
+ newValue = resultMatch;
+ }
+
+ input.set('value', newValue);
+
+ if (input.get('type') == 'textarea') {
+ input.set('scrollTop', input.get('scrollHeight'));
+ }
+
+ var end = newValue.length;
+
+ instance._selectText(input, end, end);
+
+ instance._elCurListItem = elListItem;
+ }
+ },
+
+ _currentQuery: null,
+ _delayId: -1,
+ _displayedItems: 0,
+ _elCurListItem: null,
+ _initInputValue: null,
+ _itemSelected: false,
+ _keyCode: null,
+ _lastValue: null,
+ _overContainer: false,
+ _pastSelections: '',
+ _typeAheadDelayId: -1
+ }
+ );
+
+ A.AutoComplete = AutoComplete;
+
+
+
+}, '@VERSION@' ,{requires:['datasource', 'dataschema', 'overlay', 'tool']});
3 build/alloy-autocomplete/alloy-autocomplete-min.js
@@ -0,0 +1,3 @@
+AUI.add("alloy-autocomplete",function(N){var AB=N.Lang,Y=AB.isArray,K=AB.isString,r=AB.isNull,P=AB.isFunction,z=N.ClassNameManager.getClassName,n="alert",AA="circle",l="content",t="helper",f="icon",x="item",o="list",T="loading",i="autocomplete",j="no",u="reset",v="results",E="s",d="selected",U="circle-triangle-b",m=n,D=T,C=z(i,d),I=z(i,o,x),V=z(i,j,v),s=z(t,u),B=z(i,v),X=z(i,v,l),R=8,q=9,g=13,L=16,F=17,G=18,Q=20,h=27,J=33,M=35,b=36,p=38,a=40,Z=39,W=37,k=44,y=44,H=229,c={node:null,points:["tl","bl"]},w="boundingBox",e="contentBox";var O=function(){O.superclass.constructor.apply(this,arguments);};O.NAME=i;O.ATTRS={allowBrowserAutocomplete:{value:true},alwaysShowContainer:{value:false},autoHighlight:{value:true},applyLocalFilter:{value:null},button:{value:true},dataSource:{value:null},dataSourceType:{value:null},delimChar:{value:null,setter:function(A){if(K(A)&&(A.length>0)){A=[A];}else{if(!Y(A)){A=N.Attribute.INVALID_VALUE;}}return A;}},forceSelection:{value:false},input:{value:null},matchKey:{value:""},maxResultsDisplayed:{value:10},minQueryLength:{value:1},queryDelay:{value:0.2,getter:function(A){return A*1000;}},queryInterval:{value:0.5,getter:function(S){var A=this;return S*1000;}},queryMatchCase:{value:false},queryMatchContains:{value:false},queryQuestionMark:{value:true},resultTypeList:{value:true},schema:{value:null},schemaType:{value:"",validator:K},suppressInputUpdate:{value:false},typeAhead:{value:false},typeAheadDelay:{value:0.2,getter:function(A){return A*1000;}},uniqueName:{value:null}};N.extend(O,N.Widget,{initializer:function(S){var A=this;A._createDataSource();},renderUI:function(){var A=this;A._renderInput();A._renderOverlay();},bindUI:function(){var A=this;var S=A.button;var AC=A.inputNode;A.dataSource.on("request",N.bind(S.set,S,f,D));AC.on("blur",A._onTextboxBlur,A);AC.on("focus",A._onTextboxFocus,A);AC.on("keydown",A._onTextboxKeyDown,A);AC.on("keypress",A._onTextboxKeyPress,A);AC.on("keyup",A._onTextboxKeyUp,A);var AD=A.overlay.get(w);AD.on("click",A._onContainerClick,A);AD.on("mouseout",A._onContainerMouseout,A);AD.on("mouseover",A._onContainerMouseover,A);AD.on("scroll",A._onContainerScroll,A);A.publish("containerCollapse");A.publish("containerExpand");A.publish("containerPopulate");A.publish("dataError");A.publish("dataRequest");A.publish("dataReturn");A.publish("itemArrowFrom");A.publish("itemArrowTo");A.publish("itemMouseOut");A.publish("itemMouseOver");A.publish("itemSelect");A.publish("selectionEnforce");A.publish("textboxBlur");A.publish("textboxChange");A.publish("textboxFocus");A.publish("textboxKey");A.publish("typeAhead");A.publish("unmatchedItemSelect");A.overlay.on("visibleChange",A._realignContainer);},syncUI:function(){var A=this;A.inputNode.setAttribute("autocomplete","off");},doBeforeExpandContainer:function(){return true;},doBeforeLoadData:function(A){return true;},filterResults:function(AL){var AR=this;var AC=AL.callback;var AD=AL.request;var S=AL.response;if(AC&&AC.argument&&AC.argument.query){AD=AC.argument.query;}if(AD){var AQ=AR.dataSource;var AN=S.results;var A=[];var AF=false;var AE=AR.get("matchKey")||0;var AO=AR.get("queryMatchCase");var AJ=AR.get("queryMatchContains");var AI=(AD=="*");var AK=AR.get("schema.resultFields");for(var AM=AN.length-1;AM>=0;AM--){var AH=AN[AM];var AP=null;if(K(AH)){AP=AH;}else{if(Y(AH)){AP=AH[0];}else{if(AK){AP=AH[AE||AK[0]];}}}if(K(AP)){var AG=-1;if(AO){AG=AP.indexOf(decodeURIComponent(AD));}else{AG=AP.toLowerCase().indexOf(decodeURIComponent(AD).toLowerCase());}if((AI)||(!AJ&&(AG===0))||(AJ&&(AG>-1))){A.unshift(AH);}}}S.results=A;}return S;},formatResult:function(S,AC,A){return A||"";},generateRequest:function(A){return A;},handleResponse:function(AC){var S=this;S._populateList(AC);var A=U;if(AC.error){A=m;}S.button.set(f,A);},preparseRawResponse:function(A){},sendQuery:function(S){var A=this;A.set("focused",null);var AC=S;if(A.get("delimChar")){S=A.inputNode.get("value")+S;}A._sendQuery(AC);},_clearInterval:function(){var A=this;if(A._queryIntervalId){clearInterval(A._queryIntervalId);A._queryIntervalId=null;}},_clearSelection:function(){var S=this;var AC=S.get("delimChar");var A={previous:"",query:S.inputNode.get("value")};if(AC){A=S._extractQuery(S.inputNode.get("value"));}S.fire("selectionEnforce",A.query);},_createDataSource:function(){var A=this;var AG=A.get("dataSource");var AE=AG;var AF=A.get("dataSourceType");if(!(AG instanceof N.DataSource.Local)){if(!AF){AF="Local";if(P(AE)){AF="Function";}else{if(K(AE)){AF="IO";}}}AG=new N.DataSource[AF]({source:AE});}AG.on("error",A.handleResponse,A);AG.after("response",A.handleResponse,A);AF=AG.name;if(AF=="dataSourceLocal"){A.set("applyLocalFilter",true);}A.set("dataSource",AG);A.set("dataSource",AF);A.dataSource=AG;var AD=A.get("schema");if(AD){if(AD.fn){A.dataSource.plug(AD);}else{var S=A.get("schemaType");var AC={array:N.Plugin.DataSourceArraySchema,json:N.Plugin.DataSourceJSONSchema,text:N.Plugin.DataSourceTextSchema,xml:N.Plugin.DataSourceXMLSchema};S=S.toLowerCase()||"array";A.dataSource.plug({fn:AC[S],cfg:{schema:AD}});}}A.set("schema",AD);},_enableIntervalDetection:function(){var A=this;var S=A.get("queryInterval");if(!A._queryIntervalId&&S){A._queryInterval=setInterval(N.bind(A._onInterval,A),S);}},_extractQuery:function(AE){var AI=this;var AG=AI.get("delimChar");var A=-1;var AC=AG.length-1;var AH,AF,AD;for(;AC>=0;AC--){AH=AE.lastIndexOf(AG[AC]);if(AH>A){A=AH;}}if(AG[AC]==" "){for(var S=AG.length-1;S>=0;S--){if(AE[A-1]==AG[S]){A--;break;}}}if(A>-1){AF=A+1;while(AE.charAt(AF)==" "){AF+=1;}AD=AE.substring(0,AF);AE=AE.substring(AF);}else{AD="";}return{previous:AD,query:AE};},_focus:function(){var A=this;setTimeout(function(){A.inputNode.focus();},0);},_isIgnoreKey:function(S){var A=this;if((S==q)||(S==g)||(S==L)||(S==F)||(S>=G&&S<=Q)||(S==h)||(S>=J&&S<=M)||(S>=b&&S<=a)||(S>=k&&S<=y)||(S==H)){return true;}return false;},_jumpSelection:function(){var A=this;if(A._elCurListItem){A._selectItem(A._elCurListItem);}else{A._toggleContainer(false);}},_moveSelection:function(AN){var AK=this;
+if(AK.overlay.get("visible")){var AO=AK._elCurListItem;var S=-1;if(AO){S=Number(AO.getAttribute("data-listItemIndex"));}var AC=S-1;if(AN==a){AC=S+1;}if(AC==-1){AC=AK._displayedItems-1;}if(AC>=AK._displayedItems){AC=0;}if(AC<-2){return;}if(AO){AK._toggleHighlight(AO,"from");AK.fire("itemArrowFrom",AO);}if(AC==-1){if(AK.get("delimChar")){AK.inputNode.set("value",AK._pastSelections+AK._currentQuery);}else{AK.inputNode.set("value",AK._currentQuery);}return;}if(AC==-2){AK._toggleContainer(false);return;}var AG=AK.resultList.get("childNodes").item(AC);var AE=AK.overlay.get(e);var AI=AE.getStyle("overflow");var AL=AE.getStyle("overflowY");var AD=(AI=="auto")||(AI=="scroll")||(AL=="auto")||(AL=="scroll");if(AD&&(AC>-1)&&(AC<AK._displayedItems)){var A=-1;var AP=AG.get("offsetTop");var AF=AP+AG.get("offsetHeight");var AJ=AE.get("offsetHeight");var AH=AE.get("scrollTop");var AM=AJ+AH;if(AN==a){if(AF>AM){A=(AF-AJ);}else{if(AF<AH){A=AP;}}}else{if(AP<AJ){A=AP;}else{if(AP>AM){A=(AF-AJ);}}}if(A>-1){AE.set("scrollTop",A);}}AK._toggleHighlight(AG,"to");AK.fire("itemArrowTo",AG);if(AK.get("typeAhead")){AK._updateValue(AG);}}},_onButtonMouseDown:function(S){var A=this;S.halt();A._focus();A._sendQuery(A.inputNode.get("value")+"*");},_onContainerClick:function(AC){var A=this;var AD=AC.target;var S=AD.get("nodeName").toLowerCase();AC.halt();while(AD&&(S!="table")){switch(S){case"body":return;case"li":A._toggleHighlight(AD,"to");A._selectItem(AD);return;default:break;}AD=AD.get("parentNode");if(AD){S.get("nodeName").toLowerCase();}}},_onContainerMouseout:function(AC){var A=this;var AD=AC.target;var S=AD.get("nodeName").toLowerCase();while(AD&&(S!="table")){switch(S){case"body":return;case"li":A._toggleHighlight(AD,"from");A.fire("itemMouseOut",AD);break;case"ul":A._toggleHighlight(A._elCurListItem,"to");break;case"div":if(AD.hasClass(B)){A._overContainer=false;return;}break;default:break;}AD=AD.get("parentNode");if(AD){S=AD.get("nodeName").toLowerCase();}}},_onContainerMouseover:function(AC){var A=this;var AD=AC.target;var S=AD.get("nodeName").toLowerCase();while(AD&&(S!="table")){switch(S){case"body":return;case"li":A._toggleHighlight(AD,"to");A.fire("itemMouseOut",AD);break;case"div":if(AD.hasClass(B)){A._overContainer=true;return;}break;default:break;}AD=AD.get("parentNode");if(AD){S=AD.get("nodeName").toLowerCase();}}},_onContainerScroll:function(S){var A=this;A._focus();},_onInterval:function(){var A=this;var AC=A.inputNode.get("value");var S=A._lastValue;if(AC!=S){A._lastValue=AC;A._sendQuery(AC);}},_onTextboxBlur:function(AD){var A=this;if(!A._overContainer||(A._keyCode==q)){if(!A._itemSelected){var AC=A._textMatchesOption();var S=A.overlay.get("visible");if(!S||(S&&r(AC))){if(A.get("forceSelection")){A._clearSelection();}else{A.fire("unmatchedItemSelect",A._currentQuery);}}else{if(A.get("forceSelection")){A._selectItem(AC);}}}A._clearInterval();A.blur();if(A._initInputValue!==A.inputNode.get("value")){A.fire("textboxChange");}A.fire("textboxBlur");A._toggleContainer(false);}else{A._focus();}},_onTextboxFocus:function(S){var A=this;if(!A.get("focused")){A.inputNode.setAttribute("autocomplete","off");A.focus();A._initInputValue=A.inputNode.get("value");A.fire("textboxFocus");}},_onTextboxKeyDown:function(S){var A=this;var AC=S.keyCode;if(A._typeAheadDelayId!=-1){clearTimeout(A._typeAheadDelayId);}switch(AC){case q:if(A._elCurListItem){if(A.get("delimChar")&&A._keyCode!=AC){if(A.overlay.get("visible")){S.halt();}}A._selectItem(A._elCurListItem);}else{A._toggleContainer(false);}break;case g:if(A._elCurListItem){if(A._keyCode!=AC){if(A.overlay.get("visible")){S.halt();}}A._selectItem(A._elCurListItem);}else{A._toggleContainer(false);}break;case h:A._toggleContainer(false);return;case p:if(A.overlay.get("visible")){S.halt();A._moveSelection(AC);}break;case Z:A._jumpSelection();break;case a:if(A.overlay.get("visible")){S.halt();A._moveSelection(AC);}break;default:A._itemSelected=false;A._toggleHighlight(A._elCurListItem,"from");A.fire("textboxKey",AC);break;}if(AC==G){A._enableIntervalDetection();}A._keyCode=AC;},_onTextboxKeyPress:function(S){var A=this;var AC=S.keyCode;switch(AC){case q:if(A.overlay.get("visible")){if(A.get("delimChar")){S.halt();}if(A._elCurListItem){A._selectItem(A._elCurListItem);}else{A._toggleContainer(false);}}break;case 13:if(A.overlay.get("visible")){S.halt();if(A._elCurListItem){A._selectItem(A._elCurListItem);}else{A._toggleContainer(false);}}break;default:break;}if(AC==H){A._enableIntervalDetection();}},_onTextboxKeyUp:function(AC){var A=this;var S=A.inputNode;var AD=S.get("value");var AE=AC.keyCode;if(A._isIgnoreKey(AE)){return;}if(A._delayId!=-1){clearTimeout(A._delayId);}A._delayId=setTimeout(function(){A._sendQuery(AD);},A.get("queryDelay"));},_populateList:function(A){var AL=this;if(AL._typeAheadDelayId!=-1){clearTimeout(AL._typeAheadDelayId);}var AG=A.request;var AE=A.response;var AO=A.callback;var AD=(AG=="*");if(AO&&AO.argument&&AO.argument.query){A.request=AG=AO.argument.query;}var AJ=AL.doBeforeLoadData(A);if(AJ&&!A.error){AL.fire("dataReturn",A);var AI=AL.get("focused");if(AD||AI||AI===null){var AH=decodeURIComponent(AG);AL._currentQuery=AH;AL._itemSelected=false;var AC=A.response.results;var AN=Math.min(AC.length,AL.get("maxResultsDisplayed"));var AF=AL.get("schema.resultFields");var AM=AL.get("matchKey");if(!AM&&AF){AM=AF[0];}else{AM=AM||0;}if(AN>0){var AK=AL.resultList.get("childNodes");AK.each(function(AT,AS,AR){if(AS<AN){var AQ=AC[AS];var AP="";if(K(AQ)){AP=AQ;}else{if(Y(AQ)){AP=AQ[0];}else{AP=AQ[AM];}}AT._resultMatch=AP;AT._resultData=AQ;AT.html(AL.formatResult(AQ,AH,AP));AT.removeClass("aui-helper-hidden");}else{AT.addClass("aui-helper-hidden");}});AL._displayedItems=AN;AL.fire("containerPopulate",AG,AC);if(AG!="*"&&AL.get("autoHighlight")){var S=AL.resultList.get("firstChild");AL._toggleHighlight(S,"to");AL.fire("itemArrowTo",S);AL._typeAhead(S,AG);}else{AL._toggleHighlight(AL._elCurListItem,"from");}AJ=AL.doBeforeExpandContainer(AG,AC);AL._toggleContainer(AJ);}else{AL._toggleContainer(false);
+}return;}}else{AL.fire("dataError",AG);}},_realignContainer:function(S){var A=this;A._uiSetAlign(c.node,c.points);},_renderInput:function(){var S=this;var AC=S.get(e);var AD=S.get("input");var AF={field:{labelText:false},tools:[{icon:"circle-triangle-b",id:"trigger",handler:{fn:S._onButtonMouseDown,context:S}}]};var AE=null;var A=null;if(AD){AD=N.get(AD);AF.field.node=AD;AE=AD.next();A=AD.get("parentNode");}var AG=new N.Combobox(AF).render(AC);if(A){var AH=AG.get("boundingBox");A.insertBefore(AH,AE);}S.inputNode=AG.get("node");S.button=AG.toolset.tools.item("trigger");S.set("uniqueName",N.stamp(S.inputNode));},_renderListElements:function(){var A=this;var AD=A.get("maxResultsDisplayed");var S=A.resultList;var AC=[];while(AD--){AC[AD]='<li class="aui-helper-hidden '+I+'" data-listItemIndex="'+AD+'"></li>';}S.html(AC.join(""));},_renderOverlay:function(){var A=this;c.node=A.inputNode;var AC=new N.Overlay({align:c,bodyContent:"<ul></ul>",visible:false,width:A.inputNode.get("offsetWidth")});var S=AC.get(e);AC.get(w).addClass(B);S.addClass(X);AC.render(document.body);AC.addTarget(A);A.overlay=AC;A.resultList=S.query("ul");A.resultList.addClass(s);A._renderListElements();},_selectItem:function(S){var A=this;A._itemSelected=true;A._updateValue(S);A._pastSelections=A.inputNode.get("value");A._clearInterval();A.fire("itemSelect",S,S._resultData);A._toggleContainer(false);},_selectText:function(AE,AG,AC){var A=this;var S=N.Node.getDOMNode(AE);var AF=AE.get("value");if(S.setSelectionRange){S.setSelectionRange(AG,AC);}else{if(S.createTextRange){var AD=S.createTextRange();AD.moveStart("character",AG);AD.moveEnd("character",AC-AF.length);AD.select();}else{S.select();}}},_sendQuery:function(AF){var S=this;if(S.get("disabled")){S._toggleContainer(false);return;}var AD=S.get("delimChar");var AC=S.get("minQueryLength");if(AD){var A=S._extractQuery(AF);AF=A.query;S._pastSelections=A.previous;}if((AF&&(AF.length<AC))||(!AF&&AC>0)){if(S._delayId!=-1){clearTimeout(S._delayId);}S._toggleContainer(false);return;}AF=encodeURIComponent(AF);S._delayId=-1;if(S.get("applyLocalFilter")){S.dataSource.on("response",S.filterResults,S);}var AE=S.generateRequest(AF);S.fire("dataRequest",AF,AE);S.dataSource.sendRequest(AE);},_textMatchesOption:function(){var A=this;var S=null;var AF=A._displayedItems;var AG=A.resultList.get("childNodes");for(var AD=0;AD<AF.length;AD++){var AE=AG.item(AD);var AC=(""+AE._resultMatch).toLowerCase();if(AC==A._currentQuery.toLowerCase()){S=AE;break;}}return S;},_toggleContainer:function(S){var A=this;var AC=A.overlay;if(A.get("alwaysShowContainer")&&AC.get("visible")){return;}if(!S){A._toggleHighlight(A._elCurListItem,"from");A._displayedItems=0;A._currentQuery=null;}if(S){AC.show();A.fire("containerExpand");}else{AC.hide();A.fire("containerCollapse");}},_toggleHighlight:function(S,AC){var A=this;if(S){if(A._elCurListItem){A._elCurListItem.removeClass(C);A._elCurListItem=null;}if(AC=="to"){S.addClass(C);A._elCurListItem=S;}}},_typeAhead:function(S,AC){var A=this;if(!A.get("typeAhead")||A._keyCode==R){return;}var AD=N.Node.getDOMNode(A.inputNode);if(AD.setSelectionRange||AD.createTextRange){A._typeAheadDelayId=setTimeout(function(){var AG=AD.value;var AH=AG.length;A._updateValue(S);var AE=AD.value.length;A._selectText(A.inputNode,AH,AE);var AF=AD.value.substr(AH,AE);A.fire("typeAhead",AC,AF);},A.get("typeAheadDelay"));}},_updateValue:function(AF){var S=this;if(!S.get("suppressInputUpdate")){var AE=S.inputNode;var A=AF._resultMatch;var AD=S.get("delimChar");AD=(AD&&AD[0])||AD;var AG="";if(AD){AG=S._pastSelections;AG+=A+AD;if(AD!=" "){AG+=" ";}}else{AG=A;}AE.set("value",AG);if(AE.get("type")=="textarea"){AE.set("scrollTop",AE.get("scrollHeight"));}var AC=AG.length;S._selectText(AE,AC,AC);S._elCurListItem=AF;}},_currentQuery:null,_delayId:-1,_displayedItems:0,_elCurListItem:null,_initInputValue:null,_itemSelected:false,_keyCode:null,_lastValue:null,_overContainer:false,_pastSelections:"",_typeAheadDelayId:-1});N.AutoComplete=O;},"@VERSION@",{requires:["datasource","dataschema","overlay","tool"]});
1,465 build/alloy-autocomplete/alloy-autocomplete.js
@@ -0,0 +1,1465 @@
+AUI.add('alloy-autocomplete', function(A) {
+
+
+var Lang = A.Lang,
+ isArray = Lang.isArray,
+ isString = Lang.isString,
+ isNull = Lang.isNull,
+ isFunction = Lang.isFunction,
+
+ getClassName = A.ClassNameManager.getClassName,
+
+ ALERT = 'alert',
+ CIRCLE = 'circle',
+ CONTENT = 'content',
+ HELPER = 'helper',
+ ICON = 'icon',
+ ITEM = 'item',
+ LIST = 'list',
+ LOADING = 'loading',
+ NAME = 'autocomplete',
+ NO = 'no',
+ RESET = 'reset',
+ RESULTS = 'results',
+ S = 's',
+ SELECTED = 'selected',
+
+ ICON_DEFAULT = 'circle-triangle-b',
+ ICON_ERROR = ALERT,
+ ICON_LOADING = LOADING,
+
+ CSS_HIGLIGHT = getClassName(NAME, SELECTED),
+ CSS_LIST_ITEM = getClassName(NAME, LIST, ITEM),
+ CSS_NO_RESULTS = getClassName(NAME, NO, RESULTS),
+ CSS_RESULTS_LIST = getClassName(HELPER, RESET),
+ CSS_RESULTS_OVERLAY = getClassName(NAME, RESULTS),
+ CSS_RESULTS_OVERLAY_CONTENT = getClassName(NAME, RESULTS, CONTENT),
+
+ KEY_BACKSPACE = 8,
+ KEY_TAB = 9,
+ KEY_ENTER = 13,
+ KEY_SHIFT = 16,
+ KEY_CTRL = 17,
+ KEY_ALT = 18,
+ KEY_CAPS_LOCK = 20,
+ KEY_ESC = 27,
+ KEY_PAGEUP = 33,
+ KEY_END = 35,
+ KEY_HOME = 36,
+ KEY_UP = 38,
+ KEY_DOWN = 40,
+ KEY_RIGHT = 39,
+ KEY_LEFT = 37,
+ KEY_PRINT_SCREEN = 44,
+ KEY_INSERT = 44,
+ KEY_KOREAN_IME = 229,
+
+ OVERLAY_ALIGN = {
+ node: null,
+ points: ['tl', 'bl']
+ },
+
+ BOUNDING_BOX = 'boundingBox',
+ CONTENT_BOX = 'contentBox';
+
+ var AutoComplete = function() {
+ AutoComplete.superclass.constructor.apply(this, arguments);
+ };
+
+ AutoComplete.NAME = NAME;
+
+ AutoComplete.ATTRS = {
+
+ allowBrowserAutocomplete: {
+ value: true
+ },
+
+ alwaysShowContainer: {
+ value: false
+ },
+
+ autoHighlight: {
+ value: true
+ },
+
+ applyLocalFilter: {
+ value: null
+ },
+
+ button: {
+ value: true
+ },
+
+ dataSource: {
+ value: null
+ },
+
+ dataSourceType: {
+ value: null
+ },
+
+ delimChar: {
+ value: null,
+ setter: function(value) {
+ if (isString(value) && (value.length > 0)) {
+ value = [value];
+ }
+ else if (!isArray(value)) {
+ value = A.Attribute.INVALID_VALUE;
+ }
+
+ return value;
+ }
+ },
+
+ forceSelection: {
+ value: false
+ },
+
+ input: {
+ value: null
+ },
+
+ matchKey: {
+ value: ''
+ },
+
+ maxResultsDisplayed: {
+ value: 10
+ },
+
+ minQueryLength: {
+ value: 1
+ },
+
+ queryDelay: {
+ value: 0.2,
+ getter: function(value) {
+ return value * 1000;
+ }
+ },
+
+ queryInterval: {
+ value: 0.5,
+ getter: function(value) {
+ var instance = this;
+
+ return value * 1000;
+ }
+ },
+
+ queryMatchCase: {
+ value: false
+ },
+
+ queryMatchContains: {
+ value: false
+ },
+
+ queryQuestionMark: {
+ value: true
+ },
+
+ resultTypeList: {
+ value: true
+ },
+
+ schema: {
+ value: null
+ },
+
+ schemaType: {
+ value: '',
+ validator: isString
+ },
+
+ suppressInputUpdate: {
+ value: false
+ },
+
+ typeAhead: {
+ value: false
+ },
+
+ typeAheadDelay: {
+ value: 0.2,
+ getter: function(value) {
+ return value * 1000;
+ }
+ },
+
+ uniqueName: {
+ value: null
+ }
+ };
+
+ A.extend(
+ AutoComplete,
+ A.Widget,
+ {
+ initializer: function(config) {
+ var instance = this;
+
+ instance._createDataSource();
+ },
+
+ renderUI: function() {
+ var instance = this;
+
+ instance._renderInput();
+ instance._renderOverlay();
+ },
+
+ bindUI: function() {
+ var instance = this;
+
+ var button = instance.button;
+ var inputNode = instance.inputNode;
+
+ instance.dataSource.on('request', A.bind(button.set, button, ICON, ICON_LOADING));
+
+ inputNode.on('blur', instance._onTextboxBlur, instance);
+ inputNode.on('focus', instance._onTextboxFocus, instance);
+ inputNode.on('keydown', instance._onTextboxKeyDown, instance);
+ inputNode.on('keypress', instance._onTextboxKeyPress, instance);
+ inputNode.on('keyup', instance._onTextboxKeyUp, instance);
+
+ var overlayBoundingBox = instance.overlay.get(BOUNDING_BOX);
+
+ overlayBoundingBox.on('click', instance._onContainerClick, instance);
+ overlayBoundingBox.on('mouseout', instance._onContainerMouseout, instance);
+ overlayBoundingBox.on('mouseover', instance._onContainerMouseover, instance);
+ overlayBoundingBox.on('scroll', instance._onContainerScroll, instance);
+
+ instance.publish('containerCollapse');
+ instance.publish('containerExpand');
+ instance.publish('containerPopulate');
+
+ instance.publish('dataError');
+ instance.publish('dataRequest');
+ instance.publish('dataReturn');
+
+ instance.publish('itemArrowFrom');
+ instance.publish('itemArrowTo');
+ instance.publish('itemMouseOut');
+ instance.publish('itemMouseOver');
+ instance.publish('itemSelect');
+
+ instance.publish('selectionEnforce');
+
+ instance.publish('textboxBlur');
+ instance.publish('textboxChange');
+ instance.publish('textboxFocus');
+ instance.publish('textboxKey');
+
+ instance.publish('typeAhead');
+
+ instance.publish('unmatchedItemSelect');
+
+ instance.overlay.on('visibleChange', instance._realignContainer);
+ },
+
+ syncUI: function() {
+ var instance = this;
+
+ instance.inputNode.setAttribute('autocomplete', 'off');
+ },
+
+ doBeforeExpandContainer: function() {
+ return true;
+ },
+
+ doBeforeLoadData: function(event) {
+ return true;
+ },
+
+ filterResults: function(event) {
+ var instance = this;
+
+ var callback = event.callback;
+ var query = event.request;
+ var response = event.response;
+
+ if (callback && callback.argument && callback.argument.query) {
+ query = callback.argument.query;
+ }
+
+ if (query) {
+ var dataSource = instance.dataSource;
+ var allResults = response.results;
+ var filteredResults = [];
+ var matchFound = false;
+ var matchKey = instance.get('matchKey') || 0;
+ var matchCase = instance.get('queryMatchCase');
+ var matchContains = instance.get('queryMatchContains');
+ var showAll = (query == '*');
+
+ var fields = instance.get('schema.resultFields');
+
+ for (var i = allResults.length - 1; i >= 0; i--){
+ var result = allResults[i];
+
+ var strResult = null;
+
+ if (isString(result)) {
+ strResult = result;
+ }
+ else if (isArray(result)) {
+ strResult = result[0];
+ }
+ else if (fields) {
+ strResult = result[matchKey || fields[0]];
+ }
+
+ if (isString(strResult)) {
+ var keyIndex = -1;
+
+ if (matchCase) {
+ keyIndex = strResult.indexOf(decodeURIComponent(query));
+ }
+ else {
+ keyIndex = strResult.toLowerCase().indexOf(decodeURIComponent(query).toLowerCase());
+ }
+
+ if (
+ (showAll) ||
+ (!matchContains && (keyIndex === 0)) ||
+ (matchContains && (keyIndex > -1)
+ )
+ ) {
+ filteredResults.unshift(result);
+ }
+ }
+ }
+
+ response.results = filteredResults;
+ }
+
+ return response;
+ },
+
+ formatResult: function(result, request, resultMatch) {
+ return resultMatch || '';
+ },
+
+ generateRequest: function(query) {
+ return query;
+ },
+
+ handleResponse: function(event) {
+ var instance = this;
+
+ instance._populateList(event);
+
+ var iconClass = ICON_DEFAULT;
+
+ if (event.error) {
+ iconClass = ICON_ERROR;
+ }
+
+ instance.button.set(ICON, iconClass);
+ },
+
+ preparseRawResponse: function(event) {
+ },
+
+ sendQuery: function(query) {
+ var instance = this;
+
+ instance.set('focused', null);
+
+ var newQuery = query;
+
+ if (instance.get('delimChar')) {
+ query = instance.inputNode.get('value') + query;
+ }
+
+ instance._sendQuery(newQuery);
+ },
+
+ _clearInterval: function() {
+ var instance = this;
+
+ if (instance._queryIntervalId) {
+ clearInterval(instance._queryIntervalId);
+
+ instance._queryIntervalId = null;