1#!/usr/bin/env sh
2#
3# This script loads the latest jQuery and jQuery-UI 1.* versions from jQuery's CDN
4#
5# It also loads the 'smoothness' jQuery-UI theme and all referenced images.
6#
7# @author Andreas Gohr <andi@splitbrain.org>
8# @author Stefan Grönke <stefan@gronke.net>
9# @link   http://code.jquery.com/
10
11# load version info from external file
12source ./versions
13JQUI_HOST="https://code.jquery.com/ui/$JQUI_VERSION"
14JQUI_GIT="https://raw.githubusercontent.com/jquery/jquery-ui/$JQUI_VERSION/ui"
15
16# load jQuery
17wget -nv https://code.jquery.com/jquery-${JQ_VERSION}.min.js      -O jquery.min.js
18# load jQuery-UI
19wget -nv "$JQUI_HOST/jquery-ui.min.js" -O jquery-ui.min.js
20
21# load the smoothness theme
22mkdir -p jquery-ui-theme/images
23wget -nv -qO- "$JQUI_HOST/themes/smoothness/jquery-ui.css" | sed "s/font-family:[^;]*;//" > jquery-ui-theme/smoothness.css
24images=`gawk 'match($0, /url\("?(images\/[^\)"]+)"?\)/, m) { print m[1] }' jquery-ui-theme/smoothness.css`
25for img in $images
26do
27    wget -nv "$JQUI_HOST/themes/smoothness/$img" -O jquery-ui-theme/$img
28done
29
30# load the localization data for jquery ui
31for LNG in ../../../inc/lang/*
32do
33    CODE=`basename $LNG`
34    wget -nv "$JQUI_GIT/i18n/datepicker-$CODE.js" -O $LNG/jquery.ui.datepicker.js
35    if [ ! -s "$LNG/jquery.ui.datepicker.js" ]; then
36        rm -f $LNG/jquery.ui.datepicker.js
37    fi
38done
39
40# some custom language codes
41wget -nv "$JQUI_GIT/i18n/datepicker-de.js" -O ../../../inc/lang/de-informal/jquery.ui.datepicker.js
42wget -nv "$JQUI_GIT/i18n/datepicker-pt-BR.js" -O ../../../inc/lang/pt-br/jquery.ui.datepicker.js
43wget -nv "$JQUI_GIT/i18n/datepicker-zh-CN.js" -O ../../../inc/lang/zh/jquery.ui.datepicker.js
44wget -nv "$JQUI_GIT/i18n/datepicker-zh-TW.js" -O ../../../inc/lang/zh-tw/jquery.ui.datepicker.js
45wget -nv "$JQUI_GIT/i18n/datepicker-cy-GB.js" -O ../../../inc/lang/cy/jquery.ui.datepicker.js
46
47# strip source maps
48sed -i '/sourceMappingURL/d' *.min.js
49