Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jquery/jquery-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
maggiewachs committed Apr 16, 2010
2 parents 4ffe074 + d1033cc commit 970ed9a
Show file tree
Hide file tree
Showing 56 changed files with 2,156 additions and 1,052 deletions.
112 changes: 86 additions & 26 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,26 @@
<property name="release.filename" value="jquery-ui-${release.version}" />

<property name="dist.dir" value="dist/${release.filename}/" />
<property name="cdndist.dir" value="dist/${release.filename}-googlecdn" />
<property name="build.dir" value="build" />
<property name="ui.dir" value="../" />
<property name="src.dir" value="${ui.dir}/ui/" />
<property name="theme.dir" value="${ui.dir}/themes/base/" />
<property name="docs.dir" value="${ui.dir}/docs/" />

<property name="min.folder" value="${dist.dir}/ui/minified" />
<property name="min.dir" value="${dist.dir}/ui/minified" />

<property name="concatenated" value="jquery-ui" />
<property name="concatenated.i18n" value="jquery-ui-i18n" />

<property name="core.files" value="jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.effects.core.js" />
<property name="core.files.min" value="jquery.ui.core.min.js, jquery.ui.widget.min.js, jquery.ui.mouse.min.js, jquery.ui.draggable.min.js, jquery.ui.droppable.min.js, jquery.ui.resizable.min.js, jquery.ui.selectable.min.js, jquery.ui.sortable.min.js, jquery.effects.core.min.js" />

<property description="Google Closure" name="closure-jar" value="${build.dir}/google-compiler-20091218.jar" />

<target name="deploy-release" depends="docs-download, concatenate, minify, copy, replace-version, prepend-header, zip" description="Release builder">
<target name="deploy-release" depends="clean, docs-download, concatenate, minify, copy, replace-version, prepend-header, zip, googlecdn" description="Release builder">
</target>

<target name="replace-version">
<replaceregexp match="@VERSION" replace="${release.version}" flags="g" byline="true">
<fileset dir="${dist.dir}/ui/" includes="*.js"/>
Expand All @@ -49,15 +51,14 @@
</target>

<target name="prepend-header">
<!-- TODO: refactor this ugly mess -->
<copy todir="${dist.dir}/headers/">
<fileset dir="${dist.dir}/ui/" includes="*.js" />
</copy>
<replaceregexp match="^(\/\*.*?\*\/\s).+" replace="\1" flags="s">
<fileset dir="${dist.dir}/headers/" includes="*.js"/>
</replaceregexp>
<for param="file">
<path><fileset dir="${dist.dir}/ui/minified/" includes="*.js" /></path>
<path><fileset dir="${min.dir}/" includes="*.js" /></path>
<sequential>
<propertyregex override="yes" property="target" input="@{file}" regexp=".*[\\/](.+)\.min\.js$" replace="\1"/>
<concat destfile="${dist.dir}/ui-headered/${target}.min.js">
Expand All @@ -66,9 +67,33 @@
</concat>
</sequential>
</for>
<copy todir="${dist.dir}/ui/minified">
<copy todir="${min.dir}">
<fileset dir="${dist.dir}/ui-headered/" includes="*.js" />
</copy>

<!-- once more for the i18n files -->
<!-- need to clean up headers in those files first
<copy todir="${dist.dir}/headers/i18n/">
<fileset dir="${dist.dir}/ui/i18n/" includes="*.js" />
</copy>
<replaceregexp match="^(\/\*.*?\*\/\s).+" replace="\1" flags="s">
<fileset dir="${dist.dir}/headers/i18n/" includes="*.js"/>
</replaceregexp>
<for param="file">
<path><fileset dir="${min.dir}/i18n/" includes="*.js" /></path>
<sequential>
<propertyregex override="yes" property="target" input="@{file}" regexp=".*[\\/](.+)\.min\.js$" replace="\1"/>
<concat destfile="${dist.dir}/ui-headered/i18n/${target}.min.js">
<header file="${dist.dir}/headers/i18n/${target}.js" />
<fileset file="@{file}" />
</concat>
</sequential>
</for>
<copy todir="${min.dir}/i18n/">
<fileset dir="${dist.dir}/ui-headered/i18n/" includes="*.js" />
</copy>
-->

<delete dir="${dist.dir}/headers/" />
<delete dir="${dist.dir}/ui-headered/" />
</target>
Expand Down Expand Up @@ -108,45 +133,44 @@

<target name="minify" depends="concatenate" description="Remove all comments and whitespace, no compression, great in combination with GZip">
<echo message="Building minified" />
<delete dir="${min.folder}/" />
<mkdir dir="${min.folder}" />
<delete dir="${min.folder}/i18n/" />
<mkdir dir="${min.folder}/i18n/" />
<delete dir="${min.dir}/" />
<mkdir dir="${min.dir}" />
<delete dir="${min.dir}/i18n/" />
<mkdir dir="${min.dir}/i18n/" />

<apply executable="java" parallel="false">
<fileset dir="${src.dir}/" includes="jquery.ui.*.js, jquery.effects.*.js" />
<arg line="-jar" />
<arg path="build/google-compiler-20091218.jar" />
<arg path="${closure-jar}" />
<arg value="--warning_level" />
<arg value="QUIET" />
<arg value="--js_output_file" />
<targetfile />
<arg value="--js" />
<mapper type="glob" from="*.js" to="${min.folder}/*.min.js" />
<mapper type="glob" from="*.js" to="${min.dir}/*.min.js" />
</apply>

<concat destfile="${min.dir}/${concatenated}.min.js">
<filelist dir="${min.dir}" files="${core.files.min}" />
<fileset dir="${min.dir}" includes="jquery.ui.*.js, jquery.effects.*.js" excludes="${core.files.min}" />
</concat>

<apply executable="java" parallel="false" verbose="true" dest="${dist.dir}">
<filelist dir="${dist.dir}/ui/" files="${concatenated}.js" />
<apply executable="java" parallel="false">
<fileset dir="${src.dir}/i18n/" includes="jquery.ui.*.js" />
<arg line="-jar" />
<arg path="build/google-compiler-20091218.jar" />
<arg path="${closure-jar}" />
<arg value="--warning_level" />
<arg value="QUIET" />
<arg value="--js_output_file" />
<targetfile />
<arg value="--js" />
<mapper type="glob" from="${concatenated}.js" to="tmpmin" />
<mapper type="glob" from="*.js" to="${min.dir}/i18n/*.min.js" />
</apply>
<concat destfile="${min.folder}/jquery-ui.min.js">
<filelist files="${src.dir}/jquery.ui.core.js, ${dist.dir}/tmpmin"/>
<filterchain>
<headfilter lines="9"/>
</filterchain>
</concat>
<concat destfile="${min.folder}/jquery-ui.min.js" append="yes">
<filelist files="${dist.dir}/tmpmin"/>

<concat destfile="${min.dir}/i18n/${concatenated.i18n}.min.js">
<fileset dir="${min.dir}/i18n" includes="jquery.ui.*.js" />
</concat>
<delete file="${dist.dir}/tmpmin"/>


<echo message="Minified ui/ built." />
</target>

Expand Down Expand Up @@ -257,5 +281,41 @@
</replaceregexp>
<echo message="All trailing spaces removed." />
</target>

<target name="googlecdn">
<delete dir="${cdndist.dir}" />
<mkdir dir="${cdndist.dir}" />
<copy todir="${cdndist.dir}">
<fileset dir=".." includes="AUTHORS.txt, GPL-LICENSE.txt, MIT-LICENSE.txt, version.txt" />
</copy>
<copy todir="${cdndist.dir}">
<fileset dir="${dist.dir}ui" includes="jquery-ui.js" />
<fileset dir="${dist.dir}ui/minified" includes="jquery-ui.min.js" />
</copy>
<copy todir="${cdndist.dir}/i18n">
<fileset dir="${dist.dir}ui/i18n" />
<fileset dir="${dist.dir}ui/minified/i18n" />
</copy>
<copy todir="${cdndist.dir}/themes">
<fileset dir="${dist.dir}themes" />
</copy>
<checksum>
<fileset dir="${cdndist.dir}" />
</checksum>
<for param="file">
<path><fileset dir="${cdndist.dir}" includes="**/" excludes="**/*.MD5" /></path>
<sequential>
<!-- @{file} is an absolute path, use that ugly regexes to make it relative -->
<propertyregex override="yes" property="relativepath" input="@{file}" regexp=".+?googlecdn[\\/](.+)$" replace="\1"/>
<propertyregex override="yes" property="relativepath" input="${relativepath}" regexp="\\" replace="/" global="true" />
<concat destfile="${cdndist.dir}/MANIFEST" append="yes">${relativepath} </concat>
<concat destfile="${cdndist.dir}/MANIFEST" append="yes"><file file="@{file}.MD5" /></concat>
</sequential>
</for>
<delete dir="${cdndist.dir}" includes="**/*.MD5" />
<zip destfile="${dist.dir}/../${release.filename}-googlecdn.zip">
<zipfileset dir="${cdndist.dir}/" />
</zip>
</target>

</project>
21 changes: 13 additions & 8 deletions demos/autocomplete/combobox.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,23 @@
var matcher = new RegExp(request.term, "i");
response(select.children("option").map(function() {
var text = $(this).text();
if (!request.term || matcher.test(text))
if (this.value && (!request.term || matcher.test(text)))
return {
id: $(this).val(),
label: text.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + request.term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>"),
id: this.value,
label: text.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>"),
value: text
};
}));
},
delay: 0,
select: function(e, ui) {
change: function(event, ui) {
if (!ui.item) {
// remove invalid value, as it didn't match anything
$(this).val("");
return false;
}
$(this).focus();
select.val(ui.item.id);
self._trigger("selected", null, {
self._trigger("selected", event, {
item: select.find("[value='" + ui.item.id + "']")
});

Expand All @@ -56,6 +55,7 @@
})
.addClass("ui-widget ui-widget-content ui-corner-left");
$("<button>&nbsp;</button>")
.attr("tabIndex", -1)
.attr("title", "Show All Items")
.insertAfter(input)
.button({
Expand All @@ -81,7 +81,10 @@
})(jQuery);

$(function() {
$("select").combobox();
$("#combobox").combobox();
$("#toggle").click(function() {
$("#combobox").toggle();
});
});
</script>
</head>
Expand All @@ -91,7 +94,8 @@

<div class="ui-widget">
<label>Your preferred programming language: </label>
<select>
<select id="combobox">
<option value="">Select one...</option>
<option value="a">asp</option>
<option value="c">c</option>
<option value="cpp">c++</option>
Expand All @@ -107,6 +111,7 @@
<option value="s">scala</option>
</select>
</div>
<button id="toggle">Show underlying select</button>

</div><!-- End demo -->

Expand Down
3 changes: 3 additions & 0 deletions demos/autocomplete/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ <h4>Examples</h4>
<li><a href="combobox.html">Combobox</a></li>
<li><a href="custom-data.html">Custom data and display</a></li>
<li><a href="xml.html">XML data parsed once</a></li>
<li><a href="categories.html">Categories</a></li>
<li><a href="multiple.html">Multiple values</a></li>
<li><a href="multiple-remote.html">Multiple, remote</a></li>
</ul>
</div>
</body>
Expand Down
75 changes: 75 additions & 0 deletions demos/autocomplete/multiple-remote.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>jQuery UI Autocomplete multiple demo</title>
<link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="../../jquery-1.4.2.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../ui/jquery.ui.autocomplete.js"></script>
<link type="text/css" href="../demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}

$("#birds").autocomplete({
source: function(request, response) {
$.getJSON("search.php", {
term: extractLast(request.term)
}, response);
},
search: function() {
// custom minLength
var term = extractLast(this.value);
if (term.length < 2) {
return false;
}
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function(event, ui) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms.join(", ");
return false;
}
});
});
</script>
</head>
<body>

<div class="demo">

<div class="ui-widget">
<label for="birds">Birds: </label>
<input id="birds" size="50" />
</div>

</div><!-- End demo -->

<div class="demo-description">
<p>
Usage: Enter at least two characters to get bird name suggestions. Select a value to continue adding more names.
</p>
<p>
This is an example showing how to use the source-option along with some events to enable autocompleting multiple values into a single field.
</p>
</div><!-- End demo-description -->

</body>
</html>
Loading

0 comments on commit 970ed9a

Please sign in to comment.