#!/bin/bash
################################################################################
#
# This script handles compression of all CSS and JS files to a single 
# distribution files in order to prevent multiple loading and compressing of
# scripts and style files.
#
# A developer must run this script after a change of any JS/CSS file.
#
# @author Ondrej Fibich
# @since 1.1
#
################################################################################

set -e

# compresser library
YUI="./lib/yuicompressor-2.4.8.jar"

# source CSS directory
DIR_CSS="`pwd`/../../../media/css"

# source JS directory
DIR_JS="`pwd`/../../../media/js"

cat	"$DIR_JS/jquery.min.js" \
	"$DIR_JS/jquery-ui.min.js" \
	"$DIR_JS/jquery.ui.datepicker-cs.js" \
	"$DIR_JS/jquery.validate.min.js" \
	"$DIR_JS/jquery.cookie.min.js" \
	"$DIR_JS/jquery.validate.password.js" \
	"$DIR_JS/jquery.metadata.js" \
	"$DIR_JS/jquery.tablesorter.js" \
	"$DIR_JS/jquery.form.min.js" \
	"$DIR_JS/jquery.timer.js" \
	"$DIR_JS/jquery.autoresize.js" \
	"$DIR_JS/jquery.jstree.js" \
	"$DIR_JS/messages_cs.js" \
	"$DIR_JS/php.min.js" \
| java -jar "$YUI" --type js --charset utf8 --line-break 4000 --nomunge --preserve-semi --disable-optimizations -o "$DIR_JS/js-libs-all.js"

