azkaban-uncached
Changes
bin/azkaban-executor-shutdown.sh 10(+10 -0)
bin/azkaban-executor-start.sh 41(+41 -0)
bin/azkaban-web-shutdown.sh 6(+6 -0)
bin/azkaban-web-start.sh 38(+38 -0)
build.properties 3(+2 -1)
build.xml 103(+101 -2)
conf/azkaban.properties 26(+12 -14)
conf/azkaban-users.xml 4(+3 -1)
lib/commons-dbcp-1.4.jar 0(+0 -0)
lib/commons-dbutils-1.5.jar 0(+0 -0)
lib/commons-pool-1.6.jar 0(+0 -0)
src/java/azkaban/execapp/AzkabanExecutorServer.java 329(+77 -252)
src/java/azkaban/execapp/event/Event.java 26(+16 -10)
src/java/azkaban/execapp/ExecutorServlet.java 275(+275 -0)
src/java/azkaban/execapp/FlowRunner.java 577(+577 -0)
src/java/azkaban/execapp/FlowRunnerManager.java 446(+446 -0)
src/java/azkaban/execapp/JobRunner.java 257(+174 -83)
src/java/azkaban/execapp/ProjectVersion.java 93(+93 -0)
src/java/azkaban/executor/ExecutableFlow.java 151(+121 -30)
src/java/azkaban/executor/ExecutableNode.java 48(+37 -11)
src/java/azkaban/executor/ExecutorMailer.java 182(+182 -0)
src/java/azkaban/executor/ExecutorManager.java 1629(+440 -1189)
src/java/azkaban/executor/JdbcExecutorLoader.java 807(+807 -0)
src/java/azkaban/flow/Flow.java 27(+20 -7)
src/java/azkaban/fsviewers/HdfsAvroFileViewer.java 148(+74 -74)
src/java/azkaban/fsviewers/HdfsFileViewer.java 24(+12 -12)
src/java/azkaban/fsviewers/TextFileViewer.java 90(+45 -45)
src/java/azkaban/jobExecutor/AbstractJob.java 156(+76 -80)
src/java/azkaban/jobExecutor/AbstractProcessJob.java 300(+146 -154)
src/java/azkaban/jobExecutor/JavaJob.java 77(+37 -40)
src/java/azkaban/jobExecutor/JavaProcessJob.java 33(+16 -17)
src/java/azkaban/jobExecutor/ProcessJob.java 60(+28 -32)
src/java/azkaban/jobtype/JobtypeManager.java 222(+222 -0)
src/java/azkaban/project/JdbcProjectLoader.java 1153(+1153 -0)
src/java/azkaban/project/Project.java 171(+129 -42)
src/java/azkaban/project/ProjectFileHandler.java 106(+106 -0)
src/java/azkaban/project/ProjectLoader.java 218(+218 -0)
src/java/azkaban/project/ProjectManager.java 322(+286 -36)
src/java/azkaban/scheduler/JdbcScheduleLoader.java 312(+312 -0)
src/java/azkaban/scheduler/Schedule.java 270(+270 -0)
src/java/azkaban/scheduler/ScheduleManager.java 342(+168 -174)
src/java/azkaban/user/Permission.java 55(+50 -5)
src/java/azkaban/user/Role.java 23(+23 -0)
src/java/azkaban/user/XmlUserManager.java 60(+49 -11)
src/java/azkaban/utils/DataSourceUtils.java 44(+44 -0)
src/java/azkaban/utils/EmailMessage.java 189(+189 -0)
src/java/azkaban/utils/FileIOUtils.java 299(+299 -0)
src/java/azkaban/utils/GZIPUtils.java 48(+48 -0)
src/java/azkaban/utils/LogGobbler.java 72(+72 -0)
src/java/azkaban/utils/Md5Hasher.java 48(+48 -0)
src/java/azkaban/utils/Pair.java 11(+11 -0)
src/java/azkaban/utils/PropsUtils.java 344(+201 -143)
src/java/azkaban/utils/SecurityUtils.java 215(+148 -67)
src/java/azkaban/utils/Triple.java 66(+66 -0)
src/java/azkaban/utils/Utils.java 18(+18 -0)
src/java/azkaban/utils/WebUtils.java 10(+7 -3)
src/java/azkaban/webapp/AzkabanAdminServer.java 250(+250 -0)
src/java/azkaban/webapp/AzkabanServer.java 17(+17 -0)
src/java/azkaban/webapp/AzkabanWebServer.java 216(+120 -96)
src/java/azkaban/webapp/servlet/ExecutorServlet.java 278(+144 -134)
src/java/azkaban/webapp/servlet/HdfsBrowserServlet.java 404(+188 -216)
src/java/azkaban/webapp/servlet/HistoryServlet.java 219(+137 -82)
src/java/azkaban/webapp/servlet/ProjectManagerServlet.java 417(+236 -181)
src/java/azkaban/webapp/servlet/ScheduleServlet.java 134(+80 -54)
src/sql/create_active_flow.sql 7(+7 -0)
src/sql/create_execution_flow.sql 19(+19 -0)
src/sql/create_execution_job.sql 16(+16 -0)
src/sql/create_execution_logs.sql 10(+10 -0)
src/sql/create_project_files.sql 9(+9 -0)
src/sql/create_project_flow_table.sql 11(+11 -0)
src/sql/create_project_properties.sql 10(+10 -0)
src/sql/create_project_table.sql 12(+12 -0)
src/sql/create_project_version_table.sql 12(+12 -0)
src/sql/create_schedule_table.sql 17(+17 -0)
src/web/css/azkaban.css 193(+191 -2)
src/web/css/jquery-ui.css 473(+473 -0)
src/web/css/jquery-ui-1.9.2.custom.css 462(+462 -0)
src/web/css/jquery-ui-timepicker-addon.css 10(+10 -0)
src/web/js/azkaban.admin.setup.js 117(+117 -0)
src/web/js/azkaban.ajax.utils.js 16(+0 -16)
src/web/js/azkaban.date.utils.js 2(+1 -1)
src/web/js/azkaban.exflow.options.view.js 26(+14 -12)
src/web/js/azkaban.exflow.view.js 35(+18 -17)
src/web/js/azkaban.flow.graph.view.js 16(+9 -7)
src/web/js/azkaban.flow.job.view.js 8(+5 -3)
src/web/js/azkaban.flow.view.js 5(+3 -2)
src/web/js/azkaban.history.view.js 28(+18 -10)
src/web/js/azkaban.joblog.view.js 89(+56 -33)
src/web/js/azkaban.login.js 46(+46 -0)
src/web/js/azkaban.permission.view.js 65(+44 -21)
src/web/js/azkaban.projectlog.view.js 61(+58 -3)
src/web/js/azkaban.scheduled.view.js 4(+2 -2)
src/web/js/jquery/jquery-1.8.3.js 9472(+9472 -0)
src/web/js/jqueryui/jquery-ui-1.9.2.custom.js 14879(+14879 -0)
src/web/js/jqueryui/jquery-ui-timepicker-addon.js 1882(+1882 -0)
unit/build.xml 57(+57 -0)
unit/executions/exectest1/exec1.flow 2(+2 -0)
unit/executions/exectest1/exec2.flow 2(+2 -0)
unit/executions/exectest1/exec3.flow 2(+2 -0)
unit/executions/logtest/largeLog1.log 3240(+3240 -0)
unit/executions/logtest/largeLog3.log 7200(+7200 -0)
unit/executions/logtest/log1.log 1(+1 -0)
unit/executions/logtest/log2.log 1(+1 -0)
unit/executions/logtest/log3.log 1(+1 -0)
unit/java/azkaban/test/execapp/FlowRunnerTest.java 154(+92 -62)
unit/java/azkaban/test/execapp/JobRunnerTest.java 116(+67 -49)
unit/java/azkaban/test/utils/FileIOUtilsTest.java 118(+118 -0)
unit/project/testflow/testFlow.zip 0(+0 -0)
unit/project/testjob/testjob.zip 0(+0 -0)
unit/project/testjob/testjob-med.zip 0(+0 -0)
Details
bin/azkaban-executor-shutdown.sh 10(+10 -0)
diff --git a/bin/azkaban-executor-shutdown.sh b/bin/azkaban-executor-shutdown.sh
new file mode 100644
index 0000000..21fea3c
--- /dev/null
+++ b/bin/azkaban-executor-shutdown.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+executorport=`cat conf/azkaban.properties | grep executor.port | cut -d = -f 2`
+echo "Shutting down current running AzkabanExecutorServer at port $executorport"
+
+proc=`cat currentpid`
+
+kill $proc
+
+cat /dev/null > currentpid
bin/azkaban-executor-start.sh 41(+41 -0)
diff --git a/bin/azkaban-executor-start.sh b/bin/azkaban-executor-start.sh
new file mode 100644
index 0000000..500b966
--- /dev/null
+++ b/bin/azkaban-executor-start.sh
@@ -0,0 +1,41 @@
+azkaban_dir=$(dirname $0)/..
+base_dir=$1
+tmpdir=
+
+if [[ -z "$tmpdir" ]]; then
+echo "temp directory must be set!"
+exit
+fi
+
+for file in $azkaban_dir/lib/*.jar;
+do
+ CLASSPATH=$CLASSPATH:$file
+done
+
+for file in $azkaban_dir/extlib/*.jar;
+do
+ CLASSPATH=$CLASSPATH:$file
+done
+
+for file in $base_dir/plugins/*/*.jar;
+do
+ CLASSPATH=$CLASSPATH:$file
+done
+
+echo $azkaban_dir;
+echo $base_dir;
+echo $CLASSPATH;
+
+executorport=`cat conf/azkaban.properties | grep executor.port | cut -d = -f 2`
+echo "Starting AzkabanExecutorServer on port $executorport ..."
+
+if [ -z $AZKABAN_OPTS ]; then
+ AZKABAN_OPTS="-Xmx3G -server -Dcom.sun.management.jmxremote -Djava.io.tmpdir=$tmpdir -Dexecutorport=$executorport"
+fi
+
+NATIVE_LIB_OPTS="-Djava.library.path=$HADOOP_HOME/lib/native/Linux-amd64-64"
+
+java $AZKABAN_OPTS $NATIVE_LIB_OPTS -cp $CLASSPATH azkaban.execapp.AzkabanExecutorServer -conf $base_dir/conf $@ &
+
+echo $! > currentpid
+
bin/azkaban-web-shutdown.sh 6(+6 -0)
diff --git a/bin/azkaban-web-shutdown.sh b/bin/azkaban-web-shutdown.sh
new file mode 100644
index 0000000..662e4a6
--- /dev/null
+++ b/bin/azkaban-web-shutdown.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+proc=`cat currentpid`
+echo "killing AzkabanWebServer"
+kill $proc
+
+cat /dev/null > currentpid
bin/azkaban-web-start.sh 38(+38 -0)
diff --git a/bin/azkaban-web-start.sh b/bin/azkaban-web-start.sh
new file mode 100644
index 0000000..e53ab33
--- /dev/null
+++ b/bin/azkaban-web-start.sh
@@ -0,0 +1,38 @@
+azkaban_dir=$(dirname $0)/..
+base_dir=$1
+tmpdir=
+
+if [[ -z "$tmpdir" ]]; then
+echo "temp directory must be set!"
+exit
+fi
+
+for file in $azkaban_dir/lib/*.jar;
+do
+ CLASSPATH=$CLASSPATH:$file
+done
+
+for file in $azkaban_dir/extlib/*.jar;
+do
+ CLASSPATH=$CLASSPATH:$file
+done
+
+for file in $base_dir/plugins/*/*.jar;
+do
+ CLASSPATH=$CLASSPATH:$file
+done
+
+echo $azkaban_dir;
+echo $base_dir;
+echo $CLASSPATH;
+
+if [ -z $AZKABAN_OPTS ]; then
+ AZKABAN_OPTS="-Xmx3G -server -Dcom.sun.management.jmxremote -Djava.io.tmpdir=$tmpdir"
+fi
+
+HADOOP_NATIVE_LIB="-Djava.library.path=$HADOOP_HOME/lib/native/Linux-amd64-64"
+
+java $AZKABAN_OPTS $HADOOP_NATIVE_LIB -cp $CLASSPATH azkaban.webapp.AzkabanWebServer -conf $base_dir/conf $@ &
+
+echo $! > currentpid
+
build.properties 3(+2 -1)
diff --git a/build.properties b/build.properties
index 6bb299a..a6a63c9 100644
--- a/build.properties
+++ b/build.properties
@@ -1,2 +1,3 @@
name=azkaban
-version=2.0
\ No newline at end of file
+version=2.0
+spec.file=azkaban.spec
\ No newline at end of file
build.xml 103(+101 -2)
diff --git a/build.xml b/build.xml
index 222687b..e48342a 100644
--- a/build.xml
+++ b/build.xml
@@ -1,12 +1,23 @@
<?xml version="1.0"?>
<project name="azkaban" basedir="." default="all">
+ <property file="build.properties" />
<property name="base.dir" value="${basedir}" />
<property name="dist.jar.dir" value="${basedir}/dist/jars" />
<property name="dist.classes.dir" value="${basedir}/dist/classes" />
+ <property name="dist.packages.dir" value="${basedir}/dist/packages" />
+ <property name="dist.web.package.dir" value="${dist.packages.dir}/azkaban-web-server" />
+ <property name="dist.exec.package.dir" value="${dist.packages.dir}/azkaban-exec-server" />
+ <property name="dist.sql.package.dir" value="${dist.packages.dir}/sql" />
+
+ <property name="conf.dir" value="${basedir}/conf" />
<property name="lib.dir" value="${basedir}/lib" />
+ <property name="bin.dir" value="${basedir}/bin" />
<property name="java.src.dir" value="${basedir}/src/java" />
- <property file="build.properties" />
+ <property name="web.src.dir" value="${basedir}/src/web" />
+ <property name="sql.src.dir" value="${basedir}/src/sql" />
+
+ <property name="azkaban.jar" value="${dist.jar.dir}/${name}-${version}.jar" />
<property environment="env" />
@@ -49,11 +60,99 @@
<target name="jars" depends="build" description="Create azkaban jar">
<mkdir dir="${dist.jar.dir}" />
- <jar destfile="${dist.jar.dir}/${name}-${version}.jar">
+ <jar destfile="${azkaban.jar}">
<fileset dir="${dist.classes.dir}">
<include name="**/*.*" />
</fileset>
</jar>
</target>
+ <target name="package-sql-scripts" description="Creates a package of sql">
+ <delete dir="${dist.sql.package.dir}" />
+ <mkdir dir="${dist.sql.package.dir}" />
+
+ <copy todir="${dist.sql.package.dir}" >
+ <fileset dir="${sql.src.dir}" />
+ </copy>
+
+ <tar destfile="${dist.sql.package.dir}/${name}-sql-script-${version}.tar.gz" compression="gzip" longfile="gnu">
+ <tarfileset dir="${dist.sql.package.dir}" prefix="azkaban-${version}" filemode="755" />
+ </tar>
+
+ </target>
+
+ <target name="package-web-server" depends="jars" description="Creates a package for the webserver">
+ <delete dir="${dist.web.package.dir}" />
+ <mkdir dir="${dist.web.package.dir}" />
+ <mkdir dir="${dist.web.package.dir}/conf" />
+ <mkdir dir="${dist.web.package.dir}/bin" />
+ <mkdir dir="${dist.web.package.dir}/lib" />
+ <mkdir dir="${dist.web.package.dir}/web" />
+ <mkdir dir="${dist.web.package.dir}/plugins" />
+ <mkdir dir="${dist.web.package.dir}/extlib" />
+
+ <!-- Copy Azkaban jars and libs-->
+ <copy file="${azkaban.jar}" todir="${dist.web.package.dir}/lib" />
+ <copy todir="${dist.web.package.dir}/lib" >
+ <fileset dir="${lib.dir}" >
+ <exclude name="hadoop-core*.jar"/>
+ </fileset>
+ </copy>
+
+ <!-- Copy bin files for web server only-->
+ <copy todir="${dist.web.package.dir}/bin" >
+ <fileset dir="${bin.dir}" includes="**/azkaban-web*"/>
+ </copy>
+
+ <!-- Copy web files -->
+ <copy todir="${dist.web.package.dir}/web" >
+ <fileset dir="${web.src.dir}" />
+ </copy>
+
+ <!-- Copy conf create table scripts -->
+ <copy todir="${dist.web.package.dir}/conf" >
+ <fileset dir="${conf.dir}" />
+ </copy>
+
+ <!-- Tarball it -->
+ <tar destfile="${dist.web.package.dir}/${name}-web-server-${version}.tar.gz" compression="gzip" longfile="gnu">
+ <tarfileset dir="${dist.web.package.dir}" prefix="azkaban-${version}" filemode="755" />
+ </tar>
+ </target>
+
+ <target name="package-exec-server" depends="jars" description="Creates a package for the execserver">
+ <delete dir="${dist.exec.package.dir}" />
+ <mkdir dir="${dist.exec.package.dir}" />
+ <mkdir dir="${dist.exec.package.dir}/conf" />
+ <mkdir dir="${dist.exec.package.dir}/bin" />
+ <mkdir dir="${dist.exec.package.dir}/lib" />
+ <mkdir dir="${dist.exec.package.dir}/plugins" />
+ <mkdir dir="${dist.exec.package.dir}/extlib" />
+
+ <!-- Copy Azkaban jars and libs-->
+ <copy file="${azkaban.jar}" todir="${dist.exec.package.dir}/lib" />
+ <copy todir="${dist.exec.package.dir}/lib" >
+ <fileset dir="${lib.dir}" >
+ <exclude name="hadoop-core*.jar"/>
+ </fileset>
+ </copy>
+
+ <!-- Copy bin files for exec server only-->
+ <copy todir="${dist.exec.package.dir}/bin" >
+ <fileset dir="${bin.dir}" includes="**/azkaban-executor*"/>
+ </copy>
+
+ <!-- Copy conf files -->
+ <copy todir="${dist.exec.package.dir}/conf" >
+ <fileset dir="${conf.dir}" />
+ </copy>
+
+ <!-- Tarball it -->
+ <tar destfile="${dist.exec.package.dir}/${name}-executor-server-${version}.tar.gz" compression="gzip" longfile="gnu">
+ <tarfileset dir="${dist.exec.package.dir}" prefix="azkaban-${version}" filemode="755" />
+ </tar>
+ </target>
+
+ <target name="package-all" depends="package-exec-server, package-web-server, package-sql-scripts" description="Create all packages">
+ </target>
</project>
conf/azkaban.properties 26(+12 -14)
diff --git a/conf/azkaban.properties b/conf/azkaban.properties
index 48984f1..c222cfb 100644
--- a/conf/azkaban.properties
+++ b/conf/azkaban.properties
@@ -2,8 +2,7 @@
azkaban.name=Local
azkaban.label=My Local Azkaban
azkaban.color=#FF3601
-azkaban.temp.dir=temp
-web.resource.dir=src/web/
+web.resource.dir=web/
default.timezone.id=America/Los_Angeles
#Azkaban UserManager class
@@ -11,20 +10,19 @@ user.manager.class=azkaban.user.XmlUserManager
user.manager.xml.file=conf/azkaban-users.xml
#Loader for projects
-project.manager.class=azkaban.project.FileProjectManager
-file.project.loader.path=projects
-project.global.properties=conf/global.properties
+executor.global.properties=conf/global.properties
+azkaban.project.dir=projects
-#Execution directory
-execution.directory=execution
-
-#Schedule files
-schedule.directory=schedule
-schedule.path=schedule
-schedule.backup=backup
+database.type=mysql
+mysql.port=3306
+mysql.host=localhost
+mysql.database=azkaban2
+mysql.user=azkaban
+mysql.password=azkaban
+mysql.numconnections=100
# Velocity dev mode
-velocity.dev.mode=true
+velocity.dev.mode=false
# Azkaban Jetty server properties. Ignored in tomcat
jetty.maxThreads=25
@@ -39,7 +37,7 @@ jetty.trustpassword=password
# Azkaban Executor settings
executor.maxThreads=50
executor.port=12321
-executor.shared.token=abcdefg
+#executor.shared.token=abcdefg
executor.flow.threads=30
# mail settings
conf/azkaban-users.xml 4(+3 -1)
diff --git a/conf/azkaban-users.xml b/conf/azkaban-users.xml
index af86b99..2f50c41 100644
--- a/conf/azkaban-users.xml
+++ b/conf/azkaban-users.xml
@@ -1,3 +1,5 @@
<azkaban-users>
<user username="azkaban" password="azkaban" roles="admin" groups="azkaban"/>
-</azkaban-users>
\ No newline at end of file
+
+ <role name="admin" permissions="ADMIN" />
+</azkaban-users>
lib/commons-dbcp-1.4.jar 0(+0 -0)
diff --git a/lib/commons-dbcp-1.4.jar b/lib/commons-dbcp-1.4.jar
new file mode 100644
index 0000000..c4c1c4f
Binary files /dev/null and b/lib/commons-dbcp-1.4.jar differ
lib/commons-dbutils-1.5.jar 0(+0 -0)
diff --git a/lib/commons-dbutils-1.5.jar b/lib/commons-dbutils-1.5.jar
new file mode 100644
index 0000000..b0c0e12
Binary files /dev/null and b/lib/commons-dbutils-1.5.jar differ
lib/commons-pool-1.6.jar 0(+0 -0)
diff --git a/lib/commons-pool-1.6.jar b/lib/commons-pool-1.6.jar
new file mode 100644
index 0000000..72ca75a
Binary files /dev/null and b/lib/commons-pool-1.6.jar differ
src/java/azkaban/execapp/ExecutorServlet.java 275(+275 -0)
diff --git a/src/java/azkaban/execapp/ExecutorServlet.java b/src/java/azkaban/execapp/ExecutorServlet.java
new file mode 100644
index 0000000..5556d2a
--- /dev/null
+++ b/src/java/azkaban/execapp/ExecutorServlet.java
@@ -0,0 +1,275 @@
+package azkaban.execapp;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.codehaus.jackson.map.ObjectMapper;
+
+import azkaban.executor.ConnectorParams;
+import azkaban.executor.ExecutableFlow;
+import azkaban.executor.ExecutorManagerException;
+import azkaban.utils.FileIOUtils.LogData;
+import azkaban.utils.JSONUtils;
+import azkaban.webapp.servlet.AzkabanServletContextListener;
+
+public class ExecutorServlet extends HttpServlet implements ConnectorParams {
+ private static final long serialVersionUID = 1L;
+ private static final Logger logger = Logger.getLogger(ExecutorServlet.class.getName());
+ public static final String JSON_MIME_TYPE = "application/json";
+
+ private AzkabanExecutorServer application;
+ private FlowRunnerManager flowRunnerManager;
+
+
+ public ExecutorServlet() {
+ super();
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ application = (AzkabanExecutorServer) config.getServletContext().getAttribute(AzkabanServletContextListener.AZKABAN_SERVLET_CONTEXT_KEY);
+
+ if (application == null) {
+ throw new IllegalStateException(
+ "No batch application is defined in the servlet context!");
+ }
+
+ flowRunnerManager = application.getFlowRunnerManager();
+ }
+
+
+ protected void writeJSON(HttpServletResponse resp, Object obj) throws IOException {
+ resp.setContentType(JSON_MIME_TYPE);
+ ObjectMapper mapper = new ObjectMapper();
+ OutputStream stream = resp.getOutputStream();
+ mapper.writeValue(stream, obj);
+ }
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ HashMap<String,Object> respMap= new HashMap<String,Object>();
+ try {
+ if (!hasParam(req, ACTION_PARAM)) {
+ respMap.put("error", "Parameter action not set");
+ }
+ else {
+ String action = getParam(req, ACTION_PARAM);
+ if (action.equals(UPDATE_ACTION)) {
+ handleAjaxUpdateRequest(req, respMap);
+ }
+ else if (action.equals(PING_ACTION)) {
+ respMap.put("status", "alive");
+ }
+ else {
+ int execid = Integer.parseInt(getParam(req, EXECID_PARAM));
+ String user = getParam(req, USER_PARAM, null);
+
+ if (action.equals(LOG_ACTION)) {
+ handleFetchLogEvent(execid, req, resp, respMap);
+ }
+ else if (action.equals(EXECUTE_ACTION)) {
+ handleAjaxExecute(req, respMap, execid);
+ }
+ else if (action.equals(STATUS_ACTION)) {
+ handleAjaxFlowStatus(respMap, execid);
+ }
+ else if (action.equals(CANCEL_ACTION)) {
+ logger.info("Cancel called.");
+ handleAjaxCancel(respMap, execid, user);
+ }
+ else if (action.equals(PAUSE_ACTION)) {
+ logger.info("Paused called.");
+ handleAjaxPause(respMap, execid, user);
+ }
+ else if (action.equals(RESUME_ACTION)) {
+ logger.info("Resume called.");
+ handleAjaxResume(respMap, execid, user);
+ }
+ else {
+ respMap.put("error", "action: '" + action + "' not supported.");
+ }
+ }
+ }
+ } catch (Exception e) {
+ respMap.put(RESPONSE_ERROR, e.getMessage());
+ }
+ writeJSON(resp, respMap);
+ resp.flushBuffer();
+ }
+
+ private void handleFetchLogEvent(int execId, HttpServletRequest req, HttpServletResponse resp, Map<String, Object> respMap) throws ServletException {
+ String type = getParam(req, "type");
+ int startByte = getIntParam(req, "offset");
+ int length = getIntParam(req, "length");
+
+ resp.setContentType("text/plain");
+ resp.setCharacterEncoding("utf-8");
+
+ if (type.equals("flow")) {
+ LogData result;
+ try {
+ result = flowRunnerManager.readFlowLogs(execId, startByte, length);
+ respMap.putAll(result.toObject());
+ } catch (Exception e) {
+ respMap.put("error", e.getMessage());
+ }
+ }
+ else {
+ String jobId = getParam(req, "jobId");
+ try {
+ LogData result = flowRunnerManager.readJobLogs(execId, jobId, startByte, length);
+ respMap.putAll(result.toObject());
+ } catch (Exception e) {
+ respMap.put("error", e.getMessage());
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void handleAjaxUpdateRequest(HttpServletRequest req, Map<String, Object> respMap) throws ServletException, IOException {
+ ArrayList<Object> updateTimesList = (ArrayList<Object>)JSONUtils.parseJSONFromString(getParam(req, UPDATE_TIME_LIST_PARAM));
+ ArrayList<Object> execIDList = (ArrayList<Object>)JSONUtils.parseJSONFromString(getParam(req, EXEC_ID_LIST_PARAM));
+
+ ArrayList<Object> updateList = new ArrayList<Object>();
+ for (int i = 0; i < execIDList.size(); ++i) {
+ long updateTime = JSONUtils.getLongFromObject(updateTimesList.get(i));
+ int execId = (Integer)execIDList.get(i);
+
+ ExecutableFlow flow = flowRunnerManager.getExecutableFlow(execId);
+ if (flow == null) {
+ Map<String, Object> errorResponse = new HashMap<String,Object>();
+ errorResponse.put(RESPONSE_ERROR, "Flow does not exist");
+ errorResponse.put(UPDATE_MAP_EXEC_ID, execId);
+ updateList.add(errorResponse);
+ continue;
+ }
+
+ if (flow.getUpdateTime() > updateTime) {
+ updateList.add(flow.toUpdateObject(updateTime));
+ }
+ }
+
+ respMap.put(RESPONSE_UPDATED_FLOWS, updateList);
+ }
+
+ private void handleAjaxExecute(HttpServletRequest req, Map<String, Object> respMap, int execId) throws ServletException {
+ try {
+ flowRunnerManager.submitFlow(execId);
+ } catch (ExecutorManagerException e) {
+ respMap.put(RESPONSE_ERROR, e.getMessage());
+ }
+ }
+
+ private void handleAjaxFlowStatus(Map<String, Object> respMap, int execid) {
+ ExecutableFlow flow = flowRunnerManager.getExecutableFlow(execid);
+ if (flow == null) {
+ respMap.put(STATUS_PARAM, RESPONSE_NOTFOUND);
+ }
+ else {
+ respMap.put(STATUS_PARAM, flow.getStatus().toString());
+ respMap.put(RESPONSE_UPDATETIME, flow.getUpdateTime());
+ }
+ }
+
+ private void handleAjaxPause(Map<String, Object> respMap, int execid, String user) throws ServletException {
+ if (user == null) {
+ respMap.put(RESPONSE_ERROR, "user has not been set");
+ return;
+ }
+
+ try {
+ flowRunnerManager.pauseFlow(execid, user);
+ respMap.put(STATUS_PARAM, RESPONSE_SUCCESS);
+ } catch (ExecutorManagerException e) {
+ e.printStackTrace();
+ respMap.put(RESPONSE_ERROR, e.getMessage());
+ }
+ }
+
+ private void handleAjaxResume(Map<String, Object> respMap, int execid, String user) throws ServletException {
+ if (user == null) {
+ respMap.put(RESPONSE_ERROR, "user has not been set");
+ return;
+ }
+
+ try {
+ flowRunnerManager.resumeFlow(execid, user);
+ respMap.put(STATUS_PARAM, RESPONSE_SUCCESS);
+ } catch (ExecutorManagerException e) {
+ e.printStackTrace();
+ respMap.put(RESPONSE_ERROR, e.getMessage());
+ }
+ }
+
+ private void handleAjaxCancel(Map<String, Object> respMap, int execid, String user) throws ServletException {
+ if (user == null) {
+ respMap.put(RESPONSE_ERROR, "user has not been set");
+ return;
+ }
+
+ try {
+ flowRunnerManager.cancelFlow(execid, user);
+ respMap.put(STATUS_PARAM, RESPONSE_SUCCESS);
+ } catch (ExecutorManagerException e) {
+ e.printStackTrace();
+ respMap.put(RESPONSE_ERROR, e.getMessage());
+ }
+ }
+
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+
+ }
+
+ /**
+ * Duplicated code with AbstractAzkabanServlet, but ne
+ */
+ public boolean hasParam(HttpServletRequest request, String param) {
+ return request.getParameter(param) != null;
+ }
+
+ public String getParam(HttpServletRequest request, String name)
+ throws ServletException {
+ String p = request.getParameter(name);
+ if (p == null)
+ throw new ServletException("Missing required parameter '" + name + "'.");
+ else
+ return p;
+ }
+
+ public String getParam(HttpServletRequest request, String name, String defaultVal ) {
+ String p = request.getParameter(name);
+ if (p == null) {
+ return defaultVal;
+ }
+
+ return p;
+ }
+
+ public int getIntParam(HttpServletRequest request, String name) throws ServletException {
+ String p = getParam(request, name);
+ return Integer.parseInt(p);
+ }
+
+ public int getIntParam(HttpServletRequest request, String name, int defaultVal) {
+ if (hasParam(request, name)) {
+ try {
+ return getIntParam(request, name);
+ } catch (Exception e) {
+ return defaultVal;
+ }
+ }
+
+ return defaultVal;
+ }
+}
src/java/azkaban/execapp/FlowRunner.java 577(+577 -0)
diff --git a/src/java/azkaban/execapp/FlowRunner.java b/src/java/azkaban/execapp/FlowRunner.java
new file mode 100644
index 0000000..beab501
--- /dev/null
+++ b/src/java/azkaban/execapp/FlowRunner.java
@@ -0,0 +1,577 @@
+package azkaban.execapp;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.log4j.Appender;
+import org.apache.log4j.FileAppender;
+import org.apache.log4j.Layout;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+
+import azkaban.execapp.event.Event;
+import azkaban.execapp.event.Event.Type;
+import azkaban.execapp.event.EventHandler;
+import azkaban.execapp.event.EventListener;
+import azkaban.executor.ExecutableFlow;
+import azkaban.executor.ExecutableFlow.FailureAction;
+import azkaban.executor.ExecutableFlow.Status;
+import azkaban.executor.ExecutableNode;
+import azkaban.executor.ExecutorLoader;
+import azkaban.executor.ExecutorManagerException;
+import azkaban.flow.FlowProps;
+import azkaban.jobtype.JobtypeManager;
+import azkaban.security.HadoopSecurityManager;
+import azkaban.utils.Props;
+
+public class FlowRunner extends EventHandler implements Runnable {
+ private static final Layout DEFAULT_LAYOUT = new PatternLayout("%d{dd-MM-yyyy HH:mm:ss z} %c{1} %p - %m\n");
+ private int execId;
+
+ private File execDir;
+
+ private ExecutorService executorService;
+ private ExecutorLoader executorLoader;
+
+ private ExecutableFlow flow;
+ private Thread currentThread;
+ private int numThreads = 10;
+
+ private Logger logger;
+ private Layout loggerLayout = DEFAULT_LAYOUT;
+ private Appender flowAppender;
+ private File logFile;
+
+ // Properties map
+ private Map<String, Props> sharedProps = new HashMap<String, Props>();
+ private Map<String, Props> jobOutputProps = new HashMap<String, Props>();
+
+ private Props globalProps;
+ private final JobtypeManager jobtypeManager;
+ private final HadoopSecurityManager hadoopSecurityManager;
+
+ private JobRunnerEventListener listener = new JobRunnerEventListener();
+ private BlockingQueue<JobRunner> jobsToRun = new LinkedBlockingQueue<JobRunner>();
+ private Map<String, JobRunner> runningJob = new ConcurrentHashMap<String, JobRunner>();
+ private Map<String, JobRunner> allJobs = new ConcurrentHashMap<String, JobRunner>();
+ private List<JobRunner> pausedJobsToRun = Collections.synchronizedList(new ArrayList<JobRunner>());
+
+ private Object actionSyncObj = new Object();
+ private boolean flowPaused = false;
+ private boolean flowFailed = false;
+ private boolean flowFinished = false;
+ private boolean flowCancelled = false;
+
+ public FlowRunner(ExecutableFlow flow, ExecutorLoader executorLoader, JobtypeManager jobtypeManager, HadoopSecurityManager hadoopSecurityManager) throws ExecutorManagerException {
+ this.execId = flow.getExecutionId();
+ this.flow = flow;
+ this.executorLoader = executorLoader;
+ this.executorService = Executors.newFixedThreadPool(numThreads);
+ this.execDir = new File(flow.getExecutionPath());
+ this.jobtypeManager = jobtypeManager;
+ this.hadoopSecurityManager = hadoopSecurityManager;
+ }
+
+ public FlowRunner setGlobalProps(Props globalProps) {
+ this.globalProps = globalProps;
+ return this;
+ }
+
+ public File getExecutionDir() {
+ return execDir;
+ }
+
+ @Override
+ public void run() {
+ try {
+ int projectId = flow.getProjectId();
+ int version = flow.getVersion();
+ String flowId = flow.getFlowId();
+
+ // Create execution dir
+ createLogger(flowId);
+ logger.info("Running execid:" + execId + " flow:" + flowId + " project:" + projectId + " version:" + version);
+
+ // The current thread is used for interrupting blocks
+ currentThread = Thread.currentThread();
+ currentThread.setName("FlowRunner-exec-" + flow.getExecutionId());
+
+ flow.setStartTime(System.currentTimeMillis());
+
+ logger.info("Creating active reference");
+ if (!executorLoader.updateExecutableReference(execId, System.currentTimeMillis())) {
+ throw new ExecutorManagerException("The executor reference doesn't exist. May have been killed prematurely.");
+ }
+ logger.info("Updating initial flow directory.");
+ updateFlow();
+
+ logger.info("Fetching job and shared properties.");
+ loadAllProperties();
+ logger.info("Queuing initial jobs.");
+ queueStartingJobs();
+
+ this.fireEventListeners(Event.create(this, Type.FLOW_STARTED));
+ runFlow();
+ } catch (Throwable t) {
+ if (logger != null) {
+ logger.error("An error has occurred during the running of the flow. Quiting.", t);
+ }
+ flow.setStatus(Status.FAILED);
+ }
+ finally {
+ closeLogger();
+ flow.setEndTime(System.currentTimeMillis());
+ updateFlow();
+ this.fireEventListeners(Event.create(this, Type.FLOW_FINISHED));
+ }
+ }
+
+ private void updateFlow() {
+ updateFlow(System.currentTimeMillis());
+ }
+
+ private synchronized void updateFlow(long time) {
+ try {
+ flow.setUpdateTime(time);
+ executorLoader.updateExecutableFlow(flow);
+ } catch (ExecutorManagerException e) {
+ logger.error("Error updating flow.", e);
+ }
+ }
+
+ private void createLogger(String flowId) {
+ // Create logger
+ String loggerName = execId + "." + flowId;
+ logger = Logger.getLogger(loggerName);
+
+ // Create file appender
+ String logName = "_flow." + loggerName + ".log";
+ logFile = new File(execDir, logName);
+ String absolutePath = logFile.getAbsolutePath();
+
+ flowAppender = null;
+ try {
+ flowAppender = new FileAppender(loggerLayout, absolutePath, false);
+ logger.addAppender(flowAppender);
+ } catch (IOException e) {
+ logger.error("Could not open log file in " + execDir, e);
+ }
+ }
+
+ private void closeLogger() {
+ if (logger != null) {
+ logger.removeAppender(flowAppender);
+ flowAppender.close();
+
+ try {
+ executorLoader.uploadLogFile(execId, "", logFile);
+ } catch (ExecutorManagerException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private void loadAllProperties() throws IOException {
+ // First load all the properties
+ for (FlowProps fprops : flow.getFlowProps()) {
+ String source = fprops.getSource();
+ File propsPath = new File(execDir, source);
+ Props props = new Props(null, propsPath);
+ sharedProps.put(source, props);
+ }
+
+ // Resolve parents
+ for (FlowProps fprops : flow.getFlowProps()) {
+ if (fprops.getInheritedSource() != null) {
+ String source = fprops.getSource();
+ String inherit = fprops.getInheritedSource();
+
+ Props props = sharedProps.get(source);
+ Props inherits = sharedProps.get(inherit);
+
+ props.setParent(inherits);
+ }
+ else {
+ String source = fprops.getSource();
+ Props props = sharedProps.get(source);
+ props.setParent(globalProps);
+ }
+ }
+ }
+
+ /**
+ * Main method that executes the jobs.
+ *
+ * @throws Exception
+ */
+ private void runFlow() throws Exception {
+ logger.info("Starting flows");
+ flow.setStatus(Status.RUNNING);
+ updateFlow();
+ while (!flowFinished) {
+ JobRunner runner = null;
+ try {
+ runner = jobsToRun.poll(5, TimeUnit.MINUTES);
+ } catch (InterruptedException e) {
+ logger.info("FlowRunner thread has been interrupted.");
+ continue;
+ }
+
+ if(runner == null) continue;
+
+ try {
+ synchronized(actionSyncObj) {
+ ExecutableNode node = runner.getNode();
+ if (flowPaused) {
+ logger.info("Job Paused " + node.getJobId());
+ node.setStatus(Status.PAUSED);
+ pausedJobsToRun.add(runner);
+ }
+ else {
+ runningJob.put(node.getJobId(), runner);
+ allJobs.put(node.getJobId(), runner);
+ executorService.submit(runner);
+ logger.info("Job Started " + node.getJobId());
+ }
+ }
+ } catch (RejectedExecutionException e) {
+ logger.error(e);
+ }
+ }
+
+ logger.info("Finishing up flow. Awaiting Termination");
+ executorService.shutdown();
+
+ while (!executorService.isTerminated()) {
+ try {
+ executorService.awaitTermination(1, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ }
+ };
+
+ switch(flow.getStatus()) {
+ case FAILED_FINISHING:
+ logger.info("Setting flow status to Failed.");
+ flow.setStatus(Status.FAILED);
+ case FAILED:
+ case KILLED:
+ break;
+ default:
+ flow.setStatus(Status.SUCCEEDED);
+ }
+ }
+
+ private void queueStartingJobs() {
+ for (String startNode : flow.getStartNodes()) {
+ ExecutableNode node = flow.getExecutableNode(startNode);
+ JobRunner jobRunner = createJobRunner(node, null);
+ jobsToRun.add(jobRunner);
+ }
+ }
+
+ private JobRunner createJobRunner(ExecutableNode node, Props previousOutput) {
+ String source = node.getJobPropsSource();
+ String propsSource = node.getPropsSource();
+
+ // If no properties are set, we just set the global properties.
+ Props parentProps = propsSource == null ? globalProps : sharedProps.get(propsSource);
+
+ // Set up overrides
+ @SuppressWarnings("unchecked")
+ Props flowProps = new Props(null, flow.getFlowParameters());
+
+ if (flowProps.size() > 0) {
+ flowProps.setParent(parentProps);
+ parentProps = flowProps;
+ }
+
+ // We add the previous job output and put into this props.
+ if (previousOutput != null) {
+ Props earliestParent = previousOutput.getEarliestAncestor();
+ earliestParent.setParent(parentProps);
+
+ parentProps = previousOutput;
+ }
+
+ // Load job file.
+ File path = new File(execDir, source);
+ Props prop = null;
+ try {
+ prop = new Props(null, path);
+ prop.setParent(parentProps);
+ } catch (IOException e) {
+ e.printStackTrace();
+ logger.error("Error loading job file " + source + " for job " + node.getJobId());
+ }
+
+ JobRunner jobRunner = new JobRunner(node, prop, path.getParentFile(), executorLoader, jobtypeManager, hadoopSecurityManager);
+ jobRunner.addListener(listener);
+
+ return jobRunner;
+ }
+
+ public void pause(String user) {
+ synchronized(actionSyncObj) {
+ if (flow.getStatus() == Status.RUNNING || flow.getStatus() == Status.PREPARING) {
+ logger.info("Flow paused by " + user);
+ flowPaused = true;
+ flow.setStatus(Status.PAUSED);
+
+ updateFlow();
+ }
+ }
+ }
+
+ public void resume(String user) {
+ synchronized(actionSyncObj) {
+ if (!flowPaused) {
+ logger.info("Cannot resume flow that isn't paused");
+ }
+ else {
+ logger.info("Flow resumed by " + user);
+ flowPaused = false;
+ if (!flowCancelled) {
+ flow.setStatus(Status.RUNNING);
+ }
+
+ for (JobRunner runner: pausedJobsToRun) {
+ ExecutableNode node = runner.getNode();
+ if (flowCancelled) {
+ logger.info("Resumed flow is cancelled. Job killed " + node.getJobId());
+ node.setStatus(Status.KILLED);
+ }
+ else {
+ node.setStatus(Status.QUEUED);
+ }
+
+ jobsToRun.add(runner);
+ }
+ updateFlow();
+ }
+ }
+ }
+
+ public void cancel(String user) {
+ synchronized(actionSyncObj) {
+ flowPaused = false;
+ flowCancelled = true;
+
+ for (JobRunner runner: pausedJobsToRun) {
+ ExecutableNode node = runner.getNode();
+ logger.info("Resumed flow is cancelled. Job killed " + node.getJobId());
+ node.setStatus(Status.KILLED);
+
+ jobsToRun.add(runner);
+ }
+
+ for (JobRunner runner : runningJob.values()) {
+ runner.cancel();
+ }
+
+ if (flow.getStatus() != Status.FAILED && flow.getStatus() != Status.FAILED_FINISHING) {
+ flow.setStatus(Status.KILLED);
+ }
+
+ updateFlow();
+ interrupt();
+ }
+ }
+
+ private void interrupt() {
+ currentThread.interrupt();
+ }
+
+ private Status getImpliedStatus(ExecutableNode node) {
+ switch(node.getStatus()) {
+ case FAILED:
+ case KILLED:
+ case SKIPPED:
+ case SUCCEEDED:
+ case QUEUED:
+ case RUNNING:
+ return null;
+ default:
+ break;
+ }
+
+ boolean shouldKill = false;
+ for (String dependency : node.getInNodes()) {
+ ExecutableNode dependencyNode = flow.getExecutableNode(dependency);
+
+ Status depStatus = dependencyNode.getStatus();
+ switch (depStatus) {
+ case FAILED:
+ case KILLED:
+ shouldKill = true;
+ case SKIPPED:
+ case SUCCEEDED:
+ continue;
+ default:
+ // Return null means it's not ready to run.
+ return null;
+ }
+ }
+
+ if (shouldKill || flowCancelled || (flowFailed && flow.getFailureAction() != FailureAction.FINISH_ALL_POSSIBLE)) {
+ return Status.KILLED;
+ }
+
+ // If it's disabled but ready to run, we want to make sure it continues being disabled.
+ if (node.getStatus() == Status.DISABLED) {
+ return Status.DISABLED;
+ }
+
+ // All good to go, ready to run.
+ return Status.READY;
+ }
+
+ private synchronized void queueNextJobs(ExecutableNode node) {
+ for (String dependent : node.getOutNodes()) {
+ ExecutableNode dependentNode = flow.getExecutableNode(dependent);
+
+ Status nextStatus = getImpliedStatus(dependentNode);
+ if (nextStatus == null) {
+ // Not yet ready or not applicable
+ continue;
+ }
+
+ dependentNode.setStatus(nextStatus);
+
+ Props previousOutput = null;
+ // Iterate the in nodes again and create the dependencies
+ for (String dependency : dependentNode.getInNodes()) {
+ Props output = jobOutputProps.get(dependency);
+ if (output != null) {
+ output = Props.clone(output);
+ output.setParent(previousOutput);
+ previousOutput = output;
+ }
+ }
+
+ JobRunner runner = this.createJobRunner(dependentNode, previousOutput);
+ synchronized(actionSyncObj) {
+ if (flowPaused) {
+ if (dependentNode.getStatus() != Status.DISABLED && dependentNode.getStatus() != Status.KILLED) {
+ dependentNode.setStatus(Status.PAUSED);
+ }
+ pausedJobsToRun.add(runner);
+ logger.info("Job Paused " + dependentNode.getJobId());
+ }
+ else {
+ logger.info("Adding " + dependentNode.getJobId() + " to run queue.");
+ if (dependentNode.getStatus() != Status.DISABLED && dependentNode.getStatus() != Status.KILLED) {
+ dependentNode.setStatus(Status.QUEUED);
+ }
+
+ jobsToRun.add(runner);
+ }
+ }
+ }
+ }
+
+ private class JobRunnerEventListener implements EventListener {
+ public JobRunnerEventListener() {
+ }
+
+ @Override
+ public synchronized void handleEvent(Event event) {
+ JobRunner runner = (JobRunner)event.getRunner();
+ if (event.getType() == Type.JOB_FINISHED) {
+ ExecutableNode node = runner.getNode();
+
+ logger.info("Job Finished " + node.getJobId());
+ synchronized (actionSyncObj) {
+ if (node.getStatus() == Status.FAILED) {
+ // Setting failure
+ flowFailed = true;
+ if (!isFailedStatus(flow.getStatus())) {
+ flow.setStatus(Status.FAILED_FINISHING);
+ if (flow.getFailureAction() == FailureAction.CANCEL_ALL) {
+ cancel("azkaban");
+ }
+ }
+ }
+
+ jobOutputProps.put(node.getJobId(), runner.getOutputProps());
+
+ runningJob.remove(node.getJobId());
+ queueNextJobs(node);
+ }
+
+ runner.cleanup();
+
+ if (isFlowFinished()) {
+ logger.info("Flow appears finished. Cleaning up.");
+ flowFinished = true;
+ interrupt();
+ }
+ }
+
+ if (event.isShouldUpdate()) {
+ ExecutableNode node = runner.getNode();
+ updateFlow(node.getUpdateTime());
+ }
+ }
+ }
+
+ private boolean isFailedStatus(Status status) {
+ switch (status) {
+ case FAILED_FINISHING:
+ case FAILED:
+ case KILLED:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ private boolean isFlowFinished() {
+ for (String end: flow.getEndNodes()) {
+ ExecutableNode node = flow.getExecutableNode(end);
+ switch(node.getStatus()) {
+ case KILLED:
+ case SKIPPED:
+ case FAILED:
+ case SUCCEEDED:
+ continue;
+ default:
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public boolean isCancelled() {
+ return flowCancelled;
+ }
+
+ public ExecutableFlow getExecutableFlow() {
+ return flow;
+ }
+
+ public File getFlowLogFile() {
+ return logFile;
+ }
+
+ public File getJobLogFile(String jobId) {
+ JobRunner runner = allJobs.get(jobId);
+ if (runner == null) {
+ return null;
+ }
+
+ return runner.getLogFile();
+ }
+}
\ No newline at end of file
src/java/azkaban/execapp/FlowRunnerManager.java 446(+446 -0)
diff --git a/src/java/azkaban/execapp/FlowRunnerManager.java b/src/java/azkaban/execapp/FlowRunnerManager.java
new file mode 100644
index 0000000..74e5ce4
--- /dev/null
+++ b/src/java/azkaban/execapp/FlowRunnerManager.java
@@ -0,0 +1,446 @@
+/*
+ * Copyright 2012 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package azkaban.execapp;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.log4j.Logger;
+
+import azkaban.project.ProjectLoader;
+import azkaban.execapp.event.Event;
+import azkaban.execapp.event.EventListener;
+import azkaban.executor.ExecutableFlow;
+import azkaban.executor.ExecutableFlow.Status;
+import azkaban.executor.ExecutorLoader;
+import azkaban.executor.ExecutorManagerException;
+import azkaban.jobtype.JobtypeManager;
+
+import azkaban.security.DefaultHadoopSecurityManager;
+import azkaban.security.HadoopSecurityManager;
+import azkaban.utils.FileIOUtils;
+import azkaban.utils.FileIOUtils.LogData;
+import azkaban.utils.Pair;
+import azkaban.utils.Props;
+
+/**
+ * Execution manager for the server side execution.
+ *
+ */
+public class FlowRunnerManager implements EventListener {
+ private static Logger logger = Logger.getLogger(FlowRunnerManager.class);
+ private File executionDirectory;
+ private File projectDirectory;
+
+ private static final long RECENTLY_FINISHED_TIME_TO_LIVE = 120000; // recently finished secs to clean up. 1 minute
+
+ private static final String HADOOP_SECURITY_MANAGER_CLASS_PARAM = "hadoop.security.manager.class";
+
+ private static final int DEFAULT_NUM_EXECUTING_FLOWS = 30;
+ private Map<Pair<Integer,Integer>, ProjectVersion> installedProjects = new ConcurrentHashMap<Pair<Integer,Integer>, ProjectVersion>();
+ private Map<Integer, FlowRunner> runningFlows = new ConcurrentHashMap<Integer, FlowRunner>();
+ private Map<Integer, ExecutableFlow> recentlyFinishedFlows = new ConcurrentHashMap<Integer, ExecutableFlow>();
+ private LinkedBlockingQueue<FlowRunner> flowQueue = new LinkedBlockingQueue<FlowRunner>();
+ private int numThreads = DEFAULT_NUM_EXECUTING_FLOWS;
+
+ private ExecutorService executorService;
+ private SubmitterThread submitterThread;
+ private CleanerThread cleanerThread;
+
+ private ExecutorLoader executorLoader;
+ private ProjectLoader projectLoader;
+
+ private JobtypeManager jobtypeManager;
+ private HadoopSecurityManager hadoopSecurityManager;
+
+ private Props globalProps;
+
+ public FlowRunnerManager(Props props, ExecutorLoader executorLoader, ProjectLoader projectLoader, ClassLoader parentClassLoader) throws IOException {
+ executionDirectory = new File(props.getString("azkaban.execution.dir", "executions"));
+ projectDirectory = new File(props.getString("azkaban.project.dir", "projects"));
+
+ //JobWrappingFactory.init(props, getClass().getClassLoader());
+
+ if (!executionDirectory.exists()) {
+ executionDirectory.mkdirs();
+ }
+ if (!projectDirectory.exists()) {
+ projectDirectory.mkdirs();
+ }
+
+ //azkaban.temp.dir
+ numThreads = props.getInt("executor.flow.threads", DEFAULT_NUM_EXECUTING_FLOWS);
+ executorService = Executors.newFixedThreadPool(numThreads);
+
+ this.executorLoader = executorLoader;
+ this.projectLoader = projectLoader;
+
+ submitterThread = new SubmitterThread(flowQueue);
+ submitterThread.start();
+
+ cleanerThread = new CleanerThread();
+ cleanerThread.start();
+
+ jobtypeManager = new JobtypeManager(props.getString(AzkabanExecutorServer.JOBTYPE_PLUGIN_DIR, null), parentClassLoader);
+
+ hadoopSecurityManager = loadHadoopSecurityManager(props);
+
+ }
+
+ private HadoopSecurityManager loadHadoopSecurityManager(Props props) {
+
+ Class<?> hadoopSecurityManagerClass = props.getClass(HADOOP_SECURITY_MANAGER_CLASS_PARAM, null);
+ logger.info("Loading hadoop security manager class " + hadoopSecurityManagerClass.getName());
+ HadoopSecurityManager hadoopSecurityManager = null;
+
+ if (hadoopSecurityManagerClass != null && hadoopSecurityManagerClass.getConstructors().length > 0) {
+
+ try {
+ Constructor<?> hsmConstructor = hadoopSecurityManagerClass.getConstructor(Props.class);
+ hadoopSecurityManager = (HadoopSecurityManager) hsmConstructor.newInstance(props);
+ }
+ catch (Exception e) {
+ logger.error("Could not instantiate Hadoop Security Manager "+ hadoopSecurityManagerClass.getName());
+ throw new RuntimeException(e);
+ }
+ }
+ else {
+ hadoopSecurityManager = new DefaultHadoopSecurityManager();
+ }
+
+ return hadoopSecurityManager;
+
+ }
+
+ public Props getGlobalProps() {
+ return globalProps;
+ }
+
+ public void setGlobalProps(Props globalProps) {
+ this.globalProps = globalProps;
+ }
+
+ private class SubmitterThread extends Thread {
+ private BlockingQueue<FlowRunner> queue;
+ private boolean shutdown = false;
+
+ public SubmitterThread(BlockingQueue<FlowRunner> queue) {
+ this.setName("FlowRunnerManager-Submitter-Thread");
+ this.queue = queue;
+ }
+
+ public void shutdown() {
+ shutdown = true;
+ this.interrupt();
+ }
+
+ public void run() {
+ while (!shutdown) {
+ try {
+ FlowRunner flowRunner = queue.take();
+ executorService.submit(flowRunner);
+ } catch (InterruptedException e) {
+ logger.info("Interrupted. Probably to shut down.");
+ }
+ }
+ }
+ }
+
+ private class CleanerThread extends Thread {
+ private boolean shutdown = false;
+
+ public CleanerThread() {
+ this.setName("FlowRunnerManager-Cleaner-Thread");
+ }
+
+ public void shutdown() {
+ shutdown = true;
+ this.interrupt();
+ }
+
+ public void run() {
+ while (!shutdown) {
+ synchronized (this) {
+ try {
+ wait(RECENTLY_FINISHED_TIME_TO_LIVE);
+ // Cleanup old stuff.
+ cleanRecentlyFinished();
+ cleanOlderProjects();
+ } catch (InterruptedException e) {
+ logger.info("Interrupted. Probably to shut down.");
+ }
+ }
+ }
+ }
+
+ private void cleanRecentlyFinished() {
+ long cleanupThreshold = System.currentTimeMillis() - RECENTLY_FINISHED_TIME_TO_LIVE;
+ ArrayList<Integer> executionToKill = new ArrayList<Integer>();
+ for (ExecutableFlow flow : recentlyFinishedFlows.values()) {
+ if (flow.getEndTime() < cleanupThreshold) {
+ executionToKill.add(flow.getExecutionId());
+ }
+ }
+
+ for (Integer id: executionToKill) {
+ recentlyFinishedFlows.remove(id);
+ }
+ }
+
+ private void cleanOlderProjects() {
+ Map<Integer, ArrayList<ProjectVersion>> projectVersions = new HashMap<Integer, ArrayList<ProjectVersion>>();
+ for (ProjectVersion version : installedProjects.values() ) {
+ ArrayList<ProjectVersion> versionList = projectVersions.get(version.getProjectId());
+ if (versionList == null) {
+ versionList = new ArrayList<ProjectVersion>();
+ projectVersions.put(version.getProjectId(), versionList);
+ }
+ versionList.add(version);
+ }
+
+ HashSet<Pair<Integer,Integer>> activeProjectVersions = new HashSet<Pair<Integer,Integer>>();
+ for(FlowRunner runner: runningFlows.values()) {
+ ExecutableFlow flow = runner.getExecutableFlow();
+ activeProjectVersions.add(new Pair<Integer,Integer>(flow.getProjectId(), flow.getVersion()));
+ }
+
+ for (Map.Entry<Integer, ArrayList<ProjectVersion>> entry: projectVersions.entrySet()) {
+ Integer projectId = entry.getKey();
+ ArrayList<ProjectVersion> installedVersions = entry.getValue();
+
+ // Keep one version of the project around.
+ if (installedVersions.size() == 1) {
+ continue;
+ }
+
+ Collections.sort(installedVersions);
+ for (int i = 0; i < installedVersions.size() - 1; ++i) {
+ ProjectVersion version = installedVersions.get(i);
+ Pair<Integer,Integer> versionKey = new Pair<Integer,Integer>(version.getProjectId(), version.getVersion());
+ if (!activeProjectVersions.contains(versionKey)) {
+ try {
+ logger.info("Removing old unused installed project " + version.getProjectId() + ":" + version.getVersion());
+ version.deleteDirectory();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ installedVersions.remove(versionKey);
+ }
+ }
+ }
+ }
+ }
+
+ public void submitFlow(int execId) throws ExecutorManagerException {
+ // Load file and submit
+ if (runningFlows.containsKey(execId)) {
+ throw new ExecutorManagerException("Execution " + execId + " is already running.");
+ }
+
+ ExecutableFlow flow = null;
+ flow = executorLoader.fetchExecutableFlow(execId);
+ if (flow == null) {
+ throw new ExecutorManagerException("Error loading flow with exec " + execId);
+ }
+
+ // Sets up the project files and execution directory.
+ setupFlow(flow);
+
+ // Setup flow runner
+ FlowRunner runner = new FlowRunner(flow, executorLoader, jobtypeManager, hadoopSecurityManager);
+ runner.setGlobalProps(globalProps);
+ runner.addListener(this);
+
+ // Check again.
+ if (runningFlows.containsKey(execId)) {
+ throw new ExecutorManagerException("Execution " + execId + " is already running.");
+ }
+
+ // Finally, queue the sucker.
+ runningFlows.put(execId, runner);
+ flowQueue.add(runner);
+ }
+
+ private void setupFlow(ExecutableFlow flow) throws ExecutorManagerException {
+ int execId = flow.getExecutionId();
+ File execPath = new File(executionDirectory, String.valueOf(execId));
+ flow.setExecutionPath(execPath.getPath());
+ logger.info("Flow " + execId + " submitted with path " + execPath.getPath());
+ execPath.mkdirs();
+
+ // We're setting up the installed projects. First time, it may take a while to set up.
+ Pair<Integer, Integer> projectVersionKey = new Pair<Integer,Integer>(flow.getProjectId(), flow.getVersion());
+
+ // We set up project versions this way
+ ProjectVersion projectVersion = null;
+ synchronized(installedProjects) {
+ projectVersion = installedProjects.get(projectVersionKey);
+ if (projectVersion == null) {
+ projectVersion = new ProjectVersion(flow.getProjectId(), flow.getVersion());
+ installedProjects.put(projectVersionKey, projectVersion);
+ }
+ }
+
+ try {
+ projectVersion.setupProjectFiles(projectLoader, projectDirectory, logger);
+ projectVersion.copyCreateSymlinkDirectory(execPath);
+ } catch (Exception e) {
+ e.printStackTrace();
+ if (execPath.exists()) {
+ try {
+ FileUtils.deleteDirectory(execPath);
+ }
+ catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ }
+ throw new ExecutorManagerException(e);
+ }
+ }
+
+ public void cancelFlow(int execId, String user) throws ExecutorManagerException {
+ FlowRunner runner = runningFlows.get(execId);
+
+ if (runner == null) {
+ throw new ExecutorManagerException("Execution " + execId + " is not running.");
+ }
+
+ runner.cancel(user);
+ }
+
+ public void pauseFlow(int execId, String user) throws ExecutorManagerException {
+ FlowRunner runner = runningFlows.get(execId);
+
+ if (runner == null) {
+ throw new ExecutorManagerException("Execution " + execId + " is not running.");
+ }
+
+ runner.pause(user);
+ }
+
+ public void resumeFlow(int execId, String user) throws ExecutorManagerException {
+ FlowRunner runner = runningFlows.get(execId);
+
+ if (runner == null) {
+ throw new ExecutorManagerException("Execution " + execId + " is not running.");
+ }
+
+ runner.resume(user);
+ }
+
+ public ExecutableFlow getExecutableFlow(int execId) {
+ FlowRunner runner = runningFlows.get(execId);
+ if (runner == null) {
+ return recentlyFinishedFlows.get(execId);
+ }
+ return runner.getExecutableFlow();
+ }
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.getType() == Event.Type.FLOW_FINISHED) {
+ FlowRunner flowRunner = (FlowRunner)event.getRunner();
+ ExecutableFlow flow = flowRunner.getExecutableFlow();
+ recentlyFinishedFlows.put(flow.getExecutionId(), flow);
+
+ File dir = flowRunner.getExecutionDir();
+ if (dir != null && dir.exists()) {
+ try {
+ synchronized(dir) {
+ if(flow.getStatus() == Status.SUCCEEDED)
+ FileUtils.deleteDirectory(dir);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ runningFlows.remove(flow.getExecutionId());
+ }
+ }
+
+ public LogData readFlowLogs(int execId, int startByte, int length) throws ExecutorManagerException {
+ FlowRunner runner = runningFlows.get(execId);
+ if (runner == null) {
+ throw new ExecutorManagerException("Running flow " + execId + " not found.");
+ }
+
+ File dir = runner.getExecutionDir();
+ if (dir != null && dir.exists()) {
+ try {
+ synchronized(dir) {
+ if (!dir.exists()) {
+ throw new ExecutorManagerException("Execution dir file doesn't exist. Probably has beend deleted");
+ }
+
+ File logFile = runner.getFlowLogFile();
+ if (logFile != null && logFile.exists()) {
+ return FileIOUtils.readUtf8File(logFile, startByte, length);
+ }
+ else {
+ throw new ExecutorManagerException("Flow log file doesn't exist.");
+ }
+ }
+ } catch (IOException e) {
+ throw new ExecutorManagerException(e);
+ }
+ }
+
+ throw new ExecutorManagerException("Error reading file. Log directory doesn't exist.");
+ }
+
+ public LogData readJobLogs(int execId, String jobId, int startByte, int length) throws ExecutorManagerException {
+ FlowRunner runner = runningFlows.get(execId);
+ if (runner == null) {
+ throw new ExecutorManagerException("Running flow " + execId + " not found.");
+ }
+
+ File dir = runner.getExecutionDir();
+ if (dir != null && dir.exists()) {
+ try {
+ synchronized(dir) {
+ if (!dir.exists()) {
+ throw new ExecutorManagerException("Execution dir file doesn't exist. Probably has beend deleted");
+ }
+ File logFile = runner.getJobLogFile(jobId);
+ if (logFile != null && logFile.exists()) {
+ return FileIOUtils.readUtf8File(logFile, startByte, length);
+ }
+ else {
+ throw new ExecutorManagerException("Job log file doesn't exist.");
+ }
+ }
+ } catch (IOException e) {
+ throw new ExecutorManagerException(e);
+ }
+ }
+
+ throw new ExecutorManagerException("Error reading file. Log directory doesn't exist.");
+ }
+}
src/java/azkaban/execapp/ProjectVersion.java 93(+93 -0)
diff --git a/src/java/azkaban/execapp/ProjectVersion.java b/src/java/azkaban/execapp/ProjectVersion.java
new file mode 100644
index 0000000..7a9adac
--- /dev/null
+++ b/src/java/azkaban/execapp/ProjectVersion.java
@@ -0,0 +1,93 @@
+package azkaban.execapp;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.zip.ZipFile;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.log4j.Logger;
+
+import azkaban.project.ProjectFileHandler;
+import azkaban.project.ProjectLoader;
+import azkaban.project.ProjectManagerException;
+
+import azkaban.utils.FileIOUtils;
+import azkaban.utils.Utils;
+
+public class ProjectVersion implements Comparable<ProjectVersion> {
+ private final int projectId;
+ private final int version;
+ private File installedDir;
+
+ public ProjectVersion(int projectId, int version) {
+ this.projectId = projectId;
+ this.version = version;
+ }
+
+ public int getProjectId() {
+ return projectId;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+
+ public synchronized void setupProjectFiles(ProjectLoader projectLoader, File projectDir, Logger logger) throws ProjectManagerException, IOException {
+ String projectVersion = String.valueOf(projectId) + "." + String.valueOf(version);
+ if (installedDir == null) {
+ installedDir = new File(projectDir, projectVersion);
+ }
+
+ if (!installedDir.exists()) {
+
+ logger.info("First time executing new project. Setting up in directory " + installedDir.getPath());
+
+ File tempDir = new File(projectDir, "_temp." + projectVersion + "." + System.currentTimeMillis());
+ tempDir.mkdirs();
+ ProjectFileHandler projectFileHandler = null;
+ try {
+ projectFileHandler = projectLoader.getUploadedFile(projectId, version);
+ if ("zip".equals(projectFileHandler.getFileType())) {
+ logger.info("Downloading zip file.");
+ ZipFile zip = new ZipFile(projectFileHandler.getLocalFile());
+ Utils.unzip(zip, tempDir);
+
+ tempDir.renameTo(installedDir);
+ }
+ else {
+ throw new IOException("The file type hasn't been decided yet.");
+ }
+ }
+ finally {
+ if (projectFileHandler != null) {
+ projectFileHandler.deleteLocalFile();
+ }
+ }
+ }
+ }
+
+ public synchronized void copyCreateSymlinkDirectory(File executionDir) throws IOException {
+ if (installedDir == null || !installedDir.exists()) {
+ throw new IOException("Installed dir doesn't exist");
+ }
+ else if (executionDir == null || !executionDir.exists()) {
+ throw new IOException("Execution dir doesn't exist");
+ }
+ FileIOUtils.createDeepSymlink(installedDir, executionDir);
+ }
+
+ public synchronized void deleteDirectory() throws IOException {
+ if (installedDir != null && installedDir.exists()) {
+ FileUtils.deleteDirectory(installedDir);
+ }
+ }
+
+ @Override
+ public int compareTo(ProjectVersion o) {
+ if (projectId == o.projectId) {
+ return version - o.version;
+ }
+
+ return projectId - o.projectId;
+ }
+}
\ No newline at end of file
diff --git a/src/java/azkaban/executor/ConnectorParams.java b/src/java/azkaban/executor/ConnectorParams.java
index 5e35686..8c1360e 100644
--- a/src/java/azkaban/executor/ConnectorParams.java
+++ b/src/java/azkaban/executor/ConnectorParams.java
@@ -22,12 +22,14 @@ public interface ConnectorParams {
public static final String SHAREDTOKEN_PARAM = "token";
public static final String USER_PARAM = "user";
+ public static final String UPDATE_ACTION = "update";
public static final String STATUS_ACTION = "status";
public static final String EXECUTE_ACTION = "execute";
public static final String CANCEL_ACTION = "cancel";
public static final String PAUSE_ACTION = "pause";
public static final String RESUME_ACTION = "resume";
public static final String PING_ACTION = "ping";
+ public static final String LOG_ACTION = "log";
public static final String START_PARAM = "start";
public static final String END_PARAM = "end";
@@ -40,11 +42,23 @@ public interface ConnectorParams {
public static final String RESPONSE_SUCCESS = "success";
public static final String RESPONSE_ALIVE = "alive";
public static final String RESPONSE_UPDATETIME = "lasttime";
+ public static final String RESPONSE_UPDATED_FLOWS = "updated";
public static final int NODE_NAME_INDEX = 0;
public static final int NODE_STATUS_INDEX = 1;
public static final int NODE_START_INDEX = 2;
public static final int NODE_END_INDEX = 3;
+ public static final String UPDATE_TIME_LIST_PARAM = "updatetime";
+ public static final String EXEC_ID_LIST_PARAM = "execid";
+
public static final String FORCED_FAILED_MARKER = ".failed";
+
+ public static final String UPDATE_MAP_EXEC_ID = "execId";
+ public static final String UPDATE_MAP_JOBID = "jobId";
+ public static final String UPDATE_MAP_UPDATE_TIME = "updateTime";
+ public static final String UPDATE_MAP_STATUS = "status";
+ public static final String UPDATE_MAP_START_TIME = "startTime";
+ public static final String UPDATE_MAP_END_TIME = "endTime";
+ public static final String UPDATE_MAP_NODES = "nodes";
}
src/java/azkaban/executor/ExecutableFlow.java 151(+121 -30)
diff --git a/src/java/azkaban/executor/ExecutableFlow.java b/src/java/azkaban/executor/ExecutableFlow.java
index 9a73a61..f008cef 100644
--- a/src/java/azkaban/executor/ExecutableFlow.java
+++ b/src/java/azkaban/executor/ExecutableFlow.java
@@ -29,12 +29,13 @@ import azkaban.flow.Flow;
import azkaban.flow.FlowProps;
import azkaban.flow.Node;
import azkaban.utils.JSONUtils;
-import azkaban.utils.Props;
public class ExecutableFlow {
- private String executionId;
+ private int executionId = -1;
private String flowId;
- private String projectId;
+ private int projectId;
+ private int version;
+
private String executionPath;
private HashMap<String, FlowProps> flowProps = new HashMap<String, FlowProps>();
@@ -44,13 +45,12 @@ public class ExecutableFlow {
private ArrayList<String> failureEmails = new ArrayList<String>();
private ArrayList<String> successEmails = new ArrayList<String>();
-
+
private long submitTime = -1;
private long startTime = -1;
private long endTime = -1;
private long updateTime = -1;
-
- private int updateNumber = 0;
+
private Status flowStatus = Status.READY;
private String submitUser;
private boolean notifyOnFirstFailure = true;
@@ -58,7 +58,7 @@ public class ExecutableFlow {
private Integer pipelineLevel = null;
private Map<String, String> flowParameters = new HashMap<String, String>();
-
+
public enum FailureAction {
FINISH_CURRENTLY_RUNNING,
CANCEL_ALL,
@@ -66,16 +66,55 @@ public class ExecutableFlow {
}
private FailureAction failureAction = FailureAction.FINISH_CURRENTLY_RUNNING;
-
- public enum Status {
- FAILED, FAILED_FINISHING, SUCCEEDED, RUNNING, WAITING, KILLED, DISABLED, READY, UNKNOWN, PAUSED, SKIPPED
+
+ public static enum Status {
+ READY(10), PREPARING(20), RUNNING(30), PAUSED(40), SUCCEEDED(50), KILLED(60), FAILED(70), FAILED_FINISHING(80), SKIPPED(90), DISABLED(100), QUEUED(110);
+
+ private int numVal;
+
+ Status(int numVal) {
+ this.numVal = numVal;
+ }
+
+ public int getNumVal() {
+ return numVal;
+ }
+
+ public static Status fromInteger(int x) {
+ switch (x) {
+ case 10:
+ return READY;
+ case 20:
+ return PREPARING;
+ case 30:
+ return RUNNING;
+ case 40:
+ return PAUSED;
+ case 50:
+ return SUCCEEDED;
+ case 60:
+ return KILLED;
+ case 70:
+ return FAILED;
+ case 80:
+ return FAILED_FINISHING;
+ case 90:
+ return SKIPPED;
+ case 100:
+ return DISABLED;
+ case 110:
+ return QUEUED;
+ default:
+ return READY;
+ }
+ }
}
- public ExecutableFlow(String id, Flow flow) {
- this.executionId = id;
+ public ExecutableFlow(Flow flow) {
this.projectId = flow.getProjectId();
this.flowId = flow.getId();
-
+ this.version = flow.getVersion();
+
this.setFlow(flow);
}
@@ -102,14 +141,6 @@ public class ExecutableFlow {
return flowProps.values();
}
- public int getUpdateNumber() {
- return updateNumber;
- }
-
- public void setUpdateNumber(int number) {
- updateNumber = number;
- }
-
public void addFlowParameters(Map<String, String> param) {
flowParameters.putAll(param);
}
@@ -147,7 +178,7 @@ public class ExecutableFlow {
startNodes = new ArrayList<String>();
for (ExecutableNode node: executableNodes.values()) {
if (node.getInNodes().isEmpty()) {
- startNodes.add(node.getId());
+ startNodes.add(node.getJobId());
}
}
}
@@ -160,7 +191,7 @@ public class ExecutableFlow {
endNodes = new ArrayList<String>();
for (ExecutableNode node: executableNodes.values()) {
if (node.getOutNodes().isEmpty()) {
- endNodes.add(node.getId());
+ endNodes.add(node.getJobId());
}
}
}
@@ -173,11 +204,11 @@ public class ExecutableFlow {
exNode.setStatus(status);
}
- public String getExecutionId() {
+ public int getExecutionId() {
return executionId;
}
- public void setExecutionId(String executionId) {
+ public void setExecutionId(int executionId) {
this.executionId = executionId;
}
@@ -189,11 +220,11 @@ public class ExecutableFlow {
this.flowId = flowId;
}
- public String getProjectId() {
+ public int getProjectId() {
return projectId;
}
- public void setProjectId(String projectId) {
+ public void setProjectId(int projectId) {
this.projectId = projectId;
}
@@ -272,6 +303,7 @@ public class ExecutableFlow {
flowObj.put("failureEmails", failureEmails);
flowObj.put("failureAction", failureAction.toString());
flowObj.put("pipelineLevel", pipelineLevel);
+ flowObj.put("version", version);
ArrayList<Object> props = new ArrayList<Object>();
for (FlowProps fprop: flowProps.values()) {
@@ -304,20 +336,71 @@ public class ExecutableFlow {
return failureAction;
}
+ public Object toUpdateObject(long lastUpdateTime) {
+ Map<String, Object> updateData = new HashMap<String,Object>();
+ updateData.put("execId", this.executionId);
+ updateData.put("status", this.flowStatus.getNumVal());
+ updateData.put("startTime", this.startTime);
+ updateData.put("endTime", this.endTime);
+ updateData.put("updateTime", this.updateTime);
+
+ List<Map<String,Object>> updatedNodes = new ArrayList<Map<String,Object>>();
+ for (ExecutableNode node: executableNodes.values()) {
+
+ if (node.getUpdateTime() > lastUpdateTime) {
+ Map<String, Object> updatedNodeMap = new HashMap<String,Object>();
+ updatedNodeMap.put("jobId", node.getJobId());
+ updatedNodeMap.put("status", node.getStatus().getNumVal());
+ updatedNodeMap.put("startTime", node.getStartTime());
+ updatedNodeMap.put("endTime", node.getEndTime());
+ updatedNodeMap.put("updateTime", node.getUpdateTime());
+
+ updatedNodes.add(updatedNodeMap);
+ }
+ }
+
+ updateData.put("nodes", updatedNodes);
+ return updateData;
+ }
+
+ public void applyUpdateObject(Map<String, Object> updateData) {
+ List<Map<String,Object>> updatedNodes = (List<Map<String,Object>>)updateData.get("nodes");
+ for (Map<String,Object> node: updatedNodes) {
+ String jobId = (String)node.get("jobId");
+ Status status = Status.fromInteger((Integer)node.get("status"));
+ long startTime = JSONUtils.getLongFromObject(node.get("startTime"));
+ long endTime = JSONUtils.getLongFromObject(node.get("endTime"));
+ long updateTime = JSONUtils.getLongFromObject(node.get("updateTime"));
+
+ ExecutableNode exNode = executableNodes.get(jobId);
+ exNode.setEndTime(endTime);
+ exNode.setStartTime(startTime);
+ exNode.setUpdateTime(updateTime);
+ exNode.setStatus(status);
+ }
+
+ this.flowStatus = Status.fromInteger((Integer)updateData.get("status"));
+ this.startTime = JSONUtils.getLongFromObject(updateData.get("startTime"));
+ this.endTime = JSONUtils.getLongFromObject(updateData.get("endTime"));
+ this.updateTime = JSONUtils.getLongFromObject(updateData.get("updateTime"));
+ }
+
@SuppressWarnings("unchecked")
public static ExecutableFlow createExecutableFlowFromObject(Object obj) {
ExecutableFlow exFlow = new ExecutableFlow();
HashMap<String, Object> flowObj = (HashMap<String,Object>)obj;
- exFlow.executionId = (String)flowObj.get("executionId");
+ exFlow.executionId = (Integer)flowObj.get("executionId");
exFlow.executionPath = (String)flowObj.get("executionPath");
exFlow.flowId = (String)flowObj.get("flowId");
- exFlow.projectId = (String)flowObj.get("projectId");
+ exFlow.projectId = (Integer)flowObj.get("projectId");
exFlow.submitTime = JSONUtils.getLongFromObject(flowObj.get("submitTime"));
exFlow.startTime = JSONUtils.getLongFromObject(flowObj.get("startTime"));
exFlow.endTime = JSONUtils.getLongFromObject(flowObj.get("endTime"));
exFlow.flowStatus = Status.valueOf((String)flowObj.get("status"));
exFlow.submitUser = (String)flowObj.get("submitUser");
+ exFlow.version = (Integer)flowObj.get("version");
+
if (flowObj.containsKey("flowParameters")) {
exFlow.flowParameters = new HashMap<String, String>((Map<String,String>)flowObj.get("flowParameters"));
}
@@ -339,7 +422,7 @@ public class ExecutableFlow {
List<Object> nodes = (List<Object>)flowObj.get("nodes");
for (Object nodeObj: nodes) {
ExecutableNode node = ExecutableNode.createNodeFromObject(nodeObj, exFlow);
- exFlow.executableNodes.put(node.getId(), node);
+ exFlow.executableNodes.put(node.getJobId(), node);
}
List<Object> properties = (List<Object>)flowObj.get("properties");
@@ -421,4 +504,12 @@ public class ExecutableFlow {
public boolean getNotifyOnLastFailure() {
return this.notifyOnLastFailure;
}
+
+ public int getVersion() {
+ return version;
+ }
+
+ public void setVersion(int version) {
+ this.version = version;
+ }
}
diff --git a/src/java/azkaban/executor/ExecutableJobInfo.java b/src/java/azkaban/executor/ExecutableJobInfo.java
new file mode 100644
index 0000000..99f271e
--- /dev/null
+++ b/src/java/azkaban/executor/ExecutableJobInfo.java
@@ -0,0 +1,73 @@
+package azkaban.executor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import azkaban.executor.ExecutableFlow.Status;
+
+public class ExecutableJobInfo {
+ private final int execId;
+ private final int projectId;
+ private final int version;
+ private final String flowId;
+ private final String jobId;
+ private final long startTime;
+ private final long endTime;
+ private final Status status;
+
+ public ExecutableJobInfo(int execId, int projectId, int version, String flowId, String jobId, long startTime, long endTime, Status status) {
+ this.execId = execId;
+ this.projectId = projectId;
+ this.startTime = startTime;
+ this.endTime = endTime;
+ this.status = status;
+ this.version = version;
+ this.flowId = flowId;
+ this.jobId = jobId;
+ }
+
+ public int getProjectId() {
+ return projectId;
+ }
+
+ public int getExecId() {
+ return execId;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+
+ public String getFlowId() {
+ return flowId;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public long getStartTime() {
+ return startTime;
+ }
+
+ public long getEndTime() {
+ return endTime;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public Map<String, Object> toObject() {
+ HashMap<String, Object> map = new HashMap<String, Object>();
+ map.put("execId", execId);
+ map.put("version", version);
+ map.put("flowId", flowId);
+ map.put("jobId", jobId);
+ map.put("startTime", startTime);
+ map.put("endTime", endTime);
+ map.put("status", status.toString());
+
+ return map;
+ }
+}
\ No newline at end of file
src/java/azkaban/executor/ExecutableNode.java 48(+37 -11)
diff --git a/src/java/azkaban/executor/ExecutableNode.java b/src/java/azkaban/executor/ExecutableNode.java
index 1000f64..5541bb2 100644
--- a/src/java/azkaban/executor/ExecutableNode.java
+++ b/src/java/azkaban/executor/ExecutableNode.java
@@ -16,6 +16,7 @@
package azkaban.executor;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -26,8 +27,8 @@ import azkaban.flow.Node;
import azkaban.utils.JSONUtils;
public class ExecutableNode {
- private String id;
-
+ private String jobId;
+ private int executionId;
private String type;
private String jobPropsSource;
private String inheritPropsSource;
@@ -35,6 +36,7 @@ public class ExecutableNode {
private Status status = Status.READY;
private long startTime = -1;
private long endTime = -1;
+ private long updateTime = -1;
private int level = 0;
private ExecutableFlow flow;
@@ -42,7 +44,8 @@ public class ExecutableNode {
private Set<String> outNodes = new HashSet<String>();
public ExecutableNode(Node node, ExecutableFlow flow) {
- id = node.getId();
+ jobId = node.getId();
+ executionId = flow.getExecutionId();
type = node.getType();
jobPropsSource = node.getJobSource();
inheritPropsSource = node.getPropsSource();
@@ -54,12 +57,24 @@ public class ExecutableNode {
public ExecutableNode() {
}
- public String getId() {
- return id;
+ public void setExecutableFlow(ExecutableFlow flow) {
+ this.flow = flow;
+ }
+
+ public void setExecutionId(int id) {
+ executionId = id;
+ }
+
+ public int getExecutionId() {
+ return executionId;
+ }
+
+ public String getJobId() {
+ return jobId;
}
- public void setId(String id) {
- this.id = id;
+ public void setJobId(String id) {
+ this.jobId = id;
}
public void addInNode(String exNode) {
@@ -88,15 +103,16 @@ public class ExecutableNode {
public Object toObject() {
HashMap<String, Object> objMap = new HashMap<String, Object>();
- objMap.put("id", id);
+ objMap.put("id", jobId);
objMap.put("jobSource", jobPropsSource);
objMap.put("propSource", inheritPropsSource);
objMap.put("jobType", type);
objMap.put("status", status.toString());
- objMap.put("inNodes", inNodes);
- objMap.put("outNodes", outNodes);
+ objMap.put("inNodes", new ArrayList<String>(inNodes));
+ objMap.put("outNodes", new ArrayList<String>(outNodes));
objMap.put("startTime", startTime);
objMap.put("endTime", endTime);
+ objMap.put("updateTime", updateTime);
objMap.put("level", level);
if (outputPropsSource != null) {
@@ -111,7 +127,8 @@ public class ExecutableNode {
ExecutableNode exNode = new ExecutableNode();
HashMap<String, Object> objMap = (HashMap<String,Object>)obj;
- exNode.id = (String)objMap.get("id");
+ exNode.executionId = flow == null ? 0 : flow.getExecutionId();
+ exNode.jobId = (String)objMap.get("id");
exNode.jobPropsSource = (String)objMap.get("jobSource");
exNode.inheritPropsSource = (String)objMap.get("propSource");
exNode.outputPropsSource = (String)objMap.get("outputSource");
@@ -123,6 +140,7 @@ public class ExecutableNode {
exNode.startTime = JSONUtils.getLongFromObject(objMap.get("startTime"));
exNode.endTime = JSONUtils.getLongFromObject(objMap.get("endTime"));
+ exNode.updateTime = JSONUtils.getLongFromObject(objMap.get("updateTime"));
exNode.level = (Integer)objMap.get("level");
exNode.flow = flow;
@@ -170,4 +188,12 @@ public class ExecutableNode {
public ExecutableFlow getFlow() {
return flow;
}
+
+ public long getUpdateTime() {
+ return updateTime;
+ }
+
+ public void setUpdateTime(long updateTime) {
+ this.updateTime = updateTime;
+ }
}
\ No newline at end of file
diff --git a/src/java/azkaban/executor/ExecutionReference.java b/src/java/azkaban/executor/ExecutionReference.java
new file mode 100644
index 0000000..5b5eeb1
--- /dev/null
+++ b/src/java/azkaban/executor/ExecutionReference.java
@@ -0,0 +1,52 @@
+package azkaban.executor;
+
+public class ExecutionReference {
+ private final int execId;
+ private final String host;
+ private final int port;
+ private long updateTime;
+ private long nextCheckTime = -1;
+ private int numErrors = 0;
+
+ public ExecutionReference(int execId, String host, int port) {
+ this.execId = execId;
+ this.host = host;
+ this.port = port;
+ }
+
+ public void setUpdateTime(long updateTime) {
+ this.updateTime = updateTime;
+ }
+
+ public void setNextCheckTime(long nextCheckTime) {
+ this.nextCheckTime = nextCheckTime;
+ }
+
+ public long getUpdateTime() {
+ return updateTime;
+ }
+
+ public long getNextCheckTime() {
+ return nextCheckTime;
+ }
+
+ public int getExecId() {
+ return execId;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public int getNumErrors() {
+ return numErrors;
+ }
+
+ public void setNumErrors(int numErrors) {
+ this.numErrors = numErrors;
+ }
+}
diff --git a/src/java/azkaban/executor/ExecutorLoader.java b/src/java/azkaban/executor/ExecutorLoader.java
index 02fb5fb..0ce8016 100644
--- a/src/java/azkaban/executor/ExecutorLoader.java
+++ b/src/java/azkaban/executor/ExecutorLoader.java
@@ -16,10 +16,50 @@
package azkaban.executor;
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+import azkaban.utils.FileIOUtils.LogData;
+import azkaban.utils.Pair;
+import azkaban.utils.Props;
+
public interface ExecutorLoader {
- public String getUniqueExecutionId();
+ public void uploadExecutableFlow(ExecutableFlow flow) throws ExecutorManagerException;
+
+ public ExecutableFlow fetchExecutableFlow(int execId) throws ExecutorManagerException;
+
+ public Map<Integer,Pair<ExecutionReference, ExecutableFlow>> fetchActiveFlows() throws ExecutorManagerException;
+
+ public List<ExecutableFlow> fetchFlowHistory(int skip, int num) throws ExecutorManagerException;
+
+ public List<ExecutableFlow> fetchFlowHistory(int projectId, String flowId, int skip, int num) throws ExecutorManagerException;
+
+ public List<ExecutableFlow> fetchFlowHistory(String projContain, String flowContains, String userNameContains, int status, long startData, long endData, int skip, int num) throws ExecutorManagerException;
+
+ public void addActiveExecutableReference(ExecutionReference ref) throws ExecutorManagerException;
+
+ public void removeActiveExecutableReference(int execId) throws ExecutorManagerException;
+
+ public boolean updateExecutableReference(int execId, long updateTime) throws ExecutorManagerException;
+
+ public LogData fetchLogs(int execId, String name, int startByte, int endByte) throws ExecutorManagerException;
+
+ public void uploadLogFile(int execId, String name, File ... files) throws ExecutorManagerException;
+
+ public void updateExecutableFlow(ExecutableFlow flow) throws ExecutorManagerException;
+
+ public void uploadExecutableNode(ExecutableNode node, Props inputParams) throws ExecutorManagerException;
+
+ public ExecutableJobInfo fetchJobInfo(int execId, String jobId) throws ExecutorManagerException;
+
+ public List<ExecutableJobInfo> fetchJobHistory(int projectId, String jobId, int skip, int size) throws ExecutorManagerException;
- public void commitExecutableFlow(ExecutableFlow exflow);
+ public void updateExecutableNode(ExecutableNode node, Props outputParams) throws ExecutorManagerException;
+
+ public int fetchNumExecutableFlows(int projectId, String flowId) throws ExecutorManagerException;
+
+ public int fetchNumExecutableFlows() throws ExecutorManagerException;
- public ExecutableFlow loadExecutableFlow(String executionId);
+ public int fetchNumExecutableNodes(int projectId, String jobId) throws ExecutorManagerException;
}
src/java/azkaban/executor/ExecutorMailer.java 182(+182 -0)
diff --git a/src/java/azkaban/executor/ExecutorMailer.java b/src/java/azkaban/executor/ExecutorMailer.java
new file mode 100644
index 0000000..560df54
--- /dev/null
+++ b/src/java/azkaban/executor/ExecutorMailer.java
@@ -0,0 +1,182 @@
+package azkaban.executor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.mail.MessagingException;
+
+import org.apache.log4j.Logger;
+
+import azkaban.executor.ExecutableFlow.FailureAction;
+import azkaban.executor.ExecutableFlow.Status;
+import azkaban.utils.EmailMessage;
+import azkaban.utils.Props;
+import azkaban.utils.Utils;
+
+public class ExecutorMailer {
+ private static Logger logger = Logger.getLogger(ExecutorMailer.class);
+
+ private boolean testMode = false;
+ private String clientHostname;
+ private String clientPortNumber;
+
+ private String mailHost;
+ private String mailUser;
+ private String mailPassword;
+ private String mailSender;
+ private String azkabanName;
+
+ public ExecutorMailer(Props props) {
+ this.azkabanName = props.getString("azkaban.name", "azkaban");
+ this.mailHost = props.getString("mail.host", "localhost");
+ this.mailUser = props.getString("mail.user", "");
+ this.mailPassword = props.getString("mail.password", "");
+ this.mailSender = props.getString("mail.sender", "");
+
+ this.clientHostname = props.getString("jetty.hostname", "localhost");
+ this.clientPortNumber = Utils.nonNull(props.getString("jetty.ssl.port"));
+
+ testMode = props.getBoolean("test.mode", false);
+ }
+
+ public void sendFirstErrorMessage(ExecutableFlow flow) {
+ List<String> emailList = flow.getFailureEmails();
+ int execId = flow.getExecutionId();
+
+ if (emailList != null && !emailList.isEmpty()) {
+ EmailMessage message = new EmailMessage(mailHost, mailUser, mailPassword);
+ message.setFromAddress(mailSender);
+ message.addAllToAddress(emailList);
+ message.setMimeType("text/html");
+ message.setSubject("Flow '" + flow.getFlowId() + "' has failed on " + azkabanName);
+
+ message.println("<h2 style=\"color:#FF0000\"> Execution '" + flow.getExecutionId() + "' of flow '" + flow.getFlowId() + "' has encountered a failure on " + azkabanName + "</h2>");
+
+ if (flow.getFailureAction() == FailureAction.CANCEL_ALL) {
+ message.println("This flow is set to cancel all currently running jobs.");
+ }
+ else if (flow.getFailureAction() == FailureAction.FINISH_ALL_POSSIBLE){
+ message.println("This flow is set to complete all jobs that aren't blocked by the failure.");
+ }
+ else {
+ message.println("This flow is set to complete all currently running jobs before stopping.");
+ }
+
+ message.println("<table>");
+ message.println("<tr><td>Start Time</td><td>" + flow.getStartTime() +"</td></tr>");
+ message.println("<tr><td>End Time</td><td>" + flow.getEndTime() +"</td></tr>");
+ message.println("<tr><td>Duration</td><td>" + Utils.formatDuration(flow.getStartTime(), flow.getEndTime()) +"</td></tr>");
+ message.println("</table>");
+ message.println("");
+ String executionUrl = "https://" + clientHostname + ":" + clientPortNumber + "/" + "executor?" + "execid=" + execId;
+ message.println("<a href='\"" + executionUrl + "\">" + flow.getFlowId() + " Execution Link</a>");
+
+ message.println("");
+ message.println("<h3>Reason</h3>");
+ List<String> failedJobs = findFailedJobs(flow);
+ message.println("<ul>");
+ for (String jobId : failedJobs) {
+ message.println("<li><a href=\"" + executionUrl + "&job=" + jobId + "\">Failed job '" + jobId + "' Link</a></li>" );
+ }
+
+ message.println("</ul>");
+
+ if (!testMode) {
+ try {
+ message.sendEmail();
+ } catch (MessagingException e) {
+ logger.error("Email message send failed" , e);
+ }
+ }
+ }
+ }
+
+ public void sendErrorEmail(ExecutableFlow flow, String ... extraReasons) {
+ List<String> emailList = flow.getFailureEmails();
+ int execId = flow.getExecutionId();
+
+ if (emailList != null && !emailList.isEmpty()) {
+ EmailMessage message = new EmailMessage(mailHost, mailUser, mailPassword);
+ message.setFromAddress(mailSender);
+ message.addAllToAddress(emailList);
+ message.setMimeType("text/html");
+ message.setSubject("Flow '" + flow.getFlowId() + "' has failed on " + azkabanName);
+
+ message.println("<h2 style=\"color:#FF0000\"> Execution '" + flow.getExecutionId() + "' of flow '" + flow.getFlowId() + "' has failed on " + azkabanName + "</h2>");
+ message.println("<table>");
+ message.println("<tr><td>Start Time</td><td>" + flow.getStartTime() +"</td></tr>");
+ message.println("<tr><td>End Time</td><td>" + flow.getEndTime() +"</td></tr>");
+ message.println("<tr><td>Duration</td><td>" + Utils.formatDuration(flow.getStartTime(), flow.getEndTime()) +"</td></tr>");
+ message.println("</table>");
+ message.println("");
+ String executionUrl = "https://" + clientHostname + ":" + clientPortNumber + "/" + "executor?" + "execid=" + execId;
+ message.println("<a href='\"" + executionUrl + "\">" + flow.getFlowId() + " Execution Link</a>");
+
+ message.println("");
+ message.println("<h3>Reason</h3>");
+ List<String> failedJobs = findFailedJobs(flow);
+ message.println("<ul>");
+ for (String jobId : failedJobs) {
+ message.println("<li><a href=\"" + executionUrl + "&job=" + jobId + "\">Failed job '" + jobId + "' Link</a></li>" );
+ }
+ for (String reasons: extraReasons) {
+ message.println("<li>" + extraReasons + "</li>");
+ }
+
+ message.println("</ul>");
+
+
+
+ if (!testMode) {
+ try {
+ message.sendEmail();
+ } catch (MessagingException e) {
+ logger.error("Email message send failed" , e);
+ }
+ }
+ }
+ }
+
+ public void sendSuccessEmail(ExecutableFlow flow) {
+ List<String> emailList = flow.getSuccessEmails();
+
+ int execId = flow.getExecutionId();
+
+ if (emailList != null && !emailList.isEmpty()) {
+ EmailMessage message = new EmailMessage(mailHost, mailUser, mailPassword);
+ message.setFromAddress(mailSender);
+ message.addAllToAddress(emailList);
+ message.setMimeType("text/html");
+ message.setSubject("Flow '" + flow.getFlowId() + "' has succeeded on " + azkabanName);
+
+ message.println("<h2> Execution '" + flow.getExecutionId() + "' of flow '" + flow.getFlowId() + "' has succeeded on " + azkabanName + "</h2>");
+ message.println("<table>");
+ message.println("<tr><td>Start Time</td><td>" + flow.getStartTime() +"</td></tr>");
+ message.println("<tr><td>End Time</td><td>" + flow.getEndTime() +"</td></tr>");
+ message.println("<tr><td>Duration</td><td>" + Utils.formatDuration(flow.getStartTime(), flow.getEndTime()) +"</td></tr>");
+ message.println("</table>");
+ message.println("");
+ String executionUrl = "https://" + clientHostname + ":" + clientPortNumber + "/" + "executor?" + "execid=" + execId;
+ message.println("<a href=\"" + executionUrl + "\">" + flow.getFlowId() + " Execution Link</a>");
+
+ if (!testMode) {
+ try {
+ message.sendEmail();
+ } catch (MessagingException e) {
+ logger.error("Email message send failed" , e);
+ }
+ }
+ }
+ }
+
+ private List<String> findFailedJobs(ExecutableFlow flow) {
+ ArrayList<String> failedJobs = new ArrayList<String>();
+ for (ExecutableNode node: flow.getExecutableNodes()) {
+ if (node.getStatus() == Status.FAILED) {
+ failedJobs.add(node.getJobId());
+ }
+ }
+
+ return failedJobs;
+ }
+}
\ No newline at end of file
src/java/azkaban/executor/ExecutorManager.java 1629(+440 -1189)
diff --git a/src/java/azkaban/executor/ExecutorManager.java b/src/java/azkaban/executor/ExecutorManager.java
index 0fc866a..e0a9604 100644
--- a/src/java/azkaban/executor/ExecutorManager.java
+++ b/src/java/azkaban/executor/ExecutorManager.java
@@ -16,39 +16,16 @@
package azkaban.executor;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Element;
-import net.sf.ehcache.config.CacheConfiguration;
-import net.sf.ehcache.store.MemoryStoreEvictionPolicy;
-
-import org.apache.commons.io.FileUtils;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
@@ -56,683 +33,242 @@ import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.log4j.Logger;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.joda.time.format.DateTimeFormat;
import azkaban.executor.ExecutableFlow.Status;
-import azkaban.executor.ExecutorManager.ExecutionReference;
-import azkaban.flow.Flow;
-import azkaban.utils.ExecutableFlowLoader;
+import azkaban.project.Project;
+import azkaban.utils.FileIOUtils.LogData;
import azkaban.utils.JSONUtils;
+import azkaban.utils.Pair;
import azkaban.utils.Props;
-import azkaban.webapp.AzkabanExecutorServer;
/**
* Executor manager used to manage the client side job.
*
*/
public class ExecutorManager {
- private static final String ACTIVE_DIR = ".active";
- private static final String ARCHIVE_DIR = ".archive";
- private static final String JOB_EXECUTION_DIR = ".jobexecutions";
-
private static Logger logger = Logger.getLogger(ExecutorManager.class);
- // 30 seconds of retry before failure.
- private static final long ACCESS_ERROR_THRESHOLD_MS = 30000;
-
- // log read buffer.
- private static final int LOG_BUFFER_READ_SIZE = 10*1024;
-
- private File basePath;
-
- private AtomicInteger counter = new AtomicInteger();
- private String token;
- private int portNumber;
- private String url = "localhost";
-
- private ConcurrentHashMap<String, ExecutableFlow> runningFlows = new ConcurrentHashMap<String, ExecutableFlow>();
- private ConcurrentHashMap<String, ExecutionReference> runningReference = new ConcurrentHashMap<String, ExecutionReference>();
+ private ExecutorLoader executorLoader;
+ private String executorHost;
+ private int executorPort;
- private CacheManager manager = CacheManager.create();
- private Cache recentFlowsCache;
- private static final int LIVE_SECONDS = 600;
- private Object BlockObj = new Object();
+ private ConcurrentHashMap<Integer, Pair<ExecutionReference, ExecutableFlow>> runningFlows = new ConcurrentHashMap<Integer, Pair<ExecutionReference, ExecutableFlow>>();
+ private ConcurrentHashMap<Integer, ExecutableFlow> recentlyFinished = new ConcurrentHashMap<Integer, ExecutableFlow>();
- ExecutingManagerUpdaterThread executingManager;
+ private ExecutorMailer mailer;
+ private ExecutingManagerUpdaterThread executingManager;
- public ExecutorManager(Props props) throws IOException, ExecutorManagerException {
- basePath = new File(props.getString("execution.directory"));
- if (!basePath.exists()) {
- logger.info("Execution directory " + basePath + " not found.");
- if (basePath.mkdirs()) {
- logger.info("Execution directory " + basePath + " created.");
- }
- else {
- throw new RuntimeException("Execution directory " + basePath + " does not exist and cannot be created.");
- }
- }
- setupCache();
-
- File activePath = new File(basePath, ACTIVE_DIR);
- if(!activePath.exists() && !activePath.mkdirs()) {
- throw new RuntimeException("Execution directory " + activePath + " does not exist and cannot be created.");
- }
-
- File archivePath = new File(basePath, ARCHIVE_DIR);
- if(!archivePath.exists() && !archivePath.mkdirs()) {
- throw new RuntimeException("Execution directory " + archivePath + " does not exist and cannot be created.");
- }
-
- portNumber = props.getInt("executor.port", AzkabanExecutorServer.DEFAULT_PORT_NUMBER);
- token = props.getString("executor.shared.token", "");
- counter.set(0);
- loadActiveExecutions();
+ public ExecutorManager(Props props, ExecutorLoader loader) throws ExecutorManagerException {
+ this.executorLoader = loader;
+ this.loadRunningFlows();
+ executorHost = props.getString("executor.host", "localhost");
+ executorPort = props.getInt("executor.port");
+ mailer = new ExecutorMailer(props);
executingManager = new ExecutingManagerUpdaterThread();
executingManager.start();
}
- private void setupCache() {
- CacheConfiguration cacheConfig = new CacheConfiguration("recentFlowsCache",2000)
- .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.FIFO)
- .overflowToDisk(false)
- .eternal(false)
- .timeToLiveSeconds(LIVE_SECONDS)
- .diskPersistent(false)
- .diskExpiryThreadIntervalSeconds(0);
-
- recentFlowsCache = new Cache(cacheConfig);
- manager.addCache(recentFlowsCache);
+ private void loadRunningFlows() throws ExecutorManagerException {
+ runningFlows.putAll(executorLoader.fetchActiveFlows());
}
- public int getJobHistory(String projectId, String jobId, int numResults, int skip, List<NodeStatus> nodes) throws ExecutorManagerException{
- File flowProjectPath = new File(basePath, projectId);
- if (!flowProjectPath.exists()) {
- throw new ExecutorManagerException("Project " + projectId + " directory doesn't exist.");
- }
-
- File jobStatusDir = new File(flowProjectPath, JOB_EXECUTION_DIR + File.separator + jobId);
-
- File[] jobsStatusFiles = jobStatusDir.listFiles();
-
- if (jobsStatusFiles.length == 0 || skip >= jobsStatusFiles.length) {
- return 0;
+ public boolean isFlowRunning(int projectId, String flowId) {
+ for (Pair<ExecutionReference, ExecutableFlow> ref : runningFlows.values()) {
+ if (ref.getSecond().getFlowId().equals(flowId)) {
+ return true;
+ }
}
- Arrays.sort(jobsStatusFiles);
- int index = (jobsStatusFiles.length - skip - 1);
+ return false;
+ }
+
+ public ExecutableFlow getExecutableFlow(int execId) throws ExecutorManagerException {
+ Pair<ExecutionReference, ExecutableFlow> active = runningFlows.get(execId);
- for (int count = 0; count < numResults && index >= 0; ++count, --index) {
- File exDir = jobsStatusFiles[index];
-
- NodeStatus status;
- try {
- status = NodeStatus.createNodeFromObject(JSONUtils.parseJSONFromFile(exDir));
- if (status != null) {
- nodes.add(status);
- }
- } catch (IOException e) {
- throw new ExecutorManagerException(e.getMessage());
- }
+ if (active == null) {
+ return executorLoader.fetchExecutableFlow(execId);
}
- return jobsStatusFiles.length;
+ return active.getSecond();
}
- public int getExecutableFlows(String projectId, String flowId, int from, int maxResults, List<ExecutableFlow> output) {
- String projectPath = projectId + File.separator + flowId;
- File flowProjectPath = new File(basePath, projectPath);
-
- if (!flowProjectPath.exists()) {
- return 0;
- }
-
- File[] executionFiles = flowProjectPath.listFiles();
- if (executionFiles.length == 0 || from >= executionFiles.length) {
- return 0;
- }
-
- // Sorts the file in ascending order, so we read the list backwards.
- Arrays.sort(executionFiles);
- int index = (executionFiles.length - from - 1);
-
- for (int count = 0; count < maxResults && index >= 0; ++count, --index) {
- File exDir = executionFiles[index];
- try {
- ExecutableFlow flow = ExecutableFlowLoader.loadExecutableFlowFromDir(exDir);
- output.add(flow);
- }
- catch (ExecutorManagerException e) {
- logger.error("Skipping loading " + exDir + ". Couldn't load execution.", e);
- }
+ public List<ExecutableFlow> getRunningFlows() {
+ ArrayList<ExecutableFlow> flows = new ArrayList<ExecutableFlow>();
+ for (Pair<ExecutionReference, ExecutableFlow> ref : runningFlows.values()) {
+ flows.add(ref.getSecond());
}
-
- return executionFiles.length;
+ return flows;
}
public List<ExecutableFlow> getRecentlyFinishedFlows() {
- ArrayList<ExecutableFlow> flows = new ArrayList<ExecutableFlow>();
- for(Element elem : recentFlowsCache.getAll(recentFlowsCache.getKeys()).values()) {
- if (elem != null) {
- Object obj = elem.getObjectValue();
- flows.add((ExecutableFlow)obj);
- }
- }
-
+ return new ArrayList<ExecutableFlow>(recentlyFinished.values());
+ }
+
+ public List<ExecutableFlow> getExecutableFlows(Project project, String flowId, int skip, int size) throws ExecutorManagerException {
+ List<ExecutableFlow> flows = executorLoader.fetchFlowHistory(project.getId(), flowId, skip, size);
return flows;
}
- public List<ExecutableFlow> getFlowRunningFlows(String projectId, String flowId) {
- ArrayList<ExecutableFlow> list = new ArrayList<ExecutableFlow>();
- for (ExecutableFlow flow: getRunningFlows()) {
- if (flow.getProjectId().equals(projectId) && flow.getFlowId().equals(flowId)) {
- list.add(flow);
- }
- }
-
- return list;
+ public List<ExecutableFlow> getExecutableFlows(int skip, int size) throws ExecutorManagerException {
+ List<ExecutableFlow> flows = executorLoader.fetchFlowHistory(skip, size);
+ return flows;
}
- public List<ExecutableFlow> getRunningFlows() {
- ArrayList<ExecutableFlow> execFlows = new ArrayList<ExecutableFlow>(runningFlows.values());
- return execFlows;
+ public List<ExecutableFlow> getExecutableFlows(String flowIdContains, int skip, int size) throws ExecutorManagerException {
+ List<ExecutableFlow> flows = executorLoader.fetchFlowHistory(null, '%'+flowIdContains+'%', null, 0, -1, -1 , skip, size);
+ return flows;
}
- public List<ExecutionReference> getFlowHistory(long startTime, long endTime) {
- ArrayList<ExecutionReference> references = new ArrayList<ExecutionReference>();
-
- for (ExecutionReference ref: runningReference.values()) {
- if (between(ref, startTime, endTime)) {
- references.add(ref);
- }
- }
-
- File archivePath = new File(basePath, ARCHIVE_DIR);
- if (!archivePath.exists()) {
- return references;
- }
-
-
- // This makes an assumption that there's no job that will run a day past the endTime
- // nor a day before the endTime. We use 100000, because that's what the archive
- // partitions by.
- final long startThreshold = startTime - 100000;
- final long endThreshold = endTime + 100000;
-
- File[] archivePartitionsDir = archivePath.listFiles( new FileFilter() {
- @Override
- public boolean accept(File pathname) {
- String name = pathname.getName();
- long val = Long.valueOf(name);
- return val >= startThreshold && val <= endThreshold;
- }
- }
- );
-
- for (File partition: archivePartitionsDir) {
- File[] refFiles = partition.listFiles();
- for (File refFile: refFiles) {
- try {
- ExecutionReference reference = ExecutionReference.readFromFile(refFile);
- if (between(reference, startTime, endTime)) {
- references.add(reference);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- return references;
+ public List<ExecutableFlow> getExecutableFlows(String projContain, String flowContain, String userContain, int status, long begin, long end, int skip, int size) throws ExecutorManagerException {
+ List<ExecutableFlow> flows = executorLoader.fetchFlowHistory(projContain, flowContain, userContain, status, begin, end , skip, size);
+ return flows;
}
- private boolean between(ExecutionReference ref, long startTime, long endTime) {
- long time = System.currentTimeMillis();
- long refStart = ref.getStartTime() == -1 ? time : ref.getStartTime();
- long refEnd = ref.getEndTime() == -1 ? time : ref.getEndTime();
-
- return endTime > refStart && startTime <= refEnd;
+ public List<ExecutableJobInfo> getExecutableJobs(Project project, String jobId, int skip, int size) throws ExecutorManagerException {
+ List<ExecutableJobInfo> nodes = executorLoader.fetchJobHistory(project.getId(), jobId, skip, size);
+ return nodes;
}
- public List<ExecutionReference> getFlowHistory(String projRe, String flowRe, String userRe, long startTime, long endTime, int numResults, int skip, Boolean dofilter) {
- ArrayList<ExecutionReference> searchFlows = new ArrayList<ExecutionReference>();
-
- Pattern projPattern = null;
- Pattern flowPattern = null;
- Pattern userPattern = null;
-
- if(dofilter == true) {
- try {
- projPattern = Pattern.compile(projRe, Pattern.CASE_INSENSITIVE);
- flowPattern = Pattern.compile(flowRe, Pattern.CASE_INSENSITIVE);
- userPattern = Pattern.compile(userRe, Pattern.CASE_INSENSITIVE);
- } catch (PatternSyntaxException e) {
- logger.error("Bad regex pattern " + projRe + " " + flowRe + " " + userRe);
- return searchFlows;
- }
- }
-
- for (ExecutionReference ref: runningReference.values()) {
- if (skip > 0) {
- skip--;
- }
- else {
- if(dofilter == true) {
- if(flowPattern.matcher(ref.getFlowId()).find() && projPattern.matcher(ref.getProjectId()).find() && userPattern.matcher(ref.getUserId()).find()
- && between(ref, startTime, endTime) ) {
- searchFlows.add(ref);
- }
- }
- else
- searchFlows.add(ref);
- if (searchFlows.size() == numResults) {
- Collections.sort(searchFlows);
- return searchFlows;
- }
- }
- }
-
- File archivePath = new File(basePath, ARCHIVE_DIR);
- if (!archivePath.exists()) {
- return searchFlows;
- }
-
- File[] archivePartitionsDir;
- if(dofilter == true) {
- final long startThreshold = startTime - 100000;
- final long endThreshold = endTime + 100000;
-
- archivePartitionsDir = archivePath.listFiles( new FileFilter() {
- @Override
- public boolean accept(File pathname) {
- String name = pathname.getName();
- long val = Long.valueOf(name);
- return val >= startThreshold && val <= endThreshold;
- }
- }
- );
- }
- else {
- archivePartitionsDir = archivePath.listFiles();
- }
-
- Arrays.sort(archivePartitionsDir, new Comparator<File>() {
- @Override
- public int compare(File arg0, File arg1) {
- return arg1.getName().compareTo(arg0.getName());
- }});
-
- for (File archivePartition: archivePartitionsDir) {
- File[] listArchivePartitions = archivePartition.listFiles();
- if (skip > listArchivePartitions.length) {
- skip -= listArchivePartitions.length;
- continue;
- }
-
- Arrays.sort(listArchivePartitions);
- for (int i = listArchivePartitions.length - 1; i >= 0; --i) {
- if (skip > 0) {
- skip--;
- }
- else {
- try {
- ExecutionReference ref = ExecutionReference.readFromFile(listArchivePartitions[i]);
- if (ref == null) {
- continue;
- }
-
- if(dofilter == true) {
- if(flowPattern.matcher(ref.getFlowId()).find() && projPattern.matcher(ref.getProjectId()).find() && userPattern.matcher(ref.getUserId()).find()
- && between(ref, startTime, endTime)) {
- searchFlows.add(ref);
- }
- }
- else {
- searchFlows.add(ref);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- if (searchFlows.size() == numResults) {
- Collections.sort(searchFlows);
- return searchFlows;
- }
- }
- }
- }
-
- Collections.sort(searchFlows);
- return searchFlows;
+ public int getNumberOfJobExecutions(Project project, String jobId) throws ExecutorManagerException{
+ return executorLoader.fetchNumExecutableNodes(project.getId(), jobId);
}
- private void loadActiveExecutions() throws IOException, ExecutorManagerException {
- File activeFlows = new File(basePath, ACTIVE_DIR);
- File[] activeFlowDirs = activeFlows.listFiles();
- if (activeFlowDirs == null) {
- return;
- }
-
- for (File activeFlowFile: activeFlowDirs) {
- if (activeFlowFile.isFile()) {
- ExecutionReference reference = ExecutionReference.readFromFile(activeFlowFile);
- if (reference.getExecutorUrl() == null) {
- reference.setExecutorPort(portNumber);
- reference.setExecutorUrl(url);
- }
-
- ExecutableFlow flow = this.getFlowFromReference(reference);
- if (flow == null) {
- logger.error("Flow " + reference.getExecId() + " not found.");
- }
- reference.setLastCheckedTime(System.currentTimeMillis());
-
- if (flow != null) {
- runningReference.put(reference.getExecId(), reference);
- runningFlows.put(flow.getExecutionId(), flow);
- }
- }
- else {
- logger.info("Path " + activeFlowFile + " not a directory.");
- }
- }
+ public int getNumberOfExecutions(Project project, String flowId) throws ExecutorManagerException{
+ return executorLoader.fetchNumExecutableFlows(project.getId(), flowId);
}
- public synchronized ExecutableFlow createExecutableFlow(Flow flow) {
- String projectId = flow.getProjectId();
- String flowId = flow.getId();
-
- String flowExecutionDir = projectId + File.separator + flowId;
- File projectExecutionDir = new File(basePath, flowExecutionDir);
-
- // Find execution
- File executionDir;
- String executionId;
-
- int count = 0;
-
- do {
- String countString = String.format("%05d", count);
- executionId = String.valueOf(System.currentTimeMillis()) + "." + countString + "." + projectId + "." + flowId;
- executionDir = new File(projectExecutionDir, executionId);
- count++;
+ public LogData getExecutableFlowLog(ExecutableFlow exFlow, int offset, int length) throws ExecutorManagerException {
+ Pair<ExecutionReference, ExecutableFlow> pair = runningFlows.get(exFlow.getExecutionId());
+ if (pair != null) {
+ Pair<String,String> typeParam = new Pair<String,String>("type", "flow");
+ Pair<String,String> offsetParam = new Pair<String,String>("offset", String.valueOf(offset));
+ Pair<String,String> lengthParam = new Pair<String,String>("length", String.valueOf(length));
+
+ @SuppressWarnings("unchecked")
+ Map<String, Object> result = callExecutorServer(pair.getFirst(), ConnectorParams.LOG_ACTION, typeParam, offsetParam, lengthParam);
+ return LogData.createLogDataFromObject(result);
+ }
+ else {
+ LogData value = executorLoader.fetchLogs(exFlow.getExecutionId(), "", offset, length);
+ return value;
}
- while(executionDir.exists());
-
- ExecutableFlow exFlow = new ExecutableFlow(executionId, flow);
- return exFlow;
}
- public synchronized void setupExecutableFlow(ExecutableFlow exflow) throws ExecutorManagerException {
- String executionId = exflow.getExecutionId();
+ public LogData getExecutionJobLog(ExecutableFlow exFlow, String jobId, int offset, int length) throws ExecutorManagerException {
+ Pair<ExecutionReference, ExecutableFlow> pair = runningFlows.get(exFlow.getExecutionId());
+ if (pair != null) {
- File projectDir = new File(basePath, exflow.getProjectId());
- String executionDir = exflow.getFlowId() + File.separator + executionId;
- File executionPath = new File(projectDir, executionDir);
- if (executionPath.exists()) {
- throw new ExecutorManagerException("Execution path " + executionPath + " exists. Probably a simultaneous execution.");
- }
-
- executionPath.mkdirs();
-
- // create job reference dir
- File jobExecutionDir = new File(projectDir, JOB_EXECUTION_DIR);
- jobExecutionDir.mkdirs();
-
- exflow.setExecutionPath(executionPath.getPath());
- }
+ Pair<String,String> typeParam = new Pair<String,String>("type", "job");
+ Pair<String,String> jobIdParam = new Pair<String,String>("jobId", jobId);
+ Pair<String,String> offsetParam = new Pair<String,String>("offset", String.valueOf(offset));
+ Pair<String,String> lengthParam = new Pair<String,String>("length", String.valueOf(length));
- public synchronized ExecutableFlow getExecutableFlow(String executionId) throws ExecutorManagerException {
- ExecutableFlow flow = runningFlows.get(executionId);
- if (flow != null) {
- return flow;
- }
-
- String[] split = executionId.split("\\.");
- // get project file from split.
- String projectId = split[2];
- File projectPath = new File(basePath, projectId);
- if (projectPath.exists()) {
- // Execution path sometimes looks like timestamp.count.projectId.flowId. Except flowId could have ..
- String flowId = executionId.substring(split[0].length() + split[1].length() + projectId.length() + 3);
- File flowPath = new File(projectPath, flowId);
- if (flowPath.exists()) {
- File executionPath = new File(flowPath, executionId);
- if (executionPath.exists()) {
- return ExecutableFlowLoader.loadExecutableFlowFromDir(executionPath);
- }
- }
- }
-
- // Check active
- File baseActiveDir = new File(basePath, ACTIVE_DIR);
- File referenceFile = new File(baseActiveDir, executionId + ".json");
-
- if (!referenceFile.exists()) {
- // Find the partition it would be in and search.
- String partition = getExecutableReferencePartition(executionId);
-
- File baseArchiveDir = new File(basePath, ARCHIVE_DIR + File.separator + partition);
- referenceFile = new File(baseArchiveDir, executionId + ".json");
- if (!referenceFile.exists()) {
- throw new ExecutorManagerException("Execution id '" + executionId + "' not found. Searching " + referenceFile);
- }
+ @SuppressWarnings("unchecked")
+ Map<String, Object> result = callExecutorServer(pair.getFirst(), ConnectorParams.LOG_ACTION, typeParam, jobIdParam, offsetParam, lengthParam);
+ return LogData.createLogDataFromObject(result);
}
-
- ExecutionReference reference = null;
- try {
- reference = ExecutionReference.readFromFile(referenceFile);
- } catch (IOException e) {
- throw new ExecutorManagerException(e.getMessage(), e);
+ else {
+ LogData value = executorLoader.fetchLogs(exFlow.getExecutionId(), jobId, offset, length);
+ return value;
}
-
-
- return getFlowFromReference(reference);
}
- private ExecutableFlow getFlowFromReference(ExecutionReference reference) throws ExecutorManagerException {
- File executionPath = new File(reference.getExecPath());
- if (executionPath.exists()) {
- return ExecutableFlowLoader.loadExecutableFlowFromDir(executionPath);
+ public void cancelFlow(ExecutableFlow exFlow, String userId) throws ExecutorManagerException {
+ synchronized(exFlow) {
+ Pair<ExecutionReference, ExecutableFlow> pair = runningFlows.get(exFlow.getExecutionId());
+ if (pair == null) {
+ throw new ExecutorManagerException("Execution " + exFlow.getExecutionId() + " of flow " + exFlow.getFlowId() + " isn't running.");
+ }
+ callExecutorServer(pair.getFirst(), ConnectorParams.CANCEL_ACTION, userId);
}
- return null;
}
- private synchronized ExecutionReference addActiveExecutionReference(ExecutableFlow flow) throws ExecutorManagerException {
- File activeDirectory = new File(basePath, ACTIVE_DIR);
- if (!activeDirectory.exists()) {
- activeDirectory.mkdirs();
- }
-
- // Create execution reference directory
- File referenceFile = new File(activeDirectory, flow.getExecutionId() + ".json");
-
- // We don't really need to save the reference,
- ExecutionReference reference = new ExecutionReference(flow);
- reference.setExecutorUrl(url);
- reference.setExecutorPort(portNumber);
- try {
- reference.writeToFile(referenceFile);
- } catch (IOException e) {
- throw new ExecutorManagerException("Couldn't write execution to directory.", e);
+ public void resumeFlow(ExecutableFlow exFlow, String userId) throws ExecutorManagerException {
+ synchronized(exFlow) {
+ Pair<ExecutionReference, ExecutableFlow> pair = runningFlows.get(exFlow.getExecutionId());
+ if (pair == null) {
+ throw new ExecutorManagerException("Execution " + exFlow.getExecutionId() + " of flow " + exFlow.getFlowId() + " isn't running.");
+ }
+ callExecutorServer(pair.getFirst(), ConnectorParams.RESUME_ACTION, userId);
}
-
- return reference;
}
- private void forceFlowFailure(ExecutableFlow exFlow) throws ExecutorManagerException {
- String logFileName = "_flow." + exFlow.getExecutionId() + ".log";
- File executionDir = new File(exFlow.getExecutionPath());
-
- // Add a marker to the directory as an indicator to zombie processes that this is off limits.
- File forcedFailed = new File(executionDir, ConnectorParams.FORCED_FAILED_MARKER);
- if (!forcedFailed.exists()) {
- try {
- forcedFailed.createNewFile();
- } catch (IOException e) {
- logger.error("Error creating failed marker in execution directory",e);
+ public void pauseFlow(ExecutableFlow exFlow, String userId) throws ExecutorManagerException {
+ synchronized(exFlow) {
+ Pair<ExecutionReference, ExecutableFlow> pair = runningFlows.get(exFlow.getExecutionId());
+ if (pair == null) {
+ throw new ExecutorManagerException("Execution " + exFlow.getExecutionId() + " of flow " + exFlow.getFlowId() + " isn't running.");
}
+ callExecutorServer(pair.getFirst(), ConnectorParams.PAUSE_ACTION, userId);
}
-
- // Load last update
- updateFlowFromFile(exFlow);
-
- // Return if already finished.
- if (exFlow.getStatus() == Status.FAILED ||
- exFlow.getStatus() == Status.SUCCEEDED ||
- exFlow.getStatus() == Status.KILLED) {
- return;
- }
+ }
+
+ public void submitExecutableFlow(ExecutableFlow exflow) throws ExecutorManagerException {
+ synchronized(exflow) {
+ logger.info("Submitting execution flow " + exflow.getFlowId());
- // Finish log file
- File logFile = new File(executionDir, logFileName);
- if (logFile.exists()) {
- // Finally add to log
- FileWriter writer = null;
+ // The exflow id is set by the loader. So it's unavailable until after this call.
+ executorLoader.uploadExecutableFlow(exflow);
+
+ // We create an active flow reference in the datastore. If the upload fails, we remove the reference.
+ ExecutionReference reference = new ExecutionReference(exflow.getExecutionId(), executorHost, executorPort);
+ executorLoader.addActiveExecutableReference(reference);
try {
- writer = new FileWriter(logFile, true);
- writer.append("\n" + System.currentTimeMillis() + " ERROR: Can't reach executor. Killing Flow!!!!");
- } catch (IOException e) {
- if (writer != null) {
- try {
- writer.close();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- }
+ callExecutorServer(reference, ConnectorParams.EXECUTE_ACTION);
+ runningFlows.put(exflow.getExecutionId(), new Pair<ExecutionReference, ExecutableFlow>(reference, exflow));
}
- }
-
- // We mark every untouched job with KILLED, and running jobs with FAILED.
- long time = System.currentTimeMillis();
- for (ExecutableNode node: exFlow.getExecutableNodes()) {
- switch(node.getStatus()) {
- case SUCCEEDED:
- case FAILED:
- case KILLED:
- case SKIPPED:
- case DISABLED:
- continue;
- case UNKNOWN:
- case READY:
- node.setStatus(Status.KILLED);
- break;
- default:
- node.setStatus(Status.FAILED);
- break;
- }
-
- if (node.getStartTime() == -1) {
- node.setStartTime(time);
- }
- if (node.getEndTime() == -1) {
- node.setEndTime(time);
+ catch (ExecutorManagerException e) {
+ executorLoader.removeActiveExecutableReference(reference.getExecId());
+ throw e;
}
}
-
- if (exFlow.getEndTime() == -1) {
- exFlow.setEndTime(time);
- }
-
- exFlow.setStatus(Status.FAILED);
}
- @SuppressWarnings("unchecked")
- public void cancelFlow(String execId, String user) throws ExecutorManagerException {
- logger.info("Calling cancel");
- ExecutionReference reference = runningReference.get(execId);
- if (reference == null) {
- throw new ExecutorManagerException("Execution " + execId + " not running.");
- }
-
- Map<String, Object> respObj = null;
+ private Map<String, Object> callExecutorServer(ExecutionReference ref, String action) throws ExecutorManagerException {
try {
- String response = callExecutorServer(reference, ConnectorParams.CANCEL_ACTION);
- respObj = (Map<String, Object>)JSONUtils.parseJSONFromString(response);
+ return callExecutorServer(ref.getHost(), ref.getPort(), action, ref.getExecId(), null, (Pair<String,String>[])null);
} catch (IOException e) {
- e.printStackTrace();
- throw new ExecutorManagerException("Error cancelling flow.", e);
- }
-
- if (respObj.containsKey(ConnectorParams.RESPONSE_ERROR)) {
- throw new ExecutorManagerException((String)respObj.get(ConnectorParams.RESPONSE_ERROR));
+ throw new ExecutorManagerException(e);
}
}
-
- @SuppressWarnings("unchecked")
- public void pauseFlow(String execId, String user) throws ExecutorManagerException {
- logger.info("Calling pause");
- ExecutionReference reference = runningReference.get(execId);
- if (reference == null) {
- throw new ExecutorManagerException("Execution " + execId + " not running.");
- }
-
- Map<String, Object> respObj = null;
+
+ private Map<String, Object> callExecutorServer(ExecutionReference ref, String action, String user) throws ExecutorManagerException {
try {
- String response = callExecutorServer(reference, ConnectorParams.PAUSE_ACTION);
- respObj = (Map<String, Object>)JSONUtils.parseJSONFromString(response);
+ return callExecutorServer(ref.getHost(), ref.getPort(), action, ref.getExecId(), user, (Pair<String,String>[])null);
} catch (IOException e) {
- e.printStackTrace();
- throw new ExecutorManagerException("Error pausing flow.", e);
- }
-
- if (respObj.containsKey(ConnectorParams.RESPONSE_ERROR)) {
- throw new ExecutorManagerException((String)respObj.get(ConnectorParams.RESPONSE_ERROR));
+ throw new ExecutorManagerException(e);
}
}
-
- @SuppressWarnings("unchecked")
- public void resumeFlow(String execId, String user) throws ExecutorManagerException {
- logger.info("Calling resume");
- ExecutionReference reference = runningReference.get(execId);
- if (reference == null) {
- throw new ExecutorManagerException("Execution " + execId + " not running.");
- }
-
- Map<String, Object> respObj = null;
+
+ private Map<String, Object> callExecutorServer(ExecutionReference ref, String action, Pair<String,String> ... params) throws ExecutorManagerException {
try {
- String response = callExecutorServer(reference, ConnectorParams.RESUME_ACTION);
- respObj = (Map<String, Object>)JSONUtils.parseJSONFromString(response);
+ return callExecutorServer(ref.getHost(), ref.getPort(), action, ref.getExecId(), null, params);
} catch (IOException e) {
- e.printStackTrace();
- throw new ExecutorManagerException("Error resuming flow.", e);
- }
-
- if (respObj.containsKey(ConnectorParams.RESPONSE_ERROR)) {
- throw new ExecutorManagerException((String)respObj.get(ConnectorParams.RESPONSE_ERROR));
+ throw new ExecutorManagerException(e);
}
}
- private synchronized String callExecutorServer(ExecutionReference reference, String action) throws IOException {
- return callExecutorServer(
- reference.getExecutorUrl(),
- reference.getExecutorPort(),
- action,
- reference.getExecId(),
- reference.getExecPath(),
- reference.userId);
- }
-
- private synchronized String callExecutorServer(String url, int port, String action, String execid, String execPath, String user) throws IOException {
+ private Map<String, Object> callExecutorServer(String host, int port, String action, Integer executionId, String user, Pair<String,String> ... params) throws IOException {
URIBuilder builder = new URIBuilder();
builder.setScheme("http")
- .setHost(url)
+ .setHost(host)
.setPort(port)
- .setPath("/executor")
- .setParameter(ConnectorParams.SHAREDTOKEN_PARAM, token)
- .setParameter(ConnectorParams.ACTION_PARAM, action);
+ .setPath("/executor");
- if (execid != null) {
- builder.setParameter(ConnectorParams.EXECID_PARAM, execid);
+ builder.setParameter(ConnectorParams.ACTION_PARAM, action);
+
+ if (executionId != null) {
+ builder.setParameter(ConnectorParams.EXECID_PARAM,String.valueOf(executionId));
}
if (user != null) {
builder.setParameter(ConnectorParams.USER_PARAM, user);
}
- if (execPath != null) {
- builder.setParameter(ConnectorParams.EXECPATH_PARAM, execPath);
+ if (params != null) {
+ for (Pair<String, String> pair: params) {
+ builder.setParameter(pair.getFirst(), pair.getSecond());
+ }
}
URI uri = null;
@@ -750,669 +286,384 @@ public class ExecutorManager {
try {
response = httpclient.execute(httpget, responseHandler);
} catch (IOException e) {
- e.printStackTrace();
- return response;
+ throw e;
}
finally {
httpclient.getConnectionManager().shutdown();
}
- return response;
- }
-
- public void executeFlow(ExecutableFlow flow) throws ExecutorManagerException {
- String executionPath = flow.getExecutionPath();
- File executionDir = new File(executionPath);
- flow.setSubmitTime(System.currentTimeMillis());
-
- writeResourceFile(executionDir, flow);
- ExecutableFlowLoader.writeExecutableFlowFile(executionDir, flow, null);
- ExecutionReference reference = addActiveExecutionReference(flow);
-
- logger.info("Setting up " + flow.getExecutionId() + " for execution.");
-
- String response;
- try {
- response = callExecutorServer(reference, ConnectorParams.EXECUTE_ACTION);
- reference.setSubmitted(true);
- runningReference.put(flow.getExecutionId(), reference);
- runningFlows.put(flow.getExecutionId(), flow);
- } catch (IOException e) {
- e.printStackTrace();
- // Clean up.
- forceFlowFailure(flow);
- cleanFinishedJob(flow);
- return;
+ @SuppressWarnings("unchecked")
+ Map<String, Object> jsonResponse = (Map<String, Object>)JSONUtils.parseJSONFromString(response);
+ String error = (String)jsonResponse.get(ConnectorParams.RESPONSE_ERROR);
+ if (error != null) {
+ throw new IOException(error);
}
- logger.debug("Submitted Response: " + response);
-
- reference.setStartTime(System.currentTimeMillis());
- synchronized(BlockObj) {
- BlockObj.notify();
- }
+ return jsonResponse;
}
- private long readLog(File logFile, Writer writer, long startChar, long maxSize) {
- if (!logFile.exists()) {
- logger.error("Execution log for " + logFile + " doesn't exist.");
- return -1;
+ private class ExecutingManagerUpdaterThread extends Thread {
+ private boolean shutdown = false;
+
+ public ExecutingManagerUpdaterThread() {
+ this.setName("ExecutorManagerUpdaterThread");
}
- BufferedReader reader = null;
- FileReader fileReader = null;
- char[] charBuffer = new char[LOG_BUFFER_READ_SIZE];
+ // 10 mins recently finished threshold.
+ private long recentlyFinishedLifetimeMs = 600000;
+ private int waitTimeIdleMs = 2000;
+ private int waitTimeMs = 500;
- try {
- fileReader = new FileReader(logFile);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
-
- long charPosition = startChar;
- int charRead = 0;
- long totalCharRead = 0;
- try {
- reader = new BufferedReader(fileReader);
- reader.skip(startChar);
-
- do {
- charRead = reader.read(charBuffer);
- if (charRead == -1) {
- break;
- }
- totalCharRead += charRead;
- charPosition += charRead;
- writer.write(charBuffer, 0, charRead);
- } while (charRead == charBuffer.length && totalCharRead < maxSize);
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- finally {
- if (reader != null) {
+ // When we have an http error, for that flow, we'll check every 10 secs, 6 times (1 mins) before we evict.
+ private int numErrors = 6;
+ private long errorThreshold = 10000;
+
+ @SuppressWarnings("unchecked")
+ public void run() {
+ while(!shutdown) {
try {
- reader.close();
- } catch (IOException e) {
- e.printStackTrace();
+ Map<ConnectionInfo, List<ExecutableFlow>> exFlowMap = getFlowToExecutorMap();
+ ArrayList<ExecutableFlow> finishedFlows = new ArrayList<ExecutableFlow>();
+ ArrayList<ExecutableFlow> finalizeFlows = new ArrayList<ExecutableFlow>();
+
+ if (exFlowMap.size() > 0) {
+ for (Map.Entry<ConnectionInfo, List<ExecutableFlow>> entry: exFlowMap.entrySet()) {
+ List<Long> updateTimesList = new ArrayList<Long>();
+ List<Integer> executionIdsList = new ArrayList<Integer>();
+
+ // We pack the parameters of the same host together before we query.
+ fillUpdateTimeAndExecId(entry.getValue(), executionIdsList, updateTimesList);
+
+ Pair<String,String> updateTimes = new Pair<String, String>(
+ ConnectorParams.UPDATE_TIME_LIST_PARAM,
+ JSONUtils.toJSON(updateTimesList));
+ Pair<String,String> executionIds = new Pair<String, String>(
+ ConnectorParams.EXEC_ID_LIST_PARAM,
+ JSONUtils.toJSON(executionIdsList));
+
+ ConnectionInfo connection = entry.getKey();
+ Map<String, Object> results = null;
+ try {
+ results = callExecutorServer(connection.getHost(), connection.getPort(), ConnectorParams.UPDATE_ACTION, null, null, executionIds, updateTimes);
+ } catch (IOException e) {
+ logger.error(e);
+ for (ExecutableFlow flow: entry.getValue()) {
+ Pair<ExecutionReference, ExecutableFlow> pair = runningFlows.get(flow.getExecutionId());
+ if (pair != null) {
+ ExecutionReference ref = pair.getFirst();
+ int numErrors = ref.getNumErrors();
+ if (ref.getNumErrors() < numErrors) {
+ ref.setNextCheckTime(System.currentTimeMillis() + errorThreshold);
+ ref.setNumErrors(++numErrors);
+ }
+ else {
+ logger.error("Evicting flow " + flow.getExecutionId() + ". The executor is unresponsive.");
+ //TODO should send out an unresponsive email here.
+ finalizeFlows.add(pair.getSecond());
+ }
+ }
+ }
+ }
+
+ // We gets results
+ if (results != null) {
+ List<Map<String,Object>> executionUpdates = (List<Map<String,Object>>)results.get(ConnectorParams.RESPONSE_UPDATED_FLOWS);
+ for (Map<String,Object> updateMap: executionUpdates) {
+ try {
+ ExecutableFlow flow = updateExecution(updateMap);
+ if (isFinished(flow)) {
+ finishedFlows.add(flow);
+ finalizeFlows.add(flow);
+ }
+ } catch (ExecutorManagerException e) {
+ ExecutableFlow flow = e.getExecutableFlow();
+ logger.error(e);
+
+ if (flow != null) {
+ logger.error("Finalizing flow " + flow.getExecutionId());
+ finalizeFlows.add(flow);
+ }
+ }
+ }
+ }
+ }
+
+ evictOldRecentlyFinished(recentlyFinishedLifetimeMs);
+ // Add new finished
+ for (ExecutableFlow flow: finishedFlows) {
+ recentlyFinished.put(flow.getExecutionId(), flow);
+ }
+
+ // Kill error flows
+ for (ExecutableFlow flow: finalizeFlows) {
+ finalizeFlows(flow);
+ }
+ }
+
+ synchronized(this) {
+ try {
+ if (runningFlows.size() > 0) {
+ this.wait(waitTimeMs);
+ }
+ else {
+ this.wait(waitTimeIdleMs);
+ }
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ catch (Exception e) {
+ logger.error(e);
}
}
}
-
- return charPosition;
}
- public long getExecutionJobLog(ExecutableFlow flow, String jobid, Writer writer, long startChar, long maxSize) throws ExecutorManagerException {
- String path = flow.getExecutionPath();
- File execPath = new File(path);
- if (!execPath.exists()) {
- logger.error("Execution dir for " + flow + " doesn't exist.");
- return -1;
- }
+ private void finalizeFlows(ExecutableFlow flow) {
+ int execId = flow.getExecutionId();
- String logFileName = "_job." + flow.getExecutionId() + "." + jobid + ".log";
- File logFile = new File(execPath, logFileName);
-
- if (!logFile.exists()) {
- logger.error("Execution log for " + logFile + " doesn't exist.");
- return -1;
- }
+ // First we check if the execution in the datastore is complete
+ try {
+ ExecutableFlow dsFlow;
+ if(isFinished(flow)) {
+ dsFlow = flow;
+ }
+ else {
+ dsFlow = executorLoader.fetchExecutableFlow(execId);
+
+ // If it's marked finished, we're good. If not, we fail everything and then mark it finished.
+ if (!isFinished(dsFlow)) {
+ failEverything(dsFlow);
+ executorLoader.updateExecutableFlow(dsFlow);
+ }
+ }
- long charPosition = readLog(logFile, writer, startChar, maxSize);
- return charPosition;
- }
-
- public long getExecutableFlowLog(ExecutableFlow flow, Writer writer, long startChar, long maxSize) throws ExecutorManagerException {
- String path = flow.getExecutionPath();
- File execPath = new File(path);
- if (!execPath.exists()) {
- logger.error("Execution dir for " + flow + " doesn't exist.");
- return -1;
+ // Delete the executing reference.
+ executorLoader.removeActiveExecutableReference(execId);
+
+ runningFlows.remove(execId);
+ recentlyFinished.put(execId, dsFlow);
+ } catch (ExecutorManagerException e) {
+ logger.error(e);
}
- String logFileName = "_flow." + flow.getExecutionId() + ".log";
- File flowLogFile = new File(execPath, logFileName);
+ // TODO append to the flow log that we forced killed this flow because the target no longer had
+ // the reference.
- if (!flowLogFile.exists()) {
- logger.error("Execution log for " + flowLogFile + " doesn't exist.");
- return -1;
- }
-
- long charPosition = readLog(flowLogFile, writer, startChar, maxSize);
- return charPosition;
- }
-
- public void cleanupAll(ExecutableFlow exflow) throws ExecutorManagerException{
- String path = exflow.getExecutionPath();
- File executionPath = new File(path);
- if (executionPath.exists()) {
- try {
- logger.info("Deleting resource path " + executionPath);
- FileUtils.deleteDirectory(executionPath);
- } catch (IOException e) {
- throw new ExecutorManagerException(e.getMessage(), e);
+ // But we can definitely email them.
+ if(flow.getStatus() == Status.FAILED || flow.getStatus() == Status.KILLED)
+ {
+ if(flow.getFailureEmails() != null && !flow.getFailureEmails().isEmpty())
+ {
+ try {
+ mailer.sendErrorEmail(flow, "Executor no longer seems to be running this execution. Most likely due to executor bounce.");
+ } catch (Exception e) {
+ logger.error(e);
+ }
}
}
- }
-
- private File writeResourceFile(File executionDir, ExecutableFlow flow) throws ExecutorManagerException {
- // Create a source list.
- Set<String> sourceFiles = flow.getSources();
-
- // Write out the resource files
- File resourceFile = new File(executionDir, "_" + flow.getExecutionId() + ".resources");
- if (resourceFile.exists()) {
- throw new ExecutorManagerException("The resource file " + resourceFile + " already exists. Race condition?");
- }
- HashMap<String, Object> resources = createResourcesList(executionDir, executionDir, sourceFiles);
- BufferedOutputStream out = null;
- try {
- logger.info("Writing resource file " + resourceFile);
- out = new BufferedOutputStream(new FileOutputStream(resourceFile));
- JSONUtils.toJSON(resources, out, true);
- }
- catch (IOException e) {
- throw new ExecutorManagerException(e.getMessage(), e);
- }
- finally {
- if (out != null) {
+ else
+ {
+ if(flow.getSuccessEmails() != null && !flow.getSuccessEmails().isEmpty())
+ {
try {
- out.close();
- } catch (IOException e) {
- e.printStackTrace();
+ mailer.sendSuccessEmail(flow);
+ } catch (Exception e) {
+ logger.error(e);
}
}
}
- return resourceFile;
}
- private HashMap<String, Object> createResourcesList(File baseDir, File dir, Set<String> sourceFiles) {
- boolean containsSource = false;
-
- HashMap<String, Object> directoryMap = new HashMap<String, Object>();
- String relative = dir.getPath().substring(baseDir.getPath().length(), dir.getPath().length());
- directoryMap.put("name", dir.getName());
- directoryMap.put("relative.path", relative);
- directoryMap.put("type", "directory");
-
- ArrayList<Object> children = new ArrayList<Object>();
- for (File file: dir.listFiles()) {
- if (file.isDirectory()) {
- HashMap<String, Object> subDir = createResourcesList(baseDir, file, sourceFiles);
- containsSource |= (Boolean)subDir.get("used.source");
- children.add(subDir);
+ private void failEverything(ExecutableFlow exFlow) {
+ long time = System.currentTimeMillis();
+ for (ExecutableNode node: exFlow.getExecutableNodes()) {
+ switch(node.getStatus()) {
+ case SUCCEEDED:
+ case FAILED:
+ case KILLED:
+ case SKIPPED:
+ case DISABLED:
+ continue;
+ //case UNKNOWN:
+ case READY:
+ node.setStatus(Status.KILLED);
+ break;
+ default:
+ node.setStatus(Status.FAILED);
+ break;
}
- else {
- HashMap<String, Object> subFile = new HashMap<String, Object>();
- String subFileName = file.getName();
- String subFilePath = file.getPath().substring(baseDir.getPath().length() + 1, file.getPath().length());
- boolean source = sourceFiles.contains(subFilePath);
- containsSource |= source;
-
- subFile.put("name", subFileName);
- subFile.put("relative.path", subFilePath);
- subFile.put("type", "file");
- subFile.put("used.source", source);
- subFile.put("size", file.length());
- subFile.put("modified.date", file.lastModified());
- children.add(subFile);
+
+ if (node.getStartTime() == -1) {
+ node.setStartTime(time);
}
+ if (node.getEndTime() == -1) {
+ node.setEndTime(time);
+ }
+ }
+
+ if (exFlow.getEndTime() == -1) {
+ exFlow.setEndTime(time);
}
- directoryMap.put("children", children);
- directoryMap.put("used.source", containsSource);
- return directoryMap;
+ exFlow.setStatus(Status.FAILED);
}
- @SuppressWarnings("unchecked")
- private void getDeletableResourceList(HashMap<String, Object> sourceTree, Set<String> deletableResourcePaths) {
- boolean usedSource = (Boolean)sourceTree.get("used.source");
-
- if (!usedSource) {
- String relativePath = (String)sourceTree.get("relative.path");
- deletableResourcePaths.add(relativePath);
- }
- else {
- List<Object> children = (List<Object>)sourceTree.get("children");
- if (children != null) {
- for (Object obj: children) {
- HashMap<String, Object> child = (HashMap<String,Object>)obj;
- getDeletableResourceList(child, deletableResourcePaths);
- }
+ private void evictOldRecentlyFinished(long ageMs) {
+ ArrayList<Integer> recentlyFinishedKeys = new ArrayList<Integer>(recentlyFinished.keySet());
+ long oldAgeThreshold = System.currentTimeMillis() - ageMs;
+ for (Integer key: recentlyFinishedKeys) {
+ ExecutableFlow flow = recentlyFinished.get(key);
+
+ if (flow.getEndTime() < oldAgeThreshold) {
+ // Evict
+ recentlyFinished.remove(key);
}
}
}
- @SuppressWarnings("unchecked")
- public void cleanupUnusedFiles(ExecutableFlow exflow) throws ExecutorManagerException {
- String path = exflow.getExecutionPath();
- File executionPath = new File(path);
-
- String flowFilename = "_" + exflow.getExecutionId() + ".flow";
- String resourceFilename = "_" + exflow.getExecutionId() + ".resources";
-
- File resourceFile = new File(executionPath, resourceFilename);
- if (!resourceFile.exists()) {
- throw new ExecutorManagerException("Cleaning failed. Resource file " + flowFilename + " doesn't exist.");
+ private ExecutableFlow updateExecution(Map<String,Object> updateData) throws ExecutorManagerException {
+ Integer execId = (Integer)updateData.get(ConnectorParams.UPDATE_MAP_EXEC_ID);
+ if (execId == null) {
+ throw new ExecutorManagerException("Response is malformed. Need exec id to update.");
}
- HashSet<String> deletableResources = new HashSet<String>();
- try {
- HashMap<String, Object> resourceObj = (HashMap<String, Object>)JSONUtils.parseJSONFromFile(resourceFile);
- getDeletableResourceList(resourceObj, deletableResources);
- } catch (IOException e) {
- throw new ExecutorManagerException("Cleaning failed. Resource file " + flowFilename + " parse error.", e);
+ Pair<ExecutionReference, ExecutableFlow> refPair = this.runningFlows.get(execId);
+ if (refPair == null) {
+ throw new ExecutorManagerException("No running flow found with the execution id.");
}
- logger.info("Deleting resources for " + exflow.getFlowId());
- for (String deletable: deletableResources) {
- File deleteFile = new File(executionPath, deletable);
- if (deleteFile.exists()) {
- if (deleteFile.isDirectory()) {
- try {
- FileUtils.deleteDirectory(deleteFile);
- } catch (IOException e) {
- logger.error("Failed deleting '" + deleteFile + "'", e);
- }
- }
- else {
- if(!deleteFile.delete()) {
- logger.error("Deleting of resource file '" + deleteFile + "' failed.");
- }
- }
- }
- else {
- logger.error("Failed deleting '" + deleteFile + "'. File doesn't exist.");
- }
- }
- }
-
- // This along with getExecutableArchivePartitionNumber must be kept consistant.
- private String getExecutableReferencePartition(String execID) {
- // We're partitioning the archive by the first part of the id, which should be a timestamp.
- // Then we're taking a substring of length - 6 to lop off the bottom 5 digits effectively truncating
- // by 1000000
- int index = execID.indexOf('.');
- return execID.substring(0, index - 8) + "00000000";
- }
-
- private void cleanExecutionReferenceJob(ExecutionReference reference) throws ExecutorManagerException {
- // Write final file
- String exId = reference.getExecId();
- String activeReferenceFile = ACTIVE_DIR + File.separator + exId + ".json";
- File activeFile = new File(basePath, activeReferenceFile);
- if (!activeFile.exists()) {
- logger.error("WTF!! Active reference " + activeFile + " file doesn't exist.");
- throw new ExecutorManagerException("Active reference " + activeFile + " doesn't exists.");
+ ExecutionReference ref = refPair.getFirst();
+ ExecutableFlow flow = refPair.getSecond();
+ if (updateData.containsKey("error")) {
+ // The flow should be finished here.
+ throw new ExecutorManagerException((String)updateData.get("error"), flow);
}
- String partitionVal = getExecutableReferencePartition(exId);
+ // Reset errors.
+ ref.setNextCheckTime(0);
+ ref.setNumErrors(0);
+ Status oldStatus = flow.getStatus();
- String archiveDatePartition = ARCHIVE_DIR + File.separator + partitionVal;
- File archivePartitionDir = new File(basePath, archiveDatePartition);
- if (!archivePartitionDir.exists()) {
- archivePartitionDir.mkdirs();
- }
-
- String archiveJSONFile = exId + ".json";
- File archiveFile = new File(archivePartitionDir, archiveJSONFile);
- if (!archiveFile.exists()) {
- logger.error("Archive reference doesn't exist. We're writing it.");
- try {
- reference.writeToFile(archiveFile);
- } catch (IOException e) {
- throw new ExecutorManagerException("Couldn't write execution to directory.", e);
- }
- }
-
- try {
- reference.writeToFile(archiveFile);
- } catch (IOException e) {
- throw new ExecutorManagerException("Couldn't write execution to file " + archiveFile, e);
- }
+ flow.applyUpdateObject(updateData);
+ Status newStatus = flow.getStatus();
- activeFile.delete();
- runningReference.remove(exId);
- }
-
- private void cleanFinishedJob(ExecutableFlow exFlow) throws ExecutorManagerException {
- // Write final file
- int updateNum = exFlow.getUpdateNumber();
- updateNum++;
- String exId = exFlow.getExecutionId();
- ExecutableFlowLoader.writeExecutableFlowFile(new File(exFlow.getExecutionPath()), exFlow, updateNum);
-
- // Clean up reference
- ExecutionReference reference = runningReference.get(exId);
- if (reference != null) {
- reference.setStartTime(exFlow.getStartTime());
- reference.setEndTime(exFlow.getEndTime());
- reference.setStatus(exFlow.getStatus());
- cleanExecutionReferenceJob(reference);
+ if (oldStatus != newStatus && newStatus.equals(Status.FAILED_FINISHING)) {
+ // We want to see if we should give an email status on first failure.
+ if (flow.getNotifyOnFirstFailure()) {
+ mailer.sendFirstErrorMessage(flow);
+ }
}
- runningFlows.remove(exFlow.getExecutionId());
- recentFlowsCache.put(new Element(exFlow.getExecutionId(), exFlow));
- cleanupUnusedFiles(exFlow);
+ return flow;
}
- private class ExecutingManagerUpdaterThread extends Thread {
- private boolean shutdown = false;
- private int waitTimeIdleMs = 1000;
- private int waitTimeMs = 100;
-
- @SuppressWarnings("unchecked")
- public void run() {
- while(!shutdown) {
- for (ExecutionReference reference: runningReference.values()) {
- // Don't do anything if not submitted
- if (!reference.isSubmitted()) {
- continue;
- }
-
- String execId = reference.getExecId();
- ExecutableFlow flow = runningFlows.get(execId);
- if (flow != null) {
- // Why doesn't flow exist?
- }
-
- File executionDir = new File(flow.getExecutionPath());
- // The execution dir doesn't exist. So we clean up.
- if (!executionDir.exists()) {
- logger.error("WTF!! Execution dir " + executionDir + " doesn't exist!");
- // Removing reference.
- reference.setStatus(Status.FAILED);
- try {
- cleanExecutionReferenceJob(reference);
- } catch (ExecutorManagerException e) {
- logger.error("The execution dir " + executionDir.getPath() + " doesn't exist for " + reference.toRefString(), e);
- }
- continue;
- }
-
- // Get status from the server. If the server response are errors, than we clean up after 30 seconds of errors.
- HashMap<String,Object> map = null;
- try {
- String string = callExecutorServer(reference, ConnectorParams.STATUS_ACTION);
- map = (HashMap<String,Object>)JSONUtils.parseJSONFromString(string);
- reference.setLastCheckedTime(System.currentTimeMillis());
- } catch (IOException e) {
- if (System.currentTimeMillis() - reference.getLastCheckedTime() > ACCESS_ERROR_THRESHOLD_MS) {
- logger.error("Error: Can't connect to server." + reference.toRefString() + ". Might be dead. Cleaning up project.", e);
- // Cleanup. Since we haven't seen anyone.
- try {
- forceFlowFailure(flow);
- cleanFinishedJob(flow);
- } catch (ExecutorManagerException e1) {
- logger.error("Foreced Fail: Error while cleaning up flow and job. " + reference.toRefString(), e1);
- }
-
- continue;
- }
- }
-
- // If the response from the server is an error, we print out the response and continue.
- String error = (String)map.get(ConnectorParams.RESPONSE_ERROR);
- if (error != null) {
- logger.error("Server status response for " + reference.toRefString() + " was an error: " + error);
- continue;
- }
-
- // If not found, then we clean up.
- String statusStr = (String)map.get(ConnectorParams.STATUS_PARAM);
- boolean forceFail = false;
- if (statusStr.equals(ConnectorParams.RESPONSE_NOTFOUND)) {
- logger.info("Server status response for " + reference.toRefString() + " was 'notfound'. Cleaning up");
- try {
- updateFlowFromFile(flow);
- forceFail = true;
- } catch (ExecutorManagerException e) {
- logger.error("Error updating flow status " + flow.getExecutionId() + " from file.", e);
- continue;
- }
- }
- else {
- // It's found, so we check the status.
- long time = JSONUtils.getLongFromObject(map.get(ConnectorParams.RESPONSE_UPDATETIME));
-
- if (time > flow.getUpdateTime()) {
- try {
- updateFlowFromFile(flow);
- // Update reference
- reference.setStartTime(flow.getStartTime());
- reference.setEndTime(flow.getEndTime());
- reference.setStatus(flow.getStatus());
- } catch (ExecutorManagerException e) {
- logger.error("Error updating flow status " + flow.getExecutionId() + " from file.", e);
- }
-
- flow.setUpdateTime(time);
- }
- }
-
- switch(flow.getStatus()) {
- case SUCCEEDED:
- case FAILED:
- case KILLED:
- try {
- cleanFinishedJob(flow);
- } catch (ExecutorManagerException e) {
- logger.error("Error while cleaning up flow and job. " + reference.toRefString(), e);
- }
-
- break;
- default:{
- // We force the failure.
- if (forceFail) {
- try {
- forceFlowFailure(flow);
- cleanFinishedJob(flow);
- } catch (ExecutorManagerException e) {
- logger.error("Foreced Fail: Error while cleaning up flow and job. " + reference.toRefString(), e);
- }
- }
- }
- }
- }
-
- // Change to rotating queue?
- synchronized(BlockObj) {
- try {
- if (runningReference.isEmpty()) {
- BlockObj.wait(waitTimeIdleMs);
- }
- else {
- BlockObj.wait(waitTimeMs);
- }
- } catch (InterruptedException e) {
- }
- }
- }
+ private boolean isFinished(ExecutableFlow flow) {
+ switch(flow.getStatus()) {
+ case SUCCEEDED:
+ case FAILED:
+ case KILLED:
+ return true;
+ default:
+ return false;
}
}
- private void updateFlowFromFile(ExecutableFlow exFlow) throws ExecutorManagerException {
- File executionDir = new File(exFlow.getExecutionPath());
- if (ExecutableFlowLoader.updateFlowStatusFromFile(executionDir, exFlow, true)) {
- // Move all the static directories if the update has changed.
- File statusDir = new File(basePath, exFlow.getProjectId() + File.separator + JOB_EXECUTION_DIR);
- ExecutableFlowLoader.moveJobStatusFiles(executionDir, statusDir);
+ private void fillUpdateTimeAndExecId(List<ExecutableFlow> flows, List<Integer> executionIds, List<Long> updateTimes) {
+ for (ExecutableFlow flow: flows) {
+ executionIds.add(flow.getExecutionId());
+ updateTimes.add(flow.getUpdateTime());
}
}
- /**
- * Reference to a Flow Execution.
- * It allows us to search for Flow and Project with only the Execution Id, it references
- * a file in the execution directories.
- */
- public static class ExecutionReference implements Comparable<ExecutionReference> {
- private String execId;
- private String projectId;
- private String flowId;
- private String userId;
- private String execPath;
- private long startTime;
- private long endTime;
- private Status status;
- private String executorUrl;
+ private Map<ConnectionInfo, List<ExecutableFlow>> getFlowToExecutorMap() {
+ HashMap<ConnectionInfo, List<ExecutableFlow>> exFlowMap = new HashMap<ConnectionInfo, List<ExecutableFlow>>();
- private int executorPort;
- private boolean isSubmitted = true;
- private long lastCheckedTime = -1;
-
- public ExecutionReference() {
- this.lastCheckedTime = System.currentTimeMillis();
- }
-
- public ExecutionReference(ExecutableFlow flow) {
- this();
- this.execId = flow.getExecutionId();
- this.projectId = flow.getProjectId();
- this.flowId = flow.getFlowId();
- this.userId = flow.getSubmitUser();
- this.execPath = flow.getExecutionPath();
+ ConnectionInfo lastPort = new ConnectionInfo(executorHost, executorPort);
+ for (Pair<ExecutionReference, ExecutableFlow> runningFlow: runningFlows.values()) {
+ ExecutionReference ref = runningFlow.getFirst();
+ ExecutableFlow flow = runningFlow.getSecond();
- this.startTime = flow.getStartTime();
- this.endTime = flow.getEndTime();
- this.status = flow.getStatus();
- this.isSubmitted = false;
- }
-
- private Object toObject() {
- HashMap<String, Object> obj = new HashMap<String, Object>();
- obj.put("execId", execId);
- obj.put("projectId", projectId);
- obj.put("flowId", flowId);
- obj.put("userId", userId);
- obj.put("execPath", execPath);
- obj.put("startTime", startTime);
- obj.put("endTime", endTime);
- obj.put("status", status);
- obj.put("executorUrl", executorUrl);
- obj.put("executorPort", executorPort);
- return obj;
- }
-
- public void writeToFile(File jsonFile) throws IOException {
- if (!jsonFile.exists()) {
- JSONUtils.toJSON(this.toObject(), jsonFile);
- }
- }
-
- public static ExecutionReference readFromFile(File file) throws IOException {
- if (!file.exists()) {
- throw new IOException("Execution file execution.json does not exist.");
+ // We can set the next check time to prevent the checking of certain flows.
+ if (ref.getNextCheckTime() >= System.currentTimeMillis()) {
+ continue;
}
- if (file.isDirectory()) {
- return null;
+ // Just a silly way to reduce object creation construction of objects since it's most likely that the values will be the same.
+ if (!lastPort.isEqual(ref.getHost(), ref.getPort())) {
+ lastPort = new ConnectionInfo(ref.getHost(), ref.getPort());
}
- @SuppressWarnings("unchecked")
- HashMap<String, Object> obj = (HashMap<String, Object>)JSONUtils.parseJSONFromFile(file);
- ExecutionReference reference = new ExecutionReference();
- reference.execId = (String)obj.get("execId");
- reference.projectId = (String)obj.get("projectId");
- reference.flowId = (String)obj.get("flowId");
- reference.userId = (String)obj.get("userId");
- reference.execPath = (String)obj.get("execPath");
- reference.startTime = JSONUtils.getLongFromObject(obj.get("startTime"));
- reference.endTime = JSONUtils.getLongFromObject(obj.get("endTime"));
- reference.status = Status.valueOf((String)obj.get("status"));
- if (obj.containsKey("executorUrl")) {
- reference.executorUrl = (String)obj.get("executorUrl");
- reference.executorPort = (Integer)obj.get("executorPort");
+ List<ExecutableFlow> flows = exFlowMap.get(lastPort);
+ if (flows == null) {
+ flows = new ArrayList<ExecutableFlow>();
+ exFlowMap.put(lastPort, flows);
}
-
- return reference;
+
+ flows.add(flow);
}
- public String toRefString() {
- return execId + ":" + executorUrl + ":" + executorPort;
+ return exFlowMap;
+ }
+
+ private static class ConnectionInfo {
+ private String host;
+ private int port;
+
+ public ConnectionInfo(String host, int port) {
+ this.host = host;
+ this.port = port;
}
-
- public String getExecId() {
- return execId;
+
+ private ConnectionInfo getOuterType() {
+ return ConnectionInfo.this;
}
- public String getProjectId() {
- return projectId;
+ public boolean isEqual(String host, int port) {
+ return this.port == port && this.host.equals(host);
}
- public String getFlowId() {
- return flowId;
+ public String getHost() {
+ return host;
}
- public String getUserId() {
- return userId;
+ public int getPort() {
+ return port;
}
- public String getExecPath() {
- return execPath;
- }
-
- public Long getStartTime() {
- return startTime;
- }
-
- public void setStartTime(Long startTime) {
- this.startTime = startTime;
- }
-
- public Long getEndTime() {
- return endTime;
- }
-
- public void setEndTime(Long endTime) {
- this.endTime = endTime;
- }
-
@Override
- public int compareTo(ExecutionReference arg0) {
- return arg0.getExecId().compareTo(execId);
- }
-
- public Status getStatus() {
- return status;
- }
-
- public void setStatus(Status status) {
- this.status = status;
- }
-
- public String getExecutorUrl() {
- return executorUrl;
- }
-
- public void setExecutorUrl(String executorUrl) {
- this.executorUrl = executorUrl;
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((host == null) ? 0 : host.hashCode());
+ result = prime * result + port;
+ return result;
}
- public int getExecutorPort() {
- return executorPort;
- }
-
- public void setExecutorPort(int port) {
- this.executorPort = port;
- }
-
- public boolean isSubmitted() {
- return isSubmitted;
- }
-
- public void setSubmitted(boolean isSubmitted) {
- this.isSubmitted = isSubmitted;
- }
-
- public long getLastCheckedTime() {
- return lastCheckedTime;
- }
-
- public void setLastCheckedTime(long lastCheckedTime) {
- this.lastCheckedTime = lastCheckedTime;
- }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ConnectionInfo other = (ConnectionInfo) obj;
+ if (host == null) {
+ if (other.host != null)
+ return false;
+ } else if (!host.equals(other.host))
+ return false;
+ if (port != other.port)
+ return false;
+ return true;
+ }
+ }
+
+ public int getExecutableFlows(int projectId, String flowId, int from, int length, List<ExecutableFlow> outputList) throws ExecutorManagerException {
+ List<ExecutableFlow> flows = executorLoader.fetchFlowHistory(projectId, flowId, from, length);
+ outputList.addAll(flows);
+ return executorLoader.fetchNumExecutableFlows(projectId, flowId);
}
-
-
}
diff --git a/src/java/azkaban/executor/ExecutorManagerException.java b/src/java/azkaban/executor/ExecutorManagerException.java
index b9420d8..772fc4b 100644
--- a/src/java/azkaban/executor/ExecutorManagerException.java
+++ b/src/java/azkaban/executor/ExecutorManagerException.java
@@ -18,12 +18,26 @@ package azkaban.executor;
public class ExecutorManagerException extends Exception {
private static final long serialVersionUID = 1L;
-
+ private ExecutableFlow flow = null;
+
+ public ExecutorManagerException(Exception e) {
+ super(e);
+ }
+
public ExecutorManagerException(String message) {
super(message);
}
+ public ExecutorManagerException(String message, ExecutableFlow flow) {
+ super(message);
+ this.flow = flow;
+ }
+
public ExecutorManagerException(String message, Throwable cause) {
super(message, cause);
}
+
+ public ExecutableFlow getExecutableFlow() {
+ return flow;
+ }
}
src/java/azkaban/executor/JdbcExecutorLoader.java 807(+807 -0)
diff --git a/src/java/azkaban/executor/JdbcExecutorLoader.java b/src/java/azkaban/executor/JdbcExecutorLoader.java
new file mode 100644
index 0000000..1acc59a
--- /dev/null
+++ b/src/java/azkaban/executor/JdbcExecutorLoader.java
@@ -0,0 +1,807 @@
+package azkaban.executor;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.dbutils.DbUtils;
+import org.apache.commons.dbutils.QueryRunner;
+import org.apache.commons.dbutils.ResultSetHandler;
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.Logger;
+
+import azkaban.executor.ExecutableFlow.Status;
+import azkaban.utils.DataSourceUtils;
+import azkaban.utils.FileIOUtils;
+import azkaban.utils.FileIOUtils.LogData;
+import azkaban.utils.GZIPUtils;
+import azkaban.utils.JSONUtils;
+import azkaban.utils.Pair;
+import azkaban.utils.Props;
+import azkaban.utils.PropsUtils;
+
+public class JdbcExecutorLoader implements ExecutorLoader {
+ private static final Logger logger = Logger.getLogger(JdbcExecutorLoader.class);
+
+ /**
+ * Used for when we store text data. Plain uses UTF8 encoding.
+ */
+ public static enum EncodingType {
+ PLAIN(1), GZIP(2);
+
+ private int numVal;
+
+ EncodingType(int numVal) {
+ this.numVal = numVal;
+ }
+
+ public int getNumVal() {
+ return numVal;
+ }
+
+ public static EncodingType fromInteger(int x) {
+ switch (x) {
+ case 1:
+ return PLAIN;
+ case 2:
+ return GZIP;
+ default:
+ return PLAIN;
+ }
+ }
+ }
+
+ private DataSource dataSource;
+ private EncodingType defaultEncodingType = EncodingType.GZIP;
+
+ public JdbcExecutorLoader(Props props) {
+ String databaseType = props.getString("database.type");
+
+ if (databaseType.equals("mysql")) {
+ int port = props.getInt("mysql.port");
+ String host = props.getString("mysql.host");
+ String database = props.getString("mysql.database");
+ String user = props.getString("mysql.user");
+ String password = props.getString("mysql.password");
+ int numConnections = props.getInt("mysql.numconnections");
+
+ dataSource = DataSourceUtils.getMySQLDataSource(host, port, database, user, password, numConnections);
+ }
+ }
+
+ public EncodingType getDefaultEncodingType() {
+ return defaultEncodingType;
+ }
+
+ public void setDefaultEncodingType(EncodingType defaultEncodingType) {
+ this.defaultEncodingType = defaultEncodingType;
+ }
+
+ @Override
+ public synchronized void uploadExecutableFlow(ExecutableFlow flow) throws ExecutorManagerException {
+ Connection connection = getConnection();
+ try {
+ uploadExecutableFlow(connection, flow, defaultEncodingType);
+ } catch (IOException e) {
+ throw new ExecutorManagerException("Error uploading flow", e);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+ }
+
+ private synchronized void uploadExecutableFlow(Connection connection, ExecutableFlow flow, EncodingType encType) throws ExecutorManagerException, IOException {
+ final String INSERT_EXECUTABLE_FLOW = "INSERT INTO execution_flows (project_id, flow_id, version, status, submit_time, submit_user, update_time) values (?,?,?,?,?,?,?)";
+ QueryRunner runner = new QueryRunner();
+ long submitTime = System.currentTimeMillis();
+
+ long id;
+ try {
+ flow.setStatus(ExecutableFlow.Status.PREPARING);
+ runner.update(connection, INSERT_EXECUTABLE_FLOW, flow.getProjectId(), flow.getFlowId(), flow.getVersion(), ExecutableFlow.Status.PREPARING.getNumVal(), submitTime, flow.getSubmitUser(), submitTime);
+ connection.commit();
+ id = runner.query(connection, LastInsertID.LAST_INSERT_ID, new LastInsertID());
+
+ if (id == -1l) {
+ throw new ExecutorManagerException("Execution id is not properly created.");
+ }
+ logger.info("Flow given " + flow.getFlowId() + " given id " + id);
+ flow.setExecutionId((int)id);
+
+ updateExecutableFlow(connection, flow, encType);
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error creating execution.", e);
+ }
+ }
+
+ @Override
+ public void updateExecutableFlow(ExecutableFlow flow) throws ExecutorManagerException {
+ Connection connection = this.getConnection();
+
+ try {
+ updateExecutableFlow(connection, flow, defaultEncodingType);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+ }
+
+ private void updateExecutableFlow(Connection connection, ExecutableFlow flow, EncodingType encType) throws ExecutorManagerException {
+ final String UPDATE_EXECUTABLE_FLOW_DATA = "UPDATE execution_flows SET status=?,update_time=?,start_time=?,end_time=?,enc_type=?,flow_data=? WHERE exec_id=?";
+ QueryRunner runner = new QueryRunner();
+
+ String json = JSONUtils.toJSON(flow.toObject());
+ byte[] data = null;
+ try {
+ byte[] stringData = json.getBytes("UTF-8");
+ data = stringData;
+
+ if (encType == EncodingType.GZIP) {
+ data = GZIPUtils.gzipBytes(stringData);
+ }
+ logger.debug("NumChars: " + json.length() + " UTF-8:" + stringData.length + " Gzip:"+ data.length);
+ }
+ catch (IOException e) {
+ throw new ExecutorManagerException("Error encoding the execution flow.");
+ }
+
+ try {
+ runner.update(connection, UPDATE_EXECUTABLE_FLOW_DATA, flow.getStatus().getNumVal(), flow.getUpdateTime(), flow.getStartTime(), flow.getEndTime(), encType.getNumVal(), data, flow.getExecutionId());
+ connection.commit();
+ }
+ catch(SQLException e) {
+ throw new ExecutorManagerException("Error updating flow.", e);
+ }
+ }
+
+ @Override
+ public ExecutableFlow fetchExecutableFlow(int id) throws ExecutorManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+ FetchExecutableFlows flowHandler = new FetchExecutableFlows();
+
+ try {
+ List<ExecutableFlow> properties = runner.query(FetchExecutableFlows.FETCH_EXECUTABLE_FLOW, flowHandler, id);
+ return properties.get(0);
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error fetching flow id " + id, e);
+ }
+ }
+
+ @Override
+ public Map<Integer, Pair<ExecutionReference, ExecutableFlow>> fetchActiveFlows() throws ExecutorManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+ FetchActiveExecutableFlows flowHandler = new FetchActiveExecutableFlows();
+
+ try {
+ Map<Integer, Pair<ExecutionReference, ExecutableFlow>> properties = runner.query(FetchActiveExecutableFlows.FETCH_ACTIVE_EXECUTABLE_FLOW, flowHandler);
+ return properties;
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error fetching active flows", e);
+ }
+ }
+
+ @Override
+ public int fetchNumExecutableFlows() throws ExecutorManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ IntHandler intHandler = new IntHandler();
+ try {
+ int count = runner.query(IntHandler.NUM_EXECUTIONS, intHandler);
+ return count;
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error fetching num executions", e);
+ }
+ }
+
+ @Override
+ public int fetchNumExecutableFlows(int projectId, String flowId) throws ExecutorManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ IntHandler intHandler = new IntHandler();
+ try {
+ int count = runner.query(IntHandler.NUM_FLOW_EXECUTIONS, intHandler, projectId, flowId);
+ return count;
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error fetching num executions", e);
+ }
+ }
+
+ @Override
+ public int fetchNumExecutableNodes(int projectId, String jobId) throws ExecutorManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ IntHandler intHandler = new IntHandler();
+ try {
+ int count = runner.query(IntHandler.NUM_JOB_EXECUTIONS, intHandler, projectId, jobId);
+ return count;
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error fetching num executions", e);
+ }
+ }
+
+ @Override
+ public List<ExecutableFlow> fetchFlowHistory(int projectId, String flowId, int skip, int num) throws ExecutorManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+ FetchExecutableFlows flowHandler = new FetchExecutableFlows();
+
+ try {
+ List<ExecutableFlow> properties = runner.query(FetchExecutableFlows.FETCH_EXECUTABLE_FLOW_HISTORY, flowHandler, projectId, flowId, skip, num);
+ return properties;
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error fetching active flows", e);
+ }
+ }
+
+ @Override
+ public List<ExecutableFlow> fetchFlowHistory(int skip, int num) throws ExecutorManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+ FetchExecutableFlows flowHandler = new FetchExecutableFlows();
+
+ try {
+ List<ExecutableFlow> properties = runner.query(FetchExecutableFlows.FETCH_ALL_EXECUTABLE_FLOW_HISTORY, flowHandler, skip, num);
+ return properties;
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error fetching active flows", e);
+ }
+ }
+
+
+ @Override
+ public List<ExecutableFlow> fetchFlowHistory(String projContain, String flowContains, String userNameContains, int status, long startTime, long endTime, int skip, int num) throws ExecutorManagerException {
+ String query = FetchExecutableFlows.FETCH_BASE_EXECUTABLE_FLOW_QUERY;
+ ArrayList<Object> params = new ArrayList<Object>();
+
+ boolean first = true;
+ if (projContain != null) {
+ query += " ef JOIN projects p ON ef.project_id = p.id WHERE name LIKE ?";
+ params.add('%'+projContain+'%');
+ first = false;
+ }
+
+ if (flowContains != null) {
+ if (first) {
+ query += " WHERE ";
+ first = false;
+ }
+ else {
+ query += " AND ";
+ }
+
+ query += " flow_id LIKE ?";
+ params.add('%'+flowContains+'%');
+ }
+
+ if (userNameContains != null) {
+ if (first) {
+ query += " WHERE ";
+ first = false;
+ }
+ else {
+ query += " AND ";
+ }
+ query += " submit_user LIKE ?";
+ params.add('%'+userNameContains+'%');
+ }
+
+ if (status != 0) {
+ if (first) {
+ query += " WHERE ";
+ first = false;
+ }
+ else {
+ query += " AND ";
+ }
+ query += " status = ?";
+ params.add(status);
+ }
+
+ if (startTime > 0) {
+ if (first) {
+ query += " WHERE ";
+ first = false;
+ }
+ else {
+ query += " AND ";
+ }
+ query += " start_time > ?";
+ params.add(startTime);
+ }
+
+ if (endTime > 0) {
+ if (first) {
+ query += " WHERE ";
+ first = false;
+ }
+ else {
+ query += " AND ";
+ }
+ query += " end_time < ?";
+ params.add(endTime);
+ }
+
+ if (skip > -1 && num > 0) {
+ query += " ORDER BY exec_id DESC LIMIT ?, ?";
+ params.add(skip);
+ params.add(num);
+ }
+
+ QueryRunner runner = new QueryRunner(dataSource);
+ FetchExecutableFlows flowHandler = new FetchExecutableFlows();
+
+ try {
+ List<ExecutableFlow> properties = runner.query(query, flowHandler, params.toArray());
+ return properties;
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error fetching active flows", e);
+ }
+ }
+
+ @Override
+ public void addActiveExecutableReference(ExecutionReference reference) throws ExecutorManagerException {
+ final String INSERT = "INSERT INTO active_executing_flows (exec_id, host, port, update_time) values (?,?,?,?)";
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ try {
+ runner.update(INSERT, reference.getExecId(), reference.getHost(), reference.getPort(), reference.getUpdateTime());
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error updating active flow reference " + reference.getExecId(), e);
+ }
+ }
+
+ @Override
+ public void removeActiveExecutableReference(int execid) throws ExecutorManagerException {
+ final String DELETE = "DELETE FROM active_executing_flows WHERE exec_id=?";
+
+ QueryRunner runner = new QueryRunner(dataSource);
+ try {
+ runner.update(DELETE, execid);
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error deleting active flow reference " + execid, e);
+ }
+ }
+
+ @Override
+ public boolean updateExecutableReference(int execId, long updateTime) throws ExecutorManagerException {
+ final String DELETE = "UPDATE active_executing_flows set update_time=? WHERE exec_id=?";
+
+ QueryRunner runner = new QueryRunner(dataSource);
+ int updateNum = 0;
+ try {
+ updateNum = runner.update(DELETE, updateTime, execId);
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error deleting active flow reference " + execId, e);
+ }
+
+ // Should be 1.
+ return updateNum > 0;
+ }
+
+ @Override
+ public void uploadExecutableNode(ExecutableNode node, Props inputProps) throws ExecutorManagerException {
+ final String INSERT_EXECUTION_NODE = "INSERT INTO execution_jobs (exec_id, project_id, version, flow_id, job_id, start_time, end_time, status, input_params) VALUES (?,?,?,?,?,?,?,?,?)";
+
+ byte[] inputParam = null;
+ if (inputProps != null) {
+ try {
+ String jsonString = JSONUtils.toJSON(PropsUtils.toHierarchicalMap(inputProps));
+ inputParam = GZIPUtils.gzipString(jsonString, "UTF-8");
+ } catch (IOException e) {
+ throw new ExecutorManagerException("Error encoding input params");
+ }
+ }
+
+ ExecutableFlow flow = node.getFlow();
+ QueryRunner runner = new QueryRunner(dataSource);
+ try {
+ runner.update(
+ INSERT_EXECUTION_NODE,
+ flow.getExecutionId(),
+ flow.getProjectId(),
+ flow.getVersion(),
+ flow.getFlowId(),
+ node.getJobId(),
+ node.getStartTime(),
+ node.getEndTime(),
+ node.getStatus().getNumVal(),
+ inputParam);
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error writing job " + node.getJobId(), e);
+ }
+ }
+
+ @Override
+ public void updateExecutableNode(ExecutableNode node, Props outputProps) throws ExecutorManagerException {
+ final String UPSERT_EXECUTION_NODE = "UPDATE execution_jobs SET start_time=?, end_time=?, status=?, output_params=? WHERE exec_id=? AND job_id=?";
+
+ byte[] outputParam = null;
+ if (outputProps != null) {
+ try {
+ String jsonString = JSONUtils.toJSON(PropsUtils.toHierarchicalMap(outputProps));
+ outputParam = GZIPUtils.gzipString(jsonString, "UTF-8");
+ } catch (IOException e) {
+ throw new ExecutorManagerException("Error encoding input params");
+ }
+ }
+
+ QueryRunner runner = new QueryRunner(dataSource);
+ try {
+ runner.update(
+ UPSERT_EXECUTION_NODE,
+ node.getStartTime(),
+ node.getEndTime(),
+ node.getStatus().getNumVal(),
+ outputParam,
+ node.getExecutionId(),
+ node.getJobId());
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error updating job " + node.getJobId(), e);
+ }
+ }
+
+ @Override
+ public ExecutableJobInfo fetchJobInfo(int execId, String jobId) throws ExecutorManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ try {
+ List<ExecutableJobInfo> info = runner.query(FetchExecutableJobHandler.FETCH_EXECUTABLE_NODE, new FetchExecutableJobHandler(), execId, jobId);
+ if (info == null || info.isEmpty()) {
+ return null;
+ }
+
+ return info.get(0);
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error querying job info " + jobId, e);
+ }
+ }
+
+ @Override
+ public List<ExecutableJobInfo> fetchJobHistory(int projectId, String jobId, int skip, int size) throws ExecutorManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ try {
+ List<ExecutableJobInfo> info = runner.query(FetchExecutableJobHandler.FETCH_PROJECT_EXECUTABLE_NODE, new FetchExecutableJobHandler(), projectId, jobId, skip, size);
+ if (info == null || info.isEmpty()) {
+ return null;
+ }
+
+ return info;
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error querying job info " + jobId, e);
+ }
+ }
+
+ @Override
+ public LogData fetchLogs(int execId, String name, int startByte, int length) throws ExecutorManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ FetchLogsHandler handler = new FetchLogsHandler(startByte, length + startByte);
+
+ try {
+ LogData result = runner.query(FetchLogsHandler.FETCH_LOGS, handler, execId, name, startByte, startByte + length);
+ return result;
+ } catch (SQLException e) {
+ throw new ExecutorManagerException("Error fetching logs " + execId + " : " + name, e);
+ }
+ }
+
+ @Override
+ public void uploadLogFile(int execId, String name, File ... files) throws ExecutorManagerException {
+ Connection connection = getConnection();
+ try {
+ uploadLogFile(connection, execId, name, files, defaultEncodingType);
+ connection.commit();
+ }
+ catch (SQLException e) {
+ throw new ExecutorManagerException("Error committing log", e);
+ }
+ catch (IOException e) {
+ throw new ExecutorManagerException("Error committing log", e);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+ }
+
+ private void uploadLogFile(Connection connection, int execId, String name, File[] files, EncodingType encType) throws ExecutorManagerException, IOException {
+ // 50K buffer... if logs are greater than this, we chunk.
+ // However, we better prevent large log files from being uploaded somehow
+ byte[] buffer = new byte[50*1024];
+ int pos = 0;
+ int length = buffer.length;
+ int startByte = 0;
+ BufferedInputStream bufferedStream = null;
+ try {
+ for (int i = 0; i < files.length; ++i) {
+ File file = files[i];
+
+ bufferedStream = new BufferedInputStream(new FileInputStream(file));
+ int size = bufferedStream.read(buffer, pos, length);
+ while (size >= 0) {
+ if (pos + size == buffer.length) {
+ // Flush here.
+ uploadLogPart(connection, execId, name, startByte, startByte + buffer.length, encType, buffer, buffer.length);
+
+ pos = 0;
+ length = buffer.length;
+ startByte += buffer.length;
+ }
+ else {
+ // Usually end of file.
+ pos += size;
+ length = buffer.length - pos;
+ }
+ size = bufferedStream.read(buffer, pos, length);
+ }
+ }
+
+ // Final commit of buffer.
+ if (pos > 0) {
+ uploadLogPart(connection, execId, name, startByte, startByte + pos, encType, buffer, pos);
+ }
+ }
+ catch (SQLException e) {
+ throw new ExecutorManagerException("Error writing log part.", e);
+ }
+ catch (IOException e) {
+ throw new ExecutorManagerException("Error chunking", e);
+ }
+ finally {
+ IOUtils.closeQuietly(bufferedStream);
+ }
+
+ }
+
+ private void uploadLogPart(Connection connection, int execId, String name, int startByte, int endByte, EncodingType encType, byte[] buffer, int length) throws SQLException, IOException {
+ final String INSERT_EXECUTION_LOGS = "INSERT INTO execution_logs (exec_id, name, enc_type, start_byte, end_byte, log) VALUES (?,?,?,?,?,?)";
+ QueryRunner runner = new QueryRunner();
+
+ byte[] buf = buffer;
+ if (encType == EncodingType.GZIP) {
+ buf = GZIPUtils.gzipBytes(buf, 0, length);
+ }
+ else if (length < buf.length) {
+ buf = Arrays.copyOf(buffer, length);
+ }
+
+ runner.update(connection, INSERT_EXECUTION_LOGS, execId, name, encType.getNumVal(), startByte, startByte + length, buf);
+ }
+
+ private Connection getConnection() throws ExecutorManagerException {
+ Connection connection = null;
+ try {
+ connection = dataSource.getConnection();
+ connection.setAutoCommit(false);
+ } catch (Exception e) {
+ DbUtils.closeQuietly(connection);
+ throw new ExecutorManagerException("Error getting DB connection.", e);
+ }
+
+ return connection;
+ }
+
+ private static class LastInsertID implements ResultSetHandler<Long> {
+ private static String LAST_INSERT_ID = "SELECT LAST_INSERT_ID()";
+
+ @Override
+ public Long handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return -1l;
+ }
+
+ long id = rs.getLong(1);
+ return id;
+ }
+
+ }
+
+ private static class FetchLogsHandler implements ResultSetHandler<LogData> {
+ private static String FETCH_LOGS = "SELECT exec_id, name, enc_type, start_byte, end_byte, log FROM execution_logs WHERE exec_id=? AND name=? AND end_byte > ? AND start_byte <= ? ORDER BY start_byte";
+
+ private int startByte;
+ private int endByte;
+
+ public FetchLogsHandler(int startByte, int endByte) {
+ this.startByte = startByte;
+ this.endByte = endByte;
+ }
+
+ @Override
+ public LogData handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return null;
+ }
+
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+
+ do {
+ //int execId = rs.getInt(1);
+ //String name = rs.getString(2);
+ EncodingType encType = EncodingType.fromInteger(rs.getInt(3));
+ int startByte = rs.getInt(4);
+ int endByte = rs.getInt(5);
+
+ byte[] data = rs.getBytes(6);
+
+ int offset = this.startByte > startByte ? this.startByte - startByte : 0;
+ int length = this.endByte < endByte ? this.endByte - startByte - offset: endByte - startByte - offset;
+ try {
+ byte[] buffer = data;
+ if (encType == EncodingType.GZIP) {
+ buffer = GZIPUtils.unGzipBytes(data);
+ }
+
+ byteStream.write(buffer, offset, length);
+ } catch (IOException e) {
+ throw new SQLException(e);
+ }
+ } while (rs.next());
+
+ byte[] buffer = byteStream.toByteArray();
+ Pair<Integer,Integer> result = FileIOUtils.getUtf8Range(buffer, 0, buffer.length);
+
+ return new LogData(startByte + result.getFirst(), result.getSecond(), new String(buffer, result.getFirst(), result.getSecond()));
+ }
+ }
+
+ private static class FetchExecutableJobHandler implements ResultSetHandler<List<ExecutableJobInfo>> {
+ private static String FETCH_EXECUTABLE_NODE = "SELECT exec_id, project_id, version, flow_id, job_id, start_time, end_time, status FROM execution_jobs WHERE exec_id=? AND job_id=?";
+ private static String FETCH_PROJECT_EXECUTABLE_NODE = "SELECT exec_id, project_id, version, flow_id, job_id, start_time, end_time, status FROM execution_jobs WHERE project_id=? AND job_id=? ORDER BY exec_id DESC LIMIT ?, ? ";
+
+ @Override
+ public List<ExecutableJobInfo> handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return Collections.<ExecutableJobInfo>emptyList();
+ }
+
+ List<ExecutableJobInfo> execNodes = new ArrayList<ExecutableJobInfo>();
+ do {
+ int execId = rs.getInt(1);
+ int projectId = rs.getInt(2);
+ int version = rs.getInt(3);
+ String flowId = rs.getString(4);
+ String jobId = rs.getString(5);
+ long startTime = rs.getLong(6);
+ long endTime = rs.getLong(7);
+ Status status = Status.fromInteger(rs.getInt(8));
+
+ ExecutableJobInfo info = new ExecutableJobInfo(execId, projectId, version, flowId, jobId, startTime, endTime, status);
+ execNodes.add(info);
+ } while (rs.next());
+
+ return execNodes;
+ }
+ }
+
+
+ private static class FetchActiveExecutableFlows implements ResultSetHandler<Map<Integer, Pair<ExecutionReference,ExecutableFlow>>> {
+ private static String FETCH_ACTIVE_EXECUTABLE_FLOW = "SELECT ex.exec_id exec_id, ex.enc_type enc_type, ex.flow_data flow_data, ax.host host, ax.port port, ax.update_time axUpdateTime FROM execution_flows ex INNER JOIN active_executing_flows ax ON ex.exec_id = ax.exec_id";
+
+ @Override
+ public Map<Integer, Pair<ExecutionReference,ExecutableFlow>> handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return Collections.<Integer, Pair<ExecutionReference,ExecutableFlow>>emptyMap();
+ }
+
+ Map<Integer, Pair<ExecutionReference,ExecutableFlow>> execFlows = new HashMap<Integer, Pair<ExecutionReference,ExecutableFlow>>();
+ do {
+ int id = rs.getInt(1);
+ int encodingType = rs.getInt(2);
+ byte[] data = rs.getBytes(3);
+ String host = rs.getString(4);
+ int port = rs.getInt(5);
+ long updateTime = rs.getLong(6);
+
+ if (data == null) {
+ execFlows.put(id, null);
+ }
+ else {
+ EncodingType encType = EncodingType.fromInteger(encodingType);
+ Object flowObj;
+ try {
+ // Convoluted way to inflate strings. Should find common package or helper function.
+ if (encType == EncodingType.GZIP) {
+ // Decompress the sucker.
+ String jsonString = GZIPUtils.unGzipString(data, "UTF-8");
+ flowObj = JSONUtils.parseJSONFromString(jsonString);
+ }
+ else {
+ String jsonString = new String(data, "UTF-8");
+ flowObj = JSONUtils.parseJSONFromString(jsonString);
+ }
+
+ ExecutableFlow exFlow = ExecutableFlow.createExecutableFlowFromObject(flowObj);
+ ExecutionReference ref = new ExecutionReference(id, host, port);
+ ref.setUpdateTime(updateTime);
+
+ execFlows.put(id, new Pair<ExecutionReference, ExecutableFlow>(ref, exFlow));
+ } catch (IOException e) {
+ throw new SQLException("Error retrieving flow data " + id, e);
+ }
+ }
+ } while (rs.next());
+
+ return execFlows;
+ }
+
+ }
+
+ private static class FetchExecutableFlows implements ResultSetHandler<List<ExecutableFlow>> {
+ private static String FETCH_BASE_EXECUTABLE_FLOW_QUERY = "SELECT exec_id, enc_type, flow_data FROM execution_flows ";
+ private static String FETCH_EXECUTABLE_FLOW = "SELECT exec_id, enc_type, flow_data FROM execution_flows WHERE exec_id=?";
+ private static String FETCH_ACTIVE_EXECUTABLE_FLOW = "SELECT ex.exec_id exec_id, ex.enc_type enc_type, ex.flow_data flow_data FROM execution_flows ex INNER JOIN active_executing_flows ax ON ex.exec_id = ax.exec_id";
+ private static String FETCH_ALL_EXECUTABLE_FLOW_HISTORY = "SELECT exec_id, enc_type, flow_data FROM execution_flows ORDER BY exec_id DESC LIMIT ?, ?";
+ private static String FETCH_EXECUTABLE_FLOW_HISTORY = "SELECT exec_id, enc_type, flow_data FROM execution_flows WHERE project_id=? AND flow_id=? ORDER BY exec_id DESC LIMIT ?, ?";
+
+ @Override
+ public List<ExecutableFlow> handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return Collections.<ExecutableFlow>emptyList();
+ }
+
+ List<ExecutableFlow> execFlows = new ArrayList<ExecutableFlow>();
+ do {
+ int id = rs.getInt(1);
+ int encodingType = rs.getInt(2);
+ byte[] data = rs.getBytes(3);
+
+ if (data != null) {
+ EncodingType encType = EncodingType.fromInteger(encodingType);
+ Object flowObj;
+ try {
+ // Convoluted way to inflate strings. Should find common package or helper function.
+ if (encType == EncodingType.GZIP) {
+ // Decompress the sucker.
+ String jsonString = GZIPUtils.unGzipString(data, "UTF-8");
+ flowObj = JSONUtils.parseJSONFromString(jsonString);
+ }
+ else {
+ String jsonString = new String(data, "UTF-8");
+ flowObj = JSONUtils.parseJSONFromString(jsonString);
+ }
+
+ ExecutableFlow exFlow = ExecutableFlow.createExecutableFlowFromObject(flowObj);
+ execFlows.add(exFlow);
+ } catch (IOException e) {
+ throw new SQLException("Error retrieving flow data " + id, e);
+ }
+ }
+ } while (rs.next());
+
+ return execFlows;
+ }
+
+ }
+
+ private static class IntHandler implements ResultSetHandler<Integer> {
+ private static String NUM_EXECUTIONS = "SELECT COUNT(1) FROM execution_flows";
+ private static String NUM_FLOW_EXECUTIONS = "SELECT COUNT(1) FROM execution_flows WHERE project_id=? AND flow_id=?";
+ private static String NUM_JOB_EXECUTIONS = "SELECT COUNT(1) FROM execution_jobs WHERE project_id=? AND job_id=?";
+
+ @Override
+ public Integer handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return 0;
+ }
+
+ return rs.getInt(1);
+ }
+ }
+}
\ No newline at end of file
src/java/azkaban/flow/Flow.java 27(+20 -7)
diff --git a/src/java/azkaban/flow/Flow.java b/src/java/azkaban/flow/Flow.java
index 5230644..6c01df8 100644
--- a/src/java/azkaban/flow/Flow.java
+++ b/src/java/azkaban/flow/Flow.java
@@ -25,11 +25,8 @@ import java.util.Map;
import java.util.Set;
public class Flow {
- public enum State {
- READY, RUNNING, RUNNING_WITH_FAILURE, FAILED, SUCCEEDED
- }
private final String id;
- private String projectId;
+ private int projectId;
private ArrayList<Node> startNodes = null;
private ArrayList<Node> endNodes = null;
private int numLevels = -1;
@@ -44,13 +41,22 @@ public class Flow {
private List<String> failureEmail = new ArrayList<String>();
private List<String> successEmail = new ArrayList<String>();
private ArrayList<String> errors;
-
+ private int version = -1;
+
private boolean isLayedOut = false;
public Flow(String id) {
this.id = id;
}
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+
public void initialize() {
if (startNodes == null) {
startNodes = new ArrayList<Node>();
@@ -213,6 +219,8 @@ public class Flow {
HashMap<String, Object> flowObj = new HashMap<String, Object>();
flowObj.put("type", "flow");
flowObj.put("id", getId());
+ flowObj.put("project.id", projectId);
+ flowObj.put("version", version);
flowObj.put("props", objectizeProperties());
flowObj.put("nodes", objectizeNodes());
flowObj.put("edges", objectizeEdges());
@@ -266,6 +274,11 @@ public class Flow {
if (layedout != null) {
flow.setLayedOut(layedout);
}
+ int projId = (Integer)flowObject.get("project.id");
+ flow.setProjectId(projId);
+
+ int version = (Integer)flowObject.get("version");
+ flow.setVersion(version);
// Loading projects
List<Object> propertiesList = (List<Object>)flowObject.get("props");
@@ -348,11 +361,11 @@ public class Flow {
return flowProps;
}
- public String getProjectId() {
+ public int getProjectId() {
return projectId;
}
- public void setProjectId(String projectId) {
+ public void setProjectId(int projectId) {
this.projectId = projectId;
}
}
\ No newline at end of file
src/java/azkaban/fsviewers/HdfsAvroFileViewer.java 148(+74 -74)
diff --git a/src/java/azkaban/fsviewers/HdfsAvroFileViewer.java b/src/java/azkaban/fsviewers/HdfsAvroFileViewer.java
index 9a4d4e2..8f52bbf 100644
--- a/src/java/azkaban/fsviewers/HdfsAvroFileViewer.java
+++ b/src/java/azkaban/fsviewers/HdfsAvroFileViewer.java
@@ -42,79 +42,79 @@ import org.codehaus.jackson.JsonGenerator;
*/
public class HdfsAvroFileViewer implements HdfsFileViewer {
- private static Logger logger = Logger.getLogger(HdfsAvroFileViewer.class);
- // Will spend 5 seconds trying to pull data and then stop.
- private static long STOP_TIME = 2000l;
-
- @Override
- public boolean canReadFile(FileSystem fs, Path path) {
-
- if(logger.isDebugEnabled())
- logger.debug("path:" + path.toUri().getPath());
-
- try {
- DataFileStream<Object> avroDataStream = getAvroDataStream(fs, path);
- Schema schema = avroDataStream.getSchema();
- avroDataStream.close();
- return schema != null;
- } catch(IOException e) {
- if(logger.isDebugEnabled()) {
- logger.debug(path.toUri().getPath() + " is not an avro file.");
- logger.debug("Error in getting avro schema: " + e.getLocalizedMessage());
- }
- return false;
- }
- }
-
- private DataFileStream<Object> getAvroDataStream(FileSystem fs, Path path) throws IOException {
- if(logger.isDebugEnabled())
- logger.debug("path:" + path.toUri().getPath());
-
- GenericDatumReader<Object> avroReader = new GenericDatumReader<Object>();
- InputStream hdfsInputStream = fs.open(path);
- return new DataFileStream<Object>(hdfsInputStream, avroReader);
-
- }
-
- @Override
- public void displayFile(FileSystem fs,
- Path path,
- OutputStream outputStream,
- int startLine,
- int endLine) throws IOException {
-
- if(logger.isDebugEnabled())
- logger.debug("display avro file:" + path.toUri().getPath());
-
- DataFileStream<Object> avroDatastream = null;
-
- try {
- avroDatastream = getAvroDataStream(fs, path);
- Schema schema = avroDatastream.getSchema();
- DatumWriter<Object> avroWriter = new GenericDatumWriter<Object>(schema);
-
- JsonGenerator g = new JsonFactory().createJsonGenerator(outputStream, JsonEncoding.UTF8);
- g.useDefaultPrettyPrinter();
- Encoder encoder = new JsonEncoder(schema, g);
-
- long endTime = System.currentTimeMillis() + STOP_TIME;
- int lineno = 1; // line number starts from 1
- while(avroDatastream.hasNext() && lineno <= endLine && System.currentTimeMillis() <= endTime) {
- Object datum = avroDatastream.next();
- if(lineno >= startLine) {
- String record = "\n\n Record " + lineno + ":\n";
- outputStream.write(record.getBytes("UTF-8"));
- avroWriter.write(datum, encoder);
- encoder.flush();
- }
- lineno++;
- }
- } catch(IOException e) {
- outputStream.write(("Error in display avro file: " + e.getLocalizedMessage()).getBytes("UTF-8"));
- throw e;
- } finally {
- avroDatastream.close();
- }
- }
+ private static Logger logger = Logger.getLogger(HdfsAvroFileViewer.class);
+ // Will spend 5 seconds trying to pull data and then stop.
+ private static long STOP_TIME = 2000l;
+
+ @Override
+ public boolean canReadFile(FileSystem fs, Path path) {
+
+ if(logger.isDebugEnabled())
+ logger.debug("path:" + path.toUri().getPath());
+
+ try {
+ DataFileStream<Object> avroDataStream = getAvroDataStream(fs, path);
+ Schema schema = avroDataStream.getSchema();
+ avroDataStream.close();
+ return schema != null;
+ } catch(IOException e) {
+ if(logger.isDebugEnabled()) {
+ logger.debug(path.toUri().getPath() + " is not an avro file.");
+ logger.debug("Error in getting avro schema: " + e.getLocalizedMessage());
+ }
+ return false;
+ }
+ }
+
+ private DataFileStream<Object> getAvroDataStream(FileSystem fs, Path path) throws IOException {
+ if(logger.isDebugEnabled())
+ logger.debug("path:" + path.toUri().getPath());
+
+ GenericDatumReader<Object> avroReader = new GenericDatumReader<Object>();
+ InputStream hdfsInputStream = fs.open(path);
+ return new DataFileStream<Object>(hdfsInputStream, avroReader);
+
+ }
+
+ @Override
+ public void displayFile(FileSystem fs,
+ Path path,
+ OutputStream outputStream,
+ int startLine,
+ int endLine) throws IOException {
+
+ if(logger.isDebugEnabled())
+ logger.debug("display avro file:" + path.toUri().getPath());
+
+ DataFileStream<Object> avroDatastream = null;
+
+ try {
+ avroDatastream = getAvroDataStream(fs, path);
+ Schema schema = avroDatastream.getSchema();
+ DatumWriter<Object> avroWriter = new GenericDatumWriter<Object>(schema);
+
+ JsonGenerator g = new JsonFactory().createJsonGenerator(outputStream, JsonEncoding.UTF8);
+ g.useDefaultPrettyPrinter();
+ Encoder encoder = new JsonEncoder(schema, g);
+
+ long endTime = System.currentTimeMillis() + STOP_TIME;
+ int lineno = 1; // line number starts from 1
+ while(avroDatastream.hasNext() && lineno <= endLine && System.currentTimeMillis() <= endTime) {
+ Object datum = avroDatastream.next();
+ if(lineno >= startLine) {
+ String record = "\n\n Record " + lineno + ":\n";
+ outputStream.write(record.getBytes("UTF-8"));
+ avroWriter.write(datum, encoder);
+ encoder.flush();
+ }
+ lineno++;
+ }
+ } catch(IOException e) {
+ outputStream.write(("Error in display avro file: " + e.getLocalizedMessage()).getBytes("UTF-8"));
+ throw e;
+ } finally {
+ avroDatastream.close();
+ }
+ }
}
src/java/azkaban/fsviewers/HdfsFileViewer.java 24(+12 -12)
diff --git a/src/java/azkaban/fsviewers/HdfsFileViewer.java b/src/java/azkaban/fsviewers/HdfsFileViewer.java
index a956b7b..60d4c6f 100644
--- a/src/java/azkaban/fsviewers/HdfsFileViewer.java
+++ b/src/java/azkaban/fsviewers/HdfsFileViewer.java
@@ -14,22 +14,22 @@
* the License.
*/
-package azkaban.fsviewers;
+package azkaban.fsviewers;
-import java.io.IOException;
-import java.io.OutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
-public interface HdfsFileViewer {
+public interface HdfsFileViewer {
- public boolean canReadFile(FileSystem fs, Path path);
+ public boolean canReadFile(FileSystem fs, Path path);
- public void displayFile(FileSystem fs,
- Path path,
- OutputStream outStream,
- int startLine,
- int endLine) throws IOException;
+ public void displayFile(FileSystem fs,
+ Path path,
+ OutputStream outStream,
+ int startLine,
+ int endLine) throws IOException;
}
\ No newline at end of file
diff --git a/src/java/azkaban/fsviewers/HdfsSequenceFileViewer.java b/src/java/azkaban/fsviewers/HdfsSequenceFileViewer.java
index 57f2887..1372da6 100644
--- a/src/java/azkaban/fsviewers/HdfsSequenceFileViewer.java
+++ b/src/java/azkaban/fsviewers/HdfsSequenceFileViewer.java
@@ -26,42 +26,42 @@ import org.apache.hadoop.io.SequenceFile;
public abstract class HdfsSequenceFileViewer implements HdfsFileViewer {
- protected abstract boolean canReadFile(SequenceFile.Reader reader);
+ protected abstract boolean canReadFile(SequenceFile.Reader reader);
- protected abstract void displaySequenceFile(SequenceFile.Reader reader,
- PrintWriter output,
- int startLine,
- int endLine) throws IOException;
+ protected abstract void displaySequenceFile(SequenceFile.Reader reader,
+ PrintWriter output,
+ int startLine,
+ int endLine) throws IOException;
- public boolean canReadFile(FileSystem fs, Path file) {
- boolean result = false;
- try {
- SequenceFile.Reader reader = new SequenceFile.Reader(fs, file, new Configuration());
- result = canReadFile(reader);
- reader.close();
- } catch(IOException e) {
- return false;
- }
+ public boolean canReadFile(FileSystem fs, Path file) {
+ boolean result = false;
+ try {
+ SequenceFile.Reader reader = new SequenceFile.Reader(fs, file, new Configuration());
+ result = canReadFile(reader);
+ reader.close();
+ } catch(IOException e) {
+ return false;
+ }
- return result;
- }
+ return result;
+ }
- public void displayFile(FileSystem fs,
- Path file,
- OutputStream outputStream,
- int startLine,
- int endLine) throws IOException {
- SequenceFile.Reader reader = null;
- PrintWriter writer = new PrintWriter(outputStream);
- try {
- reader = new SequenceFile.Reader(fs, file, new Configuration());
- displaySequenceFile(reader, writer, startLine, endLine);
- } catch(IOException e) {
- writer.write("Error opening sequence file " + e);
- } finally {
- if(reader != null) {
- reader.close();
- }
- }
- }
+ public void displayFile(FileSystem fs,
+ Path file,
+ OutputStream outputStream,
+ int startLine,
+ int endLine) throws IOException {
+ SequenceFile.Reader reader = null;
+ PrintWriter writer = new PrintWriter(outputStream);
+ try {
+ reader = new SequenceFile.Reader(fs, file, new Configuration());
+ displaySequenceFile(reader, writer, startLine, endLine);
+ } catch(IOException e) {
+ writer.write("Error opening sequence file " + e);
+ } finally {
+ if(reader != null) {
+ reader.close();
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/src/java/azkaban/fsviewers/JsonSequenceFileViewer.java b/src/java/azkaban/fsviewers/JsonSequenceFileViewer.java
index 9400e3d..7e4842e 100644
--- a/src/java/azkaban/fsviewers/JsonSequenceFileViewer.java
+++ b/src/java/azkaban/fsviewers/JsonSequenceFileViewer.java
@@ -29,57 +29,57 @@ import voldemort.serialization.json.JsonTypeSerializer;
public class JsonSequenceFileViewer extends HdfsSequenceFileViewer {
- private static Logger logger = Logger.getLogger(JsonSequenceFileViewer.class);
-
- public boolean canReadFile(Reader reader) {
- Text keySchema = reader.getMetadata().get(new Text("key.schema"));
- Text valueSchema = reader.getMetadata().get(new Text("value.schema"));
-
- return keySchema != null && valueSchema != null;
- }
-
- public void displaySequenceFile(SequenceFile.Reader reader,
- PrintWriter output,
- int startLine,
- int endLine) throws IOException {
-
- if(logger.isDebugEnabled())
- logger.debug("display json file");
-
- try {
- BytesWritable keyWritable = new BytesWritable();
- BytesWritable valueWritable = new BytesWritable();
- Text keySchema = reader.getMetadata().get(new Text("key.schema"));
- Text valueSchema = reader.getMetadata().get(new Text("value.schema"));
-
- JsonTypeSerializer keySerializer = new JsonTypeSerializer(keySchema.toString());
- JsonTypeSerializer valueSerializer = new JsonTypeSerializer(valueSchema.toString());
-
- // skip lines before the start line
- for(int i = 1; i < startLine; i++)
- reader.next(keyWritable, valueWritable);
-
- // now actually output lines
- for(int i = startLine; i <= endLine; i++) {
- boolean readSomething = reader.next(keyWritable, valueWritable);
- if(!readSomething)
- break;
- output.write(safeToString(keySerializer.toObject(keyWritable.getBytes())));
- output.write("\t=>\t");
- output.write(safeToString(valueSerializer.toObject(valueWritable.getBytes())));
- output.write("\n");
- output.flush();
- }
- } finally {
- reader.close();
- }
- }
-
- private String safeToString(Object value) {
- if(value == null)
- return "null";
- else
- return value.toString();
- }
+ private static Logger logger = Logger.getLogger(JsonSequenceFileViewer.class);
+
+ public boolean canReadFile(Reader reader) {
+ Text keySchema = reader.getMetadata().get(new Text("key.schema"));
+ Text valueSchema = reader.getMetadata().get(new Text("value.schema"));
+
+ return keySchema != null && valueSchema != null;
+ }
+
+ public void displaySequenceFile(SequenceFile.Reader reader,
+ PrintWriter output,
+ int startLine,
+ int endLine) throws IOException {
+
+ if(logger.isDebugEnabled())
+ logger.debug("display json file");
+
+ try {
+ BytesWritable keyWritable = new BytesWritable();
+ BytesWritable valueWritable = new BytesWritable();
+ Text keySchema = reader.getMetadata().get(new Text("key.schema"));
+ Text valueSchema = reader.getMetadata().get(new Text("value.schema"));
+
+ JsonTypeSerializer keySerializer = new JsonTypeSerializer(keySchema.toString());
+ JsonTypeSerializer valueSerializer = new JsonTypeSerializer(valueSchema.toString());
+
+ // skip lines before the start line
+ for(int i = 1; i < startLine; i++)
+ reader.next(keyWritable, valueWritable);
+
+ // now actually output lines
+ for(int i = startLine; i <= endLine; i++) {
+ boolean readSomething = reader.next(keyWritable, valueWritable);
+ if(!readSomething)
+ break;
+ output.write(safeToString(keySerializer.toObject(keyWritable.getBytes())));
+ output.write("\t=>\t");
+ output.write(safeToString(valueSerializer.toObject(valueWritable.getBytes())));
+ output.write("\n");
+ output.flush();
+ }
+ } finally {
+ reader.close();
+ }
+ }
+
+ private String safeToString(Object value) {
+ if(value == null)
+ return "null";
+ else
+ return value.toString();
+ }
}
\ No newline at end of file
src/java/azkaban/fsviewers/TextFileViewer.java 90(+45 -45)
diff --git a/src/java/azkaban/fsviewers/TextFileViewer.java b/src/java/azkaban/fsviewers/TextFileViewer.java
index 8467c39..f9d301c 100644
--- a/src/java/azkaban/fsviewers/TextFileViewer.java
+++ b/src/java/azkaban/fsviewers/TextFileViewer.java
@@ -30,53 +30,53 @@ import org.apache.log4j.Logger;
public class TextFileViewer implements HdfsFileViewer {
- private static Logger logger = Logger.getLogger(TextFileViewer.class);
- private HashSet<String> acceptedSuffix = new HashSet<String>();
+ private static Logger logger = Logger.getLogger(TextFileViewer.class);
+ private HashSet<String> acceptedSuffix = new HashSet<String>();
- public TextFileViewer() {
- acceptedSuffix.add(".txt");
- acceptedSuffix.add(".csv");
- acceptedSuffix.add(".props");
- acceptedSuffix.add(".xml");
- acceptedSuffix.add(".html");
- acceptedSuffix.add(".json");
- acceptedSuffix.add(".log");
- }
+ public TextFileViewer() {
+ acceptedSuffix.add(".txt");
+ acceptedSuffix.add(".csv");
+ acceptedSuffix.add(".props");
+ acceptedSuffix.add(".xml");
+ acceptedSuffix.add(".html");
+ acceptedSuffix.add(".json");
+ acceptedSuffix.add(".log");
+ }
- public boolean canReadFile(FileSystem fs, Path path) {
- return true;
- }
+ public boolean canReadFile(FileSystem fs, Path path) {
+ return true;
+ }
- public void displayFile(FileSystem fs,
- Path path,
- OutputStream outputStream,
- int startLine,
- int endLine) throws IOException {
+ public void displayFile(FileSystem fs,
+ Path path,
+ OutputStream outputStream,
+ int startLine,
+ int endLine) throws IOException {
- if(logger.isDebugEnabled())
- logger.debug("read in uncompressed text file");
- InputStream inputStream = fs.open(path);
- BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
- PrintWriter output = new PrintWriter(outputStream);
- for(int i = 1; i < startLine; i++)
- reader.readLine();
-
- final int bufferLimit = 1000000; //only display the first 1M chars. it is used to prevent showing/downloading gb of data
- int bufferSize = 0;
- for(int i = startLine; i < endLine; i++) {
- String line = reader.readLine();
- if(line == null)
- break;
-
- // bread if reach the buffer limit
- bufferSize += line.length();
- if (bufferSize >= bufferLimit)
- break;
-
- output.write(line);
- output.write("\n");
- }
- output.flush();
- reader.close();
- }
+ if(logger.isDebugEnabled())
+ logger.debug("read in uncompressed text file");
+ InputStream inputStream = fs.open(path);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+ PrintWriter output = new PrintWriter(outputStream);
+ for(int i = 1; i < startLine; i++)
+ reader.readLine();
+
+ final int bufferLimit = 1000000; //only display the first 1M chars. it is used to prevent showing/downloading gb of data
+ int bufferSize = 0;
+ for(int i = startLine; i < endLine; i++) {
+ String line = reader.readLine();
+ if(line == null)
+ break;
+
+ // bread if reach the buffer limit
+ bufferSize += line.length();
+ if (bufferSize >= bufferLimit)
+ break;
+
+ output.write(line);
+ output.write("\n");
+ }
+ output.flush();
+ reader.close();
+ }
}
\ No newline at end of file
src/java/azkaban/jobExecutor/AbstractJob.java 156(+76 -80)
diff --git a/src/java/azkaban/jobExecutor/AbstractJob.java b/src/java/azkaban/jobExecutor/AbstractJob.java
index 99f08d7..4e5f573 100644
--- a/src/java/azkaban/jobExecutor/AbstractJob.java
+++ b/src/java/azkaban/jobExecutor/AbstractJob.java
@@ -23,86 +23,82 @@ import azkaban.utils.Props;
public abstract class AbstractJob implements Job {
public static final String JOB_TYPE = "type";
- public static final String JOB_CLASS = "job.class";
- public static final String JOB_PATH = "job.path";
- public static final String JOB_FULLPATH = "job.fullpath";
- public static final String JOB_ID = "job.id";
-
+ public static final String JOB_CLASS = "job.class";
+ public static final String JOB_PATH = "job.path";
+ public static final String JOB_FULLPATH = "job.fullpath";
+ public static final String JOB_ID = "job.id";
- private final String _id;
- private final Logger _log;
- private volatile double _progress;
-
-// protected AbstractJob(String id) {
-// this(id, Logger.getLogger(id));
-// }
-
- protected AbstractJob(String id, Logger log) {
- _id = id;
- _log = log;
- _progress = 0.0;
- }
-
- public String getId() {
- return _id;
- }
-
- public double getProgress() throws Exception {
- return _progress;
- }
-
- public void setProgress(double progress) {
- this._progress = progress;
- }
-
- public void cancel() throws Exception {
- throw new RuntimeException("Job " + _id + " does not support cancellation!");
- }
-
- public Logger getLog() {
- return this._log;
- }
-
- public void debug(String message) {
- this._log.debug(message);
- }
-
- public void debug(String message, Throwable t) {
- this._log.debug(message, t);
- }
-
- public void info(String message) {
- this._log.info(message);
- }
-
- public void info(String message, Throwable t) {
- this._log.info(message, t);
- }
-
- public void warn(String message) {
- this._log.warn(message);
- }
-
- public void warn(String message, Throwable t) {
- this._log.warn(message, t);
- }
-
- public void error(String message) {
- this._log.error(message);
- }
-
- public void error(String message, Throwable t) {
- this._log.error(message, t);
- }
-
- public Props getJobGeneratedProperties() {
- return new Props();
- }
-
- public abstract void run() throws Exception;
-
- public boolean isCanceled() {
- return false;
- }
+
+ private final String _id;
+ private final Logger _log;
+ private volatile double _progress;
+
+ protected AbstractJob(String id, Logger log) {
+ _id = id;
+ _log = log;
+ _progress = 0.0;
+ }
+
+ public String getId() {
+ return _id;
+ }
+
+ public double getProgress() throws Exception {
+ return _progress;
+ }
+
+ public void setProgress(double progress) {
+ this._progress = progress;
+ }
+
+ public void cancel() throws Exception {
+ throw new RuntimeException("Job " + _id + " does not support cancellation!");
+ }
+
+ public Logger getLog() {
+ return this._log;
+ }
+
+ public void debug(String message) {
+ this._log.debug(message);
+ }
+
+ public void debug(String message, Throwable t) {
+ this._log.debug(message, t);
+ }
+
+ public void info(String message) {
+ this._log.info(message);
+ }
+
+ public void info(String message, Throwable t) {
+ this._log.info(message, t);
+ }
+
+ public void warn(String message) {
+ this._log.warn(message);
+ }
+
+ public void warn(String message, Throwable t) {
+ this._log.warn(message, t);
+ }
+
+ public void error(String message) {
+ this._log.error(message);
+ }
+
+ public void error(String message, Throwable t) {
+ this._log.error(message, t);
+ }
+
+ public Props getJobGeneratedProperties() {
+ return new Props();
+ }
+
+ public abstract void run() throws Exception;
+
+ public boolean isCanceled() {
+ return false;
+ }
}
src/java/azkaban/jobExecutor/AbstractProcessJob.java 300(+146 -154)
diff --git a/src/java/azkaban/jobExecutor/AbstractProcessJob.java b/src/java/azkaban/jobExecutor/AbstractProcessJob.java
index 2ec0e05..7fa242a 100644
--- a/src/java/azkaban/jobExecutor/AbstractProcessJob.java
+++ b/src/java/azkaban/jobExecutor/AbstractProcessJob.java
@@ -30,7 +30,7 @@ import org.apache.log4j.Logger;
import azkaban.utils.JSONUtils;
import azkaban.utils.Props;
-import azkaban.jobExecutor.utils.PropsUtils;
+import azkaban.utils.PropsUtils;
/*
* A revised process-based job
@@ -38,159 +38,151 @@ import azkaban.jobExecutor.utils.PropsUtils;
*/
public abstract class AbstractProcessJob extends AbstractJob {
-// private static final Logger log = Logger
-// .getLogger(AbstractProcessJob.class);
-
private final Logger log;
- public static final String ENV_PREFIX = "env.";
- public static final String ENV_PREFIX_UCASE = "ENV.";
- public static final String WORKING_DIR = "working.dir";
- public static final String JOB_PROP_ENV = "JOB_PROP_FILE";
- public static final String JOB_NAME_ENV = "JOB_NAME";
- public static final String JOB_OUTPUT_PROP_FILE = "JOB_OUTPUT_PROP_FILE";
-
- protected final String _jobPath;
-
-// protected final Props props;
- protected volatile Props _props;
-
- protected String _cwd;
-
- private volatile Props generatedPropeties;
-
- protected AbstractProcessJob(String jobid, final Props props, final Logger log) {
- super(jobid, log);
-
- _props = props;
- _jobPath = props.getString(JOB_FULLPATH, props.getSource());
-
- _cwd = getWorkingDirectory();
- this.log = log;
- }
-
- public Props getProps() {
- return _props;
- }
-
- public String getJobPath() {
- return _jobPath;
- }
-
- protected void resolveProps() {
- _props = PropsUtils.resolveProps(_props);
- }
-
- @Override
- public Props getJobGeneratedProperties() {
- return generatedPropeties;
- }
-
- /**
- * initialize temporary and final property file
- *
- * @return {tmpPropFile, outputPropFile}
- */
- public File[] initPropsFiles() {
- // Create properties file with additionally all input generated
- // properties.
- File[] files = new File[2];
- files[0] = createFlattenedPropsFile(_cwd);
-
- _props.put(ENV_PREFIX + JOB_PROP_ENV, files[0].getAbsolutePath());
- _props.put(ENV_PREFIX + JOB_NAME_ENV, getId());
-
- files[1] = createOutputPropsFile(getId(), _cwd);
- _props.put(ENV_PREFIX + JOB_OUTPUT_PROP_FILE,
- files[1].getAbsolutePath());
-
- return files;
- }
-
- public String getCwd() {
- return _cwd;
- }
-
- public Map<String, String> getEnvironmentVariables() {
- Props props = getProps();
- Map<String, String> envMap = props.getMapByPrefix(ENV_PREFIX);
- envMap.putAll(props.getMapByPrefix(ENV_PREFIX_UCASE));
- return envMap;
- }
-
- public String getWorkingDirectory() {
- return getProps()//.getString(WORKING_DIR, ".");
- .getString(WORKING_DIR, new File(_jobPath).getAbsolutePath());
- }
-
- public Props loadOutputFileProps(final File outputPropertiesFile) {
- InputStream reader = null;
- try {
- System.err.println("output properties file="
- + outputPropertiesFile.getAbsolutePath());
- reader = new BufferedInputStream(new FileInputStream(
- outputPropertiesFile));
-
- Props outputProps = new Props();
- final String content = Streams.asString(reader).trim();
-
- if (!content.isEmpty()) {
- Map<String, Object> propMap = (Map<String, Object>)JSONUtils.parseJSONFromString(content);
-
- for (Map.Entry<String, Object> entry : propMap.entrySet()) {
- outputProps
- .put(entry.getKey(), entry.getValue().toString());
- }
- }
- return outputProps;
- } catch (FileNotFoundException e) {
- log.info(String.format(
- "File[%s] wasn't found, returning empty props.",
- outputPropertiesFile));
- return new Props();
- } catch (Exception e) {
- log.error(
- "Exception thrown when trying to load output file props. Returning empty Props instead of failing. Is this really the best thing to do?",
- e);
- return new Props();
- } finally {
- IOUtils.closeQuietly(reader);
- }
- }
-
- public File createFlattenedPropsFile(final String workingDir) {
- File directory = new File(workingDir);
- File tempFile = null;
- try {
- tempFile = File.createTempFile(getId() + "_", "_tmp", directory);
- _props.storeFlattened(tempFile);
- } catch (IOException e) {
- throw new RuntimeException("Failed to create temp property file ",
- e);
- }
-
- return tempFile;
- }
-
- public static File createOutputPropsFile(final String id,
- final String workingDir) {
- System.err.println("cwd=" + workingDir);
-
- File directory = new File(workingDir);
- File tempFile = null;
- try {
- tempFile = File.createTempFile(id + "_output_", "_tmp", directory);
- } catch (IOException e) {
- System.err
- .println("Failed to create temp output property file :\n");
- e.printStackTrace(System.err);
- throw new RuntimeException(
- "Failed to create temp output property file ", e);
- }
- return tempFile;
- }
-
- public void generateProperties(final File outputFile) {
- generatedPropeties = loadOutputFileProps(outputFile);
- }
+ public static final String ENV_PREFIX = "env.";
+ public static final String ENV_PREFIX_UCASE = "ENV.";
+ public static final String WORKING_DIR = "working.dir";
+ public static final String JOB_PROP_ENV = "JOB_PROP_FILE";
+ public static final String JOB_NAME_ENV = "JOB_NAME";
+ public static final String JOB_OUTPUT_PROP_FILE = "JOB_OUTPUT_PROP_FILE";
+
+ protected final String _jobPath;
+
+ protected volatile Props _props;
+
+ protected String _cwd;
+
+ private volatile Props generatedPropeties;
+
+ protected AbstractProcessJob(String jobid, final Props props, final Logger log) {
+ super(jobid, log);
+
+ _props = props;
+ _jobPath = props.getString(JOB_FULLPATH, props.getSource());
+
+ _cwd = getWorkingDirectory();
+ this.log = log;
+ }
+
+ public Props getProps() {
+ return _props;
+ }
+
+ public String getJobPath() {
+ return _jobPath;
+ }
+
+ protected void resolveProps() {
+ _props = PropsUtils.resolveProps(_props);
+ }
+
+ @Override
+ public Props getJobGeneratedProperties() {
+ return generatedPropeties;
+ }
+
+ /**
+ * initialize temporary and final property file
+ *
+ * @return {tmpPropFile, outputPropFile}
+ */
+ public File[] initPropsFiles() {
+ // Create properties file with additionally all input generated properties.
+ File[] files = new File[2];
+ files[0] = createFlattenedPropsFile(_cwd);
+
+ _props.put(ENV_PREFIX + JOB_PROP_ENV, files[0].getAbsolutePath());
+ _props.put(ENV_PREFIX + JOB_NAME_ENV, getId());
+
+ files[1] = createOutputPropsFile(getId(), _cwd);
+ _props.put(ENV_PREFIX + JOB_OUTPUT_PROP_FILE,
+ files[1].getAbsolutePath());
+
+ return files;
+ }
+
+ public String getCwd() {
+ return _cwd;
+ }
+
+ public Map<String, String> getEnvironmentVariables() {
+ Props props = getProps();
+ Map<String, String> envMap = props.getMapByPrefix(ENV_PREFIX);
+ envMap.putAll(props.getMapByPrefix(ENV_PREFIX_UCASE));
+ return envMap;
+ }
+
+ public String getWorkingDirectory() {
+ String workingDir = getProps().getString(WORKING_DIR, _jobPath);
+ if (workingDir == null) {
+ return "";
+ }
+
+ return workingDir;
+ }
+
+ public Props loadOutputFileProps(final File outputPropertiesFile) {
+ InputStream reader = null;
+ try {
+ System.err.println("output properties file=" + outputPropertiesFile.getAbsolutePath());
+ reader = new BufferedInputStream(new FileInputStream(outputPropertiesFile));
+
+ Props outputProps = new Props();
+ final String content = Streams.asString(reader).trim();
+
+ if (!content.isEmpty()) {
+ Map<String, Object> propMap = (Map<String, Object>)JSONUtils.parseJSONFromString(content);
+
+ for (Map.Entry<String, Object> entry : propMap.entrySet()) {
+ outputProps.put(entry.getKey(), entry.getValue().toString());
+ }
+ }
+ return outputProps;
+ } catch (FileNotFoundException e) {
+ log.info(String.format(
+ "File[%s] wasn't found, returning empty props.",
+ outputPropertiesFile));
+ return new Props();
+ } catch (Exception e) {
+ log.error(
+ "Exception thrown when trying to load output file props. Returning empty Props instead of failing. Is this really the best thing to do?",
+ e);
+ return new Props();
+ } finally {
+ IOUtils.closeQuietly(reader);
+ }
+ }
+
+ public File createFlattenedPropsFile(final String workingDir) {
+ File directory = new File(workingDir);
+ File tempFile = null;
+ try {
+ tempFile = File.createTempFile(getId() + "_", "_tmp", directory);
+ _props.storeFlattened(tempFile);
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to create temp property file ", e);
+ }
+
+ return tempFile;
+ }
+
+ public static File createOutputPropsFile(final String id, final String workingDir) {
+ System.err.println("cwd=" + workingDir);
+
+ File directory = new File(workingDir);
+ File tempFile = null;
+ try {
+ tempFile = File.createTempFile(id + "_output_", "_tmp", directory);
+ } catch (IOException e) {
+ System.err.println("Failed to create temp output property file :\n");
+ e.printStackTrace(System.err);
+ throw new RuntimeException("Failed to create temp output property file ", e);
+ }
+ return tempFile;
+ }
+
+ public void generateProperties(final File outputFile) {
+ generatedPropeties = loadOutputFileProps(outputFile);
+ }
}
src/java/azkaban/jobExecutor/JavaJob.java 77(+37 -40)
diff --git a/src/java/azkaban/jobExecutor/JavaJob.java b/src/java/azkaban/jobExecutor/JavaJob.java
index 5b4b6ec..99f1bb1 100644
--- a/src/java/azkaban/jobExecutor/JavaJob.java
+++ b/src/java/azkaban/jobExecutor/JavaJob.java
@@ -48,51 +48,48 @@ public class JavaJob extends JavaProcessJob {
}
@Override
- protected List<String> getClassPaths() {
- List<String> classPath = super.getClassPaths();
-
- classPath.add(getSourcePathFromClass(JavaJobRunnerMain.class));
- String loggerPath = getSourcePathFromClass(org.apache.log4j.Logger.class);
- if (!classPath.contains(loggerPath)) {
- classPath.add(loggerPath);
- }
-
- // Add hadoop home to classpath
- String hadoopHome = System.getenv("HADOOP_HOME");
- if (hadoopHome == null) {
- info("HADOOP_HOME not set, using default hadoop config.");
- } else {
- info("Using hadoop config found in " + hadoopHome);
- classPath.add(new File(hadoopHome, "conf").getPath());
- }
-
- return classPath;
+ protected List<String> getClassPaths() {
+ List<String> classPath = super.getClassPaths();
+
+ classPath.add(getSourcePathFromClass(JavaJobRunnerMain.class));
+ String loggerPath = getSourcePathFromClass(org.apache.log4j.Logger.class);
+ if (!classPath.contains(loggerPath)) {
+ classPath.add(loggerPath);
+ }
+
+ // Add hadoop home to classpath
+ String hadoopHome = System.getenv("HADOOP_HOME");
+ if (hadoopHome == null) {
+ info("HADOOP_HOME not set, using default hadoop config.");
+ } else {
+ info("Using hadoop config found in " + hadoopHome);
+ classPath.add(new File(hadoopHome, "conf").getPath());
+ }
+ return classPath;
}
private static String getSourcePathFromClass(Class containedClass) {
- File file = new File(containedClass.getProtectionDomain().getCodeSource().getLocation().getPath());
-
- if (!file.isDirectory() && file.getName().endsWith(".class")) {
- String name = containedClass.getName();
- StringTokenizer tokenizer = new StringTokenizer(name, ".");
- while(tokenizer.hasMoreTokens()) {
- tokenizer.nextElement();
-
- file = file.getParentFile();
- }
-
- return file.getPath();
- }
- else {
- return containedClass.getProtectionDomain().getCodeSource().getLocation().getPath();
- }
+ File file = new File(containedClass.getProtectionDomain().getCodeSource().getLocation().getPath());
+
+ if (!file.isDirectory() && file.getName().endsWith(".class")) {
+ String name = containedClass.getName();
+ StringTokenizer tokenizer = new StringTokenizer(name, ".");
+ while(tokenizer.hasMoreTokens()) {
+ tokenizer.nextElement();
+ file = file.getParentFile();
+ }
+ return file.getPath();
+ }
+ else {
+ return containedClass.getProtectionDomain().getCodeSource().getLocation().getPath();
+ }
}
- @Override
- protected String getJavaClass() {
- return JavaJobRunnerMain.class.getName();
- }
-
+ @Override
+ protected String getJavaClass() {
+ return JavaJobRunnerMain.class.getName();
+ }
+
@Override
public String toString() {
return "JavaJob{" + "_runMethod='" + _runMethod + '\''
diff --git a/src/java/azkaban/jobExecutor/JavaJobRunnerMain.java b/src/java/azkaban/jobExecutor/JavaJobRunnerMain.java
index 5b5c4b2..8ff780f 100644
--- a/src/java/azkaban/jobExecutor/JavaJobRunnerMain.java
+++ b/src/java/azkaban/jobExecutor/JavaJobRunnerMain.java
@@ -16,10 +16,12 @@
package azkaban.jobExecutor;
+import azkaban.utils.JSONUtils;
import azkaban.utils.Props;
import azkaban.utils.SecurityUtils;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.security.UserGroupInformation;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Layout;
import org.apache.log4j.Logger;
@@ -34,7 +36,6 @@ import java.io.OutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.lang.reflect.UndeclaredThrowableException;
import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -127,11 +128,17 @@ public class JavaJobRunnerMain {
final Method generatedPropertiesMethod = _javaObject.getClass().getMethod(
GET_GENERATED_PROPERTIES_METHOD, new Class<?>[] {});
Object outputGendProps = generatedPropertiesMethod.invoke(_javaObject, new Object[] {});
- final Method toPropertiesMethod = outputGendProps.getClass().getMethod("toProperties", new Class<?>[] {});
- Properties properties = (Properties)toPropertiesMethod.invoke(outputGendProps, new Object[] {});
-
- Props outputProps = new Props(null, properties);
- outputGeneratedProperties(outputProps);
+ if(outputGendProps != null) {
+ final Method toPropertiesMethod = outputGendProps.getClass().getMethod("toProperties", new Class<?>[] {});
+ Properties properties = (Properties)toPropertiesMethod.invoke(outputGendProps, new Object[] {});
+
+ Props outputProps = new Props(null, properties);
+ outputGeneratedProperties(outputProps);
+ }
+ else {
+ outputGeneratedProperties(new Props());
+ }
+
} catch (NoSuchMethodException e) {
_logger.info(String.format(
"Apparently there isn't a method[%s] on object[%s], using empty Props object instead.",
@@ -146,6 +153,9 @@ public class JavaJobRunnerMain {
private void runMethodAsProxyUser(Properties prop, final Object obj, final String runMethod) throws IOException,
InterruptedException {
+ UserGroupInformation ugi = SecurityUtils.getProxiedUser(prop, _logger, new Configuration());
+ _logger.info("user " + ugi + " authenticationMethod " + ugi.getAuthenticationMethod());
+ _logger.info("user " + ugi + " hasKerberosCredentials " + ugi.hasKerberosCredentials());
SecurityUtils.getProxiedUser(prop, _logger, new Configuration()).doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
@@ -161,8 +171,7 @@ public class JavaJobRunnerMain {
}
private void outputGeneratedProperties(Props outputProperties) {
- _logger.info("Outputting generated properties to " + ProcessJob.JOB_OUTPUT_PROP_FILE);
-
+
if (outputProperties == null) {
_logger.info(" no gend props");
return;
@@ -175,6 +184,8 @@ public class JavaJobRunnerMain {
if (outputFileStr == null) {
return;
}
+
+ _logger.info("Outputting generated properties to " + outputFileStr);
Map<String, String> properties = new LinkedHashMap<String, String>();
for (String key : outputProperties.getKeySet()) {
@@ -184,12 +195,14 @@ public class JavaJobRunnerMain {
OutputStream writer = null;
try {
writer = new BufferedOutputStream(new FileOutputStream(outputFileStr));
+
// Manually serialize into JSON instead of adding org.json to
- // external classpath
+ // external classpath. Reduces one dependency for something that's essentially easy.
writer.write("{\n".getBytes());
for (Map.Entry<String, String> entry : properties.entrySet()) {
- writer.write(String.format(" '%s':'%s',\n", entry.getKey().replace("'", "\\'"),
- entry.getValue().replace("'", "\\'")).getBytes());
+ writer.write(String.format(" \"%s\":\"%s\",\n",
+ entry.getKey().replace("\"", "\\\\\""),
+ entry.getValue().replace("\"", "\\\\\"")).getBytes());
}
writer.write("}".getBytes());
} catch (Exception e) {
@@ -255,7 +268,12 @@ public class JavaJobRunnerMain {
Class<?> propsClass = null;
for (String propClassName : PROPS_CLASSES) {
- propsClass = JavaJobRunnerMain.class.getClassLoader().loadClass(propClassName);
+ try {
+ propsClass = JavaJobRunnerMain.class.getClassLoader().loadClass(propClassName);
+ }
+ catch (ClassNotFoundException e) {
+ }
+
if (propsClass != null && getConstructor(runningClass, String.class, propsClass) != null) {
//is this the props class
break;
src/java/azkaban/jobExecutor/JavaProcessJob.java 33(+16 -17)
diff --git a/src/java/azkaban/jobExecutor/JavaProcessJob.java b/src/java/azkaban/jobExecutor/JavaProcessJob.java
index 1bf992b..1b3d115 100644
--- a/src/java/azkaban/jobExecutor/JavaProcessJob.java
+++ b/src/java/azkaban/jobExecutor/JavaProcessJob.java
@@ -25,10 +25,7 @@ import org.apache.log4j.Logger;
import azkaban.utils.Props;
public class JavaProcessJob extends ProcessJob {
-// private static final Logger log = Logger
-// .getLogger(JavaProcessJob.class);
-// private Logger log;
-
+
public static final String CLASSPATH = "classpath";
public static final String GLOBAL_CLASSPATH = "global.classpaths";
public static final String JAVA_CLASS = "java.class";
@@ -82,24 +79,26 @@ public class JavaProcessJob extends ProcessJob {
protected List<String> getClassPaths() {
List<String> classPaths = getProps().getStringList(CLASSPATH, null, ",");
- ArrayList<String> classpathList = new ArrayList<String>();
- // Adding global properties used system wide.
- if (getProps().containsKey(GLOBAL_CLASSPATH)) {
- List<String> globalClasspath = getProps().getStringList(GLOBAL_CLASSPATH);
- for (String global: globalClasspath) {
- getLog().info("Adding to global classpath:" + global);
- classpathList.add(global);
- }
- }
+ ArrayList<String> classpathList = new ArrayList<String>();
+ // Adding global properties used system wide.
+ if (getProps().containsKey(GLOBAL_CLASSPATH)) {
+ List<String> globalClasspath = getProps().getStringList(GLOBAL_CLASSPATH);
+ for (String global: globalClasspath) {
+ getLog().info("Adding to global classpath:" + global);
+ classpathList.add(global);
+ }
+ }
if (classPaths == null) {
File path = new File(getPath());
File parent = path.getParentFile();
- for (File file : parent.listFiles()) {
- if (file.getName().endsWith(".jar")) {
- // log.info("Adding to classpath:" + file.getName());
- classpathList.add(file.getName());
+ if (parent != null) {
+ for (File file : parent.listFiles()) {
+ if (file.getName().endsWith(".jar")) {
+ // log.info("Adding to classpath:" + file.getName());
+ classpathList.add(file.getName());
+ }
}
}
}
diff --git a/src/java/azkaban/jobExecutor/LongArgJob.java b/src/java/azkaban/jobExecutor/LongArgJob.java
index 9a67de4..425ef57 100644
--- a/src/java/azkaban/jobExecutor/LongArgJob.java
+++ b/src/java/azkaban/jobExecutor/LongArgJob.java
@@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
import azkaban.utils.Props;
+import azkaban.utils.UndefinedPropertyException;
import azkaban.jobExecutor.utils.process.AzkabanProcess;
import azkaban.jobExecutor.utils.process.AzkabanProcessBuilder;
@@ -56,8 +57,14 @@ public abstract class LongArgJob extends AbstractProcessJob {
public void run() throws Exception {
- resolveProps();
-
+ try {
+ resolveProps();
+ }
+ catch (Exception e) {
+ error("Bad property definition! " + e.getMessage());
+
+ }
+
long startMs = System.currentTimeMillis();
info("Command: " + builder.getCommandString());
if(builder.getEnv().size() > 0)
diff --git a/src/java/azkaban/jobExecutor/PigProcessJob.java b/src/java/azkaban/jobExecutor/PigProcessJob.java
index d301c9b..ef0ddbf 100644
--- a/src/java/azkaban/jobExecutor/PigProcessJob.java
+++ b/src/java/azkaban/jobExecutor/PigProcessJob.java
@@ -16,8 +16,8 @@
package azkaban.jobExecutor;
-import azkaban.jobExecutor.utils.StringUtils;
import azkaban.utils.Props;
+import azkaban.utils.StringUtils;
import java.io.File;
import java.util.ArrayList;
@@ -28,11 +28,11 @@ import java.util.StringTokenizer;
import org.apache.log4j.Logger;
-import static azkaban.jobExecutor.SecurePigWrapper.OBTAIN_BINARY_TOKEN;
import static azkaban.utils.SecurityUtils.PROXY_KEYTAB_LOCATION;
import static azkaban.utils.SecurityUtils.PROXY_USER;
import static azkaban.utils.SecurityUtils.TO_PROXY;
import static azkaban.utils.SecurityUtils.shouldProxy;
+import static azkaban.jobExecutor.SecurePigWrapper.OBTAIN_BINARY_TOKEN;
public class PigProcessJob extends JavaProcessJob {
src/java/azkaban/jobExecutor/ProcessJob.java 60(+28 -32)
diff --git a/src/java/azkaban/jobExecutor/ProcessJob.java b/src/java/azkaban/jobExecutor/ProcessJob.java
index af6c21e..8d42a4d 100644
--- a/src/java/azkaban/jobExecutor/ProcessJob.java
+++ b/src/java/azkaban/jobExecutor/ProcessJob.java
@@ -16,24 +16,18 @@
package azkaban.jobExecutor;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.reflect.Field;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import azkaban.jobExecutor.utils.process.AzkabanProcess;
import azkaban.jobExecutor.utils.process.AzkabanProcessBuilder;
import azkaban.utils.Props;
+import azkaban.utils.UndefinedPropertyException;
/*
* A job that runs a simple unix command
@@ -42,8 +36,8 @@ import azkaban.utils.Props;
public class ProcessJob extends AbstractProcessJob {
public static final String COMMAND = "command";
- private static final long KILL_TIME_MS = 5000;
- private volatile AzkabanProcess process;
+ private static final long KILL_TIME_MS = 5000;
+ private volatile AzkabanProcess process;
public ProcessJob(final String jobId, final Props props, final Logger log) {
super(jobId, props, log);
@@ -51,7 +45,13 @@ public class ProcessJob extends AbstractProcessJob {
@Override
public void run() throws Exception {
- resolveProps();
+ try {
+ resolveProps();
+ }
+ catch (Exception e) {
+ error("Bad property definition! " + e.getMessage());
+
+ }
List<String> commands = getCommandList();
long startMs = System.currentTimeMillis();
@@ -78,7 +78,7 @@ public class ProcessJob extends AbstractProcessJob {
try {
this.process.run();
success = true;
- } catch (Exception e) {
+ } catch (Throwable e) {
for (File file : propFiles)
if (file != null && file.exists())
file.delete();
@@ -92,10 +92,6 @@ public class ProcessJob extends AbstractProcessJob {
// Get the output properties from this job.
generateProperties(propFiles[1]);
-
- for (File file : propFiles)
- if (file != null && file.exists())
- file.delete();
}
@@ -109,22 +105,22 @@ public class ProcessJob extends AbstractProcessJob {
return commands;
}
- @Override
- public void cancel() throws InterruptedException {
- if(process == null)
- throw new IllegalStateException("Not started.");
- boolean killed = process.softKill(KILL_TIME_MS, TimeUnit.MILLISECONDS);
- if(!killed) {
- warn("Kill with signal TERM failed. Killing with KILL signal.");
- process.hardKill();
- }
- }
-
- @Override
- public double getProgress() {
- return process != null && process.isComplete()? 1.0 : 0.0;
- }
-
+ @Override
+ public void cancel() throws InterruptedException {
+ if(process == null)
+ throw new IllegalStateException("Not started.");
+ boolean killed = process.softKill(KILL_TIME_MS, TimeUnit.MILLISECONDS);
+ if(!killed) {
+ warn("Kill with signal TERM failed. Killing with KILL signal.");
+ process.hardKill();
+ }
+ }
+
+ @Override
+ public double getProgress() {
+ return process != null && process.isComplete()? 1.0 : 0.0;
+ }
+
public int getProcessId() {
return process.getProcessId();
}
@@ -135,7 +131,7 @@ public class ProcessJob extends AbstractProcessJob {
}
public String getPath() {
- return _jobPath;
+ return _jobPath == null ? "" : _jobPath;
}
public String getJobName() {
diff --git a/src/java/azkaban/jobExecutor/SecurePigWrapper.java b/src/java/azkaban/jobExecutor/SecurePigWrapper.java
index 8e79c83..4eb3d98 100644
--- a/src/java/azkaban/jobExecutor/SecurePigWrapper.java
+++ b/src/java/azkaban/jobExecutor/SecurePigWrapper.java
@@ -67,6 +67,7 @@ public class SecurePigWrapper {
JobConf jc = new JobConf(conf);
JobClient jobClient = new JobClient(jc);
logger.info("Pre-fetching: Got new JobClient: " + jc);
+ //logger.info(conf.get("fs.default.name"));
Token<DelegationTokenIdentifier> mrdt = jobClient.getDelegationToken(new Text("hi"));
job.getCredentials().addToken(new Text("howdy"), mrdt);
diff --git a/src/java/azkaban/jobExecutor/utils/process/AzkabanProcess.java b/src/java/azkaban/jobExecutor/utils/process/AzkabanProcess.java
index 1fdda1b..f1d49ee 100644
--- a/src/java/azkaban/jobExecutor/utils/process/AzkabanProcess.java
+++ b/src/java/azkaban/jobExecutor/utils/process/AzkabanProcess.java
@@ -15,11 +15,9 @@
*/
package azkaban.jobExecutor.utils.process;
-import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.io.Reader;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
@@ -29,7 +27,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
-import azkaban.utils.CircularBuffer;
+import azkaban.utils.LogGobbler;
import com.google.common.base.Joiner;
@@ -41,18 +39,17 @@ import com.google.common.base.Joiner;
*
*/
public class AzkabanProcess {
-
private final String workingDir;
private final List<String> cmd;
private final Map<String, String> env;
private final Logger logger;
private final CountDownLatch startupLatch;
private final CountDownLatch completeLatch;
+
private volatile int processId;
private volatile Process process;
-
- public AzkabanProcess(final List<String> cmd, final Map<String, String> env, final String workingDir,
- final Logger logger) {
+
+ public AzkabanProcess(final List<String> cmd, final Map<String, String> env, final String workingDir, final Logger logger) {
this.cmd = cmd;
this.env = env;
this.workingDir = workingDir;
@@ -83,11 +80,9 @@ public class AzkabanProcess {
this.startupLatch.countDown();
- LogGobbler outputGobbler = new LogGobbler(new InputStreamReader(process.getInputStream()), logger, Level.INFO,
- 30);
- LogGobbler errorGobbler = new LogGobbler(new InputStreamReader(process.getErrorStream()), logger, Level.ERROR,
- 30);
-
+ LogGobbler outputGobbler = new LogGobbler(new InputStreamReader(process.getInputStream()), logger, Level.INFO, 30);
+ LogGobbler errorGobbler = new LogGobbler(new InputStreamReader(process.getErrorStream()), logger, Level.ERROR, 30);
+
outputGobbler.start();
errorGobbler.start();
int exitCode = -1;
@@ -222,50 +217,4 @@ public class AzkabanProcess {
public String toString() {
return "Process(cmd = " + Joiner.on(" ").join(cmd) + ", env = " + env + ", cwd = " + workingDir + ")";
}
-
- private static class LogGobbler extends Thread {
-
- private final BufferedReader inputReader;
- private final Logger logger;
- private final Level loggingLevel;
- private final CircularBuffer<String> buffer;
-
- public LogGobbler(final Reader inputReader, final Logger logger, final Level level, final int bufferLines) {
- this.inputReader = new BufferedReader(inputReader);
- this.logger = logger;
- this.loggingLevel = level;
- buffer = new CircularBuffer<String>(bufferLines);
- }
-
- @Override
- public void run() {
- try {
- while (!Thread.currentThread().isInterrupted()) {
- String line = inputReader.readLine();
- if (line == null) {
- return;
- }
-
- buffer.append(line);
- logger.log(loggingLevel, line);
- }
- } catch (IOException e) {
- logger.error("Error reading from logging stream:", e);
- }
- }
-
- public void awaitCompletion(final long waitMs) {
- try {
- join(waitMs);
- } catch (InterruptedException e) {
- logger.info("I/O thread interrupted.", e);
- }
- }
-
- public String getRecentLog() {
- return Joiner.on(System.getProperty("line.separator")).join(buffer);
- }
-
- }
-
}
src/java/azkaban/jobtype/JobtypeManager.java 222(+222 -0)
diff --git a/src/java/azkaban/jobtype/JobtypeManager.java b/src/java/azkaban/jobtype/JobtypeManager.java
new file mode 100644
index 0000000..f25336e
--- /dev/null
+++ b/src/java/azkaban/jobtype/JobtypeManager.java
@@ -0,0 +1,222 @@
+package azkaban.jobtype;
+
+/*
+ * Copyright 2012 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+import azkaban.jobExecutor.JavaJob;
+import azkaban.jobExecutor.JavaProcessJob;
+import azkaban.jobExecutor.Job;
+import azkaban.jobExecutor.NoopJob;
+import azkaban.jobExecutor.PigProcessJob;
+import azkaban.jobExecutor.ProcessJob;
+import azkaban.jobExecutor.PythonJob;
+import azkaban.jobExecutor.RubyJob;
+import azkaban.jobExecutor.ScriptJob;
+import azkaban.utils.Props;
+import azkaban.utils.Utils;
+import azkaban.jobExecutor.utils.JobExecutionException;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+public class JobtypeManager
+{
+
+ private final String jobtypePluginDir; // the dir for jobtype plugins
+ private final ClassLoader parentLoader;
+
+ private static final String jobtypeConfFile = "jobtype.conf"; // need jars.to.include property
+ private static final Logger logger = Logger.getLogger(JobtypeManager.class);
+
+ private Map<String, Class<? extends Job>> jobToClass;
+ private Map<String, Props> jobTypeProps;
+
+ public JobtypeManager(String jobtypePluginDir, ClassLoader parentClassLoader)
+ {
+ this.jobtypePluginDir = jobtypePluginDir;
+ this.parentLoader = parentClassLoader;
+
+ jobToClass = new HashMap<String, Class<? extends Job>>();
+ jobTypeProps = new HashMap<String, Props>();
+
+ loadDefaultTypes(jobToClass, jobTypeProps);
+
+ if(jobtypePluginDir != null) {
+ logger.info("job type plugin directory set. Loading extra job types.");
+ loadPluginJobTypes(jobToClass, jobTypeProps);;
+ }
+
+ }
+
+ private void loadDefaultTypes(Map<String, Class<? extends Job>> allJobTypes, Map<String, Props> jobTypeProps) throws JobtypeManagerException{
+ allJobTypes.put("java", JavaJob.class);
+ allJobTypes.put("command", ProcessJob.class);
+ allJobTypes.put("javaprocess", JavaProcessJob.class);
+ allJobTypes.put("pig", PigProcessJob.class);
+ allJobTypes.put("propertyPusher", NoopJob.class);
+ allJobTypes.put("python", PythonJob.class);
+ allJobTypes.put("ruby", RubyJob.class);
+ allJobTypes.put("script", ScriptJob.class);
+
+ jobTypeProps.put("java", new Props());
+ jobTypeProps.put("command", new Props());
+ jobTypeProps.put("javaprocess", new Props());
+ jobTypeProps.put("pig", new Props());
+ jobTypeProps.put("propertyPusher", new Props());
+ jobTypeProps.put("python", new Props());
+ jobTypeProps.put("ruby", new Props());
+ jobTypeProps.put("script", new Props());
+ }
+
+ // load Job Typs from dir
+ private void loadPluginJobTypes(Map<String, Class<? extends Job>> allJobTypes, Map<String, Props> jobTypeProps) throws JobtypeManagerException
+ {
+ if(jobtypePluginDir == null || parentLoader == null) throw new JobtypeManagerException("JobTypeDir not set! JobWrappingFactory not properly initiated!");
+
+ File jobPluginsDir = new File(jobtypePluginDir);
+ if(!jobPluginsDir.isDirectory()) throw new JobtypeManagerException("Job type plugin dir " + jobtypePluginDir + " is not a directory!");
+ if(!jobPluginsDir.canRead()) throw new JobtypeManagerException("Job type plugin dir " + jobtypePluginDir + " is not readable!");
+
+
+
+ for(File dir : jobPluginsDir.listFiles()) {
+ if(dir.isDirectory() && dir.canRead()) {
+ // get its conf file
+ try {
+ loadJobType(dir, allJobTypes, jobTypeProps);
+ }
+ catch (Exception e) {
+ throw new JobtypeManagerException(e);
+ }
+ }
+ }
+
+ }
+
+ public void loadJobType(File dir, Map<String, Class<? extends Job>> allJobTypes, Map<String, Props> jobTypeProps) throws JobtypeManagerException{
+
+ // look for jobtypeConf.properties and load it
+ for(File f: dir.listFiles()) {
+ if(f.isFile() && f.getName().equals(jobtypeConfFile)) {
+ loadJob(dir, f, allJobTypes, jobTypeProps);
+ return;
+ }
+ }
+
+ // no hit, keep looking
+ for(File f : dir.listFiles()) {
+ if(f.isDirectory() && f.canRead())
+ loadJobType(f, allJobTypes, jobTypeProps);
+
+
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public void loadJob(File dir, File jobConfFile, Map<String, Class<? extends Job>> allJobTypes, Map<String, Props> jobTypeProps) throws JobtypeManagerException{
+ Props props;
+ try {
+ props = new Props(null, jobConfFile);
+ } catch (IOException e) {
+ throw new JobtypeManagerException(e);
+ }
+
+ List<String> jobtypeClasspath = props.getStringList("jobtype.classpath", null, ",");
+
+ // use directory name as job type name
+ String jobtypeName = dir.getName();
+ String jobtypeClass = props.get("jobtype.class");
+
+ logger.info("Loading jobtype " + jobtypeName );
+// List<URL> resources = new ArrayList<URL>();
+// for(File f : dir.listFiles()) {
+// try {
+// resources.add(f.toURI().toURL());
+// } catch (MalformedURLException e) {
+// // TODO Auto-generated catch block
+// throw new JobWrappingFactoryException(e);
+// }
+// }
+ List<URL> resources = new ArrayList<URL>();
+ for(String path : jobtypeClasspath) {
+ URL res;
+ try {
+ res = new File(path).toURI().toURL();
+ logger.info("adding to classpath " + res);
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ throw new JobtypeManagerException(e);
+ }
+ resources.add(res);
+ }
+
+ // each job type can have a different class loader
+ ClassLoader jobTypeLoader = new URLClassLoader(resources.toArray(new URL[resources.size()]), parentLoader);
+
+ Class<? extends Job> clazz = null;
+ try {
+ clazz = (Class<? extends Job>)jobTypeLoader.loadClass(jobtypeClass);
+ allJobTypes.put(jobtypeName, clazz);
+ }
+ catch (ClassNotFoundException e) {
+ throw new JobtypeManagerException(e);
+ }
+ logger.info("Loaded jobtype " + jobtypeName + " " + jobtypeClass);
+ jobTypeProps.put(jobtypeName, props);
+ }
+
+ public Job buildJobExecutor(String jobId, Props props, Logger logger) throws JobtypeManagerException
+ {
+
+ Job job;
+ try {
+ String jobType = props.getString("type");
+ if (jobType == null || jobType.length() == 0) {
+ /*throw an exception when job name is null or empty*/
+ throw new JobExecutionException (
+ String.format("The 'type' parameter for job[%s] is null or empty", props, logger));
+ }
+
+ logger.info("Building " + jobType + " job executor. ");
+ Class<? extends Object> executorClass = jobToClass.get(jobType);
+
+ if (executorClass == null) {
+ throw new JobExecutionException(
+ String.format("Could not construct job[%s] of type[%s].", props, jobType));
+ }
+
+ job = (Job)Utils.callConstructor(executorClass, jobId, props, logger);
+
+ }
+ catch (Exception e) {
+ //job = new InitErrorJob(jobId, e);
+ throw new JobtypeManagerException(e);
+ }
+
+ return job;
+ }
+
+
+}
+
diff --git a/src/java/azkaban/jobtype/JobtypeManagerException.java b/src/java/azkaban/jobtype/JobtypeManagerException.java
new file mode 100644
index 0000000..e6be155
--- /dev/null
+++ b/src/java/azkaban/jobtype/JobtypeManagerException.java
@@ -0,0 +1,19 @@
+package azkaban.jobtype;
+
+public class JobtypeManagerException extends RuntimeException {
+
+// private final static long serialVersionUID = 1;
+
+ public JobtypeManagerException(String message) {
+ super(message);
+ }
+
+ public JobtypeManagerException(Throwable cause) {
+ super(cause);
+ }
+
+ public JobtypeManagerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
src/java/azkaban/project/JdbcProjectLoader.java 1153(+1153 -0)
diff --git a/src/java/azkaban/project/JdbcProjectLoader.java b/src/java/azkaban/project/JdbcProjectLoader.java
new file mode 100644
index 0000000..028a121
--- /dev/null
+++ b/src/java/azkaban/project/JdbcProjectLoader.java
@@ -0,0 +1,1153 @@
+package azkaban.project;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.dbutils.DbUtils;
+import org.apache.commons.dbutils.QueryRunner;
+import org.apache.commons.dbutils.ResultSetHandler;
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.Logger;
+
+import azkaban.flow.Flow;
+import azkaban.project.ProjectLogEvent.EventType;
+import azkaban.user.Permission;
+import azkaban.user.User;
+import azkaban.utils.DataSourceUtils;
+import azkaban.utils.GZIPUtils;
+import azkaban.utils.JSONUtils;
+import azkaban.utils.Md5Hasher;
+import azkaban.utils.Pair;
+import azkaban.utils.Props;
+import azkaban.utils.PropsUtils;
+import azkaban.utils.Triple;
+
+public class JdbcProjectLoader implements ProjectLoader {
+
+ /**
+ * Used for when we store text data. Plain uses UTF8 encoding.
+ */
+ public static enum EncodingType {
+ PLAIN(1), GZIP(2);
+
+ private int numVal;
+
+ EncodingType(int numVal) {
+ this.numVal = numVal;
+ }
+
+ public int getNumVal() {
+ return numVal;
+ }
+
+ public static EncodingType fromInteger(int x) {
+ switch (x) {
+ case 1:
+ return PLAIN;
+ case 2:
+ return GZIP;
+ default:
+ return PLAIN;
+ }
+ }
+ }
+
+ private static final Logger logger = Logger.getLogger(JdbcProjectLoader.class);
+ private static final int CHUCK_SIZE = 1024*1024*10;
+ private File tempDir;
+
+ private DataSource dataSource;
+ private EncodingType defaultEncodingType = EncodingType.GZIP;
+ private long startTime;
+
+ public JdbcProjectLoader(Props props) {
+ tempDir = new File(props.getString("project.temp.dir", "temp"));
+ if (!tempDir.exists()) {
+ tempDir.mkdirs();
+ }
+ String databaseType = props.getString("database.type");
+
+ if (databaseType.equals("mysql")) {
+ int port = props.getInt("mysql.port");
+ String host = props.getString("mysql.host");
+ String database = props.getString("mysql.database");
+ String user = props.getString("mysql.user");
+ String password = props.getString("mysql.password");
+ int numConnections = props.getInt("mysql.numconnections");
+
+ dataSource = DataSourceUtils.getMySQLDataSource(host, port, database, user, password, numConnections);
+ }
+ }
+
+ @Override
+ public List<Project> fetchAllActiveProjects() throws ProjectManagerException {
+ Connection connection = getConnection();
+
+ List<Project> projects = null;
+ try {
+ projects = fetchAllActiveProjects(connection);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+
+ return projects;
+ }
+
+ private List<Project> fetchAllActiveProjects(Connection connection) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner();
+
+ ProjectResultHandler handler = new ProjectResultHandler();
+ List<Project> projects = null;
+ try {
+ projects = runner.query(connection, ProjectResultHandler.SELECT_ALL_ACTIVE_PROJECTS, handler);
+
+ for (Project project: projects) {
+ List<Triple<String, Boolean, Permission>> permissions = fetchPermissionsForProject(connection, project);
+ for (Triple<String, Boolean, Permission> entry: permissions) {
+ if(entry.getSecond()) {
+ project.setGroupPermission(entry.getFirst(), entry.getThird());
+ }
+ else {
+ project.setUserPermission(entry.getFirst(), entry.getThird());
+ }
+ }
+ }
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Error retrieving all projects", e);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+
+ return projects;
+ }
+
+ @Override
+ public Project fetchProjectById(int id) throws ProjectManagerException {
+ Connection connection = getConnection();
+
+ Project project = null;
+ try {
+ project = fetchProjectById(connection, id);
+ } finally {
+ DbUtils.closeQuietly(connection);
+ }
+
+ return project;
+ }
+
+ private Project fetchProjectById(Connection connection, int id) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner();
+ // Fetch the project
+ Project project = null;
+ ProjectResultHandler handler = new ProjectResultHandler();
+ try {
+ List<Project> projects = runner.query(connection, ProjectResultHandler.SELECT_PROJECT_BY_ID, handler, id);
+ if (projects.isEmpty()) {
+ throw new ProjectManagerException("No active project with id " + id + " exists in db.");
+ }
+
+ project = projects.get(0);
+ } catch (SQLException e) {
+ logger.error(ProjectResultHandler.SELECT_PROJECT_BY_ID + " failed.");
+ throw new ProjectManagerException("Query for existing project failed. Project " + id, e);
+ }
+
+ // Fetch the user permissions
+ List<Triple<String, Boolean,Permission>> permissions = fetchPermissionsForProject(connection, project);
+
+ for (Triple<String, Boolean, Permission> perm: permissions) {
+ if (perm.getThird().toFlags() != 0) {
+ if (perm.getSecond()) {
+ project.setGroupPermission(perm.getFirst(), perm.getThird());
+ }
+ else {
+ project.setUserPermission(perm.getFirst(), perm.getThird());
+ }
+ }
+ }
+
+ return project;
+ }
+
+ private List<Triple<String, Boolean, Permission>> fetchPermissionsForProject(Connection connection, Project project) throws ProjectManagerException {
+ ProjectPermissionsResultHandler permHander = new ProjectPermissionsResultHandler();
+
+ QueryRunner runner = new QueryRunner();
+ List<Triple<String, Boolean,Permission>> permissions = null;
+ try {
+ permissions = runner.query(connection, ProjectPermissionsResultHandler.SELECT_PROJECT_PERMISSION, permHander, project.getId());
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Query for permissions for " + project.getName() + " failed.", e);
+ }
+
+ return permissions;
+ }
+
+ /**
+ * Creates a Project in the db.
+ *
+ * It will throw an exception if it finds an active project of the same name, or the SQL fails
+ */
+ @Override
+ public Project createNewProject(String name, String description, User creator) throws ProjectManagerException {
+ Connection connection = getConnection();
+
+ Project project;
+ try {
+ // No need to commit, since createNewProject should commit.
+ project = createNewProject(connection, name, description, creator);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+
+ return project;
+ }
+
+ private synchronized Project createNewProject(Connection connection, String name, String description, User creator) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner();
+ ProjectResultHandler handler = new ProjectResultHandler();
+
+ // See if it exists first.
+ try {
+ List<Project> project = runner.query(connection, ProjectResultHandler.SELECT_ACTIVE_PROJECT_BY_NAME, handler, name);
+ if (!project.isEmpty()) {
+ throw new ProjectManagerException("Active project with name " + name + " already exists in db.");
+ }
+ } catch (SQLException e) {
+ logger.error(e);
+ throw new ProjectManagerException("Checking for existing project failed. " + name, e);
+ }
+
+ final String INSERT_PROJECT = "INSERT INTO projects ( name, active, modified_time, create_time, version, last_modified_by, description) values (?,?,?,?,?,?,?)";
+ // Insert project
+ try {
+ long time = System.currentTimeMillis();
+ int i = runner.update(connection, INSERT_PROJECT, name, true, time, time, null, creator.getUserId(), description);
+ if (i == 0) {
+ throw new ProjectManagerException("No projects have been inserted.");
+ }
+ connection.commit();
+
+ } catch (SQLException e) {
+ logger.error(INSERT_PROJECT + " failed.");
+ try {
+ connection.rollback();
+ } catch (SQLException e1) {
+ e1.printStackTrace();
+ }
+ throw new ProjectManagerException("Insert project for existing project failed. " + name, e);
+ }
+
+ // Do another query to grab and return the project.
+ Project project = null;
+ try {
+ List<Project> projects = runner.query(connection, ProjectResultHandler.SELECT_ACTIVE_PROJECT_BY_NAME, handler, name);
+ if (projects.isEmpty()) {
+ throw new ProjectManagerException("No active project with name " + name + " exists in db.");
+ }
+ else if (projects.size() > 1) {
+ throw new ProjectManagerException("More than one active project " + name);
+ }
+
+ project = projects.get(0);
+ } catch (SQLException e) {
+ logger.error(e);
+ throw new ProjectManagerException("Checking for existing project failed. " + name, e);
+ }
+
+ return project;
+ }
+
+ @Override
+ public void uploadProjectFile(Project project, int version, String filetype, String filename, File localFile, String uploader) throws ProjectManagerException {
+ logger.info("Uploading to " + project.getName() + " version:" + version + " file:" + filename);
+ Connection connection = getConnection();
+
+ try {
+ uploadProjectFile(connection, project, version, filetype, filename, localFile, uploader);
+ connection.commit();
+ logger.info("Commiting upload " + localFile.getName());
+ }
+ catch (SQLException e) {
+ logger.error(e);
+ throw new ProjectManagerException("Error getting DB connection.", e);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+ }
+
+ @SuppressWarnings("resource")
+ private void uploadProjectFile(Connection connection, Project project, int version, String filetype, String filename, File localFile, String uploader) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner();
+ long updateTime = System.currentTimeMillis();
+
+ logger.info("Creating message digest for upload " + localFile.getName());
+ byte[] md5 = null;
+ try {
+ md5 = Md5Hasher.md5Hash(localFile);
+ } catch (IOException e) {
+ throw new ProjectManagerException("Error getting md5 hash.", e);
+ }
+
+ logger.info("Md5 hash created");
+ // Really... I doubt we'll get a > 2gig file. So int casting it is!
+ byte[] buffer = new byte[CHUCK_SIZE];
+ final String INSERT_PROJECT_FILES = "INSERT INTO project_files (project_id, version, chunk, size, file) values (?,?,?,?,?)";
+
+ //int numChunks = (localFileSize / buffer.length) + 1;
+ BufferedInputStream bufferedStream = null;
+ int chunk = 0;
+ try {
+ bufferedStream = new BufferedInputStream(new FileInputStream(localFile));
+ int size = bufferedStream.read(buffer);
+ while (size >= 0) {
+ logger.info("Read bytes for " + filename + " size:" + size);
+ byte[] buf = buffer;
+ if (size < buffer.length) {
+ buf = Arrays.copyOfRange(buffer, 0, size);
+ }
+ try {
+ logger.info("Running update for " + filename + " chunk " + chunk);
+ runner.update(connection, INSERT_PROJECT_FILES, project.getId(), version, chunk, size, buf);
+ logger.info("Finished update for " + filename + " chunk " + chunk);
+ } catch (SQLException e) {
+ IOUtils.closeQuietly(bufferedStream);
+ throw new ProjectManagerException("Error chunking", e);
+ }
+ ++chunk;
+
+ size = bufferedStream.read(buffer);
+ }
+
+ bufferedStream.close();
+ } catch (IOException e) {
+ IOUtils.closeQuietly(bufferedStream);
+ throw new ProjectManagerException("Error chunking file " + filename);
+ }
+
+ final String INSERT_PROJECT_VERSION =
+ "INSERT INTO project_versions (project_id, version, upload_time, uploader, file_type, file_name, md5, num_chunks) values (?,?,?,?,?,?,?,?)";
+
+ try {
+ runner.update(connection, INSERT_PROJECT_VERSION, project.getId(), version, updateTime, uploader, filetype, filename, md5, chunk);
+ } catch (SQLException e) {
+ logger.error(e);
+ throw new ProjectManagerException("Error updating project version " + project.getName(), e);
+ }
+ }
+
+ @Override
+ public ProjectFileHandler getUploadedFile(Project project, int version) throws ProjectManagerException {
+ logger.info("Retrieving to " + project.getName() + " version:" + version);
+ Connection connection = getConnection();
+ ProjectFileHandler handler = null;
+ try {
+ handler = getUploadedFile(connection, project.getId(), version);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+
+ return handler;
+ }
+
+ @Override
+ public ProjectFileHandler getUploadedFile(int projectId, int version) throws ProjectManagerException {
+ logger.info("Retrieving to " + projectId + " version:" + version);
+ Connection connection = getConnection();
+ ProjectFileHandler handler = null;
+ try {
+ handler = getUploadedFile(connection, projectId, version);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+
+ return handler;
+ }
+
+ @SuppressWarnings("resource")
+ private ProjectFileHandler getUploadedFile(Connection connection, int projectId, int version) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner();
+ ProjectVersionResultHandler pfHandler = new ProjectVersionResultHandler();
+
+ List<ProjectFileHandler> projectFiles = null;
+ try {
+ projectFiles = runner.query(connection, ProjectVersionResultHandler.SELECT_PROJECT_VERSION, pfHandler, projectId, version);
+ } catch (SQLException e) {
+ logger.error(e);
+ throw new ProjectManagerException("Query for uploaded file for project id " + projectId + " failed.", e);
+ }
+ if (projectFiles == null || projectFiles.isEmpty()) {
+ return null;
+ }
+
+ ProjectFileHandler projHandler = projectFiles.get(0);
+ int numChunks = projHandler.getNumChunks();
+ BufferedOutputStream bStream = null;
+ File file = null;
+ try {
+ file = File.createTempFile(projHandler.getFileName(), String.valueOf(version), tempDir);
+
+ bStream = new BufferedOutputStream(new FileOutputStream(file));
+ }
+ catch (IOException e) {
+ IOUtils.closeQuietly(bStream);
+ throw new ProjectManagerException("Error creating temp file for stream.");
+ }
+
+ int collect = 5;
+ int fromChunk = 0;
+ int toChunk = collect;
+ do {
+ ProjectFileChunkResultHandler chunkHandler = new ProjectFileChunkResultHandler();
+ List<byte[]> data = null;
+ try {
+ data = runner.query(connection, ProjectFileChunkResultHandler.SELECT_PROJECT_CHUNKS_FILE, chunkHandler, projectId, version, fromChunk, toChunk);
+ }
+ catch(SQLException e) {
+ logger.error(e);
+ IOUtils.closeQuietly(bStream);
+ throw new ProjectManagerException("Query for uploaded file for " + projectId + " failed.", e);
+ }
+
+ try {
+ for (byte[] d : data) {
+ bStream.write(d);
+ }
+ }
+ catch (IOException e) {
+ IOUtils.closeQuietly(bStream);
+ throw new ProjectManagerException("Error writing file", e);
+ }
+
+ // Add all the bytes to the stream.
+ fromChunk += collect;
+ toChunk += collect;
+ } while (fromChunk <= numChunks);
+ IOUtils.closeQuietly(bStream);
+
+ // Check md5.
+ byte[] md5 = null;
+ try {
+ md5 = Md5Hasher.md5Hash(file);
+ } catch (IOException e) {
+ throw new ProjectManagerException("Error getting md5 hash.", e);
+ }
+
+ if (Arrays.equals(projHandler.getMd5Hash(), md5)) {
+ logger.info("Md5 Hash is valid");
+ }
+ else {
+ throw new ProjectManagerException("Md5 Hash failed on retrieval of file");
+ }
+
+ projHandler.setLocalFile(file);
+ return projHandler;
+ }
+
+ @Override
+ public void changeProjectVersion(Project project, int version, String user) throws ProjectManagerException {
+ long timestamp = System.currentTimeMillis();
+ QueryRunner runner = new QueryRunner(dataSource);
+ try {
+ final String UPDATE_PROJECT_VERSION = "UPDATE projects SET version=?,modified_time=?,last_modified_by=? WHERE id=?";
+
+ runner.update(UPDATE_PROJECT_VERSION, version, timestamp, user, project.getId());
+ project.setVersion(version);
+ project.setLastModifiedTimestamp(timestamp);
+ project.setLastModifiedUser(user);
+ } catch (SQLException e) {
+ logger.error(e);
+ throw new ProjectManagerException("Error updating switching project version " + project.getName(), e);
+ }
+ }
+
+ @Override
+ public void updatePermission(Project project, String name, Permission perm, boolean isGroup) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ long updateTime = System.currentTimeMillis();
+ final String INSERT_PROJECT_PERMISSION =
+ "INSERT INTO project_permissions (project_id, modified_time, name, permissions, isGroup) values (?,?,?,?,?)" +
+ "ON DUPLICATE KEY UPDATE modified_time = VALUES(modified_time), permissions = VALUES(permissions)";
+
+ try {
+ runner.update(INSERT_PROJECT_PERMISSION, project.getId(), updateTime, name, perm.toFlags(), isGroup);
+ } catch (SQLException e) {
+ logger.error(e);
+ throw new ProjectManagerException("Error updating project " + project.getName() + " permissions for " + name, e);
+ }
+
+ if (isGroup) {
+ project.setGroupPermission(name, perm);
+ }
+ else {
+ project.setUserPermission(name, perm);
+ }
+ }
+
+ @Override
+ public void removePermission(Project project, String name, boolean isGroup) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+ final String DELETE_PROJECT_PERMISSION = "DELETE FROM project_permissions WHERE project_id=? AND name=? AND isGroup=?";
+
+ try {
+ runner.update(DELETE_PROJECT_PERMISSION, project.getId(), name, isGroup);
+ } catch (SQLException e) {
+ logger.error(e);
+ throw new ProjectManagerException("Error deleting project " + project.getName() + " permissions for " + name, e);
+ }
+
+ if (isGroup) {
+ project.removeGroupPermission(name);
+ }
+ else {
+ project.removeUserPermission(name);
+ }
+ }
+
+ @Override
+ public void removeProject(Project project, String user) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ long updateTime = System.currentTimeMillis();
+ final String UPDATE_INACTIVE_PROJECT = "UPDATE projects SET active=false,modified_time=?,last_modified_by=? WHERE id=?";
+ try {
+ runner.update(UPDATE_INACTIVE_PROJECT, updateTime, user, project.getId());
+ } catch (SQLException e) {
+ logger.error(e);
+ throw new ProjectManagerException("Error marking project " + project.getName() + " as inactive", e);
+ }
+ }
+
+ @Override
+ public boolean postEvent(Project project, EventType type, String user, String message) {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ final String INSERT_PROJECT_EVENTS =
+ "INSERT INTO project_events (project_id, event_type, event_time, username, message) values (?,?,?,?,?)";
+ long updateTime = System.currentTimeMillis();
+ try {
+ runner.update(INSERT_PROJECT_EVENTS, project.getId(), type.getNumVal(), updateTime, user, message);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Get all the logs for a given project
+ *
+ * @param project
+ * @return
+ * @throws ProjectManagerException
+ */
+ public List<ProjectLogEvent> getProjectEvents(Project project, int num, int skip) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ ProjectLogsResultHandler logHandler = new ProjectLogsResultHandler();
+ List<ProjectLogEvent> events = null;
+ try {
+ events = runner.query(ProjectLogsResultHandler.SELECT_PROJECT_EVENTS_ORDER, logHandler, project.getId(), num, skip);
+ } catch (SQLException e) {
+ logger.error(e);
+ }
+
+ return events;
+ }
+
+ @Override
+ public void updateDescription(Project project, String description, String user) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ final String UPDATE_PROJECT_DESCRIPTION =
+ "UPDATE projects SET description=?,modified_time=?,last_modified_by=? WHERE id=?";
+ long updateTime = System.currentTimeMillis();
+ try {
+ runner.update(UPDATE_PROJECT_DESCRIPTION, description, updateTime, user, project.getId());
+ project.setDescription(description);
+ project.setLastModifiedTimestamp(updateTime);
+ project.setLastModifiedUser(user);
+ } catch (SQLException e) {
+ logger.error(e);
+ throw new ProjectManagerException("Error marking project " + project.getName() + " as inactive", e);
+ }
+ }
+
+ @Override
+ public int getLatestProjectVersion(Project project) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ IntHander handler = new IntHander();
+ try {
+ return runner.query(IntHander.SELECT_LATEST_VERSION, handler, project.getId());
+ } catch (SQLException e) {
+ logger.error(e);
+ throw new ProjectManagerException("Error marking project " + project.getName() + " as inactive", e);
+ }
+ }
+
+ @Override
+ public void uploadFlows(Project project, int version, Collection<Flow> flows) throws ProjectManagerException {
+ // We do one at a time instead of batch... because well, the batch could be large.
+ logger.info("Uploading flows");
+ Connection connection = getConnection();
+
+ try {
+ for (Flow flow: flows) {
+ uploadFlow(connection, project, version, flow, defaultEncodingType);
+ }
+ connection.commit();
+ }
+ catch (IOException e) {
+ throw new ProjectManagerException("Flow Upload failed.", e);
+ }
+ catch (SQLException e) {
+ throw new ProjectManagerException("Flow Upload failed.", e);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+ }
+
+ @Override
+ public void uploadFlow(Project project, int version, Flow flow) throws ProjectManagerException {
+ logger.info("Uploading flows");
+ Connection connection = getConnection();
+
+ try {
+ uploadFlow(connection, project, version, flow, defaultEncodingType);
+ connection.commit();
+ }
+ catch (IOException e) {
+ throw new ProjectManagerException("Flow Upload failed.", e);
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Flow Upload failed commit.", e);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+ }
+
+ public EncodingType getDefaultEncodingType() {
+ return defaultEncodingType;
+ }
+
+ public void setDefaultEncodingType(EncodingType defaultEncodingType) {
+ this.defaultEncodingType = defaultEncodingType;
+ }
+
+ private void uploadFlow(Connection connection, Project project, int version, Flow flow, EncodingType encType) throws ProjectManagerException, IOException {
+ QueryRunner runner = new QueryRunner();
+ String json = JSONUtils.toJSON(flow.toObject());
+ byte[] stringData = json.getBytes("UTF-8");
+ byte[] data = stringData;
+
+ logger.info("UTF-8 size:" + data.length);
+ if (encType == EncodingType.GZIP) {
+ data = GZIPUtils.gzipBytes(stringData);
+ }
+
+ logger.info("Flow upload " + flow.getId() + " is byte size " + data.length);
+ final String INSERT_FLOW = "INSERT INTO project_flows (project_id, version, flow_id, modified_time, encoding_type, json) values (?,?,?,?,?,?)";
+ try {
+ runner.update(connection, INSERT_FLOW, project.getId(), version, flow.getId(), System.currentTimeMillis(), encType.getNumVal(), data );
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Error inserting flow " + flow.getId(), e);
+ }
+ }
+
+ @Override
+ public Flow fetchFlow(Project project, String flowId) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+ ProjectFlowsResultHandler handler = new ProjectFlowsResultHandler();
+
+ try {
+ List<Flow> flows = runner.query(ProjectFlowsResultHandler.SELECT_PROJECT_FLOW, handler, project.getId(), project.getVersion(), flowId);
+ if (flows.isEmpty()) {
+ return null;
+ }
+ else {
+ return flows.get(0);
+ }
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Error fetching flow " + flowId, e);
+ }
+ }
+
+ @Override
+ public List<Flow> fetchAllProjectFlows(Project project) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+ ProjectFlowsResultHandler handler = new ProjectFlowsResultHandler();
+
+ List<Flow> flows = null;
+ try {
+ flows = runner.query(ProjectFlowsResultHandler.SELECT_ALL_PROJECT_FLOWS, handler, project.getId(), project.getVersion());
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Error fetching flows from project " + project.getName() + " version " + project.getVersion(), e);
+ }
+
+ return flows;
+ }
+
+ @Override
+ public void uploadProjectProperties(Project project, List<Props> properties) throws ProjectManagerException {
+ Connection connection = getConnection();
+
+ try {
+ for (Props props: properties) {
+ uploadProjectProperty(connection, project, props.getSource(), props);
+ }
+ connection.commit();
+ }
+ catch (SQLException e) {
+ throw new ProjectManagerException("Error uploading project property files", e);
+ }
+ catch (IOException e) {
+ throw new ProjectManagerException("Error uploading project property files", e);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+ }
+
+ @Override
+ public void uploadProjectProperty(Project project, Props props) throws ProjectManagerException {
+ Connection connection = getConnection();
+ try {
+ uploadProjectProperty(connection, project, props.getSource(), props);
+ connection.commit();
+ }
+ catch (SQLException e) {
+ throw new ProjectManagerException("Error uploading project property files", e);
+ }
+ catch (IOException e) {
+ throw new ProjectManagerException("Error uploading project property file", e);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+ }
+
+ private void uploadProjectProperty(Connection connection, Project project, String name, Props props) throws ProjectManagerException, IOException {
+ QueryRunner runner = new QueryRunner();
+ final String INSERT_PROPERTIES = "INSERT INTO project_properties (project_id, version, name, modified_time, encoding_type, property) values (?,?,?,?,?,?)";
+
+ String propertyJSON = PropsUtils.toJSONString(props, true);
+ byte[] data = propertyJSON.getBytes("UTF-8");
+ logger.info("UTF-8 size:" + data.length);
+ if (defaultEncodingType == EncodingType.GZIP) {
+ data = GZIPUtils.gzipBytes(data);
+ }
+
+ try {
+ runner.update(connection, INSERT_PROPERTIES, project.getId(), project.getVersion(), name, System.currentTimeMillis(), defaultEncodingType.getNumVal(), data);
+ connection.commit();
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Error fetching flows from project " + project.getName() + " version " + project.getVersion(), e);
+ }
+ }
+
+ @Override
+ public Props fetchProjectProperty(Project project, String propsName) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ ProjectPropertiesResultsHandler handler = new ProjectPropertiesResultsHandler();
+ try {
+ List<Pair<String, Props>> properties =
+ runner.query(ProjectPropertiesResultsHandler.SELECT_PROJECT_PROPERTY, handler, project.getId(), project.getVersion(), propsName);
+
+ if (properties == null || properties.isEmpty()) {
+ return null;
+ }
+
+ return properties.get(0).getSecond();
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Error fetching property " + propsName, e);
+ }
+ }
+
+ @Override
+ public void cleanOlderProjectVersion(int projectId, int version) throws ProjectManagerException {
+ Connection connection = getConnection();
+
+ try {
+ cleanOlderProjectVersionFlows(connection, projectId, version);
+ cleanOlderProjectVersionProperties(connection, projectId, version);
+ cleanOlderProjectFiles(connection, projectId, version);
+ cleanOlderProjectVersion(connection, projectId, version);
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+ }
+
+ private void cleanOlderProjectVersionFlows(Connection connection, int projectId, int version) throws ProjectManagerException {
+ final String DELETE_FLOW = "DELETE FROM project_flows WHERE project_id=? AND version<?";
+ QueryRunner runner = new QueryRunner();
+ try {
+ runner.update(connection, DELETE_FLOW, projectId, version);
+ connection.commit();
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Error deleting project version flows " + projectId + ":" + version, e);
+ }
+ }
+
+ private void cleanOlderProjectVersionProperties(Connection connection, int projectId, int version) throws ProjectManagerException {
+ final String DELETE_PROPERTIES = "DELETE FROM project_properties WHERE project_id=? AND version<?";
+ QueryRunner runner = new QueryRunner();
+ try {
+ runner.update(connection, DELETE_PROPERTIES, projectId, version);
+ connection.commit();
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Error deleting project version properties " + projectId + ":" + version, e);
+ }
+ }
+
+ private void cleanOlderProjectFiles(Connection connection, int projectId, int version) throws ProjectManagerException {
+ final String DELETE_PROJECT_FILES = "DELETE FROM project_files WHERE project_id=? AND version<?";
+ QueryRunner runner = new QueryRunner();
+ try {
+ runner.update(connection, DELETE_PROJECT_FILES, projectId, version);
+ connection.commit();
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Error deleting project version files " + projectId + ":" + version, e);
+ }
+ }
+
+ private void cleanOlderProjectVersion(Connection connection, int projectId, int version) throws ProjectManagerException {
+ final String UPDATE_PROJECT_VERSIONS = "UPDATE project_versions SET num_chunks=0 WHERE project_id=? AND version<?";
+ QueryRunner runner = new QueryRunner();
+ try {
+ runner.update(connection, UPDATE_PROJECT_VERSIONS, projectId, version);
+ connection.commit();
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Error updating project version chunksize " + projectId + ":" + version, e);
+ }
+ }
+
+
+ @Override
+ public Map<String,Props> fetchProjectProperties(int projectId, int version) throws ProjectManagerException {
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ ProjectPropertiesResultsHandler handler = new ProjectPropertiesResultsHandler();
+ try {
+ List<Pair<String, Props>> properties =
+ runner.query(ProjectPropertiesResultsHandler.SELECT_PROJECT_PROPERTIES, handler, projectId, version);
+
+ if (properties == null || properties.isEmpty()) {
+ return null;
+ }
+
+ HashMap<String, Props> props = new HashMap<String, Props>();
+ for (Pair<String, Props> pair: properties) {
+ props.put(pair.getFirst(), pair.getSecond());
+ }
+ return props;
+ } catch (SQLException e) {
+ throw new ProjectManagerException("Error fetching properties", e);
+ }
+ }
+
+ private static class ProjectResultHandler implements ResultSetHandler<List<Project>> {
+ private static String SELECT_PROJECT_BY_ID =
+ "SELECT id, name, active, modified_time, create_time, version, last_modified_by, description FROM projects WHERE id=?";
+
+ private static String SELECT_ALL_ACTIVE_PROJECTS =
+ "SELECT id, name, active, modified_time, create_time, version, last_modified_by, description FROM projects WHERE active=true";
+
+ private static String SELECT_ACTIVE_PROJECT_BY_NAME =
+ "SELECT id, name, active, modified_time, create_time, version, last_modified_by, description FROM projects WHERE name=? AND active=true";
+
+ @Override
+ public List<Project> handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return Collections.<Project>emptyList();
+ }
+
+ ArrayList<Project> projects = new ArrayList<Project>();
+ do {
+ int id = rs.getInt(1);
+ String name = rs.getString(2);
+ boolean active = rs.getBoolean(3);
+ long modifiedTime = rs.getLong(4);
+ long createTime = rs.getLong(5);
+ int version = rs.getInt(6);
+ String lastModifiedBy = rs.getString(7);
+ String description = rs.getString(8);
+
+ Project project = new Project(id, name);
+ project.setActive(active);
+ project.setLastModifiedTimestamp(modifiedTime);
+ project.setCreateTimestamp(createTime);
+ project.setVersion(version);
+ project.setLastModifiedUser(lastModifiedBy);
+ project.setDescription(description);
+
+ projects.add(project);
+ } while (rs.next());
+
+ return projects;
+ }
+ }
+
+ private static class ProjectPermissionsResultHandler implements ResultSetHandler<List<Triple<String, Boolean, Permission>>> {
+ private static String SELECT_PROJECT_PERMISSION =
+ "SELECT project_id, modified_time, name, permissions, isGroup FROM project_permissions WHERE project_id=?";
+
+ @Override
+ public List<Triple<String, Boolean, Permission>> handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return Collections.<Triple<String, Boolean, Permission>>emptyList();
+ }
+
+ ArrayList<Triple<String, Boolean, Permission>> permissions = new ArrayList<Triple<String, Boolean, Permission>>();
+ do {
+ //int project_id = rs.getInt(1);
+ //long modifiedTime = rs.getLong(2);
+ String username = rs.getString(3);
+ int permissionFlag = rs.getInt(4);
+ boolean val = rs.getBoolean(5);
+
+ Permission perm = new Permission(permissionFlag);
+ permissions.add(new Triple<String, Boolean, Permission>(username, val, perm));
+ } while (rs.next());
+
+ return permissions;
+ }
+ }
+
+ private static class ProjectFlowsResultHandler implements ResultSetHandler<List<Flow>> {
+ private static String SELECT_PROJECT_FLOW =
+ "SELECT project_id, version, flow_id, modified_time, encoding_type, json FROM project_flows WHERE project_id=? AND version=? AND flow_id=?";
+
+ private static String SELECT_ALL_PROJECT_FLOWS =
+ "SELECT project_id, version, flow_id, modified_time, encoding_type, json FROM project_flows WHERE project_id=? AND version=?";
+
+ @Override
+ public List<Flow> handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return Collections.<Flow>emptyList();
+ }
+
+ ArrayList<Flow> flows = new ArrayList<Flow>();
+ do {
+ //int projectId = rs.getInt(1);
+ int version = rs.getInt(2);
+ String flowId = rs.getString(3);
+ //long modifiedTime = rs.getLong(4);
+ int encodingType = rs.getInt(5);
+ byte[] dataBytes = rs.getBytes(6);
+
+ if (dataBytes == null) {
+ continue;
+ }
+
+ EncodingType encType = EncodingType.fromInteger(encodingType);
+
+ Object flowObj = null;
+ try {
+ // Convoluted way to inflate strings. Should find common package or helper function.
+ if (encType == EncodingType.GZIP) {
+ // Decompress the sucker.
+ String jsonString = GZIPUtils.unGzipString(dataBytes, "UTF-8");
+ flowObj = JSONUtils.parseJSONFromString(jsonString);
+ }
+ else {
+ String jsonString = new String(dataBytes, "UTF-8");
+ flowObj = JSONUtils.parseJSONFromString(jsonString);
+ }
+
+ Flow flow = Flow.flowFromObject(flowObj);
+ flows.add(flow);
+ } catch (IOException e) {
+ throw new SQLException("Error retrieving flow data " + flowId, e);
+ }
+
+ } while (rs.next());
+
+ return flows;
+ }
+ }
+
+ private static class ProjectPropertiesResultsHandler implements ResultSetHandler<List<Pair<String, Props>>> {
+ private static String SELECT_PROJECT_PROPERTY =
+ "SELECT project_id, version, name, modified_time, encoding_type, property FROM project_properties WHERE project_id=? AND version=? AND name=?";
+
+ private static String SELECT_PROJECT_PROPERTIES =
+ "SELECT project_id, version, name, modified_time, encoding_type, property FROM project_properties WHERE project_id=? AND version=?";
+
+ @Override
+ public List<Pair<String, Props>> handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return Collections.<Pair<String, Props>>emptyList();
+ }
+
+ List<Pair<String, Props>> properties = new ArrayList<Pair<String, Props>>();
+ do {
+ //int projectId = rs.getInt(1);
+ //int version = rs.getInt(2);
+ String name = rs.getString(3);
+ //long modifiedTime = rs.getLong(4);
+ int eventType = rs.getInt(5);
+ byte[] dataBytes = rs.getBytes(6);
+
+ EncodingType encType = EncodingType.fromInteger(eventType);
+ String propertyString = null;
+
+ try {
+ if (encType == EncodingType.GZIP) {
+ // Decompress the sucker.
+ propertyString = GZIPUtils.unGzipString(dataBytes, "UTF-8");
+ }
+ else {
+ propertyString = new String(dataBytes, "UTF-8");
+ }
+
+ Props props = PropsUtils.fromJSONString(propertyString);
+ props.setSource(name);
+ properties.add(new Pair<String, Props>(name, props));
+ } catch (IOException e) {
+ throw new SQLException(e);
+ }
+ } while (rs.next());
+
+ return properties;
+ }
+ }
+
+ private static class ProjectLogsResultHandler implements ResultSetHandler<List<ProjectLogEvent>> {
+ private static String SELECT_PROJECT_EVENTS_ORDER =
+ "SELECT project_id, event_type, event_time, username, message FROM project_events WHERE project_id=? ORDER BY event_time DESC LIMIT ? OFFSET ?";
+
+ @Override
+ public List<ProjectLogEvent> handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return Collections.<ProjectLogEvent>emptyList();
+ }
+
+ ArrayList<ProjectLogEvent> events = new ArrayList<ProjectLogEvent>();
+ do {
+ int projectId = rs.getInt(1);
+ int eventType = rs.getInt(2);
+ long eventTime = rs.getLong(3);
+ String username = rs.getString(4);
+ String message = rs.getString(5);
+
+ ProjectLogEvent event = new ProjectLogEvent(projectId, EventType.fromInteger(eventType), eventTime, username, message);
+ events.add(event);
+ } while (rs.next());
+
+ return events;
+ }
+ }
+
+ private static class ProjectFileChunkResultHandler implements ResultSetHandler<List<byte[]>> {
+ private static String SELECT_PROJECT_CHUNKS_FILE = "SELECT project_id, version, chunk, size, file FROM project_files WHERE project_id=? AND version=? AND chunk >= ? AND chunk < ? ORDER BY chunk ASC";
+
+ @Override
+ public List<byte[]> handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return Collections.<byte[]>emptyList();
+ }
+
+ ArrayList<byte[]> data = new ArrayList<byte[]>();
+ do {
+// int project_id = rs.getInt(1);
+// int version = rs.getInt(2);
+// int chunk = rs.getInt(3);
+// int size = rs.getInt(4);
+ byte[] bytes = rs.getBytes(5);
+
+ data.add(bytes);
+ } while (rs.next());
+
+ return data;
+ }
+
+ }
+
+ private static class ProjectVersionResultHandler implements ResultSetHandler<List<ProjectFileHandler>> {
+ private static String SELECT_PROJECT_VERSION = "SELECT project_id, version, upload_time, uploader, file_type, file_name, md5, num_chunks FROM project_versions WHERE project_id=? AND version=?";
+ private static String SELECT_ALL_PER_PROJECT = "SELECT project_id, version, upload_time, uploader, file_type, file_name, md5, num_chunks FROM project_versions WHERE project_id=?";
+
+ @Override
+ public List<ProjectFileHandler> handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return null;
+ }
+
+ List<ProjectFileHandler> handlers = new ArrayList<ProjectFileHandler>();
+ do {
+ int projectId = rs.getInt(1);
+ int version = rs.getInt(2);
+ long uploadTime = rs.getLong(3);
+ String uploader = rs.getString(4);
+ String fileType = rs.getString(5);
+ String fileName = rs.getString(6);
+ byte[] md5 = rs.getBytes(7);
+ int numChunks = rs.getInt(8);
+
+ ProjectFileHandler handler = new ProjectFileHandler(
+ projectId, version, uploadTime, uploader, fileType, fileName, numChunks, md5
+ );
+
+ handlers.add(handler);
+ } while (rs.next());
+
+ return handlers;
+ }
+ }
+
+ private static class IntHander implements ResultSetHandler<Integer> {
+ private static String SELECT_LATEST_VERSION = "SELECT MAX(version) FROM project_versions WHERE project_id=?";
+
+ @Override
+ public Integer handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return 0;
+ }
+
+ return rs.getInt(1);
+ }
+ }
+
+ private Connection getConnection() throws ProjectManagerException {
+ Connection connection = null;
+ try {
+ connection = dataSource.getConnection();
+ connection.setAutoCommit(false);
+ } catch (Exception e) {
+ DbUtils.closeQuietly(connection);
+ throw new ProjectManagerException("Error getting DB connection.", e);
+ }
+
+ return connection;
+ }
+
+}
+
\ No newline at end of file
src/java/azkaban/project/Project.java 171(+129 -42)
diff --git a/src/java/azkaban/project/Project.java b/src/java/azkaban/project/Project.java
index fb06314..5a611fc 100644
--- a/src/java/azkaban/project/Project.java
+++ b/src/java/azkaban/project/Project.java
@@ -16,15 +16,12 @@
package azkaban.project;
-import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.apache.log4j.Logger;
-
import azkaban.flow.Flow;
import azkaban.user.Permission;
import azkaban.user.Permission.Type;
@@ -32,17 +29,21 @@ import azkaban.user.User;
import azkaban.utils.Pair;
public class Project {
+ private final int id;
private final String name;
+ private boolean active = true;
private String description;
+ private int version = -1;
private long createTimestamp;
private long lastModifiedTimestamp;
private String lastModifiedUser;
private String source;
- private LinkedHashMap<String, Permission> userToPermission = new LinkedHashMap<String, Permission>();
+ private LinkedHashMap<String, Permission> userPermissionMap = new LinkedHashMap<String, Permission>();
+ private LinkedHashMap<String, Permission> groupPermissionMap = new LinkedHashMap<String, Permission>();
private Map<String, Flow> flows = null;
- private Logger logger = null;
- public Project(String name) {
+ public Project(int id, String name) {
+ this.id = id;
this.name = name;
}
@@ -73,9 +74,36 @@ public class Project {
return retFlow;
}
+ public Permission getCollectivePermission(User user) {
+ Permission permissions = new Permission();
+ Permission perm = userPermissionMap.get(user.getUserId());
+ if (perm != null) {
+ permissions.addPermissions(perm);
+ }
+
+ for(String group: user.getGroups()) {
+ perm = groupPermissionMap.get(group);
+ if (perm != null) {
+ permissions.addPermissions(perm);
+ }
+ }
+
+ return permissions;
+ }
+
public boolean hasPermission(User user, Type type) {
- Permission perm = userToPermission.get(user.getUserId());
+ Permission perm = userPermissionMap.get(user.getUserId());
+ if (perm != null && (perm.isPermissionSet(Type.ADMIN) || perm.isPermissionSet(type))) {
+ return true;
+ }
+
+ return hasGroupPermission(user, type);
+ }
+
+ public boolean hasUserPermission(User user, Type type) {
+ Permission perm = userPermissionMap.get(user.getUserId());
if (perm == null) {
+ // Check group
return false;
}
@@ -86,9 +114,22 @@ public class Project {
return false;
}
+ public boolean hasGroupPermission(User user, Type type) {
+ for(String group: user.getGroups()) {
+ Permission perm = groupPermissionMap.get(group);
+ if (perm != null) {
+ if (perm.isPermissionSet(Type.ADMIN) || perm.isPermissionSet(type)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
public List<String> getUsersWithPermission(Type type) {
ArrayList<String> users = new ArrayList<String>();
- for (Map.Entry<String, Permission> entry : userToPermission.entrySet()) {
+ for (Map.Entry<String, Permission> entry : userPermissionMap.entrySet()) {
Permission perm = entry.getValue();
if (perm.isPermissionSet(type)) {
users.add(entry.getKey());
@@ -100,7 +141,17 @@ public class Project {
public List<Pair<String, Permission>> getUserPermissions() {
ArrayList<Pair<String, Permission>> permissions = new ArrayList<Pair<String, Permission>>();
- for (Map.Entry<String, Permission> entry : userToPermission.entrySet()) {
+ for (Map.Entry<String, Permission> entry : userPermissionMap.entrySet()) {
+ permissions.add(new Pair<String, Permission>(entry.getKey(), entry.getValue()));
+ }
+
+ return permissions;
+ }
+
+ public List<Pair<String, Permission>> getGroupPermissions() {
+ ArrayList<Pair<String, Permission>> permissions = new ArrayList<Pair<String, Permission>>();
+
+ for (Map.Entry<String, Permission> entry : groupPermissionMap.entrySet()) {
permissions.add(new Pair<String, Permission>(entry.getKey(), entry.getValue()));
}
@@ -116,19 +167,31 @@ public class Project {
}
public void setUserPermission(String userid, Permission perm) {
- userToPermission.put(userid, perm);
+ userPermissionMap.put(userid, perm);
}
+ public void setGroupPermission(String group, Permission perm) {
+ groupPermissionMap.put(group, perm);
+ }
+
public Permission getUserPermission(User user) {
- return userToPermission.get(user.getUserId());
+ return userPermissionMap.get(user.getUserId());
}
+ public Permission getGroupPermission(String group) {
+ return groupPermissionMap.get(group);
+ }
+
public Permission getUserPermission(String userID) {
- return userToPermission.get(userID);
+ return userPermissionMap.get(userID);
+ }
+
+ public void removeGroupPermission(String group) {
+ groupPermissionMap.remove(group);
}
public void removeUserPermission(String userId) {
- userToPermission.remove(userId);
+ userPermissionMap.remove(userId);
}
public long getCreateTimestamp() {
@@ -149,18 +212,24 @@ public class Project {
public Object toObject() {
HashMap<String, Object> projectObject = new HashMap<String, Object>();
+ projectObject.put("id", id);
projectObject.put("name", name);
projectObject.put("description", description);
projectObject.put("createTimestamp", createTimestamp);
projectObject.put("lastModifiedTimestamp", lastModifiedTimestamp);
projectObject.put("lastModifiedUser", lastModifiedUser);
+ projectObject.put("version", version);
+
+ if (!active) {
+ projectObject.put("active", false);
+ }
if (source != null) {
projectObject.put("source", source);
}
ArrayList<Map<String, Object>> users = new ArrayList<Map<String, Object>>();
- for (Map.Entry<String, Permission> entry : userToPermission.entrySet()) {
+ for (Map.Entry<String, Permission> entry : userPermissionMap.entrySet()) {
HashMap<String, Object> userMap = new HashMap<String, Object>();
userMap.put("userId", entry.getKey());
userMap.put("permissions", entry.getValue().toStringArray());
@@ -174,19 +243,25 @@ public class Project {
@SuppressWarnings("unchecked")
public static Project projectFromObject(Object object) {
Map<String, Object> projectObject = (Map<String, Object>) object;
+ int id = (Integer) projectObject.get("id");
String name = (String) projectObject.get("name");
String description = (String) projectObject.get("description");
String lastModifiedUser = (String) projectObject.get("lastModifiedUser");
long createTimestamp = coerceToLong(projectObject.get("createTimestamp"));
long lastModifiedTimestamp = coerceToLong(projectObject.get("lastModifiedTimestamp"));
String source = (String)projectObject.get("source");
+ Boolean active = (Boolean)projectObject.get("active");
+ active = active == null ? true : active;
+ int version = (Integer)projectObject.get("version");
- Project project = new Project(name);
+ Project project = new Project(id, name);
+ project.setVersion(version);
project.setDescription(description);
project.setCreateTimestamp(createTimestamp);
project.setLastModifiedTimestamp(lastModifiedTimestamp);
project.setLastModifiedUser(lastModifiedUser);
-
+ project.setActive(active);
+
if (source != null) {
project.setSource(source);
}
@@ -228,12 +303,21 @@ public class Project {
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + (int) (createTimestamp ^ (createTimestamp >>> 32));
- result = prime * result + ((description == null) ? 0 : description.hashCode());
- result = prime * result + (int) (lastModifiedTimestamp ^ (lastModifiedTimestamp >>> 32));
- result = prime * result + ((lastModifiedUser == null) ? 0 : lastModifiedUser.hashCode());
+ result = prime * result + (active ? 1231 : 1237);
+ result = prime * result
+ + (int) (createTimestamp ^ (createTimestamp >>> 32));
+ result = prime * result
+ + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + id;
+ result = prime
+ * result
+ + (int) (lastModifiedTimestamp ^ (lastModifiedTimestamp >>> 32));
+ result = prime
+ * result
+ + ((lastModifiedUser == null) ? 0 : lastModifiedUser.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((userToPermission == null) ? 0 : userToPermission.hashCode());
+ result = prime * result + ((source == null) ? 0 : source.hashCode());
+ result = prime * result + version;
return result;
}
@@ -245,17 +329,18 @@ public class Project {
return false;
if (getClass() != obj.getClass())
return false;
-
Project other = (Project) obj;
+ if (active != other.active)
+ return false;
if (createTimestamp != other.createTimestamp)
return false;
-
if (description == null) {
if (other.description != null)
return false;
} else if (!description.equals(other.description))
return false;
-
+ if (id != other.id)
+ return false;
if (lastModifiedTimestamp != other.lastModifiedTimestamp)
return false;
if (lastModifiedUser == null) {
@@ -268,10 +353,12 @@ public class Project {
return false;
} else if (!name.equals(other.name))
return false;
- if (userToPermission == null) {
- if (other.userToPermission != null)
+ if (source == null) {
+ if (other.source != null)
return false;
- } else if (!userToPermission.equals(other.userToPermission))
+ } else if (!source.equals(other.source))
+ return false;
+ if (version != other.version)
return false;
return true;
}
@@ -283,24 +370,24 @@ public class Project {
public void setSource(String source) {
this.source = source;
}
-
- public void attachLogger(Logger logger) {
- this.logger = logger;
+
+ public int getId() {
+ return id;
}
-
- public void info(String message) {
- if (logger != null) {
- logger.info(message);
- }
+
+ public boolean isActive() {
+ return active;
}
- public void error(String message) {
- if (logger != null) {
- logger.error(message);
- }
+ public void setActive(boolean active) {
+ this.active = active;
}
-
- public Logger getLogger() {
- return logger;
+
+ public int getVersion() {
+ return version;
+ }
+
+ public void setVersion(int version) {
+ this.version = version;
}
}
src/java/azkaban/project/ProjectFileHandler.java 106(+106 -0)
diff --git a/src/java/azkaban/project/ProjectFileHandler.java b/src/java/azkaban/project/ProjectFileHandler.java
new file mode 100644
index 0000000..9457efe
--- /dev/null
+++ b/src/java/azkaban/project/ProjectFileHandler.java
@@ -0,0 +1,106 @@
+package azkaban.project;
+
+import java.io.File;
+
+public class ProjectFileHandler {
+ private final int projectId;
+ private final int version;
+ private final long uploadTime;
+ private String fileType;
+ private String fileName;
+ private String uploader;
+ private byte[] md5Hash;
+ private int numChunks;
+ private File localFile = null;
+
+ public ProjectFileHandler(
+ int projectId,
+ int version,
+ long uploadTime,
+ String uploader,
+ String fileType,
+ String fileName,
+ int numChunks,
+ byte[] md5Hash)
+ {
+ this.projectId = projectId;
+ this.version = version;
+ this.uploadTime = uploadTime;
+ this.setUploader(uploader);
+ this.setFileType(fileType);
+ this.setFileName(fileName);
+ this.setMd5Hash(md5Hash);
+ this.setNumChunks(numChunks);
+ }
+
+ public int getProjectId() {
+ return projectId;
+ }
+
+ public int getVersion() {
+ return version;
+ }
+
+ public long getUploadTime() {
+ return uploadTime;
+ }
+
+ public String getFileType() {
+ return fileType;
+ }
+
+ public void setFileType(String fileType) {
+ this.fileType = fileType;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public byte[] getMd5Hash() {
+ return md5Hash;
+ }
+
+ public void setMd5Hash(byte[] md5Hash) {
+ this.md5Hash = md5Hash;
+ }
+
+ public File getLocalFile() {
+ return localFile;
+ }
+
+ public synchronized void setLocalFile(File localFile) {
+ this.localFile = localFile;
+ }
+
+ public synchronized void deleteLocalFile() {
+ if (localFile == null) {
+ return;
+ }
+ else {
+ localFile.delete();
+ localFile = null;
+ }
+ }
+
+ public String getUploader() {
+ return uploader;
+ }
+
+ public void setUploader(String uploader) {
+ this.uploader = uploader;
+ }
+
+ public int getNumChunks() {
+ return numChunks;
+ }
+
+ public void setNumChunks(int numChunks) {
+ this.numChunks = numChunks;
+ }
+
+}
\ No newline at end of file
src/java/azkaban/project/ProjectLoader.java 218(+218 -0)
diff --git a/src/java/azkaban/project/ProjectLoader.java b/src/java/azkaban/project/ProjectLoader.java
new file mode 100644
index 0000000..bd4c6d9
--- /dev/null
+++ b/src/java/azkaban/project/ProjectLoader.java
@@ -0,0 +1,218 @@
+package azkaban.project;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import azkaban.flow.Flow;
+import azkaban.project.ProjectLogEvent.EventType;
+import azkaban.user.Permission;
+import azkaban.user.User;
+import azkaban.utils.Props;
+
+public interface ProjectLoader {
+
+ /**
+ * Returns all projects which are active
+ *
+ * @return
+ * @throws ProjectManagerException
+ */
+ public List<Project> fetchAllActiveProjects() throws ProjectManagerException;
+
+ /**
+ * Loads whole project, including permissions, by the project id.
+ *
+ * @param id
+ * @return
+ * @throws ProjectManagerException
+ */
+ public Project fetchProjectById(int id) throws ProjectManagerException;
+
+ /**
+ * Should create an empty project with the given name and user and adds it
+ * to the data store. It will auto assign a unique id for this project if
+ * successful.
+ *
+ * If an active project of the same name exists, it will throw an exception.
+ * If the name and description of the project exceeds the store's
+ * constraints, it will throw an exception.
+ *
+ * @param name
+ * @return
+ * @throws ProjectManagerException if an active project of the same name exists.
+ */
+ public Project createNewProject(String name, String description, User creator) throws ProjectManagerException;
+
+ /**
+ * Removes the project by marking it inactive.
+ *
+ * @param project
+ * @throws ProjectManagerException
+ */
+ public void removeProject(Project project, String user) throws ProjectManagerException;
+
+ /**
+ * Adds and updates the user permissions. Does not check if the user is valid.
+ * If the permission doesn't exist, it adds. If the permission exists, it updates.
+ *
+ * @param project
+ * @param name
+ * @param perm
+ * @param isGroup
+ * @throws ProjectManagerException
+ */
+ public void updatePermission(Project project, String name, Permission perm, boolean isGroup) throws ProjectManagerException;
+
+ public void removePermission(Project project, String name, boolean isGroup) throws ProjectManagerException;
+
+ /**
+ * Modifies and commits the project description.
+ *
+ * @param project
+ * @param description
+ * @throws ProjectManagerException
+ */
+ public void updateDescription(Project project, String description, String user) throws ProjectManagerException;
+
+ /**
+ * Stores logs for a particular project. Will soft fail rather than throw exception.
+ *
+ * @param project
+ * @param type
+ * @param message
+ * return true if the posting was success.
+ */
+ public boolean postEvent(Project project, EventType type, String user, String message);
+
+ /**
+ * Returns all the events for a project sorted
+ *
+ * @param project
+ * @return
+ */
+ public List<ProjectLogEvent> getProjectEvents(Project project, int num, int skip) throws ProjectManagerException;
+
+ /**
+ * Will upload the files and return the version number of the file uploaded.
+ */
+ public void uploadProjectFile(Project project, int version, String filetype, String filename, File localFile, String user) throws ProjectManagerException;
+
+ /**
+ * Get file that's uploaded.
+ *
+ * @return
+ */
+ public ProjectFileHandler getUploadedFile(Project project, int version) throws ProjectManagerException;
+
+ /**
+ * Get file that's uploaded.
+ *
+ * @return
+ */
+ public ProjectFileHandler getUploadedFile(int projectId, int version) throws ProjectManagerException;
+
+ /**
+ * Changes and commits different project version.
+ *
+ * @param project
+ * @param version
+ * @throws ProjectManagerException
+ */
+ public void changeProjectVersion(Project project, int version, String user) throws ProjectManagerException;
+
+ /**
+ * Uploads all computed flows
+ *
+ * @param project
+ * @param version
+ * @param flows
+ * @throws ProjectManagerException
+ */
+ public void uploadFlows(Project project, int version, Collection<Flow> flows) throws ProjectManagerException;
+
+ /**
+ * Upload just one flow.
+ *
+ * @param project
+ * @param version
+ * @param flow
+ * @throws ProjectManagerException
+ */
+ public void uploadFlow(Project project, int version, Flow flow) throws ProjectManagerException;
+
+ /**
+ * Fetches one particular flow.
+ *
+ * @param project
+ * @param version
+ * @param flowId
+ * @throws ProjectManagerException
+ */
+ public Flow fetchFlow(Project project, String flowId) throws ProjectManagerException;
+
+ /**
+ * Fetches all flows.
+ *
+ * @param project
+ * @param version
+ * @param flowId
+ * @throws ProjectManagerException
+ */
+ public List<Flow> fetchAllProjectFlows(Project project) throws ProjectManagerException;
+
+ /**
+ * Gets the latest upload version.
+ */
+ public int getLatestProjectVersion(Project project) throws ProjectManagerException;
+
+ /**
+ * Upload Project properties
+ *
+ * @param project
+ * @param path
+ * @param properties
+ * @throws ProjectManagerException
+ */
+ public void uploadProjectProperty(Project project, Props props) throws ProjectManagerException;
+
+ /**
+ * Upload Project properties. Map contains key value of path and properties
+ *
+ * @param project
+ * @param path
+ * @param properties
+ * @throws ProjectManagerException
+ */
+ public void uploadProjectProperties(Project project, List<Props> properties) throws ProjectManagerException;
+
+ /**
+ * Fetch project properties
+ *
+ * @param project
+ * @param propsName
+ * @return
+ * @throws ProjectManagerException
+ */
+ public Props fetchProjectProperty(Project project, String propsName) throws ProjectManagerException;
+
+ /**
+ * Fetch all project properties
+ *
+ * @param project
+ * @return
+ * @throws ProjectManagerException
+ */
+ public Map<String,Props> fetchProjectProperties(int projectId, int version) throws ProjectManagerException;
+
+ /**
+ * Cleans all project versions less tha
+ *
+ * @param projectId
+ * @param version
+ * @throws ProjectManagerException
+ */
+ public void cleanOlderProjectVersion(int projectId, int version) throws ProjectManagerException;
+
+}
\ No newline at end of file
diff --git a/src/java/azkaban/project/ProjectLogEvent.java b/src/java/azkaban/project/ProjectLogEvent.java
new file mode 100644
index 0000000..1d109bb
--- /dev/null
+++ b/src/java/azkaban/project/ProjectLogEvent.java
@@ -0,0 +1,80 @@
+package azkaban.project;
+
+public class ProjectLogEvent {
+ /**
+ * Log event type messages. Do not change the numeric representation of each enum.
+ *
+ * Only represent from 0 to 255 different codes.
+ */
+ public static enum EventType {
+ ERROR(128), CREATED(1), DELETED(2), USER_PERMISSION(3), GROUP_PERMISSION(4), DESCRIPTION(5), UPLOADED(6), SCHEDULE(7);
+
+ private int numVal;
+
+ EventType(int numVal) {
+ this.numVal = numVal;
+ }
+
+ public int getNumVal() {
+ return numVal;
+ }
+
+ public static EventType fromInteger(int x) {
+ switch (x) {
+ case 1:
+ return CREATED;
+ case 2:
+ return DELETED;
+ case 3:
+ return USER_PERMISSION;
+ case 4:
+ return GROUP_PERMISSION;
+ case 5:
+ return DESCRIPTION;
+ case 6:
+ return UPLOADED;
+ case 7:
+ return SCHEDULE;
+ case 128:
+ return ERROR;
+ default:
+ return ERROR;
+ }
+ }
+ }
+
+ private final int projectId;
+ private final String user;
+ private final long time;
+ private final EventType type;
+ private final String message;
+
+ public ProjectLogEvent(int projectId, EventType type, long time, String user, String message) {
+ this.projectId = projectId;
+ this.user = user;
+ this.time = time;
+ this.type = type;
+ this.message = message;
+ }
+
+ public int getProjectId() {
+ return projectId;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public long getTime() {
+ return time;
+ }
+
+ public EventType getType() {
+ return type;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+}
\ No newline at end of file
src/java/azkaban/project/ProjectManager.java 322(+286 -36)
diff --git a/src/java/azkaban/project/ProjectManager.java b/src/java/azkaban/project/ProjectManager.java
index 696cce0..df73c69 100644
--- a/src/java/azkaban/project/ProjectManager.java
+++ b/src/java/azkaban/project/ProjectManager.java
@@ -1,63 +1,313 @@
-/*
- * Copyright 2012 LinkedIn, Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
package azkaban.project;
import java.io.File;
import java.io.IOException;
-import java.io.Writer;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+import java.util.zip.ZipFile;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.log4j.Logger;
+import azkaban.flow.Flow;
+import azkaban.project.ProjectLogEvent.EventType;
+import azkaban.user.Permission;
import azkaban.user.User;
+import azkaban.user.Permission.Type;
+import azkaban.utils.DirectoryFlowLoader;
import azkaban.utils.Props;
+import azkaban.utils.Utils;
-public interface ProjectManager {
-
- public List<String> getProjectNames();
-
- public List<Project> getUserProjects(User user);
+public class ProjectManager {
+ private static final Logger logger = Logger.getLogger(ProjectManager.class);
- public List<Project> getUserProjectsByRe(User user, String searchTerm);
+ private ConcurrentHashMap<Integer, Project> projectsById = new ConcurrentHashMap<Integer, Project>();
+ private ConcurrentHashMap<String, Project> projectsByName = new ConcurrentHashMap<String, Project>();
+ private final ProjectLoader projectLoader;
+ private final Props props;
+ private final File tempDir;
+ private final int projectVersionRetention;
- public List<Project> getProjects();
+ public ProjectManager(ProjectLoader loader, Props props) {
+ this.projectLoader = loader;
+ this.props = props;
+ this.tempDir = new File(this.props.getString("project.temp.dir", "temp"));
+ this.projectVersionRetention = (props.getInt("project.version.retention", 3));
+ logger.info("Project version retention is set to " + projectVersionRetention);
+
+ if (!tempDir.exists()) {
+ tempDir.mkdirs();
+ }
+
+ loadAllProjects();
+ }
- public List<Project> getProjectsByRe(String searchTerm);
+ private void loadAllProjects() {
+ List<Project> projects;
+ try {
+ projects = projectLoader.fetchAllActiveProjects();
+ } catch (ProjectManagerException e) {
+ throw new RuntimeException("Could not load projects from store.", e);
+ }
+ for (Project proj: projects) {
+ projectsByName.put(proj.getName(), proj);
+ projectsById.put(proj.getId(), proj);
+ }
+
+ for (Project proj: projects) {
+ loadAllProjectFlows(proj);
+ }
+ }
+
+ private void loadAllProjectFlows(Project project) {
+ try {
+ List<Flow> flows = projectLoader.fetchAllProjectFlows(project);
+ Map<String, Flow> flowMap = new HashMap<String, Flow>();
+ for (Flow flow: flows) {
+ flowMap.put(flow.getId(), flow);
+ }
+
+ project.setFlows(flowMap);
+ }
+ catch (ProjectManagerException e) {
+ throw new RuntimeException("Could not load projects flows from store.", e);
+ }
+ }
+
+ public List<String> getProjectNames() {
+ return new ArrayList<String>(projectsByName.keySet());
+ }
+
+ public List<Project> getUserProjects(User user) {
+ ArrayList<Project> array = new ArrayList<Project>();
+ for (Project project : projectsById.values()) {
+ Permission perm = project.getUserPermission(user);
+
+ if (perm != null && (perm.isPermissionSet(Type.ADMIN) || perm.isPermissionSet(Type.READ))) {
+ array.add(project);
+ }
+ }
+ return array;
+ }
- public void commitProject(String name) throws ProjectManagerException;
+ public List<Project> getUserProjectsByRegex(User user, String regexPattern) {
+ List<Project> array = new ArrayList<Project>();
+ Pattern pattern;
+ try {
+ pattern = Pattern.compile(regexPattern, Pattern.CASE_INSENSITIVE);
+ } catch (PatternSyntaxException e) {
+ logger.error("Bad regex pattern " + regexPattern);
+ return array;
+ }
+
+
+ for (Project project : projectsById.values()) {
+ Permission perm = project.getUserPermission(user);
- public Project getProject(String name);
+ if (perm != null && (perm.isPermissionSet(Type.ADMIN) || perm.isPermissionSet(Type.READ))) {
+ if(pattern.matcher(project.getName()).find() ) {
+ array.add(project);
+ }
+ }
+ }
+ return array;
+ }
- public void uploadProject(String projectName, File projectDir, User uploader, boolean force) throws ProjectManagerException;
+ public List<Project> getProjects() {
+ return new ArrayList<Project>(projectsById.values());
+ }
- public Project createProject(String projectName, String description, User creator) throws ProjectManagerException;
+ public List<Project> getProjectsByRegex(String regexPattern) {
+ List<Project> allProjects = new ArrayList<Project>();
+ Pattern pattern;
+ try {
+ pattern = Pattern.compile(regexPattern, Pattern.CASE_INSENSITIVE);
+ } catch (PatternSyntaxException e) {
+ logger.error("Bad regex pattern " + regexPattern);
+ return allProjects;
+ }
+ for(Project project : getProjects()) {
+ if(pattern.matcher(project.getName()).find()) {
+ allProjects.add(project);
+ }
+ }
+ return allProjects;
+ }
- public Project removeProject(String projectName) throws ProjectManagerException;
+ public Project getProject(String name) {
+ return projectsByName.get(name);
+ }
- public Props getProperties(String projectName, String source) throws ProjectManagerException;
+ public Project getProject(int id) {
+ return projectsById.get(id);
+ }
- public Props getProperties(Project project, String source) throws ProjectManagerException;
+ public Project createProject(String projectName, String description, User creator) throws ProjectManagerException {
+ if (projectName == null || projectName.trim().isEmpty()) {
+ throw new ProjectManagerException("Project name cannot be empty.");
+ }
+ else if (description == null || description.trim().isEmpty()) {
+ throw new ProjectManagerException("Description cannot be empty.");
+ }
+ else if (creator == null) {
+ throw new ProjectManagerException("Valid creator user must be set.");
+ }
+ else if (!projectName.matches("[a-zA-Z][a-zA-Z_0-9|-]*")) {
+ throw new ProjectManagerException("Project names must start with a letter, followed by any number of letters, digits, '-' or '_'.");
+ }
- public HashMap<String, Props> getAllFlowProperties(Project project, String flowId) throws ProjectManagerException;
+ if (projectsByName.contains(projectName)) {
+ throw new ProjectManagerException("Project already exists.");
+ }
+
+ logger.info("Trying to create " + projectName + " by user " + creator.getUserId());
+ Project newProject = projectLoader.createNewProject(projectName, description, creator);
+ projectsByName.put(newProject.getName(), newProject);
+ projectsById.put(newProject.getId(), newProject);
+
+ // Add permission to project
+ projectLoader.updatePermission(newProject, creator.getUserId(), new Permission(Permission.Type.ADMIN), false);
+
+ projectLoader.postEvent(newProject, EventType.CREATED, creator.getUserId(), null);
+
+ return newProject;
+ }
+
+ public synchronized Project removeProject(Project project, User deleter) throws ProjectManagerException {
+ projectLoader.removeProject(project, deleter.getUserId());
+ projectLoader.postEvent(project, EventType.DELETED, deleter.getUserId(), null);
+
+ projectsByName.remove(project.getName());
+ projectsById.remove(project.getId());
+
+ return project;
+ }
+
+ public void updateProjectDescription(Project project, String description, User modifier) throws ProjectManagerException {
+ projectLoader.updateDescription(project, description, modifier.getUserId());
+ projectLoader.postEvent(project, EventType.DESCRIPTION, modifier.getUserId(), "Description changed to " + description);
+ }
+
+ public List<ProjectLogEvent> getProjectEventLogs(Project project, int results, int skip) throws ProjectManagerException {
+ return projectLoader.getProjectEvents(project, results, skip);
+ }
+
+ public Props getProperties(Project project, String source) throws ProjectManagerException {
+ return projectLoader.fetchProjectProperty(project, source);
+ }
+
+ public void updateProjectPermission(Project project, String name, Permission perm, boolean group, User modifier) throws ProjectManagerException {
+ logger.info("User " + modifier.getUserId() + " updating permissions for project " + project.getName() + " for " + name + " " + perm.toString());
+ projectLoader.updatePermission(project, name, perm, group);
+ if (group) {
+ projectLoader.postEvent(project, EventType.GROUP_PERMISSION, modifier.getUserId(), "Permission for group " + name + " set to " + perm.toString());
+ }
+ else {
+ projectLoader.postEvent(project, EventType.USER_PERMISSION, modifier.getUserId(), "Permission for user " + name + " set to " + perm.toString());
+ }
+ }
+
+ public void removeProjectPermission(Project project, String name, boolean group, User modifier) throws ProjectManagerException {
+ logger.info("User " + modifier.getUserId() + " removing permissions for project " + project.getName() + " for " + name);
+ projectLoader.removePermission(project, name, group);
+ if (group) {
+ projectLoader.postEvent(project, EventType.GROUP_PERMISSION, modifier.getUserId(), "Permission for group " + name + " removed.");
+ }
+ else {
+ projectLoader.postEvent(project, EventType.USER_PERMISSION, modifier.getUserId(), "Permission for user " + name + " removed.");
+ }
+ }
+
+ public void uploadProject(Project project, File archive, String fileType, User uploader) throws ProjectManagerException {
+ logger.info("Uploading files to " + project.getName());
+
+ // Unzip.
+ File file = null;
+ try {
+ if (fileType.equals("zip")) {
+ file = unzipFile(archive);
+ }
+ else {
+ throw new ProjectManagerException("Unsupported archive type for file " + archive.getName());
+ }
+ } catch(IOException e) {
+ throw new ProjectManagerException("Error unzipping file.", e);
+ }
- public void copyProjectSourceFilesToDirectory(Project project, File directory) throws ProjectManagerException;
+ logger.info("Validating Flow for upload " + archive.getName());
+ DirectoryFlowLoader loader = new DirectoryFlowLoader(logger);
+ loader.loadProjectFlow(file);
+ if(!loader.getErrors().isEmpty()) {
+ logger.error("Error found in upload to " + project.getName() + ". Cleaning up.");
+
+ try {
+ FileUtils.deleteDirectory(file);
+ } catch (IOException e) {
+ file.deleteOnExit();
+ e.printStackTrace();
+ }
+
+ StringBuffer errorMessage = new StringBuffer();
+ errorMessage.append("Error found in upload. Cannot upload.\n");
+ for (String error: loader.getErrors()) {
+ errorMessage.append(error);
+ errorMessage.append('\n');
+ }
- public void getProjectLogs(String projectId, long tailBytes, long skipBytes, Writer writer) throws IOException;
+ throw new ProjectManagerException(errorMessage.toString());
+ }
+
+ Map<String, Props> jobProps = loader.getJobProps();
+ List<Props> propProps = loader.getProps();
+
+ synchronized(project) {
+ int newVersion = projectLoader.getLatestProjectVersion(project) + 1;
+ Map<String, Flow> flows = loader.getFlowMap();
+ for (Flow flow: flows.values()) {
+ flow.setProjectId(project.getId());
+ flow.setVersion(newVersion);
+ }
+
+ logger.info("Uploading file to db " + archive.getName());
+ projectLoader.uploadProjectFile(project, newVersion, fileType, archive.getName(), archive, uploader.getUserId());
+ logger.info("Uploading flow to db " + archive.getName());
+ projectLoader.uploadFlows(project, newVersion, flows.values());
+ logger.info("Changing project versions " + archive.getName());
+ projectLoader.changeProjectVersion(project, newVersion, uploader.getUserId());
+ project.setFlows(flows);
+ logger.info("Uploading Job properties");
+ projectLoader.uploadProjectProperties(project, new ArrayList<Props>(jobProps.values()));
+ logger.info("Uploading Props properties");
+ projectLoader.uploadProjectProperties(project, propProps);
+ }
+
+ logger.info("Uploaded project files. Cleaning up temp files.");
+ projectLoader.postEvent(project, EventType.UPLOADED, uploader.getUserId(), "Uploaded project files zip " + archive.getName());
+ try {
+ FileUtils.deleteDirectory(file);
+ } catch (IOException e) {
+ file.deleteOnExit();
+ e.printStackTrace();
+ }
+ logger.info("Cleaning up old install files older than " + (project.getVersion() - projectVersionRetention));
+ projectLoader.cleanOlderProjectVersion(project.getId(), project.getVersion() - projectVersionRetention);
+ }
+ private File unzipFile(File archiveFile) throws IOException {
+ ZipFile zipfile = new ZipFile(archiveFile);
+ File unzipped = Utils.createTempDir(tempDir);
+ Utils.unzip(zipfile, unzipped);
+ return unzipped;
+ }
-}
\ No newline at end of file
+ public void postProjectEvent(Project project, EventType type, String user,String message) {
+ projectLoader.postEvent(project, type, user, message);
+ }
+}
src/java/azkaban/scheduler/JdbcScheduleLoader.java 312(+312 -0)
diff --git a/src/java/azkaban/scheduler/JdbcScheduleLoader.java b/src/java/azkaban/scheduler/JdbcScheduleLoader.java
new file mode 100644
index 0000000..febfd09
--- /dev/null
+++ b/src/java/azkaban/scheduler/JdbcScheduleLoader.java
@@ -0,0 +1,312 @@
+/*
+ * Copyright 2012 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package azkaban.scheduler;
+
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.dbutils.DbUtils;
+import org.apache.commons.dbutils.QueryRunner;
+import org.apache.commons.dbutils.ResultSetHandler;
+import org.apache.log4j.Logger;
+
+import org.joda.time.DateTimeZone;
+import org.joda.time.ReadablePeriod;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+
+import azkaban.utils.DataSourceUtils;
+import azkaban.utils.Props;
+
+
+public class JdbcScheduleLoader implements ScheduleLoader {
+
+ private DataSource dataSource;
+ private static DateTimeFormatter FILE_DATEFORMAT = DateTimeFormat.forPattern("yyyy-MM-dd.HH.mm.ss.SSS");
+ private static Logger logger = Logger.getLogger(JdbcScheduleLoader.class);
+
+ private static final String SCHEDULE = "schedule";
+ // schedule ids
+// private static final String PROJECTGUID = "projectGuid";
+// private static final String FLOWGUID = "flowGuid";
+//
+// private static final String SCHEDULEID = "scheduleId";
+ private static final String PROJECTID = "projectId";
+ private static final String PROJECTNAME = "projectName";
+ private static final String FLOWNAME = "flowName";
+ // status
+ private static final String STATUS = "status";
+ // schedule info
+ private static final String FIRSTSCHEDTIME = "firstSchedTime";
+ private static final String TIMEZONE = "timezone";
+ private static final String PERIOD = "period";
+ private static final String LASTMODIFYTIME = "lastModifyTime";
+ private static final String NEXTEXECTIME = "nextExecTime";
+ // auditing info
+ private static final String SUBMITTIME = "submitTime";
+ private static final String SUBMITUSER = "userSubmit";
+
+ private static final String scheduleTableName = "schedules";
+
+ private static String SELECT_SCHEDULE_BY_KEY =
+ "SELECT project_id, project_name, flow_name, status, first_sched_time, timezone, period, last_modify_time, next_exec_time, submit_time, submit_user FROM " + scheduleTableName + " WHERE project_id=? AND flow_name=?";
+
+ private static String SELECT_ALL_SCHEDULES =
+ "SELECT project_id, project_name, flow_name, status, first_sched_time, timezone, period, last_modify_time, next_exec_time, submit_time, submit_user FROM " + scheduleTableName;
+
+ private static String INSERT_SCHEDULE =
+ "INSERT INTO " + scheduleTableName + " ( project_id, project_name, flow_name, status, first_sched_time, timezone, period, last_modify_time, next_exec_time, submit_time, submit_user) values (?,?,?,?,?,?,?,?,?,?,?)";
+
+ private static String REMOVE_SCHEDULE_BY_KEY =
+ "DELETE FROM " + scheduleTableName + " WHERE project_id=? AND flow_name=?";
+
+ private static String UPDATE_SCHEDULE_BY_KEY =
+ "UPDATE " + scheduleTableName + " SET status=?, first_sched_time=?, timezone=?, period=?, last_modify_time=?, next_exec_time=?, submit_time=?, submit_user=? WHERE project_id=? AND flow_name=?";
+
+ private static String UPDATE_NEXT_EXEC_TIME =
+ "UPDATE " + scheduleTableName + " SET next_exec_time=? WHERE project_id=? AND flow_name=?";
+
+
+ public JdbcScheduleLoader(Props props) {
+ String databaseType = props.getString("database.type");
+
+ if (databaseType.equals("mysql")) {
+ int port = props.getInt("mysql.port");
+ String host = props.getString("mysql.host");
+ String database = props.getString("mysql.database");
+ String user = props.getString("mysql.user");
+ String password = props.getString("mysql.password");
+ int numConnections = props.getInt("mysql.numconnections");
+
+ dataSource = DataSourceUtils.getMySQLDataSource(host, port, database, user, password, numConnections);
+ }
+ }
+
+ @Override
+ public List<Schedule> loadSchedules() throws ScheduleManagerException {
+ logger.info("Loading all schedules from db.");
+ Connection connection = null;
+ try {
+ connection = dataSource.getConnection();
+ } catch (SQLException e1) {
+ logger.error("Failed to get db connection!");
+ e1.printStackTrace();
+ DbUtils.closeQuietly(connection);
+ throw new ScheduleManagerException("Failed to get db connection!", e1);
+ }
+
+ QueryRunner runner = new QueryRunner();
+ ResultSetHandler<List<Schedule>> handler = new ScheduleResultHandler();
+
+ List<Schedule> schedules;
+
+ try {
+ schedules = runner.query(connection, SELECT_ALL_SCHEDULES, handler);
+ } catch (SQLException e) {
+ logger.error(SELECT_ALL_SCHEDULES + " failed.");
+
+ DbUtils.closeQuietly(connection);
+ throw new ScheduleManagerException("Loading schedules from db failed. ", e);
+ }
+
+ // filter the schedules
+ for(Schedule sched : schedules) {
+ if(!sched.updateTime()) {
+ logger.info("Schedule " + sched.getScheduleName() + " was scheduled before azkaban start, skipping it.");
+ schedules.remove(sched);
+ removeSchedule(sched);
+ }
+ else {
+ try {
+ updateNextExecTime(sched, connection);
+ } catch (Exception e) {
+ DbUtils.closeQuietly(connection);
+ throw new ScheduleManagerException("Update next execution time failed.", e);
+ }
+ logger.info("Schedule " + sched.getScheduleName() + " loaded and updated.");
+ }
+ }
+
+ DbUtils.closeQuietly(connection);
+
+ logger.info("Loaded " + schedules.size() + " schedules.");
+
+ return schedules;
+ }
+
+ @Override
+ public void removeSchedule(Schedule s) throws ScheduleManagerException {
+ logger.info("Removing schedule " + s.getScheduleName() + " from db.");
+
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ try {
+ int removes = runner.update(REMOVE_SCHEDULE_BY_KEY, s.getProjectId(), s.getFlowName());
+ if (removes == 0) {
+ throw new ScheduleManagerException("No schedule has been removed.");
+ }
+ } catch (SQLException e) {
+ logger.error(REMOVE_SCHEDULE_BY_KEY + " failed.");
+ throw new ScheduleManagerException("Remove schedule " + s.getScheduleName() + " from db failed. ", e);
+ }
+ }
+
+ @Override
+ public void insertSchedule(Schedule s) throws ScheduleManagerException {
+ logger.info("Inserting schedule " + s.getScheduleName() + " into db.");
+
+ QueryRunner runner = new QueryRunner(dataSource);
+ try {
+ int inserts = runner.update(
+ INSERT_SCHEDULE,
+ s.getProjectId(),
+ s.getProjectName(),
+ s.getFlowName(),
+ s.getStatus(),
+ s.getFirstSchedTime(),
+ s.getTimezone().getID(),
+ Schedule.createPeriodString(s.getPeriod()),
+ s.getLastModifyTime(),
+ s.getNextExecTime(),
+ s.getSubmitTime(),
+ s.getSubmitUser());
+ if (inserts == 0) {
+ throw new ScheduleManagerException("No schedule has been inserted.");
+ }
+ } catch (SQLException e) {
+ logger.error(INSERT_SCHEDULE + " failed.");
+ throw new ScheduleManagerException("Insert schedule " + s.getScheduleName() + " into db failed. ", e);
+ }
+ }
+
+ private void updateNextExecTime(Schedule s, Connection connection) throws ScheduleManagerException
+ {
+ QueryRunner runner = new QueryRunner();
+ try {
+ int updates = runner.update(connection, UPDATE_NEXT_EXEC_TIME, s.getNextExecTime(), s.getProjectId(), s.getFlowName());
+ } catch (SQLException e) {
+ logger.error(UPDATE_NEXT_EXEC_TIME + " failed.");
+ throw new ScheduleManagerException("Update schedule " + s.getScheduleName() + " into db failed. ", e);
+ }
+ }
+
+ @Override
+ public void updateSchedule(Schedule s) throws ScheduleManagerException {
+ logger.info("Updating schedule " + s.getScheduleName() + " into db.");
+
+ QueryRunner runner = new QueryRunner(dataSource);
+
+ try {
+ int updates = runner.update(
+ UPDATE_SCHEDULE_BY_KEY,
+ s.getStatus(),
+ s.getFirstSchedTime(),
+ s.getTimezone().getID(),
+ Schedule.createPeriodString(s.getPeriod()),
+ s.getLastModifyTime(),
+ s.getNextExecTime(),
+ s.getSubmitTime(),
+ s.getSubmitUser(),
+ s.getProjectId(),
+ s.getFlowName());
+ if (updates == 0) {
+ throw new ScheduleManagerException("No schedule has been updated.");
+ }
+ } catch (SQLException e) {
+ logger.error(UPDATE_SCHEDULE_BY_KEY + " failed.");
+ throw new ScheduleManagerException("Update schedule " + s.getScheduleName() + " into db failed. ", e);
+ }
+ }
+
+// private Schedule fromJSON(HashMap<String, Object> obj) {
+// long projectGuid = Long.valueOf((String) obj.get(PROJECTGUID));
+// String projectId = (String) obj.get(PROJECTID);
+// long flowGuid = Long.valueOf((String) obj.get(FLOWGUID));
+// String flowId = (String) obj.get(FLOWID);
+// String status = (String) obj.get(STATUS);
+// long firstSchedTime = Long.valueOf((String) obj.get(FIRSTSCHEDTIME));
+// String timezone = (String) obj.get(TIMEZONE);
+// String period = (String) obj.get(PERIOD);
+// long lastModifyTime = Long.valueOf((String) obj.get(LASTMODIFYTIME));
+// long nextExecTime = Long.valueOf((String) obj.get(NEXTEXECTIME));
+// long submitTime = Long.valueOf((String) obj.get(SUBMITTIME));
+// String submitUser = (String) obj.get(SUBMITUSER);
+//
+// return new Schedule(projectId, flowId, status, firstSchedTime, timezone, period, lastModifyTime, nextExecTime, submitTime, submitUser);
+//
+// }
+//
+// private HashMap<String, Object> toJSON(Schedule s) {
+// HashMap<String, Object> object = new HashMap<String, Object>();
+//// object.put(PROJECTGUID, s.getProjectGuid());
+// object.put(SCHEDULEID, s.getScheduleId());
+// object.put(PROJECTID, s.getProjectId());
+//// object.put(FLOWGUID, s.getFlowGuid());
+// object.put(FLOWID, s.getFlowId());
+//
+// object.put(STATUS, s.getStatus());
+//
+// object.put(FIRSTSCHEDTIME, s.getFirstSchedTime());
+// object.put(TIMEZONE, s.getTimezone());
+// object.put(PERIOD, s.getPeriod());
+//
+// object.put(LASTMODIFYTIME, s.getLastModifyTime());
+// object.put(NEXTEXECTIME, s.getNextExecTime());
+// object.put(SUBMITTIME, s.getSubmitTime());
+// object.put(SUBMITUSER, s.getSubmitUser());
+//
+// return object;
+// }
+
+ public class ScheduleResultHandler implements ResultSetHandler<List<Schedule>> {
+ @Override
+ public List<Schedule> handle(ResultSet rs) throws SQLException {
+ if (!rs.next()) {
+ return Collections.<Schedule>emptyList();
+ }
+
+ ArrayList<Schedule> schedules = new ArrayList<Schedule>();
+ do {
+ int projectId = rs.getInt(1);
+ String projectName = rs.getString(2);
+ String flowName = rs.getString(3);
+ String status = rs.getString(4);
+ long firstSchedTime = rs.getLong(5);
+ DateTimeZone timezone = DateTimeZone.forID(rs.getString(6));
+ ReadablePeriod period = Schedule.parsePeriodString(rs.getString(7));
+ long lastModifyTime = rs.getLong(8);
+ long nextExecTime = rs.getLong(9);
+ long submitTime = rs.getLong(10);
+ String submitUser = rs.getString(11);
+
+ Schedule s = new Schedule(projectId, projectName, flowName, status, firstSchedTime, timezone, period, lastModifyTime, nextExecTime, submitTime, submitUser);
+
+ schedules.add(s);
+ } while (rs.next());
+
+ return schedules;
+ }
+
+ }
+}
\ No newline at end of file
src/java/azkaban/scheduler/Schedule.java 270(+270 -0)
diff --git a/src/java/azkaban/scheduler/Schedule.java b/src/java/azkaban/scheduler/Schedule.java
new file mode 100644
index 0000000..a8c0c91
--- /dev/null
+++ b/src/java/azkaban/scheduler/Schedule.java
@@ -0,0 +1,270 @@
+/*
+ * Copyright 2012 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package azkaban.scheduler;
+
+
+
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.Days;
+import org.joda.time.DurationFieldType;
+import org.joda.time.Hours;
+import org.joda.time.Minutes;
+import org.joda.time.Months;
+import org.joda.time.ReadablePeriod;
+import org.joda.time.Seconds;
+import org.joda.time.Weeks;
+
+import azkaban.utils.Pair;
+
+public class Schedule{
+
+
+// private long projectGuid;
+// private long flowGuid;
+
+// private String scheduleId;
+
+ private int projectId;
+ private String projectName;
+ private String flowName;
+ private long firstSchedTime;
+ private DateTimeZone timezone;
+ private long lastModifyTime;
+ private ReadablePeriod period;
+ private long nextExecTime;
+ private String submitUser;
+ private String status;
+ private long submitTime;
+
+ public Schedule(
+ int projectId,
+ String projectName,
+ String flowName,
+ String status,
+ long firstSchedTime,
+ DateTimeZone timezone,
+ ReadablePeriod period,
+ long lastModifyTime,
+ long nextExecTime,
+ long submitTime,
+ String submitUser
+ ) {
+ this.projectId = projectId;
+ this.projectName = projectName;
+ this.flowName = flowName;
+ this.firstSchedTime = firstSchedTime;
+ this.timezone = timezone;
+ this.lastModifyTime = lastModifyTime;
+ this.period = period;
+ this.nextExecTime = nextExecTime;
+ this.submitUser = submitUser;
+ this.status = status;
+ this.submitTime = submitTime;
+ }
+
+ public Schedule(
+ int projectId,
+ String projectName,
+ String flowName,
+ String status,
+ long firstSchedTime,
+ String timezone,
+ String period,
+ long lastModifyTime,
+ long nextExecTime,
+ long submitTime,
+ String submitUser) {
+ this.projectId = projectId;
+ this.projectName = projectName;
+ this.flowName = flowName;
+ this.firstSchedTime = firstSchedTime;
+ this.timezone = DateTimeZone.forID(timezone);
+ this.lastModifyTime = lastModifyTime;
+ this.period = parsePeriodString(period);
+ this.nextExecTime = nextExecTime;
+ this.submitUser = submitUser;
+ this.status = status;
+ this.submitTime = submitTime;
+ }
+
+ public String getScheduleName() {
+ return projectName + "." + flowName + " (" + projectId + ")";
+ }
+
+ public Pair<Integer, String> getScheduleId() {
+ return new Pair<Integer, String>(getProjectId(), getFlowName());
+ }
+
+ public int getProjectId() {
+ return projectId;
+ }
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public String getFlowName() {
+ return flowName;
+ }
+
+ public long getFirstSchedTime() {
+ return firstSchedTime;
+ }
+
+ public DateTimeZone getTimezone() {
+ return timezone;
+ }
+
+ public long getLastModifyTime() {
+ return lastModifyTime;
+ }
+
+ public ReadablePeriod getPeriod() {
+ return period;
+ }
+
+ public long getNextExecTime() {
+ return nextExecTime;
+ }
+
+ public String getSubmitUser() {
+ return submitUser;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public long getSubmitTime() {
+ return submitTime;
+ }
+
+ public boolean updateTime() {
+ if (new DateTime(nextExecTime).isAfterNow()) {
+ return true;
+ }
+
+ if (period != null) {
+ DateTime nextTime = getNextRuntime(nextExecTime, timezone, period);
+
+ this.nextExecTime = nextTime.getMillis();
+ return true;
+ }
+
+ return false;
+ }
+// public String getFlowId(){
+// return this.scheduleId.split("\\.")[1];
+// }
+//
+// public String getProjectId(){
+// return this.scheduleId.split("\\.")[0];
+// }
+
+
+ private DateTime getNextRuntime(long scheduleTime, DateTimeZone timezone, ReadablePeriod period) {
+ DateTime now = new DateTime();
+ DateTime date = new DateTime(scheduleTime).withZone(timezone);
+ int count = 0;
+ while (!now.isBefore(date)) {
+ if (count > 100000) {
+ throw new IllegalStateException(
+ "100000 increments of period did not get to present time.");
+ }
+
+ if (period == null) {
+ break;
+ } else {
+ date = date.plus(period);
+ }
+
+ count += 1;
+ }
+
+ return date;
+ }
+
+ public static ReadablePeriod parsePeriodString(String periodStr) {
+ ReadablePeriod period;
+ char periodUnit = periodStr.charAt(periodStr.length() - 1);
+ if (periodUnit == 'n') {
+ return null;
+ }
+
+ int periodInt = Integer.parseInt(periodStr.substring(0,
+ periodStr.length() - 1));
+ switch (periodUnit) {
+ case 'M':
+ period = Months.months(periodInt);
+ break;
+ case 'w':
+ period = Weeks.weeks(periodInt);
+ break;
+ case 'd':
+ period = Days.days(periodInt);
+ break;
+ case 'h':
+ period = Hours.hours(periodInt);
+ break;
+ case 'm':
+ period = Minutes.minutes(periodInt);
+ break;
+ case 's':
+ period = Seconds.seconds(periodInt);
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid schedule period unit '"
+ + periodUnit);
+ }
+
+ return period;
+ }
+
+ public static String createPeriodString(ReadablePeriod period) {
+ String periodStr = "n";
+
+ if (period == null) {
+ return "n";
+ }
+
+ if (period.get(DurationFieldType.months()) > 0) {
+ int months = period.get(DurationFieldType.months());
+ periodStr = months + "M";
+ } else if (period.get(DurationFieldType.weeks()) > 0) {
+ int weeks = period.get(DurationFieldType.weeks());
+ periodStr = weeks + "w";
+ } else if (period.get(DurationFieldType.days()) > 0) {
+ int days = period.get(DurationFieldType.days());
+ periodStr = days + "d";
+ } else if (period.get(DurationFieldType.hours()) > 0) {
+ int hours = period.get(DurationFieldType.hours());
+ periodStr = hours + "h";
+ } else if (period.get(DurationFieldType.minutes()) > 0) {
+ int minutes = period.get(DurationFieldType.minutes());
+ periodStr = minutes + "m";
+ } else if (period.get(DurationFieldType.seconds()) > 0) {
+ int seconds = period.get(DurationFieldType.seconds());
+ periodStr = seconds + "s";
+ }
+
+ return periodStr;
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/src/java/azkaban/scheduler/ScheduleLoader.java b/src/java/azkaban/scheduler/ScheduleLoader.java
index 932d673..4b55b4e 100644
--- a/src/java/azkaban/scheduler/ScheduleLoader.java
+++ b/src/java/azkaban/scheduler/ScheduleLoader.java
@@ -18,10 +18,14 @@ package azkaban.scheduler;
import java.util.List;
-
public interface ScheduleLoader {
- public void saveSchedule(List<ScheduledFlow> schedule);
- public List<ScheduledFlow> loadSchedule();
+ public void insertSchedule(Schedule s) throws ScheduleManagerException;
+
+ public void updateSchedule(Schedule s) throws ScheduleManagerException;
+
+ public List<Schedule> loadSchedules() throws ScheduleManagerException;
+
+ public void removeSchedule(Schedule s) throws ScheduleManagerException;
}
\ No newline at end of file
src/java/azkaban/scheduler/ScheduleManager.java 342(+168 -174)
diff --git a/src/java/azkaban/scheduler/ScheduleManager.java b/src/java/azkaban/scheduler/ScheduleManager.java
index 3bc0f40..7ba04f8 100644
--- a/src/java/azkaban/scheduler/ScheduleManager.java
+++ b/src/java/azkaban/scheduler/ScheduleManager.java
@@ -16,10 +16,8 @@
package azkaban.scheduler;
-import java.io.File;
import java.util.ArrayList;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -28,10 +26,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.log4j.Logger;
import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
import org.joda.time.ReadablePeriod;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
-import org.joda.time.format.PeriodFormat;
import azkaban.executor.ExecutableFlow;
import azkaban.executor.ExecutorManager;
@@ -41,9 +39,10 @@ import azkaban.flow.Flow;
import azkaban.jobExecutor.utils.JobExecutionException;
import azkaban.project.Project;
import azkaban.project.ProjectManager;
-import azkaban.project.ProjectManagerException;
-import azkaban.utils.Props;
+
+import azkaban.utils.Pair;
+
/**
* The ScheduleManager stores and executes the schedule. It uses a single thread
@@ -56,7 +55,8 @@ public class ScheduleManager {
private final DateTimeFormatter _dateFormat = DateTimeFormat.forPattern("MM-dd-yyyy HH:mm:ss:SSS");
private ScheduleLoader loader;
- private Map<String, ScheduledFlow> scheduleIDMap = new LinkedHashMap<String, ScheduledFlow>();
+
+ private Map<Pair<Integer, String>, Schedule> scheduleIDMap = new LinkedHashMap<Pair<Integer, String>, Schedule>();
private final ScheduleRunner runner;
private final ExecutorManager executorManager;
private final ProjectManager projectManager;
@@ -76,9 +76,16 @@ public class ScheduleManager {
this.loader = loader;
this.runner = new ScheduleRunner();
- List<ScheduledFlow> scheduleList = loader.loadSchedule();
- for (ScheduledFlow flow : scheduleList) {
- internalSchedule(flow);
+ List<Schedule> scheduleList = null;
+ try {
+ scheduleList = loader.loadSchedules();
+ } catch (ScheduleManagerException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ for (Schedule sched : scheduleList) {
+ internalSchedule(sched);
}
this.runner.start();
@@ -97,8 +104,8 @@ public class ScheduleManager {
*
* @return
*/
- public synchronized List<ScheduledFlow> getSchedule() {
- return runner.getSchedule();
+ public synchronized List<Schedule> getSchedules() {
+ return runner.getRunnerSchedules();
}
/**
@@ -106,8 +113,8 @@ public class ScheduleManager {
*
* @param id
* @return
- */
- public ScheduledFlow getSchedule(String scheduleId) {
+ */
+ public Schedule getSchedule(Pair<Integer, String> scheduleId) {
return scheduleIDMap.get(scheduleId);
}
@@ -116,14 +123,17 @@ public class ScheduleManager {
*
* @param id
*/
- public synchronized ScheduledFlow removeScheduledFlow(String scheduleId) {
- ScheduledFlow flow = scheduleIDMap.get(scheduleId);
+ public synchronized void removeSchedule(Pair<Integer, String> scheduleId) {
+ Schedule sched = scheduleIDMap.get(scheduleId);
scheduleIDMap.remove(scheduleId);
- runner.removeScheduledFlow(flow);
-
- loader.saveSchedule(getSchedule());
- return flow;
+ runner.removeRunnerSchedule(sched);
+ try {
+ loader.removeSchedule(sched);
+ } catch (ScheduleManagerException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
// public synchronized void pauseScheduledFlow(String scheduleId){
@@ -148,60 +158,63 @@ public class ScheduleManager {
// }
// }
- public ScheduledFlow schedule(
- final String scheduleId,
- final String projectId,
- final String flowId,
- final String user,
- final String userSubmit,
- final DateTime submitTime,
- final DateTime firstSchedTime,
- final ReadablePeriod period) {
- logger.info("Scheduling flow '" + scheduleId + "' for "
+ public Schedule scheduleFlow(
+ final int projectId,
+ final String projectName,
+ final String flowName,
+ final String status,
+ final long firstSchedTime,
+ final DateTimeZone timezone,
+ final ReadablePeriod period,
+ final long lastModifyTime,
+ final long nextExecTime,
+ final long submitTime,
+ final String submitUser
+ ) {
+ Schedule sched = new Schedule(projectId, projectName, flowName, status, firstSchedTime, timezone, period, lastModifyTime, nextExecTime, submitTime, submitUser);
+ logger.info("Scheduling flow '" + sched.getScheduleName() + "' for "
+ _dateFormat.print(firstSchedTime) + " with a period of "
- + PeriodFormat.getDefault().print(period));
-
- ScheduledFlow scheduleFlow = new ScheduledFlow(scheduleId, projectId, flowId, user, userSubmit, submitTime, firstSchedTime, period);
- schedule(scheduleFlow);
- return scheduleFlow;
- }
+ + period == null ? "(non-recurring)" : period);
- /**
- * Schedule the flow
- *
- * @param flowId
- * @param date
- * @param ignoreDep
- */
- public ScheduledFlow schedule(
- String scheduleId,
- String projectId,
- String flowId,
- String user,
- String userSubmit,
- DateTime submitTime,
- DateTime firstSchedTime)
- {
- logger.info("Scheduling flow '" + scheduleId + "' for " + _dateFormat.print(firstSchedTime));
- ScheduledFlow scheduleFlow = new ScheduledFlow(scheduleId, projectId, flowId, user, userSubmit, submitTime, firstSchedTime);
- schedule(scheduleFlow);
- return scheduleFlow;
+ insertSchedule(sched);
+ return sched;
}
+// /**
+// * Schedule the flow
+// *
+// * @param flowId
+// * @param date
+// * @param ignoreDep
+// */
+// public Schedule schedule(
+// String scheduleId,
+// String projectId,
+// String flowId,
+// String user,
+// String userSubmit,
+// DateTime submitTime,
+// DateTime firstSchedTime)
+// {
+// logger.info("Scheduling flow '" + scheduleId + "' for " + _dateFormat.print(firstSchedTime));
+// ScheduledFlow scheduleFlow = new ScheduledFlow(scheduleId, projectId, flowId, user, userSubmit, submitTime, firstSchedTime);
+// schedule(scheduleFlow);
+// return scheduleFlow;
+// }
+
/**
* Schedules the flow, but doesn't save the schedule afterwards.
*
* @param flow
*/
- private synchronized void internalSchedule(ScheduledFlow flow) {
- ScheduledFlow existing = scheduleIDMap.get(flow.getScheduleId());
- flow.updateTime();
+ private synchronized void internalSchedule(Schedule s) {
+ Schedule existing = scheduleIDMap.get(s.getScheduleId());
if (existing != null) {
- this.runner.removeScheduledFlow(existing);
+ this.runner.removeRunnerSchedule(existing);
}
-
- this.runner.addScheduledFlow(flow);
- scheduleIDMap.put(flow.getScheduleId(), flow);
+ s.updateTime();
+ this.runner.addRunnerSchedule(s);
+ scheduleIDMap.put(s.getScheduleId(), s);
}
/**
@@ -209,17 +222,27 @@ public class ScheduleManager {
*
* @param flow
*/
- public synchronized void schedule(ScheduledFlow flow) {
- internalSchedule(flow);
- saveSchedule();
+ public synchronized void insertSchedule(Schedule s) {
+ if(s.updateTime()) {
+ internalSchedule(s);
+ try {
+ loader.insertSchedule(s);
+ } catch (ScheduleManagerException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ else {
+ logger.error("The provided schedule is non-recurring and the scheduled time already passed. " + s.getScheduleName());
+ }
}
- /**
- * Save the schedule
- */
- private void saveSchedule() {
- loader.saveSchedule(getSchedule());
- }
+// /**
+// * Save the schedule
+// */
+// private void saveSchedule() {
+// loader.saveSchedule(getSchedule());
+// }
/**
* Thread that simply invokes the running of flows when the schedule is
@@ -229,14 +252,14 @@ public class ScheduleManager {
*
*/
public class ScheduleRunner extends Thread {
- private final PriorityBlockingQueue<ScheduledFlow> schedule;
+ private final PriorityBlockingQueue<Schedule> schedules;
private AtomicBoolean stillAlive = new AtomicBoolean(true);
// Five minute minimum intervals
private static final int TIMEOUT_MS = 300000;
public ScheduleRunner() {
- schedule = new PriorityBlockingQueue<ScheduledFlow>(1,new ScheduleComparator());
+ schedules = new PriorityBlockingQueue<Schedule>(1,new ScheduleComparator());
}
public void shutdown() {
@@ -250,8 +273,8 @@ public class ScheduleManager {
*
* @return
*/
- public synchronized List<ScheduledFlow> getSchedule() {
- return new ArrayList<ScheduledFlow>(schedule);
+ public synchronized List<Schedule> getRunnerSchedules() {
+ return new ArrayList<Schedule>(schedules);
}
/**
@@ -260,9 +283,9 @@ public class ScheduleManager {
*
* @param flow
*/
- public synchronized void addScheduledFlow(ScheduledFlow flow) {
- logger.info("Adding " + flow + " to schedule.");
- schedule.add(flow);
+ public synchronized void addRunnerSchedule(Schedule s) {
+ logger.info("Adding " + s + " to schedule runner.");
+ schedules.add(s);
// MonitorImpl.getInternalMonitorInterface().workflowEvent(null,
// System.currentTimeMillis(),
// WorkflowAction.SCHEDULE_WORKFLOW,
@@ -277,9 +300,9 @@ public class ScheduleManager {
*
* @param flow
*/
- public synchronized void removeScheduledFlow(ScheduledFlow flow) {
- logger.info("Removing " + flow + " from the schedule.");
- schedule.remove(flow);
+ public synchronized void removeRunnerSchedule(Schedule s) {
+ logger.info("Removing " + s + " from the schedule runner.");
+ schedules.remove(s);
// MonitorImpl.getInternalMonitorInterface().workflowEvent(null,
// System.currentTimeMillis(),
// WorkflowAction.UNSCHEDULE_WORKFLOW,
@@ -295,9 +318,9 @@ public class ScheduleManager {
synchronized (this) {
try {
// TODO clear up the exception handling
- ScheduledFlow schedFlow = schedule.peek();
+ Schedule s = schedules.peek();
- if (schedFlow == null) {
+ if (s == null) {
// If null, wake up every minute or so to see if
// there's something to do. Most likely there will not be.
try {
@@ -307,104 +330,75 @@ public class ScheduleManager {
}
} else {
// We've passed the flow execution time, so we will run.
- if (!schedFlow.getNextExecTime().isAfterNow()) {
+ if (!(new DateTime(s.getNextExecTime())).isAfterNow()) {
// Run flow. The invocation of flows should be quick.
- ScheduledFlow runningFlow = schedule.poll();
- logger.info("Scheduler attempting to run " + runningFlow.getScheduleId());
-
- // Execute the flow here
- try {
- Project project = projectManager.getProject(runningFlow.getProjectId());
- if (project == null) {
- logger.error("Scheduled Project " + runningFlow.getProjectId() + " does not exist!");
- throw new RuntimeException("Error finding the scheduled project. "+ runningFlow.getScheduleId());
- }
-
- Flow flow = project.getFlow(runningFlow.getFlowId());
- if (flow == null) {
- logger.error("Flow " + runningFlow.getFlowId() + " cannot be found in project " + project.getName());
- throw new RuntimeException("Error finding the scheduled flow. " + runningFlow.getScheduleId());
- }
-
- HashMap<String, Props> sources;
- try {
- sources = projectManager.getAllFlowProperties(project,runningFlow.getFlowId());
- } catch (ProjectManagerException e) {
- logger.error(e.getMessage());
- throw new RuntimeException("Error getting the flow resources. " + runningFlow.getScheduleId());
- }
-
- // Create ExecutableFlow
- ExecutableFlow exflow = executorManager.createExecutableFlow(flow);
- exflow.setSubmitUser(runningFlow.getUser());
- // TODO make disabled in scheduled flow
- // Map<String, String> paramGroup =
- // this.getParamGroup(req, "disabled");
- // for (Map.Entry<String, String> entry:
- // paramGroup.entrySet()) {
- // boolean nodeDisabled =
- // Boolean.parseBoolean(entry.getValue());
- // exflow.setStatus(entry.getKey(),
- // nodeDisabled ? Status.DISABLED :
- // Status.READY);
- // }
-
- // Create directory
- try {
- executorManager.setupExecutableFlow(exflow);
- } catch (ExecutorManagerException e) {
- try {
- executorManager.cleanupAll(exflow);
- } catch (ExecutorManagerException e1) {
- e1.printStackTrace();
- }
- logger.error(e.getMessage());
- return;
- }
-
- // Copy files to the source.
- File executionDir = new File(exflow.getExecutionPath());
+ Schedule runningSched = schedules.poll();
+
+ logger.info("Scheduler attempting to run " + runningSched.getScheduleName() );
+
+ // check if it is already running
+ if(!executorManager.isFlowRunning(runningSched.getProjectId(), runningSched.getFlowName()))
+ {
+ // Execute the flow here
try {
- projectManager.copyProjectSourceFilesToDirectory(project, executionDir);
- } catch (ProjectManagerException e) {
- try {
- executorManager.cleanupAll(exflow);
- } catch (ExecutorManagerException e1) {
- e1.printStackTrace();
+ Project project = projectManager.getProject(runningSched.getProjectId());
+ if (project == null) {
+ logger.error("Scheduled Project " + runningSched.getProjectId() + " does not exist!");
+ throw new RuntimeException("Error finding the scheduled project. "+ runningSched.getProjectId());
+ }
+ //TODO It is possible that the project is there, but the flow doesn't exist because upload a version that changes flow structure
+
+ Flow flow = project.getFlow(runningSched.getFlowName());
+ if (flow == null) {
+ logger.error("Flow " + runningSched.getScheduleName() + " cannot be found in project " + project.getName());
+ throw new RuntimeException("Error finding the scheduled flow. " + runningSched.getScheduleName());
}
- logger.error(e.getMessage());
- return;
- }
-
- try {
- executorManager.executeFlow(exflow);
- project.info("Scheduler has invoked " + exflow.getExecutionId());
- } catch (ExecutorManagerException e) {
+
+ // Create ExecutableFlow
+ ExecutableFlow exflow = new ExecutableFlow(flow);
+ exflow.setSubmitUser(runningSched.getSubmitUser());
+
+ // TODO make disabled in scheduled flow
+ // Map<String, String> paramGroup =
+ // this.getParamGroup(req, "disabled");
+ // for (Map.Entry<String, String> entry:
+ // paramGroup.entrySet()) {
+ // boolean nodeDisabled =
+ // Boolean.parseBoolean(entry.getValue());
+ // exflow.setStatus(entry.getKey(),
+ // nodeDisabled ? Status.DISABLED :
+ // Status.READY);
+ // }
+
try {
- executorManager.cleanupAll(exflow);
- } catch (ExecutorManagerException e1) {
- e1.printStackTrace();
+ executorManager.submitExecutableFlow(exflow);
+ logger.info("Scheduler has invoked " + exflow.getExecutionId());
+ } catch (ExecutorManagerException e) {
+ logger.error("Scheduler invoked flow " + exflow.getExecutionId() + " has failed.");
+ logger.error(e.getMessage());
+ return;
}
-
- project.info("Scheduler invoked flow " + exflow.getExecutionId() + " has failed.");
- logger.error(e.getMessage());
- return;
+ } catch (JobExecutionException e) {
+ logger.info("Could not run flow. " + e.getMessage());
}
- } catch (JobExecutionException e) {
- logger.info("Could not run flow. " + e.getMessage());
}
- schedule.remove(runningFlow);
+
+ removeRunnerSchedule(runningSched);
+
// Immediately reschedule if it's possible. Let
// the execution manager
// handle any duplicate runs.
- if (runningFlow.updateTime()) {
- schedule.add(runningFlow);
+ if (runningSched.updateTime()) {
+ addRunnerSchedule(runningSched);
+ loader.updateSchedule(runningSched);
}
- saveSchedule();
+ else {
+ removeSchedule(runningSched.getScheduleId());
+ }
} else {
// wait until flow run
- long millisWait = Math.max(0, schedFlow.getNextExecTime().getMillis() - (new DateTime()).getMillis());
+ long millisWait = Math.max(0, s.getNextExecTime() - (new DateTime()).getMillis());
try {
this.wait(Math.min(millisWait, TIMEOUT_MS));
} catch (InterruptedException e) {
@@ -427,15 +421,15 @@ public class ScheduleManager {
*
* @author Richard Park
*/
- private class ScheduleComparator implements Comparator<ScheduledFlow> {
+ private class ScheduleComparator implements Comparator<Schedule> {
@Override
- public int compare(ScheduledFlow arg0, ScheduledFlow arg1) {
- DateTime first = arg1.getNextExecTime();
- DateTime second = arg0.getNextExecTime();
+ public int compare(Schedule arg0, Schedule arg1) {
+ long first = arg1.getNextExecTime();
+ long second = arg0.getNextExecTime();
- if (first.isEqual(second)) {
+ if (first == second) {
return 0;
- } else if (first.isBefore(second)) {
+ } else if (first < second) {
return 1;
}
@@ -443,4 +437,4 @@ public class ScheduleManager {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/java/azkaban/security/DefaultHadoopSecurityManager.java b/src/java/azkaban/security/DefaultHadoopSecurityManager.java
new file mode 100644
index 0000000..05c7c1e
--- /dev/null
+++ b/src/java/azkaban/security/DefaultHadoopSecurityManager.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2011 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package azkaban.security;
+
+
+import java.io.File;
+import java.util.Properties;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.log4j.Logger;
+
+import azkaban.utils.Props;
+
+public class DefaultHadoopSecurityManager extends HadoopSecurityManager {
+
+ private static final Logger logger = Logger.getLogger(DefaultHadoopSecurityManager.class);
+
+
+ public DefaultHadoopSecurityManager() {
+ logger.info("Default Hadoop Security Manager is used. Only do this on a non-hadoop cluster!");
+ }
+
+ @Override
+ public UserGroupInformation getProxiedUser(String toProxy) throws SecurityManagerException {
+ throw new SecurityManagerException("No real Hadoop Security Manager is set!");
+ }
+
+ /**
+ * Create a proxied user, taking all parameters, including which user to proxy
+ * from provided Properties.
+ */
+ @Override
+ public UserGroupInformation getProxiedUser(Props prop) throws SecurityManagerException {
+ throw new SecurityManagerException("No real Hadoop Security Manager is set!");
+ }
+
+ @Override
+ public boolean isHadoopSecurityEnabled() throws SecurityManagerException {
+ throw new SecurityManagerException("No real Hadoop Security Manager is set!");
+ }
+
+ @Override
+ public FileSystem getFSAsUser(String user) throws SecurityManagerException {
+ throw new SecurityManagerException("No real Hadoop Security Manager is set!");
+ }
+
+ @Override
+ public void prefetchToken(File tokenFile, String userToProxy)
+ throws SecurityManagerException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/src/java/azkaban/security/HadoopSecurityManager.java b/src/java/azkaban/security/HadoopSecurityManager.java
new file mode 100644
index 0000000..b8bfeda
--- /dev/null
+++ b/src/java/azkaban/security/HadoopSecurityManager.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package azkaban.security;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.log4j.Logger;
+
+import azkaban.utils.Props;
+
+public abstract class HadoopSecurityManager {
+
+ public static final String ENABLE_PROXYING = "azkaban.should.proxy"; // boolean
+
+ public static final String PROXY_KEYTAB_LOCATION = "proxy.keytab.location";
+ public static final String PROXY_USER = "proxy.user";
+ public static final String TO_PROXY = "user.to.proxy";
+ public static final String OBTAIN_BINARY_TOKEN = "obtain.binary.token";
+ public static final String MAPREDUCE_JOB_CREDENTIALS_BINARY = "mapreduce.job.credentials.binary";
+
+ public boolean isHadoopSecurityEnabled() throws SecurityManagerException {
+ return false;
+ }
+
+ /**
+ * Create a proxied user based on the explicit user name, taking other parameters
+ * necessary from properties file.
+ */
+ public abstract UserGroupInformation getProxiedUser(String toProxy) throws SecurityManagerException;
+
+ /**
+ * Create a proxied user, taking all parameters, including which user to proxy
+ * from provided Properties.
+ */
+ public abstract UserGroupInformation getProxiedUser(Props prop) throws SecurityManagerException;
+
+ public abstract FileSystem getFSAsUser(String user) throws SecurityManagerException;
+
+ public static boolean shouldProxy(Properties prop) {
+ String shouldProxy = prop.getProperty(ENABLE_PROXYING);
+
+ return shouldProxy != null && shouldProxy.equals("true");
+ }
+
+ public abstract void prefetchToken(File tokenFile, String userToProxy) throws SecurityManagerException;
+
+}
diff --git a/src/java/azkaban/security/HadoopSecurityManager_H_1_0_2.java b/src/java/azkaban/security/HadoopSecurityManager_H_1_0_2.java
new file mode 100644
index 0000000..b6eeec8
--- /dev/null
+++ b/src/java/azkaban/security/HadoopSecurityManager_H_1_0_2.java
@@ -0,0 +1,271 @@
+/*
+ * Copyright 2011 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package azkaban.security;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapred.JobClient;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.mapreduce.security.token.delegation.DelegationTokenIdentifier;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.security.token.Token;
+import org.apache.log4j.Logger;
+
+import azkaban.utils.Props;
+
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedExceptionAction;
+
+public class HadoopSecurityManager_H_1_0_2 extends HadoopSecurityManager {
+
+ private static UserGroupInformation loginUser = null;
+ private static final Logger logger = Logger.getLogger(HadoopSecurityManager_H_1_0_2.class);
+ private static Configuration conf;
+ private Props props = null;
+
+ private String keytabLocation;
+ private String proxyUser;
+ private static boolean shouldProxy = false;
+ private static boolean securityEnabled = false;
+
+ public HadoopSecurityManager_H_1_0_2(Props props) throws MalformedURLException, SecurityManagerException {
+
+ this.props = props;
+
+ ClassLoader cl;
+
+ String hadoopHome = System.getenv("HADOOP_HOME");
+ String hadoopConfDir = System.getenv("HADOOP_CONF_DIR");
+
+ if (hadoopConfDir != null) {
+ logger.info("Using hadoop config found in " + hadoopConfDir);
+ cl = new URLClassLoader(new URL[] { new File(hadoopConfDir)
+ .toURI().toURL() }, getClass().getClassLoader());
+ } else if (hadoopHome != null) {
+ logger.info("Using hadoop config found in " + hadoopHome);
+ cl = new URLClassLoader(
+ new URL[] { new File(hadoopHome, "conf").toURI().toURL() },
+ getClass().getClassLoader());
+ } else {
+ logger.info("HADOOP_HOME not set, using default hadoop config.");
+ cl = getClass().getClassLoader();
+ }
+ conf = new Configuration();
+ conf.setClassLoader(cl);
+
+ logger.info("Hadoop Security Manager Initiated");
+ logger.info("hadoop.security.authentication set to " + conf.get("hadoop.security.authentication"));
+ logger.info("hadoop.security.authorization set to " + conf.get("hadoop.security.authorization"));
+ logger.info("DFS name " + conf.get("fs.default.name"));
+
+ UserGroupInformation.setConfiguration(conf);
+
+ securityEnabled = UserGroupInformation.isSecurityEnabled();
+ if(securityEnabled) {
+ logger.info("The Hadoop cluster security enabled is " + UserGroupInformation.isSecurityEnabled());
+ keytabLocation = props.getString(PROXY_KEYTAB_LOCATION);
+ proxyUser = props.getString(PROXY_USER);
+ if(keytabLocation == null || proxyUser == null) {
+ throw new SecurityManagerException("Azkaban Keytab info missing on secured hadoop cluster.");
+ }
+ shouldProxy = true;
+ }
+
+ }
+
+ /**
+ * Create a proxied user based on the explicit user name, taking other parameters
+ * necessary from properties file.
+ * @throws IOException
+ */
+ @Override
+ public synchronized UserGroupInformation getProxiedUser(String toProxy) throws SecurityManagerException {
+ // don't do privileged actions in case the hadoop is not secured.
+ if(!isHadoopSecurityEnabled()) {
+ logger.error("Can't get proxy user with unsecured cluster");
+ return null;
+ }
+
+ if(toProxy == null) {
+ throw new SecurityManagerException("toProxy can't be null");
+ }
+
+ try {
+ if (loginUser == null) {
+ logger.info("No login user. Creating login user");
+ String keytab = verifySecureProperty(props, PROXY_KEYTAB_LOCATION);
+ String proxyUser = verifySecureProperty(props, PROXY_USER);
+ UserGroupInformation.loginUserFromKeytab(proxyUser, keytab);
+ loginUser = UserGroupInformation.getLoginUser();
+ logger.info("Logged in with user " + loginUser);
+ } else {
+ logger.info("loginUser (" + loginUser + ") already created, refreshing tgt.");
+ loginUser.checkTGTAndReloginFromKeytab();
+ }
+ }
+ catch (IOException e) {
+ throw new SecurityManagerException("Failed to get Proxy user ", e);
+ }
+
+ return UserGroupInformation.createProxyUser(toProxy, loginUser);
+ }
+
+ /**
+ * Create a proxied user, taking all parameters, including which user to proxy
+ * from provided Properties.
+ */
+ @Override
+ public UserGroupInformation getProxiedUser(Props userProp) throws SecurityManagerException {
+ String toProxy = verifySecureProperty(userProp, TO_PROXY);
+ UserGroupInformation user = getProxiedUser(toProxy);
+ if(user == null) throw new SecurityManagerException("Proxy as any user in unsecured grid is not supported!");
+ return user;
+ }
+
+ public String verifySecureProperty(Props props, String s) throws SecurityManagerException {
+ String value = props.getString(s);
+ if(value == null) {
+ throw new SecurityManagerException(s + " not set in properties.");
+ }
+ logger.info("Secure proxy configuration: Property " + s + " = " + value);
+ return value;
+ }
+
+ @Override
+ public FileSystem getFSAsUser(String user) throws SecurityManagerException {
+ FileSystem fs;
+ try {
+ UserGroupInformation ugi = getProxiedUser(user);
+
+ if (ugi != null) {
+ fs = ugi.doAs(new PrivilegedAction<FileSystem>(){
+
+ @Override
+ public FileSystem run() {
+ try {
+ return FileSystem.get(conf);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ }
+ else {
+ fs = FileSystem.get(conf);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new SecurityManagerException("Failed to get FileSystem. ", e);
+ }
+ return fs;
+ }
+
+ public boolean shouldProxy() {
+ return shouldProxy;
+ }
+
+ @Override
+ public boolean isHadoopSecurityEnabled()
+ {
+ return securityEnabled;
+ }
+
+ /*
+ * Gets hadoop tokens for a user to run mapred/pig jobs on a secured cluster
+ */
+ @Override
+ public synchronized void prefetchToken(final File tokenFile, final String userToProxy) throws SecurityManagerException {
+
+ //final Configuration conf = new Configuration(this.conf);
+ logger.info("Creating hadoop tokens for "+userToProxy);
+
+ try{
+ getProxiedUser(userToProxy).doAs(
+ //UserGroupInformation.getCurrentUser().doAs(
+ new PrivilegedExceptionAction<Void>() {
+ @Override
+ public Void run() throws Exception {
+ getToken(userToProxy);
+ return null;
+ }
+
+ private void getToken(String userToProxy) throws InterruptedException,IOException, SecurityManagerException {
+ logger.info("Pre-fetching tokens");
+
+ logger.info("Pre-fetching DFS token");
+ FileSystem fs = FileSystem.get(conf);
+ logger.info("Getting DFS token from " + fs.getCanonicalServiceName() + fs.getName());
+ Token<?> fsToken = fs.getDelegationToken(userToProxy);
+ if(fsToken == null) {
+ logger.error("Failed to fetch DFS token for ");
+ throw new SecurityManagerException("Failed to fetch DFS token for " + userToProxy);
+ }
+ logger.info("Created DFS token: " + fsToken.toString());
+
+ Job job = new Job(conf,"totally phony, extremely fake, not real job");
+ JobConf jc = new JobConf(conf);
+ JobClient jobClient = new JobClient(jc);
+ logger.info("Pre-fetching JT token: Got new JobClient: " + jc);
+
+ Token<DelegationTokenIdentifier> mrdt = jobClient.getDelegationToken(new Text("hi"));
+ if(mrdt == null) {
+ logger.error("Failed to fetch JT token for ");
+ throw new SecurityManagerException("Failed to fetch JT token for " + userToProxy);
+ }
+ logger.info("Created JT token: " + mrdt.toString());
+
+ job.getCredentials().addToken(new Text("howdy"), mrdt);
+ job.getCredentials().addToken(fsToken.getService(), fsToken);
+
+ // File temp = File.createTempFile("mr-azkaban", ".token");
+ // temp.deleteOnExit();
+
+ FileOutputStream fos = null;
+ DataOutputStream dos = null;
+ try {
+ fos = new FileOutputStream(tokenFile);
+ dos = new DataOutputStream(fos);
+ job.getCredentials().writeTokenStorageToStream( dos);
+ } finally {
+ if (dos != null) {
+ dos.close();
+ }
+ if (fos != null) {
+ fos.close();
+ }
+ }
+ logger.info("Tokens loaded in " + tokenFile.getAbsolutePath());
+ }
+ }
+ );
+ }
+ catch(Exception e) {
+ throw new SecurityManagerException("Failed to get hadoop tokens!", e);
+ }
+ }
+
+}
diff --git a/src/java/azkaban/security/SecurityManagerException.java b/src/java/azkaban/security/SecurityManagerException.java
new file mode 100644
index 0000000..fd2c0d5
--- /dev/null
+++ b/src/java/azkaban/security/SecurityManagerException.java
@@ -0,0 +1,13 @@
+package azkaban.security;
+
+public class SecurityManagerException extends Exception {
+ private static final long serialVersionUID = 1L;
+ public SecurityManagerException(String message) {
+ super(message);
+ }
+
+ public SecurityManagerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
+
src/java/azkaban/user/Permission.java 55(+50 -5)
diff --git a/src/java/azkaban/user/Permission.java b/src/java/azkaban/user/Permission.java
index 6a01d06..588855b 100644
--- a/src/java/azkaban/user/Permission.java
+++ b/src/java/azkaban/user/Permission.java
@@ -26,11 +26,21 @@ import azkaban.utils.Utils;
public class Permission {
public enum Type {
- READ,
- WRITE,
- EXECUTE,
- SCHEDULE,
- ADMIN
+ READ(0x0000001),
+ WRITE(0x0000002),
+ EXECUTE(0x0000004),
+ SCHEDULE(0x0000008),
+ ADMIN(0x8000000);
+
+ private int numVal;
+
+ Type(int numVal) {
+ this.numVal = numVal;
+ }
+
+ public int getFlag() {
+ return numVal;
+ }
}
private Set<Type> permissions = new HashSet<Type>();
@@ -38,10 +48,18 @@ public class Permission {
public Permission() {
}
+ public Permission(int flags) {
+ setPermissions(flags);
+ }
+
public Permission(Type ... list) {
addPermission(list);
}
+ public void addPermissions(Permission perm) {
+ this.permissions.addAll(perm.getTypes());
+ }
+
public void setPermission(Type type, boolean set) {
if (set) {
addPermission(type);
@@ -51,6 +69,20 @@ public class Permission {
}
}
+ public void setPermissions(int flags) {
+ permissions.clear();
+ if((flags & Type.ADMIN.getFlag()) != 0) {
+ addPermission(Type.ADMIN);
+ }
+ else {
+ for (Type type: Type.values()) {
+ if ((flags & type.getFlag()) != 0) {
+ addPermission(type);
+ }
+ }
+ }
+ }
+
public void addPermission(Type ... list) {
// Admin is all encompassing permission. No need to add other types
if (!permissions.contains(Type.ADMIN)) {
@@ -89,6 +121,10 @@ public class Permission {
}
}
+ public Set<Type> getTypes() {
+ return permissions;
+ }
+
public void removePermissions(Type ... list) {
for (Type perm: list) {
permissions.remove(perm);
@@ -152,4 +188,13 @@ public class Permission {
return false;
return true;
}
+
+ public int toFlags() {
+ int flag = 0;
+ for (Type type: permissions) {
+ flag |= type.getFlag();
+ }
+
+ return flag;
+ }
}
src/java/azkaban/user/Role.java 23(+23 -0)
diff --git a/src/java/azkaban/user/Role.java b/src/java/azkaban/user/Role.java
new file mode 100644
index 0000000..08c7009
--- /dev/null
+++ b/src/java/azkaban/user/Role.java
@@ -0,0 +1,23 @@
+package azkaban.user;
+
+public class Role {
+ private final String name;
+ private final Permission globalPermission;
+
+ public Role(String name, Permission permission) {
+ this.name = name;
+ this.globalPermission = permission;
+ }
+
+ public Permission getPermission() {
+ return globalPermission;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String toString() {
+ return "Role " + name;
+ }
+}
diff --git a/src/java/azkaban/user/UserManager.java b/src/java/azkaban/user/UserManager.java
index 9dc9b20..b6f2d1e 100644
--- a/src/java/azkaban/user/UserManager.java
+++ b/src/java/azkaban/user/UserManager.java
@@ -36,4 +36,6 @@ public interface UserManager {
public User getUser(String username, String password) throws UserManagerException;
public boolean validateUser(String username);
+
+ public Role getRole(String roleName);
}
src/java/azkaban/user/XmlUserManager.java 60(+49 -11)
diff --git a/src/java/azkaban/user/XmlUserManager.java b/src/java/azkaban/user/XmlUserManager.java
index 4b38dd7..fdb1a1a 100644
--- a/src/java/azkaban/user/XmlUserManager.java
+++ b/src/java/azkaban/user/XmlUserManager.java
@@ -48,7 +48,8 @@ public class XmlUserManager implements UserManager {
public static final String AZKABAN_USERS_TAG = "azkaban-users";
public static final String USER_TAG = "user";
public static final String ROLE_TAG = "role";
- public static final String ROLENAME_ATTR = "rolename";
+ public static final String ROLENAME_ATTR = "name";
+ public static final String ROLEPERMISSIONS_ATTR = "permissions";
public static final String USERNAME_ATTR = "username";
public static final String PASSWORD_ATTR = "password";
public static final String ROLES_ATTR = "roles";
@@ -58,6 +59,7 @@ public class XmlUserManager implements UserManager {
private HashMap<String, User> users;
private HashMap<String, String> userPassword;
+ private HashMap<String, Role> roles;
/**
* The constructor.
@@ -73,12 +75,12 @@ public class XmlUserManager implements UserManager {
private void parseXMLFile() {
File file = new File(xmlPath);
if (!file.exists()) {
- throw new IllegalArgumentException("User xml file " + xmlPath
- + " doesn't exist.");
+ throw new IllegalArgumentException("User xml file " + xmlPath + " doesn't exist.");
}
HashMap<String, User> users = new HashMap<String, User>();
HashMap<String, String> userPassword = new HashMap<String, String>();
+ HashMap<String, Role> roles = new HashMap<String, Role>();
// Creating the document builder to parse xml.
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
@@ -87,9 +89,7 @@ public class XmlUserManager implements UserManager {
try {
builder = docBuilderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
- throw new IllegalArgumentException(
- "Exception while parsing user xml. Document builder not created.",
- e);
+ throw new IllegalArgumentException("Exception while parsing user xml. Document builder not created.",e);
}
Document doc = null;
@@ -115,6 +115,9 @@ public class XmlUserManager implements UserManager {
if (node.getNodeName().equals(USER_TAG)) {
parseUserTag(node, users, userPassword);
}
+ else if (node.getNodeName().equals(ROLE_TAG)) {
+ parseRoleTag(node, roles);
+ }
}
}
@@ -122,6 +125,7 @@ public class XmlUserManager implements UserManager {
synchronized (this) {
this.users = users;
this.userPassword = userPassword;
+ this.roles = roles;
}
}
@@ -129,14 +133,11 @@ public class XmlUserManager implements UserManager {
NamedNodeMap userAttrMap = node.getAttributes();
Node userNameAttr = userAttrMap.getNamedItem(USERNAME_ATTR);
if (userNameAttr == null) {
- throw new RuntimeException(
- "Error loading user. The username doesn't exist");
+ throw new RuntimeException("Error loading user. The '" + USERNAME_ATTR + "' attribute doesn't exist");
}
Node passwordAttr = userAttrMap.getNamedItem(PASSWORD_ATTR);
if (passwordAttr == null) {
- throw new RuntimeException(
- "Error loading user. The password doesn't exist for "
- + passwordAttr);
+ throw new RuntimeException("Error loading user. The '" + PASSWORD_ATTR + "' attribute doesn't exist");
}
// Add user to the user/password map
@@ -167,6 +168,38 @@ public class XmlUserManager implements UserManager {
}
}
+ private void parseRoleTag(Node node, HashMap<String, Role> roles) {
+ NamedNodeMap roleAttrMap = node.getAttributes();
+ Node roleNameAttr = roleAttrMap.getNamedItem(ROLENAME_ATTR);
+ if (roleNameAttr == null) {
+ throw new RuntimeException(
+ "Error loading role. The role 'name' attribute doesn't exist");
+ }
+ Node permissionAttr = roleAttrMap.getNamedItem(ROLEPERMISSIONS_ATTR);
+ if (permissionAttr == null) {
+ throw new RuntimeException(
+ "Error loading user. The password doesn't exist for "+ permissionAttr);
+ }
+
+ String roleName = roleNameAttr.getNodeValue();
+ String permissions = permissionAttr.getNodeValue();
+
+ String[] permissionSplit = permissions.split("\\s*,\\s*");
+
+ Permission perm = new Permission();
+ for (String permString: permissionSplit) {
+ try {
+ Permission.Type type = Permission.Type.valueOf(permString);
+ perm.addPermission(type);
+ } catch (IllegalArgumentException e) {
+ logger.error("Error adding type " + permString + ". Permission doesn't exist.", e);
+ }
+ }
+
+ Role role = new Role(roleName, perm);
+ roles.put(roleName, role);
+ }
+
@Override
public User getUser(String username, String password) throws UserManagerException {
if (username == null || username.trim().isEmpty()) {
@@ -204,4 +237,9 @@ public class XmlUserManager implements UserManager {
public boolean validateUser(String username) {
return users.containsKey(username);
}
+
+ @Override
+ public Role getRole(String roleName) {
+ return roles.get(roleName);
+ }
}
src/java/azkaban/utils/DataSourceUtils.java 44(+44 -0)
diff --git a/src/java/azkaban/utils/DataSourceUtils.java b/src/java/azkaban/utils/DataSourceUtils.java
new file mode 100644
index 0000000..fb7cad0
--- /dev/null
+++ b/src/java/azkaban/utils/DataSourceUtils.java
@@ -0,0 +1,44 @@
+
+package azkaban.utils;
+
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.commons.dbutils.QueryRunner;
+
+public class DataSourceUtils {
+ public static DataSource getMySQLDataSource(String host, Integer port, String dbName, String user, String password, Integer numConnections) {
+ return new MySQLBasicDataSource(host, port, dbName, user, password, numConnections);
+ }
+
+
+ private DataSourceUtils() {
+ }
+
+ public static class MySQLBasicDataSource extends BasicDataSource {
+ private MySQLBasicDataSource(String host, int port, String dbName, String user, String password, int numConnections) {
+ super();
+
+ String url = "jdbc:mysql://" + (host + ":" + port + "/" + dbName);
+ setDriverClassName("com.mysql.jdbc.Driver");
+ setUsername(user);
+ setPassword(password);
+ setUrl(url);
+ setMaxActive(numConnections);
+ setValidationQuery("/* ping */ select 1");
+ setTestOnBorrow(true);
+ }
+ }
+
+ public static void testConnection(DataSource ds) throws SQLException {
+ QueryRunner runner = new QueryRunner(ds);
+ runner.update("SHOW TABLES");
+ }
+
+ public static void testMySQLConnection(String host, Integer port, String dbName, String user, String password, Integer numConnections) throws SQLException {
+ DataSource ds = new MySQLBasicDataSource(host, port, dbName, user, password, numConnections);
+ testConnection(ds);
+ }
+}
diff --git a/src/java/azkaban/utils/DirectoryFlowLoader.java b/src/java/azkaban/utils/DirectoryFlowLoader.java
index 1f675f4..9e77a2e 100644
--- a/src/java/azkaban/utils/DirectoryFlowLoader.java
+++ b/src/java/azkaban/utils/DirectoryFlowLoader.java
@@ -47,6 +47,14 @@ public class DirectoryFlowLoader {
return errors;
}
+ public Map<String, Props> getJobProps() {
+ return jobPropsMap;
+ }
+
+ public List<Props> getProps() {
+ return propsList;
+ }
+
public void loadProjectFlow(File baseDirectory) {
propsList = new ArrayList<Props>();
flowPropsList = new ArrayList<FlowProps>();
@@ -111,9 +119,9 @@ public class DirectoryFlowLoader {
if(type == null) {
errors.add("Job doesn't have type set '" + jobName + "'.");
}
-
+
node.setType(type);
-
+
node.setJobSource(relative);
if (parent != null) {
node.setPropsSource(parent.getSource());
src/java/azkaban/utils/EmailMessage.java 189(+189 -0)
diff --git a/src/java/azkaban/utils/EmailMessage.java b/src/java/azkaban/utils/EmailMessage.java
new file mode 100644
index 0000000..1ac7607
--- /dev/null
+++ b/src/java/azkaban/utils/EmailMessage.java
@@ -0,0 +1,189 @@
+package azkaban.utils;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.activation.FileDataSource;
+import javax.mail.BodyPart;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+public class EmailMessage {
+ private List<String> _toAddress = new ArrayList<String>();
+ private String _mailHost;
+ private String _mailUser;
+ private String _mailPassword;
+ private String _subject;
+ private String _fromAddress;
+ private String _mimeType = "text/plain";
+ private StringBuffer _body = new StringBuffer();
+
+ private ArrayList<BodyPart> _attachments = new ArrayList<BodyPart>();
+
+ public EmailMessage() {
+ this("localhost", "", "");
+ }
+
+ public EmailMessage(String host, String user, String password) {
+ _mailUser = user;
+ _mailHost = host;
+ _mailPassword = password;
+ }
+
+ public EmailMessage setMailHost(String host) {
+ _mailHost = host;
+ return this;
+ }
+
+ public EmailMessage setMailUser(String user) {
+ _mailUser = user;
+ return this;
+ }
+
+ public EmailMessage setMailPassword(String password) {
+ _mailPassword = password;
+ return this;
+ }
+
+ public EmailMessage addAllToAddress(Collection<? extends String> addresses) {
+ _toAddress.addAll(addresses);
+ return this;
+ }
+
+ public EmailMessage addToAddress(String address) {
+ _toAddress.add(address);
+ return this;
+ }
+
+ public EmailMessage setSubject(String subject) {
+ _subject = subject;
+ return this;
+ }
+
+ public EmailMessage setFromAddress(String fromAddress) {
+ _fromAddress = fromAddress;
+ return this;
+ }
+
+ public EmailMessage addAttachment(File file) throws MessagingException {
+ return addAttachment(file.getName(), file);
+ }
+
+ public EmailMessage addAttachment(String attachmentName, File file)
+ throws MessagingException {
+ BodyPart attachmentPart = new MimeBodyPart();
+ DataSource fileDataSource = new FileDataSource(file);
+ attachmentPart.setDataHandler(new DataHandler(fileDataSource));
+ attachmentPart.setFileName(attachmentName);
+ _attachments.add(attachmentPart);
+ return this;
+ }
+
+ public EmailMessage addAttachment(String attachmentName, InputStream stream)
+ throws MessagingException {
+ BodyPart attachmentPart = new MimeBodyPart(stream);
+ attachmentPart.setFileName(attachmentName);
+ _attachments.add(attachmentPart);
+ return this;
+ }
+
+ private void checkSettings() {
+ if (_mailHost == null) {
+ throw new RuntimeException("Mail host not set.");
+ }
+
+// if (_mailUser == null) {
+// throw new RuntimeException("Mail user not set.");
+// }
+//
+// if (_mailPassword == null) {
+// throw new RuntimeException("Mail password not set.");
+// }
+
+ if (_fromAddress == null || _fromAddress.length() == 0) {
+ throw new RuntimeException("From address not set.");
+ }
+
+ if (_subject == null) {
+ throw new RuntimeException("Subject cannot be null");
+ }
+
+ if (_toAddress.size() == 0) {
+ throw new RuntimeException("T");
+ }
+ }
+
+ public void sendEmail() throws MessagingException {
+ checkSettings();
+ Properties props = new Properties();
+ props.setProperty("mail.transport.protocol", "smtp");
+ props.put("mail.host", _mailHost);
+ props.put("mail.user", _mailUser);
+ props.put("mail.password", _mailPassword);
+
+ Session session = Session.getDefaultInstance(props);
+ Message message = new MimeMessage(session);
+ InternetAddress from = new InternetAddress(_fromAddress, false);
+ message.setFrom(from);
+ for (String toAddr : _toAddress)
+ message.addRecipient(Message.RecipientType.TO, new InternetAddress(
+ toAddr, false));
+ message.setSubject(_subject);
+ message.setSentDate(new Date());
+
+ if (_attachments.size() > 0) {
+ MimeMultipart multipart = new MimeMultipart("related");
+ // Add attachments
+ for (BodyPart part : _attachments) {
+ multipart.addBodyPart(part);
+ }
+
+ BodyPart messageBodyPart = new MimeBodyPart();
+ messageBodyPart.setContent(_body.toString(), _mimeType);
+ multipart.addBodyPart(messageBodyPart);
+
+ message.setContent(multipart);
+ } else {
+ message.setContent(_body.toString(), _mimeType);
+ }
+
+ Transport transport = session.getTransport();
+ transport.connect();
+ transport.sendMessage(message,
+ message.getRecipients(Message.RecipientType.TO));
+ transport.close();
+ }
+
+ public void setBody(String body) {
+ setBody(body, _mimeType);
+ }
+
+ public void setBody(String body, String mimeType) {
+ _body = new StringBuffer(body);
+ _mimeType = mimeType;
+ }
+
+ public EmailMessage setMimeType(String mimeType) {
+ _mimeType = mimeType;
+ return this;
+ }
+
+ public EmailMessage println(Object str) {
+ _body.append(str);
+
+ return this;
+ }
+}
src/java/azkaban/utils/FileIOUtils.java 299(+299 -0)
diff --git a/src/java/azkaban/utils/FileIOUtils.java b/src/java/azkaban/utils/FileIOUtils.java
new file mode 100644
index 0000000..7bda63b
--- /dev/null
+++ b/src/java/azkaban/utils/FileIOUtils.java
@@ -0,0 +1,299 @@
+package azkaban.utils;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.io.IOUtils;
+
+/**
+ * Runs a few unix commands. Created this so that I can move to JNI in the future.
+ */
+public class FileIOUtils {
+ /**
+ * Run a unix command that will symlink files, and recurse into directories.
+ */
+ public static void createDeepSymlink(File sourceDir, File destDir) throws IOException {
+ if (!sourceDir.exists()) {
+ throw new IOException("Source directory " + sourceDir.getPath() + " doesn't exist");
+ }
+ else if (!destDir.exists()) {
+ throw new IOException("Destination directory " + destDir.getPath() + " doesn't exist");
+ }
+ else if (sourceDir.isFile() && destDir.isFile()) {
+ throw new IOException("Source or Destination is not a directory.");
+ }
+
+ Set<String> paths = new HashSet<String>();
+ createDirsFindFiles(sourceDir, sourceDir, destDir, paths);
+
+ StringBuffer buffer = new StringBuffer();
+ //buffer.append("sh '");
+ for (String path: paths) {
+ File sourceLink = new File(sourceDir, path);
+ path = "." + path;
+
+ buffer.append("ln -s ").append(sourceLink.getAbsolutePath()).append("/*").append(" ").append(path).append(";");
+ }
+
+ //buffer.append("'");
+ String command = buffer.toString();
+ //System.out.println(command);
+ ProcessBuilder builder = new ProcessBuilder().command("sh", "-c", command);
+ builder.directory(destDir);
+
+ Process process = builder.start();
+ NullLogger errorLogger = new NullLogger(process.getErrorStream());
+ NullLogger inputLogger = new NullLogger(process.getInputStream());
+ errorLogger.start();
+ inputLogger.start();
+
+ try {
+ if (process.waitFor() < 0) {
+ // Assume that the error will be in standard out. Otherwise it'll be in standard in.
+ String errorMessage = errorLogger.getLastMessages();
+ if (errorMessage.isEmpty()) {
+ errorMessage = inputLogger.getLastMessages();
+ }
+
+ throw new IOException(errorMessage);
+ }
+
+ // System.out.println(errorLogger.getLastMessages());
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static void createDirsFindFiles(File baseDir, File sourceDir, File destDir, Set<String> paths) {
+ File[] srcList = sourceDir.listFiles();
+ String path = getRelativePath(baseDir, sourceDir);
+ paths.add(path);
+
+ for (File file: srcList) {
+ if (file.isDirectory()) {
+ File newDestDir = new File(destDir, file.getName());
+ newDestDir.mkdirs();
+ createDirsFindFiles(baseDir, file, newDestDir, paths);
+ }
+ }
+ }
+
+ private static String getRelativePath(File basePath, File sourceDir) {
+ return sourceDir.getPath().substring(basePath.getPath().length());
+ }
+
+ private static class NullLogger extends Thread {
+ private final BufferedReader inputReader;
+ private CircularBuffer<String> buffer = new CircularBuffer<String>(5);
+
+ public NullLogger(InputStream stream) {
+ inputReader = new BufferedReader(new InputStreamReader(stream));
+ }
+
+ public void run() {
+ try {
+ while (!Thread.currentThread().isInterrupted()) {
+ String line = inputReader.readLine();
+ if (line == null) {
+ return;
+ }
+ buffer.append(line);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public String getLastMessages() {
+ StringBuffer messageBuffer = new StringBuffer();
+ for (String message: buffer) {
+ messageBuffer.append(message);
+ messageBuffer.append("\n");
+ }
+
+ return messageBuffer.toString();
+ }
+ }
+
+ public static Pair<Integer, Integer> readUtf8File(File file, int offset, int length, OutputStream stream) throws IOException {
+ byte[] buffer = new byte[length];
+
+ FileInputStream fileStream = new FileInputStream(file);
+
+ long skipped = fileStream.skip(offset);
+ if (skipped < offset) {
+ return new Pair<Integer,Integer>(0, 0);
+ }
+
+ BufferedInputStream inputStream = null;
+ try {
+ inputStream = new BufferedInputStream(fileStream);
+ inputStream.read(buffer);
+ }
+ finally {
+ IOUtils.closeQuietly(inputStream);
+ }
+
+ Pair<Integer, Integer> utf8Range = getUtf8Range(buffer, 0, length);
+ stream.write(buffer, utf8Range.getFirst(), utf8Range.getSecond());
+
+ return new Pair<Integer,Integer>(offset + utf8Range.getFirst(), utf8Range.getSecond());
+ }
+
+ public static LogData readUtf8File(File file, int fileOffset, int length) throws IOException {
+ byte[] buffer = new byte[length];
+ FileInputStream fileStream = new FileInputStream(file);
+
+ long skipped = fileStream.skip(fileOffset);
+ if (skipped < fileOffset) {
+ return new LogData(fileOffset, 0, "");
+ }
+
+ BufferedInputStream inputStream = null;
+ int read = 0;
+ try {
+ inputStream = new BufferedInputStream(fileStream);
+ read = inputStream.read(buffer);
+ }
+ finally {
+ IOUtils.closeQuietly(inputStream);
+ }
+
+ if (read <= 0) {
+ return new LogData(fileOffset, 0, "");
+ }
+ Pair<Integer, Integer> utf8Range = getUtf8Range(buffer, 0, read);
+ String outputString = new String(buffer, utf8Range.getFirst(), utf8Range.getSecond());
+
+ return new LogData(fileOffset + utf8Range.getFirst(), utf8Range.getSecond(), outputString);
+ }
+
+ /**
+ * Returns first and length.
+ */
+ public static Pair<Integer, Integer> getUtf8Range(byte[] buffer, int offset, int length) {
+ int start = getUtf8ByteStart(buffer, offset);
+ int end = getUtf8ByteEnd(buffer, offset + length - 1);
+
+ return new Pair<Integer, Integer>(start, end - start + 1);
+ }
+
+ private static int getUtf8ByteStart(byte[] buffer, int offset) {
+ // If it's a proper utf-8, we should find it within the next 6 bytes.
+ for (int i = offset; i < offset + 6 && i < buffer.length; i++) {
+ byte b = buffer[i];
+ // check the mask 0x80 is 0, which is a proper ascii
+ if ((0x80 & b) == 0) {
+ return i;
+ }
+ else if ((0xC0 & b) == 0xC0) {
+ return i;
+ }
+ }
+
+ // Don't know what it is, will just set it as 0
+ return offset;
+ }
+
+ private static int getUtf8ByteEnd(byte[] buffer, int offset) {
+ // If it's a proper utf-8, we should find it within the previous 12 bytes.
+ for (int i = offset; i > offset - 11 && i >= 0; i--) {
+ byte b = buffer[i];
+ // check the mask 0x80 is 0, which is a proper ascii. Just return
+ if ((0x80 & b) == 0) {
+ return i;
+ }
+
+ if ((b & 0xE0) == 0xC0) { // two byte utf8 char. bits 110x xxxx
+ if (offset - i >= 1) {
+ // There is 1 following byte we're good.
+ return i + 1;
+ }
+ }
+ else if ((b & 0xF0) == 0xE0) { // three byte utf8 char. bits 1110 xxxx
+ if (offset - i >= 2) {
+ // There is 1 following byte we're good.
+ return i + 2;
+ }
+ }
+ else if ((b & 0xF8) == 0xF0) { // four byte utf8 char. bits 1111 0xxx
+ if (offset - i >= 3) {
+ // There is 1 following byte we're good.
+ return i + 3;
+ }
+ }
+ else if ((b & 0xFC) >= 0xF8) { // five byte utf8 char. bits 1111 10xx
+ if (offset - i == 4) {
+ // There is 1 following byte we're good.
+ return i + 4;
+ }
+ }
+ else if ((b & 0xFE) == 0xFC) { // six byte utf8 char. bits 1111 110x
+ if (offset - i >= 5) {
+ // There is 1 following byte we're good.
+ return i + 5;
+ }
+ }
+ }
+
+ // Don't know what it is, will just set it as 0
+ return offset;
+ }
+
+ public static class LogData {
+ private int offset;
+ private int length;
+ private String data;
+
+ public LogData(int offset, int length, String data) {
+ this.offset = offset;
+ this.length = length;
+ this.data = data;
+ }
+
+ public int getOffset() {
+ return offset;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public Map<String,Object> toObject() {
+ HashMap<String,Object> map = new HashMap<String,Object>();
+ map.put("offset", offset);
+ map.put("length", length);
+ map.put("data", data);
+
+ return map;
+ }
+
+ public static LogData createLogDataFromObject(Map<String,Object> map) {
+ int offset = (Integer)map.get("offset");
+ int length = (Integer)map.get("length");
+ String data = (String)map.get("data");
+
+ return new LogData(offset,length, data);
+ }
+
+ @Override
+ public String toString() {
+ return "[offset=" + offset + ",length="+length + ",data=" + data + "]";
+ }
+ }
+
+}
\ No newline at end of file
src/java/azkaban/utils/GZIPUtils.java 48(+48 -0)
diff --git a/src/java/azkaban/utils/GZIPUtils.java b/src/java/azkaban/utils/GZIPUtils.java
new file mode 100644
index 0000000..147cb55
--- /dev/null
+++ b/src/java/azkaban/utils/GZIPUtils.java
@@ -0,0 +1,48 @@
+package azkaban.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+import org.apache.hadoop.io.IOUtils;
+
+public class GZIPUtils {
+
+ public static byte[] gzipString(String str, String encType) throws IOException {
+ byte[] stringData = str.getBytes(encType);
+
+ return gzipBytes(stringData);
+ }
+
+ public static byte[] gzipBytes(byte[] bytes) throws IOException {
+ return gzipBytes(bytes, 0, bytes.length);
+ }
+
+ public static byte[] gzipBytes(byte[] bytes, int offset, int length) throws IOException {
+ ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
+ GZIPOutputStream gzipStream = null;
+
+ gzipStream = new GZIPOutputStream(byteOutputStream);
+
+ gzipStream.write(bytes, offset, length);
+ gzipStream.close();
+ return byteOutputStream.toByteArray();
+ }
+
+ public static byte[] unGzipBytes(byte[] bytes) throws IOException {
+ ByteArrayInputStream byteInputStream = new ByteArrayInputStream(bytes);
+ GZIPInputStream gzipInputStream = new GZIPInputStream(byteInputStream);
+
+ ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
+ IOUtils.copyBytes(gzipInputStream, byteOutputStream, 1024);
+
+ return byteOutputStream.toByteArray();
+ }
+
+ public static String unGzipString(byte[] bytes, String encType) throws IOException {
+ byte[] response = unGzipBytes(bytes);
+ return new String(response, encType);
+ }
+}
\ No newline at end of file
src/java/azkaban/utils/LogGobbler.java 72(+72 -0)
diff --git a/src/java/azkaban/utils/LogGobbler.java b/src/java/azkaban/utils/LogGobbler.java
new file mode 100644
index 0000000..ec20256
--- /dev/null
+++ b/src/java/azkaban/utils/LogGobbler.java
@@ -0,0 +1,72 @@
+package azkaban.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+import com.google.common.base.Joiner;
+
+public class LogGobbler extends Thread {
+ private final BufferedReader inputReader;
+ private final Logger logger;
+ private final Level loggingLevel;
+ private final CircularBuffer<String> buffer;
+
+ public LogGobbler(final Reader inputReader, final Logger logger, final Level level, final int bufferLines) {
+ this.inputReader = new BufferedReader(inputReader);
+ this.logger = logger;
+ this.loggingLevel = level;
+ buffer = new CircularBuffer<String>(bufferLines);
+ }
+
+ @Override
+ public void run() {
+ try {
+ while (!Thread.currentThread().isInterrupted()) {
+ String line = inputReader.readLine();
+ if (line == null) {
+ return;
+ }
+
+ buffer.append(line);
+ log(line);
+ }
+ } catch (IOException e) {
+ error("Error reading from logging stream:", e);
+ }
+ }
+
+ private void log(String message) {
+ if (logger != null) {
+ logger.log(loggingLevel, message);
+ }
+ }
+
+ private void error(String message, Exception e) {
+ if (logger != null) {
+ logger.error(message, e);
+ }
+ }
+
+ private void info(String message, Exception e) {
+ if (logger != null) {
+ logger.info(message, e);
+ }
+ }
+
+ public void awaitCompletion(final long waitMs) {
+ try {
+ join(waitMs);
+ } catch (InterruptedException e) {
+ info("I/O thread interrupted.", e);
+ }
+ }
+
+ public String getRecentLog() {
+ return Joiner.on(System.getProperty("line.separator")).join(buffer);
+ }
+
+}
src/java/azkaban/utils/Md5Hasher.java 48(+48 -0)
diff --git a/src/java/azkaban/utils/Md5Hasher.java b/src/java/azkaban/utils/Md5Hasher.java
new file mode 100644
index 0000000..832f223
--- /dev/null
+++ b/src/java/azkaban/utils/Md5Hasher.java
@@ -0,0 +1,48 @@
+package azkaban.utils;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.security.DigestInputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * Helper class that will find the md5 hash for files.
+ */
+public class Md5Hasher {
+
+ private static final int BYTE_BUFFER_SIZE = 1024;
+
+ public static MessageDigest getMd5Digest() {
+ MessageDigest digest = null;
+ try {
+ digest = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException e) {
+ // Should never get here.
+ }
+
+ return digest;
+ }
+
+ public static byte[] md5Hash(File file) throws IOException {
+ MessageDigest digest = getMd5Digest();
+
+ FileInputStream fStream = new FileInputStream(file);
+ BufferedInputStream bStream = new BufferedInputStream(fStream);
+ DigestInputStream blobStream = new DigestInputStream(bStream, digest);
+
+ byte[] buffer = new byte[BYTE_BUFFER_SIZE];
+
+ int num = 0;
+ do {
+ num = blobStream.read(buffer);
+ } while (num > 0);
+
+ bStream.close();
+
+ return digest.digest();
+ }
+
+}
src/java/azkaban/utils/Pair.java 11(+11 -0)
diff --git a/src/java/azkaban/utils/Pair.java b/src/java/azkaban/utils/Pair.java
index 0d85d02..c1a67a0 100644
--- a/src/java/azkaban/utils/Pair.java
+++ b/src/java/azkaban/utils/Pair.java
@@ -1,5 +1,11 @@
package azkaban.utils;
+/**
+ * Pair of values.
+ *
+ * @param <F>
+ * @param <S>
+ */
public class Pair<F, S> {
private final F first;
private final S second;
@@ -48,4 +54,9 @@ public class Pair<F, S> {
return false;
return true;
}
+
+ @Override
+ public String toString() {
+ return "{" + first.toString() + "," + second.toString() + "}";
+ }
}
src/java/azkaban/utils/SecurityUtils.java 215(+148 -67)
diff --git a/src/java/azkaban/utils/SecurityUtils.java b/src/java/azkaban/utils/SecurityUtils.java
index b6e7fe0..50803a8 100644
--- a/src/java/azkaban/utils/SecurityUtils.java
+++ b/src/java/azkaban/utils/SecurityUtils.java
@@ -17,78 +17,159 @@ package azkaban.utils;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapred.JobClient;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.hadoop.mapreduce.security.token.delegation.DelegationTokenIdentifier;
import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.security.token.Token;
import org.apache.log4j.Logger;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.security.PrivilegedExceptionAction;
import java.util.Properties;
public class SecurityUtils {
- // Secure Hadoop proxy user params
- public static final String ENABLE_PROXYING = "azkaban.should.proxy"; // boolean
- public static final String PROXY_KEYTAB_LOCATION = "proxy.keytab.location";
- public static final String PROXY_USER = "proxy.user";
- public static final String TO_PROXY = "user.to.proxy";
-
- private static UserGroupInformation loginUser = null;
-
- /**
- * Create a proxied user based on the explicit user name, taking other parameters
- * necessary from properties file.
- */
- public static synchronized UserGroupInformation getProxiedUser(String toProxy, Properties prop, Logger log, Configuration conf) throws IOException {
-
- if(conf == null) {
- throw new IllegalArgumentException("conf can't be null");
- }
- UserGroupInformation.setConfiguration(conf);
- // don't do privileged actions in case the hadoop is not secured.
- if(!UserGroupInformation.isSecurityEnabled()) {
- //we don't get into whether to allow impersonation as anybody in unsecured grid
- return null;
- }
-
- if(toProxy == null) {
- throw new IllegalArgumentException("toProxy can't be null");
- }
-
- if (loginUser == null) {
- log.info("No login user. Creating login user");
- String keytab = verifySecureProperty(prop, PROXY_KEYTAB_LOCATION, log);
- String proxyUser = verifySecureProperty(prop, PROXY_USER, log);
- UserGroupInformation.loginUserFromKeytab(proxyUser, keytab);
- loginUser = UserGroupInformation.getLoginUser();
- log.info("Logged in with user " + loginUser);
- } else {
- log.info("loginUser (" + loginUser + ") already created, refreshing tgt.");
- loginUser.checkTGTAndReloginFromKeytab();
- }
-
- return UserGroupInformation.createProxyUser(toProxy, loginUser);
- }
-
- /**
- * Create a proxied user, taking all parameters, including which user to proxy
- * from provided Properties.
- */
- public static UserGroupInformation getProxiedUser(Properties prop, Logger log, Configuration conf) throws IOException {
- String toProxy = verifySecureProperty(prop, TO_PROXY, log);
- UserGroupInformation user = getProxiedUser(toProxy, prop, log, conf);
- if(user == null) throw new IOException("Proxy as any user in unsecured grid is not supported!");
- return user;
- }
-
- public static String verifySecureProperty(Properties properties, String s, Logger l) throws IOException {
- String value = properties.getProperty(s);
-
- if(value == null) throw new IOException(s + " not set in properties. Cannot use secure proxy");
- l.info("Secure proxy configuration: Property " + s + " = " + value);
- return value;
- }
-
- public static boolean shouldProxy(Properties prop) {
- String shouldProxy = prop.getProperty(ENABLE_PROXYING);
-
- return shouldProxy != null && shouldProxy.equals("true");
- }
+ // Secure Hadoop proxy user params
+ public static final String ENABLE_PROXYING = "azkaban.should.proxy"; // boolean
+ public static final String PROXY_KEYTAB_LOCATION = "proxy.keytab.location";
+ public static final String PROXY_USER = "proxy.user";
+ public static final String TO_PROXY = "user.to.proxy";
+
+ private static UserGroupInformation loginUser = null;
+
+ /**
+ * Create a proxied user based on the explicit user name, taking other parameters
+ * necessary from properties file.
+ */
+ public static synchronized UserGroupInformation getProxiedUser(String toProxy, Properties prop, Logger log, Configuration conf) throws IOException {
+
+ if(conf == null) {
+ throw new IllegalArgumentException("conf can't be null");
+ }
+ UserGroupInformation.setConfiguration(conf);
+ // don't do privileged actions in case the hadoop is not secured.
+// if(!UserGroupInformation.isSecurityEnabled()) {
+// //we don't get into whether to allow impersonation as anybody in unsecured grid
+// return null;
+// }
+
+ if(toProxy == null) {
+ throw new IllegalArgumentException("toProxy can't be null");
+ }
+
+ if (loginUser == null) {
+ log.info("No login user. Creating login user");
+ String keytab = verifySecureProperty(prop, PROXY_KEYTAB_LOCATION, log);
+ String proxyUser = verifySecureProperty(prop, PROXY_USER, log);
+ UserGroupInformation.loginUserFromKeytab(proxyUser, keytab);
+ loginUser = UserGroupInformation.getLoginUser();
+ log.info("Logged in with user " + loginUser);
+ } else {
+ log.info("loginUser (" + loginUser + ") already created, refreshing tgt.");
+ loginUser.checkTGTAndReloginFromKeytab();
+ }
+
+ return UserGroupInformation.createProxyUser(toProxy, loginUser);
+ }
+
+ /**
+ * Create a proxied user, taking all parameters, including which user to proxy
+ * from provided Properties.
+ */
+ public static UserGroupInformation getProxiedUser(Properties prop, Logger log, Configuration conf) throws IOException {
+ String toProxy = verifySecureProperty(prop, TO_PROXY, log);
+ UserGroupInformation user = getProxiedUser(toProxy, prop, log, conf);
+ if(user == null) throw new IOException("Proxy as any user in unsecured grid is not supported!" + prop.toString());
+ log.info("created proxy user for " + user.getUserName() + user.toString());
+ return user;
+ }
+
+ public static String verifySecureProperty(Properties properties, String s, Logger l) throws IOException {
+ String value = properties.getProperty(s);
+
+ if(value == null) throw new IOException(s + " not set in properties. Cannot use secure proxy");
+ l.info("Secure proxy configuration: Property " + s + " = " + value);
+ return value;
+ }
+
+ public static boolean shouldProxy(Properties prop) {
+ String shouldProxy = prop.getProperty(ENABLE_PROXYING);
+
+ return shouldProxy != null && shouldProxy.equals("true");
+ }
+
+
+ public static final String OBTAIN_BINARY_TOKEN = "obtain.binary.token";
+ public static final String MAPREDUCE_JOB_CREDENTIALS_BINARY = "mapreduce.job.credentials.binary";
+ public static final String HADOOP_TOKEN_FILE_LOCATION = "HADOOP_TOKEN_FILE_LOCATION";
+
+ public static synchronized void prefetchToken(final File tokenFile, final Props p, final Logger logger) throws InterruptedException, IOException {
+
+ final Configuration conf = new Configuration();
+ logger.info("Getting proxy user for "+p.getString(TO_PROXY));
+ logger.info("Getting proxy user for "+p.toString());
+
+ getProxiedUser(p.toProperties(), logger, conf).doAs(
+ //UserGroupInformation.getCurrentUser().doAs(
+ new PrivilegedExceptionAction<Void>() {
+ @Override
+ public Void run() throws Exception {
+ getToken(p);
+ return null;
+ }
+
+ private void getToken(Props p) throws InterruptedException,IOException {
+ String shouldPrefetch = p.getString(OBTAIN_BINARY_TOKEN);
+ if (shouldPrefetch != null && shouldPrefetch.equals("true")) {
+ logger.info("Pre-fetching token");
+
+ logger.info("Pre-fetching fs token");
+ FileSystem fs = FileSystem.get(conf);
+ Token<?> fsToken = fs.getDelegationToken(p.getString("user.to.proxy"));
+ logger.info("Created token: " + fsToken.toString());
+
+ Job job = new Job(conf,"totally phony, extremely fake, not real job");
+ JobConf jc = new JobConf(conf);
+ JobClient jobClient = new JobClient(jc);
+ logger.info("Pre-fetching job token: Got new JobClient: " + jc);
+ //logger.info(conf.get("fs.default.name"));
+ Token<DelegationTokenIdentifier> mrdt = jobClient.getDelegationToken(new Text("hi"));
+ logger.info("Created token: " + mrdt.toString());
+
+ job.getCredentials().addToken(new Text("howdy"), mrdt);
+ job.getCredentials().addToken(fsToken.getService(), fsToken);
+
+ // File temp = File.createTempFile("mr-azkaban", ".token");
+ // temp.deleteOnExit();
+
+ FileOutputStream fos = null;
+ DataOutputStream dos = null;
+ try {
+ fos = new FileOutputStream(tokenFile);
+ dos = new DataOutputStream(fos);
+ job.getCredentials().writeTokenStorageToStream( dos);
+ } finally {
+ if (dos != null) {
+ dos.close();
+ }
+ if (fos != null) {
+ fos.close();
+ }
+ }
+ logger.info("Loading hadoop tokens into " + tokenFile.getAbsolutePath());
+ p.put("HadoopTokenFileLoc", tokenFile.getAbsolutePath());
+ //p.put(MAPREDUCE_JOB_CREDENTIALS_BINARY, tokenFile.getAbsolutePath());
+ } else {
+ logger.info("Not pre-fetching token");
+ }
+ }
+ }
+ );
+ }
}
src/java/azkaban/utils/Triple.java 66(+66 -0)
diff --git a/src/java/azkaban/utils/Triple.java b/src/java/azkaban/utils/Triple.java
new file mode 100644
index 0000000..43a1706
--- /dev/null
+++ b/src/java/azkaban/utils/Triple.java
@@ -0,0 +1,66 @@
+package azkaban.utils;
+
+/**
+ * Like pair, but with 3 values.
+ */
+public class Triple<F, S, T> {
+ private final F first;
+ private final S second;
+ private final T third;
+
+ public Triple(F first, S second, T third) {
+ this.first = first;
+ this.second = second;
+ this.third = third;
+ }
+
+ public F getFirst() {
+ return first;
+ }
+
+ public S getSecond() {
+ return second;
+ }
+
+ public T getThird() {
+ return third;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((first == null) ? 0 : first.hashCode());
+ result = prime * result + ((second == null) ? 0 : second.hashCode());
+ result = prime * result + ((third == null) ? 0 : third.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Triple other = (Triple) obj;
+ if (first == null) {
+ if (other.first != null)
+ return false;
+ } else if (!first.equals(other.first))
+ return false;
+ if (second == null) {
+ if (other.second != null)
+ return false;
+ } else if (!second.equals(other.second))
+ return false;
+ if (third == null) {
+ if (other.third != null)
+ return false;
+ } else if (!third.equals(other.third))
+ return false;
+ return true;
+ }
+
+}
src/java/azkaban/utils/Utils.java 18(+18 -0)
diff --git a/src/java/azkaban/utils/Utils.java b/src/java/azkaban/utils/Utils.java
index 1c4a717..52d2cb2 100644
--- a/src/java/azkaban/utils/Utils.java
+++ b/src/java/azkaban/utils/Utils.java
@@ -26,6 +26,8 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URLClassLoader;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Random;
@@ -35,6 +37,10 @@ import java.util.zip.ZipOutputStream;
import org.apache.commons.io.IOUtils;
+import azkaban.execapp.FlowRunner;
+import azkaban.executor.ExecutorManagerException;
+import azkaban.webapp.servlet.admin.InitialSetupServlet;
+
/**
* A util helper class full of static methods that are commonly used.
*/
@@ -264,4 +270,16 @@ public class Utils {
hours %= 24;
return days + "d " + hours + "h " + minutes + "m";
}
+
+ public static Object invokeStaticMethod(ClassLoader loader, String className, String methodName, Object ... args) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+ Class clazz = loader.loadClass(className);
+
+ Class[] argTypes = new Class[args.length];
+ for (int i=0; i < args.length; ++i) {
+ argTypes[i] = args[i].getClass();
+ }
+
+ Method method = clazz.getDeclaredMethod(methodName, argTypes);
+ return method.invoke(null, args);
+ }
}
\ No newline at end of file
src/java/azkaban/utils/WebUtils.java 10(+7 -3)
diff --git a/src/java/azkaban/utils/WebUtils.java b/src/java/azkaban/utils/WebUtils.java
index 4c063bf..4878e34 100644
--- a/src/java/azkaban/utils/WebUtils.java
+++ b/src/java/azkaban/utils/WebUtils.java
@@ -74,13 +74,17 @@ public class WebUtils {
return "Killed";
case FAILED_FINISHING:
return "Running w/Failure";
- case WAITING:
- return "Waiting";
+ case PREPARING:
+ return "Preparing";
case READY:
return "Ready";
+ case PAUSED:
+ return "Paused";
+ case SKIPPED:
+ return "Skipped";
default:
}
-
+
return "Unknown";
}
src/java/azkaban/webapp/AzkabanAdminServer.java 250(+250 -0)
diff --git a/src/java/azkaban/webapp/AzkabanAdminServer.java b/src/java/azkaban/webapp/AzkabanAdminServer.java
new file mode 100644
index 0000000..47a3dde
--- /dev/null
+++ b/src/java/azkaban/webapp/AzkabanAdminServer.java
@@ -0,0 +1,250 @@
+package azkaban.webapp;
+
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.util.Arrays;
+
+import joptsimple.OptionParser;
+import joptsimple.OptionSet;
+import joptsimple.OptionSpec;
+
+import org.apache.log4j.Logger;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.log.Log4JLogChute;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.bio.SocketConnector;
+import org.mortbay.jetty.security.SslSocketConnector;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.DefaultServlet;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+import azkaban.user.UserManager;
+import azkaban.user.XmlUserManager;
+import azkaban.utils.Props;
+import azkaban.utils.Utils;
+import azkaban.webapp.servlet.AzkabanServletContextListener;
+import azkaban.webapp.servlet.admin.InitialSetupServlet;
+import azkaban.webapp.session.SessionCache;
+
+public class AzkabanAdminServer implements AzkabanServer {
+ private static final Logger logger = Logger.getLogger(AzkabanAdminServer.class);
+ private static AzkabanAdminServer app;
+ private static final int NUM_CONNECTIONS = 10;
+ private static final String AZKABAN_DEFAULT_ADMIN_DIR = "admin";
+ private static final String AZKABAN_DEFAULT_ADMIN_PROPERTIES = "admin.properties";
+ private static final String AZKABAN_DEFAULT_WEB_DIR = "web";
+ private static final String AZKABAN_DEFAULT_PLUGIN_DIR = "pluginlib";
+ private static final int AZKABAN_DEFAULT_ADMIN_PORT = 12233;
+
+ private static final String USER_MANAGER_CLASS_PARAM = "user.manager.class";
+ private final VelocityEngine velocityEngine;
+ private final SessionCache sessionCache;
+ private static Server server;
+ private String pluginLibDirectory;
+ private File adminPropertiesFile;
+
+ private Props props;
+
+ public AzkabanAdminServer(Props props, File propFile, boolean initialSetup) throws Exception {
+ this.props = props;
+ velocityEngine = configureVelocityEngine(true);
+ sessionCache = initialSetup ? null : new SessionCache(props);
+ adminPropertiesFile = propFile;
+
+ pluginLibDirectory = props.get("pluginLibDirectory");
+ }
+
+ public File getPropFile() {
+ return adminPropertiesFile;
+ }
+
+ /**
+ * Creates and configures the velocity engine.
+ *
+ * @param devMode
+ * @return
+ */
+ private VelocityEngine configureVelocityEngine(final boolean devMode) {
+ VelocityEngine engine = new VelocityEngine();
+ engine.setProperty("resource.loader", "classpath");
+ engine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+ engine.setProperty("classpath.resource.loader.cache", !devMode);
+ engine.setProperty("classpath.resource.loader.modificationCheckInterval", 5L);
+ engine.setProperty("resource.manager.logwhenfound", false);
+ engine.setProperty("input.encoding", "UTF-8");
+ engine.setProperty("output.encoding", "UTF-8");
+ engine.setProperty("directive.set.null.allowed", true);
+ engine.setProperty("resource.manager.logwhenfound", false);
+ engine.setProperty("velocimacro.permissions.allow.inline", true);
+ engine.setProperty("velocimacro.library.autoreload", devMode);
+ engine.setProperty("velocimacro.library", "/azkaban/webapp/servlet/velocity/macros.vm");
+ engine.setProperty("velocimacro.permissions.allow.inline.to.replace.global", true);
+ engine.setProperty("velocimacro.arguments.strict", true);
+ engine.setProperty("runtime.log.invalid.references", devMode);
+ engine.setProperty("runtime.log.logsystem.class", Log4JLogChute.class);
+ engine.setProperty("runtime.log.logsystem.log4j.logger", Logger.getLogger("org.apache.velocity.Logger"));
+ engine.setProperty("parser.pool.size", 3);
+ return engine;
+ }
+
+ /**
+ * Azkaban using Jetty
+ *
+ * @param args
+ */
+ public static void main(String[] args) throws Exception {
+ OptionParser parser = new OptionParser();
+
+ OptionSpec<Integer> portArg = parser
+ .acceptsAll(Arrays.asList("p", "port"), "The port for azkaban.")
+ .withRequiredArg()
+ .describedAs("port").ofType(Integer.class);
+
+ OptionSpec<String> adminDirectory = parser
+ .acceptsAll(Arrays.asList("d", "dir"), "The admin directory")
+ .withRequiredArg()
+ .describedAs("dir").ofType(String.class);
+
+ OptionSpec<String> webDirectory = parser
+ .acceptsAll(Arrays.asList("w", "web"), "The web resource directory")
+ .withRequiredArg()
+ .describedAs("web").ofType(String.class);
+
+ OptionSpec<String> pluginLibDirectory = parser
+ .acceptsAll(Arrays.asList("l", "pluginlib"), "The plugin lib directory")
+ .withRequiredArg()
+ .describedAs("plugin").ofType(String.class);
+
+ OptionSet options = parser.parse(args);
+
+ String adminDir = options.has(adminDirectory) ? options.valueOf(adminDirectory) : AZKABAN_DEFAULT_ADMIN_DIR;
+ int port = options.has(portArg) ? options.valueOf(portArg) : AZKABAN_DEFAULT_ADMIN_PORT;
+ String webDir = options.has(webDirectory) ? options.valueOf(webDirectory) : AZKABAN_DEFAULT_WEB_DIR;
+ String pluginLib = options.has(pluginLibDirectory) ? options.valueOf(pluginLibDirectory) : AZKABAN_DEFAULT_PLUGIN_DIR;
+
+ Props props = null;
+ server = new Server();
+ File adminDirFile = new File(adminDir);
+ if (!adminDirFile.exists()) {
+ adminDirFile.mkdirs();
+ }
+ File adminPropertiesFile = new File(adminDirFile, AZKABAN_DEFAULT_ADMIN_PROPERTIES);
+
+ boolean secureMode = false;
+ if (adminPropertiesFile.exists()) {
+ props = new Props(null, adminPropertiesFile);
+ if (props.containsKey("mysql.host") && props.containsKey("user.manager.class")) {
+ secureMode = true;
+ }
+ }
+ else {
+ props = new Props();
+ }
+
+ if (secureMode) {
+ app = new AzkabanAdminServer(props, adminPropertiesFile, false);
+
+ SslSocketConnector secureConnector = new SslSocketConnector();
+ secureConnector.setPort(port);
+ server.addConnector(secureConnector);
+ }
+ else {
+ logger.info("Server settings not found. Running setup wizard.");
+ props.put("pluginLibDirectory", pluginLib);
+ app = new AzkabanAdminServer(props, adminPropertiesFile, true);
+ SocketConnector connector = new SocketConnector();
+ connector.setPort(port);
+ server.addConnector(connector);
+ }
+
+ Context root = new Context(server, "/", Context.SESSIONS);
+ String staticDir = webDir;
+ root.setResourceBase(staticDir);
+
+ root.setAttribute(AzkabanServletContextListener.AZKABAN_SERVLET_CONTEXT_KEY, app);
+ ServletHolder executorHolder = new ServletHolder(new InitialSetupServlet());
+ root.addServlet(executorHolder, "/");
+
+ ServletHolder staticServlet = new ServletHolder(new DefaultServlet());
+ root.addServlet(staticServlet, "/css/*");
+ root.addServlet(staticServlet, "/js/*");
+ root.addServlet(staticServlet, "/images/*");
+ root.addServlet(staticServlet, "/favicon.ico");
+
+ try {
+ server.start();
+ }
+ catch (Exception e) {
+ logger.warn(e);
+ Utils.croak(e.getMessage(), 1);
+ }
+
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ public void run() {
+ logger.info("Shutting down http server...");
+ try {
+ app.stopServer();
+ } catch (Exception e) {
+ logger.error("Error while shutting down http server.", e);
+ }
+ logger.info("kk thx bye.");
+ }
+ });
+ }
+
+ public void stopServer() throws Exception {
+ server.stop();
+ server.destroy();
+ }
+
+ @Override
+ public Props getServerProps() {
+ return props;
+ }
+
+ @Override
+ public VelocityEngine getVelocityEngine() {
+ return velocityEngine;
+ }
+
+ @Override
+ public SessionCache getSessionCache() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public UserManager getUserManager() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getPluginLibDirectory() {
+ return pluginLibDirectory;
+ }
+
+ private UserManager loadUserManager(Props props) {
+ Class<?> userManagerClass = props.getClass(USER_MANAGER_CLASS_PARAM, null);
+ logger.info("Loading user manager class " + userManagerClass.getName());
+ UserManager manager = null;
+
+ if (userManagerClass != null && userManagerClass.getConstructors().length > 0) {
+
+ try {
+ Constructor<?> userManagerConstructor = userManagerClass.getConstructor(Props.class);
+ manager = (UserManager) userManagerConstructor.newInstance(props);
+ }
+ catch (Exception e) {
+ logger.error("Could not instantiate UserManager "+ userManagerClass.getName());
+ throw new RuntimeException(e);
+ }
+
+ }
+ else {
+ manager = new XmlUserManager(props);
+ }
+
+ return manager;
+ }
+}
src/java/azkaban/webapp/AzkabanServer.java 17(+17 -0)
diff --git a/src/java/azkaban/webapp/AzkabanServer.java b/src/java/azkaban/webapp/AzkabanServer.java
new file mode 100644
index 0000000..b88c9a8
--- /dev/null
+++ b/src/java/azkaban/webapp/AzkabanServer.java
@@ -0,0 +1,17 @@
+package azkaban.webapp;
+
+import org.apache.velocity.app.VelocityEngine;
+
+import azkaban.user.UserManager;
+import azkaban.utils.Props;
+import azkaban.webapp.session.SessionCache;
+
+public interface AzkabanServer {
+ public Props getServerProps();
+
+ public VelocityEngine getVelocityEngine();
+
+ public SessionCache getSessionCache();
+
+ public UserManager getUserManager();
+}
\ No newline at end of file
src/java/azkaban/webapp/AzkabanWebServer.java 216(+120 -96)
diff --git a/src/java/azkaban/webapp/AzkabanWebServer.java b/src/java/azkaban/webapp/AzkabanWebServer.java
index 2871ef2..fbe9878 100644
--- a/src/java/azkaban/webapp/AzkabanWebServer.java
+++ b/src/java/azkaban/webapp/AzkabanWebServer.java
@@ -24,6 +24,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Arrays;
+import java.util.Properties;
import java.util.TimeZone;
import org.apache.log4j.Logger;
@@ -39,10 +40,14 @@ import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.thread.QueuedThreadPool;
import azkaban.executor.ExecutorManager;
-import azkaban.project.FileProjectManager;
+import azkaban.executor.JdbcExecutorLoader;
+import azkaban.project.JdbcProjectLoader;
import azkaban.project.ProjectManager;
-import azkaban.scheduler.LocalFileScheduleLoader;
+
+import azkaban.scheduler.JdbcScheduleLoader;
import azkaban.scheduler.ScheduleManager;
+import azkaban.security.DefaultHadoopSecurityManager;
+import azkaban.security.HadoopSecurityManager;
import azkaban.user.UserManager;
import azkaban.user.XmlUserManager;
import azkaban.utils.Props;
@@ -81,13 +86,16 @@ import joptsimple.OptionSpec;
* keystore password jetty.truststore - Jetty truststore jetty.trustpassword -
* Jetty truststore password
*/
-public class AzkabanWebServer {
+public class AzkabanWebServer implements AzkabanServer {
private static final Logger logger = Logger.getLogger(AzkabanWebServer.class);
public static final String AZKABAN_HOME = "AZKABAN_HOME";
public static final String DEFAULT_CONF_PATH = "conf";
public static final String AZKABAN_PROPERTIES_FILE = "azkaban.properties";
+ public static final String AZKABAN_PRIVATE_PROPERTIES_FILE = "azkaban.private.properties";
+ public static final String JDO_PROPERTIES_FILE = "jdo.properties";
+ private static final int MAX_FORM_CONTENT_SIZE = 10*1024*1024;
private static AzkabanWebServer app;
private static final String DEFAULT_TIMEZONE_ID = "default.timezone.id";
@@ -96,16 +104,18 @@ public class AzkabanWebServer {
private static final int DEFAULT_THREAD_NUMBER = 20;
private static final String VELOCITY_DEV_MODE_PARAM = "velocity.dev.mode";
private static final String USER_MANAGER_CLASS_PARAM = "user.manager.class";
- private static final String PROJECT_MANAGER_CLASS_PARAM = "project.manager.class";
+ private static final String HADOOP_SECURITY_MANAGER_CLASS_PARAM = "hadoop.security.manager.class";
private static final String DEFAULT_STATIC_DIR = "";
private final VelocityEngine velocityEngine;
+
private UserManager userManager;
private ProjectManager projectManager;
private ExecutorManager executorManager;
private ScheduleManager scheduleManager;
- private final ClassLoader _baseClassLoader;
+ private final ClassLoader baseClassLoader;
+ private HadoopSecurityManager hadoopSecurityManager;
private Props props;
private SessionCache sessionCache;
@@ -130,7 +140,9 @@ public class AzkabanWebServer {
projectManager = loadProjectManager(props);
executorManager = loadExecutorManager(props);
scheduleManager = loadScheduleManager(executorManager, props);
- _baseClassLoader = getBaseClassloader();
+ baseClassLoader = getBaseClassloader();
+ hadoopSecurityManager = loadHadoopSecurityManager(props);
+
tempDir = new File(props.getString("azkaban.temp.dir", "temp"));
// Setup time zone
@@ -141,9 +153,8 @@ public class AzkabanWebServer {
logger.info("Setting timezone to " + timezone);
}
-
}
-
+
private UserManager loadUserManager(Props props) {
Class<?> userManagerClass = props.getClass(USER_MANAGER_CLASS_PARAM, null);
logger.info("Loading user manager class " + userManagerClass.getName());
@@ -169,41 +180,26 @@ public class AzkabanWebServer {
}
private ProjectManager loadProjectManager(Props props) {
- Class<?> projectManagerClass = props.getClass(PROJECT_MANAGER_CLASS_PARAM, null);
- logger.info("Loading project manager class " + projectManagerClass.getName());
- ProjectManager manager = null;
-
- if (projectManagerClass != null && projectManagerClass.getConstructors().length > 0) {
-
- try {
- Constructor<?> projectManagerConstructor = projectManagerClass.getConstructor(Props.class);
- manager = (ProjectManager) projectManagerConstructor.newInstance(props);
- }
- catch (Exception e) {
- logger.error("Could not instantiate ProjectManager " + projectManagerClass.getName());
- throw new RuntimeException(e);
- }
-
- }
- else {
- manager = new FileProjectManager(props);
- }
+ logger.info("Loading JDBC for project management");
+ JdbcProjectLoader loader = new JdbcProjectLoader(props);
+ ProjectManager manager = new ProjectManager(loader, props);
+
return manager;
}
private ExecutorManager loadExecutorManager(Props props) throws Exception {
- ExecutorManager execManager = new ExecutorManager(props);
+ JdbcExecutorLoader loader = new JdbcExecutorLoader(props);
+ ExecutorManager execManager = new ExecutorManager(props, loader);
return execManager;
}
private ScheduleManager loadScheduleManager(ExecutorManager execManager, Props props ) throws Exception {
+ ScheduleManager schedManager = new ScheduleManager(execManager, projectManager, new JdbcScheduleLoader(props));
- ScheduleManager schedManager = new ScheduleManager(execManager, projectManager, new LocalFileScheduleLoader(props));
return schedManager;
}
-
/**
* Returns the web session cache.
*
@@ -248,7 +244,7 @@ public class AzkabanWebServer {
public ScheduleManager getScheduleManager() {
return scheduleManager;
}
-
+
/**
* Creates and configures the velocity engine.
*
@@ -277,40 +273,69 @@ public class AzkabanWebServer {
engine.setProperty("parser.pool.size", 3);
return engine;
}
+
+ private ClassLoader getBaseClassloader() throws MalformedURLException {
+ final ClassLoader retVal;
+
+ String hadoopHome = System.getenv("HADOOP_HOME");
+ String hadoopConfDir = System.getenv("HADOOP_CONF_DIR");
+
+ if (hadoopConfDir != null) {
+ logger.info("Using hadoop config found in " + hadoopConfDir);
+ retVal = new URLClassLoader(new URL[] { new File(hadoopConfDir)
+ .toURI().toURL() }, getClass().getClassLoader());
+ } else if (hadoopHome != null) {
+ logger.info("Using hadoop config found in " + hadoopHome);
+ retVal = new URLClassLoader(
+ new URL[] { new File(hadoopHome, "conf").toURI().toURL() },
+ getClass().getClassLoader());
+ } else {
+ logger.info("HADOOP_HOME not set, using default hadoop config.");
+ retVal = getClass().getClassLoader();
+ }
+
+ return retVal;
+ }
+
+ public HadoopSecurityManager getHadoopSecurityManager() {
+ return hadoopSecurityManager;
+ }
- private ClassLoader getBaseClassloader() throws MalformedURLException
- {
- final ClassLoader retVal;
-
- String hadoopHome = System.getenv("HADOOP_HOME");
- String hadoopConfDir = System.getenv("HADOOP_CONF_DIR");
-
- if(hadoopConfDir != null) {
- logger.info("Using hadoop config found in " + hadoopConfDir);
- retVal = new URLClassLoader(new URL[] { new File(hadoopConfDir).toURI().toURL() },
- getClass().getClassLoader());
- } else if(hadoopHome != null) {
- logger.info("Using hadoop config found in " + hadoopHome);
- retVal = new URLClassLoader(new URL[] { new File(hadoopHome, "conf").toURI().toURL() },
- getClass().getClassLoader());
- } else {
- logger.info("HADOOP_HOME not set, using default hadoop config.");
- retVal = getClass().getClassLoader();
- }
-
- return retVal;
- }
-
- public ClassLoader getClassLoader() {
- return _baseClassLoader;
- }
-
+ private HadoopSecurityManager loadHadoopSecurityManager(Props props) {
+
+ Class<?> hadoopSecurityManagerClass = props.getClass(HADOOP_SECURITY_MANAGER_CLASS_PARAM, null);
+ logger.info("Loading hadoop security manager class " + hadoopSecurityManagerClass.getName());
+ HadoopSecurityManager hadoopSecurityManager = null;
+
+ if (hadoopSecurityManagerClass != null && hadoopSecurityManagerClass.getConstructors().length > 0) {
+
+ try {
+ Constructor<?> hsmConstructor = hadoopSecurityManagerClass.getConstructor(Props.class);
+ hadoopSecurityManager = (HadoopSecurityManager) hsmConstructor.newInstance(props);
+ }
+ catch (Exception e) {
+ logger.error("Could not instantiate Hadoop Security Manager "+ hadoopSecurityManagerClass.getName());
+ throw new RuntimeException(e);
+ }
+ }
+ else {
+ hadoopSecurityManager = new DefaultHadoopSecurityManager();
+ }
+
+ return hadoopSecurityManager;
+
+ }
+
+ public ClassLoader getClassLoader() {
+ return baseClassLoader;
+ }
+
/**
* Returns the global azkaban properties
*
* @return
*/
- public Props getAzkabanProps() {
+ public Props getServerProps() {
return props;
}
@@ -335,12 +360,16 @@ public class AzkabanWebServer {
if (options.has(configDirectory)) {
String path = options.valueOf(configDirectory);
logger.info("Loading azkaban settings file from " + path);
- File file = new File(path, AZKABAN_PROPERTIES_FILE);
- if (!file.exists() || file.isDirectory() || !file.canRead()) {
- logger.error("Cannot read file " + file);
+ File dir = new File(path);
+ if (!dir.exists()) {
+ logger.error("Conf directory " + path + " doesn't exist.");
+ }
+ else if (!dir.isDirectory()) {
+ logger.error("Conf directory " + path + " isn't a directory.");
+ }
+ else {
+ azkabanSettings = loadAzkabanConfigurationFromDirectory(dir);
}
-
- azkabanSettings = loadAzkabanConfiguration(file.getPath());
}
else {
logger.info("Conf parameter not set, attempting to get value from AZKABAN_HOME env.");
@@ -348,10 +377,6 @@ public class AzkabanWebServer {
}
if (azkabanSettings == null) {
- // one last chance to
- }
-
- if (azkabanSettings == null) {
logger.error("Azkaban Properties not loaded.");
logger.error("Exiting Azkaban...");
return;
@@ -375,6 +400,7 @@ public class AzkabanWebServer {
secureConnector.setKeyPassword(azkabanSettings.getString("jetty.keypassword"));
secureConnector.setTruststore(azkabanSettings.getString("jetty.truststore"));
secureConnector.setTrustPassword(azkabanSettings.getString("jetty.trustpassword"));
+
server.addConnector(secureConnector);
QueuedThreadPool httpThreadPool = new QueuedThreadPool(maxThreads);
@@ -383,7 +409,8 @@ public class AzkabanWebServer {
String staticDir = azkabanSettings.getString("web.resource.dir", DEFAULT_STATIC_DIR);
logger.info("Setting up web resource dir " + staticDir);
Context root = new Context(server, "/", Context.SESSIONS);
-
+ root.setMaxFormContentSize(MAX_FORM_CONTENT_SIZE);
+
root.setResourceBase(staticDir);
ServletHolder index = new ServletHolder(new IndexServlet());
root.addServlet(index, "/index");
@@ -394,7 +421,7 @@ public class AzkabanWebServer {
root.addServlet(staticServlet, "/js/*");
root.addServlet(staticServlet, "/images/*");
root.addServlet(staticServlet, "/favicon.ico");
-
+
root.addServlet(new ServletHolder(new ProjectManagerServlet()),"/manager");
root.addServlet(new ServletHolder(new ExecutorServlet()),"/executor");
root.addServlet(new ServletHolder(new HistoryServlet()), "/history");
@@ -453,13 +480,7 @@ public class AzkabanWebServer {
return null;
}
- File confFile = new File(confPath, AZKABAN_PROPERTIES_FILE);
- if (!confFile.exists() || confFile.isDirectory() || !confPath.canRead()) {
- logger.error(confFile + " does not contain a readable azkaban.properties file.");
- return null;
- }
-
- return loadAzkabanConfiguration(confFile.getPath());
+ return loadAzkabanConfigurationFromDirectory(confPath);
}
/**
@@ -470,26 +491,29 @@ public class AzkabanWebServer {
public File getTempDirectory() {
return tempDir;
}
-
- /**
- * Loads the Azkaban conf file int a Props object
- *
- * @param path
- * @return
- */
- private static Props loadAzkabanConfiguration(String path) {
+
+ private static Props loadAzkabanConfigurationFromDirectory(File dir) {
+ File azkabanPrivatePropsFile = new File(dir, AZKABAN_PRIVATE_PROPERTIES_FILE);
+ File azkabanPropsFile = new File(dir, AZKABAN_PROPERTIES_FILE);
+
+ Props props = null;
try {
- return new Props(null, path);
- }
- catch (FileNotFoundException e) {
- logger.error("File not found. Could not load azkaban config file " + path);
- }
- catch (IOException e) {
- logger.error("File found, but error reading. Could not load azkaban config file " + path);
- }
+ // This is purely optional
+ if (azkabanPrivatePropsFile.exists() && azkabanPrivatePropsFile.isFile()) {
+ logger.info("Loading azkaban private properties file" );
+ props = new Props(null, azkabanPrivatePropsFile);
+ }
- return null;
+ if (azkabanPropsFile.exists() && azkabanPropsFile.isFile()) {
+ logger.info("Loading azkaban properties file" );
+ props = new Props(props, azkabanPropsFile);
+ }
+ } catch (FileNotFoundException e) {
+ logger.error("File not found. Could not load azkaban config file", e);
+ } catch (IOException e) {
+ logger.error("File found, but error reading. Could not load azkaban config file", e);
+ }
+
+ return props;
}
-
-
}
diff --git a/src/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java b/src/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
index 727abc2..e1fd52c 100644
--- a/src/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
+++ b/src/java/azkaban/webapp/servlet/AbstractAzkabanServlet.java
@@ -38,6 +38,7 @@ import org.joda.time.format.DateTimeFormatter;
import azkaban.utils.WebUtils;
import azkaban.utils.JSONUtils;
import azkaban.utils.Props;
+import azkaban.webapp.AzkabanServer;
import azkaban.webapp.AzkabanWebServer;
import azkaban.webapp.session.Session;
@@ -58,7 +59,7 @@ public abstract class AbstractAzkabanServlet extends HttpServlet {
private static final WebUtils utils = new WebUtils();
- private AzkabanWebServer application;
+ private AzkabanServer application;
private String name;
private String label;
private String color;
@@ -68,20 +69,20 @@ public abstract class AbstractAzkabanServlet extends HttpServlet {
*
* @return
*/
- public AzkabanWebServer getApplication() {
+ public AzkabanServer getApplication() {
return application;
}
@Override
public void init(ServletConfig config) throws ServletException {
- application = (AzkabanWebServer) config.getServletContext().getAttribute(AzkabanServletContextListener.AZKABAN_SERVLET_CONTEXT_KEY);
+ application = (AzkabanServer) config.getServletContext().getAttribute(AzkabanServletContextListener.AZKABAN_SERVLET_CONTEXT_KEY);
if (application == null) {
throw new IllegalStateException(
"No batch application is defined in the servlet context!");
}
- Props props = application.getAzkabanProps();
+ Props props = application.getServerProps();
name = props.getString("azkaban.name", "");
label = props.getString("azkaban.label", "");
color = props.getString("azkaban.color", "#FF0000");
diff --git a/src/java/azkaban/webapp/servlet/admin/InitialSetupServlet.java b/src/java/azkaban/webapp/servlet/admin/InitialSetupServlet.java
new file mode 100644
index 0000000..b4f1b32
--- /dev/null
+++ b/src/java/azkaban/webapp/servlet/admin/InitialSetupServlet.java
@@ -0,0 +1,279 @@
+/*
+ * Copyright 2012 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package azkaban.webapp.servlet.admin;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.Logger;
+
+import azkaban.utils.DataSourceUtils;
+import azkaban.utils.Props;
+import azkaban.utils.Utils;
+import azkaban.webapp.AzkabanAdminServer;
+import azkaban.webapp.servlet.AbstractAzkabanServlet;
+import azkaban.webapp.servlet.MultipartParser;
+import azkaban.webapp.servlet.Page;
+
+/**
+ * The main page
+ */
+public class InitialSetupServlet extends AbstractAzkabanServlet {
+
+ private static final long serialVersionUID = -1;
+ private static final int DEFAULT_UPLOAD_DISK_SPOOL_SIZE = 20 * 1024 * 1024;
+ private static final String DB_DIRECTORY = "db";
+ private static final String LDAP_DIRECTORY = "auth";
+
+ private static Logger logger = Logger.getLogger(InitialSetupServlet.class);
+
+ private File mysqlConnectorJar;
+ private File propsFile;
+ private String pluginLibDirectory;
+ private MultipartParser multipartParser;
+ private Props props;
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ super.init(config);
+ AzkabanAdminServer server = (AzkabanAdminServer)getApplication();
+ pluginLibDirectory = server.getPluginLibDirectory();
+ props = server.getServerProps();
+ multipartParser = new MultipartParser(DEFAULT_UPLOAD_DISK_SPOOL_SIZE);
+ mysqlConnectorJar = getConnectorJar();
+ propsFile = server.getPropFile();
+ }
+
+ private File getConnectorJar() {
+ File pluginLibs = new File(pluginLibDirectory);
+ File dbPluginDir = new File(pluginLibs, DB_DIRECTORY);
+ if (dbPluginDir.exists()) {
+ File[] listFiles = dbPluginDir.listFiles(new PrefixSuffixFilter("mysql-connector", ".jar"));
+ if (listFiles.length > 0) {
+ return listFiles[0];
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ if (hasParam(req, "dbsetup")) {
+ Page page = newPage(req, resp, "azkaban/webapp/servlet/admin/velocity/setup-db.vm");
+
+ String host = props.getString("mysql.host", "localhost");
+ int port = props.getInt("mysql.port", 3306);
+ String database = props.getString("mysql.database", "");
+ String username = props.getString("mysql.username", "");
+ String password = props.getString("mysql.password", "");
+
+ page.add("host", host);
+ page.add("port", port);
+ page.add("database", database);
+ page.add("username", username);
+ page.add("password", password);
+
+ if (mysqlConnectorJar != null) {
+ page.add("installedJar", mysqlConnectorJar.getName());
+
+ if (props.containsKey("mysql.host")) {
+ URL url = mysqlConnectorJar.toURI().toURL();
+ URL[] urls = new URL[] {url};
+ ClassLoader mySQLLoader = new URLClassLoader(urls, InitialSetupServlet.class.getClassLoader());
+
+ try {
+ Utils.invokeStaticMethod(mySQLLoader, DataSourceUtils.class.getName(), "testMySQLConnection", host, port, database, username, password, 1);
+ page.add("message", "Able to connect to DB.");
+ page.add("verified", true);
+ } catch (InvocationTargetException e) {
+ page.add("message", "");
+ page.add("verified", false);
+ }
+ catch (Exception e) {
+ page.add("message", "");
+ page.add("verified", false);
+ }
+ }
+ }
+
+ page.render();
+ }
+ else if (hasParam(req, "usersetup")) {
+ Page page = newPage(req, resp, "azkaban/webapp/servlet/admin/velocity/setup-usermanager.vm");
+ page.render();
+ }
+ else {
+ Page page = newPage(req, resp, "azkaban/webapp/servlet/admin/velocity/setup-initial.vm");
+ page.render();
+ }
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ HashMap<String, Object> jsonResponse = new HashMap<String,Object>();
+
+ if (ServletFileUpload.isMultipartContent(req)) {
+ logger.info("Post is multipart");
+ Map<String, Object> params = multipartParser.parseMultipart(req);
+ if (params.containsKey("action")) {
+ String action = (String)params.get("action");
+ if (action.equals("upload")) {
+ handleUpload(req, resp, params, jsonResponse);
+ }
+ }
+ }
+ else if (hasParam(req, "ajax")){
+ try {
+ String action = getParam(req, "ajax");
+ if (action.equals("saveDbConnection")) {
+ handleSaveDBConnection(req, resp, jsonResponse);
+ }
+ }
+ catch (InvocationTargetException e) {
+ jsonResponse.put("error", e.getTargetException().getMessage());
+ }
+ catch (Exception e) {
+ jsonResponse.put("error", e.getMessage());
+ }
+ }
+
+ this.writeJSON(resp, jsonResponse);
+ }
+
+ private void handleSaveDBConnection(HttpServletRequest req, HttpServletResponse resp, Map<String, Object> jsonResponse) throws Exception {
+ if (mysqlConnectorJar == null) {
+ jsonResponse.put("error", "No connector jar has been installed");
+ }
+ else {
+ String host = getParam(req, "host");
+ int port = getIntParam(req, "port");
+ String database = getParam(req, "database");
+ String username = getParam(req, "username");
+ String password = getParam(req, "password");
+
+ URL url = mysqlConnectorJar.toURI().toURL();
+ URL[] urls = new URL[] {url};
+ ClassLoader mySQLLoader = new URLClassLoader(urls, InitialSetupServlet.class.getClassLoader());
+
+ Utils.invokeStaticMethod(mySQLLoader, DataSourceUtils.class.getName(), "testMySQLConnection", host, port, database, username, password, 1);
+
+ props.put("mysql.host", host);
+ props.put("mysql.port", port);
+ props.put("mysql.database", database);
+ props.put("mysql.username", username);
+ props.put("mysql.password", password);
+
+ logger.info("Print file " + propsFile.getPath());
+ props.storeLocal(propsFile);
+
+ jsonResponse.put("success", "Able to connect to DB.");
+ }
+ }
+
+ private void handleUpload(HttpServletRequest req, HttpServletResponse resp, Map<String, Object> multipart, Map<String, Object> jsonResponse) throws ServletException, IOException {
+ FileItem item = (FileItem) multipart.get("file");
+ String name = item.getName();
+
+ final String contentType = item.getContentType();
+
+ File tempDir = Utils.createTempDir();
+ OutputStream out = null;
+ try {
+ logger.info("Uploading file " + name);
+ File archiveFile = new File(tempDir, name);
+ out = new BufferedOutputStream(new FileOutputStream(archiveFile));
+ IOUtils.copy(item.getInputStream(), out);
+ out.close();
+
+ File pluginLibs = new File(pluginLibDirectory);
+ File dbPluginDir = new File(pluginLibs, DB_DIRECTORY);
+ if (dbPluginDir.exists()) {
+
+ }
+ if (!dbPluginDir.exists()) {
+ dbPluginDir.mkdirs();
+ }
+ else {
+ FileUtils.cleanDirectory(dbPluginDir);
+ }
+
+ File newName = new File(dbPluginDir, archiveFile.getName());
+ archiveFile.renameTo(newName);
+ mysqlConnectorJar = newName;
+
+ jsonResponse.put("jarname", archiveFile.getName());
+ } catch (Exception e) {
+ jsonResponse.put("error", "Failed:" + e.getMessage());
+ }
+ finally {
+ if (tempDir.exists()) {
+ FileUtils.deleteDirectory(tempDir);
+ }
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ private static class PrefixSuffixFilter implements FileFilter {
+ private String prefix;
+ private String suffix;
+
+ public PrefixSuffixFilter(String prefix, String suffix) {
+ this.prefix = prefix;
+ this.suffix = suffix;
+ }
+
+ @Override
+ public boolean accept(File pathname) {
+ String name = pathname.getName();
+
+ if (!pathname.isFile() || pathname.isHidden()) {
+ return false;
+ }
+
+ if (name.length() < prefix.length() || !name.startsWith(prefix)) {
+ return false;
+ }
+
+ if (name.length() < suffix.length() || !name.endsWith(suffix)) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/src/java/azkaban/webapp/servlet/admin/velocity/setup-db.vm b/src/java/azkaban/webapp/servlet/admin/velocity/setup-db.vm
new file mode 100644
index 0000000..63f6cef
--- /dev/null
+++ b/src/java/azkaban/webapp/servlet/admin/velocity/setup-db.vm
@@ -0,0 +1,89 @@
+#*
+ * Copyright 2012 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+*#
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>#appname()</title>
+ <link rel="stylesheet" type="text/css" href="${context}/css/azkaban.css">
+ <link rel="shortcut icon" href="${context}/favicon.ico" />
+ <script type="text/javascript" src="${context}/js/jquery/jquery.js"></script>
+ <script type="text/javascript" src="${context}/js/namespace.js"></script>
+ <script type="text/javascript" src="${context}/js/underscore-1.2.1-min.js"></script>
+ <script type="text/javascript" src="${context}/js/backbone-0.5.3-min.js"></script>
+ <script type="text/javascript" src="${context}/js/azkaban.admin.setup.js"></script>
+ #parse( "azkaban/webapp/servlet/velocity/style.vm" )
+ <script type="text/javascript">
+ var contextURL = "${context}";
+ var verified = $verified;
+ var message = "$message";
+ </script>
+ </head>
+ <body>
+ <div class="header">
+ #parse("azkaban/webapp/servlet/admin/velocity/title.vm" )
+ </div>
+ <div class="shadow-box admin">
+ <div id="all-jobs-content">
+ <div class="section-hd">
+ <h2>Azkaban Setup DB</h2>
+ </div>
+ </div>
+ <div class="comment">
+ We need to setup the datastore that Azkaban will use. Currently the only store that is supported is JDBC MySQL.
+ </div>
+ <div id="dbuploadpanel" class="admin-panel">
+ <h3>DB Connector Jar</h3>
+ <div class="comment">
+ Since Azkaban does not distribute GPL packages, the MySQL JDBC Connector Jar is not included with the default distribution.<br/>
+ You will need to upload it here. The jar file should be named <span class="bold">mysql-connector-*.jar</span>
+ </div>
+ <form class="upload" id="upload-form" enctype="multipart/form-data" method="post" action="$!context/?upload">
+ <fieldset>
+ <dl>
+ <dd><input id="file" name="file" class="file" type="file" /></dd>
+ <input type="hidden" name="action" value="upload" />
+ </dl>
+ </fieldset>
+ <div class="yes button1 btn2" id="upload-jar-btn">Upload Jar</div>
+ <div id="installed" class="installed">#if($installedJar) Currently installed Jar <span class="bold">$installedJar</span> #else No jars Installed.#end</div>
+ </form>
+ </div>
+ <div id="dbsettingspanel" class="admin-panel">
+ <h3>DB Connection Settings</h3>
+ <div class="comment">
+ Fill in the parameters to connect to your database. The database should already be set up to give the azkaban user read, write, update, insert tables to the azkaban user for the hosts that serve the admin client, azkaban web client and the executor server.
+ Also give admin host create, drop, alter table if you want the admin tool to automatically setup the database. Azkaban does not need access to add and remove user permissions.
+ </div>
+ <form id="dbconnection">
+ <table>
+ <tr><td class="left">Host</td> <td class="param"><input type="text" id="host" name="host" value="$host"></input></td> <td class="desc">The mysql instance host url/ip. i.e. mysql.mytestdomain.com</td></tr>
+ <tr><td class="left">Port</td> <td class="param"><input type="text" id="port" name="port" value="$port"></input></td> <td class="desc">The port. Default Mysql is 3306</td></tr>
+ <tr><td class="left">Database</td> <td class="param"><input type="text" id="database" name="database" value="$database"></input></td> <td class="desc">The database name.</td></tr>
+ <tr><td class="left">User</td> <td class="param"><input type="text" id="username" name="username" value="$username"></input></td> <td class="desc">The username which azkaban will use to connect to the db.</td></tr>
+ <tr><td class="left">Password</td> <td class="param"><input type="password" id="password" name="password" value="$password"></input></td> <td class="desc">The password which azkaban will use to connect to the db.</td></tr>
+ </table>
+ <div class="button1 btn2" id="save-connection-button">Test Connection</div><div id="save-results"></div>
+ </form>
+
+ </div>
+ <div class="shadow-box-footer">
+ <div id="saveAndContinue" class="btn2 button1">Continue</div>
+ <a href="${context}/" class="btn3 button1">Go Back</a>
+ </div>
+
+ </div>
+ </body>
+</html>
\ No newline at end of file
diff --git a/src/java/azkaban/webapp/servlet/admin/velocity/setup-initial.vm b/src/java/azkaban/webapp/servlet/admin/velocity/setup-initial.vm
new file mode 100644
index 0000000..afc1f54
--- /dev/null
+++ b/src/java/azkaban/webapp/servlet/admin/velocity/setup-initial.vm
@@ -0,0 +1,57 @@
+#*
+ * Copyright 2012 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+*#
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>#appname()</title>
+ <link rel="stylesheet" type="text/css" href="${context}/css/azkaban.css">
+ <link rel="shortcut icon" href="${context}/favicon.ico" />
+ <script type="text/javascript" src="${context}/js/jquery/jquery.js"></script>
+ <script type="text/javascript" src="${context}/js/namespace.js"></script>
+ <script type="text/javascript" src="${context}/js/underscore-1.2.1-min.js"></script>
+ <script type="text/javascript" src="${context}/js/backbone-0.5.3-min.js"></script>
+ #parse( "azkaban/webapp/servlet/velocity/style.vm" )
+ <script type="text/javascript">
+ var contextURL = "${context}";
+ </script>
+ </head>
+ <body>
+ <div class="header">
+ #parse("azkaban/webapp/servlet/admin/velocity/title.vm" )
+ </div>
+ <div class="shadow-box admin">
+ <div id="all-jobs-content">
+ <div class="section-hd">
+ <h2>Initial Azkaban Setup</h2>
+ </div>
+ </div>
+ <div class="comment">
+ To get started with Azkaban, there are a few things we need to get done.
+
+ <ul class="admin-setup-points">
+ <li>Setup Database</li>
+ <li>Setup Authentication</li>
+ <li>Create Config Files</li>
+ </ul>
+ </div>
+ <div class="shadow-box-footer">
+ <a href="${context}?dbsetup" class="btn2 button1">Continue</a>
+ </div>
+
+ </div>
+ </body>
+</html>
+
diff --git a/src/java/azkaban/webapp/servlet/admin/velocity/setup-usermanager.vm b/src/java/azkaban/webapp/servlet/admin/velocity/setup-usermanager.vm
new file mode 100644
index 0000000..adc57c9
--- /dev/null
+++ b/src/java/azkaban/webapp/servlet/admin/velocity/setup-usermanager.vm
@@ -0,0 +1,70 @@
+#*
+ * Copyright 2012 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+*#
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>#appname()</title>
+ <link rel="stylesheet" type="text/css" href="${context}/css/azkaban.css">
+ <link rel="shortcut icon" href="${context}/favicon.ico" />
+ <script type="text/javascript" src="${context}/js/jquery/jquery.js"></script>
+ <script type="text/javascript" src="${context}/js/namespace.js"></script>
+ <script type="text/javascript" src="${context}/js/underscore-1.2.1-min.js"></script>
+ <script type="text/javascript" src="${context}/js/backbone-0.5.3-min.js"></script>
+ #parse( "azkaban/webapp/servlet/velocity/style.vm" )
+ <script type="text/javascript">
+ var contextURL = "${context}";
+ </script>
+ </head>
+ <body>
+ <div class="header">
+ #parse("azkaban/webapp/servlet/admin/velocity/title.vm" )
+ </div>
+ <div class="shadow-box admin">
+ <div id="all-jobs-content">
+ <div class="section-hd">
+ <h2>Setup UserManager</h2>
+ </div>
+ </div>
+ <div class="comment">
+ Azkaban uses a UserManager to authenticate. The default is the XmlUserManager. For LDAP authentication you can upload your own.
+ </div>
+ <div id="usermanagerpanel" class="admin-panel">
+ <h3>UserManager Upload</h3>
+ <input type="radio" name="group1" value="xml"/><label for="xml">XmlUserManager</label>
+ <input type="radio" name="group1" value="custom"/><label for="custom">Custom Manager</label>
+ <div class="xml-panel">
+ <div class="comment">
+ The default manager. Please upload your user xml file.
+ </div>
+ </div>
+ <div class="custom-panel">
+ <div class="comment">
+ Upload your jar. Input your custom jar settings for the UserManager
+ </div>
+ </div>
+ </div>
+
+ <div class="shadow-box-footer">
+ </div>
+
+ <div class="shadow-box-footer">
+ <div id="saveAndContinue" class="btn2 button1">Continue</div>
+ <a href="${context}/?dbsetup" class="btn3 button1">Go Back</a>
+ </div>
+
+ </div>
+ </body>
+</html>
\ No newline at end of file
diff --git a/src/java/azkaban/webapp/servlet/admin/velocity/title.vm b/src/java/azkaban/webapp/servlet/admin/velocity/title.vm
new file mode 100644
index 0000000..dec058d
--- /dev/null
+++ b/src/java/azkaban/webapp/servlet/admin/velocity/title.vm
@@ -0,0 +1,20 @@
+#*
+ * Copyright 2012 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+*#
+ <h1 class="logo"><a href="${context}/" title="Azkaban">Azkaban Admin</a></h1>
+ <div class="enviro">
+ <p class="enviro-name">${azkaban_name}</p>
+ <p class="enviro-server">${azkaban_label}</p>
+ </div>
src/java/azkaban/webapp/servlet/ExecutorServlet.java 278(+144 -134)
diff --git a/src/java/azkaban/webapp/servlet/ExecutorServlet.java b/src/java/azkaban/webapp/servlet/ExecutorServlet.java
index 8e36964..8fb522f 100644
--- a/src/java/azkaban/webapp/servlet/ExecutorServlet.java
+++ b/src/java/azkaban/webapp/servlet/ExecutorServlet.java
@@ -16,9 +16,7 @@
package azkaban.webapp.servlet;
-import java.io.File;
import java.io.IOException;
-import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -39,13 +37,15 @@ import azkaban.executor.ExecutorManagerException;
import azkaban.flow.Flow;
import azkaban.project.Project;
import azkaban.project.ProjectManager;
-import azkaban.project.ProjectManagerException;
+import azkaban.scheduler.Schedule;
import azkaban.scheduler.ScheduleManager;
-import azkaban.scheduler.ScheduledFlow;
import azkaban.user.Permission;
+import azkaban.user.Role;
import azkaban.user.User;
import azkaban.user.Permission.Type;
-import azkaban.utils.Utils;
+import azkaban.user.UserManager;
+import azkaban.utils.FileIOUtils.LogData;
+import azkaban.webapp.AzkabanWebServer;
import azkaban.webapp.session.Session;
public class ExecutorServlet extends LoginAbstractAzkabanServlet {
@@ -53,13 +53,18 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
private ProjectManager projectManager;
private ExecutorManager executorManager;
private ScheduleManager scheduleManager;
+ private UserManager userManager;
+ private ExecutorVMHelper vmHelper;
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
- projectManager = this.getApplication().getProjectManager();
- executorManager = this.getApplication().getExecutorManager();
- scheduleManager = this.getApplication().getScheduleManager();
+ AzkabanWebServer server = (AzkabanWebServer)getApplication();
+ projectManager = server.getProjectManager();
+ executorManager = server.getExecutorManager();
+ scheduleManager = server.getScheduleManager();
+ userManager = server.getUserManager();
+ vmHelper = new ExecutorVMHelper();
}
@Override
@@ -83,7 +88,7 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
private void handleExecutionJobPage(HttpServletRequest req, HttpServletResponse resp, Session session) throws ServletException, IOException {
Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/joblogpage.vm");
User user = session.getUser();
- String execId = getParam(req, "execid");
+ int execId = getIntParam(req, "execid");
String jobId = getParam(req, "job");
page.add("execid", execId);
page.add("jobid", jobId);
@@ -102,14 +107,14 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
return;
}
- String projectId = flow.getProjectId();
- Project project = getProjectPageByPermission(page, flow.getProjectId(), user, Type.READ);
+ int projectId = flow.getProjectId();
+ Project project = getProjectPageByPermission(page, projectId, user, Type.READ);
if (project == null) {
page.render();
return;
}
- page.add("projectName", projectId);
+ page.add("projectName", project.getName());
page.add("flowid", flow.getFlowId());
page.render();
@@ -123,13 +128,14 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
List<ExecutableFlow> finishedFlows = executorManager.getRecentlyFinishedFlows();
page.add("recentlyFinished", finishedFlows.isEmpty() ? null : finishedFlows);
+ page.add("vmutils", vmHelper);
page.render();
}
private void handleExecutionFlowPage(HttpServletRequest req, HttpServletResponse resp, Session session) throws ServletException, IOException {
Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/executingflowpage.vm");
User user = session.getUser();
- String execId = getParam(req, "execid");
+ int execId = getIntParam(req, "execid");
page.add("execid", execId);
ExecutableFlow flow = null;
@@ -146,27 +152,43 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
return;
}
- String projectId = flow.getProjectId();
- Project project = getProjectPageByPermission(page, flow.getProjectId(), user, Type.READ);
+ int projectId = flow.getProjectId();
+ Project project = getProjectPageByPermission(page, projectId, user, Type.READ);
if(project == null) {
page.render();
return;
}
- page.add("projectName", projectId);
+ page.add("projectName", project.getName());
page.add("flowid", flow.getFlowId());
page.render();
}
- protected Project getProjectPageByPermission(Page page, String projectId, User user, Permission.Type type) {
+ protected Project getProjectPageByPermission(Page page, int projectId, User user, Permission.Type type) {
Project project = projectManager.getProject(projectId);
if (project == null) {
page.add("errorMsg", "Project " + project + " not found.");
}
- else if (!project.hasPermission(user, type)) {
- page.add("errorMsg", "User " + user.getUserId() + " doesn't have " + type.name() + " permissions on " + projectId);
+ else if (!hasPermission(project, user, type)) {
+ page.add("errorMsg", "User " + user.getUserId() + " doesn't have " + type.name() + " permissions on " + project.getName());
+ }
+ else {
+ return project;
+ }
+
+ return null;
+ }
+
+ protected Project getProjectAjaxByPermission(Map<String, Object> ret, String projectName, User user, Permission.Type type) {
+ Project project = projectManager.getProject(projectName);
+
+ if (project == null) {
+ ret.put("error", "Project '" + project + "' not found.");
+ }
+ else if (!hasPermission(project, user, type)) {
+ ret.put("error", "User '" + user.getUserId() + "' doesn't have " + type.name() + " permissions on " + project.getName());
}
else {
return project;
@@ -175,14 +197,14 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
return null;
}
- protected Project getProjectAjaxByPermission(Map<String, Object> ret, String projectId, User user, Permission.Type type) {
+ protected Project getProjectAjaxByPermission(Map<String, Object> ret, int projectId, User user, Permission.Type type) {
Project project = projectManager.getProject(projectId);
if (project == null) {
ret.put("error", "Project '" + project + "' not found.");
}
- else if (!project.hasPermission(user, type)) {
- ret.put("error", "User '" + user.getUserId() + "' doesn't have " + type.name() + " permissions on " + projectId);
+ else if (!hasPermission(project, user, type)) {
+ ret.put("error", "User '" + user.getUserId() + "' doesn't have " + type.name() + " permissions on " + project.getName());
}
else {
return project;
@@ -190,7 +212,7 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
return null;
}
-
+
@Override
protected void handlePost(HttpServletRequest req, HttpServletResponse resp, Session session) throws ServletException, IOException {
if (hasParam(req, "ajax")) {
@@ -203,7 +225,7 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
String ajaxName = getParam(req, "ajax");
if (hasParam(req, "execid")) {
- String execid = getParam(req, "execid");
+ int execid = getIntParam(req, "execid");
ExecutableFlow exFlow = null;
try {
@@ -236,16 +258,15 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
}
else if (ajaxName.equals("fetchExecFlowLogs")) {
ajaxFetchExecFlowLogs(req, resp, ret, session.getUser(), exFlow);
- ret = null;
}
else if (ajaxName.equals("fetchExecJobLogs")) {
ajaxFetchJobLogs(req, resp, ret, session.getUser(), exFlow);
- ret = null;
}
else if (ajaxName.equals("flowInfo")) {
String projectName = getParam(req, "project");
+ Project project = projectManager.getProject(projectName);
String flowName = getParam(req, "flow");
- ajaxFetchExecutableFlowInfo(req, resp, ret, session.getUser(), projectName, flowName, exFlow);
+ ajaxFetchExecutableFlowInfo(req, resp, ret, session.getUser(), exFlow);
}
}
}
@@ -257,7 +278,6 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
else if (ajaxName.equals("flowInfo")) {
String projectName = getParam(req, "project");
String flowName = getParam(req, "flow");
-
ajaxFetchFlowInfo(req, resp, ret, session.getUser(), projectName, flowName);
}
else {
@@ -282,34 +302,32 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
* @param exFlow
* @throws ServletException
*/
- private void ajaxFetchExecFlowLogs(HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user, ExecutableFlow exFlow) throws ServletException {
+ private void ajaxFetchExecFlowLogs(HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user, ExecutableFlow exFlow) throws ServletException {
Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.READ);
if (project == null) {
return;
}
- int startChar = this.getIntParam(req, "current");
- int maxSize = this.getIntParam(req, "max");
+ int offset = this.getIntParam(req, "offset");
+ int length = this.getIntParam(req, "length");
- resp.setContentType("text/plain");
resp.setCharacterEncoding("utf-8");
- PrintWriter writer;
- try {
- writer = resp.getWriter();
- } catch (IOException e) {
- throw new ServletException(e);
- }
try {
- long character = executorManager.getExecutableFlowLog(exFlow, writer, startChar, maxSize);
- writer.write("\n");
- writer.write(Long.toString(character));
+ LogData data = executorManager.getExecutableFlowLog(exFlow, offset, length);
+ if (data == null) {
+ ret.put("length", 0);
+ ret.put("offset", offset);
+ ret.put("data", "");
+ }
+ else {
+ ret.put("length", data.getLength());
+ ret.put("offset", data.getOffset());
+ ret.put("data", data.getData());
+ }
} catch (ExecutorManagerException e) {
throw new ServletException(e);
}
- finally {
- writer.close();
- }
}
/**
@@ -327,70 +345,70 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
return;
}
- int startChar = this.getIntParam(req, "current");
- int maxSize = this.getIntParam(req, "max");
- String jobId = this.getParam(req, "job");
-
- PrintWriter writer;
- try {
- writer = resp.getWriter();
- } catch (IOException e) {
- throw new ServletException(e);
- }
-
+ int offset = this.getIntParam(req, "offset");
+ int length = this.getIntParam(req, "length");
+ String jobId = this.getParam(req, "jobId");
+ resp.setCharacterEncoding("utf-8");
+
try {
- long character = executorManager.getExecutionJobLog(exFlow, jobId, writer, startChar, maxSize);
- writer.write("\n");
- writer.write(Long.toString(character));
+ LogData data = executorManager.getExecutionJobLog(exFlow, jobId, offset, length);
+ if (data == null) {
+ ret.put("length", 0);
+ ret.put("offset", offset);
+ ret.put("data", "");
+ }
+ else {
+ ret.put("length", data.getLength());
+ ret.put("offset", data.getOffset());
+ ret.put("data", data.getData());
+ }
} catch (ExecutorManagerException e) {
- e.printStackTrace();
- ret.put("error", e.getMessage());
+ throw new ServletException(e);
}
}
- private void ajaxFetchFlowInfo(HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user, String projectId, String flowId) throws ServletException {
- Project project = getProjectAjaxByPermission(ret, projectId, user, Type.READ);
+ private void ajaxFetchFlowInfo(HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user, String projectName, String flowId) throws ServletException {
+ Project project = getProjectAjaxByPermission(ret, projectName, user, Type.READ);
if (project == null) {
return;
}
Flow flow = project.getFlow(flowId);
if (flow == null) {
- ret.put("error", "Error loading flow. Flow " + flowId + " doesn't exist in " + projectId);
+ ret.put("error", "Error loading flow. Flow " + flowId + " doesn't exist in " + projectName);
return;
}
ret.put("successEmails", flow.getSuccessEmails());
ret.put("failureEmails", flow.getFailureEmails());
- ret.put("running", executorManager.getFlowRunningFlows(projectId, flowId));
- ScheduledFlow sflow = null;
- for (ScheduledFlow schedFlow: scheduleManager.getSchedule()) {
- if (schedFlow.getProjectId().equals(projectId) && schedFlow.getFlowId().equals(flowId)) {
- sflow = schedFlow;
+ Schedule sflow = null;
+ for (Schedule sched: scheduleManager.getSchedules()) {
+ if (sched.getProjectId() == project.getId() && sched.getFlowName().equals(flowId)) {
+ sflow = sched;
break;
}
}
if (sflow != null) {
- ret.put("scheduled", sflow.getNextExecTime().getMillis());
+ ret.put("scheduled", sflow.getNextExecTime());
}
}
- private void ajaxFetchExecutableFlowInfo(HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user, String projectId, String flowId, ExecutableFlow exflow) throws ServletException {
- Project project = getProjectAjaxByPermission(ret, projectId, user, Type.READ);
+ private void ajaxFetchExecutableFlowInfo(HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user, ExecutableFlow exflow) throws ServletException {
+ Project project = getProjectAjaxByPermission(ret, exflow.getProjectId(), user, Type.READ);
if (project == null) {
return;
}
- Flow flow = project.getFlow(flowId);
+ Flow flow = project.getFlow(exflow.getFlowId());
if (flow == null) {
- ret.put("error", "Error loading flow. Flow " + flowId + " doesn't exist in " + projectId);
+ ret.put("error", "Error loading flow. Flow " + exflow.getFlowId() + " doesn't exist in " + exflow.getProjectId());
return;
}
ret.put("successEmails", exflow.getSuccessEmails());
- ret.put("failureEmails", flow.getFailureEmails());
+ ret.put("failureEmails", exflow.getFailureEmails());
ret.put("flowParam", exflow.getFlowParameters());
FailureAction action = exflow.getFailureAction();
@@ -409,18 +427,17 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
ret.put("failureAction", failureAction);
ret.put("notifyFailureFirst", exflow.getNotifyOnFirstFailure());
ret.put("notifyFailureLast", exflow.getNotifyOnLastFailure());
- ret.put("running", executorManager.getFlowRunningFlows(projectId, flowId));
-
- ScheduledFlow sflow = null;
- for (ScheduledFlow schedFlow: scheduleManager.getSchedule()) {
- if (schedFlow.getProjectId().equals(projectId) && schedFlow.getFlowId().equals(flowId)) {
- sflow = schedFlow;
+
+ Schedule sflow = null;
+ for (Schedule sched: scheduleManager.getSchedules()) {
+ if (sched.getProjectId() == project.getId() && sched.getFlowName().equals(exflow.getFlowId())) {
+ sflow = sched;
break;
}
}
if (sflow != null) {
- ret.put("scheduled", sflow.getNextExecTime().getMillis());
+ ret.put("scheduled", sflow.getNextExecTime());
}
}
@@ -431,7 +448,7 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
}
try {
- executorManager.cancelFlow(exFlow.getExecutionId(), user.getUserId());
+ executorManager.cancelFlow(exFlow, user.getUserId());
} catch (ExecutorManagerException e) {
ret.put("error", e.getMessage());
}
@@ -443,7 +460,7 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
return;
}
- ret.put("running", executorManager.getFlowRunningFlows(projectId, flowId));
+ ret.put("running", executorManager.isFlowRunning(project.getId(), flowId));
}
private void ajaxRestartFlow(HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user, ExecutableFlow exFlow) throws ServletException{
@@ -460,7 +477,7 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
}
try {
- executorManager.pauseFlow(exFlow.getExecutionId(), user.getUserId());
+ executorManager.pauseFlow(exFlow, user.getUserId());
} catch (ExecutorManagerException e) {
ret.put("error", e.getMessage());
}
@@ -473,7 +490,7 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
}
try {
- executorManager.resumeFlow(exFlow.getExecutionId(), user.getUserId());
+ executorManager.resumeFlow(exFlow, user.getUserId());
} catch (ExecutorManagerException e) {
ret.put("resume", e.getMessage());
}
@@ -481,7 +498,6 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
private void ajaxFetchExecutableFlowUpdate(HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user, ExecutableFlow exFlow) throws ServletException{
Long lastUpdateTime = Long.parseLong(getParam(req, "lastUpdateTime"));
-
System.out.println("Fetching " + exFlow.getExecutionId());
Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.READ);
@@ -492,12 +508,12 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
// Just update the nodes and flow states
ArrayList<Map<String, Object>> nodeList = new ArrayList<Map<String, Object>>();
for (ExecutableNode node : exFlow.getExecutableNodes()) {
- if (node.getStartTime() < lastUpdateTime && node.getEndTime() < lastUpdateTime) {
+ if (node.getUpdateTime() <= lastUpdateTime) {
continue;
}
HashMap<String, Object> nodeObj = new HashMap<String,Object>();
- nodeObj.put("id", node.getId());
+ nodeObj.put("id", node.getJobId());
nodeObj.put("status", node.getStatus());
nodeObj.put("startTime", node.getStartTime());
nodeObj.put("endTime", node.getEndTime());
@@ -510,6 +526,7 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
ret.put("startTime", exFlow.getStartTime());
ret.put("endTime", exFlow.getEndTime());
ret.put("submitTime", exFlow.getSubmitTime());
+ ret.put("updateTime", exFlow.getUpdateTime());
}
private void ajaxFetchExecutableFlow(HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user, ExecutableFlow exFlow) throws ServletException {
@@ -524,7 +541,7 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
ArrayList<Map<String, Object>> edgeList = new ArrayList<Map<String,Object>>();
for (ExecutableNode node : exFlow.getExecutableNodes()) {
HashMap<String, Object> nodeObj = new HashMap<String,Object>();
- nodeObj.put("id", node.getId());
+ nodeObj.put("id", node.getJobId());
nodeObj.put("level", node.getLevel());
nodeObj.put("status", node.getStatus());
nodeObj.put("startTime", node.getStartTime());
@@ -535,7 +552,7 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
// Add edges
for (String out: node.getOutNodes()) {
HashMap<String, Object> edgeObj = new HashMap<String,Object>();
- edgeObj.put("from", node.getId());
+ edgeObj.put("from", node.getJobId());
edgeObj.put("target", out);
edgeList.add(edgeObj);
}
@@ -551,25 +568,25 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
}
private void ajaxExecuteFlow(HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user) throws ServletException {
- String projectId = getParam(req, "project");
+ String projectName = getParam(req, "project");
String flowId = getParam(req, "flow");
- ret.put("flow", flowId);
-
- Project project = getProjectAjaxByPermission(ret, projectId, user, Type.EXECUTE);
+ Project project = getProjectAjaxByPermission(ret, projectName, user, Type.EXECUTE);
if (project == null) {
+ ret.put("error", "Project '" + projectName + "' doesn't exist.");
return;
}
-
+
+ ret.put("flow", flowId);
Flow flow = project.getFlow(flowId);
if (flow == null) {
ret.put("error", "Flow '" + flowId + "' cannot be found in project " + project);
return;
}
- // Create ExecutableFlow
- ExecutableFlow exflow = executorManager.createExecutableFlow(flow);
+ ExecutableFlow exflow = new ExecutableFlow(flow);
exflow.setSubmitUser(user.getUserId());
+
if (hasParam(req, "failureAction")) {
String option = getParam(req, "failureAction");
if (option.equals("finishCurrent") ) {
@@ -582,6 +599,7 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
exflow.setFailureAction(FailureAction.FINISH_ALL_POSSIBLE);
}
}
+
if (hasParam(req, "failureEmails")) {
String emails = getParam(req, "failureEmails");
String[] emailSplit = emails.split("\\s*,\\s*|\\s*;\\s*|\\s+");
@@ -613,49 +631,41 @@ public class ExecutorServlet extends LoginAbstractAzkabanServlet {
exflow.setStatus(entry.getKey(), nodeDisabled ? Status.DISABLED : Status.READY);
}
- // Create directory
try {
- executorManager.setupExecutableFlow(exflow);
- } catch (ExecutorManagerException e) {
- try {
- executorManager.cleanupAll(exflow);
- } catch (ExecutorManagerException e1) {
- e1.printStackTrace();
- }
- ret.put("error", e.getMessage());
- return;
+ executorManager.submitExecutableFlow(exflow);
}
-
- // Copy files to the source.
- File executionDir = new File(exflow.getExecutionPath());
- try {
- projectManager.copyProjectSourceFilesToDirectory(project, executionDir);
- } catch (ProjectManagerException e) {
- try {
- executorManager.cleanupAll(exflow);
- } catch (ExecutorManagerException e1) {
- e1.printStackTrace();
- }
- ret.put("error", e.getMessage());
- return;
+ catch (ExecutorManagerException e) {
+ e.printStackTrace();
+ ret.put("error", "Error submitting flow " + exflow.getFlowId() + ". " + e.getMessage());
}
- try {
- executorManager.executeFlow(exflow);
- project.info("User '" + user.getUserId() + "' executed flow '" + exflow.getExecutionId() + "'");
- } catch (ExecutorManagerException e) {
- try {
- executorManager.cleanupAll(exflow);
- } catch (ExecutorManagerException e1) {
- e1.printStackTrace();
+ ret.put("execid", exflow.getExecutionId());
+ }
+
+ public class ExecutorVMHelper {
+ @SuppressWarnings("unused")
+ public String getProjectName(int id) {
+ Project project = projectManager.getProject(id);
+ if (project == null) {
+ return String.valueOf(id);
}
- ret.put("error", e.getMessage());
- return;
+ return project.getName();
}
-
- String execId = exflow.getExecutionId();
-
- ret.put("execid", execId);
+ }
+
+ private boolean hasPermission(Project project, User user, Permission.Type type) {
+ if (project.hasPermission(user, type)) {
+ return true;
+ }
+
+ for(String roleName: user.getRoles()) {
+ Role role = userManager.getRole(roleName);
+ if (role.getPermission().isPermissionSet(type)) {
+ return true;
+ }
+ }
+
+ return true;
}
}
src/java/azkaban/webapp/servlet/HdfsBrowserServlet.java 404(+188 -216)
diff --git a/src/java/azkaban/webapp/servlet/HdfsBrowserServlet.java b/src/java/azkaban/webapp/servlet/HdfsBrowserServlet.java
index d3194f3..ae74a1d 100644
--- a/src/java/azkaban/webapp/servlet/HdfsBrowserServlet.java
+++ b/src/java/azkaban/webapp/servlet/HdfsBrowserServlet.java
@@ -18,7 +18,7 @@ package azkaban.webapp.servlet;
import java.io.IOException;
import java.io.OutputStream;
-import java.security.PrivilegedAction;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -26,21 +26,21 @@ import java.util.Properties;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
+import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.security.AccessControlException;
-import org.apache.hadoop.security.UserGroupInformation;
import org.apache.log4j.Logger;
import azkaban.fsviewers.HdfsAvroFileViewer;
import azkaban.fsviewers.HdfsFileViewer;
import azkaban.fsviewers.JsonSequenceFileViewer;
import azkaban.fsviewers.TextFileViewer;
-import azkaban.utils.SecurityUtils;
+import azkaban.security.HadoopSecurityManager;
+import azkaban.webapp.AzkabanWebServer;
import azkaban.webapp.session.Session;
/**
@@ -50,35 +50,28 @@ import azkaban.webapp.session.Session;
public class HdfsBrowserServlet extends LoginAbstractAzkabanServlet {
private static final long serialVersionUID = 1L;
-
- private ArrayList<HdfsFileViewer> _viewers = new ArrayList<HdfsFileViewer>();
-
- // Default viewer will be a text viewer
- private HdfsFileViewer _defaultViewer = new TextFileViewer();
-
-
- private static Logger logger = Logger.getLogger(HdfsBrowserServlet.class);
+ private static final String SESSION_ID_NAME = "azkaban.hdfsbrowser.session.id";
+
+ private ArrayList<HdfsFileViewer> _viewers = new ArrayList<HdfsFileViewer>();
- private Configuration conf;
-
- private Properties property;
-
-// public HdfsBrowserServlet() {
-// super();
-// _viewers.add(new HdfsAvroFileViewer());
-// _viewers.add(new JsonSequenceFileViewer());
-// }
+ // Default viewer will be a text viewer
+ private HdfsFileViewer _defaultViewer = new TextFileViewer();
+
+ private static Logger logger = Logger.getLogger(HdfsBrowserServlet.class);
+
+ private Properties property;
+ private HadoopSecurityManager hadoopSecurityManager;
- @Override
+ @Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
_viewers.add(new HdfsAvroFileViewer());
_viewers.add(new JsonSequenceFileViewer());
- property = this.getApplication().getAzkabanProps().toProperties();
- conf = new Configuration();
+
+
// String hadoopHome = System.getenv("HADOOP_HOME");
// String hadoopConfDir = System.getenv("HADOOP_CONF_DIR");
@@ -106,210 +99,189 @@ public class HdfsBrowserServlet extends LoginAbstractAzkabanServlet {
// throw new ServletException("HADOOP_HOME or HADOOP_CONF_DIR is not valid!");
// }
+ AzkabanWebServer server = (AzkabanWebServer)getApplication();
+ hadoopSecurityManager = server.getHadoopSecurityManager();
+ property = server.getServerProps().toProperties();
- conf.setClassLoader(this.getApplication().getClassLoader());
+ logger.info("HDFS Browser initiated");
+ }
+
+
+ @Override
+ protected void handleGet(HttpServletRequest req, HttpServletResponse resp, Session session) throws ServletException, IOException {
+
+ //use default user or browseUser
+ String user = getBrowseUserFromRequest(req);
+
+ if (user == null) {
+ user = session.getUser().getUserId();
+ }
- logger.info("HDFS Browser init");
- logger.info("hadoop.security.authentication set to " + conf.get("hadoop.security.authentication"));
- logger.info("hadoop.security.authorization set to " + conf.get("hadoop.security.authorization"));
- logger.info("DFS name " + conf.get("fs.default.name"));
- }
-
-
-
- @Override
- protected void handleGet(HttpServletRequest req, HttpServletResponse resp, Session session) throws ServletException, IOException {
-
- String user = session.getUser().getUserId();
- UserGroupInformation ugi = null;
- try {
- ugi = SecurityUtils.getProxiedUser(user, this.property, logger, conf);
-
- FileSystem fs;
- if (ugi != null) {
- fs = ugi.doAs(new PrivilegedAction<FileSystem>(){
-
- @Override
- public FileSystem run() {
- try {
- return FileSystem.get(conf);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }});
- }
- else {
- fs = FileSystem.get(conf);
- }
-
- try {
- handleFSDisplay(fs, user, req, resp, session);
- } catch (IOException e) {
- fs.close();
- throw e;
- }
- fs.close();
- }
- catch (Exception e) {
- Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/hdfsbrowserpage.vm");
- page.add("error_message", e.getMessage());
- page.add("no_fs", "true");
- page.render();
- }
+ try {
+ FileSystem fs = hadoopSecurityManager.getFSAsUser(user);
+ try {
+ handleFSDisplay(fs, user, req, resp, session);
+ } catch (IOException e) {
+ fs.close();
+ throw e;
+ } finally {
+ fs.close();
+ }
+ }
+ catch (Exception e) {
+ Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/hdfsbrowserpage.vm");
+ page.add("error_message", "Error: " + e.getMessage());
+ page.add("no_fs", "true");
+ page.render();
+ }
}
-// private void setCookieInResponse(HttpServletResponse resp, String key, String value) {
-// if (value == null) {
-// Cookie cookie = new Cookie(key, "");
-// cookie.setMaxAge(0);
-// resp.addCookie(cookie);
-// }
-// else {
-// Cookie cookie = new Cookie(key, value);
-// resp.addCookie(cookie);
-// }
-// }
+ private void setCookieInResponse(HttpServletResponse resp, String key, String value, Session session) {
+ if (value == null) {
+ Cookie cookie = new Cookie(key, "");
+ cookie.setMaxAge(0);
+ cookie.setPath("/");
+ resp.addCookie(cookie);
+ }
+ else {
+ Cookie cookie = new Cookie(key, value);
+ cookie.setPath("/");
+ resp.addCookie(cookie);
+ getApplication().getSessionCache().addSession(session);
+ }
+ }
-// private String getUserFromRequest(HttpServletRequest req) {
-// Cookie cookie = getCookieByName(req, SESSION_ID_NAME);
-// if (cookie == null) {
-// return null;
-// }
-// return cookie.getValue();
-// }
-
-// @Override
-// protected void handlePost(HttpServletRequest req, HttpServletResponse resp, Session session)
-// throws ServletException, IOException {
-// if (hasParam(req, "logout")) {
-// setCookieInResponse(resp, SESSION_ID_NAME, null);
-// Page page = newPage(req, resp, "azkaban/web/pages/hdfs_browser_login.vm");
-// page.render();
-// } else if(hasParam(req, "login")) {
-// Props prop = this.getApplication().getAzkabanProps();
-// Properties property = prop.toProperties();
-//
-// String user = getParam(req, "login");
-// logger.info("hadoop.security.authentication set to " + conf.get("hadoop.security.authentication"));
-// logger.info("hadoop.security.authorization set to " + conf.get("hadoop.security.authorization"));
-//
-// UserGroupInformation ugi = SecurityUtils.getProxiedUser(user, property, logger, conf);
-// logger.info("Logging in as " + user);
-// FileSystem fs = ugi.doAs(new PrivilegedAction<FileSystem>(){
-// @Override
-// public FileSystem run() {
-// try {
-// return FileSystem.get(conf);
-// } catch (IOException e) {
-// throw new RuntimeException(e);
-// }
-// }});
-//
-// setCookieInResponse(resp, SESSION_ID_NAME, user);
-// try {
-// handleFSDisplay(fs, user, req, resp);
-// } catch (IOException e) {
-// throw e;
-// }
-// finally {
-// fs.close();
-// }
-// }
-// }
-
- private void handleFSDisplay(FileSystem fs, String user, HttpServletRequest req, HttpServletResponse resp, Session session) throws IOException {
- String prefix = req.getContextPath() + req.getServletPath();
- String fsPath = req.getRequestURI().substring(prefix.length());
- if(fsPath.length() == 0)
- fsPath = "/";
-
- if(logger.isDebugEnabled())
- logger.debug("path=" + fsPath);
-
- Path path = new Path(fsPath);
- if(!fs.exists(path)) {
- throw new IllegalArgumentException(path.toUri().getPath() + " does not exist.");
- }
- else if(fs.isFile(path)) {
- displayFile(fs, req, resp, session, path);
- }
- else if(fs.getFileStatus(path).isDir()) {
- displayDir(fs, user, req, resp, session, path);
- } else {
- throw new IllegalStateException("It exists, it is not a file, and it is not a directory, what is it precious?");
- }
- }
-
- private void displayDir(FileSystem fs, String user, HttpServletRequest req, HttpServletResponse resp, Session session, Path path)
- throws IOException {
-
- Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/hdfsbrowserpage.vm");
-
- List<Path> paths = new ArrayList<Path>();
- List<String> segments = new ArrayList<String>();
- Path curr = path;
- while(curr.getParent() != null) {
- paths.add(curr);
- segments.add(curr.getName());
- curr = curr.getParent();
- }
-
- Collections.reverse(paths);
- Collections.reverse(segments);
-
- page.add("paths", paths);
- page.add("segments", segments);
-
- try {
- page.add("subdirs", fs.listStatus(path)); // ??? line
- }
- catch (AccessControlException e) {
- page.add("error_message", "Permission denied. User cannot read file or directory");
- }
- catch (IOException e) {
- page.add("error_message", e.getMessage());
- }
- page.render();
-
- }
-
- private void displayFile(FileSystem fs, HttpServletRequest req, HttpServletResponse resp, Session session, Path path)
- throws IOException {
- int startLine = getIntParam(req, "start_line", 1);
- int endLine = getIntParam(req, "end_line", 1000);
-
- // use registered viewers to show the file content
- boolean outputed = false;
- OutputStream output = resp.getOutputStream();
- for(HdfsFileViewer viewer: _viewers) {
- if(viewer.canReadFile(fs, path)) {
- viewer.displayFile(fs, path, output, startLine, endLine);
- outputed = true;
- break; // don't need to try other viewers
- }
- }
-
- // use default text viewer
- if(!outputed) {
- if(_defaultViewer.canReadFile(fs, path)) {
- _defaultViewer.displayFile(fs, path, output, startLine, endLine);
- } else {
- output.write(("Sorry, no viewer available for this file. ").getBytes("UTF-8"));
- }
- }
- }
+ private String getBrowseUserFromRequest(HttpServletRequest req) {
+ Cookie cookie = getCookieByName(req, SESSION_ID_NAME);
+ if (cookie == null) {
+ return null;
+ }
+ return cookie.getValue();
+ }
@Override
- protected void handlePost(HttpServletRequest req, HttpServletResponse resp,
- Session session) throws ServletException, IOException {
- // TODO Auto-generated method stub
-
+ protected void handlePost(HttpServletRequest req, HttpServletResponse resp, Session session)
+ throws ServletException, IOException {
+ if (hasParam(req, "logout")) {
+ setCookieInResponse(resp, SESSION_ID_NAME, null, session);
+ Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/hdfsbrowserlogin.vm");
+ page.render();
+ } else if(hasParam(req, "login")) {
+// Props prop = this.getApplication().getAzkabanProps();
+// Properties property = prop.toProperties();
+
+ String user = session.getUser().getUserId();
+
+ String browseUser = getParam(req, "login");
+ logger.info("Browsing user set to " + browseUser + " by " + user);
+
+
+ try {
+ FileSystem fs = hadoopSecurityManager.getFSAsUser(user);
+
+ setCookieInResponse(resp, SESSION_ID_NAME, browseUser, session);
+
+ try{
+ handleFSDisplay(fs, browseUser, req, resp, session);
+ } catch (IOException e) {
+ fs.close();
+ throw e;
+ } finally {
+ fs.close();
+ }
+
+ } catch (Exception e) {
+ Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/hdfsbrowserpage.vm");
+ page.add("error_message", "Error: " + e.getMessage());
+ page.add("no_fs", "true");
+ page.render();
+ }
+
+ }
}
+ private void handleFSDisplay(FileSystem fs, String user, HttpServletRequest req, HttpServletResponse resp, Session session) throws IOException {
+ String prefix = req.getContextPath() + req.getServletPath();
+ String fsPath = req.getRequestURI().substring(prefix.length());
+ if(fsPath.length() == 0)
+ fsPath = "/";
+
+ if(logger.isDebugEnabled())
+ logger.debug("path=" + fsPath);
+
+ Path path = new Path(fsPath);
+ if(!fs.exists(path)) {
+ throw new IllegalArgumentException(path.toUri().getPath() + " does not exist.");
+ }
+ else if(fs.isFile(path)) {
+ displayFile(fs, req, resp, session, path);
+ }
+ else if(fs.getFileStatus(path).isDir()) {
+ displayDir(fs, user, req, resp, session, path);
+ } else {
+ throw new IllegalStateException("It exists, it is not a file, and it is not a directory, what is it precious?");
+ }
+ }
+ private void displayDir(FileSystem fs, String user, HttpServletRequest req, HttpServletResponse resp, Session session, Path path)
+ throws IOException {
+
+ Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/hdfsbrowserpage.vm");
+
+ List<Path> paths = new ArrayList<Path>();
+ List<String> segments = new ArrayList<String>();
+ Path curr = path;
+ while(curr.getParent() != null) {
+ paths.add(curr);
+ segments.add(curr.getName());
+ curr = curr.getParent();
+ }
+
+ Collections.reverse(paths);
+ Collections.reverse(segments);
+
+ page.add("paths", paths);
+ page.add("segments", segments);
+ page.add("user", user);
+
+ try {
+ page.add("subdirs", fs.listStatus(path)); // ??? line
+ }
+ catch (AccessControlException e) {
+ page.add("error_message", "Permission denied. User cannot read file or directory");
+ }
+ catch (IOException e) {
+ page.add("error_message", "Error: " + e.getMessage());
+ }
+ page.render();
+ }
-
+ private void displayFile(FileSystem fs, HttpServletRequest req, HttpServletResponse resp, Session session, Path path)
+ throws IOException {
+ int startLine = getIntParam(req, "start_line", 1);
+ int endLine = getIntParam(req, "end_line", 1000);
+
+ // use registered viewers to show the file content
+ boolean outputed = false;
+ OutputStream output = resp.getOutputStream();
+ for(HdfsFileViewer viewer: _viewers) {
+ if(viewer.canReadFile(fs, path)) {
+ viewer.displayFile(fs, path, output, startLine, endLine);
+ outputed = true;
+ break; // don't need to try other viewers
+ }
+ }
+
+ // use default text viewer
+ if(!outputed) {
+ if(_defaultViewer.canReadFile(fs, path)) {
+ _defaultViewer.displayFile(fs, path, output, startLine, endLine);
+ } else {
+ output.write(("Sorry, no viewer available for this file. ").getBytes("UTF-8"));
+ }
+ }
+ }
}
src/java/azkaban/webapp/servlet/HistoryServlet.java 219(+137 -82)
diff --git a/src/java/azkaban/webapp/servlet/HistoryServlet.java b/src/java/azkaban/webapp/servlet/HistoryServlet.java
index 8ed0697..9fa9ed3 100644
--- a/src/java/azkaban/webapp/servlet/HistoryServlet.java
+++ b/src/java/azkaban/webapp/servlet/HistoryServlet.java
@@ -33,20 +33,29 @@ import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
+import azkaban.executor.ExecutableFlow;
import azkaban.executor.ExecutorManager;
-import azkaban.executor.ExecutorManager.ExecutionReference;
+import azkaban.executor.ExecutorManagerException;
+import azkaban.project.Project;
+import azkaban.project.ProjectManager;
import azkaban.utils.JSONUtils;
+import azkaban.webapp.AzkabanWebServer;
import azkaban.webapp.session.Session;
public class HistoryServlet extends LoginAbstractAzkabanServlet {
private static final long serialVersionUID = 1L;
private ExecutorManager executorManager;
+ private ProjectManager projectManager;
+ private ExecutorVMHelper vmHelper;
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
- executorManager = this.getApplication().getExecutorManager();
+ AzkabanWebServer server = (AzkabanWebServer)getApplication();
+ executorManager = server.getExecutorManager();
+ projectManager = server.getProjectManager();
+ vmHelper = new ExecutorVMHelper();
}
@Override
@@ -81,64 +90,98 @@ public class HistoryServlet extends LoginAbstractAzkabanServlet {
}
private void fetchHistoryData(HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret) throws ServletException {
- long start = getLongParam(req, "start");
- long end = getLongParam(req, "end");
-
- ret.put("start", start);
- ret.put("end", end);
-
- List<ExecutionReference> refs = executorManager.getFlowHistory(start, end);
- ArrayList<Object> refList = new ArrayList<Object>();
- for (ExecutionReference ref: refs) {
-
- HashMap<String,Object> refObj = new HashMap<String,Object>();
- refObj.put("execId", ref.getExecId());
- refObj.put("start", ref.getStartTime());
- refObj.put("end", ref.getEndTime());
- refObj.put("status", ref.getStatus().toString());
-
- refList.add(refObj);
- }
-
- ret.put("data", refList);
+// long start = getLongParam(req, "start");
+// long end = getLongParam(req, "end");
+//
+// ret.put("start", start);
+// ret.put("end", end);
+//
+// List<ExecutionReference> refs = executorManager.getFlowHistory(start, end);
+// ArrayList<Object> refList = new ArrayList<Object>();
+// for (ExecutionReference ref: refs) {
+//
+// HashMap<String,Object> refObj = new HashMap<String,Object>();
+// refObj.put("execId", ref.getExecId());
+// refObj.put("start", ref.getStartTime());
+// refObj.put("end", ref.getEndTime());
+// refObj.put("status", ref.getStatus().toString());
+//
+// refList.add(refObj);
+// }
+//
+// ret.put("data", refList);
}
private void handleHistoryPage(HttpServletRequest req, HttpServletResponse resp, Session session) throws ServletException {
Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/historypage.vm");
int pageNum = getIntParam(req, "page", 1);
int pageSize = getIntParam(req, "size", 16);
-
+ page.add("vmutils", vmHelper);
if (pageNum < 0) {
pageNum = 1;
}
- List<ExecutionReference> history = null;
+ List<ExecutableFlow> history = null;
if(hasParam(req, "advfilter")) {
- String projRe = getParam(req, "projre").equals("") ? ".*" : getParam(req, "projre");
- String flowRe = getParam(req, "flowre").equals("") ? ".*" : getParam(req, "flowre");
- String userRe = getParam(req, "userre").equals("") ? ".*" : getParam(req, "userre");
- long beginTime = getParam(req, "begin").equals("") ? 0 : DateTimeFormat.forPattern("MM/dd/yyyy").parseDateTime(getParam(req, "begin")).getMillis();
- long endTime = getParam(req, "end").equals("") ? DateTime.now().getMillis() : DateTimeFormat.forPattern("MM/dd/yyyy").parseDateTime(getParam(req, "end")).getMillis();
- history = executorManager.getFlowHistory(projRe, flowRe, userRe, beginTime, endTime, pageSize, (pageNum - 1)*pageSize, true);
+ String projContain = getParam(req, "projcontain") == "" ? null : getParam(req, "projcontain");
+ String flowContain = getParam(req, "flowcontain") == "" ? null : getParam(req, "flowcontain");
+ String userContain = getParam(req, "usercontain") == "" ? null : getParam(req, "usercontain");
+ int status = getIntParam(req, "status") == 0 ? 0 : getIntParam(req, "status");
+ String begin = getParam(req, "begin");
+ long beginTime = begin == "" ? -1 : DateTimeFormat.forPattern("MM/dd/yyyy-HH:mm").parseDateTime(begin).getMillis();
+ String end = getParam(req, "end");
+ long endTime = end == "" ? -1 : DateTimeFormat.forPattern("MM/dd/yyyy-HH:mm").parseDateTime(end).getMillis();
+ try {
+ history = executorManager.getExecutableFlows(projContain, flowContain, userContain, status, beginTime, endTime, (pageNum - 1)*pageSize, pageSize);
+ } catch (ExecutorManagerException e) {
+ // TODO Auto-generated catch block
+ page.add("error", e.getMessage());
+ }
}
else if(hasParam(req, "search")) {
String searchTerm = getParam(req, "searchterm");
- if(!searchTerm.equals("") && !searchTerm.equals(".*")) {
- history = executorManager.getFlowHistory(".*", searchTerm, ".*", 0, DateTime.now().getMillis(), pageSize, (pageNum - 1)*pageSize, true);
- page.add("search_term", searchTerm);
- }
-
+ try {
+ history = executorManager.getExecutableFlows(searchTerm, (pageNum - 1)*pageSize, pageSize);
+ } catch (ExecutorManagerException e) {
+ // TODO Auto-generated catch block
+ page.add("error", e.getMessage());
+ }
}
else {
- history = executorManager.getFlowHistory("", "", "", 0, 0, pageSize, (pageNum - 1)*pageSize, false);
+ try {
+ history = executorManager.getExecutableFlows((pageNum - 1)*pageSize, pageSize);
+ } catch (ExecutorManagerException e) {
+ e.printStackTrace();
+ }
}
page.add("flowHistory", history);
page.add("size", pageSize);
page.add("page", pageNum);
+ //keep the search terms so that we can navigate to later pages
+ if(hasParam(req, "searchterm") && !getParam(req, "searchterm").equals("")) {
+ page.add("search", "true");
+ page.add("search_term", getParam(req, "searchterm"));
+ }
+
+ if(hasParam(req, "advfilter")) {
+ page.add("advfilter", "true");
+ page.add("projcontain", getParam(req, "projcontain"));
+ page.add("flowcontain", getParam(req, "flowcontain"));
+ page.add("usercontain", getParam(req, "usercontain"));
+ page.add("status", getIntParam(req, "status"));
+ page.add("begin", getParam(req, "begin"));
+ page.add("end", getParam(req, "end"));
+ }
+// else {
+// page.add("search_term", "");
+// }
if (pageNum == 1) {
page.add("previous", new PageSelection(1, pageSize, true, false));
}
+ else {
+ page.add("previous", new PageSelection(pageNum-1, pageSize, false, false));
+ }
page.add("next", new PageSelection(pageNum + 1, pageSize, false, false));
// Now for the 5 other values.
int pageStartValue = 1;
@@ -161,55 +204,55 @@ public class HistoryServlet extends LoginAbstractAzkabanServlet {
}
private void handleHistoryTimelinePage(HttpServletRequest req, HttpServletResponse resp, Session session) {
- Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/historytimelinepage.vm");
- long currentTime = System.currentTimeMillis();
- long begin = getLongParam(req, "begin", currentTime - 86400000);
- long end = getLongParam(req, "end", currentTime);
-
- page.add("begin", begin);
- page.add("end", end);
-
- List<ExecutionReference> refs = executorManager.getFlowHistory(begin, end);
- ArrayList<Object> refList = new ArrayList<Object>();
- for (ExecutionReference ref: refs) {
-
- HashMap<String,Object> refObj = new HashMap<String,Object>();
- refObj.put("execId", ref.getExecId());
- refObj.put("start", ref.getStartTime());
- refObj.put("end", ref.getEndTime());
- refObj.put("status", ref.getStatus().toString());
-
- refList.add(refObj);
- }
-
- page.add("data", JSONUtils.toJSON(refList));
- page.render();
+// Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/historytimelinepage.vm");
+// long currentTime = System.currentTimeMillis();
+// long begin = getLongParam(req, "begin", currentTime - 86400000);
+// long end = getLongParam(req, "end", currentTime);
+//
+// page.add("begin", begin);
+// page.add("end", end);
+//
+// List<ExecutionReference> refs = executorManager.getFlowHistory(begin, end);
+// ArrayList<Object> refList = new ArrayList<Object>();
+// for (ExecutionReference ref: refs) {
+//
+// HashMap<String,Object> refObj = new HashMap<String,Object>();
+// refObj.put("execId", ref.getExecId());
+// refObj.put("start", ref.getStartTime());
+// refObj.put("end", ref.getEndTime());
+// refObj.put("status", ref.getStatus().toString());
+//
+// refList.add(refObj);
+// }
+//
+// page.add("data", JSONUtils.toJSON(refList));
+// page.render();
}
private void handleHistoryDayPage(HttpServletRequest req, HttpServletResponse resp, Session session) {
- Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/historydaypage.vm");
- long currentTime = System.currentTimeMillis();
- long begin = getLongParam(req, "begin", currentTime - 86400000);
- long end = getLongParam(req, "end", currentTime);
-
- page.add("begin", begin);
- page.add("end", end);
-
- List<ExecutionReference> refs = executorManager.getFlowHistory(begin, end);
- ArrayList<Object> refList = new ArrayList<Object>();
- for (ExecutionReference ref: refs) {
-
- HashMap<String,Object> refObj = new HashMap<String,Object>();
- refObj.put("execId", ref.getExecId());
- refObj.put("start", ref.getStartTime());
- refObj.put("end", ref.getEndTime());
- refObj.put("status", ref.getStatus().toString());
-
- refList.add(refObj);
- }
-
- page.add("data", JSONUtils.toJSON(refList));
- page.render();
+// Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/historydaypage.vm");
+// long currentTime = System.currentTimeMillis();
+// long begin = getLongParam(req, "begin", currentTime - 86400000);
+// long end = getLongParam(req, "end", currentTime);
+//
+// page.add("begin", begin);
+// page.add("end", end);
+//
+// List<ExecutionReference> refs = executorManager.getFlowHistory(begin, end);
+// ArrayList<Object> refList = new ArrayList<Object>();
+// for (ExecutionReference ref: refs) {
+//
+// HashMap<String,Object> refObj = new HashMap<String,Object>();
+// refObj.put("execId", ref.getExecId());
+// refObj.put("start", ref.getStartTime());
+// refObj.put("end", ref.getEndTime());
+// refObj.put("status", ref.getStatus().toString());
+//
+// refList.add(refObj);
+// }
+//
+// page.add("data", JSONUtils.toJSON(refList));
+// page.render();
}
public class PageSelection {
@@ -252,4 +295,16 @@ public class HistoryServlet extends LoginAbstractAzkabanServlet {
// TODO Auto-generated method stub
}
+
+ public class ExecutorVMHelper {
+ @SuppressWarnings("unused")
+ public String getProjectName(int id) {
+ Project project = projectManager.getProject(id);
+ if (project == null) {
+ return String.valueOf(id);
+ }
+
+ return project.getName();
+ }
+ }
}
diff --git a/src/java/azkaban/webapp/servlet/IndexServlet.java b/src/java/azkaban/webapp/servlet/IndexServlet.java
index 1d0aea5..895e766 100644
--- a/src/java/azkaban/webapp/servlet/IndexServlet.java
+++ b/src/java/azkaban/webapp/servlet/IndexServlet.java
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletResponse;
import azkaban.project.Project;
import azkaban.project.ProjectManager;
import azkaban.user.User;
+import azkaban.webapp.AzkabanWebServer;
import azkaban.webapp.session.Session;
/**
@@ -55,11 +56,11 @@ public class IndexServlet extends LoginAbstractAzkabanServlet {
User user = session.getUser();
- ProjectManager manager = this.getApplication().getProjectManager();
+ ProjectManager manager = ((AzkabanWebServer)getApplication()).getProjectManager();
Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/index.vm");
if (hasParam(req, "all")) {
List<Project> projects = manager.getProjects();
- page.add("allProjects", "");
+ page.add("allProjects", "true");
page.add("projects", projects);
}
else {
@@ -72,17 +73,17 @@ public class IndexServlet extends LoginAbstractAzkabanServlet {
private void handleFilter(HttpServletRequest req, HttpServletResponse resp, Session session, String searchTerm) {
User user = session.getUser();
- ProjectManager manager = this.getApplication().getProjectManager();
+ ProjectManager manager = ((AzkabanWebServer)getApplication()).getProjectManager();
Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/index.vm");
if (hasParam(req, "all")) {
//do nothing special if one asks for 'ALL' projects
- List<Project> projects = manager.getProjectsByRe(searchTerm);
+ List<Project> projects = manager.getProjectsByRegex(searchTerm);
page.add("allProjects", "");
page.add("projects", projects);
page.add("search_term", searchTerm);
}
else {
- List<Project> projects = manager.getUserProjectsByRe(user, searchTerm);
+ List<Project> projects = manager.getUserProjectsByRegex(user, searchTerm);
page.add("projects", projects);
page.add("search_term", searchTerm);
}
diff --git a/src/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java b/src/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
index 54dc366..5455044 100644
--- a/src/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
+++ b/src/java/azkaban/webapp/servlet/LoginAbstractAzkabanServlet.java
@@ -19,6 +19,7 @@ package azkaban.webapp.servlet;
import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
+import java.util.Map;
import java.util.UUID;
import javax.servlet.ServletException;
@@ -55,16 +56,6 @@ public abstract class LoginAbstractAzkabanServlet extends AbstractAzkabanServlet
}
return;
}
- else if (hasParam(req, "action")) {
- String action = getParam(req, "action");
- if (action.equals("login")) {
- handleLoginAction(req, resp);
- }
-
- String referer = req.getHeader("Referer");
- resp.sendRedirect(referer);
- return;
- }
if (session != null) {
logger.info("Found session " + session.getUser());
@@ -80,8 +71,9 @@ public abstract class LoginAbstractAzkabanServlet extends AbstractAzkabanServlet
}
}
}
-
+
private Session getSessionFromRequest(HttpServletRequest req) {
+ String remoteIp = req.getRemoteAddr();
Cookie cookie = getCookieByName(req, SESSION_ID_NAME);
String sessionId = null;
@@ -92,7 +84,13 @@ public abstract class LoginAbstractAzkabanServlet extends AbstractAzkabanServlet
if (sessionId == null) {
return null;
} else {
- return getApplication().getSessionCache().getSession(sessionId);
+ Session session = getApplication().getSessionCache().getSession(sessionId);
+ // Check if the IP's are equal. If not, we invalidate the sesson.
+ if (session == null || !remoteIp.equals(session.getIp())) {
+ return null;
+ }
+
+ return session;
}
}
@@ -101,8 +99,7 @@ public abstract class LoginAbstractAzkabanServlet extends AbstractAzkabanServlet
}
private void handleLogin(HttpServletRequest req, HttpServletResponse resp, String errorMsg) throws ServletException, IOException {
- Page page = newPage(req, resp,
- "azkaban/webapp/servlet/velocity/login.vm");
+ Page page = newPage(req, resp,"azkaban/webapp/servlet/velocity/login.vm");
if (errorMsg != null) {
page.add("errorMsg", errorMsg);
}
@@ -115,7 +112,9 @@ public abstract class LoginAbstractAzkabanServlet extends AbstractAzkabanServlet
if (hasParam(req, "action")) {
String action = getParam(req, "action");
if (action.equals("login")) {
- handleLoginAction(req, resp);
+ HashMap<String,Object> obj = new HashMap<String,Object>();
+ handleAjaxLoginAction(req, resp, obj);
+ this.writeJSON(resp, obj);
}
else {
Session session = getSessionFromRequest(req);
@@ -150,7 +149,7 @@ public abstract class LoginAbstractAzkabanServlet extends AbstractAzkabanServlet
}
}
- protected void handleLoginAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ protected void handleAjaxLoginAction(HttpServletRequest req, HttpServletResponse resp, Map<String, Object> ret) throws ServletException {
if (hasParam(req, "username") && hasParam(req, "password")) {
String username = getParam(req, "username");
String password = getParam(req, "password");
@@ -162,26 +161,21 @@ public abstract class LoginAbstractAzkabanServlet extends AbstractAzkabanServlet
user = manager.getUser(username, password);
}
catch (UserManagerException e) {
- handleLogin(req, resp, e.getMessage());
+ ret.put("error", "Incorrect Login. " + e.getCause());
return;
}
+ String ip = req.getRemoteAddr();
String randomUID = UUID.randomUUID().toString();
- Session session = new Session(randomUID, user);
+ Session session = new Session(randomUID, user, ip);
Cookie cookie = new Cookie(SESSION_ID_NAME, randomUID);
cookie.setPath("/");
resp.addCookie(cookie);
getApplication().getSessionCache().addSession(session);
- handleGet(req, resp, session);
+ ret.put("status", "success");
}
else {
- if (isAjaxCall(req)) {
- String response = createJsonResponse("error", "Incorrect Login.", "login", null);
- writeResponse(resp, response);
- }
- else {
- handleLogin(req, resp, "Enter username and password");
- }
+ ret.put("error", "Incorrect Login.");
}
}
src/java/azkaban/webapp/servlet/ProjectManagerServlet.java 417(+236 -181)
diff --git a/src/java/azkaban/webapp/servlet/ProjectManagerServlet.java b/src/java/azkaban/webapp/servlet/ProjectManagerServlet.java
index 9700df6..dcefce6 100644
--- a/src/java/azkaban/webapp/servlet/ProjectManagerServlet.java
+++ b/src/java/azkaban/webapp/servlet/ProjectManagerServlet.java
@@ -21,7 +21,6 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import java.io.PrintWriter;
import java.io.Writer;
import java.security.AccessControlException;
import java.util.ArrayList;
@@ -32,8 +31,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.zip.ZipFile;
-
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -47,21 +44,21 @@ import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import azkaban.executor.ExecutableFlow;
-import azkaban.executor.ExecutableFlow.Status;
-import azkaban.executor.ExecutableNode;
+import azkaban.executor.ExecutableJobInfo;
import azkaban.executor.ExecutorManager;
import azkaban.executor.ExecutorManagerException;
-import azkaban.executor.NodeStatus;
import azkaban.flow.Edge;
import azkaban.flow.Flow;
import azkaban.flow.FlowProps;
import azkaban.flow.Node;
import azkaban.project.Project;
+import azkaban.project.ProjectLogEvent;
import azkaban.project.ProjectManager;
import azkaban.project.ProjectManagerException;
+import azkaban.scheduler.Schedule;
import azkaban.scheduler.ScheduleManager;
-import azkaban.scheduler.ScheduledFlow;
import azkaban.user.Permission;
+import azkaban.user.Role;
import azkaban.user.UserManager;
import azkaban.user.Permission.Type;
import azkaban.user.User;
@@ -69,9 +66,9 @@ import azkaban.utils.JSONUtils;
import azkaban.utils.Pair;
import azkaban.utils.Props;
import azkaban.utils.Utils;
+import azkaban.webapp.AzkabanWebServer;
import azkaban.webapp.session.Session;
import azkaban.webapp.servlet.MultipartParser;
-import azkaban.webapp.servlet.HistoryServlet.PageSelection;
public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
private static final long serialVersionUID = 1;
@@ -82,8 +79,10 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
private ProjectManager projectManager;
private ExecutorManager executorManager;
private ScheduleManager scheduleManager;
+ private UserManager userManager;
+
private MultipartParser multipartParser;
- private File tempDir;
+
private static Comparator<Flow> FLOW_ID_COMPARATOR = new Comparator<Flow>() {
@Override
public int compare(Flow f1, Flow f2) {
@@ -94,11 +93,13 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
- projectManager = this.getApplication().getProjectManager();
- executorManager = this.getApplication().getExecutorManager();
- scheduleManager = this.getApplication().getScheduleManager();
- tempDir = this.getApplication().getTempDirectory();
+ AzkabanWebServer server = (AzkabanWebServer)getApplication();
+ projectManager = server.getProjectManager();
+ executorManager = server.getExecutorManager();
+ scheduleManager = server.getScheduleManager();
+ userManager = server.getUserManager();
+
multipartParser = new MultipartParser(DEFAULT_UPLOAD_DISK_SPOOL_SIZE);
}
@@ -176,10 +177,12 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
return;
}
+ ret.put("projectId", project.getId());
String ajaxName = getParam(req, "ajax");
if (ajaxName.equals("fetchProjectLogs")) {
- ajaxFetchProjectLogs(project, req, resp, ret, user);
- ret = null;
+ if (handleAjaxPermission(project, user, Type.READ, ret)) {
+ ajaxFetchProjectLogEvents(project, req, resp, ret, user);
+ }
}
else if (ajaxName.equals("fetchflowjobs")) {
if (handleAjaxPermission(project, user, Type.READ, ret)) {
@@ -206,14 +209,14 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
ajaxGetPermissions(project, ret);
}
}
- else if (ajaxName.equals("changeUserPermission")) {
+ else if (ajaxName.equals("changePermission")) {
if (handleAjaxPermission(project, user, Type.ADMIN, ret)) {
ajaxChangePermissions(project, ret, req, user);
}
}
- else if (ajaxName.equals("addUserPermission")) {
+ else if (ajaxName.equals("addPermission")) {
if (handleAjaxPermission(project, user, Type.ADMIN, ret)) {
- ajaxAddUserPermission(project, ret, req, user);
+ ajaxAddPermission(project, ret, req, user);
}
}
else if (ajaxName.equals("fetchFlowExecutions")) {
@@ -231,7 +234,7 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
}
private boolean handleAjaxPermission(Project project, User user, Type type, Map<String, Object> ret) {
- if (project.hasPermission(user, type)) {
+ if (hasPermission(project,user,type)) {
return true;
}
@@ -239,39 +242,37 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
return false;
}
- /**
- * Gets the logs through plain text stream to reduce memory overhead.
- *
- * @param req
- * @param resp
- * @param user
- * @param exFlow
- * @throws ServletException
- */
- private void ajaxFetchProjectLogs(Project project, HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user) throws ServletException {
- if (!project.hasPermission(user, Type.READ)) {
+ private void ajaxFetchProjectLogEvents(Project project, HttpServletRequest req, HttpServletResponse resp, HashMap<String, Object> ret, User user) throws ServletException {
+ if (!hasPermission(project,user,Type.READ)) {
+ ret.put("error", "Permission denied. Need READ access.");
return;
}
- int tailBytes = this.getIntParam(req, "tail");
+ int num = this.getIntParam(req, "size", 1000);
+ int skip = this.getIntParam(req, "skip", 0);
- resp.setContentType("text/plain");
- resp.setCharacterEncoding("utf-8");
- PrintWriter writer;
+ List<ProjectLogEvent> logEvents = null;
try {
- writer = resp.getWriter();
- } catch (IOException e) {
- throw new ServletException(e);
- }
-
- try {
- projectManager.getProjectLogs(project.getName(), tailBytes, 0, writer);
- } catch (IOException e) {
+ logEvents = projectManager.getProjectEventLogs(project, num, skip);
+ } catch (ProjectManagerException e) {
throw new ServletException(e);
}
- finally {
- writer.close();
+
+ String[] columns = new String[] {"user", "time", "type", "message"};
+ ret.put("columns", columns);
+
+ List<Object[]> eventData = new ArrayList<Object[]>();
+ for (ProjectLogEvent events: logEvents) {
+ Object[] entry = new Object[4];
+ entry[0] = events.getUser();
+ entry[1] = events.getTime();
+ entry[2] = events.getType();
+ entry[3] = events.getMessage();
+
+ eventData.add(entry);
}
+
+ ret.put("logData", eventData);
}
private void ajaxFetchFlowExecutions(Project project, HashMap<String, Object> ret, HttpServletRequest req) throws ServletException {
@@ -280,7 +281,12 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
int length = Integer.valueOf(getParam(req, "length"));
ArrayList<ExecutableFlow> exFlows = new ArrayList<ExecutableFlow>();
- int total = executorManager.getExecutableFlows(project.getName(), flowId, from, length, exFlows);
+ int total = 0;
+ try {
+ total = executorManager.getExecutableFlows(project.getId(), flowId, from, length, exFlows);
+ } catch (ExecutorManagerException e) {
+ ret.put("error", "Error retrieving executable flows");
+ }
ret.put("flow", flowId);
ret.put("total", total);
@@ -316,22 +322,24 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
return;
}
- if (!project.hasPermission(user, Type.ADMIN)) {
+ if (!hasPermission(project,user,Type.ADMIN)) {
this.setErrorMessageInCookie(resp, "Cannot delete. User '" + user.getUserId() + "' is not an ADMIN.");
resp.sendRedirect(req.getRequestURI() + "?project=" + projectName);
return;
}
// Check if scheduled
- ScheduledFlow sflow = null;
- for (ScheduledFlow flow: scheduleManager.getSchedule()) {
- if (flow.getProjectId().equals(projectName)) {
+ Schedule sflow = null;
+ for (Schedule flow: scheduleManager.getSchedules()) {
+
+ if (flow.getProjectId() == project.getId()) {
sflow = flow;
break;
}
}
if (sflow != null) {
- this.setErrorMessageInCookie(resp, "Cannot delete. Please unschedule " + sflow.getScheduleId() + ".");
+ this.setErrorMessageInCookie(resp, "Cannot delete. Please unschedule " + sflow.getScheduleName() + ".");
+
resp.sendRedirect(req.getRequestURI() + "?project=" + projectName);
return;
}
@@ -339,7 +347,7 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
// Check if executing
ExecutableFlow exflow = null;
for (ExecutableFlow flow: executorManager.getRunningFlows()) {
- if (flow.getProjectId() == projectName) {
+ if (flow.getProjectId() == project.getId()) {
exflow = flow;
break;
}
@@ -350,9 +358,9 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
return;
}
- project.info("Project removing by '" + user.getUserId() + "'");
+ //project.info("Project removing by '" + user.getUserId() + "'");
try {
- projectManager.removeProject(projectName);
+ projectManager.removeProject(project, user);
} catch (ProjectManagerException e) {
this.setErrorMessageInCookie(resp, e.getMessage());
resp.sendRedirect(req.getRequestURI() + "?project=" + projectName);
@@ -368,8 +376,7 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
project.setDescription(description);
try {
- projectManager.commitProject(project.getName());
- project.info("Project description changed to '" + description + "' by " + user.getUserId());
+ projectManager.updateProjectDescription(project, description, user);
} catch (ProjectManagerException e) {
ret.put("error", e.getMessage());
}
@@ -409,20 +416,6 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
if (edge.hasError()) {
edgeObj.put("error", edge.getError());
}
-// if (edge.getGuideValues() != null) {
-// List<Point2D> guides = edge.getGuideValues();
-// ArrayList<Object> guideOutput = new ArrayList<Object>();
-// for (Point2D guide: guides) {
-// double x = guide.getX();
-// double y = guide.getY();
-// HashMap<String, Double> point = new HashMap<String, Double>();
-// point.put("x", x);
-// point.put("y", y);
-// guideOutput.add(point);
-// }
-//
-// edgeObj.put("guides", guideOutput);
-// }
edgeList.add(edgeObj);
}
@@ -470,16 +463,26 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
ret.put("nodes", nodeList);
}
- private void ajaxAddUserPermission(Project project, HashMap<String, Object> ret, HttpServletRequest req, User user) throws ServletException {
- String username = getParam(req, "username");
- UserManager userManager = getApplication().getUserManager();
- if (!userManager.validateUser(username)) {
- ret.put("error", "User is invalid.");
- return;
+ private void ajaxAddPermission(Project project, HashMap<String, Object> ret, HttpServletRequest req, User user) throws ServletException {
+ String name = getParam(req, "name");
+ boolean group = Boolean.parseBoolean(getParam(req, "group"));
+
+ if (group) {
+ if (project.getGroupPermission(name) != null) {
+ ret.put("error", "Group permission already exists.");
+ return;
+ }
}
- if (project.getUserPermission(username) != null) {
- ret.put("error", "User permission already exists.");
- return;
+ else {
+ if (!userManager.validateUser(name)) {
+ ret.put("error", "User is invalid.");
+ return;
+ }
+
+ if (project.getUserPermission(name) != null) {
+ ret.put("error", "User permission already exists.");
+ return;
+ }
}
boolean admin = Boolean.parseBoolean(getParam(req, "permissions[admin]"));
@@ -498,11 +501,9 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
perm.setPermission(Type.EXECUTE, execute);
perm.setPermission(Type.SCHEDULE, schedule);
}
-
- project.setUserPermission(username, perm);
- project.info("User '" + user.getUserId() + "' has added user '" + username + "' to the project with permission " + perm.toString());
+
try {
- projectManager.commitProject(project.getName());
+ projectManager.updateProjectPermission(project, name, perm, group, user);
} catch (ProjectManagerException e) {
ret.put("error", e.getMessage());
}
@@ -516,10 +517,19 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
boolean execute = Boolean.parseBoolean(getParam(req, "permissions[execute]"));
boolean schedule = Boolean.parseBoolean(getParam(req, "permissions[schedule]"));
- String username = getParam(req, "username");
- Permission perm = project.getUserPermission(username);
+ boolean group = Boolean.parseBoolean(getParam(req, "group"));
+
+ String name = getParam(req, "name");
+ Permission perm;
+ if (group) {
+ perm = project.getGroupPermission(name);
+ }
+ else {
+ perm = project.getUserPermission(name);
+ }
+
if (perm == null) {
- ret.put("error", "Permissions for " + username + " cannot be found.");
+ ret.put("error", "Permissions for " + name + " cannot be found.");
return;
}
@@ -538,17 +548,19 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
perm.setPermission(Type.EXECUTE, execute);
perm.setPermission(Type.SCHEDULE, schedule);
}
- project.info("User '" + user.getUserId() + "' has changed permissions for '" + username + "' to " + perm.toString());
+
+ try {
+ projectManager.updateProjectPermission(project, name, perm, group, user);
+ } catch (ProjectManagerException e) {
+ ret.put("error", e.getMessage());
+ }
}
else {
- project.removeUserPermission(username);
- project.info("User '" + user.getUserId() + "' has removed '" + username + "'");
- }
-
- try {
- projectManager.commitProject(project.getName());
- } catch (ProjectManagerException e) {
- ret.put("error", e.getMessage());
+ try {
+ projectManager.removeProjectPermission(project, name, group, user);
+ } catch (ProjectManagerException e) {
+ ret.put("error", e.getMessage());
+ }
}
}
@@ -591,45 +603,59 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
private void handleJobHistoryPage(HttpServletRequest req, HttpServletResponse resp, Session session) throws ServletException, IOException {
Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/jobhistorypage.vm");
- String projectId = getParam(req, "project");
+ String projectName = getParam(req, "project");
+ User user = session.getUser();
+
+ Project project = projectManager.getProject(projectName);
+ if (project == null) {
+ page.add("errorMsg", "Project " + projectName + " doesn't exist.");
+ page.render();
+ return;
+ }
+ if (!hasPermission(project, user, Type.READ)) {
+ page.add("errorMsg", "No permission to view project " + projectName + ".");
+ page.render();
+ return;
+ }
+
String jobId = getParam(req, "job");
int pageNum = getIntParam(req, "page", 1);
int pageSize = getIntParam(req, "size", 25);
- page.add("projectId", projectId);
+ page.add("projectId", project.getId());
+ page.add("projectName", project.getName());
page.add("jobid", jobId);
page.add("page", pageNum);
int skipPage = (pageNum - 1)*pageSize;
-
-
int numResults = 0;
try {
- ArrayList<NodeStatus> statuses = new ArrayList<NodeStatus>();
- numResults = executorManager.getJobHistory(projectId, jobId, pageSize, skipPage, statuses);
- if (statuses.isEmpty()) {
- statuses = null;
+ numResults = executorManager.getNumberOfJobExecutions(project, jobId);
+ int maxPage = (numResults / pageSize) + 1;
+ List<ExecutableJobInfo> jobInfo = executorManager.getExecutableJobs(project, jobId, skipPage, pageSize);
+
+ if (jobInfo == null || jobInfo.isEmpty()) {
+ jobInfo = null;
}
- page.add("history", statuses);
+ page.add("history", jobInfo);
if (pageNum == 1) {
- page.add("previous", new PageSelection(1, pageSize, true, false));
+ page.add("previous", new PageSelection("Previous", pageSize, true, false, pageNum - 1));
}
- page.add("next", new PageSelection(pageNum + 1, pageSize, false, false));
+ page.add("next", new PageSelection("Next", pageSize, false, false, Math.min(pageNum + 1, maxPage)));
- if (statuses != null) {
+ if (jobInfo != null) {
ArrayList<Object> dataSeries = new ArrayList<Object>();
- for (NodeStatus status: statuses) {
- Map<String,Object> map = (Map<String,Object>)status.toObject();
- map.remove("jobId");
- String execId = (String)map.get("execId");
- String newExecId = execId.substring(0, 19);
- map.put("execId", newExecId);
+ for (ExecutableJobInfo info: jobInfo) {
+ Map<String,Object> map = info.toObject();
dataSeries.add(map);
}
page.add("dataSeries", JSONUtils.toJSON(dataSeries));
}
+ else {
+ page.add("dataSeries", "[]");
+ }
} catch (ExecutorManagerException e) {
page.add("errorMsg", e.getMessage());
}
@@ -641,16 +667,16 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
}
int maxPage = (numResults / pageSize) + 1;
- page.add("page1", new PageSelection(pageStartValue, pageSize, pageStartValue > maxPage, pageStartValue == pageNum));
+ page.add("page1", new PageSelection(String.valueOf(pageStartValue), pageSize, pageStartValue > maxPage, pageStartValue == pageNum, Math.min(pageStartValue, maxPage)));
pageStartValue++;
- page.add("page2", new PageSelection(pageStartValue, pageSize, pageStartValue > maxPage, pageStartValue == pageNum));
+ page.add("page2", new PageSelection(String.valueOf(pageStartValue), pageSize, pageStartValue > maxPage, pageStartValue == pageNum, Math.min(pageStartValue, maxPage)));
pageStartValue++;
- page.add("page3", new PageSelection(pageStartValue, pageSize, pageStartValue > maxPage, pageStartValue == pageNum));
+ page.add("page3", new PageSelection(String.valueOf(pageStartValue), pageSize, pageStartValue > maxPage, pageStartValue == pageNum, Math.min(pageStartValue, maxPage)));
pageStartValue++;
- page.add("page4", new PageSelection(pageStartValue, pageSize, pageStartValue > maxPage, pageStartValue == pageNum));
- pageStartValue++;
- page.add("page5", new PageSelection(pageStartValue, pageSize, pageStartValue > maxPage, pageStartValue == pageNum));
+ page.add("page4", new PageSelection(String.valueOf(pageStartValue), pageSize, pageStartValue > maxPage, pageStartValue == pageNum, Math.min(pageStartValue, maxPage)));
pageStartValue++;
+ page.add("page5", new PageSelection(String.valueOf(pageStartValue), pageSize, pageStartValue > maxPage, pageStartValue == pageNum, Math.min(pageStartValue, maxPage)));
+
page.render();
}
@@ -667,13 +693,24 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
page.add("errorMsg", "Project " + projectName + " not found.");
}
else {
+ if (!hasPermission(project, user, Type.READ)) {
+ throw new AccessControlException( "No permission to view project " + projectName + ".");
+ }
+
page.add("project", project);
page.add("username", user.getUserId());
page.add("admins", Utils.flattenToString(project.getUsersWithPermission(Type.ADMIN), ","));
- page.add("userpermission", project.getUserPermission(user));
+ Permission perm = this.getPermissionObject(project, user, Type.ADMIN);
+ page.add("userpermission", perm);
+
+ if (perm.isPermissionSet(Type.ADMIN)) {
+ page.add("admin", true);
+ }
+
page.add("permissions", project.getUserPermissions());
+ page.add("groupPermissions", project.getGroupPermissions());
- if(project.hasPermission(user, Type.ADMIN)) {
+ if(hasPermission(project, user, Type.ADMIN)) {
page.add("isAdmin", true);
}
}
@@ -701,7 +738,7 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
page.add("errorMsg", "Project " + projectName + " not found.");
}
else {
- if (!project.hasPermission(user, Type.READ)) {
+ if (!hasPermission(project, user, Type.READ)) {
throw new AccessControlException( "No permission to view project " + projectName + ".");
}
@@ -720,7 +757,7 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
page.add("errorMsg", "Job " + jobName + " not found.");
}
else {
- Props prop = projectManager.getProperties(projectName, node.getJobSource());
+ Props prop = projectManager.getProperties(project, node.getJobSource());
page.add("jobid", node.getId());
page.add("jobtype", node.getType());
@@ -800,7 +837,7 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
page.add("errorMsg", "Project " + projectName + " not found.");
}
else {
- if (!project.hasPermission(user, Type.READ)) {
+ if (!hasPermission(project,user,Type.READ)) {
throw new AccessControlException( "No permission to view project " + projectName + ".");
}
@@ -846,7 +883,6 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
page.add("dependingproperties", dependingProps);
}
-
ArrayList<Pair<String,String>> parameters = new ArrayList<Pair<String, String>>();
// Parameter
for (String key : prop.getKeySet()) {
@@ -883,7 +919,7 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
page.add("errorMsg", "Project " + projectName + " not found.");
}
else {
- if (!project.hasPermission(user, Type.READ)) {
+ if (!hasPermission(project, user, Type.READ)) {
throw new AccessControlException( "No permission Project " + projectName + ".");
}
@@ -924,7 +960,7 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
page.add("errorMsg", "Project " + projectName + " not found.");
}
else {
- if (!project.hasPermission(user, Type.EXECUTE)) {
+ if (!hasPermission(project, user, Type.EXECUTE)) {
throw new AccessControlException( "No permission Project " + projectName + " to Execute.");
}
@@ -958,18 +994,19 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
page.add("errorMsg", "Project " + projectName + " not found.");
}
else {
- if (project.hasPermission(user, Type.ADMIN)) {
- page.add("admin", true);
- }
-
- if (!project.hasPermission(user, Type.READ)) {
+ if (!hasPermission(project,user,Type.READ)) {
throw new AccessControlException( "No permission to view project " + projectName + ".");
}
page.add("project", project);
page.add("admins", Utils.flattenToString(project.getUsersWithPermission(Type.ADMIN), ","));
- page.add("userpermission", project.getUserPermission(user));
+ Permission perm = this.getPermissionObject(project, user, Type.ADMIN);
+ page.add("userpermission", perm);
+ if (perm.isPermissionSet(Type.ADMIN)) {
+ page.add("admin", true);
+ }
+
List<Flow> flows = project.getFlows();
if (!flows.isEmpty()) {
Collections.sort(flows, FLOW_ID_COMPARATOR);
@@ -1027,63 +1064,49 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
else if (project == null) {
setErrorMessageInCookie(resp, "Installation Failed. Project '" + projectName + "' doesn't exist.");
}
- else if (!project.hasPermission(user, Type.WRITE)) {
+ else if (!hasPermission(project,user,Type.WRITE)) {
setErrorMessageInCookie(resp, "Installation Failed. User '" + user.getUserId() + "' does not have write access.");
}
else {
FileItem item = (FileItem) multipart.get("file");
- String forceStr = (String) multipart.get("force");
- boolean force = forceStr == null ? false : Boolean.parseBoolean(forceStr);
- File projectDir = null;
- if (projectName == null || projectName.isEmpty()) {
- setErrorMessageInCookie(resp, "No project name found.");
- }
- else if (item == null) {
- setErrorMessageInCookie(resp, "No file found.");
+ String name = item.getName();
+ String type = null;
+
+ final String contentType = item.getContentType();
+ if(contentType.startsWith("application/zip")) {
+ type = "zip";
}
else {
- try {
- projectDir = extractFile(item);
- projectManager.uploadProject(projectName, projectDir, user, force);
- setSuccessMessageInCookie(resp, "Project Uploaded");
- }
- catch (Exception e) {
- logger.info("Installation Failed.", e);
- project.error("Upload by '" + user.getUserId() + "' failed: " + e.getMessage());
- setErrorMessageInCookie(resp, "Installation Failed.\n" + e.getMessage());
- }
+ item.delete();
+ setErrorMessageInCookie(resp, "File type " + contentType + " unrecognized.");
+ }
+
+ File tempDir = Utils.createTempDir();
+ OutputStream out = null;
+ try {
+ logger.info("Uploading file " + name);
+ File archiveFile = new File(tempDir, name);
+ out = new BufferedOutputStream(new FileOutputStream(archiveFile));
+ IOUtils.copy(item.getInputStream(), out);
+ out.close();
- if (projectDir != null && projectDir.exists() ) {
- FileUtils.deleteDirectory(projectDir);
+ projectManager.uploadProject(project, archiveFile, type, user);
+ } catch (Exception e) {
+ logger.info("Installation Failed.", e);
+ setErrorMessageInCookie(resp, "Installation Failed.\n" + e.getMessage());
+ }
+ finally {
+ if (tempDir.exists()) {
+ FileUtils.deleteDirectory(tempDir);
+ }
+ if (out != null) {
+ out.close();
}
- project.error("New project files uploaded by '" + user.getUserId() + "'");
}
}
resp.sendRedirect(req.getRequestURI() + "?project=" + projectName);
}
- private File extractFile(FileItem item) throws IOException, ServletException {
- final String contentType = item.getContentType();
- if (contentType.startsWith("application/zip")) {
- return unzipFile(item);
- }
-
- throw new ServletException(String.format("Unsupported file type[%s].", contentType));
- }
-
- private File unzipFile(FileItem item) throws ServletException, IOException {
- File temp = File.createTempFile("job-temp", ".zip");
- temp.deleteOnExit();
- OutputStream out = new BufferedOutputStream(new FileOutputStream(temp));
- IOUtils.copy(item.getInputStream(), out);
- out.close();
- ZipFile zipfile = new ZipFile(temp);
- File unzipped = Utils.createTempDir(tempDir);
- Utils.unzip(zipfile, unzipped);
- temp.delete();
- return unzipped;
- }
-
private static class NodeLevelComparator implements Comparator<Node> {
@Override
public int compare(Node node1, Node node2) {
@@ -1092,19 +1115,21 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
}
public class PageSelection {
- private int page;
+ private String page;
private int size;
private boolean disabled;
private boolean selected;
+ private int nextPage;
- public PageSelection(int page, int size, boolean disabled, boolean selected) {
- this.page = page;
+ public PageSelection(String pageName, int size, boolean disabled, boolean selected, int nextPage) {
+ this.page = pageName;
this.size = size;
this.disabled = disabled;
this.setSelected(selected);
+ this.nextPage = nextPage;
}
- public int getPage() {
+ public String getPage() {
return page;
}
@@ -1119,9 +1144,39 @@ public class ProjectManagerServlet extends LoginAbstractAzkabanServlet {
public boolean isSelected() {
return selected;
}
-
+
+ public int getNextPage() {
+ return nextPage;
+ }
+
public void setSelected(boolean selected) {
this.selected = selected;
}
}
+
+ private boolean hasPermission(Project project, User user, Permission.Type type) {
+ if (project.hasPermission(user, type)) {
+ return true;
+ }
+
+ for(String roleName: user.getRoles()) {
+ Role role = userManager.getRole(roleName);
+ if (role.getPermission().isPermissionSet(type)) {
+ return true;
+ }
+ }
+
+ return true;
+ }
+
+ private Permission getPermissionObject(Project project, User user, Permission.Type type) {
+ Permission perm = project.getCollectivePermission(user);
+
+ for(String roleName: user.getRoles()) {
+ Role role = userManager.getRole(roleName);
+ perm.addPermissions(role.getPermission());
+ }
+
+ return perm;
+ }
}
src/java/azkaban/webapp/servlet/ScheduleServlet.java 134(+80 -54)
diff --git a/src/java/azkaban/webapp/servlet/ScheduleServlet.java b/src/java/azkaban/webapp/servlet/ScheduleServlet.java
index aa06ebb..85731a8 100644
--- a/src/java/azkaban/webapp/servlet/ScheduleServlet.java
+++ b/src/java/azkaban/webapp/servlet/ScheduleServlet.java
@@ -17,7 +17,6 @@
package azkaban.webapp.servlet;
import java.io.IOException;
-import java.io.Writer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -27,37 +26,42 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.log4j.Logger;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
-import org.joda.time.Months;
-import org.joda.time.Weeks;
-import org.joda.time.Days;
-import org.joda.time.Hours;
import org.joda.time.LocalDateTime;
-import org.joda.time.Minutes;
import org.joda.time.ReadablePeriod;
-import org.joda.time.Seconds;
import org.joda.time.format.DateTimeFormat;
import azkaban.flow.Flow;
import azkaban.project.Project;
import azkaban.project.ProjectManager;
+import azkaban.project.ProjectLogEvent.EventType;
+import azkaban.user.Permission;
+import azkaban.user.Role;
import azkaban.user.User;
import azkaban.user.Permission.Type;
+import azkaban.user.UserManager;
+import azkaban.utils.Pair;
+import azkaban.webapp.AzkabanWebServer;
import azkaban.webapp.session.Session;
+import azkaban.scheduler.Schedule;
import azkaban.scheduler.ScheduleManager;
-import azkaban.scheduler.ScheduledFlow;
public class ScheduleServlet extends LoginAbstractAzkabanServlet {
private static final long serialVersionUID = 1L;
+ private static final Logger logger = Logger.getLogger(ScheduleServlet.class);
private ProjectManager projectManager;
private ScheduleManager scheduleManager;
+ private UserManager userManager;
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
- projectManager = this.getApplication().getProjectManager();
- scheduleManager = this.getApplication().getScheduleManager();
+ AzkabanWebServer server = (AzkabanWebServer)getApplication();
+ projectManager = server.getProjectManager();
+ scheduleManager = server.getScheduleManager();
+ userManager = server.getUserManager();
}
@Override
@@ -65,7 +69,7 @@ public class ScheduleServlet extends LoginAbstractAzkabanServlet {
Session session) throws ServletException, IOException {
Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/scheduledflowpage.vm");
- List<ScheduledFlow> schedules = scheduleManager.getSchedule();
+ List<Schedule> schedules = scheduleManager.getSchedules();
page.add("schedules", schedules);
page.render();
@@ -105,9 +109,13 @@ public class ScheduleServlet extends LoginAbstractAzkabanServlet {
//
private void ajaxRemoveSched(HttpServletRequest req, Map<String, Object> ret, User user) throws ServletException{
- String scheduleId = getParam(req, "scheduleId");
- ScheduledFlow schedFlow = scheduleManager.getSchedule(scheduleId);
- String projectId = schedFlow.getProjectId();
+ int projectId = getIntParam(req, "projectId");
+ String flowName = getParam(req, "flowName");
+ Pair scheduleId = new Pair(projectId, flowName);
+ Schedule sched = scheduleManager.getSchedule(scheduleId);
+
+// int projectId = sched.getProjectId();
+
Project project = projectManager.getProject(projectId);
if (project == null) {
@@ -116,42 +124,44 @@ public class ScheduleServlet extends LoginAbstractAzkabanServlet {
return;
}
- if (!project.hasPermission(user, Type.SCHEDULE)) {
+ if(!hasPermission(project, user, Type.SCHEDULE)) {
ret.put("status", "error");
- ret.put("message", "Permission denied. Cannot remove schedule " + scheduleId);
+ ret.put("message", "Permission denied. Cannot remove schedule " + projectId + "." + flowName);
return;
}
-
- scheduleManager.removeScheduledFlow(scheduleId);
- project.info("User '" + user.getUserId() + " has removed schedule " + schedFlow.toNiceString());
+ scheduleManager.removeSchedule(scheduleId);
+ logger.info("User '" + user.getUserId() + " has removed schedule " + sched.getScheduleName());
+ projectManager.postProjectEvent(project, EventType.SCHEDULE, user.getUserId(), "Schedule " + sched.toString() + " has been removed.");
+
ret.put("status", "success");
- ret.put("message", scheduleId + " removed.");
+ ret.put("message", "flow " + scheduleId.getSecond() + " removed from Schedules.");
return;
}
private void ajaxScheduleFlow(HttpServletRequest req, Map<String, Object> ret, User user) throws ServletException {
- String projectId = getParam(req, "projectId");
- String flowId = getParam(req, "flowId");
+ String projectName = getParam(req, "projectName");
+ String flowName = getParam(req, "flowName");
+ int projectId = getIntParam(req, "projectId");
Project project = projectManager.getProject(projectId);
if (project == null) {
- ret.put("message", "Project " + projectId + " does not exist");
+ ret.put("message", "Project " + projectName + " does not exist");
ret.put("status", "error");
return;
}
- if (!project.hasPermission(user, Type.SCHEDULE)) {
+ if (!hasPermission(project, user, Type.SCHEDULE)) {
ret.put("status", "error");
- ret.put("message", "Permission denied. Cannot execute " + flowId);
+ ret.put("message", "Permission denied. Cannot execute " + flowName);
return;
}
- Flow flow = project.getFlow(flowId);
+ Flow flow = project.getFlow(flowName);
if (flow == null) {
ret.put("status", "error");
- ret.put("message", "Flow " + flowId + " cannot be found in project " + project);
+ ret.put("message", "Flow " + flowName + " cannot be found in project " + project);
return;
}
@@ -161,7 +171,6 @@ public class ScheduleServlet extends LoginAbstractAzkabanServlet {
DateTimeZone timezone = getParam(req, "timezone").equals("UTC") ? DateTimeZone.UTC : DateTimeZone.forID("America/Los_Angeles");
-
String scheduledDate = req.getParameter("date");
DateTime day = null;
if(scheduledDate == null || scheduledDate.trim().length() == 0) {
@@ -178,7 +187,7 @@ public class ScheduleServlet extends LoginAbstractAzkabanServlet {
ReadablePeriod thePeriod = null;
try {
if(hasParam(req, "is_recurring"))
- thePeriod = parsePeriod(req);
+ thePeriod = Schedule.parsePeriodString(getParam(req, "period")+getParam(req,"period_units"));
}
catch(Exception e){
ret.put("error", e.getMessage());
@@ -188,36 +197,53 @@ public class ScheduleServlet extends LoginAbstractAzkabanServlet {
hour += 12;
hour %= 24;
- String userSubmit = user.getUserId();
- String userExec = userSubmit;//getParam(req, "userExec");
- String scheduleId = projectId + "." + flowId;
- DateTime submitTime = new DateTime().withZone(timezone);
+ String submitUser = user.getUserId();
+// String userExec = userSubmit;//getParam(req, "userExec");
+// String scheduleId = projectId + "." + flowName;
+ DateTime submitTime = new DateTime();
DateTime firstSchedTime = day.withHourOfDay(hour).withMinuteOfHour(minutes).withSecondOfMinute(0);
- ScheduledFlow schedFlow = scheduleManager.schedule(scheduleId, projectId, flowId, userExec, userSubmit, submitTime, firstSchedTime, thePeriod);
- project.info("User '" + user.getUserId() + "' has scheduled " + flow.getId() + "[" + schedFlow.toNiceString() + "].");
+ //ScheduledFlow schedFlow = scheduleManager.schedule(scheduleId, projectId, flowId, userExec, userSubmit, submitTime, firstSchedTime, thePeriod);
+ //project.info("User '" + user.getUserId() + "' has scheduled " + flow.getId() + "[" + schedFlow.toNiceString() + "].");
+ Schedule schedule = scheduleManager.scheduleFlow(projectId, projectName, flowName, "ready", firstSchedTime.getMillis(), timezone, thePeriod, submitTime.getMillis(), firstSchedTime.getMillis(), firstSchedTime.getMillis(), user.getUserId());
+ logger.info("User '" + user.getUserId() + "' has scheduled " + "[" + projectName + flowName + " (" + projectId +")" + "].");
+ projectManager.postProjectEvent(project, EventType.SCHEDULE, user.getUserId(), "Schedule " + schedule.toString() + " has been added.");
ret.put("status", "success");
- ret.put("message", scheduleId + " scheduled.");
+ ret.put("message", projectName + "." + flowName + " scheduled.");
}
- private ReadablePeriod parsePeriod(HttpServletRequest req) throws ServletException {
- int period = getIntParam(req, "period");
- String periodUnits = getParam(req, "period_units");
- if("M".equals(periodUnits))
- return Months.months(period);
- else if("w".equals(periodUnits))
- return Weeks.weeks(period);
- else if("d".equals(periodUnits))
- return Days.days(period);
- else if("h".equals(periodUnits))
- return Hours.hours(period);
- else if("m".equals(periodUnits))
- return Minutes.minutes(period);
- else if("s".equals(periodUnits))
- return Seconds.seconds(period);
- else
- throw new ServletException("Unknown period unit: " + periodUnits);
- }
+// private ReadablePeriod parsePeriod(HttpServletRequest req) throws ServletException {
+// int period = getIntParam(req, "period");
+// String periodUnits = getParam(req, "period_units");
+// if("M".equals(periodUnits))
+// return Months.months(period);
+// else if("w".equals(periodUnits))
+// return Weeks.weeks(period);
+// else if("d".equals(periodUnits))
+// return Days.days(period);
+// else if("h".equals(periodUnits))
+// return Hours.hours(period);
+// else if("m".equals(periodUnits))
+// return Minutes.minutes(period);
+// else if("s".equals(periodUnits))
+// return Seconds.seconds(period);
+// else
+// throw new ServletException("Unknown period unit: " + periodUnits);
+// }
+ private boolean hasPermission(Project project, User user, Permission.Type type) {
+ if (project.hasPermission(user, type)) {
+ return true;
+ }
+
+ for(String roleName: user.getRoles()) {
+ Role role = userManager.getRole(roleName);
+ if (role.getPermission().isPermissionSet(type)) {
+ return true;
+ }
+ }
+
+ return true;
+ }
}
diff --git a/src/java/azkaban/webapp/servlet/velocity/executingflowpage.vm b/src/java/azkaban/webapp/servlet/velocity/executingflowpage.vm
index 99c496e..670b67b 100644
--- a/src/java/azkaban/webapp/servlet/velocity/executingflowpage.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/executingflowpage.vm
@@ -155,9 +155,9 @@
<div id="completeActions">
<h4>Completion Actions</h4>
<dl>
- <dt class="disabled">Failure Action</dt>
+ <dt>Failure Action</dt>
<dd>
- <select id="failureAction" name="failureAction" disabled="disabled">
+ <select id="failureAction" name="failureAction">
<option value="finishCurrent">Finish Current Running</option>
<option value="cancelImmediately">Cancel All</option>
<option value="finishPossible">Finish All Possible</option>
@@ -167,10 +167,10 @@
<dd>
<textarea id="failureEmails"></textarea>
</dd>
- <dt class="disabled">Notify on Failure</dt>
+ <dt>Notify on Failure</dt>
<dd>
- <input id="notifyFailureFirst" class="checkbox" type="checkbox" name="notify" value="first" disabled="disabled" checked >First Failure</input>
- <input id="notifyFailureLast" class="checkbox" type="checkbox" name="notify" disabled="disabled" value="last">Flow Stop</input>
+ <input id="notifyFailureFirst" class="checkbox" type="checkbox" name="notify" value="first" checked >First Failure</input>
+ <input id="notifyFailureLast" class="checkbox" type="checkbox" name="notify" value="last">Flow Stop</input>
</dd>
<dt>Success Email</dt>
<dd>
diff --git a/src/java/azkaban/webapp/servlet/velocity/executionspage.vm b/src/java/azkaban/webapp/servlet/velocity/executionspage.vm
index b2fa253..c51cf52 100644
--- a/src/java/azkaban/webapp/servlet/velocity/executionspage.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/executionspage.vm
@@ -66,11 +66,11 @@
#foreach($flow in $runningFlows)
<tr class="row" >
<td class="tb-name">
- <a href="${context}/executor?execid=${flow.executionId}">$utils.extractNumericalId(${flow.executionId})</a>
+ <a href="${context}/executor?execid=${flow.executionId}">${flow.executionId}</a>
</td>
- <td><a href="${context}/manager?project=${flow.projectId}&flow=${flow.flowId}">${flow.flowId}</a></td>
+ <td><a href="${context}/manager?project=$vmutils.getProjectName(${flow.projectId})&flow=${flow.flowId}">${flow.flowId}</a></td>
<td>
- <a href="${context}/manager?project=${flow.projectId}">${flow.projectId}</a>
+ <a href="${context}/manager?project=$vmutils.getProjectName(${flow.projectId})">$vmutils.getProjectName(${flow.projectId})</a>
</td>
<td>${flow.submitUser}</td>
<td>$utils.formatDate(${flow.startTime})</td>
@@ -81,7 +81,7 @@
</tr>
#end
#else
- <tr><td class="last">No Executing Flows</td></tr>
+ <tr><td></td><td class="last">No Executing Flows</td></tr>
#end
</tbody>
</table>
@@ -106,12 +106,12 @@
#if($recentlyFinished)
#foreach($flow in $recentlyFinished)
<tr class="row" >
- <td class="tb-name">
- <a href="${context}/executor?execid=${flow.executionId}">$utils.extractNumericalId(${flow.executionId})</a>
+ <td class="tb-name execId">
+ <a href="${context}/executor?execid=${flow.executionId}">${flow.executionId}</a>
</td>
- <td><a href="${context}/manager?project=${flow.projectId}&flow=${flow.flowId}">${flow.flowId}</a></td>
+ <td><a href="${context}/manager?project=$vmutils.getProjectName(${flow.projectId})&flow=${flow.flowId}">${flow.flowId}</a></td>
<td>
- <a href="${context}/manager?project=${flow.projectId}">${flow.projectId}</a>
+ <a href="${context}/manager?project=$vmutils.getProjectName(${flow.projectId})">$vmutils.getProjectName(${flow.projectId})</a>
</td>
<td>${flow.submitUser}</td>
<td>$utils.formatDate(${flow.startTime})</td>
@@ -122,7 +122,7 @@
</tr>
#end
#else
- <tr><td class="last">No Recently Finished</td></tr>
+ <tr><td></td><td class="last">No Recently Finished</td></tr>
#end
</tbody>
</table>
diff --git a/src/java/azkaban/webapp/servlet/velocity/flowpage.vm b/src/java/azkaban/webapp/servlet/velocity/flowpage.vm
index a6a3ce1..ee2436b 100644
--- a/src/java/azkaban/webapp/servlet/velocity/flowpage.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/flowpage.vm
@@ -42,6 +42,7 @@
var errorMessage = null;
var successMessage = null;
+ var projectId = ${project.id};
var projectName = "${project.name}";
var flowName = "${flowid}";
var execId = null;
@@ -161,7 +162,6 @@
<option value="d">Days</option>
<option value="h">Hours</option>
<option value="m">Minutes</option>
- <option value="s">Seconds</option>
<option value="M">Months</option>
<option value="w">Weeks</option>
</select>
@@ -204,7 +204,7 @@
<dl>
<dt class="disabled">Failure Action</dt>
<dd>
- <select id="failureAction" name="failureAction" disabled="disabled">
+ <select id="failureAction" name="failureAction">
<option value="finishCurrent">Finish Current Running</option>
<option value="cancelImmediately">Cancel All</option>
<option value="finishPossible">Finish All Possible</option>
@@ -214,10 +214,10 @@
<dd>
<textarea id="failureEmails"></textarea>
</dd>
- <dt class="disabled">Notify on Failure</dt>
+ <dt>Notify on Failure</dt>
<dd>
- <input id="notifyFailureFirst" class="checkbox" type="checkbox" name="notify" value="first" disabled="disabled" checked >First Failure</input>
- <input id="notifyFailureLast" class="checkbox" type="checkbox" name="notify" disabled="disabled" value="last">Flow Stop</input>
+ <input id="notifyFailureFirst" class="checkbox" type="checkbox" name="notify" value="first" checked >First Failure</input>
+ <input id="notifyFailureLast" class="checkbox" type="checkbox" name="notify" value="last">Flow Stop</input>
</dd>
<dt>Success Email</dt>
<dd>
diff --git a/src/java/azkaban/webapp/servlet/velocity/hdfsbrowserlogin.vm b/src/java/azkaban/webapp/servlet/velocity/hdfsbrowserlogin.vm
new file mode 100644
index 0000000..80aacf6
--- /dev/null
+++ b/src/java/azkaban/webapp/servlet/velocity/hdfsbrowserlogin.vm
@@ -0,0 +1,62 @@
+#*
+ * Copyright 2012 LinkedIn, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+*#
+
+<!DOCTYPE html>
+<html>
+ <head>
+#parse( "azkaban/webapp/servlet/velocity/style.vm" )
+ <script type="text/javascript" src="${context}/js/jquery/jquery.js"></script>
+ <script type="text/javascript" src="${context}/js/namespace.js"></script>
+ <script type="text/javascript" src="${context}/js/azkaban.nav.js"></script>
+ <script type="text/javascript">
+ var contextURL = "${context}";
+ </script>
+ <style>
+
+ </style>
+ </head>
+ <body>
+#set($current_page="hdfsbrowserlogin")
+#parse( "azkaban/webapp/servlet/velocity/nav.vm" )
+
+ <div class="content">
+
+ #if($errorMsg)
+ <div class="box-error-message">$errorMsg</div>
+ #else
+ #if($error_message != "null")
+ <div class="box-error-message">$error_message</div>
+ #elseif($success_message != "null")
+ <div class="box-success-message">$success_message</div>
+ #end
+ #end
+
+ <div id="main">
+ <h2 class="title" >HDFS Browser User Login</h2>
+ <div id="variableWidth">
+
+ <div class="box">
+ <form class="login-form" method="post">
+ <p class="login-label">Username</p>
+ <input type="text" name="login" class="login-textbox" ></input>
+ <input class="btn2 button1" type="submit" value="Login" class="login-submit"/>
+ </form>
+ </div>
+ </div>
+ </div>
+ </body>
+
+</html>
diff --git a/src/java/azkaban/webapp/servlet/velocity/hdfsbrowserpage.vm b/src/java/azkaban/webapp/servlet/velocity/hdfsbrowserpage.vm
index 19a38cb..936bf64 100644
--- a/src/java/azkaban/webapp/servlet/velocity/hdfsbrowserpage.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/hdfsbrowserpage.vm
@@ -28,14 +28,26 @@
var contextURL = "${context}";
var currentTime = ${currentTime};
var timezone = "${timezone}";
- var errorMessage = null;
- var successMessage = null;
</script>
+ <style>
+ .logout-label {
+ float: right;
+ margin: 3px;
+ }
+ .logout-submit {
+ float: right;
+ }
+ </style>
</head>
<body>
#set($current_page="hdfsbrowser")
#parse( "azkaban/webapp/servlet/velocity/nav.vm" )
- <div class="messaging"><p id="messageClose">X</p><p id="message"></p></div>
+
+ <form class="logout-form" method="post">
+ <input type="hidden" name="logout" ></input>
+ <input type="submit" value="Logout" class="logout-submit"/>
+ <p class="logout-label">Browsing as ${user}</p>
+ </form>
<div class="content">
diff --git a/src/java/azkaban/webapp/servlet/velocity/historypage.vm b/src/java/azkaban/webapp/servlet/velocity/historypage.vm
index cd9945f..71f6f07 100644
--- a/src/java/azkaban/webapp/servlet/velocity/historypage.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/historypage.vm
@@ -18,9 +18,12 @@
<html>
<head>
#parse( "azkaban/webapp/servlet/velocity/style.vm" )
- <script type="text/javascript" src="${context}/js/jquery/jquery.js"></script>
- <script type="text/javascript" src="${context}/js/jqueryui/jquery-ui.custom.min.js"></script>
- <script type="text/javascript" src="${context}/js/jqueryui/jquery.ui.datepicker.min.js"></script>
+ <link rel="stylesheet" type="text/css" href="${context}/css/jquery-ui-timepicker-addon.css" />
+ <link rel="stylesheet" type="text/css" href="${context}/css/jquery-ui.css" />
+ <script type="text/javascript" src="${context}/js/jquery/jquery-1.8.3.min.js"></script>
+ <script type="text/javascript" src="${context}/js/jqueryui/jquery-ui-1.9.2.custom.min.js"></script>
+ <script type="text/javascript" src="${context}/js/jqueryui/jquery-ui-timepicker-addon.js"></script>
+ <script type="text/javascript" src="${context}/js/jqueryui/jquery-ui-sliderAccess.js"></script>
<script type="text/javascript" src="${context}/js/namespace.js"></script>
<script type="text/javascript" src="${context}/js/underscore-1.2.1-min.js"></script>
<script type="text/javascript" src="${context}/js/backbone-0.5.3-min.js"></script>
@@ -31,8 +34,6 @@
var contextURL = "${context}";
var currentTime = ${currentTime};
var timezone = "${timezone}";
- var errorMessage = "${error_message}";
- var successMessage = "${success_message}";
</script>
</head>
<body>
@@ -40,6 +41,17 @@
#parse( "azkaban/webapp/servlet/velocity/nav.vm" )
<div class="messaging"><p id="messageClose">X</p><p id="message"></p></div>
+ #if($errorMsg)
+ <div class="box-error-message">$errorMsg</div>
+ #else
+ #if($error_message != "null")
+ <div class="box-error-message">$error_message</div>
+ #elseif($success_message != "null")
+ <div class="box-success-message">$success_message</div>
+ #end
+ #end
+
+
<div class="content">
<div id="all-jobs-content">
<div class="section-hd">
@@ -50,12 +62,9 @@
<input type="submit" value="Quick Search" class="search-btn">
<input id="searchtextbox" type="text" placeholder="flow name containing ..." value=#if($search_term) ${search_term} #else "" #end class="search-input" name="searchterm">
</form>
-
</div>
</div>
-
-
<div class="executionInfo">
<table id="executingJobs">
<thead>
@@ -75,16 +84,16 @@
#if($flowHistory)
#foreach($flow in $flowHistory)
<tr class="row" >
- <td class="tb-name">
- <a href="${context}/executor?execid=${flow.execId}">$utils.extractNumericalId(${flow.execId})</a>
+ <td class="tb-name execId">
+ <a href="${context}/executor?execid=${flow.executionId}">${flow.executionId}</a>
</td>
<td class="tb-name">
- <a href="${context}/manager?project=${flow.projectId}&flow=${flow.flowId}">${flow.flowId}</a>
+ <a href="${context}/executor?execid=${flow.executionId}">${flow.flowId}</a>
</td>
<td>
- <a href="${context}/manager?project=${flow.projectId}">${flow.projectId}</a>
+ <a href="${context}/manager?project=$vmutils.getProjectName(${flow.projectId})">$vmutils.getProjectName(${flow.projectId})</a>
</td>
- <td>${flow.userId}</td>
+ <td>${flow.submitUser}</td>
<td>$utils.formatDate(${flow.startTime})</td>
<td>$utils.formatDate(${flow.endTime})</td>
<td>$utils.formatDuration(${flow.startTime}, ${flow.endTime})</td>
@@ -101,15 +110,32 @@
<div id="pageSelection" class="nonjavascript">
<ul>
+ #if($search)
+ <li id="previous" class="first"><a href="${context}/history?page=${previous.page}&size=${previous.size}&search=true&searchterm=${search_term}"><span class="arrow">←</span>Previous</a></li>
+ <li id="page1" #if($page1.selected) class="selected" #end><a href="${context}/history?page=${page1.page}&size=${page1.size}&search=true&searchterm=${search_term}">${page1.page}</a></li>
+ <li id="page2" #if($page2.selected) class="selected" #end><a href="${context}/history?page=${page2.page}&size=${page2.size}&search=true&searchterm=${search_term}">${page2.page}</a></li>
+ <li id="page3" #if($page3.selected) class="selected" #end><a href="${context}/history?page=${page3.page}&size=${page3.size}&search=true&searchterm=${search_term}">${page3.page}</a></li>
+ <li id="page4" #if($page4.selected) class="selected" #end><a href="${context}/history?page=${page4.page}&size=${page4.size}&search=true&searchterm=${search_term}">${page4.page}</a></li>
+ <li id="page5" #if($page5.selected) class="selected" #end><a href="${context}/history?page=${page5.page}&size=${page5.size}&search=true&searchterm=${search_term}">${page5.page}</a></li>
+ <li id="next"><a href="${context}/history?page=${next.page}&size=${next.size}&search=true&searchterm=${search_term}">Next<span class="arrow">→</span></a></li>
+ #elseif($advfilter)
+ <li id="previous" class="first"><a href="${context}/history?page=${previous.page}&size=${previous.size}&advfilter=true&projcontain=${projcontain}&flowcontain=${flowcontain}&usercontain=${usercontain}&status=${status}&begin=${begin}&end=${end}"><span class="arrow">←</span>Previous</a></li>
+ <li id="page1" #if($page1.selected) class="selected" #end><a href="${context}/history?page=${page1.page}&size=${page1.size}&advfilter=true&projcontain=${projcontain}&flowcontain=${flowcontain}&usercontain=${usercontain}&status=${status}&begin=${begin}&end=${end}">${page1.page}</a></li>
+ <li id="page2" #if($page2.selected) class="selected" #end><a href="${context}/history?page=${page2.page}&size=${page2.size}&advfilter=true&projcontain=${projcontain}&flowcontain=${flowcontain}&usercontain=${usercontain}&status=${status}&begin=${begin}&end=${end}">${page2.page}</a></li>
+ <li id="page3" #if($page3.selected) class="selected" #end><a href="${context}/history?page=${page3.page}&size=${page3.size}&advfilter=true&projcontain=${projcontain}&flowcontain=${flowcontain}&usercontain=${usercontain}&status=${status}&begin=${begin}&end=${end}">${page3.page}</a></li>
+ <li id="page4" #if($page4.selected) class="selected" #end><a href="${context}/history?page=${page4.page}&size=${page4.size}&advfilter=true&projcontain=${projcontain}&flowcontain=${flowcontain}&usercontain=${usercontain}&status=${status}&begin=${begin}&end=${end}">${page4.page}</a></li>
+ <li id="page5" #if($page5.selected) class="selected" #end><a href="${context}/history?page=${page5.page}&size=${page5.size}&advfilter=true&projcontain=${projcontain}&flowcontain=${flowcontain}&usercontain=${usercontain}&status=${status}&begin=${begin}&end=${end}">${page5.page}</a></li>
+ <li id="next"><a href="${context}/history?page=${next.page}&size=${next.size}&advfilter=true&projcontain=${projcontain}&flowcontain=${flowcontain}&usercontain=${usercontain}&status=${status}&begin=${begin}&end=${end}">Next<span class="arrow">→</span></a></li>
+ #else
<li id="previous" class="first"><a href="${context}/history?page=${previous.page}&size=${previous.size}"><span class="arrow">←</span>Previous</a></li>
-
<li id="page1" #if($page1.selected) class="selected" #end><a href="${context}/history?page=${page1.page}&size=${page1.size}">${page1.page}</a></li>
<li id="page2" #if($page2.selected) class="selected" #end><a href="${context}/history?page=${page2.page}&size=${page2.size}">${page2.page}</a></li>
<li id="page3" #if($page3.selected) class="selected" #end><a href="${context}/history?page=${page3.page}&size=${page3.size}">${page3.page}</a></li>
<li id="page4" #if($page4.selected) class="selected" #end><a href="${context}/history?page=${page4.page}&size=${page4.size}">${page4.page}</a></li>
<li id="page5" #if($page5.selected) class="selected" #end><a href="${context}/history?page=${page5.page}&size=${page5.size}">${page5.page}</a></li>
-
<li id="next"><a href="${context}/history?page=${next.page}&size=${next.size}">Next<span class="arrow">→</span></a></li>
+ #end
+
</ul>
</div>
</div>
@@ -123,17 +149,37 @@
<div class="message">
<fieldset>
<dl>
-
- <dt><label for="path">Project Name</label></dt>
- <dd><input id="projRe" type="text" placeholder="project name containing ..." value = "" class="filter-input" name="projre"/></dd>
- <dt><label for="path">Flow Name Name</label></dt>
- <dd><input id="flowRe" type="text" placeholder="flow name containing ..." value = "" class="filter-input" name="flowre"/></dd>
+ <dt><label for="path" >Project Name</label></dt>
+ <dd><input id="projcontain" type="text" placeholder="project name containing ..." value = "" class="filter-input" name="projcontain"/></dd>
+ <dt><label for="path">Flow Name</label></dt>
+ <dd><input id="flowcontain" type="text" placeholder="flow name containing ..." value = "" class="filter-input" name="flowcontain"/></dd>
<dt><label for="path">User Name</label></dt>
- <dd><input id="userRe" type="text" placeholder="user name containing ..." value = "" class="filter-input" name="userre"/></dd>
+ <dd><input id="usercontain" type="text" placeholder="user name containing ..." value = "" class="filter-input" name="usercontain"/></dd>
+ <dt><label for="path">Status</label></dt>
+ <!--dd><input id="status" type="text" placeholder="Flow status is ..." value = "" class="filter-input" name="status"/></dd-->
+ <dd>
+ <select id="status">
+ <option value=0>All Status</option>
+ <option value=10>Ready</option>
+ <option value=20>Preapring</option>
+ <option value=30>Running</option>
+ <option value=40>Paused</option>
+ <option value=50>Succeed</option>
+ <option value=60>Killed</option>
+ <option value=70>Failed</option>
+ <option value=80>Failed Finishing</option>
+ <option value=90>Skipped</option>
+ <option value=100>Disabled</option>
+ <option value=110>Queued</option>
+ </select>
+ </dd>
<dt>Date between</dt>
- <dd><input type="text" id="daterangebegin" value=""/></dd>
+ <dd><div class="ui-datetime-container">
+ <input type="text" name="basic_example_1" id="datetimebegin" value="" />
+ </div></dd>
+ <!--dd><input type="text" class="ui-datetime-container" id="datetimebegin" value=""/></dd-->
<dt>and</dt>
- <dd><input type="text" id="daterangeend" value=""/></dd>
+ <dd><input type="text" class="ui-datetime-container" id="datetimeend" value=""/></dd>
</dl>
</fieldset>
</div>
diff --git a/src/java/azkaban/webapp/servlet/velocity/index.vm b/src/java/azkaban/webapp/servlet/velocity/index.vm
index 803f524..4d3a0c8 100644
--- a/src/java/azkaban/webapp/servlet/velocity/index.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/index.vm
@@ -60,6 +60,9 @@
<form id="search-form" method="get">
<input type="hidden" name="doaction" value="search">
<input type="submit" value="Quick Search" class="search-btn">
+#if ($allProjects)
+ <input type="hidden" name="all" value="true">
+#end
<input id="searchtextbox" type="text" placeholder="project name containing ..." value=#if($search_term) ${search_term} #else "" #end class="search-input" name="searchterm">
</form>
diff --git a/src/java/azkaban/webapp/servlet/velocity/jobhistorypage.vm b/src/java/azkaban/webapp/servlet/velocity/jobhistorypage.vm
index a7a89e1..60c39a1 100644
--- a/src/java/azkaban/webapp/servlet/velocity/jobhistorypage.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/jobhistorypage.vm
@@ -36,6 +36,7 @@
var successMessage = null;
var projectId = "$projectId";
+ var projectName = "$projectName";
var jobName = "$jobid";
var dataSeries = $dataSeries;
</script>
@@ -74,9 +75,9 @@
#end
<div id="all-jobs-content">
<div class="section-hd">
- <h2><a href="${context}/manager?project=${projectId}&job=${jobid}&history">Job <span>$jobid</span> History</a></h2>
+ <h2><a href="${context}/manager?project=${projectName}&job=${jobid}&history">Job <span>$jobid</span> History</a></h2>
<div class="section-sub-hd">
- <h4><a href="${context}/manager?project=${projectId}">Project <span>$projectId</span></a></h4>
+ <h4><a href="${context}/manager?project=${projectName}">Project <span>$projectName</span></a></h4>
</div>
</div>
@@ -103,13 +104,13 @@
#foreach($job in $history)
<tr>
<td class="first">
- <a href="${context}/executor?execid=${job.execId}">$utils.extractNumericalId(${job.execId})</a>
+ <a href="${context}/executor?execid=${job.execId}">${job.execId}</a>
</td>
<td>
- <a href="${context}/manager?project=${projectId}&flow=${job.flowId}&job=${jobid}">$jobid</a>
+ <a href="${context}/manager?project=${projectName}&flow=${job.flowId}&job=${jobid}">$jobid</a>
</td>
<td>
- <a href="${context}/manager?project=${projectId}&flow=${job.flowId}">${job.flowId}</a>
+ <a href="${context}/manager?project=${projectName}&flow=${job.flowId}">${job.flowId}</a>
</td>
<td>$utils.formatDate(${job.startTime})</td>
<td>$utils.formatDate(${job.endTime})</td>
@@ -127,13 +128,13 @@
<ul>
<li id="previous" class="first"><a href="${context}/manager?project=${projectId}&job=${jobid}&history&page=${previous.page}&size=${previous.size}"><span class="arrow">←</span>Previous</a></li>
- <li id="page1" #if($page1.selected) class="selected" #elseif ($page1.disabled) class="disabled" #end><a href="${context}/manager?project=${projectId}&job=${jobid}&history&page=${page1.page}&size=${page1.size}">${page1.page}</a></li>
- <li id="page2" #if($page2.selected) class="selected" #elseif ($page2.disabled) class="disabled" #end><a href="${context}/manager?project=${projectId}&job=${jobid}&history&page=${page2.page}&size=${page2.size}">${page2.page}</a></li>
- <li id="page3" #if($page3.selected) class="selected" #elseif ($page3.disabled) class="disabled" #end><a href="${context}/manager?project=${projectId}&job=${jobid}&history&page=${page3.page}&size=${page3.size}">${page3.page}</a></li>
- <li id="page4" #if($page4.selected) class="selected" #elseif ($page4.disabled) class="disabled" #end><a href="${context}/manager?project=${projectId}&job=${jobid}&history&page=${page4.page}&size=${page4.size}">${page4.page}</a></li>
- <li id="page5" #if($page5.selected) class="selected" #elseif ($page5.disabled) class="disabled" #end><a href="${context}/manager?project=${projectId}&job=${jobid}&history&page=${page5.page}&size=${page5.size}">${page5.page}</a></li>
+ <li id="page1" #if($page1.selected) class="selected" #elseif ($page1.disabled) class="disabled" #end><a href="${context}/manager?project=${projectName}&job=${jobid}&history&page=${page1.nextPage}&size=${page1.size}">${page1.page}</a></li>
+ <li id="page2" #if($page2.selected) class="selected" #elseif ($page2.disabled) class="disabled" #end><a href="${context}/manager?project=${projectName}&job=${jobid}&history&page=${page2.nextPage}&size=${page2.size}">${page2.page}</a></li>
+ <li id="page3" #if($page3.selected) class="selected" #elseif ($page3.disabled) class="disabled" #end><a href="${context}/manager?project=${projectName}&job=${jobid}&history&page=${page3.nextPage}&size=${page3.size}">${page3.page}</a></li>
+ <li id="page4" #if($page4.selected) class="selected" #elseif ($page4.disabled) class="disabled" #end><a href="${context}/manager?project=${projectName}&job=${jobid}&history&page=${page4.nextPage}&size=${page4.size}">${page4.page}</a></li>
+ <li id="page5" #if($page5.selected) class="selected" #elseif ($page5.disabled) class="disabled" #end><a href="${context}/manager?project=${projectName}&job=${jobid}&history&page=${page5.nextPage}&size=${page5.size}">${page5.page}</a></li>
- <li id="next"><a href="${context}/manager?project=${projectId}&job=${jobid}&history&page=${next.page}&size=${next.size}">Next<span class="arrow">→</span></a></li>
+ <li id="next"><a href="${context}/manager?project=${projectName}&job=${jobid}&history&page=${next.page}&size=${next.size}">Next<span class="arrow">→</span></a></li>
</ul>
</div>
</div>
diff --git a/src/java/azkaban/webapp/servlet/velocity/joblogpage.vm b/src/java/azkaban/webapp/servlet/velocity/joblogpage.vm
index 3becb97..4a9fa44 100644
--- a/src/java/azkaban/webapp/servlet/velocity/joblogpage.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/joblogpage.vm
@@ -69,11 +69,11 @@
<div id="headertabs" class="headertabs">
<ul>
- <li><a id="logViewLink" href="#log">Log</a></li>
+ <li><a id="logViewLink" >Log</a></li>
</ul>
</div>
- <div id="projectLogView" class="logView">
+ <div id="jobLogView" class="logView">
<div class="logHeader"><div class="logButtonRow"><div id="updateLogBtn" class="btn7">Refresh</div></div></div>
<div class="logViewer">
<pre id="logSection" class="log"></pre>
diff --git a/src/java/azkaban/webapp/servlet/velocity/jobpage.vm b/src/java/azkaban/webapp/servlet/velocity/jobpage.vm
index ceb2287..b5f7401 100644
--- a/src/java/azkaban/webapp/servlet/velocity/jobpage.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/jobpage.vm
@@ -32,7 +32,8 @@
var errorMessage = null;
var successMessage = null;
- var projectId = "$project.name";
+ var projectId = "$project.id";
+ var projectName = "$project.name";
</script>
</head>
<body>
@@ -41,7 +42,7 @@
<div class="messaging"><p id="messageClose">X</p><p id="message"></p></div>
#if($errorMsg)
- <div class="box-error-message">$errorMsg</div>
+ <div class="box-error-message">$errorMsg</div>
#else
<div class="content">
#if($error_message != "null")
diff --git a/src/java/azkaban/webapp/servlet/velocity/login.vm b/src/java/azkaban/webapp/servlet/velocity/login.vm
index 4de7c5b..e539aff 100644
--- a/src/java/azkaban/webapp/servlet/velocity/login.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/login.vm
@@ -20,7 +20,15 @@
<title>#appname()</title>
<link rel="stylesheet" type="text/css" href="${context}/css/azkaban.css">
<link rel="shortcut icon" href="${context}/favicon.ico" />
+ <script type="text/javascript" src="${context}/js/jquery/jquery.js"></script>
+ <script type="text/javascript" src="${context}/js/namespace.js"></script>
+ <script type="text/javascript" src="${context}/js/underscore-1.2.1-min.js"></script>
+ <script type="text/javascript" src="${context}/js/backbone-0.5.3-min.js"></script>
+ <script type="text/javascript" src="${context}/js/azkaban.login.js"></script>
#parse( "azkaban/webapp/servlet/velocity/style.vm" )
+ <script type="text/javascript">
+ var contextURL = "${context}";
+ </script>
</head>
<body>
<div class="header">
@@ -32,24 +40,21 @@
<div class="box-title">Login</div>
</div>
<br>
- #if($errorMsg)
- <div class="box-error-message">$errorMsg</div>
- #end
- <form class="login-form" method="get">
- <div id="login-password">
+ <div id="errorMsg" class="box-error-message">$errorMsg</div>
+ <div id="loginForm" class="login-form">
+ <div id="login-password">
<p class="login-label">Username</p>
- <input type="text" name="username" class="login-textbox" ></input>
+ <input id="username" type="text" name="username" class="login-textbox" ></input>
<br/>
<p class="login-label">Password</p>
- <input type="password" name="password" class="login-textbox"></input>
+ <input id="password" type="password" name="password" class="login-textbox"></input>
</div>
<div class="shadow-box-footer">
- <input type="hidden" name="action" value="login"></input>
- <input class="btn2 button1" type="submit" value="Login" class="login-submit"/>
+ <div id="loginSubmit" class="btn2 button1" class="login-submit">Login</div>
</div>
- </form>
+ </div>
</div>
</body>
</html>
diff --git a/src/java/azkaban/webapp/servlet/velocity/permissionspage.vm b/src/java/azkaban/webapp/servlet/velocity/permissionspage.vm
index 86626f2..159bd05 100644
--- a/src/java/azkaban/webapp/servlet/velocity/permissionspage.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/permissionspage.vm
@@ -33,7 +33,7 @@
var errorMessage = null;
var successMessage = null;
var userId = "$username";
- var projectId = "$project.name";
+ var projectName = "$project.name";
</script>
</head>
<body>
@@ -70,6 +70,7 @@
#if($isAdmin)
<button id="addUser" class="btn1">Add User</button>
+ <button id="addGroup" class="btn1">Add Group</button>
#end
</div>
@@ -127,11 +128,56 @@
#end
</tbody>
</table>
+
+ <table id="group-permissions-table" class="all-jobs permission-table">
+ <thead>
+ <tr>
+ <th class="tb-username">Group</th>
+ <th class="tb-perm">Admin</th>
+ <th class="tb-read">Read</th>
+ <th class="tb-write">Write</th>
+ <th class="tb-execute">Execute</th>
+ <th class="tb-schedule">Schedule</th>
+ #if($isAdmin)
+ <th class="tb-action"></th>
+ #end
+ </tr>
+ </thead>
+ <tbody>
+#if($groupPermissions)
+#foreach($perm in $groupPermissions)
+ <tr id="${perm.first}-row" >
+ <td class="tb-name">#if($perm.first == $username) ${perm.first} <span class="sublabel">(you)</span> #else $perm.first #end</td>
+ #if ($perm.second.isPermissionNameSet("ADMIN"))
+ <td><input id="group-${perm.first}-admin-checkbox" type="checkbox" name="admin" disabled="disabled" checked="true"></input></td>
+ <td><input id="group-${perm.first}-read-checkbox" type="checkbox" name="read" disabled="disabled" checked="true"></input></td>
+ <td><input id="group-${perm.first}-write-checkbox" type="checkbox" name="write" disabled="disabled" checked="true"></input></td>
+ <td><input id="group-${perm.first}-execute-checkbox" type="checkbox" name="execute" disabled="disabled" checked="true"></input></td>
+ <td><input id="group-${perm.first}-schedule-checkbox" type="checkbox" name="schedule" disabled="disabled" checked="true"></input></td>
+ #else
+ <td><input id="group-${perm.first}-admin-checkbox" type="checkbox" name="admin" disabled="disabled"></input></td>
+ <td><input id="group-${perm.first}-read-checkbox" type="checkbox" name="read" disabled="disabled" #if ($perm.second.isPermissionNameSet("READ")) checked="true" #end></input></td>
+ <td><input id="group-${perm.first}-write-checkbox" type="checkbox" name="write" disabled="disabled" #if ($perm.second.isPermissionNameSet("WRITE")) checked="true" #end></input></td>
+ <td><input id="group-${perm.first}-execute-checkbox" type="checkbox" name="execute" disabled="disabled" #if ($perm.second.isPermissionNameSet("EXECUTE")) checked="true" #end></input></td>
+ <td><input id="group-${perm.first}-schedule-checkbox" type="checkbox" name="schedule" disabled="disabled" #if ($perm.second.isPermissionNameSet("SCHEDULE")) checked="true" #end></input></td>
+ #end
+
+ #if($isAdmin)
+ <td><button id="group-$perm.first" class="change-btn btn2">Change</button></td>
+ #end
+ </tr>
+#end
+#else
+ <tr><td class="last">No Groups Found.</td></tr>
#end
+ </tbody>
+ </table>
+#end
+
</div>
<div id="change-permission" class="modal">
- <h3 id="change-title">Change User Permissions</h3>
+ <h3 id="change-title">Change Permissions</h3>
<div id="errorMsg" class="box-error-message"></div>
<div class="message">
<fieldset>
diff --git a/src/java/azkaban/webapp/servlet/velocity/projectlogpage.vm b/src/java/azkaban/webapp/servlet/velocity/projectlogpage.vm
index 3fcad73..874f468 100644
--- a/src/java/azkaban/webapp/servlet/velocity/projectlogpage.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/projectlogpage.vm
@@ -23,6 +23,7 @@
<script type="text/javascript" src="${context}/js/underscore-1.2.1-min.js"></script>
<script type="text/javascript" src="${context}/js/backbone-0.5.3-min.js"></script>
<script type="text/javascript" src="${context}/js/jquery.simplemodal.js"></script>
+ <script type="text/javascript" src="${context}/js/azkaban.date.utils.js"></script>
<script type="text/javascript" src="${context}/js/azkaban.ajax.utils.js"></script>
<script type="text/javascript" src="${context}/js/azkaban.nav.js"></script>
<script type="text/javascript" src="${context}/js/azkaban.projectlog.view.js"></script>
@@ -65,8 +66,10 @@
<div id="projectLogView" class="logView">
<div class="logHeader"><div class="logButtonRow"><div id="updateLogBtn" class="btn7">Refresh</div></div></div>
- <div class="logViewer">
- <pre id="logSection" class="log"></pre>
+ <div id="logViewer" class="logViewer">
+ <table id="logTable">
+
+ </table>
</div>
</div>
#end
diff --git a/src/java/azkaban/webapp/servlet/velocity/projectpage.vm b/src/java/azkaban/webapp/servlet/velocity/projectpage.vm
index 81b7a51..46499a2 100644
--- a/src/java/azkaban/webapp/servlet/velocity/projectpage.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/projectpage.vm
@@ -73,8 +73,8 @@
<div id="project-summary">
<table class="summary-table">
<tr><td class="first">Name:</td><td>$project.name</td></tr>
- <tr><td class="first">Created Date:</td><td>$utils.formatDate($project.lastModifiedTimestamp)</td></tr>
- <tr><td class="first">Modified Date:</td><td>$utils.formatDate($project.createTimestamp)</td></tr>
+ <tr><td class="first">Created Date:</td><td>$utils.formatDate($project.createTimestamp)</td></tr>
+ <tr><td class="first">Modified Date:</td><td>$utils.formatDate($project.lastModifiedTimestamp)</td></tr>
<tr><td class="first">Modified by:</td><td>$project.lastModifiedUser</td></tr>
<tr><td class="first">Description:</td><td id="pdescription">$project.description</td>
#if($admin)
diff --git a/src/java/azkaban/webapp/servlet/velocity/scheduledflowpage.vm b/src/java/azkaban/webapp/servlet/velocity/scheduledflowpage.vm
index 398b3fd..09d387a 100644
--- a/src/java/azkaban/webapp/servlet/velocity/scheduledflowpage.vm
+++ b/src/java/azkaban/webapp/servlet/velocity/scheduledflowpage.vm
@@ -79,17 +79,17 @@
<tr class="row" >
<td class="tb-name">
- <a href="${context}/manager?project=${sched.projectId}&flow=${sched.flowId}">${sched.flowId}</a>
+ <a href="${context}/manager?project=${sched.projectName}&flow=${sched.flowName}">${sched.flowName}</a>
</td>
<td>
- <a href="${context}/manager?project=${sched.projectId}">${sched.projectId}</a>
+ <a href="${context}/manager?project=${sched.projectName}">${sched.projectName}</a>
</td>
- <td>${sched.user}</td>
- <td>${sched.userSubmit}</td>
+ <td>${sched.submitUser}</td>
+ <td>${sched.submitUser}</td>
<td>$utils.formatDateTime(${sched.firstSchedTime})</td>
<td>$utils.formatDateTime(${sched.nextExecTime})</td>
<td>$utils.formatPeriod(${sched.period})</td>
- <td><button id="removeSchedBtn" onclick="removeSched('${sched.scheduleId}')" >Remove Schedule</button></td>
+ <td><button id="removeSchedBtn" onclick="removeSched(${sched.projectId}, '${sched.flowName}')" >Remove Schedule</button></td>
</tr>
#end
#else
diff --git a/src/java/azkaban/webapp/session/Session.java b/src/java/azkaban/webapp/session/Session.java
index 570fe5d..d12b1f4 100644
--- a/src/java/azkaban/webapp/session/Session.java
+++ b/src/java/azkaban/webapp/session/Session.java
@@ -23,16 +23,18 @@ import azkaban.user.User;
public class Session {
private final User user;
private final String sessionId;
-
+ private final String ip;
+
/**
* Constructor for the session
*
* @param sessionId
* @param user
*/
- public Session(String sessionId, User user) {
+ public Session(String sessionId, User user, String ip) {
this.user = user;
this.sessionId = sessionId;
+ this.ip = ip;
}
/**
@@ -52,4 +54,8 @@ public class Session {
public String getSessionId() {
return sessionId;
}
+
+ public String getIp() {
+ return ip;
+ }
}
src/sql/create_active_flow.sql 7(+7 -0)
diff --git a/src/sql/create_active_flow.sql b/src/sql/create_active_flow.sql
new file mode 100644
index 0000000..f3a088c
--- /dev/null
+++ b/src/sql/create_active_flow.sql
@@ -0,0 +1,7 @@
+CREATE TABLE active_executing_flows (
+ exec_id INT,
+ host VARCHAR(255),
+ port INT,
+ update_time BIGINT,
+ PRIMARY KEY (exec_id)
+) ENGINE=InnoDB;
src/sql/create_execution_flow.sql 19(+19 -0)
diff --git a/src/sql/create_execution_flow.sql b/src/sql/create_execution_flow.sql
new file mode 100644
index 0000000..1d0ef8c
--- /dev/null
+++ b/src/sql/create_execution_flow.sql
@@ -0,0 +1,19 @@
+CREATE TABLE execution_flows (
+ exec_id INT NOT NULL AUTO_INCREMENT,
+ project_id INT NOT NULL,
+ version INT NOT NULL,
+ flow_id VARCHAR(128) NOT NULL,
+ status TINYINT,
+ submit_user VARCHAR(64),
+ submit_time BIGINT,
+ update_time BIGINT,
+ start_time BIGINT,
+ end_time BIGINT,
+ enc_type TINYINT,
+ flow_data LONGBLOB,
+ PRIMARY KEY (exec_id),
+ INDEX start_time (start_time),
+ INDEX end_time (end_time),
+ INDEX time_range (start_time, end_time),
+ INDEX (project_id, flow_id)
+) ENGINE=InnoDB;
src/sql/create_execution_job.sql 16(+16 -0)
diff --git a/src/sql/create_execution_job.sql b/src/sql/create_execution_job.sql
new file mode 100644
index 0000000..bcaf90a
--- /dev/null
+++ b/src/sql/create_execution_job.sql
@@ -0,0 +1,16 @@
+CREATE TABLE execution_jobs (
+ exec_id INT NOT NULL,
+ project_id INT NOT NULL,
+ version INT NOT NULL,
+ flow_id VARCHAR(128) NOT NULL,
+ job_id VARCHAR(128) NOT NULL,
+ start_time BIGINT,
+ end_time BIGINT,
+ status TINYINT,
+ input_params LONGBLOB,
+ output_params LONGBLOB,
+ attachments LONGBLOB,
+ PRIMARY KEY (exec_id, job_id),
+ INDEX exec_id (exec_id),
+ INDEX job_id (project_id, job_id)
+) ENGINE=InnoDB;
\ No newline at end of file
src/sql/create_execution_logs.sql 10(+10 -0)
diff --git a/src/sql/create_execution_logs.sql b/src/sql/create_execution_logs.sql
new file mode 100644
index 0000000..330d4b2
--- /dev/null
+++ b/src/sql/create_execution_logs.sql
@@ -0,0 +1,10 @@
+CREATE TABLE execution_logs (
+ exec_id INT NOT NULL,
+ name VARCHAR(128),
+ enc_type TINYINT,
+ start_byte INT,
+ end_byte INT,
+ log LONGBLOB,
+ INDEX log_index (exec_id, name),
+ INDEX byte_log_index(exec_id, name, start_byte, end_byte)
+) ENGINE=InnoDB;
diff --git a/src/sql/create_project_event_table.sql b/src/sql/create_project_event_table.sql
new file mode 100644
index 0000000..4cf8f21
--- /dev/null
+++ b/src/sql/create_project_event_table.sql
@@ -0,0 +1,8 @@
+CREATE TABLE project_events (
+ project_id INT NOT NULL,
+ event_type TINYINT NOT NULL,
+ event_time BIGINT NOT NULL,
+ username VARCHAR(64),
+ message VARCHAR(128),
+ INDEX log (project_id, event_time)
+) ENGINE=InnoDB;
src/sql/create_project_files.sql 9(+9 -0)
diff --git a/src/sql/create_project_files.sql b/src/sql/create_project_files.sql
new file mode 100644
index 0000000..a298f1b
--- /dev/null
+++ b/src/sql/create_project_files.sql
@@ -0,0 +1,9 @@
+CREATE TABLE project_files (
+ project_id INT NOT NULL,
+ version INT not NULL,
+ chunk INT,
+ size INT,
+ file LONGBLOB,
+ PRIMARY KEY (project_id, version, chunk),
+ INDEX file_version (project_id, version)
+) ENGINE=InnoDB;
src/sql/create_project_flow_table.sql 11(+11 -0)
diff --git a/src/sql/create_project_flow_table.sql b/src/sql/create_project_flow_table.sql
new file mode 100644
index 0000000..92fc758
--- /dev/null
+++ b/src/sql/create_project_flow_table.sql
@@ -0,0 +1,11 @@
+CREATE TABLE project_flows (
+ project_id INT NOT NULL,
+ version INT NOT NULL,
+ flow_id VARCHAR(128),
+ modified_time BIGINT NOT NULL,
+ encoding_type TINYINT,
+ json BLOB,
+ PRIMARY KEY (project_id, version, flow_id),
+ INDEX (project_id, version)
+) ENGINE=InnoDB;
+
diff --git a/src/sql/create_project_permissions.sql b/src/sql/create_project_permissions.sql
new file mode 100644
index 0000000..201e254
--- /dev/null
+++ b/src/sql/create_project_permissions.sql
@@ -0,0 +1,9 @@
+CREATE TABLE project_permissions (
+ project_id VARCHAR(64) NOT NULL,
+ modified_time BIGINT NOT NULL,
+ name VARCHAR(64) NOT NULL,
+ permissions INT NOT NULL,
+ isGroup BOOLEAN NOT NULL,
+ PRIMARY KEY (project_id, name),
+ INDEX project_id (project_id)
+) ENGINE=InnoDB;
src/sql/create_project_properties.sql 10(+10 -0)
diff --git a/src/sql/create_project_properties.sql b/src/sql/create_project_properties.sql
new file mode 100644
index 0000000..419c21c
--- /dev/null
+++ b/src/sql/create_project_properties.sql
@@ -0,0 +1,10 @@
+CREATE TABLE project_properties (
+ project_id INT NOT NULL,
+ version INT NOT NULL,
+ name VARCHAR(128),
+ modified_time BIGINT NOT NULL,
+ encoding_type TINYINT,
+ property BLOB,
+ PRIMARY KEY (project_id, version, name),
+ INDEX (project_id, version)
+) ENGINE=InnoDB;
\ No newline at end of file
src/sql/create_project_table.sql 12(+12 -0)
diff --git a/src/sql/create_project_table.sql b/src/sql/create_project_table.sql
new file mode 100644
index 0000000..e52fa76
--- /dev/null
+++ b/src/sql/create_project_table.sql
@@ -0,0 +1,12 @@
+CREATE TABLE projects (
+ id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ name VARCHAR(64) NOT NULL,
+ active BOOLEAN,
+ modified_time BIGINT NOT NULL,
+ create_time BIGINT NOT NULL,
+ version INT,
+ last_modified_by VARCHAR(64) NOT NULL,
+ description VARCHAR(255),
+ UNIQUE INDEX project_id (id),
+ INDEX project_name (name)
+) ENGINE=InnoDB;
src/sql/create_project_version_table.sql 12(+12 -0)
diff --git a/src/sql/create_project_version_table.sql b/src/sql/create_project_version_table.sql
new file mode 100644
index 0000000..5ca49dc
--- /dev/null
+++ b/src/sql/create_project_version_table.sql
@@ -0,0 +1,12 @@
+CREATE TABLE project_versions (
+ project_id INT NOT NULL,
+ version INT not NULL,
+ upload_time BIGINT NOT NULL,
+ uploader VARCHAR(64) NOT NULL,
+ file_type VARCHAR(16),
+ file_name VARCHAR(128),
+ md5 BINARY(16),
+ num_chunks INT,
+ PRIMARY KEY (project_id, version),
+ INDEX project_version_id (project_id)
+) ENGINE=InnoDB;
src/sql/create_schedule_table.sql 17(+17 -0)
diff --git a/src/sql/create_schedule_table.sql b/src/sql/create_schedule_table.sql
new file mode 100644
index 0000000..defadce
--- /dev/null
+++ b/src/sql/create_schedule_table.sql
@@ -0,0 +1,17 @@
+DROP TABLE if exists schedules;
+
+CREATE TABLE schedules (
+ project_id INT NOT NULL,
+ project_name VARCHAR(128) NOT NULL,
+ flow_name VARCHAR(128) NOT NULL,
+ status VARCHAR(16),
+ first_sched_time BIGINT,
+ timezone VARCHAR(64),
+ period VARCHAR(16),
+ last_modify_time BIGINT,
+ next_exec_time BIGINT,
+ submit_time BIGINT,
+ submit_user VARCHAR(128),
+ primary key(project_id, flow_name)
+) ENGINE=InnoDB;
+
src/web/css/azkaban.css 193(+191 -2)
diff --git a/src/web/css/azkaban.css b/src/web/css/azkaban.css
index 4603598..7c1aa97 100644
--- a/src/web/css/azkaban.css
+++ b/src/web/css/azkaban.css
@@ -1305,6 +1305,18 @@ tr:hover td {
font-size: 10pt;
}
+#logTable td.time {
+ width: 160px;
+}
+
+#logTable td.user {
+ width: 80px;
+}
+
+#logTable td.type {
+ width: 160px;
+}
+
.relative {
position: relative;
width: 100%;
@@ -1656,6 +1668,49 @@ table.parameters tr td {
text-align: center;
}
+#group-permissions-table {
+ margin-top: 20px;
+}
+
+.permission-table .tb-username {
+ margin: 0px;
+}
+
+.permission-table .tb-perm {
+ width: 60px;
+ margin: 0px;
+}
+
+.permission-table .tb-admin {
+ width: 60px;
+ margin: 0px;
+}
+
+.permission-table .tb-read {
+ width: 60px;
+ margin: 0px;
+}
+
+.permission-table .tb-write {
+ width: 60px;
+ margin: 0px;
+}
+
+.permission-table .tb-execute {
+ width: 60px;
+ margin: 0px;
+}
+
+.permission-table .tb-schedule {
+ margin: 0px;
+ width: 60px;
+}
+
+.permission-table .tb-action {
+ margin: 0px;
+ width: 100px;
+}
+
.permission-table thead tr th.tb-username {
padding-left: 15px;
text-align:left;
@@ -1898,6 +1953,11 @@ span.sublabel {
font-size: 12px;
}
+
+#flow-status table td.SKIPPED {
+ color: #AAA;
+}
+
#flow-status table td.SUCCEEDED {
color: #4e911e;
}
@@ -1931,7 +1991,7 @@ span.sublabel {
}
.executionInfo table th.execid {
- width: 150px;
+ width: 80px;
}
.executionInfo table th.project {
@@ -1969,8 +2029,12 @@ span.sublabel {
margin: 0px;
}
+.executionInfo table td.execId {
+ font-weight: bold;
+}
+
.executionInfo table td {
- padding-left: 6px;
+ padding-left: 3px;
height: 20px;
}
@@ -2130,6 +2194,131 @@ span .nowrap {
background: #E0E0E0;
}
+.comment {
+ font-size: 11pt;
+ margin: 0px 20px;
+}
+
+.comment-small {
+ font-size: 11pt;
+ margin: 0px 20px;
+}
+
+.admin {
+ margin: 20px;
+}
+
+.admin-panel {
+ border-top: 2px groove #FFF;
+ margin: 40px 5px;
+ padding-top: 10px;
+ padding-bottom: 10px;
+}
+
+.admin-panel label {
+ font-size: 10pt;
+}
+
+.admin-panel input[type="radio"] {
+ margin-left: 50px;
+}
+
+
+.admin-panel h3 {
+ font-size: 12pt;
+ font-weight: bold;
+ margin: 3px 30px;
+}
+
+.admin-setup-points {
+ font-size: 10pt;
+ margin: 8px 25px;
+ list-style-type: disc;
+}
+
+.upload {
+ margin: 10px 20px;
+}
+
+.upload fieldset {
+ float: left;
+}
+
+.upload a {
+ float: left;
+}
+
+.upload .installed {
+ float: left;
+ font-size: 9pt;
+ margin-left: 20px;
+}
+
+#upload-jar-btn {
+ float: left;
+}
+
+#dbconnection {
+ margin-left: 40px;
+}
+
+#dbconnection label {
+ font-size: 10pt;
+ width: 100px;
+}
+
+#dbconnection table {
+ margin-top: 5px;
+}
+
+#dbconnection table tr td{
+ padding: 0;
+ border-top: none;
+ border-right: none;
+}
+
+#dbconnection table tr td.left{
+ width: 100px;
+}
+
+#dbconnection table tr td.param{
+ width: 310px;
+}
+
+#dbconnection table tr td.desc{
+ text-align:left;
+ font-style: italic;
+}
+
+#dbconnection table tr td input{
+ width: 300px;
+}
+
+#save-connection-button {
+ float: left;
+ margin-top: 5px;
+}
+
+#save-results {
+ float: left;
+ font-size: 10pt;
+ padding-top: 10px;
+ padding-left: 20px;
+ padding-bottom: 10px;
+}
+
+#save-results .fail{
+ background-color: #FF0000;
+ color: #FFFFFF;
+}
+
+.block {
+ display: block;
+}
+
+.bold {
+ font-weight: bold;
+}
/* old styles */
.azkaban-charts .hitarea {
diff --git a/src/web/css/images/ui-bg_flat_0_aaaaaa_40x100.png b/src/web/css/images/ui-bg_flat_0_aaaaaa_40x100.png
new file mode 100644
index 0000000..5b5dab2
Binary files /dev/null and b/src/web/css/images/ui-bg_flat_0_aaaaaa_40x100.png differ
diff --git a/src/web/css/images/ui-bg_flat_75_ffffff_40x100.png b/src/web/css/images/ui-bg_flat_75_ffffff_40x100.png
new file mode 100644
index 0000000..ac8b229
Binary files /dev/null and b/src/web/css/images/ui-bg_flat_75_ffffff_40x100.png differ
diff --git a/src/web/css/images/ui-bg_glass_55_fbf9ee_1x400.png b/src/web/css/images/ui-bg_glass_55_fbf9ee_1x400.png
new file mode 100644
index 0000000..ad3d634
Binary files /dev/null and b/src/web/css/images/ui-bg_glass_55_fbf9ee_1x400.png differ
diff --git a/src/web/css/images/ui-bg_glass_65_ffffff_1x400.png b/src/web/css/images/ui-bg_glass_65_ffffff_1x400.png
new file mode 100644
index 0000000..42ccba2
Binary files /dev/null and b/src/web/css/images/ui-bg_glass_65_ffffff_1x400.png differ
diff --git a/src/web/css/images/ui-bg_glass_75_dadada_1x400.png b/src/web/css/images/ui-bg_glass_75_dadada_1x400.png
new file mode 100644
index 0000000..5a46b47
Binary files /dev/null and b/src/web/css/images/ui-bg_glass_75_dadada_1x400.png differ
diff --git a/src/web/css/images/ui-bg_glass_75_e6e6e6_1x400.png b/src/web/css/images/ui-bg_glass_75_e6e6e6_1x400.png
new file mode 100644
index 0000000..86c2baa
Binary files /dev/null and b/src/web/css/images/ui-bg_glass_75_e6e6e6_1x400.png differ
diff --git a/src/web/css/images/ui-bg_glass_95_fef1ec_1x400.png b/src/web/css/images/ui-bg_glass_95_fef1ec_1x400.png
new file mode 100644
index 0000000..8f28bc9
Binary files /dev/null and b/src/web/css/images/ui-bg_glass_95_fef1ec_1x400.png differ
diff --git a/src/web/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/src/web/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png
new file mode 100644
index 0000000..7c9fa6c
Binary files /dev/null and b/src/web/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png differ
diff --git a/src/web/css/images/ui-icons_222222_256x240.png b/src/web/css/images/ui-icons_222222_256x240.png
new file mode 100644
index 0000000..b273ff1
Binary files /dev/null and b/src/web/css/images/ui-icons_222222_256x240.png differ
diff --git a/src/web/css/images/ui-icons_2e83ff_256x240.png b/src/web/css/images/ui-icons_2e83ff_256x240.png
new file mode 100644
index 0000000..84defe6
Binary files /dev/null and b/src/web/css/images/ui-icons_2e83ff_256x240.png differ
diff --git a/src/web/css/images/ui-icons_454545_256x240.png b/src/web/css/images/ui-icons_454545_256x240.png
new file mode 100644
index 0000000..59bd45b
Binary files /dev/null and b/src/web/css/images/ui-icons_454545_256x240.png differ
diff --git a/src/web/css/images/ui-icons_888888_256x240.png b/src/web/css/images/ui-icons_888888_256x240.png
new file mode 100644
index 0000000..6d02426
Binary files /dev/null and b/src/web/css/images/ui-icons_888888_256x240.png differ
diff --git a/src/web/css/images/ui-icons_cd0a0a_256x240.png b/src/web/css/images/ui-icons_cd0a0a_256x240.png
new file mode 100644
index 0000000..2ab019b
Binary files /dev/null and b/src/web/css/images/ui-icons_cd0a0a_256x240.png differ
src/web/css/jquery-ui.css 473(+473 -0)
diff --git a/src/web/css/jquery-ui.css b/src/web/css/jquery-ui.css
new file mode 100644
index 0000000..cdab8a4
--- /dev/null
+++ b/src/web/css/jquery-ui.css
@@ -0,0 +1,473 @@
+/*! jQuery UI - v1.9.1 - 2012-10-25
+* http://jqueryui.com
+* Includes: jquery.ui.core.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css, jquery.ui.theme.css
+* Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */
+
+/* Layout helpers
+----------------------------------*/
+.ui-helper-hidden { display: none; }
+.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
+.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
+.ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; }
+.ui-helper-clearfix:after { clear: both; }
+.ui-helper-clearfix { zoom: 1; }
+.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
+
+
+/* Interaction Cues
+----------------------------------*/
+.ui-state-disabled { cursor: default !important; }
+
+
+/* Icons
+----------------------------------*/
+
+/* states and images */
+.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
+
+
+/* Misc visuals
+----------------------------------*/
+
+/* Overlays */
+.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
+
+.ui-accordion .ui-accordion-header { display: block; cursor: pointer; position: relative; margin-top: 2px; padding: .5em .5em .5em .7em; zoom: 1; }
+.ui-accordion .ui-accordion-icons { padding-left: 2.2em; }
+.ui-accordion .ui-accordion-noicons { padding-left: .7em; }
+.ui-accordion .ui-accordion-icons .ui-accordion-icons { padding-left: 2.2em; }
+.ui-accordion .ui-accordion-header .ui-accordion-header-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
+.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; overflow: auto; zoom: 1; }
+
+.ui-autocomplete {
+ position: absolute;
+ top: 0; /* #8656 */
+ cursor: default;
+}
+
+/* workarounds */
+* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
+
+.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */
+.ui-button, .ui-button:link, .ui-button:visited, .ui-button:hover, .ui-button:active { text-decoration: none; }
+.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
+button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
+.ui-button-icons-only { width: 3.4em; }
+button.ui-button-icons-only { width: 3.7em; }
+
+/*button text element */
+.ui-button .ui-button-text { display: block; line-height: 1.4; }
+.ui-button-text-only .ui-button-text { padding: .4em 1em; }
+.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; }
+.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; }
+.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; }
+.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; }
+/* no icon support for input elements, provide padding by default */
+input.ui-button { padding: .4em 1em; }
+
+/*button icon element(s) */
+.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; }
+.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; }
+.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; }
+.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
+.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
+
+/*button sets*/
+.ui-buttonset { margin-right: 7px; }
+.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; }
+
+/* workarounds */
+button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */
+
+.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
+.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
+.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
+.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
+.ui-datepicker .ui-datepicker-prev { left:2px; }
+.ui-datepicker .ui-datepicker-next { right:2px; }
+.ui-datepicker .ui-datepicker-prev-hover { left:1px; }
+.ui-datepicker .ui-datepicker-next-hover { right:1px; }
+.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
+.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
+.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
+.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
+.ui-datepicker select.ui-datepicker-month,
+.ui-datepicker select.ui-datepicker-year { width: 49%;}
+.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
+.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
+.ui-datepicker td { border: 0; padding: 1px; }
+.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
+.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
+.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
+.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
+
+/* with multiple calendars */
+.ui-datepicker.ui-datepicker-multi { width:auto; }
+.ui-datepicker-multi .ui-datepicker-group { float:left; }
+.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
+.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
+.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
+.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
+.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
+.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
+.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
+.ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
+
+/* RTL support */
+.ui-datepicker-rtl { direction: rtl; }
+.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
+.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
+.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
+.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
+.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
+.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
+.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
+.ui-datepicker-rtl .ui-datepicker-group { float:right; }
+.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
+.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
+
+/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
+.ui-datepicker-cover {
+ position: absolute; /*must have*/
+ z-index: -1; /*must have*/
+ filter: mask(); /*must have*/
+ top: -4px; /*must have*/
+ left: -4px; /*must have*/
+ width: 200px; /*must have*/
+ height: 200px; /*must have*/
+}
+.ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
+.ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; }
+.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
+.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
+.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
+.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
+.ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; }
+.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
+.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; }
+.ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; }
+.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; }
+.ui-draggable .ui-dialog-titlebar { cursor: move; }
+
+.ui-menu { list-style:none; padding: 2px; margin: 0; display:block; outline: none; }
+.ui-menu .ui-menu { margin-top: -3px; position: absolute; }
+.ui-menu .ui-menu-item { margin: 0; padding: 0; zoom: 1; width: 100%; }
+.ui-menu .ui-menu-divider { margin: 5px -2px 5px -2px; height: 0; font-size: 0; line-height: 0; border-width: 1px 0 0 0; }
+.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; }
+.ui-menu .ui-menu-item a.ui-state-focus,
+.ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; }
+
+.ui-menu .ui-state-disabled { font-weight: normal; margin: .4em 0 .2em; line-height: 1.5; }
+.ui-menu .ui-state-disabled a { cursor: default; }
+
+/* icon support */
+.ui-menu-icons { position: relative; }
+.ui-menu-icons .ui-menu-item a { position: relative; padding-left: 2em; }
+
+/* left-aligned */
+.ui-menu .ui-icon { position: absolute; top: .2em; left: .2em; }
+
+/* right-aligned */
+.ui-menu .ui-menu-icon { position: static; float: right; }
+
+.ui-progressbar { height:2em; text-align: left; overflow: hidden; }
+.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
+.ui-resizable { position: relative;}
+.ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; }
+.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
+.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
+.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
+.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
+.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
+.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
+.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
+.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
+.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}
+.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; }
+
+.ui-slider { position: relative; text-align: left; }
+.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
+.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
+
+.ui-slider-horizontal { height: .8em; }
+.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
+.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
+.ui-slider-horizontal .ui-slider-range-min { left: 0; }
+.ui-slider-horizontal .ui-slider-range-max { right: 0; }
+
+.ui-slider-vertical { width: .8em; height: 100px; }
+.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
+.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
+.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
+.ui-slider-vertical .ui-slider-range-max { top: 0; }
+.ui-spinner { position:relative; display: inline-block; overflow: hidden; padding: 0; vertical-align: middle; }
+.ui-spinner-input { border: none; background: none; padding: 0; margin: .2em 0; vertical-align: middle; margin-left: .4em; margin-right: 22px; }
+.ui-spinner-button { width: 16px; height: 50%; font-size: .5em; padding: 0; margin: 0; text-align: center; position: absolute; cursor: default; display: block; overflow: hidden; right: 0; }
+.ui-spinner a.ui-spinner-button { border-top: none; border-bottom: none; border-right: none; } /* more specificity required here to overide default borders */
+.ui-spinner .ui-icon { position: absolute; margin-top: -8px; top: 50%; left: 0; } /* vertical centre icon */
+.ui-spinner-up { top: 0; }
+.ui-spinner-down { bottom: 0; }
+
+/* TR overrides */
+.ui-spinner .ui-icon-triangle-1-s {
+ /* need to fix icons sprite */
+ background-position:-65px -16px;
+}
+
+.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
+.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; }
+.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 0; margin: 1px .2em 0 0; border-bottom: 0; padding: 0; white-space: nowrap; }
+.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; }
+.ui-tabs .ui-tabs-nav li.ui-tabs-active { margin-bottom: -1px; padding-bottom: 1px; }
+.ui-tabs .ui-tabs-nav li.ui-tabs-active a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-tabs-loading a { cursor: text; }
+.ui-tabs .ui-tabs-nav li a, .ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
+.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; }
+
+.ui-tooltip {
+ padding: 8px;
+ position: absolute;
+ z-index: 9999;
+ max-width: 300px;
+ -webkit-box-shadow: 0 0 5px #aaa;
+ box-shadow: 0 0 5px #aaa;
+}
+/* Fades and background-images don't work well together in IE6, drop the image */
+* html .ui-tooltip {
+ background-image: none;
+}
+body .ui-tooltip { border-width: 2px; }
+
+/* Component containers
+----------------------------------*/
+.ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; }
+.ui-widget .ui-widget { font-size: 1em; }
+.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; }
+.ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; }
+.ui-widget-content a { color: #222222; }
+.ui-widget-header { border: 1px solid #aaaaaa; background: #cccccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; }
+.ui-widget-header a { color: #222222; }
+
+/* Interaction states
+----------------------------------*/
+.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3; background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #555555; }
+.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #555555; text-decoration: none; }
+.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
+.ui-state-hover a, .ui-state-hover a:hover, .ui-state-hover a:link, .ui-state-hover a:visited { color: #212121; text-decoration: none; }
+.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
+.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #212121; text-decoration: none; }
+
+/* Interaction Cues
+----------------------------------*/
+.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1; background: #fbf9ee url(images/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x; color: #363636; }
+.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; }
+.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; }
+.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a; }
+.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a; }
+.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
+.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
+.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
+.ui-state-disabled .ui-icon { filter:Alpha(Opacity=35); } /* For IE8 - See #6059 */
+
+/* Icons
+----------------------------------*/
+
+/* states and images */
+.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
+.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
+.ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
+.ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png); }
+.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
+.ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
+.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); }
+.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); }
+
+/* positioning */
+.ui-icon-carat-1-n { background-position: 0 0; }
+.ui-icon-carat-1-ne { background-position: -16px 0; }
+.ui-icon-carat-1-e { background-position: -32px 0; }
+.ui-icon-carat-1-se { background-position: -48px 0; }
+.ui-icon-carat-1-s { background-position: -64px 0; }
+.ui-icon-carat-1-sw { background-position: -80px 0; }
+.ui-icon-carat-1-w { background-position: -96px 0; }
+.ui-icon-carat-1-nw { background-position: -112px 0; }
+.ui-icon-carat-2-n-s { background-position: -128px 0; }
+.ui-icon-carat-2-e-w { background-position: -144px 0; }
+.ui-icon-triangle-1-n { background-position: 0 -16px; }
+.ui-icon-triangle-1-ne { background-position: -16px -16px; }
+.ui-icon-triangle-1-e { background-position: -32px -16px; }
+.ui-icon-triangle-1-se { background-position: -48px -16px; }
+.ui-icon-triangle-1-s { background-position: -64px -16px; }
+.ui-icon-triangle-1-sw { background-position: -80px -16px; }
+.ui-icon-triangle-1-w { background-position: -96px -16px; }
+.ui-icon-triangle-1-nw { background-position: -112px -16px; }
+.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
+.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
+.ui-icon-arrow-1-n { background-position: 0 -32px; }
+.ui-icon-arrow-1-ne { background-position: -16px -32px; }
+.ui-icon-arrow-1-e { background-position: -32px -32px; }
+.ui-icon-arrow-1-se { background-position: -48px -32px; }
+.ui-icon-arrow-1-s { background-position: -64px -32px; }
+.ui-icon-arrow-1-sw { background-position: -80px -32px; }
+.ui-icon-arrow-1-w { background-position: -96px -32px; }
+.ui-icon-arrow-1-nw { background-position: -112px -32px; }
+.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
+.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
+.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
+.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
+.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
+.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
+.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
+.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
+.ui-icon-arrowthick-1-n { background-position: 0 -48px; }
+.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
+.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
+.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
+.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
+.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
+.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
+.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
+.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
+.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
+.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
+.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
+.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
+.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
+.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
+.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
+.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
+.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
+.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
+.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
+.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
+.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
+.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
+.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
+.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
+.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
+.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
+.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
+.ui-icon-arrow-4 { background-position: 0 -80px; }
+.ui-icon-arrow-4-diag { background-position: -16px -80px; }
+.ui-icon-extlink { background-position: -32px -80px; }
+.ui-icon-newwin { background-position: -48px -80px; }
+.ui-icon-refresh { background-position: -64px -80px; }
+.ui-icon-shuffle { background-position: -80px -80px; }
+.ui-icon-transfer-e-w { background-position: -96px -80px; }
+.ui-icon-transferthick-e-w { background-position: -112px -80px; }
+.ui-icon-folder-collapsed { background-position: 0 -96px; }
+.ui-icon-folder-open { background-position: -16px -96px; }
+.ui-icon-document { background-position: -32px -96px; }
+.ui-icon-document-b { background-position: -48px -96px; }
+.ui-icon-note { background-position: -64px -96px; }
+.ui-icon-mail-closed { background-position: -80px -96px; }
+.ui-icon-mail-open { background-position: -96px -96px; }
+.ui-icon-suitcase { background-position: -112px -96px; }
+.ui-icon-comment { background-position: -128px -96px; }
+.ui-icon-person { background-position: -144px -96px; }
+.ui-icon-print { background-position: -160px -96px; }
+.ui-icon-trash { background-position: -176px -96px; }
+.ui-icon-locked { background-position: -192px -96px; }
+.ui-icon-unlocked { background-position: -208px -96px; }
+.ui-icon-bookmark { background-position: -224px -96px; }
+.ui-icon-tag { background-position: -240px -96px; }
+.ui-icon-home { background-position: 0 -112px; }
+.ui-icon-flag { background-position: -16px -112px; }
+.ui-icon-calendar { background-position: -32px -112px; }
+.ui-icon-cart { background-position: -48px -112px; }
+.ui-icon-pencil { background-position: -64px -112px; }
+.ui-icon-clock { background-position: -80px -112px; }
+.ui-icon-disk { background-position: -96px -112px; }
+.ui-icon-calculator { background-position: -112px -112px; }
+.ui-icon-zoomin { background-position: -128px -112px; }
+.ui-icon-zoomout { background-position: -144px -112px; }
+.ui-icon-search { background-position: -160px -112px; }
+.ui-icon-wrench { background-position: -176px -112px; }
+.ui-icon-gear { background-position: -192px -112px; }
+.ui-icon-heart { background-position: -208px -112px; }
+.ui-icon-star { background-position: -224px -112px; }
+.ui-icon-link { background-position: -240px -112px; }
+.ui-icon-cancel { background-position: 0 -128px; }
+.ui-icon-plus { background-position: -16px -128px; }
+.ui-icon-plusthick { background-position: -32px -128px; }
+.ui-icon-minus { background-position: -48px -128px; }
+.ui-icon-minusthick { background-position: -64px -128px; }
+.ui-icon-close { background-position: -80px -128px; }
+.ui-icon-closethick { background-position: -96px -128px; }
+.ui-icon-key { background-position: -112px -128px; }
+.ui-icon-lightbulb { background-position: -128px -128px; }
+.ui-icon-scissors { background-position: -144px -128px; }
+.ui-icon-clipboard { background-position: -160px -128px; }
+.ui-icon-copy { background-position: -176px -128px; }
+.ui-icon-contact { background-position: -192px -128px; }
+.ui-icon-image { background-position: -208px -128px; }
+.ui-icon-video { background-position: -224px -128px; }
+.ui-icon-script { background-position: -240px -128px; }
+.ui-icon-alert { background-position: 0 -144px; }
+.ui-icon-info { background-position: -16px -144px; }
+.ui-icon-notice { background-position: -32px -144px; }
+.ui-icon-help { background-position: -48px -144px; }
+.ui-icon-check { background-position: -64px -144px; }
+.ui-icon-bullet { background-position: -80px -144px; }
+.ui-icon-radio-on { background-position: -96px -144px; }
+.ui-icon-radio-off { background-position: -112px -144px; }
+.ui-icon-pin-w { background-position: -128px -144px; }
+.ui-icon-pin-s { background-position: -144px -144px; }
+.ui-icon-play { background-position: 0 -160px; }
+.ui-icon-pause { background-position: -16px -160px; }
+.ui-icon-seek-next { background-position: -32px -160px; }
+.ui-icon-seek-prev { background-position: -48px -160px; }
+.ui-icon-seek-end { background-position: -64px -160px; }
+.ui-icon-seek-start { background-position: -80px -160px; }
+/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
+.ui-icon-seek-first { background-position: -80px -160px; }
+.ui-icon-stop { background-position: -96px -160px; }
+.ui-icon-eject { background-position: -112px -160px; }
+.ui-icon-volume-off { background-position: -128px -160px; }
+.ui-icon-volume-on { background-position: -144px -160px; }
+.ui-icon-power { background-position: 0 -176px; }
+.ui-icon-signal-diag { background-position: -16px -176px; }
+.ui-icon-signal { background-position: -32px -176px; }
+.ui-icon-battery-0 { background-position: -48px -176px; }
+.ui-icon-battery-1 { background-position: -64px -176px; }
+.ui-icon-battery-2 { background-position: -80px -176px; }
+.ui-icon-battery-3 { background-position: -96px -176px; }
+.ui-icon-circle-plus { background-position: 0 -192px; }
+.ui-icon-circle-minus { background-position: -16px -192px; }
+.ui-icon-circle-close { background-position: -32px -192px; }
+.ui-icon-circle-triangle-e { background-position: -48px -192px; }
+.ui-icon-circle-triangle-s { background-position: -64px -192px; }
+.ui-icon-circle-triangle-w { background-position: -80px -192px; }
+.ui-icon-circle-triangle-n { background-position: -96px -192px; }
+.ui-icon-circle-arrow-e { background-position: -112px -192px; }
+.ui-icon-circle-arrow-s { background-position: -128px -192px; }
+.ui-icon-circle-arrow-w { background-position: -144px -192px; }
+.ui-icon-circle-arrow-n { background-position: -160px -192px; }
+.ui-icon-circle-zoomin { background-position: -176px -192px; }
+.ui-icon-circle-zoomout { background-position: -192px -192px; }
+.ui-icon-circle-check { background-position: -208px -192px; }
+.ui-icon-circlesmall-plus { background-position: 0 -208px; }
+.ui-icon-circlesmall-minus { background-position: -16px -208px; }
+.ui-icon-circlesmall-close { background-position: -32px -208px; }
+.ui-icon-squaresmall-plus { background-position: -48px -208px; }
+.ui-icon-squaresmall-minus { background-position: -64px -208px; }
+.ui-icon-squaresmall-close { background-position: -80px -208px; }
+.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
+.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
+.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
+.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
+.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
+.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
+
+
+/* Misc visuals
+----------------------------------*/
+
+/* Corner radius */
+.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; }
+.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; }
+.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }
+.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
+
+/* Overlays */
+.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .3;filter:Alpha(Opacity=30); }
+.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .3;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -khtml-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }
\ No newline at end of file
src/web/css/jquery-ui-1.9.2.custom.css 462(+462 -0)
diff --git a/src/web/css/jquery-ui-1.9.2.custom.css b/src/web/css/jquery-ui-1.9.2.custom.css
new file mode 100644
index 0000000..f685567
--- /dev/null
+++ b/src/web/css/jquery-ui-1.9.2.custom.css
@@ -0,0 +1,462 @@
+/*! jQuery UI - v1.9.2 - 2012-12-13
+* http://jqueryui.com
+* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css
+* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana%2CArial%2Csans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=cccccc&bgTextureHeader=03_highlight_soft.png&bgImgOpacityHeader=75&borderColorHeader=aaaaaa&fcHeader=222222&iconColorHeader=222222&bgColorContent=ffffff&bgTextureContent=01_flat.png&bgImgOpacityContent=75&borderColorContent=aaaaaa&fcContent=222222&iconColorContent=222222&bgColorDefault=e6e6e6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=75&borderColorDefault=d3d3d3&fcDefault=555555&iconColorDefault=888888&bgColorHover=dadada&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=999999&fcHover=212121&iconColorHover=454545&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=aaaaaa&fcActive=212121&iconColorActive=454545&bgColorHighlight=fbf9ee&bgTextureHighlight=02_glass.png&bgImgOpacityHighlight=55&borderColorHighlight=fcefa1&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px
+* Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */
+
+/* Layout helpers
+----------------------------------*/
+.ui-helper-hidden { display: none; }
+.ui-helper-hidden-accessible { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }
+.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
+.ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; }
+.ui-helper-clearfix:after { clear: both; }
+.ui-helper-clearfix { zoom: 1; }
+.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
+
+
+/* Interaction Cues
+----------------------------------*/
+.ui-state-disabled { cursor: default !important; }
+
+
+/* Icons
+----------------------------------*/
+
+/* states and images */
+.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
+
+
+/* Misc visuals
+----------------------------------*/
+
+/* Overlays */
+.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
+.ui-resizable { position: relative;}
+.ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; }
+.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
+.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
+.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
+.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
+.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
+.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
+.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
+.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
+.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; }
+.ui-accordion .ui-accordion-header { display: block; cursor: pointer; position: relative; margin-top: 2px; padding: .5em .5em .5em .7em; zoom: 1; }
+.ui-accordion .ui-accordion-icons { padding-left: 2.2em; }
+.ui-accordion .ui-accordion-noicons { padding-left: .7em; }
+.ui-accordion .ui-accordion-icons .ui-accordion-icons { padding-left: 2.2em; }
+.ui-accordion .ui-accordion-header .ui-accordion-header-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
+.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; overflow: auto; zoom: 1; }
+.ui-autocomplete {
+ position: absolute;
+ top: 0;
+ left: 0;
+ cursor: default;
+}
+
+/* workarounds */
+* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
+.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */
+.ui-button, .ui-button:link, .ui-button:visited, .ui-button:hover, .ui-button:active { text-decoration: none; }
+.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
+button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
+.ui-button-icons-only { width: 3.4em; }
+button.ui-button-icons-only { width: 3.7em; }
+
+/*button text element */
+.ui-button .ui-button-text { display: block; line-height: 1.4; }
+.ui-button-text-only .ui-button-text { padding: .4em 1em; }
+.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; }
+.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; }
+.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; }
+.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; }
+/* no icon support for input elements, provide padding by default */
+input.ui-button { padding: .4em 1em; }
+
+/*button icon element(s) */
+.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; }
+.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; }
+.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; }
+.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
+.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
+
+/*button sets*/
+.ui-buttonset { margin-right: 7px; }
+.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; }
+
+/* workarounds */
+button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */
+.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
+.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
+.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
+.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
+.ui-datepicker .ui-datepicker-prev { left:2px; }
+.ui-datepicker .ui-datepicker-next { right:2px; }
+.ui-datepicker .ui-datepicker-prev-hover { left:1px; }
+.ui-datepicker .ui-datepicker-next-hover { right:1px; }
+.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
+.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
+.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
+.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
+.ui-datepicker select.ui-datepicker-month,
+.ui-datepicker select.ui-datepicker-year { width: 49%;}
+.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
+.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
+.ui-datepicker td { border: 0; padding: 1px; }
+.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
+.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
+.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
+.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
+
+/* with multiple calendars */
+.ui-datepicker.ui-datepicker-multi { width:auto; }
+.ui-datepicker-multi .ui-datepicker-group { float:left; }
+.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
+.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
+.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
+.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
+.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
+.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
+.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
+.ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
+
+/* RTL support */
+.ui-datepicker-rtl { direction: rtl; }
+.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
+.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
+.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
+.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
+.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
+.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
+.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
+.ui-datepicker-rtl .ui-datepicker-group { float:right; }
+.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
+.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
+
+/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
+.ui-datepicker-cover {
+ position: absolute; /*must have*/
+ z-index: -1; /*must have*/
+ filter: mask(); /*must have*/
+ top: -4px; /*must have*/
+ left: -4px; /*must have*/
+ width: 200px; /*must have*/
+ height: 200px; /*must have*/
+}.ui-dialog { position: absolute; top: 0; left: 0; padding: .2em; width: 300px; overflow: hidden; }
+.ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; }
+.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
+.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
+.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
+.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
+.ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; }
+.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
+.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; }
+.ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; }
+.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; }
+.ui-draggable .ui-dialog-titlebar { cursor: move; }
+.ui-menu { list-style:none; padding: 2px; margin: 0; display:block; outline: none; }
+.ui-menu .ui-menu { margin-top: -3px; position: absolute; }
+.ui-menu .ui-menu-item { margin: 0; padding: 0; zoom: 1; width: 100%; }
+.ui-menu .ui-menu-divider { margin: 5px -2px 5px -2px; height: 0; font-size: 0; line-height: 0; border-width: 1px 0 0 0; }
+.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; }
+.ui-menu .ui-menu-item a.ui-state-focus,
+.ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; }
+
+.ui-menu .ui-state-disabled { font-weight: normal; margin: .4em 0 .2em; line-height: 1.5; }
+.ui-menu .ui-state-disabled a { cursor: default; }
+
+/* icon support */
+.ui-menu-icons { position: relative; }
+.ui-menu-icons .ui-menu-item a { position: relative; padding-left: 2em; }
+
+/* left-aligned */
+.ui-menu .ui-icon { position: absolute; top: .2em; left: .2em; }
+
+/* right-aligned */
+.ui-menu .ui-menu-icon { position: static; float: right; }
+.ui-progressbar { height:2em; text-align: left; overflow: hidden; }
+.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }.ui-slider { position: relative; text-align: left; }
+.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
+.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
+
+.ui-slider-horizontal { height: .8em; }
+.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
+.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
+.ui-slider-horizontal .ui-slider-range-min { left: 0; }
+.ui-slider-horizontal .ui-slider-range-max { right: 0; }
+
+.ui-slider-vertical { width: .8em; height: 100px; }
+.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
+.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
+.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
+.ui-slider-vertical .ui-slider-range-max { top: 0; }.ui-spinner { position:relative; display: inline-block; overflow: hidden; padding: 0; vertical-align: middle; }
+.ui-spinner-input { border: none; background: none; padding: 0; margin: .2em 0; vertical-align: middle; margin-left: .4em; margin-right: 22px; }
+.ui-spinner-button { width: 16px; height: 50%; font-size: .5em; padding: 0; margin: 0; text-align: center; position: absolute; cursor: default; display: block; overflow: hidden; right: 0; }
+.ui-spinner a.ui-spinner-button { border-top: none; border-bottom: none; border-right: none; } /* more specificity required here to overide default borders */
+.ui-spinner .ui-icon { position: absolute; margin-top: -8px; top: 50%; left: 0; } /* vertical centre icon */
+.ui-spinner-up { top: 0; }
+.ui-spinner-down { bottom: 0; }
+
+/* TR overrides */
+.ui-spinner .ui-icon-triangle-1-s {
+ /* need to fix icons sprite */
+ background-position:-65px -16px;
+}
+.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
+.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; }
+.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 0; margin: 1px .2em 0 0; border-bottom: 0; padding: 0; white-space: nowrap; }
+.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; }
+.ui-tabs .ui-tabs-nav li.ui-tabs-active { margin-bottom: -1px; padding-bottom: 1px; }
+.ui-tabs .ui-tabs-nav li.ui-tabs-active a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-tabs-loading a { cursor: text; }
+.ui-tabs .ui-tabs-nav li a, .ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
+.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; }
+.ui-tooltip {
+ padding: 8px;
+ position: absolute;
+ z-index: 9999;
+ max-width: 300px;
+ -webkit-box-shadow: 0 0 5px #aaa;
+ box-shadow: 0 0 5px #aaa;
+}
+/* Fades and background-images don't work well together in IE6, drop the image */
+* html .ui-tooltip {
+ background-image: none;
+}
+body .ui-tooltip { border-width: 2px; }
+
+/* Component containers
+----------------------------------*/
+jqueryui .ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; }
+jqueryui .ui-widget .ui-widget { font-size: 1em; }
+jqueryui .ui-widget input, jqueryui .ui-widget select, jqueryui .ui-widget textarea, jqueryui .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; }
+jqueryui .ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x; color: #222222; }
+jqueryui .ui-widget-content a { color: #222222; }
+jqueryui .ui-widget-header { border: 1px solid #aaaaaa; background: #cccccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; }
+jqueryui .ui-widget-header a { color: #222222; }
+
+/* Interaction states
+----------------------------------*/
+jqueryui .ui-state-default, jqueryui .ui-widget-content .ui-state-default, jqueryui .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3; background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #555555; }
+jqueryui .ui-state-default a, jqueryui .ui-state-default a:link, jqueryui .ui-state-default a:visited { color: #555555; text-decoration: none; }
+jqueryui .ui-state-hover, jqueryui .ui-widget-content .ui-state-hover, jqueryui .ui-widget-header .ui-state-hover, jqueryui .ui-state-focus, jqueryui .ui-widget-content .ui-state-focus, jqueryui .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
+jqueryui .ui-state-hover a, jqueryui .ui-state-hover a:hover, jqueryui .ui-state-hover a:link, jqueryui .ui-state-hover a:visited { color: #212121; text-decoration: none; }
+jqueryui .ui-state-active, jqueryui .ui-widget-content .ui-state-active, jqueryui .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; }
+jqueryui .ui-state-active a, jqueryui .ui-state-active a:link, jqueryui .ui-state-active a:visited { color: #212121; text-decoration: none; }
+
+/* Interaction Cues
+----------------------------------*/
+jqueryui .ui-state-highlight, jqueryui .ui-widget-content .ui-state-highlight, jqueryui .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1; background: #fbf9ee url(images/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x; color: #363636; }
+jqueryui .ui-state-highlight a, jqueryui .ui-widget-content .ui-state-highlight a,jqueryui .ui-widget-header .ui-state-highlight a { color: #363636; }
+jqueryui .ui-state-error, jqueryui .ui-widget-content .ui-state-error, jqueryui .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; }
+jqueryui .ui-state-error a, jqueryui .ui-widget-content .ui-state-error a, jqueryui .ui-widget-header .ui-state-error a { color: #cd0a0a; }
+jqueryui .ui-state-error-text, jqueryui .ui-widget-content .ui-state-error-text, jqueryui .ui-widget-header .ui-state-error-text { color: #cd0a0a; }
+jqueryui .ui-priority-primary, jqueryui .ui-widget-content .ui-priority-primary, jqueryui .ui-widget-header .ui-priority-primary { font-weight: bold; }
+jqueryui .ui-priority-secondary, jqueryui .ui-widget-content .ui-priority-secondary, jqueryui .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
+jqueryui .ui-state-disabled, jqueryui .ui-widget-content .ui-state-disabled, jqueryui .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
+jqueryui .ui-state-disabled .ui-icon { filter:Alpha(Opacity=35); } /* For IE8 - See #6059 */
+
+/* Icons
+----------------------------------*/
+
+/* states and images */
+jqueryui .ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
+jqueryui .ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
+jqueryui .ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
+jqueryui .ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png); }
+jqueryui .ui-state-hover .ui-icon, jqueryui .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
+jqueryui .ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); }
+jqueryui .ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); }
+jqueryui .ui-state-error .ui-icon, jqueryui .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); }
+
+/* positioning */
+jqueryui .ui-icon-carat-1-n { background-position: 0 0; }
+jqueryui .ui-icon-carat-1-ne { background-position: -16px 0; }
+jqueryui .ui-icon-carat-1-e { background-position: -32px 0; }
+jqueryui .ui-icon-carat-1-se { background-position: -48px 0; }
+jqueryui .ui-icon-carat-1-s { background-position: -64px 0; }
+jqueryui .ui-icon-carat-1-sw { background-position: -80px 0; }
+jqueryui .ui-icon-carat-1-w { background-position: -96px 0; }
+jqueryui .ui-icon-carat-1-nw { background-position: -112px 0; }
+jqueryui .ui-icon-carat-2-n-s { background-position: -128px 0; }
+jqueryui .ui-icon-carat-2-e-w { background-position: -144px 0; }
+jqueryui .ui-icon-triangle-1-n { background-position: 0 -16px; }
+jqueryui .ui-icon-triangle-1-ne { background-position: -16px -16px; }
+jqueryui .ui-icon-triangle-1-e { background-position: -32px -16px; }
+jqueryui .ui-icon-triangle-1-se { background-position: -48px -16px; }
+jqueryui .ui-icon-triangle-1-s { background-position: -64px -16px; }
+jqueryui .ui-icon-triangle-1-sw { background-position: -80px -16px; }
+jqueryui .ui-icon-triangle-1-w { background-position: -96px -16px; }
+jqueryui .ui-icon-triangle-1-nw { background-position: -112px -16px; }
+jqueryui .ui-icon-triangle-2-n-s { background-position: -128px -16px; }
+jqueryui .ui-icon-triangle-2-e-w { background-position: -144px -16px; }
+jqueryui .ui-icon-arrow-1-n { background-position: 0 -32px; }
+jqueryui .ui-icon-arrow-1-ne { background-position: -16px -32px; }
+jqueryui .ui-icon-arrow-1-e { background-position: -32px -32px; }
+jqueryui .ui-icon-arrow-1-se { background-position: -48px -32px; }
+jqueryui .ui-icon-arrow-1-s { background-position: -64px -32px; }
+jqueryui .ui-icon-arrow-1-sw { background-position: -80px -32px; }
+jqueryui .ui-icon-arrow-1-w { background-position: -96px -32px; }
+jqueryui .ui-icon-arrow-1-nw { background-position: -112px -32px; }
+jqueryui .ui-icon-arrow-2-n-s { background-position: -128px -32px; }
+jqueryui .ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
+jqueryui .ui-icon-arrow-2-e-w { background-position: -160px -32px; }
+jqueryui .ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
+jqueryui .ui-icon-arrowstop-1-n { background-position: -192px -32px; }
+jqueryui .ui-icon-arrowstop-1-e { background-position: -208px -32px; }
+jqueryui .ui-icon-arrowstop-1-s { background-position: -224px -32px; }
+jqueryui .ui-icon-arrowstop-1-w { background-position: -240px -32px; }
+jqueryui .ui-icon-arrowthick-1-n { background-position: 0 -48px; }
+jqueryui .ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
+jqueryui .ui-icon-arrowthick-1-e { background-position: -32px -48px; }
+jqueryui .ui-icon-arrowthick-1-se { background-position: -48px -48px; }
+jqueryui .ui-icon-arrowthick-1-s { background-position: -64px -48px; }
+jqueryui .ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
+jqueryui .ui-icon-arrowthick-1-w { background-position: -96px -48px; }
+jqueryui .ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
+jqueryui .ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
+jqueryui .ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
+jqueryui .ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
+jqueryui .ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
+jqueryui .ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
+jqueryui .ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
+jqueryui .ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
+jqueryui .ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
+jqueryui .ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
+jqueryui .ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
+jqueryui .ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
+jqueryui .ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
+jqueryui .ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
+jqueryui .ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
+jqueryui .ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
+jqueryui .ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
+jqueryui .ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
+jqueryui .ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
+jqueryui .ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
+jqueryui .ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
+jqueryui .ui-icon-arrow-4 { background-position: 0 -80px; }
+jqueryui .ui-icon-arrow-4-diag { background-position: -16px -80px; }
+jqueryui .ui-icon-extlink { background-position: -32px -80px; }
+jqueryui .ui-icon-newwin { background-position: -48px -80px; }
+jqueryui .ui-icon-refresh { background-position: -64px -80px; }
+jqueryui .ui-icon-shuffle { background-position: -80px -80px; }
+jqueryui .ui-icon-transfer-e-w { background-position: -96px -80px; }
+jqueryui .ui-icon-transferthick-e-w { background-position: -112px -80px; }
+jqueryui .ui-icon-folder-collapsed { background-position: 0 -96px; }
+jqueryui .ui-icon-folder-open { background-position: -16px -96px; }
+jqueryui .ui-icon-document { background-position: -32px -96px; }
+jqueryui .ui-icon-document-b { background-position: -48px -96px; }
+jqueryui .ui-icon-note { background-position: -64px -96px; }
+jqueryui .ui-icon-mail-closed { background-position: -80px -96px; }
+jqueryui .ui-icon-mail-open { background-position: -96px -96px; }
+jqueryui .ui-icon-suitcase { background-position: -112px -96px; }
+jqueryui .ui-icon-comment { background-position: -128px -96px; }
+jqueryui .ui-icon-person { background-position: -144px -96px; }
+jqueryui .ui-icon-print { background-position: -160px -96px; }
+jqueryui .ui-icon-trash { background-position: -176px -96px; }
+jqueryui .ui-icon-locked { background-position: -192px -96px; }
+jqueryui .ui-icon-unlocked { background-position: -208px -96px; }
+jqueryui .ui-icon-bookmark { background-position: -224px -96px; }
+jqueryui .ui-icon-tag { background-position: -240px -96px; }
+jqueryui .ui-icon-home { background-position: 0 -112px; }
+jqueryui .ui-icon-flag { background-position: -16px -112px; }
+jqueryui .ui-icon-calendar { background-position: -32px -112px; }
+jqueryui .ui-icon-cart { background-position: -48px -112px; }
+jqueryui .ui-icon-pencil { background-position: -64px -112px; }
+jqueryui .ui-icon-clock { background-position: -80px -112px; }
+jqueryui .ui-icon-disk { background-position: -96px -112px; }
+jqueryui .ui-icon-calculator { background-position: -112px -112px; }
+jqueryui .ui-icon-zoomin { background-position: -128px -112px; }
+jqueryui .ui-icon-zoomout { background-position: -144px -112px; }
+jqueryui .ui-icon-search { background-position: -160px -112px; }
+jqueryui .ui-icon-wrench { background-position: -176px -112px; }
+jqueryui .ui-icon-gear { background-position: -192px -112px; }
+jqueryui .ui-icon-heart { background-position: -208px -112px; }
+jqueryui .ui-icon-star { background-position: -224px -112px; }
+jqueryui .ui-icon-link { background-position: -240px -112px; }
+jqueryui .ui-icon-cancel { background-position: 0 -128px; }
+jqueryui .ui-icon-plus { background-position: -16px -128px; }
+jqueryui .ui-icon-plusthick { background-position: -32px -128px; }
+jqueryui .ui-icon-minus { background-position: -48px -128px; }
+jqueryui .ui-icon-minusthick { background-position: -64px -128px; }
+jqueryui .ui-icon-close { background-position: -80px -128px; }
+jqueryui .ui-icon-closethick { background-position: -96px -128px; }
+jqueryui .ui-icon-key { background-position: -112px -128px; }
+jqueryui .ui-icon-lightbulb { background-position: -128px -128px; }
+jqueryui .ui-icon-scissors { background-position: -144px -128px; }
+jqueryui .ui-icon-clipboard { background-position: -160px -128px; }
+jqueryui .ui-icon-copy { background-position: -176px -128px; }
+jqueryui .ui-icon-contact { background-position: -192px -128px; }
+jqueryui .ui-icon-image { background-position: -208px -128px; }
+jqueryui .ui-icon-video { background-position: -224px -128px; }
+jqueryui .ui-icon-script { background-position: -240px -128px; }
+jqueryui .ui-icon-alert { background-position: 0 -144px; }
+jqueryui .ui-icon-info { background-position: -16px -144px; }
+jqueryui .ui-icon-notice { background-position: -32px -144px; }
+jqueryui .ui-icon-help { background-position: -48px -144px; }
+jqueryui .ui-icon-check { background-position: -64px -144px; }
+jqueryui .ui-icon-bullet { background-position: -80px -144px; }
+jqueryui .ui-icon-radio-on { background-position: -96px -144px; }
+jqueryui .ui-icon-radio-off { background-position: -112px -144px; }
+jqueryui .ui-icon-pin-w { background-position: -128px -144px; }
+jqueryui .ui-icon-pin-s { background-position: -144px -144px; }
+jqueryui .ui-icon-play { background-position: 0 -160px; }
+jqueryui .ui-icon-pause { background-position: -16px -160px; }
+jqueryui .ui-icon-seek-next { background-position: -32px -160px; }
+jqueryui .ui-icon-seek-prev { background-position: -48px -160px; }
+jqueryui .ui-icon-seek-end { background-position: -64px -160px; }
+jqueryui .ui-icon-seek-start { background-position: -80px -160px; }
+/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
+jqueryui .ui-icon-seek-first { background-position: -80px -160px; }
+jqueryui .ui-icon-stop { background-position: -96px -160px; }
+jqueryui .ui-icon-eject { background-position: -112px -160px; }
+jqueryui .ui-icon-volume-off { background-position: -128px -160px; }
+jqueryui .ui-icon-volume-on { background-position: -144px -160px; }
+jqueryui .ui-icon-power { background-position: 0 -176px; }
+jqueryui .ui-icon-signal-diag { background-position: -16px -176px; }
+jqueryui .ui-icon-signal { background-position: -32px -176px; }
+jqueryui .ui-icon-battery-0 { background-position: -48px -176px; }
+jqueryui .ui-icon-battery-1 { background-position: -64px -176px; }
+jqueryui .ui-icon-battery-2 { background-position: -80px -176px; }
+jqueryui .ui-icon-battery-3 { background-position: -96px -176px; }
+jqueryui .ui-icon-circle-plus { background-position: 0 -192px; }
+jqueryui .ui-icon-circle-minus { background-position: -16px -192px; }
+jqueryui .ui-icon-circle-close { background-position: -32px -192px; }
+jqueryui .ui-icon-circle-triangle-e { background-position: -48px -192px; }
+jqueryui .ui-icon-circle-triangle-s { background-position: -64px -192px; }
+jqueryui .ui-icon-circle-triangle-w { background-position: -80px -192px; }
+jqueryui .ui-icon-circle-triangle-n { background-position: -96px -192px; }
+jqueryui .ui-icon-circle-arrow-e { background-position: -112px -192px; }
+jqueryui .ui-icon-circle-arrow-s { background-position: -128px -192px; }
+jqueryui .ui-icon-circle-arrow-w { background-position: -144px -192px; }
+jqueryui .ui-icon-circle-arrow-n { background-position: -160px -192px; }
+jqueryui .ui-icon-circle-zoomin { background-position: -176px -192px; }
+jqueryui .ui-icon-circle-zoomout { background-position: -192px -192px; }
+jqueryui .ui-icon-circle-check { background-position: -208px -192px; }
+jqueryui .ui-icon-circlesmall-plus { background-position: 0 -208px; }
+jqueryui .ui-icon-circlesmall-minus { background-position: -16px -208px; }
+jqueryui .ui-icon-circlesmall-close { background-position: -32px -208px; }
+jqueryui .ui-icon-squaresmall-plus { background-position: -48px -208px; }
+jqueryui .ui-icon-squaresmall-minus { background-position: -64px -208px; }
+jqueryui .ui-icon-squaresmall-close { background-position: -80px -208px; }
+jqueryui .ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
+jqueryui .ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
+jqueryui .ui-icon-grip-solid-vertical { background-position: -32px -224px; }
+jqueryui .ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
+jqueryui .ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
+jqueryui .ui-icon-grip-diagonal-se { background-position: -80px -224px; }
+
+
+/* Misc visuals
+----------------------------------*/
+
+/* Corner radius */
+jqueryui .ui-corner-all, jqueryui .ui-corner-top, jqueryui .ui-corner-left, jqueryui .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; }
+jqueryui .ui-corner-all, jqueryui .ui-corner-top, jqueryui .ui-corner-right, jqueryui .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; }
+jqueryui .ui-corner-all, jqueryui .ui-corner-bottom, jqueryui .ui-corner-left, jqueryui .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }
+jqueryui .ui-corner-all, jqueryui .ui-corner-bottom, jqueryui .ui-corner-right, jqueryui .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
+
+/* Overlays */
+jqueryui .ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .3;filter:Alpha(Opacity=30); }
+jqueryui .ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .3;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -khtml-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }
\ No newline at end of file
diff --git a/src/web/css/jquery-ui-1.9.2.custom.min.css b/src/web/css/jquery-ui-1.9.2.custom.min.css
new file mode 100644
index 0000000..ea83646
--- /dev/null
+++ b/src/web/css/jquery-ui-1.9.2.custom.min.css
@@ -0,0 +1,5 @@
+/*! jQuery UI - v1.9.2 - 2012-12-13
+* http://jqueryui.com
+* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css
+* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana%2CArial%2Csans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=cccccc&bgTextureHeader=03_highlight_soft.png&bgImgOpacityHeader=75&borderColorHeader=aaaaaa&fcHeader=222222&iconColorHeader=222222&bgColorContent=ffffff&bgTextureContent=01_flat.png&bgImgOpacityContent=75&borderColorContent=aaaaaa&fcContent=222222&iconColorContent=222222&bgColorDefault=e6e6e6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=75&borderColorDefault=d3d3d3&fcDefault=555555&iconColorDefault=888888&bgColorHover=dadada&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=999999&fcHover=212121&iconColorHover=454545&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=aaaaaa&fcActive=212121&iconColorActive=454545&bgColorHighlight=fbf9ee&bgTextureHighlight=02_glass.png&bgImgOpacityHighlight=55&borderColorHighlight=fcefa1&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px
+* Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{zoom:1}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:0.1px;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.ui-accordion .ui-accordion-header{display:block;cursor:pointer;position:relative;margin-top:2px;padding:.5em .5em .5em .7em;zoom:1}.ui-accordion .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-noicons{padding-left:.7em}.ui-accordion .ui-accordion-icons .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-accordion-header-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;overflow:auto;zoom:1}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}* html .ui-autocomplete{width:1px}.ui-button{display:inline-block;position:relative;padding:0;margin-right:.1em;cursor:pointer;text-align:center;zoom:1;overflow:visible}.ui-button,.ui-button:link,.ui-button:visited,.ui-button:hover,.ui-button:active{text-decoration:none}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:1.4}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}.ui-datepicker .ui-datepicker-prev{left:2px}.ui-datepicker .ui-datepicker-next{right:2px}.ui-datepicker .ui-datepicker-prev-hover{left:1px}.ui-datepicker .ui-datepicker-next-hover{right:1px}.ui-datepicker .ui-datepicker-prev span,.ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}.ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.ui-datepicker select.ui-datepicker-month-year{width:100%}.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:49%}.ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:bold;border:0}.ui-datepicker td{border:0;padding:1px}.ui-datepicker td span,.ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}.ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em .6em;width:auto;overflow:visible}.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.ui-datepicker.ui-datepicker-multi{width:auto}.ui-datepicker-multi .ui-datepicker-group{float:left}.ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.ui-datepicker-row-break{clear:both;width:100%;font-size:0em}.ui-datepicker-rtl{direction:rtl}.ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}.ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}.ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current{float:right}.ui-datepicker-rtl .ui-datepicker-group{float:right}.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-cover{position:absolute;z-index:-1;filter:mask();top:-4px;left:-4px;width:200px;height:200px}.ui-dialog{position:absolute;top:0;left:0;padding:.2em;width:300px;overflow:hidden}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 16px .1em 0}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:19px;margin:-10px 0 0 0;padding:1px;height:18px}.ui-dialog .ui-dialog-titlebar-close span{display:block;margin:1px}.ui-dialog .ui-dialog-titlebar-close:hover,.ui-dialog .ui-dialog-titlebar-close:focus{padding:0}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:none;overflow:auto;zoom:1}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin:.5em 0 0 0;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:14px;height:14px;right:3px;bottom:3px}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-menu{list-style:none;padding:2px;margin:0;display:block;outline:none}.ui-menu .ui-menu{margin-top:-3px;position:absolute}.ui-menu .ui-menu-item{margin:0;padding:0;zoom:1;width:100%}.ui-menu .ui-menu-divider{margin:5px -2px 5px -2px;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-menu-item a{text-decoration:none;display:block;padding:2px .4em;line-height:1.5;zoom:1;font-weight:normal}.ui-menu .ui-menu-item a.ui-state-focus,.ui-menu .ui-menu-item a.ui-state-active{font-weight:normal;margin:-1px}.ui-menu .ui-state-disabled{font-weight:normal;margin:.4em 0 .2em;line-height:1.5}.ui-menu .ui-state-disabled a{cursor:default}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item a{position:relative;padding-left:2em}.ui-menu .ui-icon{position:absolute;top:.2em;left:.2em}.ui-menu .ui-menu-icon{position:static;float:right}.ui-progressbar{height:2em;text-align:left;overflow:hidden}.ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.ui-slider{position:relative;text-align:left}.ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default}.ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.ui-slider-horizontal{height:.8em}.ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.ui-slider-horizontal .ui-slider-range-min{left:0}.ui-slider-horizontal .ui-slider-range-max{right:0}.ui-slider-vertical{width:.8em;height:100px}.ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.ui-slider-vertical .ui-slider-range{left:0;width:100%}.ui-slider-vertical .ui-slider-range-min{bottom:0}.ui-slider-vertical .ui-slider-range-max{top:0}.ui-spinner{position:relative;display:inline-block;overflow:hidden;padding:0;vertical-align:middle}.ui-spinner-input{border:none;background:none;padding:0;margin:.2em 0;vertical-align:middle;margin-left:.4em;margin-right:22px}.ui-spinner-button{width:16px;height:50%;font-size:.5em;padding:0;margin:0;text-align:center;position:absolute;cursor:default;display:block;overflow:hidden;right:0}.ui-spinner a.ui-spinner-button{border-top:none;border-bottom:none;border-right:none}.ui-spinner .ui-icon{position:absolute;margin-top:-8px;top:50%;left:0}.ui-spinner-up{top:0}.ui-spinner-down{bottom:0}.ui-spinner .ui-icon-triangle-1-s{background-position:-65px -16px}.ui-tabs{position:relative;padding:.2em;zoom:1}.ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:0;margin:1px .2em 0 0;border-bottom:0;padding:0;white-space:nowrap}.ui-tabs .ui-tabs-nav li a{float:left;padding:.5em 1em;text-decoration:none}.ui-tabs .ui-tabs-nav li.ui-tabs-active{margin-bottom:-1px;padding-bottom:1px}.ui-tabs .ui-tabs-nav li.ui-tabs-active a,.ui-tabs .ui-tabs-nav li.ui-state-disabled a,.ui-tabs .ui-tabs-nav li.ui-tabs-loading a{cursor:text}.ui-tabs .ui-tabs-nav li a,.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a{cursor:pointer}.ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:none}.ui-tooltip{padding:8px;position:absolute;z-index:9999;max-width:300px;-webkit-box-shadow:0 0 5px #aaa;box-shadow:0 0 5px #aaa}* html .ui-tooltip{background-image:none}body .ui-tooltip{border-width:2px}jqueryui .ui-widget{font-family:Verdana,Arial,sans-serif;font-size:1.1em}jqueryui .ui-widget .ui-widget{font-size:1em}jqueryui .ui-widget input,jqueryui .ui-widget select,jqueryui .ui-widget textarea,jqueryui .ui-widget button{font-family:Verdana,Arial,sans-serif;font-size:1em}jqueryui .ui-widget-content{border:1px solid #aaa;background:#fff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x;color:#222}jqueryui .ui-widget-content a{color:#222}jqueryui .ui-widget-header{border:1px solid #aaa;background:#ccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x;color:#222;font-weight:bold}jqueryui .ui-widget-header a{color:#222}jqueryui .ui-state-default,jqueryui .ui-widget-content .ui-state-default,jqueryui .ui-widget-header .ui-state-default{border:1px solid #d3d3d3;background:#e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#555}jqueryui .ui-state-default a,jqueryui .ui-state-default a:link,jqueryui .ui-state-default a:visited{color:#555;text-decoration:none}jqueryui .ui-state-hover,jqueryui .ui-widget-content .ui-state-hover,jqueryui .ui-widget-header .ui-state-hover,jqueryui .ui-state-focus,jqueryui .ui-widget-content .ui-state-focus,jqueryui .ui-widget-header .ui-state-focus{border:1px solid #999;background:#dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#212121}jqueryui .ui-state-hover a,jqueryui .ui-state-hover a:hover,jqueryui .ui-state-hover a:link,jqueryui .ui-state-hover a:visited{color:#212121;text-decoration:none}jqueryui .ui-state-active,jqueryui .ui-widget-content .ui-state-active,jqueryui .ui-widget-header .ui-state-active{border:1px solid #aaa;background:#fff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#212121}jqueryui .ui-state-active a,jqueryui .ui-state-active a:link,jqueryui .ui-state-active a:visited{color:#212121;text-decoration:none}jqueryui .ui-state-highlight,jqueryui .ui-widget-content .ui-state-highlight,jqueryui .ui-widget-header .ui-state-highlight{border:1px solid #fcefa1;background:#fbf9ee url(images/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x;color:#363636}jqueryui .ui-state-highlight a,jqueryui .ui-widget-content .ui-state-highlight a,jqueryui .ui-widget-header .ui-state-highlight a{color:#363636}jqueryui .ui-state-error,jqueryui .ui-widget-content .ui-state-error,jqueryui .ui-widget-header .ui-state-error{border:1px solid #cd0a0a;background:#fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x;color:#cd0a0a}jqueryui .ui-state-error a,jqueryui .ui-widget-content .ui-state-error a,jqueryui .ui-widget-header .ui-state-error a{color:#cd0a0a}jqueryui .ui-state-error-text,jqueryui .ui-widget-content .ui-state-error-text,jqueryui .ui-widget-header .ui-state-error-text{color:#cd0a0a}jqueryui .ui-priority-primary,jqueryui .ui-widget-content .ui-priority-primary,jqueryui .ui-widget-header .ui-priority-primary{font-weight:bold}jqueryui .ui-priority-secondary,jqueryui .ui-widget-content .ui-priority-secondary,jqueryui .ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}jqueryui .ui-state-disabled,jqueryui .ui-widget-content .ui-state-disabled,jqueryui .ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}jqueryui .ui-state-disabled .ui-icon{filter:Alpha(Opacity=35)}jqueryui .ui-icon{width:16px;height:16px;background-image:url(images/ui-icons_222222_256x240.png)}jqueryui .ui-widget-content .ui-icon{background-image:url(images/ui-icons_222222_256x240.png)}jqueryui .ui-widget-header .ui-icon{background-image:url(images/ui-icons_222222_256x240.png)}jqueryui .ui-state-default .ui-icon{background-image:url(images/ui-icons_888888_256x240.png)}jqueryui .ui-state-hover .ui-icon,jqueryui .ui-state-focus .ui-icon{background-image:url(images/ui-icons_454545_256x240.png)}jqueryui .ui-state-active .ui-icon{background-image:url(images/ui-icons_454545_256x240.png)}jqueryui .ui-state-highlight .ui-icon{background-image:url(images/ui-icons_2e83ff_256x240.png)}jqueryui .ui-state-error .ui-icon,jqueryui .ui-state-error-text .ui-icon{background-image:url(images/ui-icons_cd0a0a_256x240.png)}jqueryui .ui-icon-carat-1-n{background-position:0 0}jqueryui .ui-icon-carat-1-ne{background-position:-16px 0}jqueryui .ui-icon-carat-1-e{background-position:-32px 0}jqueryui .ui-icon-carat-1-se{background-position:-48px 0}jqueryui .ui-icon-carat-1-s{background-position:-64px 0}jqueryui .ui-icon-carat-1-sw{background-position:-80px 0}jqueryui .ui-icon-carat-1-w{background-position:-96px 0}jqueryui .ui-icon-carat-1-nw{background-position:-112px 0}jqueryui .ui-icon-carat-2-n-s{background-position:-128px 0}jqueryui .ui-icon-carat-2-e-w{background-position:-144px 0}jqueryui .ui-icon-triangle-1-n{background-position:0 -16px}jqueryui .ui-icon-triangle-1-ne{background-position:-16px -16px}jqueryui .ui-icon-triangle-1-e{background-position:-32px -16px}jqueryui .ui-icon-triangle-1-se{background-position:-48px -16px}jqueryui .ui-icon-triangle-1-s{background-position:-64px -16px}jqueryui .ui-icon-triangle-1-sw{background-position:-80px -16px}jqueryui .ui-icon-triangle-1-w{background-position:-96px -16px}jqueryui .ui-icon-triangle-1-nw{background-position:-112px -16px}jqueryui .ui-icon-triangle-2-n-s{background-position:-128px -16px}jqueryui .ui-icon-triangle-2-e-w{background-position:-144px -16px}jqueryui .ui-icon-arrow-1-n{background-position:0 -32px}jqueryui .ui-icon-arrow-1-ne{background-position:-16px -32px}jqueryui .ui-icon-arrow-1-e{background-position:-32px -32px}jqueryui .ui-icon-arrow-1-se{background-position:-48px -32px}jqueryui .ui-icon-arrow-1-s{background-position:-64px -32px}jqueryui .ui-icon-arrow-1-sw{background-position:-80px -32px}jqueryui .ui-icon-arrow-1-w{background-position:-96px -32px}jqueryui .ui-icon-arrow-1-nw{background-position:-112px -32px}jqueryui .ui-icon-arrow-2-n-s{background-position:-128px -32px}jqueryui .ui-icon-arrow-2-ne-sw{background-position:-144px -32px}jqueryui .ui-icon-arrow-2-e-w{background-position:-160px -32px}jqueryui .ui-icon-arrow-2-se-nw{background-position:-176px -32px}jqueryui .ui-icon-arrowstop-1-n{background-position:-192px -32px}jqueryui .ui-icon-arrowstop-1-e{background-position:-208px -32px}jqueryui .ui-icon-arrowstop-1-s{background-position:-224px -32px}jqueryui .ui-icon-arrowstop-1-w{background-position:-240px -32px}jqueryui .ui-icon-arrowthick-1-n{background-position:0 -48px}jqueryui .ui-icon-arrowthick-1-ne{background-position:-16px -48px}jqueryui .ui-icon-arrowthick-1-e{background-position:-32px -48px}jqueryui .ui-icon-arrowthick-1-se{background-position:-48px -48px}jqueryui .ui-icon-arrowthick-1-s{background-position:-64px -48px}jqueryui .ui-icon-arrowthick-1-sw{background-position:-80px -48px}jqueryui .ui-icon-arrowthick-1-w{background-position:-96px -48px}jqueryui .ui-icon-arrowthick-1-nw{background-position:-112px -48px}jqueryui .ui-icon-arrowthick-2-n-s{background-position:-128px -48px}jqueryui .ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}jqueryui .ui-icon-arrowthick-2-e-w{background-position:-160px -48px}jqueryui .ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}jqueryui .ui-icon-arrowthickstop-1-n{background-position:-192px -48px}jqueryui .ui-icon-arrowthickstop-1-e{background-position:-208px -48px}jqueryui .ui-icon-arrowthickstop-1-s{background-position:-224px -48px}jqueryui .ui-icon-arrowthickstop-1-w{background-position:-240px -48px}jqueryui .ui-icon-arrowreturnthick-1-w{background-position:0 -64px}jqueryui .ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}jqueryui .ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}jqueryui .ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}jqueryui .ui-icon-arrowreturn-1-w{background-position:-64px -64px}jqueryui .ui-icon-arrowreturn-1-n{background-position:-80px -64px}jqueryui .ui-icon-arrowreturn-1-e{background-position:-96px -64px}jqueryui .ui-icon-arrowreturn-1-s{background-position:-112px -64px}jqueryui .ui-icon-arrowrefresh-1-w{background-position:-128px -64px}jqueryui .ui-icon-arrowrefresh-1-n{background-position:-144px -64px}jqueryui .ui-icon-arrowrefresh-1-e{background-position:-160px -64px}jqueryui .ui-icon-arrowrefresh-1-s{background-position:-176px -64px}jqueryui .ui-icon-arrow-4{background-position:0 -80px}jqueryui .ui-icon-arrow-4-diag{background-position:-16px -80px}jqueryui .ui-icon-extlink{background-position:-32px -80px}jqueryui .ui-icon-newwin{background-position:-48px -80px}jqueryui .ui-icon-refresh{background-position:-64px -80px}jqueryui .ui-icon-shuffle{background-position:-80px -80px}jqueryui .ui-icon-transfer-e-w{background-position:-96px -80px}jqueryui .ui-icon-transferthick-e-w{background-position:-112px -80px}jqueryui .ui-icon-folder-collapsed{background-position:0 -96px}jqueryui .ui-icon-folder-open{background-position:-16px -96px}jqueryui .ui-icon-document{background-position:-32px -96px}jqueryui .ui-icon-document-b{background-position:-48px -96px}jqueryui .ui-icon-note{background-position:-64px -96px}jqueryui .ui-icon-mail-closed{background-position:-80px -96px}jqueryui .ui-icon-mail-open{background-position:-96px -96px}jqueryui .ui-icon-suitcase{background-position:-112px -96px}jqueryui .ui-icon-comment{background-position:-128px -96px}jqueryui .ui-icon-person{background-position:-144px -96px}jqueryui .ui-icon-print{background-position:-160px -96px}jqueryui .ui-icon-trash{background-position:-176px -96px}jqueryui .ui-icon-locked{background-position:-192px -96px}jqueryui .ui-icon-unlocked{background-position:-208px -96px}jqueryui .ui-icon-bookmark{background-position:-224px -96px}jqueryui .ui-icon-tag{background-position:-240px -96px}jqueryui .ui-icon-home{background-position:0 -112px}jqueryui .ui-icon-flag{background-position:-16px -112px}jqueryui .ui-icon-calendar{background-position:-32px -112px}jqueryui .ui-icon-cart{background-position:-48px -112px}jqueryui .ui-icon-pencil{background-position:-64px -112px}jqueryui .ui-icon-clock{background-position:-80px -112px}jqueryui .ui-icon-disk{background-position:-96px -112px}jqueryui .ui-icon-calculator{background-position:-112px -112px}jqueryui .ui-icon-zoomin{background-position:-128px -112px}jqueryui .ui-icon-zoomout{background-position:-144px -112px}jqueryui .ui-icon-search{background-position:-160px -112px}jqueryui .ui-icon-wrench{background-position:-176px -112px}jqueryui .ui-icon-gear{background-position:-192px -112px}jqueryui .ui-icon-heart{background-position:-208px -112px}jqueryui .ui-icon-star{background-position:-224px -112px}jqueryui .ui-icon-link{background-position:-240px -112px}jqueryui .ui-icon-cancel{background-position:0 -128px}jqueryui .ui-icon-plus{background-position:-16px -128px}jqueryui .ui-icon-plusthick{background-position:-32px -128px}jqueryui .ui-icon-minus{background-position:-48px -128px}jqueryui .ui-icon-minusthick{background-position:-64px -128px}jqueryui .ui-icon-close{background-position:-80px -128px}jqueryui .ui-icon-closethick{background-position:-96px -128px}jqueryui .ui-icon-key{background-position:-112px -128px}jqueryui .ui-icon-lightbulb{background-position:-128px -128px}jqueryui .ui-icon-scissors{background-position:-144px -128px}jqueryui .ui-icon-clipboard{background-position:-160px -128px}jqueryui .ui-icon-copy{background-position:-176px -128px}jqueryui .ui-icon-contact{background-position:-192px -128px}jqueryui .ui-icon-image{background-position:-208px -128px}jqueryui .ui-icon-video{background-position:-224px -128px}jqueryui .ui-icon-script{background-position:-240px -128px}jqueryui .ui-icon-alert{background-position:0 -144px}jqueryui .ui-icon-info{background-position:-16px -144px}jqueryui .ui-icon-notice{background-position:-32px -144px}jqueryui .ui-icon-help{background-position:-48px -144px}jqueryui .ui-icon-check{background-position:-64px -144px}jqueryui .ui-icon-bullet{background-position:-80px -144px}jqueryui .ui-icon-radio-on{background-position:-96px -144px}jqueryui .ui-icon-radio-off{background-position:-112px -144px}jqueryui .ui-icon-pin-w{background-position:-128px -144px}jqueryui .ui-icon-pin-s{background-position:-144px -144px}jqueryui .ui-icon-play{background-position:0 -160px}jqueryui .ui-icon-pause{background-position:-16px -160px}jqueryui .ui-icon-seek-next{background-position:-32px -160px}jqueryui .ui-icon-seek-prev{background-position:-48px -160px}jqueryui .ui-icon-seek-end{background-position:-64px -160px}jqueryui .ui-icon-seek-start{background-position:-80px -160px}jqueryui .ui-icon-seek-first{background-position:-80px -160px}jqueryui .ui-icon-stop{background-position:-96px -160px}jqueryui .ui-icon-eject{background-position:-112px -160px}jqueryui .ui-icon-volume-off{background-position:-128px -160px}jqueryui .ui-icon-volume-on{background-position:-144px -160px}jqueryui .ui-icon-power{background-position:0 -176px}jqueryui .ui-icon-signal-diag{background-position:-16px -176px}jqueryui .ui-icon-signal{background-position:-32px -176px}jqueryui .ui-icon-battery-0{background-position:-48px -176px}jqueryui .ui-icon-battery-1{background-position:-64px -176px}jqueryui .ui-icon-battery-2{background-position:-80px -176px}jqueryui .ui-icon-battery-3{background-position:-96px -176px}jqueryui .ui-icon-circle-plus{background-position:0 -192px}jqueryui .ui-icon-circle-minus{background-position:-16px -192px}jqueryui .ui-icon-circle-close{background-position:-32px -192px}jqueryui .ui-icon-circle-triangle-e{background-position:-48px -192px}jqueryui .ui-icon-circle-triangle-s{background-position:-64px -192px}jqueryui .ui-icon-circle-triangle-w{background-position:-80px -192px}jqueryui .ui-icon-circle-triangle-n{background-position:-96px -192px}jqueryui .ui-icon-circle-arrow-e{background-position:-112px -192px}jqueryui .ui-icon-circle-arrow-s{background-position:-128px -192px}jqueryui .ui-icon-circle-arrow-w{background-position:-144px -192px}jqueryui .ui-icon-circle-arrow-n{background-position:-160px -192px}jqueryui .ui-icon-circle-zoomin{background-position:-176px -192px}jqueryui .ui-icon-circle-zoomout{background-position:-192px -192px}jqueryui .ui-icon-circle-check{background-position:-208px -192px}jqueryui .ui-icon-circlesmall-plus{background-position:0 -208px}jqueryui .ui-icon-circlesmall-minus{background-position:-16px -208px}jqueryui .ui-icon-circlesmall-close{background-position:-32px -208px}jqueryui .ui-icon-squaresmall-plus{background-position:-48px -208px}jqueryui .ui-icon-squaresmall-minus{background-position:-64px -208px}jqueryui .ui-icon-squaresmall-close{background-position:-80px -208px}jqueryui .ui-icon-grip-dotted-vertical{background-position:0 -224px}jqueryui .ui-icon-grip-dotted-horizontal{background-position:-16px -224px}jqueryui .ui-icon-grip-solid-vertical{background-position:-32px -224px}jqueryui .ui-icon-grip-solid-horizontal{background-position:-48px -224px}jqueryui .ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}jqueryui .ui-icon-grip-diagonal-se{background-position:-80px -224px}jqueryui .ui-corner-all,jqueryui .ui-corner-top,jqueryui .ui-corner-left,jqueryui .ui-corner-tl{-moz-border-radius-topleft:4px;-webkit-border-top-left-radius:4px;-khtml-border-top-left-radius:4px;border-top-left-radius:4px}jqueryui .ui-corner-all,jqueryui .ui-corner-top,jqueryui .ui-corner-right,jqueryui .ui-corner-tr{-moz-border-radius-topright:4px;-webkit-border-top-right-radius:4px;-khtml-border-top-right-radius:4px;border-top-right-radius:4px}jqueryui .ui-corner-all,jqueryui .ui-corner-bottom,jqueryui .ui-corner-left,jqueryui .ui-corner-bl{-moz-border-radius-bottomleft:4px;-webkit-border-bottom-left-radius:4px;-khtml-border-bottom-left-radius:4px;border-bottom-left-radius:4px}jqueryui .ui-corner-all,jqueryui .ui-corner-bottom,jqueryui .ui-corner-right,jqueryui .ui-corner-br{-moz-border-radius-bottomright:4px;-webkit-border-bottom-right-radius:4px;-khtml-border-bottom-right-radius:4px;border-bottom-right-radius:4px}jqueryui .ui-widget-overlay{background:#aaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x;opacity:.3;filter:Alpha(Opacity=30)}jqueryui .ui-widget-shadow{margin:-8px 0 0 -8px;padding:8px;background:#aaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x;opacity:.3;filter:Alpha(Opacity=30);-moz-border-radius:8px;-khtml-border-radius:8px;-webkit-border-radius:8px;border-radius:8px}
\ No newline at end of file
src/web/css/jquery-ui-timepicker-addon.css 10(+10 -0)
diff --git a/src/web/css/jquery-ui-timepicker-addon.css b/src/web/css/jquery-ui-timepicker-addon.css
new file mode 100644
index 0000000..becbd7b
--- /dev/null
+++ b/src/web/css/jquery-ui-timepicker-addon.css
@@ -0,0 +1,10 @@
+.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
+.ui-timepicker-div dl { text-align: left; }
+.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
+.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
+.ui-timepicker-div td { font-size: 90%; }
+.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
+
+.ui-timepicker-rtl{ direction: rtl; }
+.ui-timepicker-rtl dl { text-align: right; }
+.ui-timepicker-rtl dl dd { margin: 0 65px 10px 10px; }
src/web/js/azkaban.admin.setup.js 117(+117 -0)
diff --git a/src/web/js/azkaban.admin.setup.js b/src/web/js/azkaban.admin.setup.js
new file mode 100644
index 0000000..80a0f94
--- /dev/null
+++ b/src/web/js/azkaban.admin.setup.js
@@ -0,0 +1,117 @@
+$.namespace('azkaban');
+
+var dbUploadPanel;
+azkaban.DBUploadPanel= Backbone.View.extend({
+ events : {
+ "click #upload-jar-btn" : "handleUpload"
+ },
+ initialize : function(settings) {
+ },
+ render: function() {
+ },
+ handleUpload: function(){
+ var filename = $("#file").val();
+ if (filename.length > 4) {
+ var lastIndexOf = filename.lastIndexOf('.');
+ var lastIndexOfForwardSlash = filename.lastIndexOf('\\');
+ var lastIndexOfBackwardSlash = filename.lastIndexOf('/');
+
+ var startIndex = Math.max(lastIndexOfForwardSlash, lastIndexOfBackwardSlash);
+ startIndex += 1;
+
+ var subfilename = filename.substring(startIndex, filename.length);
+ var end = filename.substring(lastIndexOf, filename.length);
+ if (end != ".jar") {
+ alert("File "+ subfilename + " doesn't appear to be a jar. Looking for mysql-connector*.jar");
+ return;
+ }
+ else if (subfilename.substr(0, "mysql-connector".length) != "mysql-connector") {
+ alert("File "+ subfilename + " doesn't appear to be a mysql connector jar. Looking for mysql-connector*.jar");
+ return;
+ }
+
+ console.log("Looks valid, uploading.");
+ var uploadForm = document.getElementById("upload-form");
+ var formData = new FormData(uploadForm);
+ var contextUrl = contextURL;
+
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange=function() {
+ if (xhr.readyState==4) {
+ var data = JSON.parse(xhr.responseText);
+ if (data.error) {
+ alert(data.error);
+ }
+ else {
+ $("#installed").html("Uploaded <span class=bold>" + data.jarname + "</span>");
+ }
+ }
+ }
+ xhr.open("POST", "uploadServlet");
+ xhr.send(formData);
+
+ console.log("Finished.");
+
+ }
+ else {
+ alert("File doesn't appear to be valid.");
+ }
+ }
+});
+
+var dbConnectionsPanel;
+azkaban.DBConnectionPanel= Backbone.View.extend({
+ events : {
+ "click #save-connection-button" : "handleSaveConnection"
+ },
+ initialize : function(settings) {
+ if (verified) {
+ $("#save-results").text(message);
+ $("#save-results").css("color", "#00CC00");
+ } else {
+ $("#save-results").hide();
+ }
+ },
+ render: function() {
+ },
+ handleSaveConnection: function(){
+ var host = $("#host").val();
+ var port = $("#port").val();
+ var database = $("#database").val();
+ var username = $("#username").val();
+ var password = $("#password").val();
+
+ var contextUrl = contextURL;
+ $.post(
+ contextUrl,
+ {ajax:"saveDbConnection", host: host, port:port, database: database, username: username, password: password},
+ function(data) {
+ if (data.error) {
+ verified = false;
+ $("#save-results").text(data.error);
+ $("#save-results").css("color", "#FF0000");
+ }
+ else if (data.success) {
+ verified = true;
+ $("#save-results").text(data.success);
+ $("#save-results").css("color", "#00CC00");
+ }
+ $("#save-results").show();
+ }
+ );
+ }
+});
+
+$(function() {
+ dbUploadPanel = new azkaban.DBUploadPanel({el:$( '#dbuploadpanel')});
+ dbConnectionPanel = new azkaban.DBConnectionPanel({el:$( '#dbsettingspanel')});
+
+ $("#saveAndContinue").click(function(data) {
+ if (!verified) {
+ alert("The database connection hasn't been verified.");
+ }
+ else {
+ window.location="/?usersetup";
+ }
+ });
+});
\ No newline at end of file
src/web/js/azkaban.ajax.utils.js 16(+0 -16)
diff --git a/src/web/js/azkaban.ajax.utils.js b/src/web/js/azkaban.ajax.utils.js
index 395d696..c087086 100644
--- a/src/web/js/azkaban.ajax.utils.js
+++ b/src/web/js/azkaban.ajax.utils.js
@@ -28,19 +28,3 @@ function ajaxCall(requestURL, data, callback) {
"json"
);
}
-
-function ajaxLogsCall(requestURL, data, callback) {
- $.get(
- requestURL,
- data,
- function(data) {
- var pos = data.lastIndexOf("\n");
- var log = data.substring(0, pos);
- var currentPos = data.substr(pos + 1);
-
- var newData = {current: currentPos, log: log};
-
- callback.call(this,newData);
- }
- );
-}
\ No newline at end of file
src/web/js/azkaban.date.utils.js 2(+1 -1)
diff --git a/src/web/js/azkaban.date.utils.js b/src/web/js/azkaban.date.utils.js
index 507d62a..e436648 100644
--- a/src/web/js/azkaban.date.utils.js
+++ b/src/web/js/azkaban.date.utils.js
@@ -44,7 +44,7 @@ var formatDuration = function(duration, millisecSig) {
var getDateFormat = function(date) {
var year = date.getFullYear();
- var month = getTwoDigitStr(date.getMonth());
+ var month = getTwoDigitStr(date.getMonth() + 1);
var day = getTwoDigitStr(date.getDate());
var hours = getTwoDigitStr(date.getHours());
src/web/js/azkaban.exflow.options.view.js 26(+14 -12)
diff --git a/src/web/js/azkaban.exflow.options.view.js b/src/web/js/azkaban.exflow.options.view.js
index 3b5a0d4..e6fdefb 100644
--- a/src/web/js/azkaban.exflow.options.view.js
+++ b/src/web/js/azkaban.exflow.options.view.js
@@ -107,6 +107,7 @@ azkaban.ExecuteFlowView = Backbone.View.extend({
$('#modalBackground').show();
$('#executing-options').show();
this.cloneModel = this.model.clone();
+ cloneModel = this.cloneModel;
var fetchData = {"project": projectName, "ajax":"flowInfo", "flow":flowName};
if (execId) {
@@ -139,6 +140,19 @@ azkaban.ExecuteFlowView = Backbone.View.extend({
}
this.cloneModel.set({nodes: nodes});
+ var disabled = {};
+ for (var i = 0; i < data.nodes.length; ++i) {
+ var updateNode = data.nodes[i];
+ if (updateNode.status == "DISABLED" || updateNode.status == "SKIPPED") {
+ updateNode.status = "READY";
+ disabled[updateNode.id] = true;
+ }
+ if (updateNode.status == "SUCCEEDED") {
+ disabled[updateNode.id] = true;
+ }
+ }
+ this.cloneModel.set({disabled: disabled});
+
$.get(
executeURL,
fetchData,
@@ -205,18 +219,6 @@ azkaban.ExecuteFlowView = Backbone.View.extend({
return;
}
- cloneModel = this.cloneModel;
-
- var disabled = {};
- var data = this.cloneModel.get("data");
- for (var i = 0; i < data.nodes.length; ++i) {
- var updateNode = data.nodes[i];
- if (updateNode.status == "DISABLED" || updateNode.status == "SUCCEEDED" || updateNode.status == "SKIPPED") {
- disabled[updateNode.id] = true;
- }
- }
- cloneModel.set({disabled: disabled});
-
customSvgGraphView = new azkaban.SvgGraphView({el:$('#svgDivCustom'), model: this.cloneModel, rightClick: {id: 'disableJobMenu', callback: this.handleDisableMenuClick}});
customJobsListView = new azkaban.JobListView({el:$('#jobListCustom'), model: this.cloneModel, rightClick: {id: 'disableJobMenu', callback: this.handleDisableMenuClick}});
this.cloneModel.trigger("change:graph");
src/web/js/azkaban.exflow.view.js 35(+18 -17)
diff --git a/src/web/js/azkaban.exflow.view.js b/src/web/js/azkaban.exflow.view.js
index aeeb316..e3365fa 100644
--- a/src/web/js/azkaban.exflow.view.js
+++ b/src/web/js/azkaban.exflow.view.js
@@ -292,7 +292,8 @@ azkaban.ExecutionListView = Backbone.View.extend({
progressBar.addClass(node.status);
if (node.endTime == -1) {
- $("#" + node.id + "-elapse").text("0 sec");
+// $("#" + node.id + "-elapse").text("0 sec");
+ $("#" + node.id + "-elapse").text(getDuration(node.startTime, (new Date()).getTime()));
}
else {
$("#" + node.id + "-elapse").text(getDuration(node.startTime, node.endTime));
@@ -323,7 +324,8 @@ azkaban.ExecutionListView = Backbone.View.extend({
var factor = outerWidth/diff;
var left = Math.max((node.startTime-flowStartTime)*factor, 0);
- var width = Math.max((node.endTime - node.startTime)*factor, 1);
+ var nodeLastTime = node.endTime == -1 ? (new Date()).getTime() : node.endTime;
+ var width = Math.max((nodeLastTime - node.startTime)*factor, 3);
width = Math.min(width, outerWidth);
$("#" + node.id + "-progressbar").css("margin-left", left)
@@ -393,33 +395,34 @@ azkaban.FlowLogView = Backbone.View.extend({
"click #updateLogBtn" : "handleUpdate"
},
initialize: function(settings) {
- this.model.set({"current": 0});
+ this.model.set({"offset": 0});
this.handleUpdate();
},
handleUpdate: function(evt) {
- var current = this.model.get("current");
+ var offset = this.model.get("offset");
var requestURL = contextURL + "/executor";
var model = this.model;
- ajaxLogsCall(
+ $.get(
requestURL,
- {"execid": execId, "ajax":"fetchExecFlowLogs", "current": current, "max": 100000},
+ {"execid": execId, "ajax":"fetchExecFlowLogs", "offset": offset, "length": 50000},
function(data) {
console.log("fetchLogs");
if (data.error) {
- showDialog("Error", data.error);
+ console.log(data.error);
}
else {
var log = $("#logSection").text();
if (!log) {
- log = data.log;
+ log = data.data;
}
else {
- log += data.log;
+ log += data.data;
}
- current = data.current;
+ var newOffset = data.offset + data.length;
+
$("#logSection").text(log);
- model.set({"current": current, "log": log});
+ model.set({"offset": newOffset, "log": log});
$(".logViewer").scrollTop(9999);
}
}
@@ -443,9 +446,7 @@ var updateStatus = function() {
{"execid": execId, "ajax":"fetchexecflowupdate", "lastUpdateTime": updateTime},
function(data) {
console.log("data updated");
- updateTime = Math.max(updateTime, data.submitTime);
- updateTime = Math.max(updateTime, data.startTime);
- updateTime = Math.max(updateTime, data.endTime);
+ updateTime = data.updateTime;
oldData.submitTime = data.submitTime;
oldData.startTime = data.startTime;
oldData.endTime = data.endTime;
@@ -453,15 +454,15 @@ var updateStatus = function() {
for (var i = 0; i < data.nodes.length; ++i) {
var node = data.nodes[i];
- updateTime = Math.max(updateTime, node.startTime);
- updateTime = Math.max(updateTime, node.endTime);
var oldNode = nodeMap[node.id];
oldNode.startTime = node.startTime;
+ oldNode.updateTime = node.updateTime;
oldNode.endTime = node.endTime;
oldNode.status = node.status;
}
graphModel.set({"update": data});
+ graphModel.trigger("change:update");
});
}
@@ -474,7 +475,7 @@ var updaterFunction = function() {
updateStatus();
var data = graphModel.get("data");
- if (data.status == "UNKNOWN" || data.status == "WAITING") {
+ if (data.status == "UNKNOWN" || data.status == "WAITING" || data.status == "PREPARING") {
setTimeout(function() {updaterFunction();}, 1000);
}
else if (data.status != "SUCCEEDED" && data.status != "FAILED" ) {
src/web/js/azkaban.flow.graph.view.js 16(+9 -7)
diff --git a/src/web/js/azkaban.flow.graph.view.js b/src/web/js/azkaban.flow.graph.view.js
index e01c161..a26ca3a 100644
--- a/src/web/js/azkaban.flow.graph.view.js
+++ b/src/web/js/azkaban.flow.graph.view.js
@@ -137,13 +137,15 @@ azkaban.SvgGraphView = Backbone.View.extend({
},
handleStatusUpdate: function(evt) {
var updateData = this.model.get("update");
- for (var i = 0; i < updateData.nodes.length; ++i) {
- var updateNode = updateData.nodes[i];
-
- var g = this.gNodes[updateNode.id];
- this.handleRemoveAllStatus(g);
-
- addClass(g, updateNode.status);
+ if (updateData.nodes) {
+ for (var i = 0; i < updateData.nodes.length; ++i) {
+ var updateNode = updateData.nodes[i];
+
+ var g = this.gNodes[updateNode.id];
+ this.handleRemoveAllStatus(g);
+
+ addClass(g, updateNode.status);
+ }
}
},
handleRemoveAllStatus: function(gNode) {
src/web/js/azkaban.flow.job.view.js 8(+5 -3)
diff --git a/src/web/js/azkaban.flow.job.view.js b/src/web/js/azkaban.flow.job.view.js
index 50de61d..006fcf4 100644
--- a/src/web/js/azkaban.flow.job.view.js
+++ b/src/web/js/azkaban.flow.job.view.js
@@ -73,9 +73,11 @@ azkaban.JobListView = Backbone.View.extend({
},
handleStatusUpdate: function(evt) {
var updateData = this.model.get("update");
- for (var i = 0; i < updateData.nodes.length; ++i) {
- var updateNode = updateData.nodes[i];
- $(this.listNodes[updateNode.id]).addClass(updateNode.status);
+ if (updateData.nodes) {
+ for (var i = 0; i < updateData.nodes.length; ++i) {
+ var updateNode = updateData.nodes[i];
+ $(this.listNodes[updateNode.id]).addClass(updateNode.status);
+ }
}
},
assignInitialStatus: function(evt) {
src/web/js/azkaban.flow.view.js 5(+3 -2)
diff --git a/src/web/js/azkaban.flow.view.js b/src/web/js/azkaban.flow.view.js
index 315f523..0624033 100644
--- a/src/web/js/azkaban.flow.view.js
+++ b/src/web/js/azkaban.flow.view.js
@@ -313,8 +313,9 @@ azkaban.ScheduleFlowView = Backbone.View.extend({
data: {
action:"scheduleFlow",
- projectId:projectName,
- flowId:flowName,
+ projectId:projectId,
+ projectName:projectName,
+ flowName:flowName,
hour:hourVal,
minutes:minutesVal,
am_pm:ampmVal,
src/web/js/azkaban.history.view.js 28(+18 -10)
diff --git a/src/web/js/azkaban.history.view.js b/src/web/js/azkaban.history.view.js
index 323a313..01bb55d 100644
--- a/src/web/js/azkaban.history.view.js
+++ b/src/web/js/azkaban.history.view.js
@@ -6,26 +6,34 @@ azkaban.AdvFilterView = Backbone.View.extend({
"click #filter-btn": "handleAdvFilter"
},
initialize: function(settings) {
- $( "#daterangebegin" ).datepicker();
- $( "#daterangeend" ).datepicker();
-// $( "#daterangeend" ).datepicker('setDate', new Date());
+ $( "#datetimebegin" ).datetimepicker({
+ dateFormat: "mm/dd/yy",
+ separator: '-',
+ timeFormat: "HH:mm"
+ });
+ $( "#datetimeend" ).datetimepicker({
+ dateFormat: "mm/dd/yy",
+ separator: '-',
+ timeFormat: "HH:mm"
+ });
$("#errorMsg").hide();
},
handleAdvFilter: function(evt) {
console.log("handleAdv");
- var projre = $('#projRe').val();
- var flowre = $('#flowRe').val();
- var userre = $('#userRe').val();
- var begin = $('#daterangebegin').val();
- var end = $('#daterangeend').val();
-
+ var projcontain = $('#projcontain').val();
+ var flowcontain = $('#flowcontain').val();
+ var usercontain = $('#usercontain').val();
+ var status = $('#status').val();
+ var begin = $('#datetimebegin').val();
+ var end = $('#datetimeend').val();
+
console.log("filtering history");
var historyURL = contextURL + "/history"
var redirectURL = contextURL + "/schedule"
- var requestURL = historyURL + "?advfilter=true&projre=" + projre + "&flowre=" + flowre + "&userre=" + userre + "&begin=" + begin + "&end=" + end ;
+ var requestURL = historyURL + "?advfilter=true" + "&projcontain=" + projcontain + "&flowcontain=" + flowcontain + "&usercontain=" + usercontain + "&status=" + status + "&begin=" + begin + "&end=" + end ;
window.location = requestURL;
// $.get(
diff --git a/src/web/js/azkaban.job.status.utils.js b/src/web/js/azkaban.job.status.utils.js
index 848a351..7d4b45d 100644
--- a/src/web/js/azkaban.job.status.utils.js
+++ b/src/web/js/azkaban.job.status.utils.js
@@ -1,5 +1,7 @@
var statusList = ["FAILED", "FAILED_FINISHING", "SUCCEEDED", "RUNNING", "WAITING", "KILLED", "DISABLED", "READY", "UNKNOWN", "PAUSED", "SKIPPED"];
var statusStringMap = {
+ "SKIPPED": "Skipped",
+ "PREPARING": "Preparing",
"FAILED": "Failed",
"SUCCEEDED": "Success",
"FAILED_FINISHING": "Running w/Failure",
src/web/js/azkaban.joblog.view.js 89(+56 -33)
diff --git a/src/web/js/azkaban.joblog.view.js b/src/web/js/azkaban.joblog.view.js
index e81bfb3..97c5bdf 100644
--- a/src/web/js/azkaban.joblog.view.js
+++ b/src/web/js/azkaban.joblog.view.js
@@ -9,44 +9,68 @@ azkaban.JobLogView = Backbone.View.extend({
"click #updateLogBtn" : "handleUpdate"
},
initialize: function(settings) {
- this.model.set({"current": 0});
+ this.model.set({"offset": 0});
this.handleUpdate();
},
handleUpdate: function(evt) {
- var current = this.model.get("current");
var requestURL = contextURL + "/executor";
var model = this.model;
+ var finished = false;
- ajaxLogsCall(
- requestURL,
- {"execid": execId, "job": jobId, "ajax":"fetchExecJobLogs", "current": current, "max": 100000},
- function(data) {
- console.log("fetchLogs");
- if (data.error) {
- showDialog("Error", data.error);
- }
- else {
- var re = /(https?:\/\/(([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?))/g;
- var log = $("#logSection").text();
- if (!log) {
- log = data.log;
- }
- else {
- log += data.log;
- }
-
- current = data.current;
-
- $("#logSection").text(log);
- log = $("#logSection").html();
- log = log.replace(re, "<a href=\"$1\" title=\"\">$1</a>");
- $("#logSection").html(log);
-
- model.set({"current": current, "log": log});
- $(".logViewer").scrollTop(9999);
- }
- }
- );
+ var date = new Date();
+ var startTime = date.getTime();
+
+ while(!finished) {
+ var offset = this.model.get("offset");
+ $.ajax({
+ url: requestURL,
+ type: "get",
+ async: false,
+ dataType: "json",
+ data: {"execid": execId, "jobId": jobId, "ajax":"fetchExecJobLogs", "offset": offset, "length": 50000},
+ error: function(data) {
+ console.log(data);
+ finished = true;
+ },
+ success: function(data) {
+ console.log("fetchLogs");
+ if (data.error) {
+ console.log(data.error);
+ finished = true;
+ }
+ else if (data.length == 0) {
+ finished = true;
+ }
+ else {
+ var date = new Date();
+ var endTime = date.getTime();
+ if ((endTime - startTime) > 10000) {
+ finished = true;
+ showDialog("Alert","The log are taking a long time to finish loading. Azkaban has stopped loading them. Please click Refresh to restart the load.");
+ }
+
+ var re = /(https?:\/\/(([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?))/g;
+ var log = $("#logSection").text();
+ if (!log) {
+ log = data.data;
+ }
+ else {
+ log += data.data;
+ }
+
+ var newOffset = data.offset + data.length;
+
+ $("#logSection").text(log);
+ log = $("#logSection").html();
+ log = log.replace(re, "<a href=\"$1\" title=\"\">$1</a>");
+ $("#logSection").html(log);
+
+ model.set({"offset": newOffset, "log": log});
+ $(".logViewer").scrollTop(9999);
+ }
+ }
+ });
+ }
}
});
@@ -68,7 +92,6 @@ var showDialog = function(title, message) {
});
}
-
$(function() {
var selected;
src/web/js/azkaban.login.js 46(+46 -0)
diff --git a/src/web/js/azkaban.login.js b/src/web/js/azkaban.login.js
new file mode 100644
index 0000000..31851c4
--- /dev/null
+++ b/src/web/js/azkaban.login.js
@@ -0,0 +1,46 @@
+
+$.namespace('azkaban');
+
+var loginView;
+azkaban.LoginView= Backbone.View.extend({
+ events : {
+ "click #loginSubmit": "handleLogin",
+ 'keypress input': 'handleKeyPress'
+ },
+ initialize : function(settings) {
+ $('#errorMsg').hide();
+ },
+ handleLogin : function(evt) {
+ console.log("Logging in.");
+ var username = $("#username").val();
+ var password = $("#password").val();
+
+ $.ajax({
+ async: "false",
+ url: contextURL,
+ dataType: "json",
+ type: "POST",
+ data: {action:"login", username:username, password:password},
+ success: function(data) {
+ if (data.error) {
+ $('#errorMsg').text(data.error);
+ $('#errorMsg').slideDown('fast');
+ }
+ else {
+ document.location.reload();
+ }
+ }
+ });
+ },
+ handleKeyPress : function(evt) {
+ if (evt.charCode == 13 || evt.keyCode == 13) {
+ this.handleLogin();
+ }
+ },
+ render: function() {
+ }
+});
+
+$(function() {
+ loginView = new azkaban.LoginView({el:$('#loginForm')});
+});
src/web/js/azkaban.permission.view.js 65(+44 -21)
diff --git a/src/web/js/azkaban.permission.view.js b/src/web/js/azkaban.permission.view.js
index d6c0bbb..429b8ed 100644
--- a/src/web/js/azkaban.permission.view.js
+++ b/src/web/js/azkaban.permission.view.js
@@ -1,17 +1,19 @@
$.namespace('azkaban');
var permissionTableView;
+var groupPermissionTableView;
azkaban.PermissionTableView= Backbone.View.extend({
events : {
"click button": "handleChangePermission"
},
initialize : function(settings) {
+ this.group = settings.group;
},
render: function() {
},
handleChangePermission: function(evt) {
var currentTarget = evt.currentTarget;
- changePermissionView.display(currentTarget.id, false);
+ changePermissionView.display(currentTarget.id, false, this.group);
}
});
@@ -25,20 +27,28 @@ azkaban.ChangePermissionView= Backbone.View.extend({
initialize : function(settings) {
$('#errorMsg').hide();
},
- display: function(userid, newUser) {
- this.userid = userid;
+ display: function(userid, newPerm, group) {
+ // 6 is the length of the prefix "group-"
+ this.userid = group ? userid.substring(6, userid.length) : userid;
this.permission = {};
- $('#user-box').val(userid);
- this.newUser = newUser;
+ $('#user-box').val(this.userid);
+ this.newPerm = newPerm;
+ this.group = group;
- var adminInput = $("#" + userid + "-admin-checkbox");
- var readInput = $("#" + userid + "-read-checkbox");
- var writeInput = $("#" + userid + "-write-checkbox");
- var executeInput = $("#" + userid + "-execute-checkbox");
- var scheduleInput = $("#" + userid + "-schedule-checkbox");
+ var prefix = userid;
+ var adminInput = $("#" + prefix + "-admin-checkbox");
+ var readInput = $("#" + prefix + "-read-checkbox");
+ var writeInput = $("#" + prefix + "-write-checkbox");
+ var executeInput = $("#" + prefix + "-execute-checkbox");
+ var scheduleInput = $("#" + prefix + "-schedule-checkbox");
- if (newUser) {
- $('#change-title').text("Add New User");
+ if (newPerm) {
+ if (group) {
+ $('#change-title').text("Add New Group Permissions");
+ }
+ else {
+ $('#change-title').text("Add New User Permissions");
+ }
$('#user-box').attr("disabled", null);
// default
@@ -49,7 +59,13 @@ azkaban.ChangePermissionView= Backbone.View.extend({
this.permission.schedule = false;
}
else {
- $('#change-title').text("Change Permissions");
+ if (group) {
+ $('#change-title').text("Change Group Permissions");
+ }
+ else {
+ $('#change-title').text("Change User Permissions");
+ }
+
$('#user-box').attr("disabled", "disabled");
this.permission.admin = $(adminInput).attr("checked");
@@ -86,6 +102,7 @@ azkaban.ChangePermissionView= Backbone.View.extend({
},
changeCheckbox : function(evt) {
var perm = this.permission;
+
if (perm.admin) {
$("#admin-change").attr("checked", true);
$("#read-change").attr("checked", true);
@@ -122,7 +139,7 @@ azkaban.ChangePermissionView= Backbone.View.extend({
$("#change-btn").text("Commit");
}
else {
- if( this.newUser) {
+ if( this.newPerm) {
$("#change-btn").disabled = true;
$("#change-btn").addClass("btn-disabled");
}
@@ -133,12 +150,13 @@ azkaban.ChangePermissionView= Backbone.View.extend({
},
handleChangePermissions : function(evt) {
var requestURL = contextURL + "/manager";
- var userID = $('#user-box').val();
- var command = this.newUser ? "addUserPermission" : "changeUserPermission";
-
+ var name = $('#user-box').val();
+ var command = this.newPerm ? "addPermission" : "changePermission";
+ var group = this.group;
+
$.get(
requestURL,
- {"project": projectId, "username": userID, "ajax":command, "permissions": this.permission},
+ {"project": projectName, "name": name, "ajax":command, "permissions": this.permission, "group": group},
function(data) {
console.log("Output");
if (data.error) {
@@ -147,7 +165,7 @@ azkaban.ChangePermissionView= Backbone.View.extend({
return;
}
- var replaceURL = requestURL + "?project=" + projectId +"&permissions";
+ var replaceURL = requestURL + "?project=" + projectName +"&permissions";
window.location.replace(replaceURL);
},
"json"
@@ -156,10 +174,15 @@ azkaban.ChangePermissionView= Backbone.View.extend({
});
$(function() {
- permissionTableView = new azkaban.PermissionTableView({el:$('#permissions-table')});
+ permissionTableView = new azkaban.PermissionTableView({el:$('#permissions-table'), group: false});
+ groupPermissionTableView = new azkaban.PermissionTableView({el:$('#group-permissions-table'), group: true});
changePermissionView = new azkaban.ChangePermissionView({el:$('#change-permission')});
$('#addUser').bind('click', function() {
- changePermissionView.display("", true);
+ changePermissionView.display("", true, false);
+ });
+
+ $('#addGroup').bind('click', function() {
+ changePermissionView.display("", true, true);
});
});
src/web/js/azkaban.projectlog.view.js 61(+58 -3)
diff --git a/src/web/js/azkaban.projectlog.view.js b/src/web/js/azkaban.projectlog.view.js
index 5dd8314..c3006cf 100644
--- a/src/web/js/azkaban.projectlog.view.js
+++ b/src/web/js/azkaban.projectlog.view.js
@@ -3,6 +3,19 @@ $.namespace('azkaban');
var logModel;
azkaban.LogModel = Backbone.Model.extend({});
+// From ProjectLogEvent.java
+// ERROR(128), CREATED(1), DELETED(2), USER_PERMISSION(3), GROUP_PERMISSION(4), DESCRIPTION(5);
+var typeMapping = {
+ "ERROR": "Error",
+ "CREATED": "Project Created",
+ "DELETED": "Project Deleted",
+ "USER_PERMISSION" : "User Permission",
+ "GROUP_PERMISSION" : "Group Permission",
+ "DESCRIPTION" : "Description Set",
+ "SCHEDULE": "Schedule",
+ "UPLOADED": "Uploaded"
+};
+
var projectLogView;
azkaban.ProjectLogView = Backbone.View.extend({
events: {
@@ -19,16 +32,58 @@ azkaban.ProjectLogView = Backbone.View.extend({
$.get(
requestURL,
- {"project": projectName, "ajax":"fetchProjectLogs", "tail": 100000},
+ {"project": projectName, "ajax":"fetchProjectLogs", "size": 1000, "skip": 0 },
function(data) {
console.log("fetchLogs");
if (data.error) {
showDialog("Error", data.error);
}
else {
- $("#logSection").text(data);
+ // Get the columns to map to the values.
+ var columns = data.columns;
+ var columnMap = {};
+ for (var i =0; i < columns.length; ++i) {
+ columnMap[columns[i]] = i;
+ }
+ var logSection = $("#logTable");
+ $(logSection).empty();
+ var logData = data.logData;
+ for (var i = 0; i < logData.length; ++i) {
+ var event = logData[i];
+ var user = event[columnMap['user']];
+ var time = event[columnMap['time']];
+ var type = event[columnMap['type']];
+ var message = event[columnMap['message']];
+
+ var containerEvent = document.createElement("tr");
+ $(containerEvent).addClass("projectEvent");
+
+ var containerTime = document.createElement("td");
+ $(containerTime).addClass("time");
+ $(containerTime).text(getDateFormat(new Date(time)));
+
+ var containerUser = document.createElement("td");
+ $(containerUser).addClass("user");
+ $(containerUser).text(user);
+
+ var containerType = document.createElement("td");
+ $(containerType).addClass("type");
+ $(containerType).addClass(type);
+ $(containerType).text(typeMapping[type] ? typeMapping[type] : type);
+
+ var containerMessage = document.createElement("td");
+ $(containerMessage).addClass("message");
+ $(containerMessage).text(message);
+
+ $(containerEvent).append(containerTime);
+ $(containerEvent).append(containerUser);
+ $(containerEvent).append(containerType);
+ $(containerEvent).append(containerMessage);
+
+ $(logSection).append(containerEvent);
+ }
+
model.set({"log": data});
- $(".logViewer").scrollTop(9999);
}
}
);
src/web/js/azkaban.scheduled.view.js 4(+2 -2)
diff --git a/src/web/js/azkaban.scheduled.view.js b/src/web/js/azkaban.scheduled.view.js
index e035d63..5cea0ac 100644
--- a/src/web/js/azkaban.scheduled.view.js
+++ b/src/web/js/azkaban.scheduled.view.js
@@ -1,11 +1,11 @@
$.namespace('azkaban');
-function removeSched(schedId) {
+function removeSched(projectId, flowName) {
var scheduleURL = contextURL + "/schedule"
var redirectURL = contextURL + "/schedule"
$.post(
scheduleURL,
- {"action":"removeSched", "scheduleId":schedId},
+ {"action":"removeSched", "projectId":projectId, "flowName":flowName},
function(data) {
if (data.error) {
// alert(data.error)
src/web/js/jquery/jquery-1.8.3.js 9472(+9472 -0)
diff --git a/src/web/js/jquery/jquery-1.8.3.js b/src/web/js/jquery/jquery-1.8.3.js
new file mode 100644
index 0000000..a86bf79
--- /dev/null
+++ b/src/web/js/jquery/jquery-1.8.3.js
@@ -0,0 +1,9472 @@
+/*!
+ * jQuery JavaScript Library v1.8.3
+ * http://jquery.com/
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ *
+ * Copyright 2012 jQuery Foundation and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
+ *
+ * Date: Tue Nov 13 2012 08:20:33 GMT-0500 (Eastern Standard Time)
+ */
+(function( window, undefined ) {
+var
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // The deferred used on DOM ready
+ readyList,
+
+ // Use the correct document accordingly with window argument (sandbox)
+ document = window.document,
+ location = window.location,
+ navigator = window.navigator,
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // Save a reference to some core methods
+ core_push = Array.prototype.push,
+ core_slice = Array.prototype.slice,
+ core_indexOf = Array.prototype.indexOf,
+ core_toString = Object.prototype.toString,
+ core_hasOwn = Object.prototype.hasOwnProperty,
+ core_trim = String.prototype.trim,
+
+ // Define a local copy of jQuery
+ jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context, rootjQuery );
+ },
+
+ // Used for matching numbers
+ core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,
+
+ // Used for detecting and trimming whitespace
+ core_rnotwhite = /\S/,
+ core_rspace = /\s+/,
+
+ // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
+ rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
+
+ // A simple way to check for HTML strings
+ // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
+ rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
+
+ // JSON RegExp
+ rvalidchars = /^[\],:{}\s]*$/,
+ rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
+ rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
+ rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,
+
+ // Matches dashed string for camelizing
+ rmsPrefix = /^-ms-/,
+ rdashAlpha = /-([\da-z])/gi,
+
+ // Used by jQuery.camelCase as callback to replace()
+ fcamelCase = function( all, letter ) {
+ return ( letter + "" ).toUpperCase();
+ },
+
+ // The ready event handler and self cleanup method
+ DOMContentLoaded = function() {
+ if ( document.addEventListener ) {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ } else if ( document.readyState === "complete" ) {
+ // we're here because readyState === "complete" in oldIE
+ // which is good enough for us to call the dom ready!
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ },
+
+ // [[Class]] -> type pairs
+ class2type = {};
+
+jQuery.fn = jQuery.prototype = {
+ constructor: jQuery,
+ init: function( selector, context, rootjQuery ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), $(undefined), $(false)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
+ // Assume that strings that start and end with <> are HTML and skip the regex check
+ match = [ null, selector, null ];
+
+ } else {
+ match = rquickExpr.exec( selector );
+ }
+
+ // Match html or make sure no context is specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ context = context instanceof jQuery ? context[0] : context;
+ doc = ( context && context.nodeType ? context.ownerDocument || context : document );
+
+ // scripts is true for back-compat
+ selector = jQuery.parseHTML( match[1], doc, true );
+ if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
+ this.attr.call( selector, context, true );
+ }
+
+ return jQuery.merge( this, selector );
+
+ // HANDLE: $(#id)
+ } else {
+ elem = document.getElementById( match[2] );
+
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ if ( elem && elem.parentNode ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return ( context || rootjQuery ).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return this.constructor( context ).find( selector );
+ }
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if ( selector.selector !== undefined ) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.8.3",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return core_slice.call( this );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this[ this.length + num ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+
+ // Build a new jQuery matched element set
+ var ret = jQuery.merge( this.constructor(), elems );
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Add the callback
+ jQuery.ready.promise().done( fn );
+
+ return this;
+ },
+
+ eq: function( i ) {
+ i = +i;
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( core_slice.apply( this, arguments ),
+ "slice", core_slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || this.constructor(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: core_push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ var options, name, src, copy, copyIsArray, clone,
+ target = arguments[0] || {},
+ i = 1,
+ length = arguments.length,
+ deep = false;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging plain objects or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
+ if ( copyIsArray ) {
+ copyIsArray = false;
+ clone = src && jQuery.isArray(src) ? src : [];
+
+ } else {
+ clone = src && jQuery.isPlainObject(src) ? src : {};
+ }
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ if ( window.$ === jQuery ) {
+ window.$ = _$;
+ }
+
+ if ( deep && window.jQuery === jQuery ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // A counter to track how many items to wait for before
+ // the ready event fires. See #6781
+ readyWait: 1,
+
+ // Hold (or release) the ready event
+ holdReady: function( hold ) {
+ if ( hold ) {
+ jQuery.readyWait++;
+ } else {
+ jQuery.ready( true );
+ }
+ },
+
+ // Handle when the DOM is ready
+ ready: function( wait ) {
+
+ // Abort if there are pending holds or we're already ready
+ if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
+ return;
+ }
+
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 1 );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If a normal DOM Ready event fired, decrement, and wait if need be
+ if ( wait !== true && --jQuery.readyWait > 0 ) {
+ return;
+ }
+
+ // If there are functions bound, to execute
+ readyList.resolveWith( document, [ jQuery ] );
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.trigger ) {
+ jQuery( document ).trigger("ready").off("ready");
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return jQuery.type(obj) === "function";
+ },
+
+ isArray: Array.isArray || function( obj ) {
+ return jQuery.type(obj) === "array";
+ },
+
+ isWindow: function( obj ) {
+ return obj != null && obj == obj.window;
+ },
+
+ isNumeric: function( obj ) {
+ return !isNaN( parseFloat(obj) ) && isFinite( obj );
+ },
+
+ type: function( obj ) {
+ return obj == null ?
+ String( obj ) :
+ class2type[ core_toString.call(obj) ] || "object";
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
+ return false;
+ }
+
+ try {
+ // Not own constructor property must be Object
+ if ( obj.constructor &&
+ !core_hasOwn.call(obj, "constructor") &&
+ !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+ } catch ( e ) {
+ // IE8,9 Will throw exceptions on certain host objects #9897
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || core_hasOwn.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ var name;
+ for ( name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ error: function( msg ) {
+ throw new Error( msg );
+ },
+
+ // data: string of html
+ // context (optional): If specified, the fragment will be created in this context, defaults to document
+ // scripts (optional): If true, will include scripts passed in the html string
+ parseHTML: function( data, context, scripts ) {
+ var parsed;
+ if ( !data || typeof data !== "string" ) {
+ return null;
+ }
+ if ( typeof context === "boolean" ) {
+ scripts = context;
+ context = 0;
+ }
+ context = context || document;
+
+ // Single tag
+ if ( (parsed = rsingleTag.exec( data )) ) {
+ return [ context.createElement( parsed[1] ) ];
+ }
+
+ parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] );
+ return jQuery.merge( [],
+ (parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes );
+ },
+
+ parseJSON: function( data ) {
+ if ( !data || typeof data !== "string") {
+ return null;
+ }
+
+ // Make sure leading/trailing whitespace is removed (IE can't handle it)
+ data = jQuery.trim( data );
+
+ // Attempt to parse using the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ return window.JSON.parse( data );
+ }
+
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if ( rvalidchars.test( data.replace( rvalidescape, "@" )
+ .replace( rvalidtokens, "]" )
+ .replace( rvalidbraces, "")) ) {
+
+ return ( new Function( "return " + data ) )();
+
+ }
+ jQuery.error( "Invalid JSON: " + data );
+ },
+
+ // Cross-browser xml parsing
+ parseXML: function( data ) {
+ var xml, tmp;
+ if ( !data || typeof data !== "string" ) {
+ return null;
+ }
+ try {
+ if ( window.DOMParser ) { // Standard
+ tmp = new DOMParser();
+ xml = tmp.parseFromString( data , "text/xml" );
+ } else { // IE
+ xml = new ActiveXObject( "Microsoft.XMLDOM" );
+ xml.async = "false";
+ xml.loadXML( data );
+ }
+ } catch( e ) {
+ xml = undefined;
+ }
+ if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
+ jQuery.error( "Invalid XML: " + data );
+ }
+ return xml;
+ },
+
+ noop: function() {},
+
+ // Evaluates a script in a global context
+ // Workarounds based on findings by Jim Driscoll
+ // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
+ globalEval: function( data ) {
+ if ( data && core_rnotwhite.test( data ) ) {
+ // We use execScript on Internet Explorer
+ // We use an anonymous function so that context is window
+ // rather than jQuery in Firefox
+ ( window.execScript || function( data ) {
+ window[ "eval" ].call( window, data );
+ } )( data );
+ }
+ },
+
+ // Convert dashed to camelCase; used by the css and data modules
+ // Microsoft forgot to hump their vendor prefix (#9572)
+ camelCase: function( string ) {
+ return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
+ },
+
+ // args is for internal usage only
+ each: function( obj, callback, args ) {
+ var name,
+ i = 0,
+ length = obj.length,
+ isObj = length === undefined || jQuery.isFunction( obj );
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in obj ) {
+ if ( callback.apply( obj[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( obj[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in obj ) {
+ if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) {
+ break;
+ }
+ }
+ }
+ }
+
+ return obj;
+ },
+
+ // Use native String.trim function wherever possible
+ trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
+ function( text ) {
+ return text == null ?
+ "" :
+ core_trim.call( text );
+ } :
+
+ // Otherwise use our own trimming functionality
+ function( text ) {
+ return text == null ?
+ "" :
+ ( text + "" ).replace( rtrim, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( arr, results ) {
+ var type,
+ ret = results || [];
+
+ if ( arr != null ) {
+ // The window, strings (and functions) also have 'length'
+ // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
+ type = jQuery.type( arr );
+
+ if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) {
+ core_push.call( ret, arr );
+ } else {
+ jQuery.merge( ret, arr );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, arr, i ) {
+ var len;
+
+ if ( arr ) {
+ if ( core_indexOf ) {
+ return core_indexOf.call( arr, elem, i );
+ }
+
+ len = arr.length;
+ i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
+
+ for ( ; i < len; i++ ) {
+ // Skip accessing in sparse arrays
+ if ( i in arr && arr[ i ] === elem ) {
+ return i;
+ }
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var l = second.length,
+ i = first.length,
+ j = 0;
+
+ if ( typeof l === "number" ) {
+ for ( ; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var retVal,
+ ret = [],
+ i = 0,
+ length = elems.length;
+ inv = !!inv;
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( ; i < length; i++ ) {
+ retVal = !!callback( elems[ i ], i );
+ if ( inv !== retVal ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var value, key,
+ ret = [],
+ i = 0,
+ length = elems.length,
+ // jquery objects are treated as arrays
+ isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
+
+ // Go through the array, translating each of the items to their
+ if ( isArray ) {
+ for ( ; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ // Go through every key on the object,
+ } else {
+ for ( key in elems ) {
+ value = callback( elems[ key ], key, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+ }
+
+ // Flatten any nested arrays
+ return ret.concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ // Bind a function to a context, optionally partially applying any
+ // arguments.
+ proxy: function( fn, context ) {
+ var tmp, args, proxy;
+
+ if ( typeof context === "string" ) {
+ tmp = fn[ context ];
+ context = fn;
+ fn = tmp;
+ }
+
+ // Quick check to determine if target is callable, in the spec
+ // this throws a TypeError, but we will just return undefined.
+ if ( !jQuery.isFunction( fn ) ) {
+ return undefined;
+ }
+
+ // Simulated bind
+ args = core_slice.call( arguments, 2 );
+ proxy = function() {
+ return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
+ };
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ proxy.guid = fn.guid = fn.guid || jQuery.guid++;
+
+ return proxy;
+ },
+
+ // Multifunctional method to get and set values of a collection
+ // The value/s can optionally be executed if it's a function
+ access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
+ var exec,
+ bulk = key == null,
+ i = 0,
+ length = elems.length;
+
+ // Sets many values
+ if ( key && typeof key === "object" ) {
+ for ( i in key ) {
+ jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
+ }
+ chainable = 1;
+
+ // Sets one value
+ } else if ( value !== undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = pass === undefined && jQuery.isFunction( value );
+
+ if ( bulk ) {
+ // Bulk operations only iterate when executing function values
+ if ( exec ) {
+ exec = fn;
+ fn = function( elem, key, value ) {
+ return exec.call( jQuery( elem ), value );
+ };
+
+ // Otherwise they run against the entire set
+ } else {
+ fn.call( elems, value );
+ fn = null;
+ }
+ }
+
+ if ( fn ) {
+ for (; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+ }
+
+ chainable = 1;
+ }
+
+ return chainable ?
+ elems :
+
+ // Gets
+ bulk ?
+ fn.call( elems ) :
+ length ? fn( elems[0], key ) : emptyGet;
+ },
+
+ now: function() {
+ return ( new Date() ).getTime();
+ }
+});
+
+jQuery.ready.promise = function( obj ) {
+ if ( !readyList ) {
+
+ readyList = jQuery.Deferred();
+
+ // Catch cases where $(document).ready() is called after the browser event has already occurred.
+ // we once tried to use readyState "interactive" here, but it caused issues like the one
+ // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
+ if ( document.readyState === "complete" ) {
+ // Handle it asynchronously to allow scripts the opportunity to delay ready
+ setTimeout( jQuery.ready, 1 );
+
+ // Standards-based browsers support DOMContentLoaded
+ } else if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else {
+ // Ensure firing before onload, maybe late but safe also for iframes
+ document.attachEvent( "onreadystatechange", DOMContentLoaded );
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var top = false;
+
+ try {
+ top = window.frameElement == null && document.documentElement;
+ } catch(e) {}
+
+ if ( top && top.doScroll ) {
+ (function doScrollCheck() {
+ if ( !jQuery.isReady ) {
+
+ try {
+ // Use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ top.doScroll("left");
+ } catch(e) {
+ return setTimeout( doScrollCheck, 50 );
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+ }
+ })();
+ }
+ }
+ }
+ return readyList.promise( obj );
+};
+
+// Populate the class2type map
+jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
+ class2type[ "[object " + name + "]" ] = name.toLowerCase();
+});
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+// String to Object options format cache
+var optionsCache = {};
+
+// Convert String-formatted options into Object-formatted ones and store in cache
+function createOptions( options ) {
+ var object = optionsCache[ options ] = {};
+ jQuery.each( options.split( core_rspace ), function( _, flag ) {
+ object[ flag ] = true;
+ });
+ return object;
+}
+
+/*
+ * Create a callback list using the following parameters:
+ *
+ * options: an optional list of space-separated options that will change how
+ * the callback list behaves or a more traditional option object
+ *
+ * By default a callback list will act like an event callback list and can be
+ * "fired" multiple times.
+ *
+ * Possible options:
+ *
+ * once: will ensure the callback list can only be fired once (like a Deferred)
+ *
+ * memory: will keep track of previous values and will call any callback added
+ * after the list has been fired right away with the latest "memorized"
+ * values (like a Deferred)
+ *
+ * unique: will ensure a callback can only be added once (no duplicate in the list)
+ *
+ * stopOnFalse: interrupt callings when a callback returns false
+ *
+ */
+jQuery.Callbacks = function( options ) {
+
+ // Convert options from String-formatted to Object-formatted if needed
+ // (we check in cache first)
+ options = typeof options === "string" ?
+ ( optionsCache[ options ] || createOptions( options ) ) :
+ jQuery.extend( {}, options );
+
+ var // Last fire value (for non-forgettable lists)
+ memory,
+ // Flag to know if list was already fired
+ fired,
+ // Flag to know if list is currently firing
+ firing,
+ // First callback to fire (used internally by add and fireWith)
+ firingStart,
+ // End of the loop when firing
+ firingLength,
+ // Index of currently firing callback (modified by remove if needed)
+ firingIndex,
+ // Actual callback list
+ list = [],
+ // Stack of fire calls for repeatable lists
+ stack = !options.once && [],
+ // Fire callbacks
+ fire = function( data ) {
+ memory = options.memory && data;
+ fired = true;
+ firingIndex = firingStart || 0;
+ firingStart = 0;
+ firingLength = list.length;
+ firing = true;
+ for ( ; list && firingIndex < firingLength; firingIndex++ ) {
+ if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
+ memory = false; // To prevent further calls using add
+ break;
+ }
+ }
+ firing = false;
+ if ( list ) {
+ if ( stack ) {
+ if ( stack.length ) {
+ fire( stack.shift() );
+ }
+ } else if ( memory ) {
+ list = [];
+ } else {
+ self.disable();
+ }
+ }
+ },
+ // Actual Callbacks object
+ self = {
+ // Add a callback or a collection of callbacks to the list
+ add: function() {
+ if ( list ) {
+ // First, we save the current length
+ var start = list.length;
+ (function add( args ) {
+ jQuery.each( args, function( _, arg ) {
+ var type = jQuery.type( arg );
+ if ( type === "function" ) {
+ if ( !options.unique || !self.has( arg ) ) {
+ list.push( arg );
+ }
+ } else if ( arg && arg.length && type !== "string" ) {
+ // Inspect recursively
+ add( arg );
+ }
+ });
+ })( arguments );
+ // Do we need to add the callbacks to the
+ // current firing batch?
+ if ( firing ) {
+ firingLength = list.length;
+ // With memory, if we're not firing then
+ // we should call right away
+ } else if ( memory ) {
+ firingStart = start;
+ fire( memory );
+ }
+ }
+ return this;
+ },
+ // Remove a callback from the list
+ remove: function() {
+ if ( list ) {
+ jQuery.each( arguments, function( _, arg ) {
+ var index;
+ while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
+ list.splice( index, 1 );
+ // Handle firing indexes
+ if ( firing ) {
+ if ( index <= firingLength ) {
+ firingLength--;
+ }
+ if ( index <= firingIndex ) {
+ firingIndex--;
+ }
+ }
+ }
+ });
+ }
+ return this;
+ },
+ // Control if a given callback is in the list
+ has: function( fn ) {
+ return jQuery.inArray( fn, list ) > -1;
+ },
+ // Remove all callbacks from the list
+ empty: function() {
+ list = [];
+ return this;
+ },
+ // Have the list do nothing anymore
+ disable: function() {
+ list = stack = memory = undefined;
+ return this;
+ },
+ // Is it disabled?
+ disabled: function() {
+ return !list;
+ },
+ // Lock the list in its current state
+ lock: function() {
+ stack = undefined;
+ if ( !memory ) {
+ self.disable();
+ }
+ return this;
+ },
+ // Is it locked?
+ locked: function() {
+ return !stack;
+ },
+ // Call all callbacks with the given context and arguments
+ fireWith: function( context, args ) {
+ args = args || [];
+ args = [ context, args.slice ? args.slice() : args ];
+ if ( list && ( !fired || stack ) ) {
+ if ( firing ) {
+ stack.push( args );
+ } else {
+ fire( args );
+ }
+ }
+ return this;
+ },
+ // Call all the callbacks with the given arguments
+ fire: function() {
+ self.fireWith( this, arguments );
+ return this;
+ },
+ // To know if the callbacks have already been called at least once
+ fired: function() {
+ return !!fired;
+ }
+ };
+
+ return self;
+};
+jQuery.extend({
+
+ Deferred: function( func ) {
+ var tuples = [
+ // action, add listener, listener list, final state
+ [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
+ [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
+ [ "notify", "progress", jQuery.Callbacks("memory") ]
+ ],
+ state = "pending",
+ promise = {
+ state: function() {
+ return state;
+ },
+ always: function() {
+ deferred.done( arguments ).fail( arguments );
+ return this;
+ },
+ then: function( /* fnDone, fnFail, fnProgress */ ) {
+ var fns = arguments;
+ return jQuery.Deferred(function( newDefer ) {
+ jQuery.each( tuples, function( i, tuple ) {
+ var action = tuple[ 0 ],
+ fn = fns[ i ];
+ // deferred[ done | fail | progress ] for forwarding actions to newDefer
+ deferred[ tuple[1] ]( jQuery.isFunction( fn ) ?
+ function() {
+ var returned = fn.apply( this, arguments );
+ if ( returned && jQuery.isFunction( returned.promise ) ) {
+ returned.promise()
+ .done( newDefer.resolve )
+ .fail( newDefer.reject )
+ .progress( newDefer.notify );
+ } else {
+ newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
+ }
+ } :
+ newDefer[ action ]
+ );
+ });
+ fns = null;
+ }).promise();
+ },
+ // Get a promise for this deferred
+ // If obj is provided, the promise aspect is added to the object
+ promise: function( obj ) {
+ return obj != null ? jQuery.extend( obj, promise ) : promise;
+ }
+ },
+ deferred = {};
+
+ // Keep pipe for back-compat
+ promise.pipe = promise.then;
+
+ // Add list-specific methods
+ jQuery.each( tuples, function( i, tuple ) {
+ var list = tuple[ 2 ],
+ stateString = tuple[ 3 ];
+
+ // promise[ done | fail | progress ] = list.add
+ promise[ tuple[1] ] = list.add;
+
+ // Handle state
+ if ( stateString ) {
+ list.add(function() {
+ // state = [ resolved | rejected ]
+ state = stateString;
+
+ // [ reject_list | resolve_list ].disable; progress_list.lock
+ }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
+ }
+
+ // deferred[ resolve | reject | notify ] = list.fire
+ deferred[ tuple[0] ] = list.fire;
+ deferred[ tuple[0] + "With" ] = list.fireWith;
+ });
+
+ // Make the deferred a promise
+ promise.promise( deferred );
+
+ // Call given func if any
+ if ( func ) {
+ func.call( deferred, deferred );
+ }
+
+ // All done!
+ return deferred;
+ },
+
+ // Deferred helper
+ when: function( subordinate /* , ..., subordinateN */ ) {
+ var i = 0,
+ resolveValues = core_slice.call( arguments ),
+ length = resolveValues.length,
+
+ // the count of uncompleted subordinates
+ remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
+
+ // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
+ deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
+
+ // Update function for both resolve and progress values
+ updateFunc = function( i, contexts, values ) {
+ return function( value ) {
+ contexts[ i ] = this;
+ values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
+ if( values === progressValues ) {
+ deferred.notifyWith( contexts, values );
+ } else if ( !( --remaining ) ) {
+ deferred.resolveWith( contexts, values );
+ }
+ };
+ },
+
+ progressValues, progressContexts, resolveContexts;
+
+ // add listeners to Deferred subordinates; treat others as resolved
+ if ( length > 1 ) {
+ progressValues = new Array( length );
+ progressContexts = new Array( length );
+ resolveContexts = new Array( length );
+ for ( ; i < length; i++ ) {
+ if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
+ resolveValues[ i ].promise()
+ .done( updateFunc( i, resolveContexts, resolveValues ) )
+ .fail( deferred.reject )
+ .progress( updateFunc( i, progressContexts, progressValues ) );
+ } else {
+ --remaining;
+ }
+ }
+ }
+
+ // if we're not waiting on anything, resolve the master
+ if ( !remaining ) {
+ deferred.resolveWith( resolveContexts, resolveValues );
+ }
+
+ return deferred.promise();
+ }
+});
+jQuery.support = (function() {
+
+ var support,
+ all,
+ a,
+ select,
+ opt,
+ input,
+ fragment,
+ eventName,
+ i,
+ isSupported,
+ clickFn,
+ div = document.createElement("div");
+
+ // Setup
+ div.setAttribute( "className", "t" );
+ div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
+
+ // Support tests won't run in some limited or non-browser environments
+ all = div.getElementsByTagName("*");
+ a = div.getElementsByTagName("a")[ 0 ];
+ if ( !all || !a || !all.length ) {
+ return {};
+ }
+
+ // First batch of tests
+ select = document.createElement("select");
+ opt = select.appendChild( document.createElement("option") );
+ input = div.getElementsByTagName("input")[ 0 ];
+
+ a.style.cssText = "top:1px;float:left;opacity:.5";
+ support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: ( div.firstChild.nodeType === 3 ),
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText instead)
+ style: /top/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: ( a.getAttribute("href") === "/a" ),
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.5/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: ( input.value === "on" ),
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: opt.selected,
+
+ // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
+ getSetAttribute: div.className !== "t",
+
+ // Tests for enctype support on a form (#6743)
+ enctype: !!document.createElement("form").enctype,
+
+ // Makes sure cloning an html5 element does not cause problems
+ // Where outerHTML is undefined, this still works
+ html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
+
+ // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
+ boxModel: ( document.compatMode === "CSS1Compat" ),
+
+ // Will be defined later
+ submitBubbles: true,
+ changeBubbles: true,
+ focusinBubbles: false,
+ deleteExpando: true,
+ noCloneEvent: true,
+ inlineBlockNeedsLayout: false,
+ shrinkWrapBlocks: false,
+ reliableMarginRight: true,
+ boxSizingReliable: true,
+ pixelPosition: false
+ };
+
+ // Make sure checked status is properly cloned
+ input.checked = true;
+ support.noCloneChecked = input.cloneNode( true ).checked;
+
+ // Make sure that the options inside disabled selects aren't marked as disabled
+ // (WebKit marks them as disabled)
+ select.disabled = true;
+ support.optDisabled = !opt.disabled;
+
+ // Test to see if it's possible to delete an expando from an element
+ // Fails in Internet Explorer
+ try {
+ delete div.test;
+ } catch( e ) {
+ support.deleteExpando = false;
+ }
+
+ if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
+ div.attachEvent( "onclick", clickFn = function() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ support.noCloneEvent = false;
+ });
+ div.cloneNode( true ).fireEvent("onclick");
+ div.detachEvent( "onclick", clickFn );
+ }
+
+ // Check if a radio maintains its value
+ // after being appended to the DOM
+ input = document.createElement("input");
+ input.value = "t";
+ input.setAttribute( "type", "radio" );
+ support.radioValue = input.value === "t";
+
+ input.setAttribute( "checked", "checked" );
+
+ // #11217 - WebKit loses check when the name is after the checked attribute
+ input.setAttribute( "name", "t" );
+
+ div.appendChild( input );
+ fragment = document.createDocumentFragment();
+ fragment.appendChild( div.lastChild );
+
+ // WebKit doesn't clone checked state correctly in fragments
+ support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
+
+ // Check if a disconnected checkbox will retain its checked
+ // value of true after appended to the DOM (IE6/7)
+ support.appendChecked = input.checked;
+
+ fragment.removeChild( input );
+ fragment.appendChild( div );
+
+ // Technique from Juriy Zaytsev
+ // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
+ // We only care about the case where non-standard event systems
+ // are used, namely in IE. Short-circuiting here helps us to
+ // avoid an eval call (in setAttribute) which can cause CSP
+ // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
+ if ( div.attachEvent ) {
+ for ( i in {
+ submit: true,
+ change: true,
+ focusin: true
+ }) {
+ eventName = "on" + i;
+ isSupported = ( eventName in div );
+ if ( !isSupported ) {
+ div.setAttribute( eventName, "return;" );
+ isSupported = ( typeof div[ eventName ] === "function" );
+ }
+ support[ i + "Bubbles" ] = isSupported;
+ }
+ }
+
+ // Run tests that need a body at doc ready
+ jQuery(function() {
+ var container, div, tds, marginDiv,
+ divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;",
+ body = document.getElementsByTagName("body")[0];
+
+ if ( !body ) {
+ // Return for frameset docs that don't have a body
+ return;
+ }
+
+ container = document.createElement("div");
+ container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";
+ body.insertBefore( container, body.firstChild );
+
+ // Construct the test element
+ div = document.createElement("div");
+ container.appendChild( div );
+
+ // Check if table cells still have offsetWidth/Height when they are set
+ // to display:none and there are still other visible table cells in a
+ // table row; if so, offsetWidth/Height are not reliable for use when
+ // determining if an element has been hidden directly using
+ // display:none (it is still safe to use offsets if a parent element is
+ // hidden; don safety goggles and see bug #4512 for more information).
+ // (only IE 8 fails this test)
+ div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
+ tds = div.getElementsByTagName("td");
+ tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
+ isSupported = ( tds[ 0 ].offsetHeight === 0 );
+
+ tds[ 0 ].style.display = "";
+ tds[ 1 ].style.display = "none";
+
+ // Check if empty table cells still have offsetWidth/Height
+ // (IE <= 8 fail this test)
+ support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
+
+ // Check box-sizing and margin behavior
+ div.innerHTML = "";
+ div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
+ support.boxSizing = ( div.offsetWidth === 4 );
+ support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
+
+ // NOTE: To any future maintainer, we've window.getComputedStyle
+ // because jsdom on node.js will break without it.
+ if ( window.getComputedStyle ) {
+ support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
+ support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
+
+ // Check if div with explicit width and no margin-right incorrectly
+ // gets computed margin-right based on width of container. For more
+ // info see bug #3333
+ // Fails in WebKit before Feb 2011 nightlies
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ marginDiv = document.createElement("div");
+ marginDiv.style.cssText = div.style.cssText = divReset;
+ marginDiv.style.marginRight = marginDiv.style.width = "0";
+ div.style.width = "1px";
+ div.appendChild( marginDiv );
+ support.reliableMarginRight =
+ !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
+ }
+
+ if ( typeof div.style.zoom !== "undefined" ) {
+ // Check if natively block-level elements act like inline-block
+ // elements when setting their display to 'inline' and giving
+ // them layout
+ // (IE < 8 does this)
+ div.innerHTML = "";
+ div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
+ support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
+
+ // Check if elements with layout shrink-wrap their children
+ // (IE 6 does this)
+ div.style.display = "block";
+ div.style.overflow = "visible";
+ div.innerHTML = "<div></div>";
+ div.firstChild.style.width = "5px";
+ support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
+
+ container.style.zoom = 1;
+ }
+
+ // Null elements to avoid leaks in IE
+ body.removeChild( container );
+ container = div = tds = marginDiv = null;
+ });
+
+ // Null elements to avoid leaks in IE
+ fragment.removeChild( div );
+ all = a = select = opt = input = fragment = div = null;
+
+ return support;
+})();
+var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
+ rmultiDash = /([A-Z])/g;
+
+jQuery.extend({
+ cache: {},
+
+ deletedIds: [],
+
+ // Remove at next major release (1.9/2.0)
+ uuid: 0,
+
+ // Unique for each copy of jQuery on the page
+ // Non-digits removed to match rinlinejQuery
+ expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ // Ban all objects except for Flash (which handle expandos)
+ "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
+ "applet": true
+ },
+
+ hasData: function( elem ) {
+ elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
+ return !!elem && !isEmptyDataObject( elem );
+ },
+
+ data: function( elem, name, data, pvt /* Internal Use Only */ ) {
+ if ( !jQuery.acceptData( elem ) ) {
+ return;
+ }
+
+ var thisCache, ret,
+ internalKey = jQuery.expando,
+ getByName = typeof name === "string",
+
+ // We have to handle DOM nodes and JS objects differently because IE6-7
+ // can't GC object references properly across the DOM-JS boundary
+ isNode = elem.nodeType,
+
+ // Only DOM nodes need the global jQuery cache; JS object data is
+ // attached directly to the object so GC can occur automatically
+ cache = isNode ? jQuery.cache : elem,
+
+ // Only defining an ID for JS objects if its cache already exists allows
+ // the code to shortcut on the same path as a DOM node with no cache
+ id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
+
+ // Avoid doing any more work than we need to when trying to get data on an
+ // object that has no data at all
+ if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
+ return;
+ }
+
+ if ( !id ) {
+ // Only DOM nodes need a new unique ID for each element since their data
+ // ends up in the global cache
+ if ( isNode ) {
+ elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++;
+ } else {
+ id = internalKey;
+ }
+ }
+
+ if ( !cache[ id ] ) {
+ cache[ id ] = {};
+
+ // Avoids exposing jQuery metadata on plain JS objects when the object
+ // is serialized using JSON.stringify
+ if ( !isNode ) {
+ cache[ id ].toJSON = jQuery.noop;
+ }
+ }
+
+ // An object can be passed to jQuery.data instead of a key/value pair; this gets
+ // shallow copied over onto the existing cache
+ if ( typeof name === "object" || typeof name === "function" ) {
+ if ( pvt ) {
+ cache[ id ] = jQuery.extend( cache[ id ], name );
+ } else {
+ cache[ id ].data = jQuery.extend( cache[ id ].data, name );
+ }
+ }
+
+ thisCache = cache[ id ];
+
+ // jQuery data() is stored in a separate object inside the object's internal data
+ // cache in order to avoid key collisions between internal data and user-defined
+ // data.
+ if ( !pvt ) {
+ if ( !thisCache.data ) {
+ thisCache.data = {};
+ }
+
+ thisCache = thisCache.data;
+ }
+
+ if ( data !== undefined ) {
+ thisCache[ jQuery.camelCase( name ) ] = data;
+ }
+
+ // Check for both converted-to-camel and non-converted data property names
+ // If a data property was specified
+ if ( getByName ) {
+
+ // First Try to find as-is property data
+ ret = thisCache[ name ];
+
+ // Test for null|undefined property data
+ if ( ret == null ) {
+
+ // Try to find the camelCased property
+ ret = thisCache[ jQuery.camelCase( name ) ];
+ }
+ } else {
+ ret = thisCache;
+ }
+
+ return ret;
+ },
+
+ removeData: function( elem, name, pvt /* Internal Use Only */ ) {
+ if ( !jQuery.acceptData( elem ) ) {
+ return;
+ }
+
+ var thisCache, i, l,
+
+ isNode = elem.nodeType,
+
+ // See jQuery.data for more information
+ cache = isNode ? jQuery.cache : elem,
+ id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
+
+ // If there is already no cache entry for this object, there is no
+ // purpose in continuing
+ if ( !cache[ id ] ) {
+ return;
+ }
+
+ if ( name ) {
+
+ thisCache = pvt ? cache[ id ] : cache[ id ].data;
+
+ if ( thisCache ) {
+
+ // Support array or space separated string names for data keys
+ if ( !jQuery.isArray( name ) ) {
+
+ // try the string as a key before any manipulation
+ if ( name in thisCache ) {
+ name = [ name ];
+ } else {
+
+ // split the camel cased version by spaces unless a key with the spaces exists
+ name = jQuery.camelCase( name );
+ if ( name in thisCache ) {
+ name = [ name ];
+ } else {
+ name = name.split(" ");
+ }
+ }
+ }
+
+ for ( i = 0, l = name.length; i < l; i++ ) {
+ delete thisCache[ name[i] ];
+ }
+
+ // If there is no data left in the cache, we want to continue
+ // and let the cache object itself get destroyed
+ if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
+ return;
+ }
+ }
+ }
+
+ // See jQuery.data for more information
+ if ( !pvt ) {
+ delete cache[ id ].data;
+
+ // Don't destroy the parent cache unless the internal data object
+ // had been the only thing left in it
+ if ( !isEmptyDataObject( cache[ id ] ) ) {
+ return;
+ }
+ }
+
+ // Destroy the cache
+ if ( isNode ) {
+ jQuery.cleanData( [ elem ], true );
+
+ // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
+ } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
+ delete cache[ id ];
+
+ // When all else fails, null
+ } else {
+ cache[ id ] = null;
+ }
+ },
+
+ // For internal use only.
+ _data: function( elem, name, data ) {
+ return jQuery.data( elem, name, data, true );
+ },
+
+ // A method for determining if a DOM node can handle the data expando
+ acceptData: function( elem ) {
+ var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
+
+ // nodes accept data unless otherwise specified; rejection can be conditional
+ return !noData || noData !== true && elem.getAttribute("classid") === noData;
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ var parts, part, attr, name, l,
+ elem = this[0],
+ i = 0,
+ data = null;
+
+ // Gets all values
+ if ( key === undefined ) {
+ if ( this.length ) {
+ data = jQuery.data( elem );
+
+ if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
+ attr = elem.attributes;
+ for ( l = attr.length; i < l; i++ ) {
+ name = attr[i].name;
+
+ if ( !name.indexOf( "data-" ) ) {
+ name = jQuery.camelCase( name.substring(5) );
+
+ dataAttr( elem, name, data[ name ] );
+ }
+ }
+ jQuery._data( elem, "parsedAttrs", true );
+ }
+ }
+
+ return data;
+ }
+
+ // Sets multiple values
+ if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ parts = key.split( ".", 2 );
+ parts[1] = parts[1] ? "." + parts[1] : "";
+ part = parts[1] + "!";
+
+ return jQuery.access( this, function( value ) {
+
+ if ( value === undefined ) {
+ data = this.triggerHandler( "getData" + part, [ parts[0] ] );
+
+ // Try to fetch any internally stored data first
+ if ( data === undefined && elem ) {
+ data = jQuery.data( elem, key );
+ data = dataAttr( elem, key, data );
+ }
+
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ }
+
+ parts[1] = value;
+ this.each(function() {
+ var self = jQuery( this );
+
+ self.triggerHandler( "setData" + part, parts );
+ jQuery.data( this, key, value );
+ self.triggerHandler( "changeData" + part, parts );
+ });
+ }, null, value, arguments.length > 1, null, false );
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+
+function dataAttr( elem, key, data ) {
+ // If nothing was found internally, try to fetch any
+ // data from the HTML5 data-* attribute
+ if ( data === undefined && elem.nodeType === 1 ) {
+
+ var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
+
+ data = elem.getAttribute( name );
+
+ if ( typeof data === "string" ) {
+ try {
+ data = data === "true" ? true :
+ data === "false" ? false :
+ data === "null" ? null :
+ // Only convert to a number if it doesn't change the string
+ +data + "" === data ? +data :
+ rbrace.test( data ) ? jQuery.parseJSON( data ) :
+ data;
+ } catch( e ) {}
+
+ // Make sure we set the data so it isn't changed later
+ jQuery.data( elem, key, data );
+
+ } else {
+ data = undefined;
+ }
+ }
+
+ return data;
+}
+
+// checks a cache object for emptiness
+function isEmptyDataObject( obj ) {
+ var name;
+ for ( name in obj ) {
+
+ // if the public data object is empty, the private is still empty
+ if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
+ continue;
+ }
+ if ( name !== "toJSON" ) {
+ return false;
+ }
+ }
+
+ return true;
+}
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ var queue;
+
+ if ( elem ) {
+ type = ( type || "fx" ) + "queue";
+ queue = jQuery._data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( data ) {
+ if ( !queue || jQuery.isArray(data) ) {
+ queue = jQuery._data( elem, type, jQuery.makeArray(data) );
+ } else {
+ queue.push( data );
+ }
+ }
+ return queue || [];
+ }
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ),
+ startLength = queue.length,
+ fn = queue.shift(),
+ hooks = jQuery._queueHooks( elem, type ),
+ next = function() {
+ jQuery.dequeue( elem, type );
+ };
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ startLength--;
+ }
+
+ if ( fn ) {
+
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift( "inprogress" );
+ }
+
+ // clear up the last queue stop function
+ delete hooks.stop;
+ fn.call( elem, next, hooks );
+ }
+
+ if ( !startLength && hooks ) {
+ hooks.empty.fire();
+ }
+ },
+
+ // not intended for public consumption - generates a queueHooks object, or returns the current one
+ _queueHooks: function( elem, type ) {
+ var key = type + "queueHooks";
+ return jQuery._data( elem, key ) || jQuery._data( elem, key, {
+ empty: jQuery.Callbacks("once memory").add(function() {
+ jQuery.removeData( elem, type + "queue", true );
+ jQuery.removeData( elem, key, true );
+ })
+ });
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ var setter = 2;
+
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ setter--;
+ }
+
+ if ( arguments.length < setter ) {
+ return jQuery.queue( this[0], type );
+ }
+
+ return data === undefined ?
+ this :
+ this.each(function() {
+ var queue = jQuery.queue( this, type, data );
+
+ // ensure a hooks for this queue
+ jQuery._queueHooks( this, type );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function( next, hooks ) {
+ var timeout = setTimeout( next, time );
+ hooks.stop = function() {
+ clearTimeout( timeout );
+ };
+ });
+ },
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ },
+ // Get a promise resolved when queues of a certain type
+ // are emptied (fx is the type by default)
+ promise: function( type, obj ) {
+ var tmp,
+ count = 1,
+ defer = jQuery.Deferred(),
+ elements = this,
+ i = this.length,
+ resolve = function() {
+ if ( !( --count ) ) {
+ defer.resolveWith( elements, [ elements ] );
+ }
+ };
+
+ if ( typeof type !== "string" ) {
+ obj = type;
+ type = undefined;
+ }
+ type = type || "fx";
+
+ while( i-- ) {
+ tmp = jQuery._data( elements[ i ], type + "queueHooks" );
+ if ( tmp && tmp.empty ) {
+ count++;
+ tmp.empty.add( resolve );
+ }
+ }
+ resolve();
+ return defer.promise( obj );
+ }
+});
+var nodeHook, boolHook, fixSpecified,
+ rclass = /[\t\r\n]/g,
+ rreturn = /\r/g,
+ rtype = /^(?:button|input)$/i,
+ rfocusable = /^(?:button|input|object|select|textarea)$/i,
+ rclickable = /^a(?:rea|)$/i,
+ rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
+ getSetAttribute = jQuery.support.getSetAttribute;
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
+ },
+
+ removeAttr: function( name ) {
+ return this.each(function() {
+ jQuery.removeAttr( this, name );
+ });
+ },
+
+ prop: function( name, value ) {
+ return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
+ },
+
+ removeProp: function( name ) {
+ name = jQuery.propFix[ name ] || name;
+ return this.each(function() {
+ // try/catch handles cases where IE balks (such as removing a property on window)
+ try {
+ this[ name ] = undefined;
+ delete this[ name ];
+ } catch( e ) {}
+ });
+ },
+
+ addClass: function( value ) {
+ var classNames, i, l, elem,
+ setClass, c, cl;
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( j ) {
+ jQuery( this ).addClass( value.call(this, j, this.className) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ classNames = value.split( core_rspace );
+
+ for ( i = 0, l = this.length; i < l; i++ ) {
+ elem = this[ i ];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className && classNames.length === 1 ) {
+ elem.className = value;
+
+ } else {
+ setClass = " " + elem.className + " ";
+
+ for ( c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
+ setClass += classNames[ c ] + " ";
+ }
+ }
+ elem.className = jQuery.trim( setClass );
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ var removes, className, elem, c, cl, i, l;
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( j ) {
+ jQuery( this ).removeClass( value.call(this, j, this.className) );
+ });
+ }
+ if ( (value && typeof value === "string") || value === undefined ) {
+ removes = ( value || "" ).split( core_rspace );
+
+ for ( i = 0, l = this.length; i < l; i++ ) {
+ elem = this[ i ];
+ if ( elem.nodeType === 1 && elem.className ) {
+
+ className = (" " + elem.className + " ").replace( rclass, " " );
+
+ // loop over each item in the removal list
+ for ( c = 0, cl = removes.length; c < cl; c++ ) {
+ // Remove until there is nothing to remove,
+ while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
+ className = className.replace( " " + removes[ c ] + " " , " " );
+ }
+ }
+ elem.className = value ? jQuery.trim( className ) : "";
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value,
+ isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( i ) {
+ jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className,
+ i = 0,
+ self = jQuery( this ),
+ state = stateVal,
+ classNames = value.split( core_rspace );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space separated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery._data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ",
+ i = 0,
+ l = this.length;
+ for ( ; i < l; i++ ) {
+ if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ var hooks, ret, isFunction,
+ elem = this[0];
+
+ if ( !arguments.length ) {
+ if ( elem ) {
+ hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
+
+ if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
+ return ret;
+ }
+
+ ret = elem.value;
+
+ return typeof ret === "string" ?
+ // handle most common string cases
+ ret.replace(rreturn, "") :
+ // handle cases where value is null/undef or number
+ ret == null ? "" : ret;
+ }
+
+ return;
+ }
+
+ isFunction = jQuery.isFunction( value );
+
+ return this.each(function( i ) {
+ var val,
+ self = jQuery(this);
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call( this, i, self.val() );
+ } else {
+ val = value;
+ }
+
+ // Treat null/undefined as ""; convert numbers to string
+ if ( val == null ) {
+ val = "";
+ } else if ( typeof val === "number" ) {
+ val += "";
+ } else if ( jQuery.isArray( val ) ) {
+ val = jQuery.map(val, function ( value ) {
+ return value == null ? "" : value + "";
+ });
+ }
+
+ hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
+
+ // If set returns undefined, fall back to normal setting
+ if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ valHooks: {
+ option: {
+ get: function( elem ) {
+ // attributes.value is undefined in Blackberry 4.7 but
+ // uses .value. See #6932
+ var val = elem.attributes.value;
+ return !val || val.specified ? elem.value : elem.text;
+ }
+ },
+ select: {
+ get: function( elem ) {
+ var value, option,
+ options = elem.options,
+ index = elem.selectedIndex,
+ one = elem.type === "select-one" || index < 0,
+ values = one ? null : [],
+ max = one ? index + 1 : options.length,
+ i = index < 0 ?
+ max :
+ one ? index : 0;
+
+ // Loop through all the selected options
+ for ( ; i < max; i++ ) {
+ option = options[ i ];
+
+ // oldIE doesn't update selected after form reset (#2551)
+ if ( ( option.selected || i === index ) &&
+ // Don't return options that are disabled or in a disabled optgroup
+ ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
+ ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
+
+ // Get the specific value for the option
+ value = jQuery( option ).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ },
+
+ set: function( elem, value ) {
+ var values = jQuery.makeArray( value );
+
+ jQuery(elem).find("option").each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ elem.selectedIndex = -1;
+ }
+ return values;
+ }
+ }
+ },
+
+ // Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9
+ attrFn: {},
+
+ attr: function( elem, name, value, pass ) {
+ var ret, hooks, notxml,
+ nType = elem.nodeType;
+
+ // don't get/set attributes on text, comment and attribute nodes
+ if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+ return;
+ }
+
+ if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) {
+ return jQuery( elem )[ name ]( value );
+ }
+
+ // Fallback to prop when attributes are not supported
+ if ( typeof elem.getAttribute === "undefined" ) {
+ return jQuery.prop( elem, name, value );
+ }
+
+ notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+
+ // All attributes are lowercase
+ // Grab necessary hook if one is defined
+ if ( notxml ) {
+ name = name.toLowerCase();
+ hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
+ }
+
+ if ( value !== undefined ) {
+
+ if ( value === null ) {
+ jQuery.removeAttr( elem, name );
+ return;
+
+ } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
+ return ret;
+
+ } else {
+ elem.setAttribute( name, value + "" );
+ return value;
+ }
+
+ } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
+ return ret;
+
+ } else {
+
+ ret = elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return ret === null ?
+ undefined :
+ ret;
+ }
+ },
+
+ removeAttr: function( elem, value ) {
+ var propName, attrNames, name, isBool,
+ i = 0;
+
+ if ( value && elem.nodeType === 1 ) {
+
+ attrNames = value.split( core_rspace );
+
+ for ( ; i < attrNames.length; i++ ) {
+ name = attrNames[ i ];
+
+ if ( name ) {
+ propName = jQuery.propFix[ name ] || name;
+ isBool = rboolean.test( name );
+
+ // See #9699 for explanation of this approach (setting first, then removal)
+ // Do not do this for boolean attributes (see #10870)
+ if ( !isBool ) {
+ jQuery.attr( elem, name, "" );
+ }
+ elem.removeAttribute( getSetAttribute ? name : propName );
+
+ // Set corresponding property to false for boolean attributes
+ if ( isBool && propName in elem ) {
+ elem[ propName ] = false;
+ }
+ }
+ }
+ }
+ },
+
+ attrHooks: {
+ type: {
+ set: function( elem, value ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
+ jQuery.error( "type property can't be changed" );
+ } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
+ // Setting the type on a radio button after the value resets the value in IE6-9
+ // Reset value to it's default in case type is set after value
+ // This is for element creation
+ var val = elem.value;
+ elem.setAttribute( "type", value );
+ if ( val ) {
+ elem.value = val;
+ }
+ return value;
+ }
+ }
+ },
+ // Use the value property for back compat
+ // Use the nodeHook for button elements in IE6/7 (#1954)
+ value: {
+ get: function( elem, name ) {
+ if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
+ return nodeHook.get( elem, name );
+ }
+ return name in elem ?
+ elem.value :
+ null;
+ },
+ set: function( elem, value, name ) {
+ if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
+ return nodeHook.set( elem, value, name );
+ }
+ // Does not return so that setAttribute is also used
+ elem.value = value;
+ }
+ }
+ },
+
+ propFix: {
+ tabindex: "tabIndex",
+ readonly: "readOnly",
+ "for": "htmlFor",
+ "class": "className",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ cellpadding: "cellPadding",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ usemap: "useMap",
+ frameborder: "frameBorder",
+ contenteditable: "contentEditable"
+ },
+
+ prop: function( elem, name, value ) {
+ var ret, hooks, notxml,
+ nType = elem.nodeType;
+
+ // don't get/set properties on text, comment and attribute nodes
+ if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+ return;
+ }
+
+ notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+
+ if ( notxml ) {
+ // Fix name and attach hooks
+ name = jQuery.propFix[ name ] || name;
+ hooks = jQuery.propHooks[ name ];
+ }
+
+ if ( value !== undefined ) {
+ if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
+ return ret;
+
+ } else {
+ return ( elem[ name ] = value );
+ }
+
+ } else {
+ if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
+ return ret;
+
+ } else {
+ return elem[ name ];
+ }
+ }
+ },
+
+ propHooks: {
+ tabIndex: {
+ get: function( elem ) {
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ var attributeNode = elem.getAttributeNode("tabindex");
+
+ return attributeNode && attributeNode.specified ?
+ parseInt( attributeNode.value, 10 ) :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+ }
+ }
+});
+
+// Hook for boolean attributes
+boolHook = {
+ get: function( elem, name ) {
+ // Align boolean attributes with corresponding properties
+ // Fall back to attribute presence where some booleans are not supported
+ var attrNode,
+ property = jQuery.prop( elem, name );
+ return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
+ name.toLowerCase() :
+ undefined;
+ },
+ set: function( elem, value, name ) {
+ var propName;
+ if ( value === false ) {
+ // Remove boolean attributes when set to false
+ jQuery.removeAttr( elem, name );
+ } else {
+ // value is true since we know at this point it's type boolean and not false
+ // Set boolean attributes to the same name and set the DOM property
+ propName = jQuery.propFix[ name ] || name;
+ if ( propName in elem ) {
+ // Only set the IDL specifically if it already exists on the element
+ elem[ propName ] = true;
+ }
+
+ elem.setAttribute( name, name.toLowerCase() );
+ }
+ return name;
+ }
+};
+
+// IE6/7 do not support getting/setting some attributes with get/setAttribute
+if ( !getSetAttribute ) {
+
+ fixSpecified = {
+ name: true,
+ id: true,
+ coords: true
+ };
+
+ // Use this for any attribute in IE6/7
+ // This fixes almost every IE6/7 issue
+ nodeHook = jQuery.valHooks.button = {
+ get: function( elem, name ) {
+ var ret;
+ ret = elem.getAttributeNode( name );
+ return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ?
+ ret.value :
+ undefined;
+ },
+ set: function( elem, value, name ) {
+ // Set the existing or create a new attribute node
+ var ret = elem.getAttributeNode( name );
+ if ( !ret ) {
+ ret = document.createAttribute( name );
+ elem.setAttributeNode( ret );
+ }
+ return ( ret.value = value + "" );
+ }
+ };
+
+ // Set width and height to auto instead of 0 on empty string( Bug #8150 )
+ // This is for removals
+ jQuery.each([ "width", "height" ], function( i, name ) {
+ jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
+ set: function( elem, value ) {
+ if ( value === "" ) {
+ elem.setAttribute( name, "auto" );
+ return value;
+ }
+ }
+ });
+ });
+
+ // Set contenteditable to false on removals(#10429)
+ // Setting to empty string throws an error as an invalid value
+ jQuery.attrHooks.contenteditable = {
+ get: nodeHook.get,
+ set: function( elem, value, name ) {
+ if ( value === "" ) {
+ value = "false";
+ }
+ nodeHook.set( elem, value, name );
+ }
+ };
+}
+
+
+// Some attributes require a special call on IE
+if ( !jQuery.support.hrefNormalized ) {
+ jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
+ jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
+ get: function( elem ) {
+ var ret = elem.getAttribute( name, 2 );
+ return ret === null ? undefined : ret;
+ }
+ });
+ });
+}
+
+if ( !jQuery.support.style ) {
+ jQuery.attrHooks.style = {
+ get: function( elem ) {
+ // Return undefined in the case of empty string
+ // Normalize to lowercase since IE uppercases css property names
+ return elem.style.cssText.toLowerCase() || undefined;
+ },
+ set: function( elem, value ) {
+ return ( elem.style.cssText = value + "" );
+ }
+ };
+}
+
+// Safari mis-reports the default selected property of an option
+// Accessing the parent's selectedIndex property fixes it
+if ( !jQuery.support.optSelected ) {
+ jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
+ get: function( elem ) {
+ var parent = elem.parentNode;
+
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ return null;
+ }
+ });
+}
+
+// IE6/7 call enctype encoding
+if ( !jQuery.support.enctype ) {
+ jQuery.propFix.enctype = "encoding";
+}
+
+// Radios and checkboxes getter/setter
+if ( !jQuery.support.checkOn ) {
+ jQuery.each([ "radio", "checkbox" ], function() {
+ jQuery.valHooks[ this ] = {
+ get: function( elem ) {
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+ };
+ });
+}
+jQuery.each([ "radio", "checkbox" ], function() {
+ jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
+ set: function( elem, value ) {
+ if ( jQuery.isArray( value ) ) {
+ return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
+ }
+ }
+ });
+});
+var rformElems = /^(?:textarea|input|select)$/i,
+ rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/,
+ rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
+ rkeyEvent = /^key/,
+ rmouseEvent = /^(?:mouse|contextmenu)|click/,
+ rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
+ hoverHack = function( events ) {
+ return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
+ };
+
+/*
+ * Helper functions for managing events -- not part of the public interface.
+ * Props to Dean Edwards' addEvent library for many of the ideas.
+ */
+jQuery.event = {
+
+ add: function( elem, types, handler, data, selector ) {
+
+ var elemData, eventHandle, events,
+ t, tns, type, namespaces, handleObj,
+ handleObjIn, handlers, special;
+
+ // Don't attach events to noData or text/comment nodes (allow plain objects tho)
+ if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
+ return;
+ }
+
+ // Caller can pass in an object of custom data in lieu of the handler
+ if ( handler.handler ) {
+ handleObjIn = handler;
+ handler = handleObjIn.handler;
+ selector = handleObjIn.selector;
+ }
+
+ // Make sure that the handler has a unique ID, used to find/remove it later
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // Init the element's event structure and main handler, if this is the first
+ events = elemData.events;
+ if ( !events ) {
+ elemData.events = events = {};
+ }
+ eventHandle = elemData.handle;
+ if ( !eventHandle ) {
+ elemData.handle = eventHandle = function( e ) {
+ // Discard the second event of a jQuery.event.trigger() and
+ // when an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
+ jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+ // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
+ eventHandle.elem = elem;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = jQuery.trim( hoverHack(types) ).split( " " );
+ for ( t = 0; t < types.length; t++ ) {
+
+ tns = rtypenamespace.exec( types[t] ) || [];
+ type = tns[1];
+ namespaces = ( tns[2] || "" ).split( "." ).sort();
+
+ // If event changes its type, use the special event handlers for the changed type
+ special = jQuery.event.special[ type ] || {};
+
+ // If selector defined, determine special event api type, otherwise given type
+ type = ( selector ? special.delegateType : special.bindType ) || type;
+
+ // Update special based on newly reset type
+ special = jQuery.event.special[ type ] || {};
+
+ // handleObj is passed to all event handlers
+ handleObj = jQuery.extend({
+ type: type,
+ origType: tns[1],
+ data: data,
+ handler: handler,
+ guid: handler.guid,
+ selector: selector,
+ needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
+ namespace: namespaces.join(".")
+ }, handleObjIn );
+
+ // Init the event handler queue if we're the first
+ handlers = events[ type ];
+ if ( !handlers ) {
+ handlers = events[ type ] = [];
+ handlers.delegateCount = 0;
+
+ // Only use addEventListener/attachEvent if the special events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, eventHandle, false );
+
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, eventHandle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ special.add.call( elem, handleObj );
+
+ if ( !handleObj.handler.guid ) {
+ handleObj.handler.guid = handler.guid;
+ }
+ }
+
+ // Add to the element's handler list, delegates in front
+ if ( selector ) {
+ handlers.splice( handlers.delegateCount++, 0, handleObj );
+ } else {
+ handlers.push( handleObj );
+ }
+
+ // Keep track of which events have ever been used, for event optimization
+ jQuery.event.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler, selector, mappedTypes ) {
+
+ var t, tns, type, origType, namespaces, origCount,
+ j, events, special, eventType, handleObj,
+ elemData = jQuery.hasData( elem ) && jQuery._data( elem );
+
+ if ( !elemData || !(events = elemData.events) ) {
+ return;
+ }
+
+ // Once for each type.namespace in types; type may be omitted
+ types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
+ for ( t = 0; t < types.length; t++ ) {
+ tns = rtypenamespace.exec( types[t] ) || [];
+ type = origType = tns[1];
+ namespaces = tns[2];
+
+ // Unbind all events (on this namespace, if provided) for the element
+ if ( !type ) {
+ for ( type in events ) {
+ jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
+ }
+ continue;
+ }
+
+ special = jQuery.event.special[ type ] || {};
+ type = ( selector? special.delegateType : special.bindType ) || type;
+ eventType = events[ type ] || [];
+ origCount = eventType.length;
+ namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
+
+ // Remove matching events
+ for ( j = 0; j < eventType.length; j++ ) {
+ handleObj = eventType[ j ];
+
+ if ( ( mappedTypes || origType === handleObj.origType ) &&
+ ( !handler || handler.guid === handleObj.guid ) &&
+ ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
+ ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
+ eventType.splice( j--, 1 );
+
+ if ( handleObj.selector ) {
+ eventType.delegateCount--;
+ }
+ if ( special.remove ) {
+ special.remove.call( elem, handleObj );
+ }
+ }
+ }
+
+ // Remove generic event handler if we removed something and no more handlers exist
+ // (avoids potential for endless recursion during removal of special event handlers)
+ if ( eventType.length === 0 && origCount !== eventType.length ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
+ jQuery.removeEvent( elem, type, elemData.handle );
+ }
+
+ delete events[ type ];
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ if ( jQuery.isEmptyObject( events ) ) {
+ delete elemData.handle;
+
+ // removeData also checks for emptiness and clears the expando if empty
+ // so use it instead of delete
+ jQuery.removeData( elem, "events", true );
+ }
+ },
+
+ // Events that are safe to short-circuit if no handlers are attached.
+ // Native DOM events should not be added, they may have inline handlers.
+ customEvent: {
+ "getData": true,
+ "setData": true,
+ "changeData": true
+ },
+
+ trigger: function( event, data, elem, onlyHandlers ) {
+ // Don't do events on text and comment nodes
+ if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
+ return;
+ }
+
+ // Event object or event type
+ var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType,
+ type = event.type || event,
+ namespaces = [];
+
+ // focus/blur morphs to focusin/out; ensure we're not firing them right now
+ if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
+ return;
+ }
+
+ if ( type.indexOf( "!" ) >= 0 ) {
+ // Exclusive events trigger only for the exact event (no namespaces)
+ type = type.slice(0, -1);
+ exclusive = true;
+ }
+
+ if ( type.indexOf( "." ) >= 0 ) {
+ // Namespaced trigger; create a regexp to match event type in handle()
+ namespaces = type.split(".");
+ type = namespaces.shift();
+ namespaces.sort();
+ }
+
+ if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
+ // No jQuery handlers for this event type, and it can't have inline handlers
+ return;
+ }
+
+ // Caller can pass in an Event, Object, or just an event type string
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[ jQuery.expando ] ? event :
+ // Object literal
+ new jQuery.Event( type, event ) :
+ // Just the event type (string)
+ new jQuery.Event( type );
+
+ event.type = type;
+ event.isTrigger = true;
+ event.exclusive = exclusive;
+ event.namespace = namespaces.join( "." );
+ event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
+ ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
+
+ // Handle a global trigger
+ if ( !elem ) {
+
+ // TODO: Stop taunting the data cache; remove global events and always attach to document
+ cache = jQuery.cache;
+ for ( i in cache ) {
+ if ( cache[ i ].events && cache[ i ].events[ type ] ) {
+ jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
+ }
+ }
+ return;
+ }
+
+ // Clean up the event in case it is being reused
+ event.result = undefined;
+ if ( !event.target ) {
+ event.target = elem;
+ }
+
+ // Clone any incoming data and prepend the event, creating the handler arg list
+ data = data != null ? jQuery.makeArray( data ) : [];
+ data.unshift( event );
+
+ // Allow special events to draw outside the lines
+ special = jQuery.event.special[ type ] || {};
+ if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
+ return;
+ }
+
+ // Determine event propagation path in advance, per W3C events spec (#9951)
+ // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
+ eventPath = [[ elem, special.bindType || type ]];
+ if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
+
+ bubbleType = special.delegateType || type;
+ cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
+ for ( old = elem; cur; cur = cur.parentNode ) {
+ eventPath.push([ cur, bubbleType ]);
+ old = cur;
+ }
+
+ // Only add window if we got to document (e.g., not plain obj or detached DOM)
+ if ( old === (elem.ownerDocument || document) ) {
+ eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
+ }
+ }
+
+ // Fire handlers on the event path
+ for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
+
+ cur = eventPath[i][0];
+ event.type = eventPath[i][1];
+
+ handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
+ if ( handle ) {
+ handle.apply( cur, data );
+ }
+ // Note that this is a bare JS function and not a jQuery handler
+ handle = ontype && cur[ ontype ];
+ if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
+ event.preventDefault();
+ }
+ }
+ event.type = type;
+
+ // If nobody prevented the default action, do it now
+ if ( !onlyHandlers && !event.isDefaultPrevented() ) {
+
+ if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
+ !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
+
+ // Call a native DOM method on the target with the same name name as the event.
+ // Can't use an .isFunction() check here because IE6/7 fails that test.
+ // Don't do default actions on window, that's where global variables be (#6170)
+ // IE<9 dies on focus/blur to hidden element (#1486)
+ if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
+
+ // Don't re-trigger an onFOO event when we call its FOO() method
+ old = elem[ ontype ];
+
+ if ( old ) {
+ elem[ ontype ] = null;
+ }
+
+ // Prevent re-triggering of the same event, since we already bubbled it above
+ jQuery.event.triggered = type;
+ elem[ type ]();
+ jQuery.event.triggered = undefined;
+
+ if ( old ) {
+ elem[ ontype ] = old;
+ }
+ }
+ }
+ }
+
+ return event.result;
+ },
+
+ dispatch: function( event ) {
+
+ // Make a writable jQuery.Event from the native event object
+ event = jQuery.event.fix( event || window.event );
+
+ var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
+ handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
+ delegateCount = handlers.delegateCount,
+ args = core_slice.call( arguments ),
+ run_all = !event.exclusive && !event.namespace,
+ special = jQuery.event.special[ event.type ] || {},
+ handlerQueue = [];
+
+ // Use the fix-ed jQuery.Event rather than the (read-only) native event
+ args[0] = event;
+ event.delegateTarget = this;
+
+ // Call the preDispatch hook for the mapped type, and let it bail if desired
+ if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
+ return;
+ }
+
+ // Determine handlers that should run if there are delegated events
+ // Avoid non-left-click bubbling in Firefox (#3861)
+ if ( delegateCount && !(event.button && event.type === "click") ) {
+
+ for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
+
+ // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764)
+ if ( cur.disabled !== true || event.type !== "click" ) {
+ selMatch = {};
+ matches = [];
+ for ( i = 0; i < delegateCount; i++ ) {
+ handleObj = handlers[ i ];
+ sel = handleObj.selector;
+
+ if ( selMatch[ sel ] === undefined ) {
+ selMatch[ sel ] = handleObj.needsContext ?
+ jQuery( sel, this ).index( cur ) >= 0 :
+ jQuery.find( sel, this, null, [ cur ] ).length;
+ }
+ if ( selMatch[ sel ] ) {
+ matches.push( handleObj );
+ }
+ }
+ if ( matches.length ) {
+ handlerQueue.push({ elem: cur, matches: matches });
+ }
+ }
+ }
+ }
+
+ // Add the remaining (directly-bound) handlers
+ if ( handlers.length > delegateCount ) {
+ handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
+ }
+
+ // Run delegates first; they may want to stop propagation beneath us
+ for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
+ matched = handlerQueue[ i ];
+ event.currentTarget = matched.elem;
+
+ for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
+ handleObj = matched.matches[ j ];
+
+ // Triggered event must either 1) be non-exclusive and have no namespace, or
+ // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
+ if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
+
+ event.data = handleObj.data;
+ event.handleObj = handleObj;
+
+ ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
+ .apply( matched.elem, args );
+
+ if ( ret !== undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+ }
+ }
+ }
+
+ // Call the postDispatch hook for the mapped type
+ if ( special.postDispatch ) {
+ special.postDispatch.call( this, event );
+ }
+
+ return event.result;
+ },
+
+ // Includes some event props shared by KeyEvent and MouseEvent
+ // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
+ props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
+
+ fixHooks: {},
+
+ keyHooks: {
+ props: "char charCode key keyCode".split(" "),
+ filter: function( event, original ) {
+
+ // Add which for key events
+ if ( event.which == null ) {
+ event.which = original.charCode != null ? original.charCode : original.keyCode;
+ }
+
+ return event;
+ }
+ },
+
+ mouseHooks: {
+ props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
+ filter: function( event, original ) {
+ var eventDoc, doc, body,
+ button = original.button,
+ fromElement = original.fromElement;
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && original.clientX != null ) {
+ eventDoc = event.target.ownerDocument || document;
+ doc = eventDoc.documentElement;
+ body = eventDoc.body;
+
+ event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
+ event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && fromElement ) {
+ event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && button !== undefined ) {
+ event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
+ }
+
+ return event;
+ }
+ },
+
+ fix: function( event ) {
+ if ( event[ jQuery.expando ] ) {
+ return event;
+ }
+
+ // Create a writable copy of the event object and normalize some properties
+ var i, prop,
+ originalEvent = event,
+ fixHook = jQuery.event.fixHooks[ event.type ] || {},
+ copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
+
+ event = jQuery.Event( originalEvent );
+
+ for ( i = copy.length; i; ) {
+ prop = copy[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
+ if ( !event.target ) {
+ event.target = originalEvent.srcElement || document;
+ }
+
+ // Target should not be a text node (#504, Safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8)
+ event.metaKey = !!event.metaKey;
+
+ return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
+ },
+
+ special: {
+ load: {
+ // Prevent triggered image.load events from bubbling to window.load
+ noBubble: true
+ },
+
+ focus: {
+ delegateType: "focusin"
+ },
+ blur: {
+ delegateType: "focusout"
+ },
+
+ beforeunload: {
+ setup: function( data, namespaces, eventHandle ) {
+ // We only want to do this special case on windows
+ if ( jQuery.isWindow( this ) ) {
+ this.onbeforeunload = eventHandle;
+ }
+ },
+
+ teardown: function( namespaces, eventHandle ) {
+ if ( this.onbeforeunload === eventHandle ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ },
+
+ simulate: function( type, elem, event, bubble ) {
+ // Piggyback on a donor event to simulate a different one.
+ // Fake originalEvent to avoid donor's stopPropagation, but if the
+ // simulated event prevents default then we do the same on the donor.
+ var e = jQuery.extend(
+ new jQuery.Event(),
+ event,
+ { type: type,
+ isSimulated: true,
+ originalEvent: {}
+ }
+ );
+ if ( bubble ) {
+ jQuery.event.trigger( e, null, elem );
+ } else {
+ jQuery.event.dispatch.call( elem, e );
+ }
+ if ( e.isDefaultPrevented() ) {
+ event.preventDefault();
+ }
+ }
+};
+
+// Some plugins are using, but it's undocumented/deprecated and will be removed.
+// The 1.7 special event interface should provide all the hooks needed now.
+jQuery.event.handle = jQuery.event.dispatch;
+
+jQuery.removeEvent = document.removeEventListener ?
+ function( elem, type, handle ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, handle, false );
+ }
+ } :
+ function( elem, type, handle ) {
+ var name = "on" + type;
+
+ if ( elem.detachEvent ) {
+
+ // #8545, #7054, preventing memory leaks for custom events in IE6-8
+ // detachEvent needed property on element, by name of that event, to properly expose it to GC
+ if ( typeof elem[ name ] === "undefined" ) {
+ elem[ name ] = null;
+ }
+
+ elem.detachEvent( name, handle );
+ }
+ };
+
+jQuery.Event = function( src, props ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !(this instanceof jQuery.Event) ) {
+ return new jQuery.Event( src, props );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+
+ // Events bubbling up the document may have been marked as prevented
+ // by a handler lower down the tree; reflect the correct value.
+ this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
+ src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
+
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // Put explicitly provided properties onto the event object
+ if ( props ) {
+ jQuery.extend( this, props );
+ }
+
+ // Create a timestamp if incoming event doesn't have one
+ this.timeStamp = src && src.timeStamp || jQuery.now();
+
+ // Mark it as fixed
+ this[ jQuery.expando ] = true;
+};
+
+function returnFalse() {
+ return false;
+}
+function returnTrue() {
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+
+ // otherwise set the returnValue property of the original event to false (IE)
+ } else {
+ e.returnValue = false;
+ }
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+
+// Create mouseenter/leave events using mouseover/out and event-time checks
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ delegateType: fix,
+ bindType: fix,
+
+ handle: function( event ) {
+ var ret,
+ target = this,
+ related = event.relatedTarget,
+ handleObj = event.handleObj,
+ selector = handleObj.selector;
+
+ // For mousenter/leave call the handler if related is outside the target.
+ // NB: No relatedTarget if the mouse left/entered the browser window
+ if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
+ event.type = handleObj.origType;
+ ret = handleObj.handler.apply( this, arguments );
+ event.type = fix;
+ }
+ return ret;
+ }
+ };
+});
+
+// IE submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+ jQuery.event.special.submit = {
+ setup: function() {
+ // Only need this for delegated form submit events
+ if ( jQuery.nodeName( this, "form" ) ) {
+ return false;
+ }
+
+ // Lazy-add a submit handler when a descendant form may potentially be submitted
+ jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
+ // Node name check avoids a VML-related crash in IE (#9807)
+ var elem = e.target,
+ form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
+ if ( form && !jQuery._data( form, "_submit_attached" ) ) {
+ jQuery.event.add( form, "submit._submit", function( event ) {
+ event._submit_bubble = true;
+ });
+ jQuery._data( form, "_submit_attached", true );
+ }
+ });
+ // return undefined since we don't need an event listener
+ },
+
+ postDispatch: function( event ) {
+ // If form was submitted by the user, bubble the event up the tree
+ if ( event._submit_bubble ) {
+ delete event._submit_bubble;
+ if ( this.parentNode && !event.isTrigger ) {
+ jQuery.event.simulate( "submit", this.parentNode, event, true );
+ }
+ }
+ },
+
+ teardown: function() {
+ // Only need this for delegated form submit events
+ if ( jQuery.nodeName( this, "form" ) ) {
+ return false;
+ }
+
+ // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
+ jQuery.event.remove( this, "._submit" );
+ }
+ };
+}
+
+// IE change delegation and checkbox/radio fix
+if ( !jQuery.support.changeBubbles ) {
+
+ jQuery.event.special.change = {
+
+ setup: function() {
+
+ if ( rformElems.test( this.nodeName ) ) {
+ // IE doesn't fire change on a check/radio until blur; trigger it on click
+ // after a propertychange. Eat the blur-change in special.change.handle.
+ // This still fires onchange a second time for check/radio after blur.
+ if ( this.type === "checkbox" || this.type === "radio" ) {
+ jQuery.event.add( this, "propertychange._change", function( event ) {
+ if ( event.originalEvent.propertyName === "checked" ) {
+ this._just_changed = true;
+ }
+ });
+ jQuery.event.add( this, "click._change", function( event ) {
+ if ( this._just_changed && !event.isTrigger ) {
+ this._just_changed = false;
+ }
+ // Allow triggered, simulated change events (#11500)
+ jQuery.event.simulate( "change", this, event, true );
+ });
+ }
+ return false;
+ }
+ // Delegated event; lazy-add a change handler on descendant inputs
+ jQuery.event.add( this, "beforeactivate._change", function( e ) {
+ var elem = e.target;
+
+ if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) {
+ jQuery.event.add( elem, "change._change", function( event ) {
+ if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
+ jQuery.event.simulate( "change", this.parentNode, event, true );
+ }
+ });
+ jQuery._data( elem, "_change_attached", true );
+ }
+ });
+ },
+
+ handle: function( event ) {
+ var elem = event.target;
+
+ // Swallow native change events from checkbox/radio, we already triggered them above
+ if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
+ return event.handleObj.handler.apply( this, arguments );
+ }
+ },
+
+ teardown: function() {
+ jQuery.event.remove( this, "._change" );
+
+ return !rformElems.test( this.nodeName );
+ }
+ };
+}
+
+// Create "bubbling" focus and blur events
+if ( !jQuery.support.focusinBubbles ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+
+ // Attach a single capturing handler while someone wants focusin/focusout
+ var attaches = 0,
+ handler = function( event ) {
+ jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
+ };
+
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ if ( attaches++ === 0 ) {
+ document.addEventListener( orig, handler, true );
+ }
+ },
+ teardown: function() {
+ if ( --attaches === 0 ) {
+ document.removeEventListener( orig, handler, true );
+ }
+ }
+ };
+ });
+}
+
+jQuery.fn.extend({
+
+ on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
+ var origFn, type;
+
+ // Types can be a map of types/handlers
+ if ( typeof types === "object" ) {
+ // ( types-Object, selector, data )
+ if ( typeof selector !== "string" ) { // && selector != null
+ // ( types-Object, data )
+ data = data || selector;
+ selector = undefined;
+ }
+ for ( type in types ) {
+ this.on( type, selector, data, types[ type ], one );
+ }
+ return this;
+ }
+
+ if ( data == null && fn == null ) {
+ // ( types, fn )
+ fn = selector;
+ data = selector = undefined;
+ } else if ( fn == null ) {
+ if ( typeof selector === "string" ) {
+ // ( types, selector, fn )
+ fn = data;
+ data = undefined;
+ } else {
+ // ( types, data, fn )
+ fn = data;
+ data = selector;
+ selector = undefined;
+ }
+ }
+ if ( fn === false ) {
+ fn = returnFalse;
+ } else if ( !fn ) {
+ return this;
+ }
+
+ if ( one === 1 ) {
+ origFn = fn;
+ fn = function( event ) {
+ // Can use an empty set, since event contains the info
+ jQuery().off( event );
+ return origFn.apply( this, arguments );
+ };
+ // Use same guid so caller can remove using origFn
+ fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
+ }
+ return this.each( function() {
+ jQuery.event.add( this, types, fn, data, selector );
+ });
+ },
+ one: function( types, selector, data, fn ) {
+ return this.on( types, selector, data, fn, 1 );
+ },
+ off: function( types, selector, fn ) {
+ var handleObj, type;
+ if ( types && types.preventDefault && types.handleObj ) {
+ // ( event ) dispatched jQuery.Event
+ handleObj = types.handleObj;
+ jQuery( types.delegateTarget ).off(
+ handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
+ handleObj.selector,
+ handleObj.handler
+ );
+ return this;
+ }
+ if ( typeof types === "object" ) {
+ // ( types-object [, selector] )
+ for ( type in types ) {
+ this.off( type, selector, types[ type ] );
+ }
+ return this;
+ }
+ if ( selector === false || typeof selector === "function" ) {
+ // ( types [, fn] )
+ fn = selector;
+ selector = undefined;
+ }
+ if ( fn === false ) {
+ fn = returnFalse;
+ }
+ return this.each(function() {
+ jQuery.event.remove( this, types, fn, selector );
+ });
+ },
+
+ bind: function( types, data, fn ) {
+ return this.on( types, null, data, fn );
+ },
+ unbind: function( types, fn ) {
+ return this.off( types, null, fn );
+ },
+
+ live: function( types, data, fn ) {
+ jQuery( this.context ).on( types, this.selector, data, fn );
+ return this;
+ },
+ die: function( types, fn ) {
+ jQuery( this.context ).off( types, this.selector || "**", fn );
+ return this;
+ },
+
+ delegate: function( selector, types, data, fn ) {
+ return this.on( types, selector, data, fn );
+ },
+ undelegate: function( selector, types, fn ) {
+ // ( namespace ) or ( selector, types [, fn] )
+ return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
+ },
+
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ return jQuery.event.trigger( type, data, this[0], true );
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments,
+ guid = fn.guid || jQuery.guid++,
+ i = 0,
+ toggler = function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ };
+
+ // link all the functions, so any of them can unbind this click handler
+ toggler.guid = guid;
+ while ( i < args.length ) {
+ args[ i++ ].guid = guid;
+ }
+
+ return this.click( toggler );
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ }
+});
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( data, fn ) {
+ if ( fn == null ) {
+ fn = data;
+ data = null;
+ }
+
+ return arguments.length > 0 ?
+ this.on( name, null, data, fn ) :
+ this.trigger( name );
+ };
+
+ if ( rkeyEvent.test( name ) ) {
+ jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
+ }
+
+ if ( rmouseEvent.test( name ) ) {
+ jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
+ }
+});
+/*!
+ * Sizzle CSS Selector Engine
+ * Copyright 2012 jQuery Foundation and other contributors
+ * Released under the MIT license
+ * http://sizzlejs.com/
+ */
+(function( window, undefined ) {
+
+var cachedruns,
+ assertGetIdNotName,
+ Expr,
+ getText,
+ isXML,
+ contains,
+ compile,
+ sortOrder,
+ hasDuplicate,
+ outermostContext,
+
+ baseHasDuplicate = true,
+ strundefined = "undefined",
+
+ expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
+
+ Token = String,
+ document = window.document,
+ docElem = document.documentElement,
+ dirruns = 0,
+ done = 0,
+ pop = [].pop,
+ push = [].push,
+ slice = [].slice,
+ // Use a stripped-down indexOf if a native one is unavailable
+ indexOf = [].indexOf || function( elem ) {
+ var i = 0,
+ len = this.length;
+ for ( ; i < len; i++ ) {
+ if ( this[i] === elem ) {
+ return i;
+ }
+ }
+ return -1;
+ },
+
+ // Augment a function for special use by Sizzle
+ markFunction = function( fn, value ) {
+ fn[ expando ] = value == null || value;
+ return fn;
+ },
+
+ createCache = function() {
+ var cache = {},
+ keys = [];
+
+ return markFunction(function( key, value ) {
+ // Only keep the most recent entries
+ if ( keys.push( key ) > Expr.cacheLength ) {
+ delete cache[ keys.shift() ];
+ }
+
+ // Retrieve with (key + " ") to avoid collision with native Object.prototype properties (see Issue #157)
+ return (cache[ key + " " ] = value);
+ }, cache );
+ },
+
+ classCache = createCache(),
+ tokenCache = createCache(),
+ compilerCache = createCache(),
+
+ // Regex
+
+ // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
+ whitespace = "[\\x20\\t\\r\\n\\f]",
+ // http://www.w3.org/TR/css3-syntax/#characters
+ characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",
+
+ // Loosely modeled on CSS identifier characters
+ // An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors)
+ // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
+ identifier = characterEncoding.replace( "w", "w#" ),
+
+ // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
+ operators = "([*^$|!~]?=)",
+ attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
+ "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
+
+ // Prefer arguments not in parens/brackets,
+ // then attribute selectors and non-pseudos (denoted by :),
+ // then anything else
+ // These preferences are here to reduce the number of selectors
+ // needing tokenize in the PSEUDO preFilter
+ pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",
+
+ // For matchExpr.POS and matchExpr.needsContext
+ pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
+ "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",
+
+ // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
+ rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
+
+ rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
+ rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),
+ rpseudo = new RegExp( pseudos ),
+
+ // Easily-parseable/retrievable ID or TAG or CLASS selectors
+ rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,
+
+ rnot = /^:not/,
+ rsibling = /[\x20\t\r\n\f]*[+~]/,
+ rendsWithNot = /:not\($/,
+
+ rheader = /h\d/i,
+ rinputs = /input|select|textarea|button/i,
+
+ rbackslash = /\\(?!\\)/g,
+
+ matchExpr = {
+ "ID": new RegExp( "^#(" + characterEncoding + ")" ),
+ "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
+ "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
+ "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
+ "ATTR": new RegExp( "^" + attributes ),
+ "PSEUDO": new RegExp( "^" + pseudos ),
+ "POS": new RegExp( pos, "i" ),
+ "CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace +
+ "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
+ "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
+ // For use in libraries implementing .is()
+ "needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
+ },
+
+ // Support
+
+ // Used for testing something on an element
+ assert = function( fn ) {
+ var div = document.createElement("div");
+
+ try {
+ return fn( div );
+ } catch (e) {
+ return false;
+ } finally {
+ // release memory in IE
+ div = null;
+ }
+ },
+
+ // Check if getElementsByTagName("*") returns only elements
+ assertTagNameNoComments = assert(function( div ) {
+ div.appendChild( document.createComment("") );
+ return !div.getElementsByTagName("*").length;
+ }),
+
+ // Check if getAttribute returns normalized href attributes
+ assertHrefNotNormalized = assert(function( div ) {
+ div.innerHTML = "<a href='#'></a>";
+ return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
+ div.firstChild.getAttribute("href") === "#";
+ }),
+
+ // Check if attributes should be retrieved by attribute nodes
+ assertAttributes = assert(function( div ) {
+ div.innerHTML = "<select></select>";
+ var type = typeof div.lastChild.getAttribute("multiple");
+ // IE8 returns a string for some attributes even when not present
+ return type !== "boolean" && type !== "string";
+ }),
+
+ // Check if getElementsByClassName can be trusted
+ assertUsableClassName = assert(function( div ) {
+ // Opera can't find a second classname (in 9.6)
+ div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
+ if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {
+ return false;
+ }
+
+ // Safari 3.2 caches class attributes and doesn't catch changes
+ div.lastChild.className = "e";
+ return div.getElementsByClassName("e").length === 2;
+ }),
+
+ // Check if getElementById returns elements by name
+ // Check if getElementsByName privileges form controls or returns elements by ID
+ assertUsableName = assert(function( div ) {
+ // Inject content
+ div.id = expando + 0;
+ div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>";
+ docElem.insertBefore( div, docElem.firstChild );
+
+ // Test
+ var pass = document.getElementsByName &&
+ // buggy browsers will return fewer than the correct 2
+ document.getElementsByName( expando ).length === 2 +
+ // buggy browsers will return more than the correct 0
+ document.getElementsByName( expando + 0 ).length;
+ assertGetIdNotName = !document.getElementById( expando );
+
+ // Cleanup
+ docElem.removeChild( div );
+
+ return pass;
+ });
+
+// If slice is not available, provide a backup
+try {
+ slice.call( docElem.childNodes, 0 )[0].nodeType;
+} catch ( e ) {
+ slice = function( i ) {
+ var elem,
+ results = [];
+ for ( ; (elem = this[i]); i++ ) {
+ results.push( elem );
+ }
+ return results;
+ };
+}
+
+function Sizzle( selector, context, results, seed ) {
+ results = results || [];
+ context = context || document;
+ var match, elem, xml, m,
+ nodeType = context.nodeType;
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ if ( nodeType !== 1 && nodeType !== 9 ) {
+ return [];
+ }
+
+ xml = isXML( context );
+
+ if ( !xml && !seed ) {
+ if ( (match = rquickExpr.exec( selector )) ) {
+ // Speed-up: Sizzle("#ID")
+ if ( (m = match[1]) ) {
+ if ( nodeType === 9 ) {
+ elem = context.getElementById( m );
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ if ( elem && elem.parentNode ) {
+ // Handle the case where IE, Opera, and Webkit return items
+ // by name instead of ID
+ if ( elem.id === m ) {
+ results.push( elem );
+ return results;
+ }
+ } else {
+ return results;
+ }
+ } else {
+ // Context is not a document
+ if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
+ contains( context, elem ) && elem.id === m ) {
+ results.push( elem );
+ return results;
+ }
+ }
+
+ // Speed-up: Sizzle("TAG")
+ } else if ( match[2] ) {
+ push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );
+ return results;
+
+ // Speed-up: Sizzle(".CLASS")
+ } else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) {
+ push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );
+ return results;
+ }
+ }
+ }
+
+ // All others
+ return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );
+}
+
+Sizzle.matches = function( expr, elements ) {
+ return Sizzle( expr, null, null, elements );
+};
+
+Sizzle.matchesSelector = function( elem, expr ) {
+ return Sizzle( expr, null, null, [ elem ] ).length > 0;
+};
+
+// Returns a function to use in pseudos for input types
+function createInputPseudo( type ) {
+ return function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === type;
+ };
+}
+
+// Returns a function to use in pseudos for buttons
+function createButtonPseudo( type ) {
+ return function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return (name === "input" || name === "button") && elem.type === type;
+ };
+}
+
+// Returns a function to use in pseudos for positionals
+function createPositionalPseudo( fn ) {
+ return markFunction(function( argument ) {
+ argument = +argument;
+ return markFunction(function( seed, matches ) {
+ var j,
+ matchIndexes = fn( [], seed.length, argument ),
+ i = matchIndexes.length;
+
+ // Match elements found at the specified indexes
+ while ( i-- ) {
+ if ( seed[ (j = matchIndexes[i]) ] ) {
+ seed[j] = !(matches[j] = seed[j]);
+ }
+ }
+ });
+ });
+}
+
+/**
+ * Utility function for retrieving the text value of an array of DOM nodes
+ * @param {Array|Element} elem
+ */
+getText = Sizzle.getText = function( elem ) {
+ var node,
+ ret = "",
+ i = 0,
+ nodeType = elem.nodeType;
+
+ if ( nodeType ) {
+ if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
+ // Use textContent for elements
+ // innerText usage removed for consistency of new lines (see #11153)
+ if ( typeof elem.textContent === "string" ) {
+ return elem.textContent;
+ } else {
+ // Traverse its children
+ for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
+ ret += getText( elem );
+ }
+ }
+ } else if ( nodeType === 3 || nodeType === 4 ) {
+ return elem.nodeValue;
+ }
+ // Do not include comment or processing instruction nodes
+ } else {
+
+ // If no nodeType, this is expected to be an array
+ for ( ; (node = elem[i]); i++ ) {
+ // Do not traverse comment nodes
+ ret += getText( node );
+ }
+ }
+ return ret;
+};
+
+isXML = Sizzle.isXML = function( elem ) {
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = elem && (elem.ownerDocument || elem).documentElement;
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+// Element contains another
+contains = Sizzle.contains = docElem.contains ?
+ function( a, b ) {
+ var adown = a.nodeType === 9 ? a.documentElement : a,
+ bup = b && b.parentNode;
+ return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) );
+ } :
+ docElem.compareDocumentPosition ?
+ function( a, b ) {
+ return b && !!( a.compareDocumentPosition( b ) & 16 );
+ } :
+ function( a, b ) {
+ while ( (b = b.parentNode) ) {
+ if ( b === a ) {
+ return true;
+ }
+ }
+ return false;
+ };
+
+Sizzle.attr = function( elem, name ) {
+ var val,
+ xml = isXML( elem );
+
+ if ( !xml ) {
+ name = name.toLowerCase();
+ }
+ if ( (val = Expr.attrHandle[ name ]) ) {
+ return val( elem );
+ }
+ if ( xml || assertAttributes ) {
+ return elem.getAttribute( name );
+ }
+ val = elem.getAttributeNode( name );
+ return val ?
+ typeof elem[ name ] === "boolean" ?
+ elem[ name ] ? name : null :
+ val.specified ? val.value : null :
+ null;
+};
+
+Expr = Sizzle.selectors = {
+
+ // Can be adjusted by the user
+ cacheLength: 50,
+
+ createPseudo: markFunction,
+
+ match: matchExpr,
+
+ // IE6/7 return a modified href
+ attrHandle: assertHrefNotNormalized ?
+ {} :
+ {
+ "href": function( elem ) {
+ return elem.getAttribute( "href", 2 );
+ },
+ "type": function( elem ) {
+ return elem.getAttribute("type");
+ }
+ },
+
+ find: {
+ "ID": assertGetIdNotName ?
+ function( id, context, xml ) {
+ if ( typeof context.getElementById !== strundefined && !xml ) {
+ var m = context.getElementById( id );
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ return m && m.parentNode ? [m] : [];
+ }
+ } :
+ function( id, context, xml ) {
+ if ( typeof context.getElementById !== strundefined && !xml ) {
+ var m = context.getElementById( id );
+
+ return m ?
+ m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?
+ [m] :
+ undefined :
+ [];
+ }
+ },
+
+ "TAG": assertTagNameNoComments ?
+ function( tag, context ) {
+ if ( typeof context.getElementsByTagName !== strundefined ) {
+ return context.getElementsByTagName( tag );
+ }
+ } :
+ function( tag, context ) {
+ var results = context.getElementsByTagName( tag );
+
+ // Filter out possible comments
+ if ( tag === "*" ) {
+ var elem,
+ tmp = [],
+ i = 0;
+
+ for ( ; (elem = results[i]); i++ ) {
+ if ( elem.nodeType === 1 ) {
+ tmp.push( elem );
+ }
+ }
+
+ return tmp;
+ }
+ return results;
+ },
+
+ "NAME": assertUsableName && function( tag, context ) {
+ if ( typeof context.getElementsByName !== strundefined ) {
+ return context.getElementsByName( name );
+ }
+ },
+
+ "CLASS": assertUsableClassName && function( className, context, xml ) {
+ if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
+ return context.getElementsByClassName( className );
+ }
+ }
+ },
+
+ relative: {
+ ">": { dir: "parentNode", first: true },
+ " ": { dir: "parentNode" },
+ "+": { dir: "previousSibling", first: true },
+ "~": { dir: "previousSibling" }
+ },
+
+ preFilter: {
+ "ATTR": function( match ) {
+ match[1] = match[1].replace( rbackslash, "" );
+
+ // Move the given value to match[3] whether quoted or unquoted
+ match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" );
+
+ if ( match[2] === "~=" ) {
+ match[3] = " " + match[3] + " ";
+ }
+
+ return match.slice( 0, 4 );
+ },
+
+ "CHILD": function( match ) {
+ /* matches from matchExpr["CHILD"]
+ 1 type (only|nth|...)
+ 2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
+ 3 xn-component of xn+y argument ([+-]?\d*n|)
+ 4 sign of xn-component
+ 5 x of xn-component
+ 6 sign of y-component
+ 7 y of y-component
+ */
+ match[1] = match[1].toLowerCase();
+
+ if ( match[1] === "nth" ) {
+ // nth-child requires argument
+ if ( !match[2] ) {
+ Sizzle.error( match[0] );
+ }
+
+ // numeric x and y parameters for Expr.filter.CHILD
+ // remember that false/true cast respectively to 0/1
+ match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) );
+ match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" );
+
+ // other types prohibit arguments
+ } else if ( match[2] ) {
+ Sizzle.error( match[0] );
+ }
+
+ return match;
+ },
+
+ "PSEUDO": function( match ) {
+ var unquoted, excess;
+ if ( matchExpr["CHILD"].test( match[0] ) ) {
+ return null;
+ }
+
+ if ( match[3] ) {
+ match[2] = match[3];
+ } else if ( (unquoted = match[4]) ) {
+ // Only check arguments that contain a pseudo
+ if ( rpseudo.test(unquoted) &&
+ // Get excess from tokenize (recursively)
+ (excess = tokenize( unquoted, true )) &&
+ // advance to the next closing parenthesis
+ (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
+
+ // excess is a negative index
+ unquoted = unquoted.slice( 0, excess );
+ match[0] = match[0].slice( 0, excess );
+ }
+ match[2] = unquoted;
+ }
+
+ // Return only captures needed by the pseudo filter method (type and argument)
+ return match.slice( 0, 3 );
+ }
+ },
+
+ filter: {
+ "ID": assertGetIdNotName ?
+ function( id ) {
+ id = id.replace( rbackslash, "" );
+ return function( elem ) {
+ return elem.getAttribute("id") === id;
+ };
+ } :
+ function( id ) {
+ id = id.replace( rbackslash, "" );
+ return function( elem ) {
+ var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
+ return node && node.value === id;
+ };
+ },
+
+ "TAG": function( nodeName ) {
+ if ( nodeName === "*" ) {
+ return function() { return true; };
+ }
+ nodeName = nodeName.replace( rbackslash, "" ).toLowerCase();
+
+ return function( elem ) {
+ return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
+ };
+ },
+
+ "CLASS": function( className ) {
+ var pattern = classCache[ expando ][ className + " " ];
+
+ return pattern ||
+ (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
+ classCache( className, function( elem ) {
+ return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
+ });
+ },
+
+ "ATTR": function( name, operator, check ) {
+ return function( elem, context ) {
+ var result = Sizzle.attr( elem, name );
+
+ if ( result == null ) {
+ return operator === "!=";
+ }
+ if ( !operator ) {
+ return true;
+ }
+
+ result += "";
+
+ return operator === "=" ? result === check :
+ operator === "!=" ? result !== check :
+ operator === "^=" ? check && result.indexOf( check ) === 0 :
+ operator === "*=" ? check && result.indexOf( check ) > -1 :
+ operator === "$=" ? check && result.substr( result.length - check.length ) === check :
+ operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
+ operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :
+ false;
+ };
+ },
+
+ "CHILD": function( type, argument, first, last ) {
+
+ if ( type === "nth" ) {
+ return function( elem ) {
+ var node, diff,
+ parent = elem.parentNode;
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ if ( parent ) {
+ diff = 0;
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ diff++;
+ if ( elem === node ) {
+ break;
+ }
+ }
+ }
+ }
+
+ // Incorporate the offset (or cast to NaN), then check against cycle size
+ diff -= last;
+ return diff === first || ( diff % first === 0 && diff / first >= 0 );
+ };
+ }
+
+ return function( elem ) {
+ var node = elem;
+
+ switch ( type ) {
+ case "only":
+ case "first":
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+
+ if ( type === "first" ) {
+ return true;
+ }
+
+ node = elem;
+
+ /* falls through */
+ case "last":
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ };
+ },
+
+ "PSEUDO": function( pseudo, argument ) {
+ // pseudo-class names are case-insensitive
+ // http://www.w3.org/TR/selectors/#pseudo-classes
+ // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
+ // Remember that setFilters inherits from pseudos
+ var args,
+ fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
+ Sizzle.error( "unsupported pseudo: " + pseudo );
+
+ // The user may use createPseudo to indicate that
+ // arguments are needed to create the filter function
+ // just as Sizzle does
+ if ( fn[ expando ] ) {
+ return fn( argument );
+ }
+
+ // But maintain support for old signatures
+ if ( fn.length > 1 ) {
+ args = [ pseudo, pseudo, "", argument ];
+ return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
+ markFunction(function( seed, matches ) {
+ var idx,
+ matched = fn( seed, argument ),
+ i = matched.length;
+ while ( i-- ) {
+ idx = indexOf.call( seed, matched[i] );
+ seed[ idx ] = !( matches[ idx ] = matched[i] );
+ }
+ }) :
+ function( elem ) {
+ return fn( elem, 0, args );
+ };
+ }
+
+ return fn;
+ }
+ },
+
+ pseudos: {
+ "not": markFunction(function( selector ) {
+ // Trim the selector passed to compile
+ // to avoid treating leading and trailing
+ // spaces as combinators
+ var input = [],
+ results = [],
+ matcher = compile( selector.replace( rtrim, "$1" ) );
+
+ return matcher[ expando ] ?
+ markFunction(function( seed, matches, context, xml ) {
+ var elem,
+ unmatched = matcher( seed, null, xml, [] ),
+ i = seed.length;
+
+ // Match elements unmatched by `matcher`
+ while ( i-- ) {
+ if ( (elem = unmatched[i]) ) {
+ seed[i] = !(matches[i] = elem);
+ }
+ }
+ }) :
+ function( elem, context, xml ) {
+ input[0] = elem;
+ matcher( input, null, xml, results );
+ return !results.pop();
+ };
+ }),
+
+ "has": markFunction(function( selector ) {
+ return function( elem ) {
+ return Sizzle( selector, elem ).length > 0;
+ };
+ }),
+
+ "contains": markFunction(function( text ) {
+ return function( elem ) {
+ return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
+ };
+ }),
+
+ "enabled": function( elem ) {
+ return elem.disabled === false;
+ },
+
+ "disabled": function( elem ) {
+ return elem.disabled === true;
+ },
+
+ "checked": function( elem ) {
+ // In CSS3, :checked should return both checked and selected elements
+ // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+ var nodeName = elem.nodeName.toLowerCase();
+ return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
+ },
+
+ "selected": function( elem ) {
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ if ( elem.parentNode ) {
+ elem.parentNode.selectedIndex;
+ }
+
+ return elem.selected === true;
+ },
+
+ "parent": function( elem ) {
+ return !Expr.pseudos["empty"]( elem );
+ },
+
+ "empty": function( elem ) {
+ // http://www.w3.org/TR/selectors/#empty-pseudo
+ // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
+ // not comment, processing instructions, or others
+ // Thanks to Diego Perini for the nodeName shortcut
+ // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
+ var nodeType;
+ elem = elem.firstChild;
+ while ( elem ) {
+ if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) {
+ return false;
+ }
+ elem = elem.nextSibling;
+ }
+ return true;
+ },
+
+ "header": function( elem ) {
+ return rheader.test( elem.nodeName );
+ },
+
+ "text": function( elem ) {
+ var type, attr;
+ // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
+ // use getAttribute instead to test this case
+ return elem.nodeName.toLowerCase() === "input" &&
+ (type = elem.type) === "text" &&
+ ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type );
+ },
+
+ // Input types
+ "radio": createInputPseudo("radio"),
+ "checkbox": createInputPseudo("checkbox"),
+ "file": createInputPseudo("file"),
+ "password": createInputPseudo("password"),
+ "image": createInputPseudo("image"),
+
+ "submit": createButtonPseudo("submit"),
+ "reset": createButtonPseudo("reset"),
+
+ "button": function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && elem.type === "button" || name === "button";
+ },
+
+ "input": function( elem ) {
+ return rinputs.test( elem.nodeName );
+ },
+
+ "focus": function( elem ) {
+ var doc = elem.ownerDocument;
+ return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
+ },
+
+ "active": function( elem ) {
+ return elem === elem.ownerDocument.activeElement;
+ },
+
+ // Positional types
+ "first": createPositionalPseudo(function() {
+ return [ 0 ];
+ }),
+
+ "last": createPositionalPseudo(function( matchIndexes, length ) {
+ return [ length - 1 ];
+ }),
+
+ "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ return [ argument < 0 ? argument + length : argument ];
+ }),
+
+ "even": createPositionalPseudo(function( matchIndexes, length ) {
+ for ( var i = 0; i < length; i += 2 ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
+
+ "odd": createPositionalPseudo(function( matchIndexes, length ) {
+ for ( var i = 1; i < length; i += 2 ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
+
+ "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
+
+ "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ })
+ }
+};
+
+function siblingCheck( a, b, ret ) {
+ if ( a === b ) {
+ return ret;
+ }
+
+ var cur = a.nextSibling;
+
+ while ( cur ) {
+ if ( cur === b ) {
+ return -1;
+ }
+
+ cur = cur.nextSibling;
+ }
+
+ return 1;
+}
+
+sortOrder = docElem.compareDocumentPosition ?
+ function( a, b ) {
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ return ( !a.compareDocumentPosition || !b.compareDocumentPosition ?
+ a.compareDocumentPosition :
+ a.compareDocumentPosition(b) & 4
+ ) ? -1 : 1;
+ } :
+ function( a, b ) {
+ // The nodes are identical, we can exit early
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+
+ // Fallback to using sourceIndex (in IE) if it's available on both nodes
+ } else if ( a.sourceIndex && b.sourceIndex ) {
+ return a.sourceIndex - b.sourceIndex;
+ }
+
+ var al, bl,
+ ap = [],
+ bp = [],
+ aup = a.parentNode,
+ bup = b.parentNode,
+ cur = aup;
+
+ // If the nodes are siblings (or identical) we can do a quick check
+ if ( aup === bup ) {
+ return siblingCheck( a, b );
+
+ // If no parents were found then the nodes are disconnected
+ } else if ( !aup ) {
+ return -1;
+
+ } else if ( !bup ) {
+ return 1;
+ }
+
+ // Otherwise they're somewhere else in the tree so we need
+ // to build up a full list of the parentNodes for comparison
+ while ( cur ) {
+ ap.unshift( cur );
+ cur = cur.parentNode;
+ }
+
+ cur = bup;
+
+ while ( cur ) {
+ bp.unshift( cur );
+ cur = cur.parentNode;
+ }
+
+ al = ap.length;
+ bl = bp.length;
+
+ // Start walking down the tree looking for a discrepancy
+ for ( var i = 0; i < al && i < bl; i++ ) {
+ if ( ap[i] !== bp[i] ) {
+ return siblingCheck( ap[i], bp[i] );
+ }
+ }
+
+ // We ended someplace up the tree so do a sibling check
+ return i === al ?
+ siblingCheck( a, bp[i], -1 ) :
+ siblingCheck( ap[i], b, 1 );
+ };
+
+// Always assume the presence of duplicates if sort doesn't
+// pass them to our comparison function (as in Google Chrome).
+[0, 0].sort( sortOrder );
+baseHasDuplicate = !hasDuplicate;
+
+// Document sorting and removing duplicates
+Sizzle.uniqueSort = function( results ) {
+ var elem,
+ duplicates = [],
+ i = 1,
+ j = 0;
+
+ hasDuplicate = baseHasDuplicate;
+ results.sort( sortOrder );
+
+ if ( hasDuplicate ) {
+ for ( ; (elem = results[i]); i++ ) {
+ if ( elem === results[ i - 1 ] ) {
+ j = duplicates.push( i );
+ }
+ }
+ while ( j-- ) {
+ results.splice( duplicates[ j ], 1 );
+ }
+ }
+
+ return results;
+};
+
+Sizzle.error = function( msg ) {
+ throw new Error( "Syntax error, unrecognized expression: " + msg );
+};
+
+function tokenize( selector, parseOnly ) {
+ var matched, match, tokens, type,
+ soFar, groups, preFilters,
+ cached = tokenCache[ expando ][ selector + " " ];
+
+ if ( cached ) {
+ return parseOnly ? 0 : cached.slice( 0 );
+ }
+
+ soFar = selector;
+ groups = [];
+ preFilters = Expr.preFilter;
+
+ while ( soFar ) {
+
+ // Comma and first run
+ if ( !matched || (match = rcomma.exec( soFar )) ) {
+ if ( match ) {
+ // Don't consume trailing commas as valid
+ soFar = soFar.slice( match[0].length ) || soFar;
+ }
+ groups.push( tokens = [] );
+ }
+
+ matched = false;
+
+ // Combinators
+ if ( (match = rcombinators.exec( soFar )) ) {
+ tokens.push( matched = new Token( match.shift() ) );
+ soFar = soFar.slice( matched.length );
+
+ // Cast descendant combinators to space
+ matched.type = match[0].replace( rtrim, " " );
+ }
+
+ // Filters
+ for ( type in Expr.filter ) {
+ if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
+ (match = preFilters[ type ]( match ))) ) {
+
+ tokens.push( matched = new Token( match.shift() ) );
+ soFar = soFar.slice( matched.length );
+ matched.type = type;
+ matched.matches = match;
+ }
+ }
+
+ if ( !matched ) {
+ break;
+ }
+ }
+
+ // Return the length of the invalid excess
+ // if we're just parsing
+ // Otherwise, throw an error or return tokens
+ return parseOnly ?
+ soFar.length :
+ soFar ?
+ Sizzle.error( selector ) :
+ // Cache the tokens
+ tokenCache( selector, groups ).slice( 0 );
+}
+
+function addCombinator( matcher, combinator, base ) {
+ var dir = combinator.dir,
+ checkNonElements = base && combinator.dir === "parentNode",
+ doneName = done++;
+
+ return combinator.first ?
+ // Check against closest ancestor/preceding element
+ function( elem, context, xml ) {
+ while ( (elem = elem[ dir ]) ) {
+ if ( checkNonElements || elem.nodeType === 1 ) {
+ return matcher( elem, context, xml );
+ }
+ }
+ } :
+
+ // Check against all ancestor/preceding elements
+ function( elem, context, xml ) {
+ // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
+ if ( !xml ) {
+ var cache,
+ dirkey = dirruns + " " + doneName + " ",
+ cachedkey = dirkey + cachedruns;
+ while ( (elem = elem[ dir ]) ) {
+ if ( checkNonElements || elem.nodeType === 1 ) {
+ if ( (cache = elem[ expando ]) === cachedkey ) {
+ return elem.sizset;
+ } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
+ if ( elem.sizset ) {
+ return elem;
+ }
+ } else {
+ elem[ expando ] = cachedkey;
+ if ( matcher( elem, context, xml ) ) {
+ elem.sizset = true;
+ return elem;
+ }
+ elem.sizset = false;
+ }
+ }
+ }
+ } else {
+ while ( (elem = elem[ dir ]) ) {
+ if ( checkNonElements || elem.nodeType === 1 ) {
+ if ( matcher( elem, context, xml ) ) {
+ return elem;
+ }
+ }
+ }
+ }
+ };
+}
+
+function elementMatcher( matchers ) {
+ return matchers.length > 1 ?
+ function( elem, context, xml ) {
+ var i = matchers.length;
+ while ( i-- ) {
+ if ( !matchers[i]( elem, context, xml ) ) {
+ return false;
+ }
+ }
+ return true;
+ } :
+ matchers[0];
+}
+
+function condense( unmatched, map, filter, context, xml ) {
+ var elem,
+ newUnmatched = [],
+ i = 0,
+ len = unmatched.length,
+ mapped = map != null;
+
+ for ( ; i < len; i++ ) {
+ if ( (elem = unmatched[i]) ) {
+ if ( !filter || filter( elem, context, xml ) ) {
+ newUnmatched.push( elem );
+ if ( mapped ) {
+ map.push( i );
+ }
+ }
+ }
+ }
+
+ return newUnmatched;
+}
+
+function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
+ if ( postFilter && !postFilter[ expando ] ) {
+ postFilter = setMatcher( postFilter );
+ }
+ if ( postFinder && !postFinder[ expando ] ) {
+ postFinder = setMatcher( postFinder, postSelector );
+ }
+ return markFunction(function( seed, results, context, xml ) {
+ var temp, i, elem,
+ preMap = [],
+ postMap = [],
+ preexisting = results.length,
+
+ // Get initial elements from seed or context
+ elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
+
+ // Prefilter to get matcher input, preserving a map for seed-results synchronization
+ matcherIn = preFilter && ( seed || !selector ) ?
+ condense( elems, preMap, preFilter, context, xml ) :
+ elems,
+
+ matcherOut = matcher ?
+ // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
+ postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
+
+ // ...intermediate processing is necessary
+ [] :
+
+ // ...otherwise use results directly
+ results :
+ matcherIn;
+
+ // Find primary matches
+ if ( matcher ) {
+ matcher( matcherIn, matcherOut, context, xml );
+ }
+
+ // Apply postFilter
+ if ( postFilter ) {
+ temp = condense( matcherOut, postMap );
+ postFilter( temp, [], context, xml );
+
+ // Un-match failing elements by moving them back to matcherIn
+ i = temp.length;
+ while ( i-- ) {
+ if ( (elem = temp[i]) ) {
+ matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
+ }
+ }
+ }
+
+ if ( seed ) {
+ if ( postFinder || preFilter ) {
+ if ( postFinder ) {
+ // Get the final matcherOut by condensing this intermediate into postFinder contexts
+ temp = [];
+ i = matcherOut.length;
+ while ( i-- ) {
+ if ( (elem = matcherOut[i]) ) {
+ // Restore matcherIn since elem is not yet a final match
+ temp.push( (matcherIn[i] = elem) );
+ }
+ }
+ postFinder( null, (matcherOut = []), temp, xml );
+ }
+
+ // Move matched elements from seed to results to keep them synchronized
+ i = matcherOut.length;
+ while ( i-- ) {
+ if ( (elem = matcherOut[i]) &&
+ (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
+
+ seed[temp] = !(results[temp] = elem);
+ }
+ }
+ }
+
+ // Add elements to results, through postFinder if defined
+ } else {
+ matcherOut = condense(
+ matcherOut === results ?
+ matcherOut.splice( preexisting, matcherOut.length ) :
+ matcherOut
+ );
+ if ( postFinder ) {
+ postFinder( null, results, matcherOut, xml );
+ } else {
+ push.apply( results, matcherOut );
+ }
+ }
+ });
+}
+
+function matcherFromTokens( tokens ) {
+ var checkContext, matcher, j,
+ len = tokens.length,
+ leadingRelative = Expr.relative[ tokens[0].type ],
+ implicitRelative = leadingRelative || Expr.relative[" "],
+ i = leadingRelative ? 1 : 0,
+
+ // The foundational matcher ensures that elements are reachable from top-level context(s)
+ matchContext = addCombinator( function( elem ) {
+ return elem === checkContext;
+ }, implicitRelative, true ),
+ matchAnyContext = addCombinator( function( elem ) {
+ return indexOf.call( checkContext, elem ) > -1;
+ }, implicitRelative, true ),
+ matchers = [ function( elem, context, xml ) {
+ return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
+ (checkContext = context).nodeType ?
+ matchContext( elem, context, xml ) :
+ matchAnyContext( elem, context, xml ) );
+ } ];
+
+ for ( ; i < len; i++ ) {
+ if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
+ matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
+ } else {
+ matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
+
+ // Return special upon seeing a positional matcher
+ if ( matcher[ expando ] ) {
+ // Find the next relative operator (if any) for proper handling
+ j = ++i;
+ for ( ; j < len; j++ ) {
+ if ( Expr.relative[ tokens[j].type ] ) {
+ break;
+ }
+ }
+ return setMatcher(
+ i > 1 && elementMatcher( matchers ),
+ i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ),
+ matcher,
+ i < j && matcherFromTokens( tokens.slice( i, j ) ),
+ j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
+ j < len && tokens.join("")
+ );
+ }
+ matchers.push( matcher );
+ }
+ }
+
+ return elementMatcher( matchers );
+}
+
+function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
+ var bySet = setMatchers.length > 0,
+ byElement = elementMatchers.length > 0,
+ superMatcher = function( seed, context, xml, results, expandContext ) {
+ var elem, j, matcher,
+ setMatched = [],
+ matchedCount = 0,
+ i = "0",
+ unmatched = seed && [],
+ outermost = expandContext != null,
+ contextBackup = outermostContext,
+ // We must always have either seed elements or context
+ elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
+ // Nested matchers should use non-integer dirruns
+ dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);
+
+ if ( outermost ) {
+ outermostContext = context !== document && context;
+ cachedruns = superMatcher.el;
+ }
+
+ // Add elements passing elementMatchers directly to results
+ for ( ; (elem = elems[i]) != null; i++ ) {
+ if ( byElement && elem ) {
+ for ( j = 0; (matcher = elementMatchers[j]); j++ ) {
+ if ( matcher( elem, context, xml ) ) {
+ results.push( elem );
+ break;
+ }
+ }
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ cachedruns = ++superMatcher.el;
+ }
+ }
+
+ // Track unmatched elements for set filters
+ if ( bySet ) {
+ // They will have gone through all possible matchers
+ if ( (elem = !matcher && elem) ) {
+ matchedCount--;
+ }
+
+ // Lengthen the array for every element, matched or not
+ if ( seed ) {
+ unmatched.push( elem );
+ }
+ }
+ }
+
+ // Apply set filters to unmatched elements
+ matchedCount += i;
+ if ( bySet && i !== matchedCount ) {
+ for ( j = 0; (matcher = setMatchers[j]); j++ ) {
+ matcher( unmatched, setMatched, context, xml );
+ }
+
+ if ( seed ) {
+ // Reintegrate element matches to eliminate the need for sorting
+ if ( matchedCount > 0 ) {
+ while ( i-- ) {
+ if ( !(unmatched[i] || setMatched[i]) ) {
+ setMatched[i] = pop.call( results );
+ }
+ }
+ }
+
+ // Discard index placeholder values to get only actual matches
+ setMatched = condense( setMatched );
+ }
+
+ // Add matches to results
+ push.apply( results, setMatched );
+
+ // Seedless set matches succeeding multiple successful matchers stipulate sorting
+ if ( outermost && !seed && setMatched.length > 0 &&
+ ( matchedCount + setMatchers.length ) > 1 ) {
+
+ Sizzle.uniqueSort( results );
+ }
+ }
+
+ // Override manipulation of globals by nested matchers
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ outermostContext = contextBackup;
+ }
+
+ return unmatched;
+ };
+
+ superMatcher.el = 0;
+ return bySet ?
+ markFunction( superMatcher ) :
+ superMatcher;
+}
+
+compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
+ var i,
+ setMatchers = [],
+ elementMatchers = [],
+ cached = compilerCache[ expando ][ selector + " " ];
+
+ if ( !cached ) {
+ // Generate a function of recursive functions that can be used to check each element
+ if ( !group ) {
+ group = tokenize( selector );
+ }
+ i = group.length;
+ while ( i-- ) {
+ cached = matcherFromTokens( group[i] );
+ if ( cached[ expando ] ) {
+ setMatchers.push( cached );
+ } else {
+ elementMatchers.push( cached );
+ }
+ }
+
+ // Cache the compiled function
+ cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
+ }
+ return cached;
+};
+
+function multipleContexts( selector, contexts, results ) {
+ var i = 0,
+ len = contexts.length;
+ for ( ; i < len; i++ ) {
+ Sizzle( selector, contexts[i], results );
+ }
+ return results;
+}
+
+function select( selector, context, results, seed, xml ) {
+ var i, tokens, token, type, find,
+ match = tokenize( selector ),
+ j = match.length;
+
+ if ( !seed ) {
+ // Try to minimize operations if there is only one group
+ if ( match.length === 1 ) {
+
+ // Take a shortcut and set the context if the root selector is an ID
+ tokens = match[0] = match[0].slice( 0 );
+ if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
+ context.nodeType === 9 && !xml &&
+ Expr.relative[ tokens[1].type ] ) {
+
+ context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0];
+ if ( !context ) {
+ return results;
+ }
+
+ selector = selector.slice( tokens.shift().length );
+ }
+
+ // Fetch a seed set for right-to-left matching
+ for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {
+ token = tokens[i];
+
+ // Abort if we hit a combinator
+ if ( Expr.relative[ (type = token.type) ] ) {
+ break;
+ }
+ if ( (find = Expr.find[ type ]) ) {
+ // Search, expanding context for leading sibling combinators
+ if ( (seed = find(
+ token.matches[0].replace( rbackslash, "" ),
+ rsibling.test( tokens[0].type ) && context.parentNode || context,
+ xml
+ )) ) {
+
+ // If seed is empty or no tokens remain, we can return early
+ tokens.splice( i, 1 );
+ selector = seed.length && tokens.join("");
+ if ( !selector ) {
+ push.apply( results, slice.call( seed, 0 ) );
+ return results;
+ }
+
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ // Compile and execute a filtering function
+ // Provide `match` to avoid retokenization if we modified the selector above
+ compile( selector, match )(
+ seed,
+ context,
+ xml,
+ results,
+ rsibling.test( selector )
+ );
+ return results;
+}
+
+if ( document.querySelectorAll ) {
+ (function() {
+ var disconnectedMatch,
+ oldSelect = select,
+ rescape = /'|\\/g,
+ rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
+
+ // qSa(:focus) reports false when true (Chrome 21), no need to also add to buggyMatches since matches checks buggyQSA
+ // A support test would require too much code (would include document ready)
+ rbuggyQSA = [ ":focus" ],
+
+ // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
+ // A support test would require too much code (would include document ready)
+ // just skip matchesSelector for :active
+ rbuggyMatches = [ ":active" ],
+ matches = docElem.matchesSelector ||
+ docElem.mozMatchesSelector ||
+ docElem.webkitMatchesSelector ||
+ docElem.oMatchesSelector ||
+ docElem.msMatchesSelector;
+
+ // Build QSA regex
+ // Regex strategy adopted from Diego Perini
+ assert(function( div ) {
+ // Select is set to empty string on purpose
+ // This is to test IE's treatment of not explictly
+ // setting a boolean content attribute,
+ // since its presence should be enough
+ // http://bugs.jquery.com/ticket/12359
+ div.innerHTML = "<select><option selected=''></option></select>";
+
+ // IE8 - Some boolean attributes are not treated correctly
+ if ( !div.querySelectorAll("[selected]").length ) {
+ rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );
+ }
+
+ // Webkit/Opera - :checked should return selected option elements
+ // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+ // IE8 throws error here (do not put tests after this one)
+ if ( !div.querySelectorAll(":checked").length ) {
+ rbuggyQSA.push(":checked");
+ }
+ });
+
+ assert(function( div ) {
+
+ // Opera 10-12/IE9 - ^= $= *= and empty values
+ // Should not select anything
+ div.innerHTML = "<p test=''></p>";
+ if ( div.querySelectorAll("[test^='']").length ) {
+ rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
+ }
+
+ // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
+ // IE8 throws error here (do not put tests after this one)
+ div.innerHTML = "<input type='hidden'/>";
+ if ( !div.querySelectorAll(":enabled").length ) {
+ rbuggyQSA.push(":enabled", ":disabled");
+ }
+ });
+
+ // rbuggyQSA always contains :focus, so no need for a length check
+ rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") );
+
+ select = function( selector, context, results, seed, xml ) {
+ // Only use querySelectorAll when not filtering,
+ // when this is not xml,
+ // and when no QSA bugs apply
+ if ( !seed && !xml && !rbuggyQSA.test( selector ) ) {
+ var groups, i,
+ old = true,
+ nid = expando,
+ newContext = context,
+ newSelector = context.nodeType === 9 && selector;
+
+ // qSA works strangely on Element-rooted queries
+ // We can work around this by specifying an extra ID on the root
+ // and working up from there (Thanks to Andrew Dupont for the technique)
+ // IE 8 doesn't work on object elements
+ if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
+ groups = tokenize( selector );
+
+ if ( (old = context.getAttribute("id")) ) {
+ nid = old.replace( rescape, "\\$&" );
+ } else {
+ context.setAttribute( "id", nid );
+ }
+ nid = "[id='" + nid + "'] ";
+
+ i = groups.length;
+ while ( i-- ) {
+ groups[i] = nid + groups[i].join("");
+ }
+ newContext = rsibling.test( selector ) && context.parentNode || context;
+ newSelector = groups.join(",");
+ }
+
+ if ( newSelector ) {
+ try {
+ push.apply( results, slice.call( newContext.querySelectorAll(
+ newSelector
+ ), 0 ) );
+ return results;
+ } catch(qsaError) {
+ } finally {
+ if ( !old ) {
+ context.removeAttribute("id");
+ }
+ }
+ }
+ }
+
+ return oldSelect( selector, context, results, seed, xml );
+ };
+
+ if ( matches ) {
+ assert(function( div ) {
+ // Check to see if it's possible to do matchesSelector
+ // on a disconnected node (IE 9)
+ disconnectedMatch = matches.call( div, "div" );
+
+ // This should fail with an exception
+ // Gecko does not error, returns false instead
+ try {
+ matches.call( div, "[test!='']:sizzle" );
+ rbuggyMatches.push( "!=", pseudos );
+ } catch ( e ) {}
+ });
+
+ // rbuggyMatches always contains :active and :focus, so no need for a length check
+ rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
+
+ Sizzle.matchesSelector = function( elem, expr ) {
+ // Make sure that attribute selectors are quoted
+ expr = expr.replace( rattributeQuotes, "='$1']" );
+
+ // rbuggyMatches always contains :active, so no need for an existence check
+ if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && !rbuggyQSA.test( expr ) ) {
+ try {
+ var ret = matches.call( elem, expr );
+
+ // IE 9's matchesSelector returns false on disconnected nodes
+ if ( ret || disconnectedMatch ||
+ // As well, disconnected nodes are said to be in a document
+ // fragment in IE 9
+ elem.document && elem.document.nodeType !== 11 ) {
+ return ret;
+ }
+ } catch(e) {}
+ }
+
+ return Sizzle( expr, null, null, [ elem ] ).length > 0;
+ };
+ }
+ })();
+}
+
+// Deprecated
+Expr.pseudos["nth"] = Expr.pseudos["eq"];
+
+// Back-compat
+function setFilters() {}
+Expr.filters = setFilters.prototype = Expr.pseudos;
+Expr.setFilters = new setFilters();
+
+// Override sizzle attribute retrieval
+Sizzle.attr = jQuery.attr;
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.pseudos;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.text = Sizzle.getText;
+jQuery.isXMLDoc = Sizzle.isXML;
+jQuery.contains = Sizzle.contains;
+
+
+})( window );
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prev(?:Until|All))/,
+ isSimple = /^.[^:#\[\.,]*$/,
+ rneedsContext = jQuery.expr.match.needsContext,
+ // methods guaranteed to produce a unique set when starting from a unique set
+ guaranteedUnique = {
+ children: true,
+ contents: true,
+ next: true,
+ prev: true
+ };
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var i, l, length, n, r, ret,
+ self = this;
+
+ if ( typeof selector !== "string" ) {
+ return jQuery( selector ).filter(function() {
+ for ( i = 0, l = self.length; i < l; i++ ) {
+ if ( jQuery.contains( self[ i ], this ) ) {
+ return true;
+ }
+ }
+ });
+ }
+
+ ret = this.pushStack( "", "find", selector );
+
+ for ( i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( n = length; n < ret.length; n++ ) {
+ for ( r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var i,
+ targets = jQuery( target, this ),
+ len = targets.length;
+
+ return this.filter(function() {
+ for ( i = 0; i < len; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && (
+ typeof selector === "string" ?
+ // If this is a positional/relative selector, check membership in the returned set
+ // so $("p:first").is("p:last") won't return true for a doc with two "p".
+ rneedsContext.test( selector ) ?
+ jQuery( selector, this.context ).index( this[0] ) >= 0 :
+ jQuery.filter( selector, this ).length > 0 :
+ this.filter( selector ).length > 0 );
+ },
+
+ closest: function( selectors, context ) {
+ var cur,
+ i = 0,
+ l = this.length,
+ ret = [],
+ pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
+ jQuery( selectors, context || this.context ) :
+ 0;
+
+ for ( ; i < l; i++ ) {
+ cur = this[i];
+
+ while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
+ ret.push( cur );
+ break;
+ }
+ cur = cur.parentNode;
+ }
+ }
+
+ ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
+
+ return this.pushStack( ret, "closest", selectors );
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+
+ // No argument, return index in parent
+ if ( !elem ) {
+ return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
+ }
+
+ // index in selector
+ if ( typeof elem === "string" ) {
+ return jQuery.inArray( this[0], jQuery( elem ) );
+ }
+
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context ) :
+ jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ addBack: function( selector ) {
+ return this.add( selector == null ?
+ this.prevObject : this.prevObject.filter(selector)
+ );
+ }
+});
+
+jQuery.fn.andSelf = jQuery.fn.addBack;
+
+// A painfully simple check to see if an element is disconnected
+// from a document (should be improved, where feasible).
+function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+}
+
+function sibling( cur, dir ) {
+ do {
+ cur = cur[ dir ];
+ } while ( cur && cur.nodeType !== 1 );
+
+ return cur;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return sibling( elem, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return sibling( elem, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.merge( [], elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
+
+ if ( this.length > 1 && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, core_slice.call( arguments ).join(",") );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return elems.length === 1 ?
+ jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
+ jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [],
+ cur = elem[ dir ];
+
+ while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+
+// Implement the identical functionality for filter and not
+function winnow( elements, qualifier, keep ) {
+
+ // Can't pass null or undefined to indexOf in Firefox 4
+ // Set to 0 to skip string check
+ qualifier = qualifier || 0;
+
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ var retVal = !!qualifier.call( elem, i, elem );
+ return retVal === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return ( elem === qualifier ) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, filtered );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
+ });
+}
+function createSafeFragment( document ) {
+ var list = nodeNames.split( "|" ),
+ safeFrag = document.createDocumentFragment();
+
+ if ( safeFrag.createElement ) {
+ while ( list.length ) {
+ safeFrag.createElement(
+ list.pop()
+ );
+ }
+ }
+ return safeFrag;
+}
+
+var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
+ "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
+ rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
+ rtagName = /<([\w:]+)/,
+ rtbody = /<tbody/i,
+ rhtml = /<|&#?\w+;/,
+ rnoInnerhtml = /<(?:script|style|link)/i,
+ rnocache = /<(?:script|object|embed|option|style)/i,
+ rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
+ rcheckableType = /^(?:checkbox|radio)$/,
+ // checked="checked" or checked
+ rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
+ rscriptType = /\/(java|ecma)script/i,
+ rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,
+ wrapMap = {
+ option: [ 1, "<select multiple='multiple'>", "</select>" ],
+ legend: [ 1, "<fieldset>", "</fieldset>" ],
+ thead: [ 1, "<table>", "</table>" ],
+ tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+ td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+ col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
+ area: [ 1, "<map>", "</map>" ],
+ _default: [ 0, "", "" ]
+ },
+ safeFragment = createSafeFragment( document ),
+ fragmentDiv = safeFragment.appendChild( document.createElement("div") );
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
+// unless wrapped in a div with non-breaking characters in front of it.
+if ( !jQuery.support.htmlSerialize ) {
+ wrapMap._default = [ 1, "X<div>", "</div>" ];
+}
+
+jQuery.fn.extend({
+ text: function( value ) {
+ return jQuery.access( this, function( value ) {
+ return value === undefined ?
+ jQuery.text( this ) :
+ this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
+ }, null, value, arguments.length );
+ },
+
+ wrapAll: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapAll( html.call(this, i) );
+ });
+ }
+
+ if ( this[0] ) {
+ // The elements to wrap the target around
+ var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
+
+ if ( this[0].parentNode ) {
+ wrap.insertBefore( this[0] );
+ }
+
+ wrap.map(function() {
+ var elem = this;
+
+ while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+ elem = elem.firstChild;
+ }
+
+ return elem;
+ }).append( this );
+ }
+
+ return this;
+ },
+
+ wrapInner: function( html ) {
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapInner( html.call(this, i) );
+ });
+ }
+
+ return this.each(function() {
+ var self = jQuery( this ),
+ contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
+ });
+ },
+
+ wrap: function( html ) {
+ var isFunction = jQuery.isFunction( html );
+
+ return this.each(function(i) {
+ jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
+ });
+ },
+
+ unwrap: function() {
+ return this.parent().each(function() {
+ if ( !jQuery.nodeName( this, "body" ) ) {
+ jQuery( this ).replaceWith( this.childNodes );
+ }
+ }).end();
+ },
+
+ append: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 || this.nodeType === 11 ) {
+ this.appendChild( elem );
+ }
+ });
+ },
+
+ prepend: function() {
+ return this.domManip(arguments, true, function( elem ) {
+ if ( this.nodeType === 1 || this.nodeType === 11 ) {
+ this.insertBefore( elem, this.firstChild );
+ }
+ });
+ },
+
+ before: function() {
+ if ( !isDisconnected( this[0] ) ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this );
+ });
+ }
+
+ if ( arguments.length ) {
+ var set = jQuery.clean( arguments );
+ return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
+ }
+ },
+
+ after: function() {
+ if ( !isDisconnected( this[0] ) ) {
+ return this.domManip(arguments, false, function( elem ) {
+ this.parentNode.insertBefore( elem, this.nextSibling );
+ });
+ }
+
+ if ( arguments.length ) {
+ var set = jQuery.clean( arguments );
+ return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
+ }
+ },
+
+ // keepData is for internal use only--do not document
+ remove: function( selector, keepData ) {
+ var elem,
+ i = 0;
+
+ for ( ; (elem = this[i]) != null; i++ ) {
+ if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
+ if ( !keepData && elem.nodeType === 1 ) {
+ jQuery.cleanData( elem.getElementsByTagName("*") );
+ jQuery.cleanData( [ elem ] );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+ }
+ }
+
+ return this;
+ },
+
+ empty: function() {
+ var elem,
+ i = 0;
+
+ for ( ; (elem = this[i]) != null; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( elem.nodeType === 1 ) {
+ jQuery.cleanData( elem.getElementsByTagName("*") );
+ }
+
+ // Remove any remaining nodes
+ while ( elem.firstChild ) {
+ elem.removeChild( elem.firstChild );
+ }
+ }
+
+ return this;
+ },
+
+ clone: function( dataAndEvents, deepDataAndEvents ) {
+ dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
+ deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
+
+ return this.map( function () {
+ return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
+ });
+ },
+
+ html: function( value ) {
+ return jQuery.access( this, function( value ) {
+ var elem = this[0] || {},
+ i = 0,
+ l = this.length;
+
+ if ( value === undefined ) {
+ return elem.nodeType === 1 ?
+ elem.innerHTML.replace( rinlinejQuery, "" ) :
+ undefined;
+ }
+
+ // See if we can take a shortcut and just use innerHTML
+ if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
+ ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
+ ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
+ !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
+
+ value = value.replace( rxhtmlTag, "<$1></$2>" );
+
+ try {
+ for (; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ elem = this[i] || {};
+ if ( elem.nodeType === 1 ) {
+ jQuery.cleanData( elem.getElementsByTagName( "*" ) );
+ elem.innerHTML = value;
+ }
+ }
+
+ elem = 0;
+
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {}
+ }
+
+ if ( elem ) {
+ this.empty().append( value );
+ }
+ }, null, value, arguments.length );
+ },
+
+ replaceWith: function( value ) {
+ if ( !isDisconnected( this[0] ) ) {
+ // Make sure that the elements are removed from the DOM before they are inserted
+ // this can help fix replacing a parent with child elements
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this), old = self.html();
+ self.replaceWith( value.call( this, i, old ) );
+ });
+ }
+
+ if ( typeof value !== "string" ) {
+ value = jQuery( value ).detach();
+ }
+
+ return this.each(function() {
+ var next = this.nextSibling,
+ parent = this.parentNode;
+
+ jQuery( this ).remove();
+
+ if ( next ) {
+ jQuery(next).before( value );
+ } else {
+ jQuery(parent).append( value );
+ }
+ });
+ }
+
+ return this.length ?
+ this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
+ this;
+ },
+
+ detach: function( selector ) {
+ return this.remove( selector, true );
+ },
+
+ domManip: function( args, table, callback ) {
+
+ // Flatten any nested arrays
+ args = [].concat.apply( [], args );
+
+ var results, first, fragment, iNoClone,
+ i = 0,
+ value = args[0],
+ scripts = [],
+ l = this.length;
+
+ // We can't cloneNode fragments that contain checked, in WebKit
+ if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) {
+ return this.each(function() {
+ jQuery(this).domManip( args, table, callback );
+ });
+ }
+
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ args[0] = value.call( this, i, table ? self.html() : undefined );
+ self.domManip( args, table, callback );
+ });
+ }
+
+ if ( this[0] ) {
+ results = jQuery.buildFragment( args, this, scripts );
+ fragment = results.fragment;
+ first = fragment.firstChild;
+
+ if ( fragment.childNodes.length === 1 ) {
+ fragment = first;
+ }
+
+ if ( first ) {
+ table = table && jQuery.nodeName( first, "tr" );
+
+ // Use the original fragment for the last item instead of the first because it can end up
+ // being emptied incorrectly in certain situations (#8070).
+ // Fragments from the fragment cache must always be cloned and never used in place.
+ for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) {
+ callback.call(
+ table && jQuery.nodeName( this[i], "table" ) ?
+ findOrAppend( this[i], "tbody" ) :
+ this[i],
+ i === iNoClone ?
+ fragment :
+ jQuery.clone( fragment, true, true )
+ );
+ }
+ }
+
+ // Fix #11809: Avoid leaking memory
+ fragment = first = null;
+
+ if ( scripts.length ) {
+ jQuery.each( scripts, function( i, elem ) {
+ if ( elem.src ) {
+ if ( jQuery.ajax ) {
+ jQuery.ajax({
+ url: elem.src,
+ type: "GET",
+ dataType: "script",
+ async: false,
+ global: false,
+ "throws": true
+ });
+ } else {
+ jQuery.error("no ajax");
+ }
+ } else {
+ jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+ });
+ }
+ }
+
+ return this;
+ }
+});
+
+function findOrAppend( elem, tag ) {
+ return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
+}
+
+function cloneCopyEvent( src, dest ) {
+
+ if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
+ return;
+ }
+
+ var type, i, l,
+ oldData = jQuery._data( src ),
+ curData = jQuery._data( dest, oldData ),
+ events = oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
+
+ for ( type in events ) {
+ for ( i = 0, l = events[ type ].length; i < l; i++ ) {
+ jQuery.event.add( dest, type, events[ type ][ i ] );
+ }
+ }
+ }
+
+ // make the cloned public data object a copy from the original
+ if ( curData.data ) {
+ curData.data = jQuery.extend( {}, curData.data );
+ }
+}
+
+function cloneFixAttributes( src, dest ) {
+ var nodeName;
+
+ // We do not need to do anything for non-Elements
+ if ( dest.nodeType !== 1 ) {
+ return;
+ }
+
+ // clearAttributes removes the attributes, which we don't want,
+ // but also removes the attachEvent events, which we *do* want
+ if ( dest.clearAttributes ) {
+ dest.clearAttributes();
+ }
+
+ // mergeAttributes, in contrast, only merges back on the
+ // original attributes, not the events
+ if ( dest.mergeAttributes ) {
+ dest.mergeAttributes( src );
+ }
+
+ nodeName = dest.nodeName.toLowerCase();
+
+ if ( nodeName === "object" ) {
+ // IE6-10 improperly clones children of object elements using classid.
+ // IE10 throws NoModificationAllowedError if parent is null, #12132.
+ if ( dest.parentNode ) {
+ dest.outerHTML = src.outerHTML;
+ }
+
+ // This path appears unavoidable for IE9. When cloning an object
+ // element in IE9, the outerHTML strategy above is not sufficient.
+ // If the src has innerHTML and the destination does not,
+ // copy the src.innerHTML into the dest.innerHTML. #10324
+ if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
+ dest.innerHTML = src.innerHTML;
+ }
+
+ } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
+ // IE6-8 fails to persist the checked state of a cloned checkbox
+ // or radio button. Worse, IE6-7 fail to give the cloned element
+ // a checked appearance if the defaultChecked value isn't also set
+
+ dest.defaultChecked = dest.checked = src.checked;
+
+ // IE6-7 get confused and end up setting the value of a cloned
+ // checkbox/radio button to an empty string instead of "on"
+ if ( dest.value !== src.value ) {
+ dest.value = src.value;
+ }
+
+ // IE6-8 fails to return the selected option to the default selected
+ // state when cloning options
+ } else if ( nodeName === "option" ) {
+ dest.selected = src.defaultSelected;
+
+ // IE6-8 fails to set the defaultValue to the correct value when
+ // cloning other types of input fields
+ } else if ( nodeName === "input" || nodeName === "textarea" ) {
+ dest.defaultValue = src.defaultValue;
+
+ // IE blanks contents when cloning scripts
+ } else if ( nodeName === "script" && dest.text !== src.text ) {
+ dest.text = src.text;
+ }
+
+ // Event data gets referenced instead of copied if the expando
+ // gets copied too
+ dest.removeAttribute( jQuery.expando );
+}
+
+jQuery.buildFragment = function( args, context, scripts ) {
+ var fragment, cacheable, cachehit,
+ first = args[ 0 ];
+
+ // Set context from what may come in as undefined or a jQuery collection or a node
+ // Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 &
+ // also doubles as fix for #8950 where plain objects caused createDocumentFragment exception
+ context = context || document;
+ context = !context.nodeType && context[0] || context;
+ context = context.ownerDocument || context;
+
+ // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
+ // Cloning options loses the selected state, so don't cache them
+ // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
+ // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
+ // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
+ if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document &&
+ first.charAt(0) === "<" && !rnocache.test( first ) &&
+ (jQuery.support.checkClone || !rchecked.test( first )) &&
+ (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
+
+ // Mark cacheable and look for a hit
+ cacheable = true;
+ fragment = jQuery.fragments[ first ];
+ cachehit = fragment !== undefined;
+ }
+
+ if ( !fragment ) {
+ fragment = context.createDocumentFragment();
+ jQuery.clean( args, context, fragment, scripts );
+
+ // Update the cache, but only store false
+ // unless this is a second parsing of the same content
+ if ( cacheable ) {
+ jQuery.fragments[ first ] = cachehit && fragment;
+ }
+ }
+
+ return { fragment: fragment, cacheable: cacheable };
+};
+
+jQuery.fragments = {};
+
+jQuery.each({
+ appendTo: "append",
+ prependTo: "prepend",
+ insertBefore: "before",
+ insertAfter: "after",
+ replaceAll: "replaceWith"
+}, function( name, original ) {
+ jQuery.fn[ name ] = function( selector ) {
+ var elems,
+ i = 0,
+ ret = [],
+ insert = jQuery( selector ),
+ l = insert.length,
+ parent = this.length === 1 && this[0].parentNode;
+
+ if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) {
+ insert[ original ]( this[0] );
+ return this;
+ } else {
+ for ( ; i < l; i++ ) {
+ elems = ( i > 0 ? this.clone(true) : this ).get();
+ jQuery( insert[i] )[ original ]( elems );
+ ret = ret.concat( elems );
+ }
+
+ return this.pushStack( ret, name, insert.selector );
+ }
+ };
+});
+
+function getAll( elem ) {
+ if ( typeof elem.getElementsByTagName !== "undefined" ) {
+ return elem.getElementsByTagName( "*" );
+
+ } else if ( typeof elem.querySelectorAll !== "undefined" ) {
+ return elem.querySelectorAll( "*" );
+
+ } else {
+ return [];
+ }
+}
+
+// Used in clean, fixes the defaultChecked property
+function fixDefaultChecked( elem ) {
+ if ( rcheckableType.test( elem.type ) ) {
+ elem.defaultChecked = elem.checked;
+ }
+}
+
+jQuery.extend({
+ clone: function( elem, dataAndEvents, deepDataAndEvents ) {
+ var srcElements,
+ destElements,
+ i,
+ clone;
+
+ if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
+ clone = elem.cloneNode( true );
+
+ // IE<=8 does not properly clone detached, unknown element nodes
+ } else {
+ fragmentDiv.innerHTML = elem.outerHTML;
+ fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
+ }
+
+ if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
+ (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
+ // IE copies events bound via attachEvent when using cloneNode.
+ // Calling detachEvent on the clone will also remove the events
+ // from the original. In order to get around this, we use some
+ // proprietary methods to clear the events. Thanks to MooTools
+ // guys for this hotness.
+
+ cloneFixAttributes( elem, clone );
+
+ // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
+ srcElements = getAll( elem );
+ destElements = getAll( clone );
+
+ // Weird iteration because IE will replace the length property
+ // with an element if you are cloning the body and one of the
+ // elements on the page has a name or id of "length"
+ for ( i = 0; srcElements[i]; ++i ) {
+ // Ensure that the destination node is not null; Fixes #9587
+ if ( destElements[i] ) {
+ cloneFixAttributes( srcElements[i], destElements[i] );
+ }
+ }
+ }
+
+ // Copy the events from the original to the clone
+ if ( dataAndEvents ) {
+ cloneCopyEvent( elem, clone );
+
+ if ( deepDataAndEvents ) {
+ srcElements = getAll( elem );
+ destElements = getAll( clone );
+
+ for ( i = 0; srcElements[i]; ++i ) {
+ cloneCopyEvent( srcElements[i], destElements[i] );
+ }
+ }
+ }
+
+ srcElements = destElements = null;
+
+ // Return the cloned set
+ return clone;
+ },
+
+ clean: function( elems, context, fragment, scripts ) {
+ var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags,
+ safe = context === document && safeFragment,
+ ret = [];
+
+ // Ensure that context is a document
+ if ( !context || typeof context.createDocumentFragment === "undefined" ) {
+ context = document;
+ }
+
+ // Use the already-created safe fragment if context permits
+ for ( i = 0; (elem = elems[i]) != null; i++ ) {
+ if ( typeof elem === "number" ) {
+ elem += "";
+ }
+
+ if ( !elem ) {
+ continue;
+ }
+
+ // Convert html string into DOM nodes
+ if ( typeof elem === "string" ) {
+ if ( !rhtml.test( elem ) ) {
+ elem = context.createTextNode( elem );
+ } else {
+ // Ensure a safe container in which to render the html
+ safe = safe || createSafeFragment( context );
+ div = context.createElement("div");
+ safe.appendChild( div );
+
+ // Fix "XHTML"-style tags in all browsers
+ elem = elem.replace(rxhtmlTag, "<$1></$2>");
+
+ // Go to html and back, then peel off extra wrappers
+ tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
+ wrap = wrapMap[ tag ] || wrapMap._default;
+ depth = wrap[0];
+ div.innerHTML = wrap[1] + elem + wrap[2];
+
+ // Move to the right depth
+ while ( depth-- ) {
+ div = div.lastChild;
+ }
+
+ // Remove IE's autoinserted <tbody> from table fragments
+ if ( !jQuery.support.tbody ) {
+
+ // String was a <table>, *may* have spurious <tbody>
+ hasBody = rtbody.test(elem);
+ tbody = tag === "table" && !hasBody ?
+ div.firstChild && div.firstChild.childNodes :
+
+ // String was a bare <thead> or <tfoot>
+ wrap[1] === "<table>" && !hasBody ?
+ div.childNodes :
+ [];
+
+ for ( j = tbody.length - 1; j >= 0 ; --j ) {
+ if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
+ tbody[ j ].parentNode.removeChild( tbody[ j ] );
+ }
+ }
+ }
+
+ // IE completely kills leading whitespace when innerHTML is used
+ if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+ div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
+ }
+
+ elem = div.childNodes;
+
+ // Take out of fragment container (we need a fresh div each time)
+ div.parentNode.removeChild( div );
+ }
+ }
+
+ if ( elem.nodeType ) {
+ ret.push( elem );
+ } else {
+ jQuery.merge( ret, elem );
+ }
+ }
+
+ // Fix #11356: Clear elements from safeFragment
+ if ( div ) {
+ elem = div = safe = null;
+ }
+
+ // Reset defaultChecked for any radios and checkboxes
+ // about to be appended to the DOM in IE 6/7 (#8060)
+ if ( !jQuery.support.appendChecked ) {
+ for ( i = 0; (elem = ret[i]) != null; i++ ) {
+ if ( jQuery.nodeName( elem, "input" ) ) {
+ fixDefaultChecked( elem );
+ } else if ( typeof elem.getElementsByTagName !== "undefined" ) {
+ jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
+ }
+ }
+ }
+
+ // Append elements to a provided document fragment
+ if ( fragment ) {
+ // Special handling of each script element
+ handleScript = function( elem ) {
+ // Check if we consider it executable
+ if ( !elem.type || rscriptType.test( elem.type ) ) {
+ // Detach the script and store it in the scripts array (if provided) or the fragment
+ // Return truthy to indicate that it has been handled
+ return scripts ?
+ scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
+ fragment.appendChild( elem );
+ }
+ };
+
+ for ( i = 0; (elem = ret[i]) != null; i++ ) {
+ // Check if we're done after handling an executable script
+ if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
+ // Append to fragment and handle embedded scripts
+ fragment.appendChild( elem );
+ if ( typeof elem.getElementsByTagName !== "undefined" ) {
+ // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
+ jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
+
+ // Splice the scripts into ret after their former ancestor and advance our index beyond them
+ ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
+ i += jsTags.length;
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ cleanData: function( elems, /* internal */ acceptData ) {
+ var data, id, elem, type,
+ i = 0,
+ internalKey = jQuery.expando,
+ cache = jQuery.cache,
+ deleteExpando = jQuery.support.deleteExpando,
+ special = jQuery.event.special;
+
+ for ( ; (elem = elems[i]) != null; i++ ) {
+
+ if ( acceptData || jQuery.acceptData( elem ) ) {
+
+ id = elem[ internalKey ];
+ data = id && cache[ id ];
+
+ if ( data ) {
+ if ( data.events ) {
+ for ( type in data.events ) {
+ if ( special[ type ] ) {
+ jQuery.event.remove( elem, type );
+
+ // This is a shortcut to avoid jQuery.event.remove's overhead
+ } else {
+ jQuery.removeEvent( elem, type, data.handle );
+ }
+ }
+ }
+
+ // Remove cache only if it was not already removed by jQuery.event.remove
+ if ( cache[ id ] ) {
+
+ delete cache[ id ];
+
+ // IE does not allow us to delete expando properties from nodes,
+ // nor does it have a removeAttribute function on Document nodes;
+ // we must handle all of these cases
+ if ( deleteExpando ) {
+ delete elem[ internalKey ];
+
+ } else if ( elem.removeAttribute ) {
+ elem.removeAttribute( internalKey );
+
+ } else {
+ elem[ internalKey ] = null;
+ }
+
+ jQuery.deletedIds.push( id );
+ }
+ }
+ }
+ }
+ }
+});
+// Limit scope pollution from any deprecated API
+(function() {
+
+var matched, browser;
+
+// Use of jQuery.browser is frowned upon.
+// More details: http://api.jquery.com/jQuery.browser
+// jQuery.uaMatch maintained for back-compat
+jQuery.uaMatch = function( ua ) {
+ ua = ua.toLowerCase();
+
+ var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
+ /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
+ /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
+ /(msie) ([\w.]+)/.exec( ua ) ||
+ ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
+ [];
+
+ return {
+ browser: match[ 1 ] || "",
+ version: match[ 2 ] || "0"
+ };
+};
+
+matched = jQuery.uaMatch( navigator.userAgent );
+browser = {};
+
+if ( matched.browser ) {
+ browser[ matched.browser ] = true;
+ browser.version = matched.version;
+}
+
+// Chrome is Webkit, but Webkit is also Safari.
+if ( browser.chrome ) {
+ browser.webkit = true;
+} else if ( browser.webkit ) {
+ browser.safari = true;
+}
+
+jQuery.browser = browser;
+
+jQuery.sub = function() {
+ function jQuerySub( selector, context ) {
+ return new jQuerySub.fn.init( selector, context );
+ }
+ jQuery.extend( true, jQuerySub, this );
+ jQuerySub.superclass = this;
+ jQuerySub.fn = jQuerySub.prototype = this();
+ jQuerySub.fn.constructor = jQuerySub;
+ jQuerySub.sub = this.sub;
+ jQuerySub.fn.init = function init( selector, context ) {
+ if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
+ context = jQuerySub( context );
+ }
+
+ return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
+ };
+ jQuerySub.fn.init.prototype = jQuerySub.fn;
+ var rootjQuerySub = jQuerySub(document);
+ return jQuerySub;
+};
+
+})();
+var curCSS, iframe, iframeDoc,
+ ralpha = /alpha\([^)]*\)/i,
+ ropacity = /opacity=([^)]*)/,
+ rposition = /^(top|right|bottom|left)$/,
+ // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
+ // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
+ rdisplayswap = /^(none|table(?!-c[ea]).+)/,
+ rmargin = /^margin/,
+ rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
+ rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
+ rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ),
+ elemdisplay = { BODY: "block" },
+
+ cssShow = { position: "absolute", visibility: "hidden", display: "block" },
+ cssNormalTransform = {
+ letterSpacing: 0,
+ fontWeight: 400
+ },
+
+ cssExpand = [ "Top", "Right", "Bottom", "Left" ],
+ cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
+
+ eventsToggle = jQuery.fn.toggle;
+
+// return a css property mapped to a potentially vendor prefixed property
+function vendorPropName( style, name ) {
+
+ // shortcut for names that are not vendor prefixed
+ if ( name in style ) {
+ return name;
+ }
+
+ // check for vendor prefixed names
+ var capName = name.charAt(0).toUpperCase() + name.slice(1),
+ origName = name,
+ i = cssPrefixes.length;
+
+ while ( i-- ) {
+ name = cssPrefixes[ i ] + capName;
+ if ( name in style ) {
+ return name;
+ }
+ }
+
+ return origName;
+}
+
+function isHidden( elem, el ) {
+ elem = el || elem;
+ return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
+}
+
+function showHide( elements, show ) {
+ var elem, display,
+ values = [],
+ index = 0,
+ length = elements.length;
+
+ for ( ; index < length; index++ ) {
+ elem = elements[ index ];
+ if ( !elem.style ) {
+ continue;
+ }
+ values[ index ] = jQuery._data( elem, "olddisplay" );
+ if ( show ) {
+ // Reset the inline display of this element to learn if it is
+ // being hidden by cascaded rules or not
+ if ( !values[ index ] && elem.style.display === "none" ) {
+ elem.style.display = "";
+ }
+
+ // Set elements which have been overridden with display: none
+ // in a stylesheet to whatever the default browser style is
+ // for such an element
+ if ( elem.style.display === "" && isHidden( elem ) ) {
+ values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
+ }
+ } else {
+ display = curCSS( elem, "display" );
+
+ if ( !values[ index ] && display !== "none" ) {
+ jQuery._data( elem, "olddisplay", display );
+ }
+ }
+ }
+
+ // Set the display of most of the elements in a second loop
+ // to avoid the constant reflow
+ for ( index = 0; index < length; index++ ) {
+ elem = elements[ index ];
+ if ( !elem.style ) {
+ continue;
+ }
+ if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
+ elem.style.display = show ? values[ index ] || "" : "none";
+ }
+ }
+
+ return elements;
+}
+
+jQuery.fn.extend({
+ css: function( name, value ) {
+ return jQuery.access( this, function( elem, name, value ) {
+ return value !== undefined ?
+ jQuery.style( elem, name, value ) :
+ jQuery.css( elem, name );
+ }, name, value, arguments.length > 1 );
+ },
+ show: function() {
+ return showHide( this, true );
+ },
+ hide: function() {
+ return showHide( this );
+ },
+ toggle: function( state, fn2 ) {
+ var bool = typeof state === "boolean";
+
+ if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) {
+ return eventsToggle.apply( this, arguments );
+ }
+
+ return this.each(function() {
+ if ( bool ? state : isHidden( this ) ) {
+ jQuery( this ).show();
+ } else {
+ jQuery( this ).hide();
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ // Add in style property hooks for overriding the default
+ // behavior of getting and setting a style property
+ cssHooks: {
+ opacity: {
+ get: function( elem, computed ) {
+ if ( computed ) {
+ // We should always get a number back from opacity
+ var ret = curCSS( elem, "opacity" );
+ return ret === "" ? "1" : ret;
+
+ }
+ }
+ }
+ },
+
+ // Exclude the following css properties to add px
+ cssNumber: {
+ "fillOpacity": true,
+ "fontWeight": true,
+ "lineHeight": true,
+ "opacity": true,
+ "orphans": true,
+ "widows": true,
+ "zIndex": true,
+ "zoom": true
+ },
+
+ // Add in properties whose names you wish to fix before
+ // setting or getting the value
+ cssProps: {
+ // normalize float css property
+ "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
+ },
+
+ // Get and set the style property on a DOM Node
+ style: function( elem, name, value, extra ) {
+ // Don't set styles on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
+ return;
+ }
+
+ // Make sure that we're working with the right name
+ var ret, type, hooks,
+ origName = jQuery.camelCase( name ),
+ style = elem.style;
+
+ name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
+
+ // gets hook for the prefixed version
+ // followed by the unprefixed version
+ hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+ // Check if we're setting a value
+ if ( value !== undefined ) {
+ type = typeof value;
+
+ // convert relative number strings (+= or -=) to relative numbers. #7345
+ if ( type === "string" && (ret = rrelNum.exec( value )) ) {
+ value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
+ // Fixes bug #9237
+ type = "number";
+ }
+
+ // Make sure that NaN and null values aren't set. See: #7116
+ if ( value == null || type === "number" && isNaN( value ) ) {
+ return;
+ }
+
+ // If a number was passed in, add 'px' to the (except for certain CSS properties)
+ if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
+ value += "px";
+ }
+
+ // If a hook was provided, use that value, otherwise just set the specified value
+ if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
+ // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
+ // Fixes bug #5509
+ try {
+ style[ name ] = value;
+ } catch(e) {}
+ }
+
+ } else {
+ // If a hook was provided get the non-computed value from there
+ if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
+ return ret;
+ }
+
+ // Otherwise just get the value from the style object
+ return style[ name ];
+ }
+ },
+
+ css: function( elem, name, numeric, extra ) {
+ var val, num, hooks,
+ origName = jQuery.camelCase( name );
+
+ // Make sure that we're working with the right name
+ name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
+
+ // gets hook for the prefixed version
+ // followed by the unprefixed version
+ hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+ // If a hook was provided get the computed value from there
+ if ( hooks && "get" in hooks ) {
+ val = hooks.get( elem, true, extra );
+ }
+
+ // Otherwise, if a way to get the computed value exists, use that
+ if ( val === undefined ) {
+ val = curCSS( elem, name );
+ }
+
+ //convert "normal" to computed value
+ if ( val === "normal" && name in cssNormalTransform ) {
+ val = cssNormalTransform[ name ];
+ }
+
+ // Return, converting to number if forced or a qualifier was provided and val looks numeric
+ if ( numeric || extra !== undefined ) {
+ num = parseFloat( val );
+ return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
+ }
+ return val;
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations
+ swap: function( elem, options, callback ) {
+ var ret, name,
+ old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ ret = callback.call( elem );
+
+ // Revert the old values
+ for ( name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+
+ return ret;
+ }
+});
+
+// NOTE: To any future maintainer, we've window.getComputedStyle
+// because jsdom on node.js will break without it.
+if ( window.getComputedStyle ) {
+ curCSS = function( elem, name ) {
+ var ret, width, minWidth, maxWidth,
+ computed = window.getComputedStyle( elem, null ),
+ style = elem.style;
+
+ if ( computed ) {
+
+ // getPropertyValue is only needed for .css('filter') in IE9, see #12537
+ ret = computed.getPropertyValue( name ) || computed[ name ];
+
+ if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
+ ret = jQuery.style( elem, name );
+ }
+
+ // A tribute to the "awesome hack by Dean Edwards"
+ // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
+ // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
+ // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
+ if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
+ width = style.width;
+ minWidth = style.minWidth;
+ maxWidth = style.maxWidth;
+
+ style.minWidth = style.maxWidth = style.width = ret;
+ ret = computed.width;
+
+ style.width = width;
+ style.minWidth = minWidth;
+ style.maxWidth = maxWidth;
+ }
+ }
+
+ return ret;
+ };
+} else if ( document.documentElement.currentStyle ) {
+ curCSS = function( elem, name ) {
+ var left, rsLeft,
+ ret = elem.currentStyle && elem.currentStyle[ name ],
+ style = elem.style;
+
+ // Avoid setting ret to empty string here
+ // so we don't default to auto
+ if ( ret == null && style && style[ name ] ) {
+ ret = style[ name ];
+ }
+
+ // From the awesome hack by Dean Edwards
+ // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+ // If we're not dealing with a regular pixel number
+ // but a number that has a weird ending, we need to convert it to pixels
+ // but not position css attributes, as those are proportional to the parent element instead
+ // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
+ if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
+
+ // Remember the original values
+ left = style.left;
+ rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
+
+ // Put in the new values to get a computed value out
+ if ( rsLeft ) {
+ elem.runtimeStyle.left = elem.currentStyle.left;
+ }
+ style.left = name === "fontSize" ? "1em" : ret;
+ ret = style.pixelLeft + "px";
+
+ // Revert the changed values
+ style.left = left;
+ if ( rsLeft ) {
+ elem.runtimeStyle.left = rsLeft;
+ }
+ }
+
+ return ret === "" ? "auto" : ret;
+ };
+}
+
+function setPositiveNumber( elem, value, subtract ) {
+ var matches = rnumsplit.exec( value );
+ return matches ?
+ Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
+ value;
+}
+
+function augmentWidthOrHeight( elem, name, extra, isBorderBox ) {
+ var i = extra === ( isBorderBox ? "border" : "content" ) ?
+ // If we already have the right measurement, avoid augmentation
+ 4 :
+ // Otherwise initialize for horizontal or vertical properties
+ name === "width" ? 1 : 0,
+
+ val = 0;
+
+ for ( ; i < 4; i += 2 ) {
+ // both box models exclude margin, so add it if we want it
+ if ( extra === "margin" ) {
+ // we use jQuery.css instead of curCSS here
+ // because of the reliableMarginRight CSS hook!
+ val += jQuery.css( elem, extra + cssExpand[ i ], true );
+ }
+
+ // From this point on we use curCSS for maximum performance (relevant in animations)
+ if ( isBorderBox ) {
+ // border-box includes padding, so remove it if we want content
+ if ( extra === "content" ) {
+ val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
+ }
+
+ // at this point, extra isn't border nor margin, so remove border
+ if ( extra !== "margin" ) {
+ val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
+ }
+ } else {
+ // at this point, extra isn't content, so add padding
+ val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
+
+ // at this point, extra isn't content nor padding, so add border
+ if ( extra !== "padding" ) {
+ val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
+ }
+ }
+ }
+
+ return val;
+}
+
+function getWidthOrHeight( elem, name, extra ) {
+
+ // Start with offset property, which is equivalent to the border-box value
+ var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
+ valueIsBorderBox = true,
+ isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";
+
+ // some non-html elements return undefined for offsetWidth, so check for null/undefined
+ // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
+ // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
+ if ( val <= 0 || val == null ) {
+ // Fall back to computed then uncomputed css if necessary
+ val = curCSS( elem, name );
+ if ( val < 0 || val == null ) {
+ val = elem.style[ name ];
+ }
+
+ // Computed unit is not pixels. Stop here and return.
+ if ( rnumnonpx.test(val) ) {
+ return val;
+ }
+
+ // we need the check for style in case a browser which returns unreliable values
+ // for getComputedStyle silently falls back to the reliable elem.style
+ valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
+
+ // Normalize "", auto, and prepare for extra
+ val = parseFloat( val ) || 0;
+ }
+
+ // use the active box-sizing model to add/subtract irrelevant styles
+ return ( val +
+ augmentWidthOrHeight(
+ elem,
+ name,
+ extra || ( isBorderBox ? "border" : "content" ),
+ valueIsBorderBox
+ )
+ ) + "px";
+}
+
+
+// Try to determine the default display value of an element
+function css_defaultDisplay( nodeName ) {
+ if ( elemdisplay[ nodeName ] ) {
+ return elemdisplay[ nodeName ];
+ }
+
+ var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ),
+ display = elem.css("display");
+ elem.remove();
+
+ // If the simple way fails,
+ // get element's real default display by attaching it to a temp iframe
+ if ( display === "none" || display === "" ) {
+ // Use the already-created iframe if possible
+ iframe = document.body.appendChild(
+ iframe || jQuery.extend( document.createElement("iframe"), {
+ frameBorder: 0,
+ width: 0,
+ height: 0
+ })
+ );
+
+ // Create a cacheable copy of the iframe document on first call.
+ // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
+ // document to it; WebKit & Firefox won't allow reusing the iframe document.
+ if ( !iframeDoc || !iframe.createElement ) {
+ iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
+ iframeDoc.write("<!doctype html><html><body>");
+ iframeDoc.close();
+ }
+
+ elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) );
+
+ display = curCSS( elem, "display" );
+ document.body.removeChild( iframe );
+ }
+
+ // Store the correct default display
+ elemdisplay[ nodeName ] = display;
+
+ return display;
+}
+
+jQuery.each([ "height", "width" ], function( i, name ) {
+ jQuery.cssHooks[ name ] = {
+ get: function( elem, computed, extra ) {
+ if ( computed ) {
+ // certain elements can have dimension info if we invisibly show them
+ // however, it must have a current display style that would benefit from this
+ if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) {
+ return jQuery.swap( elem, cssShow, function() {
+ return getWidthOrHeight( elem, name, extra );
+ });
+ } else {
+ return getWidthOrHeight( elem, name, extra );
+ }
+ }
+ },
+
+ set: function( elem, value, extra ) {
+ return setPositiveNumber( elem, value, extra ?
+ augmentWidthOrHeight(
+ elem,
+ name,
+ extra,
+ jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"
+ ) : 0
+ );
+ }
+ };
+});
+
+if ( !jQuery.support.opacity ) {
+ jQuery.cssHooks.opacity = {
+ get: function( elem, computed ) {
+ // IE uses filters for opacity
+ return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
+ ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
+ computed ? "1" : "";
+ },
+
+ set: function( elem, value ) {
+ var style = elem.style,
+ currentStyle = elem.currentStyle,
+ opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
+ filter = currentStyle && currentStyle.filter || style.filter || "";
+
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
+ if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
+ style.removeAttribute ) {
+
+ // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
+ // if "filter:" is present at all, clearType is disabled, we want to avoid this
+ // style.removeAttribute is IE Only, but so apparently is this code path...
+ style.removeAttribute( "filter" );
+
+ // if there there is no filter style applied in a css rule, we are done
+ if ( currentStyle && !currentStyle.filter ) {
+ return;
+ }
+ }
+
+ // otherwise, set new filter values
+ style.filter = ralpha.test( filter ) ?
+ filter.replace( ralpha, opacity ) :
+ filter + " " + opacity;
+ }
+ };
+}
+
+// These hooks cannot be added until DOM ready because the support test
+// for it is not run until after DOM ready
+jQuery(function() {
+ if ( !jQuery.support.reliableMarginRight ) {
+ jQuery.cssHooks.marginRight = {
+ get: function( elem, computed ) {
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ // Work around by temporarily setting element display to inline-block
+ return jQuery.swap( elem, { "display": "inline-block" }, function() {
+ if ( computed ) {
+ return curCSS( elem, "marginRight" );
+ }
+ });
+ }
+ };
+ }
+
+ // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
+ // getComputedStyle returns percent when specified for top/left/bottom/right
+ // rather than make the css module depend on the offset module, we just check for it here
+ if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
+ jQuery.each( [ "top", "left" ], function( i, prop ) {
+ jQuery.cssHooks[ prop ] = {
+ get: function( elem, computed ) {
+ if ( computed ) {
+ var ret = curCSS( elem, prop );
+ // if curCSS returns percentage, fallback to offset
+ return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret;
+ }
+ }
+ };
+ });
+ }
+
+});
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.hidden = function( elem ) {
+ return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none");
+ };
+
+ jQuery.expr.filters.visible = function( elem ) {
+ return !jQuery.expr.filters.hidden( elem );
+ };
+}
+
+// These hooks are used by animate to expand properties
+jQuery.each({
+ margin: "",
+ padding: "",
+ border: "Width"
+}, function( prefix, suffix ) {
+ jQuery.cssHooks[ prefix + suffix ] = {
+ expand: function( value ) {
+ var i,
+
+ // assumes a single number if not a string
+ parts = typeof value === "string" ? value.split(" ") : [ value ],
+ expanded = {};
+
+ for ( i = 0; i < 4; i++ ) {
+ expanded[ prefix + cssExpand[ i ] + suffix ] =
+ parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
+ }
+
+ return expanded;
+ }
+ };
+
+ if ( !rmargin.test( prefix ) ) {
+ jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
+ }
+});
+var r20 = /%20/g,
+ rbracket = /\[\]$/,
+ rCRLF = /\r?\n/g,
+ rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
+ rselectTextarea = /^(?:select|textarea)/i;
+
+jQuery.fn.extend({
+ serialize: function() {
+ return jQuery.param( this.serializeArray() );
+ },
+ serializeArray: function() {
+ return this.map(function(){
+ return this.elements ? jQuery.makeArray( this.elements ) : this;
+ })
+ .filter(function(){
+ return this.name && !this.disabled &&
+ ( this.checked || rselectTextarea.test( this.nodeName ) ||
+ rinput.test( this.type ) );
+ })
+ .map(function( i, elem ){
+ var val = jQuery( this ).val();
+
+ return val == null ?
+ null :
+ jQuery.isArray( val ) ?
+ jQuery.map( val, function( val, i ){
+ return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+ }) :
+ { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+ }).get();
+ }
+});
+
+//Serialize an array of form elements or a set of
+//key/values into a query string
+jQuery.param = function( a, traditional ) {
+ var prefix,
+ s = [],
+ add = function( key, value ) {
+ // If value is a function, invoke it and return its value
+ value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
+ s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
+ };
+
+ // Set traditional to true for jQuery <= 1.3.2 behavior.
+ if ( traditional === undefined ) {
+ traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
+ }
+
+ // If an array was passed in, assume that it is an array of form elements.
+ if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
+ // Serialize the form elements
+ jQuery.each( a, function() {
+ add( this.name, this.value );
+ });
+
+ } else {
+ // If traditional, encode the "old" way (the way 1.3.2 or older
+ // did it), otherwise encode params recursively.
+ for ( prefix in a ) {
+ buildParams( prefix, a[ prefix ], traditional, add );
+ }
+ }
+
+ // Return the resulting serialization
+ return s.join( "&" ).replace( r20, "+" );
+};
+
+function buildParams( prefix, obj, traditional, add ) {
+ var name;
+
+ if ( jQuery.isArray( obj ) ) {
+ // Serialize array item.
+ jQuery.each( obj, function( i, v ) {
+ if ( traditional || rbracket.test( prefix ) ) {
+ // Treat each array item as a scalar.
+ add( prefix, v );
+
+ } else {
+ // If array item is non-scalar (array or object), encode its
+ // numeric index to resolve deserialization ambiguity issues.
+ // Note that rack (as of 1.0.0) can't currently deserialize
+ // nested arrays properly, and attempting to do so may cause
+ // a server error. Possible fixes are to modify rack's
+ // deserialization algorithm or to provide an option or flag
+ // to force array serialization to be shallow.
+ buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
+ }
+ });
+
+ } else if ( !traditional && jQuery.type( obj ) === "object" ) {
+ // Serialize object item.
+ for ( name in obj ) {
+ buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
+ }
+
+ } else {
+ // Serialize scalar item.
+ add( prefix, obj );
+ }
+}
+var
+ // Document location
+ ajaxLocParts,
+ ajaxLocation,
+
+ rhash = /#.*$/,
+ rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
+ // #7653, #8125, #8152: local protocol detection
+ rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
+ rnoContent = /^(?:GET|HEAD)$/,
+ rprotocol = /^\/\//,
+ rquery = /\?/,
+ rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
+ rts = /([?&])_=[^&]*/,
+ rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
+
+ // Keep a copy of the old load method
+ _load = jQuery.fn.load,
+
+ /* Prefilters
+ * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
+ * 2) These are called:
+ * - BEFORE asking for a transport
+ * - AFTER param serialization (s.data is a string if s.processData is true)
+ * 3) key is the dataType
+ * 4) the catchall symbol "*" can be used
+ * 5) execution will start with transport dataType and THEN continue down to "*" if needed
+ */
+ prefilters = {},
+
+ /* Transports bindings
+ * 1) key is the dataType
+ * 2) the catchall symbol "*" can be used
+ * 3) selection will start with transport dataType and THEN go to "*" if needed
+ */
+ transports = {},
+
+ // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
+ allTypes = ["*/"] + ["*"];
+
+// #8138, IE may throw an exception when accessing
+// a field from window.location if document.domain has been set
+try {
+ ajaxLocation = location.href;
+} catch( e ) {
+ // Use the href attribute of an A element
+ // since IE will modify it given document.location
+ ajaxLocation = document.createElement( "a" );
+ ajaxLocation.href = "";
+ ajaxLocation = ajaxLocation.href;
+}
+
+// Segment location into parts
+ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
+
+// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
+function addToPrefiltersOrTransports( structure ) {
+
+ // dataTypeExpression is optional and defaults to "*"
+ return function( dataTypeExpression, func ) {
+
+ if ( typeof dataTypeExpression !== "string" ) {
+ func = dataTypeExpression;
+ dataTypeExpression = "*";
+ }
+
+ var dataType, list, placeBefore,
+ dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
+ i = 0,
+ length = dataTypes.length;
+
+ if ( jQuery.isFunction( func ) ) {
+ // For each dataType in the dataTypeExpression
+ for ( ; i < length; i++ ) {
+ dataType = dataTypes[ i ];
+ // We control if we're asked to add before
+ // any existing element
+ placeBefore = /^\+/.test( dataType );
+ if ( placeBefore ) {
+ dataType = dataType.substr( 1 ) || "*";
+ }
+ list = structure[ dataType ] = structure[ dataType ] || [];
+ // then we add to the structure accordingly
+ list[ placeBefore ? "unshift" : "push" ]( func );
+ }
+ }
+ };
+}
+
+// Base inspection function for prefilters and transports
+function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
+ dataType /* internal */, inspected /* internal */ ) {
+
+ dataType = dataType || options.dataTypes[ 0 ];
+ inspected = inspected || {};
+
+ inspected[ dataType ] = true;
+
+ var selection,
+ list = structure[ dataType ],
+ i = 0,
+ length = list ? list.length : 0,
+ executeOnly = ( structure === prefilters );
+
+ for ( ; i < length && ( executeOnly || !selection ); i++ ) {
+ selection = list[ i ]( options, originalOptions, jqXHR );
+ // If we got redirected to another dataType
+ // we try there if executing only and not done already
+ if ( typeof selection === "string" ) {
+ if ( !executeOnly || inspected[ selection ] ) {
+ selection = undefined;
+ } else {
+ options.dataTypes.unshift( selection );
+ selection = inspectPrefiltersOrTransports(
+ structure, options, originalOptions, jqXHR, selection, inspected );
+ }
+ }
+ }
+ // If we're only executing or nothing was selected
+ // we try the catchall dataType if not done already
+ if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
+ selection = inspectPrefiltersOrTransports(
+ structure, options, originalOptions, jqXHR, "*", inspected );
+ }
+ // unnecessary when only executing (prefilters)
+ // but it'll be ignored by the caller in that case
+ return selection;
+}
+
+// A special extend for ajax options
+// that takes "flat" options (not to be deep extended)
+// Fixes #9887
+function ajaxExtend( target, src ) {
+ var key, deep,
+ flatOptions = jQuery.ajaxSettings.flatOptions || {};
+ for ( key in src ) {
+ if ( src[ key ] !== undefined ) {
+ ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
+ }
+ }
+ if ( deep ) {
+ jQuery.extend( true, target, deep );
+ }
+}
+
+jQuery.fn.load = function( url, params, callback ) {
+ if ( typeof url !== "string" && _load ) {
+ return _load.apply( this, arguments );
+ }
+
+ // Don't do a request if no elements are being requested
+ if ( !this.length ) {
+ return this;
+ }
+
+ var selector, type, response,
+ self = this,
+ off = url.indexOf(" ");
+
+ if ( off >= 0 ) {
+ selector = url.slice( off, url.length );
+ url = url.slice( 0, off );
+ }
+
+ // If it's a function
+ if ( jQuery.isFunction( params ) ) {
+
+ // We assume that it's the callback
+ callback = params;
+ params = undefined;
+
+ // Otherwise, build a param string
+ } else if ( params && typeof params === "object" ) {
+ type = "POST";
+ }
+
+ // Request the remote document
+ jQuery.ajax({
+ url: url,
+
+ // if "type" variable is undefined, then "GET" method will be used
+ type: type,
+ dataType: "html",
+ data: params,
+ complete: function( jqXHR, status ) {
+ if ( callback ) {
+ self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
+ }
+ }
+ }).done(function( responseText ) {
+
+ // Save response for use in complete callback
+ response = arguments;
+
+ // See if a selector was specified
+ self.html( selector ?
+
+ // Create a dummy div to hold the results
+ jQuery("<div>")
+
+ // inject the contents of the document in, removing the scripts
+ // to avoid any 'Permission Denied' errors in IE
+ .append( responseText.replace( rscript, "" ) )
+
+ // Locate the specified elements
+ .find( selector ) :
+
+ // If not, just inject the full result
+ responseText );
+
+ });
+
+ return this;
+};
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
+ jQuery.fn[ o ] = function( f ){
+ return this.on( o, f );
+ };
+});
+
+jQuery.each( [ "get", "post" ], function( i, method ) {
+ jQuery[ method ] = function( url, data, callback, type ) {
+ // shift arguments if data argument was omitted
+ if ( jQuery.isFunction( data ) ) {
+ type = type || callback;
+ callback = data;
+ data = undefined;
+ }
+
+ return jQuery.ajax({
+ type: method,
+ url: url,
+ data: data,
+ success: callback,
+ dataType: type
+ });
+ };
+});
+
+jQuery.extend({
+
+ getScript: function( url, callback ) {
+ return jQuery.get( url, undefined, callback, "script" );
+ },
+
+ getJSON: function( url, data, callback ) {
+ return jQuery.get( url, data, callback, "json" );
+ },
+
+ // Creates a full fledged settings object into target
+ // with both ajaxSettings and settings fields.
+ // If target is omitted, writes into ajaxSettings.
+ ajaxSetup: function( target, settings ) {
+ if ( settings ) {
+ // Building a settings object
+ ajaxExtend( target, jQuery.ajaxSettings );
+ } else {
+ // Extending ajaxSettings
+ settings = target;
+ target = jQuery.ajaxSettings;
+ }
+ ajaxExtend( target, settings );
+ return target;
+ },
+
+ ajaxSettings: {
+ url: ajaxLocation,
+ isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
+ global: true,
+ type: "GET",
+ contentType: "application/x-www-form-urlencoded; charset=UTF-8",
+ processData: true,
+ async: true,
+ /*
+ timeout: 0,
+ data: null,
+ dataType: null,
+ username: null,
+ password: null,
+ cache: null,
+ throws: false,
+ traditional: false,
+ headers: {},
+ */
+
+ accepts: {
+ xml: "application/xml, text/xml",
+ html: "text/html",
+ text: "text/plain",
+ json: "application/json, text/javascript",
+ "*": allTypes
+ },
+
+ contents: {
+ xml: /xml/,
+ html: /html/,
+ json: /json/
+ },
+
+ responseFields: {
+ xml: "responseXML",
+ text: "responseText"
+ },
+
+ // List of data converters
+ // 1) key format is "source_type destination_type" (a single space in-between)
+ // 2) the catchall symbol "*" can be used for source_type
+ converters: {
+
+ // Convert anything to text
+ "* text": window.String,
+
+ // Text to html (true = no transformation)
+ "text html": true,
+
+ // Evaluate text as a json expression
+ "text json": jQuery.parseJSON,
+
+ // Parse text as xml
+ "text xml": jQuery.parseXML
+ },
+
+ // For options that shouldn't be deep extended:
+ // you can add your own custom options here if
+ // and when you create one that shouldn't be
+ // deep extended (see ajaxExtend)
+ flatOptions: {
+ context: true,
+ url: true
+ }
+ },
+
+ ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
+ ajaxTransport: addToPrefiltersOrTransports( transports ),
+
+ // Main method
+ ajax: function( url, options ) {
+
+ // If url is an object, simulate pre-1.5 signature
+ if ( typeof url === "object" ) {
+ options = url;
+ url = undefined;
+ }
+
+ // Force options to be an object
+ options = options || {};
+
+ var // ifModified key
+ ifModifiedKey,
+ // Response headers
+ responseHeadersString,
+ responseHeaders,
+ // transport
+ transport,
+ // timeout handle
+ timeoutTimer,
+ // Cross-domain detection vars
+ parts,
+ // To know if global events are to be dispatched
+ fireGlobals,
+ // Loop variable
+ i,
+ // Create the final options object
+ s = jQuery.ajaxSetup( {}, options ),
+ // Callbacks context
+ callbackContext = s.context || s,
+ // Context for global events
+ // It's the callbackContext if one was provided in the options
+ // and if it's a DOM node or a jQuery collection
+ globalEventContext = callbackContext !== s &&
+ ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
+ jQuery( callbackContext ) : jQuery.event,
+ // Deferreds
+ deferred = jQuery.Deferred(),
+ completeDeferred = jQuery.Callbacks( "once memory" ),
+ // Status-dependent callbacks
+ statusCode = s.statusCode || {},
+ // Headers (they are sent all at once)
+ requestHeaders = {},
+ requestHeadersNames = {},
+ // The jqXHR state
+ state = 0,
+ // Default abort message
+ strAbort = "canceled",
+ // Fake xhr
+ jqXHR = {
+
+ readyState: 0,
+
+ // Caches the header
+ setRequestHeader: function( name, value ) {
+ if ( !state ) {
+ var lname = name.toLowerCase();
+ name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
+ requestHeaders[ name ] = value;
+ }
+ return this;
+ },
+
+ // Raw string
+ getAllResponseHeaders: function() {
+ return state === 2 ? responseHeadersString : null;
+ },
+
+ // Builds headers hashtable if needed
+ getResponseHeader: function( key ) {
+ var match;
+ if ( state === 2 ) {
+ if ( !responseHeaders ) {
+ responseHeaders = {};
+ while( ( match = rheaders.exec( responseHeadersString ) ) ) {
+ responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
+ }
+ }
+ match = responseHeaders[ key.toLowerCase() ];
+ }
+ return match === undefined ? null : match;
+ },
+
+ // Overrides response content-type header
+ overrideMimeType: function( type ) {
+ if ( !state ) {
+ s.mimeType = type;
+ }
+ return this;
+ },
+
+ // Cancel the request
+ abort: function( statusText ) {
+ statusText = statusText || strAbort;
+ if ( transport ) {
+ transport.abort( statusText );
+ }
+ done( 0, statusText );
+ return this;
+ }
+ };
+
+ // Callback for when everything is done
+ // It is defined here because jslint complains if it is declared
+ // at the end of the function (which would be more logical and readable)
+ function done( status, nativeStatusText, responses, headers ) {
+ var isSuccess, success, error, response, modified,
+ statusText = nativeStatusText;
+
+ // Called once
+ if ( state === 2 ) {
+ return;
+ }
+
+ // State is "done" now
+ state = 2;
+
+ // Clear timeout if it exists
+ if ( timeoutTimer ) {
+ clearTimeout( timeoutTimer );
+ }
+
+ // Dereference transport for early garbage collection
+ // (no matter how long the jqXHR object will be used)
+ transport = undefined;
+
+ // Cache response headers
+ responseHeadersString = headers || "";
+
+ // Set readyState
+ jqXHR.readyState = status > 0 ? 4 : 0;
+
+ // Get response data
+ if ( responses ) {
+ response = ajaxHandleResponses( s, jqXHR, responses );
+ }
+
+ // If successful, handle type chaining
+ if ( status >= 200 && status < 300 || status === 304 ) {
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+
+ modified = jqXHR.getResponseHeader("Last-Modified");
+ if ( modified ) {
+ jQuery.lastModified[ ifModifiedKey ] = modified;
+ }
+ modified = jqXHR.getResponseHeader("Etag");
+ if ( modified ) {
+ jQuery.etag[ ifModifiedKey ] = modified;
+ }
+ }
+
+ // If not modified
+ if ( status === 304 ) {
+
+ statusText = "notmodified";
+ isSuccess = true;
+
+ // If we have data
+ } else {
+
+ isSuccess = ajaxConvert( s, response );
+ statusText = isSuccess.state;
+ success = isSuccess.data;
+ error = isSuccess.error;
+ isSuccess = !error;
+ }
+ } else {
+ // We extract error from statusText
+ // then normalize statusText and status for non-aborts
+ error = statusText;
+ if ( !statusText || status ) {
+ statusText = "error";
+ if ( status < 0 ) {
+ status = 0;
+ }
+ }
+ }
+
+ // Set data for the fake xhr object
+ jqXHR.status = status;
+ jqXHR.statusText = ( nativeStatusText || statusText ) + "";
+
+ // Success/Error
+ if ( isSuccess ) {
+ deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
+ } else {
+ deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
+ }
+
+ // Status-dependent callbacks
+ jqXHR.statusCode( statusCode );
+ statusCode = undefined;
+
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
+ [ jqXHR, s, isSuccess ? success : error ] );
+ }
+
+ // Complete
+ completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
+
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
+ // Handle the global AJAX counter
+ if ( !( --jQuery.active ) ) {
+ jQuery.event.trigger( "ajaxStop" );
+ }
+ }
+ }
+
+ // Attach deferreds
+ deferred.promise( jqXHR );
+ jqXHR.success = jqXHR.done;
+ jqXHR.error = jqXHR.fail;
+ jqXHR.complete = completeDeferred.add;
+
+ // Status-dependent callbacks
+ jqXHR.statusCode = function( map ) {
+ if ( map ) {
+ var tmp;
+ if ( state < 2 ) {
+ for ( tmp in map ) {
+ statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
+ }
+ } else {
+ tmp = map[ jqXHR.status ];
+ jqXHR.always( tmp );
+ }
+ }
+ return this;
+ };
+
+ // Remove hash character (#7531: and string promotion)
+ // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
+ // We also use the url parameter if available
+ s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
+
+ // Extract dataTypes list
+ s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
+
+ // A cross-domain request is in order when we have a protocol:host:port mismatch
+ if ( s.crossDomain == null ) {
+ parts = rurl.exec( s.url.toLowerCase() );
+ s.crossDomain = !!( parts &&
+ ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
+ ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
+ ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
+ );
+ }
+
+ // Convert data if not already a string
+ if ( s.data && s.processData && typeof s.data !== "string" ) {
+ s.data = jQuery.param( s.data, s.traditional );
+ }
+
+ // Apply prefilters
+ inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
+
+ // If request was aborted inside a prefilter, stop there
+ if ( state === 2 ) {
+ return jqXHR;
+ }
+
+ // We can fire global events as of now if asked to
+ fireGlobals = s.global;
+
+ // Uppercase the type
+ s.type = s.type.toUpperCase();
+
+ // Determine if request has content
+ s.hasContent = !rnoContent.test( s.type );
+
+ // Watch for a new set of requests
+ if ( fireGlobals && jQuery.active++ === 0 ) {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+
+ // More options handling for requests with no content
+ if ( !s.hasContent ) {
+
+ // If data is available, append data to url
+ if ( s.data ) {
+ s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
+ // #9682: remove data so that it's not used in an eventual retry
+ delete s.data;
+ }
+
+ // Get ifModifiedKey before adding the anti-cache parameter
+ ifModifiedKey = s.url;
+
+ // Add anti-cache in url if needed
+ if ( s.cache === false ) {
+
+ var ts = jQuery.now(),
+ // try replacing _= if it is there
+ ret = s.url.replace( rts, "$1_=" + ts );
+
+ // if nothing was replaced, add timestamp to the end
+ s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
+ }
+ }
+
+ // Set the correct header, if data is being sent
+ if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
+ jqXHR.setRequestHeader( "Content-Type", s.contentType );
+ }
+
+ // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+ if ( s.ifModified ) {
+ ifModifiedKey = ifModifiedKey || s.url;
+ if ( jQuery.lastModified[ ifModifiedKey ] ) {
+ jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
+ }
+ if ( jQuery.etag[ ifModifiedKey ] ) {
+ jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
+ }
+ }
+
+ // Set the Accepts header for the server, depending on the dataType
+ jqXHR.setRequestHeader(
+ "Accept",
+ s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
+ s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
+ s.accepts[ "*" ]
+ );
+
+ // Check for headers option
+ for ( i in s.headers ) {
+ jqXHR.setRequestHeader( i, s.headers[ i ] );
+ }
+
+ // Allow custom headers/mimetypes and early abort
+ if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
+ // Abort if not done already and return
+ return jqXHR.abort();
+
+ }
+
+ // aborting is no longer a cancellation
+ strAbort = "abort";
+
+ // Install callbacks on deferreds
+ for ( i in { success: 1, error: 1, complete: 1 } ) {
+ jqXHR[ i ]( s[ i ] );
+ }
+
+ // Get transport
+ transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
+
+ // If no transport, we auto-abort
+ if ( !transport ) {
+ done( -1, "No Transport" );
+ } else {
+ jqXHR.readyState = 1;
+ // Send global event
+ if ( fireGlobals ) {
+ globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
+ }
+ // Timeout
+ if ( s.async && s.timeout > 0 ) {
+ timeoutTimer = setTimeout( function(){
+ jqXHR.abort( "timeout" );
+ }, s.timeout );
+ }
+
+ try {
+ state = 1;
+ transport.send( requestHeaders, done );
+ } catch (e) {
+ // Propagate exception as error if not done
+ if ( state < 2 ) {
+ done( -1, e );
+ // Simply rethrow otherwise
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ return jqXHR;
+ },
+
+ // Counter for holding the number of active queries
+ active: 0,
+
+ // Last-Modified header cache for next request
+ lastModified: {},
+ etag: {}
+
+});
+
+/* Handles responses to an ajax request:
+ * - sets all responseXXX fields accordingly
+ * - finds the right dataType (mediates between content-type and expected dataType)
+ * - returns the corresponding response
+ */
+function ajaxHandleResponses( s, jqXHR, responses ) {
+
+ var ct, type, finalDataType, firstDataType,
+ contents = s.contents,
+ dataTypes = s.dataTypes,
+ responseFields = s.responseFields;
+
+ // Fill responseXXX fields
+ for ( type in responseFields ) {
+ if ( type in responses ) {
+ jqXHR[ responseFields[type] ] = responses[ type ];
+ }
+ }
+
+ // Remove auto dataType and get content-type in the process
+ while( dataTypes[ 0 ] === "*" ) {
+ dataTypes.shift();
+ if ( ct === undefined ) {
+ ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
+ }
+ }
+
+ // Check if we're dealing with a known content-type
+ if ( ct ) {
+ for ( type in contents ) {
+ if ( contents[ type ] && contents[ type ].test( ct ) ) {
+ dataTypes.unshift( type );
+ break;
+ }
+ }
+ }
+
+ // Check to see if we have a response for the expected dataType
+ if ( dataTypes[ 0 ] in responses ) {
+ finalDataType = dataTypes[ 0 ];
+ } else {
+ // Try convertible dataTypes
+ for ( type in responses ) {
+ if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
+ finalDataType = type;
+ break;
+ }
+ if ( !firstDataType ) {
+ firstDataType = type;
+ }
+ }
+ // Or just use first one
+ finalDataType = finalDataType || firstDataType;
+ }
+
+ // If we found a dataType
+ // We add the dataType to the list if needed
+ // and return the corresponding response
+ if ( finalDataType ) {
+ if ( finalDataType !== dataTypes[ 0 ] ) {
+ dataTypes.unshift( finalDataType );
+ }
+ return responses[ finalDataType ];
+ }
+}
+
+// Chain conversions given the request and the original response
+function ajaxConvert( s, response ) {
+
+ var conv, conv2, current, tmp,
+ // Work with a copy of dataTypes in case we need to modify it for conversion
+ dataTypes = s.dataTypes.slice(),
+ prev = dataTypes[ 0 ],
+ converters = {},
+ i = 0;
+
+ // Apply the dataFilter if provided
+ if ( s.dataFilter ) {
+ response = s.dataFilter( response, s.dataType );
+ }
+
+ // Create converters map with lowercased keys
+ if ( dataTypes[ 1 ] ) {
+ for ( conv in s.converters ) {
+ converters[ conv.toLowerCase() ] = s.converters[ conv ];
+ }
+ }
+
+ // Convert to each sequential dataType, tolerating list modification
+ for ( ; (current = dataTypes[++i]); ) {
+
+ // There's only work to do if current dataType is non-auto
+ if ( current !== "*" ) {
+
+ // Convert response if prev dataType is non-auto and differs from current
+ if ( prev !== "*" && prev !== current ) {
+
+ // Seek a direct converter
+ conv = converters[ prev + " " + current ] || converters[ "* " + current ];
+
+ // If none found, seek a pair
+ if ( !conv ) {
+ for ( conv2 in converters ) {
+
+ // If conv2 outputs current
+ tmp = conv2.split(" ");
+ if ( tmp[ 1 ] === current ) {
+
+ // If prev can be converted to accepted input
+ conv = converters[ prev + " " + tmp[ 0 ] ] ||
+ converters[ "* " + tmp[ 0 ] ];
+ if ( conv ) {
+ // Condense equivalence converters
+ if ( conv === true ) {
+ conv = converters[ conv2 ];
+
+ // Otherwise, insert the intermediate dataType
+ } else if ( converters[ conv2 ] !== true ) {
+ current = tmp[ 0 ];
+ dataTypes.splice( i--, 0, current );
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ // Apply converter (if not an equivalence)
+ if ( conv !== true ) {
+
+ // Unless errors are allowed to bubble, catch and return them
+ if ( conv && s["throws"] ) {
+ response = conv( response );
+ } else {
+ try {
+ response = conv( response );
+ } catch ( e ) {
+ return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
+ }
+ }
+ }
+ }
+
+ // Update prev for next iteration
+ prev = current;
+ }
+ }
+
+ return { state: "success", data: response };
+}
+var oldCallbacks = [],
+ rquestion = /\?/,
+ rjsonp = /(=)\?(?=&|$)|\?\?/,
+ nonce = jQuery.now();
+
+// Default jsonp settings
+jQuery.ajaxSetup({
+ jsonp: "callback",
+ jsonpCallback: function() {
+ var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
+ this[ callback ] = true;
+ return callback;
+ }
+});
+
+// Detect, normalize options and install callbacks for jsonp requests
+jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
+
+ var callbackName, overwritten, responseContainer,
+ data = s.data,
+ url = s.url,
+ hasCallback = s.jsonp !== false,
+ replaceInUrl = hasCallback && rjsonp.test( url ),
+ replaceInData = hasCallback && !replaceInUrl && typeof data === "string" &&
+ !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") &&
+ rjsonp.test( data );
+
+ // Handle iff the expected data type is "jsonp" or we have a parameter to set
+ if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) {
+
+ // Get callback name, remembering preexisting value associated with it
+ callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
+ s.jsonpCallback() :
+ s.jsonpCallback;
+ overwritten = window[ callbackName ];
+
+ // Insert callback into url or form data
+ if ( replaceInUrl ) {
+ s.url = url.replace( rjsonp, "$1" + callbackName );
+ } else if ( replaceInData ) {
+ s.data = data.replace( rjsonp, "$1" + callbackName );
+ } else if ( hasCallback ) {
+ s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
+ }
+
+ // Use data converter to retrieve json after script execution
+ s.converters["script json"] = function() {
+ if ( !responseContainer ) {
+ jQuery.error( callbackName + " was not called" );
+ }
+ return responseContainer[ 0 ];
+ };
+
+ // force json dataType
+ s.dataTypes[ 0 ] = "json";
+
+ // Install callback
+ window[ callbackName ] = function() {
+ responseContainer = arguments;
+ };
+
+ // Clean-up function (fires after converters)
+ jqXHR.always(function() {
+ // Restore preexisting value
+ window[ callbackName ] = overwritten;
+
+ // Save back as free
+ if ( s[ callbackName ] ) {
+ // make sure that re-using the options doesn't screw things around
+ s.jsonpCallback = originalSettings.jsonpCallback;
+
+ // save the callback name for future use
+ oldCallbacks.push( callbackName );
+ }
+
+ // Call if it was a function and we have a response
+ if ( responseContainer && jQuery.isFunction( overwritten ) ) {
+ overwritten( responseContainer[ 0 ] );
+ }
+
+ responseContainer = overwritten = undefined;
+ });
+
+ // Delegate to script
+ return "script";
+ }
+});
+// Install script dataType
+jQuery.ajaxSetup({
+ accepts: {
+ script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
+ },
+ contents: {
+ script: /javascript|ecmascript/
+ },
+ converters: {
+ "text script": function( text ) {
+ jQuery.globalEval( text );
+ return text;
+ }
+ }
+});
+
+// Handle cache's special case and global
+jQuery.ajaxPrefilter( "script", function( s ) {
+ if ( s.cache === undefined ) {
+ s.cache = false;
+ }
+ if ( s.crossDomain ) {
+ s.type = "GET";
+ s.global = false;
+ }
+});
+
+// Bind script tag hack transport
+jQuery.ajaxTransport( "script", function(s) {
+
+ // This transport only deals with cross domain requests
+ if ( s.crossDomain ) {
+
+ var script,
+ head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
+
+ return {
+
+ send: function( _, callback ) {
+
+ script = document.createElement( "script" );
+
+ script.async = "async";
+
+ if ( s.scriptCharset ) {
+ script.charset = s.scriptCharset;
+ }
+
+ script.src = s.url;
+
+ // Attach handlers for all browsers
+ script.onload = script.onreadystatechange = function( _, isAbort ) {
+
+ if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+
+ // Remove the script
+ if ( head && script.parentNode ) {
+ head.removeChild( script );
+ }
+
+ // Dereference the script
+ script = undefined;
+
+ // Callback if not abort
+ if ( !isAbort ) {
+ callback( 200, "success" );
+ }
+ }
+ };
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709 and #4378).
+ head.insertBefore( script, head.firstChild );
+ },
+
+ abort: function() {
+ if ( script ) {
+ script.onload( 0, 1 );
+ }
+ }
+ };
+ }
+});
+var xhrCallbacks,
+ // #5280: Internet Explorer will keep connections alive if we don't abort on unload
+ xhrOnUnloadAbort = window.ActiveXObject ? function() {
+ // Abort all pending requests
+ for ( var key in xhrCallbacks ) {
+ xhrCallbacks[ key ]( 0, 1 );
+ }
+ } : false,
+ xhrId = 0;
+
+// Functions to create xhrs
+function createStandardXHR() {
+ try {
+ return new window.XMLHttpRequest();
+ } catch( e ) {}
+}
+
+function createActiveXHR() {
+ try {
+ return new window.ActiveXObject( "Microsoft.XMLHTTP" );
+ } catch( e ) {}
+}
+
+// Create the request object
+// (This is still attached to ajaxSettings for backward compatibility)
+jQuery.ajaxSettings.xhr = window.ActiveXObject ?
+ /* Microsoft failed to properly
+ * implement the XMLHttpRequest in IE7 (can't request local files),
+ * so we use the ActiveXObject when it is available
+ * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
+ * we need a fallback.
+ */
+ function() {
+ return !this.isLocal && createStandardXHR() || createActiveXHR();
+ } :
+ // For all other browsers, use the standard XMLHttpRequest object
+ createStandardXHR;
+
+// Determine support properties
+(function( xhr ) {
+ jQuery.extend( jQuery.support, {
+ ajax: !!xhr,
+ cors: !!xhr && ( "withCredentials" in xhr )
+ });
+})( jQuery.ajaxSettings.xhr() );
+
+// Create transport if the browser can provide an xhr
+if ( jQuery.support.ajax ) {
+
+ jQuery.ajaxTransport(function( s ) {
+ // Cross domain only allowed if supported through XMLHttpRequest
+ if ( !s.crossDomain || jQuery.support.cors ) {
+
+ var callback;
+
+ return {
+ send: function( headers, complete ) {
+
+ // Get a new xhr
+ var handle, i,
+ xhr = s.xhr();
+
+ // Open the socket
+ // Passing null username, generates a login popup on Opera (#2865)
+ if ( s.username ) {
+ xhr.open( s.type, s.url, s.async, s.username, s.password );
+ } else {
+ xhr.open( s.type, s.url, s.async );
+ }
+
+ // Apply custom fields if provided
+ if ( s.xhrFields ) {
+ for ( i in s.xhrFields ) {
+ xhr[ i ] = s.xhrFields[ i ];
+ }
+ }
+
+ // Override mime type if needed
+ if ( s.mimeType && xhr.overrideMimeType ) {
+ xhr.overrideMimeType( s.mimeType );
+ }
+
+ // X-Requested-With header
+ // For cross-domain requests, seeing as conditions for a preflight are
+ // akin to a jigsaw puzzle, we simply never set it to be sure.
+ // (it can always be set on a per-request basis or even using ajaxSetup)
+ // For same-domain requests, won't change header if already provided.
+ if ( !s.crossDomain && !headers["X-Requested-With"] ) {
+ headers[ "X-Requested-With" ] = "XMLHttpRequest";
+ }
+
+ // Need an extra try/catch for cross domain requests in Firefox 3
+ try {
+ for ( i in headers ) {
+ xhr.setRequestHeader( i, headers[ i ] );
+ }
+ } catch( _ ) {}
+
+ // Do send the request
+ // This may raise an exception which is actually
+ // handled in jQuery.ajax (so no try/catch here)
+ xhr.send( ( s.hasContent && s.data ) || null );
+
+ // Listener
+ callback = function( _, isAbort ) {
+
+ var status,
+ statusText,
+ responseHeaders,
+ responses,
+ xml;
+
+ // Firefox throws exceptions when accessing properties
+ // of an xhr when a network error occurred
+ // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
+ try {
+
+ // Was never called and is aborted or complete
+ if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
+
+ // Only called once
+ callback = undefined;
+
+ // Do not keep as active anymore
+ if ( handle ) {
+ xhr.onreadystatechange = jQuery.noop;
+ if ( xhrOnUnloadAbort ) {
+ delete xhrCallbacks[ handle ];
+ }
+ }
+
+ // If it's an abort
+ if ( isAbort ) {
+ // Abort it manually if needed
+ if ( xhr.readyState !== 4 ) {
+ xhr.abort();
+ }
+ } else {
+ status = xhr.status;
+ responseHeaders = xhr.getAllResponseHeaders();
+ responses = {};
+ xml = xhr.responseXML;
+
+ // Construct response list
+ if ( xml && xml.documentElement /* #4958 */ ) {
+ responses.xml = xml;
+ }
+
+ // When requesting binary data, IE6-9 will throw an exception
+ // on any attempt to access responseText (#11426)
+ try {
+ responses.text = xhr.responseText;
+ } catch( e ) {
+ }
+
+ // Firefox throws an exception when accessing
+ // statusText for faulty cross-domain requests
+ try {
+ statusText = xhr.statusText;
+ } catch( e ) {
+ // We normalize with Webkit giving an empty statusText
+ statusText = "";
+ }
+
+ // Filter status for non standard behaviors
+
+ // If the request is local and we have data: assume a success
+ // (success with no data won't get notified, that's the best we
+ // can do given current implementations)
+ if ( !status && s.isLocal && !s.crossDomain ) {
+ status = responses.text ? 200 : 404;
+ // IE - #1450: sometimes returns 1223 when it should be 204
+ } else if ( status === 1223 ) {
+ status = 204;
+ }
+ }
+ }
+ } catch( firefoxAccessException ) {
+ if ( !isAbort ) {
+ complete( -1, firefoxAccessException );
+ }
+ }
+
+ // Call complete if needed
+ if ( responses ) {
+ complete( status, statusText, responses, responseHeaders );
+ }
+ };
+
+ if ( !s.async ) {
+ // if we're in sync mode we fire the callback
+ callback();
+ } else if ( xhr.readyState === 4 ) {
+ // (IE6 & IE7) if it's in cache and has been
+ // retrieved directly we need to fire the callback
+ setTimeout( callback, 0 );
+ } else {
+ handle = ++xhrId;
+ if ( xhrOnUnloadAbort ) {
+ // Create the active xhrs callbacks list if needed
+ // and attach the unload handler
+ if ( !xhrCallbacks ) {
+ xhrCallbacks = {};
+ jQuery( window ).unload( xhrOnUnloadAbort );
+ }
+ // Add to list of active xhrs callbacks
+ xhrCallbacks[ handle ] = callback;
+ }
+ xhr.onreadystatechange = callback;
+ }
+ },
+
+ abort: function() {
+ if ( callback ) {
+ callback(0,1);
+ }
+ }
+ };
+ }
+ });
+}
+var fxNow, timerId,
+ rfxtypes = /^(?:toggle|show|hide)$/,
+ rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
+ rrun = /queueHooks$/,
+ animationPrefilters = [ defaultPrefilter ],
+ tweeners = {
+ "*": [function( prop, value ) {
+ var end, unit,
+ tween = this.createTween( prop, value ),
+ parts = rfxnum.exec( value ),
+ target = tween.cur(),
+ start = +target || 0,
+ scale = 1,
+ maxIterations = 20;
+
+ if ( parts ) {
+ end = +parts[2];
+ unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+
+ // We need to compute starting value
+ if ( unit !== "px" && start ) {
+ // Iteratively approximate from a nonzero starting point
+ // Prefer the current property, because this process will be trivial if it uses the same units
+ // Fallback to end or a simple constant
+ start = jQuery.css( tween.elem, prop, true ) || end || 1;
+
+ do {
+ // If previous iteration zeroed out, double until we get *something*
+ // Use a string for doubling factor so we don't accidentally see scale as unchanged below
+ scale = scale || ".5";
+
+ // Adjust and apply
+ start = start / scale;
+ jQuery.style( tween.elem, prop, start + unit );
+
+ // Update scale, tolerating zero or NaN from tween.cur()
+ // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
+ } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
+ }
+
+ tween.unit = unit;
+ tween.start = start;
+ // If a +=/-= token was provided, we're doing a relative animation
+ tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
+ }
+ return tween;
+ }]
+ };
+
+// Animations created synchronously will run synchronously
+function createFxNow() {
+ setTimeout(function() {
+ fxNow = undefined;
+ }, 0 );
+ return ( fxNow = jQuery.now() );
+}
+
+function createTweens( animation, props ) {
+ jQuery.each( props, function( prop, value ) {
+ var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
+ index = 0,
+ length = collection.length;
+ for ( ; index < length; index++ ) {
+ if ( collection[ index ].call( animation, prop, value ) ) {
+
+ // we're done with this property
+ return;
+ }
+ }
+ });
+}
+
+function Animation( elem, properties, options ) {
+ var result,
+ index = 0,
+ tweenerIndex = 0,
+ length = animationPrefilters.length,
+ deferred = jQuery.Deferred().always( function() {
+ // don't match elem in the :animated selector
+ delete tick.elem;
+ }),
+ tick = function() {
+ var currentTime = fxNow || createFxNow(),
+ remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
+ // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
+ temp = remaining / animation.duration || 0,
+ percent = 1 - temp,
+ index = 0,
+ length = animation.tweens.length;
+
+ for ( ; index < length ; index++ ) {
+ animation.tweens[ index ].run( percent );
+ }
+
+ deferred.notifyWith( elem, [ animation, percent, remaining ]);
+
+ if ( percent < 1 && length ) {
+ return remaining;
+ } else {
+ deferred.resolveWith( elem, [ animation ] );
+ return false;
+ }
+ },
+ animation = deferred.promise({
+ elem: elem,
+ props: jQuery.extend( {}, properties ),
+ opts: jQuery.extend( true, { specialEasing: {} }, options ),
+ originalProperties: properties,
+ originalOptions: options,
+ startTime: fxNow || createFxNow(),
+ duration: options.duration,
+ tweens: [],
+ createTween: function( prop, end, easing ) {
+ var tween = jQuery.Tween( elem, animation.opts, prop, end,
+ animation.opts.specialEasing[ prop ] || animation.opts.easing );
+ animation.tweens.push( tween );
+ return tween;
+ },
+ stop: function( gotoEnd ) {
+ var index = 0,
+ // if we are going to the end, we want to run all the tweens
+ // otherwise we skip this part
+ length = gotoEnd ? animation.tweens.length : 0;
+
+ for ( ; index < length ; index++ ) {
+ animation.tweens[ index ].run( 1 );
+ }
+
+ // resolve when we played the last frame
+ // otherwise, reject
+ if ( gotoEnd ) {
+ deferred.resolveWith( elem, [ animation, gotoEnd ] );
+ } else {
+ deferred.rejectWith( elem, [ animation, gotoEnd ] );
+ }
+ return this;
+ }
+ }),
+ props = animation.props;
+
+ propFilter( props, animation.opts.specialEasing );
+
+ for ( ; index < length ; index++ ) {
+ result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
+ if ( result ) {
+ return result;
+ }
+ }
+
+ createTweens( animation, props );
+
+ if ( jQuery.isFunction( animation.opts.start ) ) {
+ animation.opts.start.call( elem, animation );
+ }
+
+ jQuery.fx.timer(
+ jQuery.extend( tick, {
+ anim: animation,
+ queue: animation.opts.queue,
+ elem: elem
+ })
+ );
+
+ // attach callbacks from options
+ return animation.progress( animation.opts.progress )
+ .done( animation.opts.done, animation.opts.complete )
+ .fail( animation.opts.fail )
+ .always( animation.opts.always );
+}
+
+function propFilter( props, specialEasing ) {
+ var index, name, easing, value, hooks;
+
+ // camelCase, specialEasing and expand cssHook pass
+ for ( index in props ) {
+ name = jQuery.camelCase( index );
+ easing = specialEasing[ name ];
+ value = props[ index ];
+ if ( jQuery.isArray( value ) ) {
+ easing = value[ 1 ];
+ value = props[ index ] = value[ 0 ];
+ }
+
+ if ( index !== name ) {
+ props[ name ] = value;
+ delete props[ index ];
+ }
+
+ hooks = jQuery.cssHooks[ name ];
+ if ( hooks && "expand" in hooks ) {
+ value = hooks.expand( value );
+ delete props[ name ];
+
+ // not quite $.extend, this wont overwrite keys already present.
+ // also - reusing 'index' from above because we have the correct "name"
+ for ( index in value ) {
+ if ( !( index in props ) ) {
+ props[ index ] = value[ index ];
+ specialEasing[ index ] = easing;
+ }
+ }
+ } else {
+ specialEasing[ name ] = easing;
+ }
+ }
+}
+
+jQuery.Animation = jQuery.extend( Animation, {
+
+ tweener: function( props, callback ) {
+ if ( jQuery.isFunction( props ) ) {
+ callback = props;
+ props = [ "*" ];
+ } else {
+ props = props.split(" ");
+ }
+
+ var prop,
+ index = 0,
+ length = props.length;
+
+ for ( ; index < length ; index++ ) {
+ prop = props[ index ];
+ tweeners[ prop ] = tweeners[ prop ] || [];
+ tweeners[ prop ].unshift( callback );
+ }
+ },
+
+ prefilter: function( callback, prepend ) {
+ if ( prepend ) {
+ animationPrefilters.unshift( callback );
+ } else {
+ animationPrefilters.push( callback );
+ }
+ }
+});
+
+function defaultPrefilter( elem, props, opts ) {
+ var index, prop, value, length, dataShow, toggle, tween, hooks, oldfire,
+ anim = this,
+ style = elem.style,
+ orig = {},
+ handled = [],
+ hidden = elem.nodeType && isHidden( elem );
+
+ // handle queue: false promises
+ if ( !opts.queue ) {
+ hooks = jQuery._queueHooks( elem, "fx" );
+ if ( hooks.unqueued == null ) {
+ hooks.unqueued = 0;
+ oldfire = hooks.empty.fire;
+ hooks.empty.fire = function() {
+ if ( !hooks.unqueued ) {
+ oldfire();
+ }
+ };
+ }
+ hooks.unqueued++;
+
+ anim.always(function() {
+ // doing this makes sure that the complete handler will be called
+ // before this completes
+ anim.always(function() {
+ hooks.unqueued--;
+ if ( !jQuery.queue( elem, "fx" ).length ) {
+ hooks.empty.fire();
+ }
+ });
+ });
+ }
+
+ // height/width overflow pass
+ if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
+ // Make sure that nothing sneaks out
+ // Record all 3 overflow attributes because IE does not
+ // change the overflow attribute when overflowX and
+ // overflowY are set to the same value
+ opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
+
+ // Set display property to inline-block for height/width
+ // animations on inline elements that are having width/height animated
+ if ( jQuery.css( elem, "display" ) === "inline" &&
+ jQuery.css( elem, "float" ) === "none" ) {
+
+ // inline-level elements accept inline-block;
+ // block-level elements need to be inline with layout
+ if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
+ style.display = "inline-block";
+
+ } else {
+ style.zoom = 1;
+ }
+ }
+ }
+
+ if ( opts.overflow ) {
+ style.overflow = "hidden";
+ if ( !jQuery.support.shrinkWrapBlocks ) {
+ anim.done(function() {
+ style.overflow = opts.overflow[ 0 ];
+ style.overflowX = opts.overflow[ 1 ];
+ style.overflowY = opts.overflow[ 2 ];
+ });
+ }
+ }
+
+
+ // show/hide pass
+ for ( index in props ) {
+ value = props[ index ];
+ if ( rfxtypes.exec( value ) ) {
+ delete props[ index ];
+ toggle = toggle || value === "toggle";
+ if ( value === ( hidden ? "hide" : "show" ) ) {
+ continue;
+ }
+ handled.push( index );
+ }
+ }
+
+ length = handled.length;
+ if ( length ) {
+ dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
+ if ( "hidden" in dataShow ) {
+ hidden = dataShow.hidden;
+ }
+
+ // store state if its toggle - enables .stop().toggle() to "reverse"
+ if ( toggle ) {
+ dataShow.hidden = !hidden;
+ }
+ if ( hidden ) {
+ jQuery( elem ).show();
+ } else {
+ anim.done(function() {
+ jQuery( elem ).hide();
+ });
+ }
+ anim.done(function() {
+ var prop;
+ jQuery.removeData( elem, "fxshow", true );
+ for ( prop in orig ) {
+ jQuery.style( elem, prop, orig[ prop ] );
+ }
+ });
+ for ( index = 0 ; index < length ; index++ ) {
+ prop = handled[ index ];
+ tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
+ orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
+
+ if ( !( prop in dataShow ) ) {
+ dataShow[ prop ] = tween.start;
+ if ( hidden ) {
+ tween.end = tween.start;
+ tween.start = prop === "width" || prop === "height" ? 1 : 0;
+ }
+ }
+ }
+ }
+}
+
+function Tween( elem, options, prop, end, easing ) {
+ return new Tween.prototype.init( elem, options, prop, end, easing );
+}
+jQuery.Tween = Tween;
+
+Tween.prototype = {
+ constructor: Tween,
+ init: function( elem, options, prop, end, easing, unit ) {
+ this.elem = elem;
+ this.prop = prop;
+ this.easing = easing || "swing";
+ this.options = options;
+ this.start = this.now = this.cur();
+ this.end = end;
+ this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+ },
+ cur: function() {
+ var hooks = Tween.propHooks[ this.prop ];
+
+ return hooks && hooks.get ?
+ hooks.get( this ) :
+ Tween.propHooks._default.get( this );
+ },
+ run: function( percent ) {
+ var eased,
+ hooks = Tween.propHooks[ this.prop ];
+
+ if ( this.options.duration ) {
+ this.pos = eased = jQuery.easing[ this.easing ](
+ percent, this.options.duration * percent, 0, 1, this.options.duration
+ );
+ } else {
+ this.pos = eased = percent;
+ }
+ this.now = ( this.end - this.start ) * eased + this.start;
+
+ if ( this.options.step ) {
+ this.options.step.call( this.elem, this.now, this );
+ }
+
+ if ( hooks && hooks.set ) {
+ hooks.set( this );
+ } else {
+ Tween.propHooks._default.set( this );
+ }
+ return this;
+ }
+};
+
+Tween.prototype.init.prototype = Tween.prototype;
+
+Tween.propHooks = {
+ _default: {
+ get: function( tween ) {
+ var result;
+
+ if ( tween.elem[ tween.prop ] != null &&
+ (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
+ return tween.elem[ tween.prop ];
+ }
+
+ // passing any value as a 4th parameter to .css will automatically
+ // attempt a parseFloat and fallback to a string if the parse fails
+ // so, simple values such as "10px" are parsed to Float.
+ // complex values such as "rotate(1rad)" are returned as is.
+ result = jQuery.css( tween.elem, tween.prop, false, "" );
+ // Empty strings, null, undefined and "auto" are converted to 0.
+ return !result || result === "auto" ? 0 : result;
+ },
+ set: function( tween ) {
+ // use step hook for back compat - use cssHook if its there - use .style if its
+ // available and use plain properties where available
+ if ( jQuery.fx.step[ tween.prop ] ) {
+ jQuery.fx.step[ tween.prop ]( tween );
+ } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
+ jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
+ } else {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+ }
+};
+
+// Remove in 2.0 - this supports IE8's panic based approach
+// to setting things on disconnected nodes
+
+Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
+ set: function( tween ) {
+ if ( tween.elem.nodeType && tween.elem.parentNode ) {
+ tween.elem[ tween.prop ] = tween.now;
+ }
+ }
+};
+
+jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
+ var cssFn = jQuery.fn[ name ];
+ jQuery.fn[ name ] = function( speed, easing, callback ) {
+ return speed == null || typeof speed === "boolean" ||
+ // special check for .toggle( handler, handler, ... )
+ ( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ?
+ cssFn.apply( this, arguments ) :
+ this.animate( genFx( name, true ), speed, easing, callback );
+ };
+});
+
+jQuery.fn.extend({
+ fadeTo: function( speed, to, easing, callback ) {
+
+ // show any hidden elements after setting opacity to 0
+ return this.filter( isHidden ).css( "opacity", 0 ).show()
+
+ // animate to the value specified
+ .end().animate({ opacity: to }, speed, easing, callback );
+ },
+ animate: function( prop, speed, easing, callback ) {
+ var empty = jQuery.isEmptyObject( prop ),
+ optall = jQuery.speed( speed, easing, callback ),
+ doAnimation = function() {
+ // Operate on a copy of prop so per-property easing won't be lost
+ var anim = Animation( this, jQuery.extend( {}, prop ), optall );
+
+ // Empty animations resolve immediately
+ if ( empty ) {
+ anim.stop( true );
+ }
+ };
+
+ return empty || optall.queue === false ?
+ this.each( doAnimation ) :
+ this.queue( optall.queue, doAnimation );
+ },
+ stop: function( type, clearQueue, gotoEnd ) {
+ var stopQueue = function( hooks ) {
+ var stop = hooks.stop;
+ delete hooks.stop;
+ stop( gotoEnd );
+ };
+
+ if ( typeof type !== "string" ) {
+ gotoEnd = clearQueue;
+ clearQueue = type;
+ type = undefined;
+ }
+ if ( clearQueue && type !== false ) {
+ this.queue( type || "fx", [] );
+ }
+
+ return this.each(function() {
+ var dequeue = true,
+ index = type != null && type + "queueHooks",
+ timers = jQuery.timers,
+ data = jQuery._data( this );
+
+ if ( index ) {
+ if ( data[ index ] && data[ index ].stop ) {
+ stopQueue( data[ index ] );
+ }
+ } else {
+ for ( index in data ) {
+ if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
+ stopQueue( data[ index ] );
+ }
+ }
+ }
+
+ for ( index = timers.length; index--; ) {
+ if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
+ timers[ index ].anim.stop( gotoEnd );
+ dequeue = false;
+ timers.splice( index, 1 );
+ }
+ }
+
+ // start the next in the queue if the last step wasn't forced
+ // timers currently will call their complete callbacks, which will dequeue
+ // but only if they were gotoEnd
+ if ( dequeue || !gotoEnd ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ }
+});
+
+// Generate parameters to create a standard animation
+function genFx( type, includeWidth ) {
+ var which,
+ attrs = { height: type },
+ i = 0;
+
+ // if we include width, step value is 1 to do all cssExpand values,
+ // if we don't include width, step value is 2 to skip over Left and Right
+ includeWidth = includeWidth? 1 : 0;
+ for( ; i < 4 ; i += 2 - includeWidth ) {
+ which = cssExpand[ i ];
+ attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
+ }
+
+ if ( includeWidth ) {
+ attrs.opacity = attrs.width = type;
+ }
+
+ return attrs;
+}
+
+// Generate shortcuts for custom animations
+jQuery.each({
+ slideDown: genFx("show"),
+ slideUp: genFx("hide"),
+ slideToggle: genFx("toggle"),
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" },
+ fadeToggle: { opacity: "toggle" }
+}, function( name, props ) {
+ jQuery.fn[ name ] = function( speed, easing, callback ) {
+ return this.animate( props, speed, easing, callback );
+ };
+});
+
+jQuery.speed = function( speed, easing, fn ) {
+ var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
+ complete: fn || !fn && easing ||
+ jQuery.isFunction( speed ) && speed,
+ duration: speed,
+ easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
+ };
+
+ opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+ opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
+
+ // normalize opt.queue - true/undefined/null -> "fx"
+ if ( opt.queue == null || opt.queue === true ) {
+ opt.queue = "fx";
+ }
+
+ // Queueing
+ opt.old = opt.complete;
+
+ opt.complete = function() {
+ if ( jQuery.isFunction( opt.old ) ) {
+ opt.old.call( this );
+ }
+
+ if ( opt.queue ) {
+ jQuery.dequeue( this, opt.queue );
+ }
+ };
+
+ return opt;
+};
+
+jQuery.easing = {
+ linear: function( p ) {
+ return p;
+ },
+ swing: function( p ) {
+ return 0.5 - Math.cos( p*Math.PI ) / 2;
+ }
+};
+
+jQuery.timers = [];
+jQuery.fx = Tween.prototype.init;
+jQuery.fx.tick = function() {
+ var timer,
+ timers = jQuery.timers,
+ i = 0;
+
+ fxNow = jQuery.now();
+
+ for ( ; i < timers.length; i++ ) {
+ timer = timers[ i ];
+ // Checks the timer has not already been removed
+ if ( !timer() && timers[ i ] === timer ) {
+ timers.splice( i--, 1 );
+ }
+ }
+
+ if ( !timers.length ) {
+ jQuery.fx.stop();
+ }
+ fxNow = undefined;
+};
+
+jQuery.fx.timer = function( timer ) {
+ if ( timer() && jQuery.timers.push( timer ) && !timerId ) {
+ timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
+ }
+};
+
+jQuery.fx.interval = 13;
+
+jQuery.fx.stop = function() {
+ clearInterval( timerId );
+ timerId = null;
+};
+
+jQuery.fx.speeds = {
+ slow: 600,
+ fast: 200,
+ // Default speed
+ _default: 400
+};
+
+// Back Compat <1.8 extension point
+jQuery.fx.step = {};
+
+if ( jQuery.expr && jQuery.expr.filters ) {
+ jQuery.expr.filters.animated = function( elem ) {
+ return jQuery.grep(jQuery.timers, function( fn ) {
+ return elem === fn.elem;
+ }).length;
+ };
+}
+var rroot = /^(?:body|html)$/i;
+
+jQuery.fn.offset = function( options ) {
+ if ( arguments.length ) {
+ return options === undefined ?
+ this :
+ this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft,
+ box = { top: 0, left: 0 },
+ elem = this[ 0 ],
+ doc = elem && elem.ownerDocument;
+
+ if ( !doc ) {
+ return;
+ }
+
+ if ( (body = doc.body) === elem ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ docElem = doc.documentElement;
+
+ // Make sure it's not a disconnected DOM node
+ if ( !jQuery.contains( docElem, elem ) ) {
+ return box;
+ }
+
+ // If we don't have gBCR, just use 0,0 rather than error
+ // BlackBerry 5, iOS 3 (original iPhone)
+ if ( typeof elem.getBoundingClientRect !== "undefined" ) {
+ box = elem.getBoundingClientRect();
+ }
+ win = getWindow( doc );
+ clientTop = docElem.clientTop || body.clientTop || 0;
+ clientLeft = docElem.clientLeft || body.clientLeft || 0;
+ scrollTop = win.pageYOffset || docElem.scrollTop;
+ scrollLeft = win.pageXOffset || docElem.scrollLeft;
+ return {
+ top: box.top + scrollTop - clientTop,
+ left: box.left + scrollLeft - clientLeft
+ };
+};
+
+jQuery.offset = {
+
+ bodyOffset: function( body ) {
+ var top = body.offsetTop,
+ left = body.offsetLeft;
+
+ if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
+ top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
+ left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
+ }
+
+ return { top: top, left: left };
+ },
+
+ setOffset: function( elem, options, i ) {
+ var position = jQuery.css( elem, "position" );
+
+ // set position first, in-case top/left are set even on static elem
+ if ( position === "static" ) {
+ elem.style.position = "relative";
+ }
+
+ var curElem = jQuery( elem ),
+ curOffset = curElem.offset(),
+ curCSSTop = jQuery.css( elem, "top" ),
+ curCSSLeft = jQuery.css( elem, "left" ),
+ calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
+ props = {}, curPosition = {}, curTop, curLeft;
+
+ // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
+ if ( calculatePosition ) {
+ curPosition = curElem.position();
+ curTop = curPosition.top;
+ curLeft = curPosition.left;
+ } else {
+ curTop = parseFloat( curCSSTop ) || 0;
+ curLeft = parseFloat( curCSSLeft ) || 0;
+ }
+
+ if ( jQuery.isFunction( options ) ) {
+ options = options.call( elem, i, curOffset );
+ }
+
+ if ( options.top != null ) {
+ props.top = ( options.top - curOffset.top ) + curTop;
+ }
+ if ( options.left != null ) {
+ props.left = ( options.left - curOffset.left ) + curLeft;
+ }
+
+ if ( "using" in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ }
+};
+
+
+jQuery.fn.extend({
+
+ position: function() {
+ if ( !this[0] ) {
+ return;
+ }
+
+ var elem = this[0],
+
+ // Get *real* offsetParent
+ offsetParent = this.offsetParent(),
+
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
+
+ // Subtract element margins
+ // note: when an element has margin: auto the offsetLeft and marginLeft
+ // are the same in Safari causing offset.left to incorrectly be 0
+ offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
+ offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
+
+ // Add offsetParent borders
+ parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
+ parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
+
+ // Subtract the two offsets
+ return {
+ top: offset.top - parentOffset.top,
+ left: offset.left - parentOffset.left
+ };
+ },
+
+ offsetParent: function() {
+ return this.map(function() {
+ var offsetParent = this.offsetParent || document.body;
+ while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
+ offsetParent = offsetParent.offsetParent;
+ }
+ return offsetParent || document.body;
+ });
+ }
+});
+
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
+ var top = /Y/.test( prop );
+
+ jQuery.fn[ method ] = function( val ) {
+ return jQuery.access( this, function( elem, method, val ) {
+ var win = getWindow( elem );
+
+ if ( val === undefined ) {
+ return win ? (prop in win) ? win[ prop ] :
+ win.document.documentElement[ method ] :
+ elem[ method ];
+ }
+
+ if ( win ) {
+ win.scrollTo(
+ !top ? val : jQuery( win ).scrollLeft(),
+ top ? val : jQuery( win ).scrollTop()
+ );
+
+ } else {
+ elem[ method ] = val;
+ }
+ }, method, val, arguments.length, null );
+ };
+});
+
+function getWindow( elem ) {
+ return jQuery.isWindow( elem ) ?
+ elem :
+ elem.nodeType === 9 ?
+ elem.defaultView || elem.parentWindow :
+ false;
+}
+// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
+jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
+ jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
+ // margin is only for outerHeight, outerWidth
+ jQuery.fn[ funcName ] = function( margin, value ) {
+ var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
+ extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
+
+ return jQuery.access( this, function( elem, type, value ) {
+ var doc;
+
+ if ( jQuery.isWindow( elem ) ) {
+ // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
+ // isn't a whole lot we can do. See pull request at this URL for discussion:
+ // https://github.com/jquery/jquery/pull/764
+ return elem.document.documentElement[ "client" + name ];
+ }
+
+ // Get document width or height
+ if ( elem.nodeType === 9 ) {
+ doc = elem.documentElement;
+
+ // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
+ // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
+ return Math.max(
+ elem.body[ "scroll" + name ], doc[ "scroll" + name ],
+ elem.body[ "offset" + name ], doc[ "offset" + name ],
+ doc[ "client" + name ]
+ );
+ }
+
+ return value === undefined ?
+ // Get width or height on the element, requesting but not forcing parseFloat
+ jQuery.css( elem, type, value, extra ) :
+
+ // Set width or height on the element
+ jQuery.style( elem, type, value, extra );
+ }, type, chainable ? margin : undefined, chainable, null );
+ };
+ });
+});
+// Expose jQuery to the global object
+window.jQuery = window.$ = jQuery;
+
+// Expose jQuery as an AMD module, but only for AMD loaders that
+// understand the issues with loading multiple versions of jQuery
+// in a page that all might call define(). The loader will indicate
+// they have special allowances for multiple jQuery versions by
+// specifying define.amd.jQuery = true. Register as a named module,
+// since jQuery can be concatenated with other files that may use define,
+// but not use a proper concatenation script that understands anonymous
+// AMD modules. A named AMD is safest and most robust way to register.
+// Lowercase jquery is used because AMD module names are derived from
+// file names, and jQuery is normally delivered in a lowercase file name.
+// Do this after creating the global so that if an AMD module wants to call
+// noConflict to hide this version of jQuery, it will work.
+if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
+ define( "jquery", [], function () { return jQuery; } );
+}
+
+})( window );
diff --git a/src/web/js/jquery/jquery-1.8.3.min.js b/src/web/js/jquery/jquery-1.8.3.min.js
new file mode 100644
index 0000000..83589da
--- /dev/null
+++ b/src/web/js/jquery/jquery-1.8.3.min.js
@@ -0,0 +1,2 @@
+/*! jQuery v1.8.3 jquery.com | jquery.org/license */
+(function(e,t){function _(e){var t=M[e]={};return v.each(e.split(y),function(e,n){t[n]=!0}),t}function H(e,n,r){if(r===t&&e.nodeType===1){var i="data-"+n.replace(P,"-$1").toLowerCase();r=e.getAttribute(i);if(typeof r=="string"){try{r=r==="true"?!0:r==="false"?!1:r==="null"?null:+r+""===r?+r:D.test(r)?v.parseJSON(r):r}catch(s){}v.data(e,n,r)}else r=t}return r}function B(e){var t;for(t in e){if(t==="data"&&v.isEmptyObject(e[t]))continue;if(t!=="toJSON")return!1}return!0}function et(){return!1}function tt(){return!0}function ut(e){return!e||!e.parentNode||e.parentNode.nodeType===11}function at(e,t){do e=e[t];while(e&&e.nodeType!==1);return e}function ft(e,t,n){t=t||0;if(v.isFunction(t))return v.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return v.grep(e,function(e,r){return e===t===n});if(typeof t=="string"){var r=v.grep(e,function(e){return e.nodeType===1});if(it.test(t))return v.filter(t,r,!n);t=v.filter(t,r)}return v.grep(e,function(e,r){return v.inArray(e,t)>=0===n})}function lt(e){var t=ct.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function At(e,t){if(t.nodeType!==1||!v.hasData(e))return;var n,r,i,s=v._data(e),o=v._data(t,s),u=s.events;if(u){delete o.handle,o.events={};for(n in u)for(r=0,i=u[n].length;r<i;r++)v.event.add(t,n,u[n][r])}o.data&&(o.data=v.extend({},o.data))}function Ot(e,t){var n;if(t.nodeType!==1)return;t.clearAttributes&&t.clearAttributes(),t.mergeAttributes&&t.mergeAttributes(e),n=t.nodeName.toLowerCase(),n==="object"?(t.parentNode&&(t.outerHTML=e.outerHTML),v.support.html5Clone&&e.innerHTML&&!v.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):n==="input"&&Et.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):n==="option"?t.selected=e.defaultSelected:n==="input"||n==="textarea"?t.defaultValue=e.defaultValue:n==="script"&&t.text!==e.text&&(t.text=e.text),t.removeAttribute(v.expando)}function Mt(e){return typeof e.getElementsByTagName!="undefined"?e.getElementsByTagName("*"):typeof e.querySelectorAll!="undefined"?e.querySelectorAll("*"):[]}function _t(e){Et.test(e.type)&&(e.defaultChecked=e.checked)}function Qt(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=Jt.length;while(i--){t=Jt[i]+n;if(t in e)return t}return r}function Gt(e,t){return e=t||e,v.css(e,"display")==="none"||!v.contains(e.ownerDocument,e)}function Yt(e,t){var n,r,i=[],s=0,o=e.length;for(;s<o;s++){n=e[s];if(!n.style)continue;i[s]=v._data(n,"olddisplay"),t?(!i[s]&&n.style.display==="none"&&(n.style.display=""),n.style.display===""&&Gt(n)&&(i[s]=v._data(n,"olddisplay",nn(n.nodeName)))):(r=Dt(n,"display"),!i[s]&&r!=="none"&&v._data(n,"olddisplay",r))}for(s=0;s<o;s++){n=e[s];if(!n.style)continue;if(!t||n.style.display==="none"||n.style.display==="")n.style.display=t?i[s]||"":"none"}return e}function Zt(e,t,n){var r=Rt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function en(e,t,n,r){var i=n===(r?"border":"content")?4:t==="width"?1:0,s=0;for(;i<4;i+=2)n==="margin"&&(s+=v.css(e,n+$t[i],!0)),r?(n==="content"&&(s-=parseFloat(Dt(e,"padding"+$t[i]))||0),n!=="margin"&&(s-=parseFloat(Dt(e,"border"+$t[i]+"Width"))||0)):(s+=parseFloat(Dt(e,"padding"+$t[i]))||0,n!=="padding"&&(s+=parseFloat(Dt(e,"border"+$t[i]+"Width"))||0));return s}function tn(e,t,n){var r=t==="width"?e.offsetWidth:e.offsetHeight,i=!0,s=v.support.boxSizing&&v.css(e,"boxSizing")==="border-box";if(r<=0||r==null){r=Dt(e,t);if(r<0||r==null)r=e.style[t];if(Ut.test(r))return r;i=s&&(v.support.boxSizingReliable||r===e.style[t]),r=parseFloat(r)||0}return r+en(e,t,n||(s?"border":"content"),i)+"px"}function nn(e){if(Wt[e])return Wt[e];var t=v("<"+e+">").appendTo(i.body),n=t.css("display");t.remove();if(n==="none"||n===""){Pt=i.body.appendChild(Pt||v.extend(i.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!Ht||!Pt.createElement)Ht=(Pt.contentWindow||Pt.contentDocument).document,Ht.write("<!doctype html><html><body>"),Ht.close();t=Ht.body.appendChild(Ht.createElement(e)),n=Dt(t,"display"),i.body.removeChild(Pt)}return Wt[e]=n,n}function fn(e,t,n,r){var i;if(v.isArray(t))v.each(t,function(t,i){n||sn.test(e)?r(e,i):fn(e+"["+(typeof i=="object"?t:"")+"]",i,n,r)});else if(!n&&v.type(t)==="object")for(i in t)fn(e+"["+i+"]",t[i],n,r);else r(e,t)}function Cn(e){return function(t,n){typeof t!="string"&&(n=t,t="*");var r,i,s,o=t.toLowerCase().split(y),u=0,a=o.length;if(v.isFunction(n))for(;u<a;u++)r=o[u],s=/^\+/.test(r),s&&(r=r.substr(1)||"*"),i=e[r]=e[r]||[],i[s?"unshift":"push"](n)}}function kn(e,n,r,i,s,o){s=s||n.dataTypes[0],o=o||{},o[s]=!0;var u,a=e[s],f=0,l=a?a.length:0,c=e===Sn;for(;f<l&&(c||!u);f++)u=a[f](n,r,i),typeof u=="string"&&(!c||o[u]?u=t:(n.dataTypes.unshift(u),u=kn(e,n,r,i,u,o)));return(c||!u)&&!o["*"]&&(u=kn(e,n,r,i,"*",o)),u}function Ln(e,n){var r,i,s=v.ajaxSettings.flatOptions||{};for(r in n)n[r]!==t&&((s[r]?e:i||(i={}))[r]=n[r]);i&&v.extend(!0,e,i)}function An(e,n,r){var i,s,o,u,a=e.contents,f=e.dataTypes,l=e.responseFields;for(s in l)s in r&&(n[l[s]]=r[s]);while(f[0]==="*")f.shift(),i===t&&(i=e.mimeType||n.getResponseHeader("content-type"));if(i)for(s in a)if(a[s]&&a[s].test(i)){f.unshift(s);break}if(f[0]in r)o=f[0];else{for(s in r){if(!f[0]||e.converters[s+" "+f[0]]){o=s;break}u||(u=s)}o=o||u}if(o)return o!==f[0]&&f.unshift(o),r[o]}function On(e,t){var n,r,i,s,o=e.dataTypes.slice(),u=o[0],a={},f=0;e.dataFilter&&(t=e.dataFilter(t,e.dataType));if(o[1])for(n in e.converters)a[n.toLowerCase()]=e.converters[n];for(;i=o[++f];)if(i!=="*"){if(u!=="*"&&u!==i){n=a[u+" "+i]||a["* "+i];if(!n)for(r in a){s=r.split(" ");if(s[1]===i){n=a[u+" "+s[0]]||a["* "+s[0]];if(n){n===!0?n=a[r]:a[r]!==!0&&(i=s[0],o.splice(f--,0,i));break}}}if(n!==!0)if(n&&e["throws"])t=n(t);else try{t=n(t)}catch(l){return{state:"parsererror",error:n?l:"No conversion from "+u+" to "+i}}}u=i}return{state:"success",data:t}}function Fn(){try{return new e.XMLHttpRequest}catch(t){}}function In(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}function $n(){return setTimeout(function(){qn=t},0),qn=v.now()}function Jn(e,t){v.each(t,function(t,n){var r=(Vn[t]||[]).concat(Vn["*"]),i=0,s=r.length;for(;i<s;i++)if(r[i].call(e,t,n))return})}function Kn(e,t,n){var r,i=0,s=0,o=Xn.length,u=v.Deferred().always(function(){delete a.elem}),a=function(){var t=qn||$n(),n=Math.max(0,f.startTime+f.duration-t),r=n/f.duration||0,i=1-r,s=0,o=f.tweens.length;for(;s<o;s++)f.tweens[s].run(i);return u.notifyWith(e,[f,i,n]),i<1&&o?n:(u.resolveWith(e,[f]),!1)},f=u.promise({elem:e,props:v.extend({},t),opts:v.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:qn||$n(),duration:n.duration,tweens:[],createTween:function(t,n,r){var i=v.Tween(e,f.opts,t,n,f.opts.specialEasing[t]||f.opts.easing);return f.tweens.push(i),i},stop:function(t){var n=0,r=t?f.tweens.length:0;for(;n<r;n++)f.tweens[n].run(1);return t?u.resolveWith(e,[f,t]):u.rejectWith(e,[f,t]),this}}),l=f.props;Qn(l,f.opts.specialEasing);for(;i<o;i++){r=Xn[i].call(f,e,l,f.opts);if(r)return r}return Jn(f,l),v.isFunction(f.opts.start)&&f.opts.start.call(e,f),v.fx.timer(v.extend(a,{anim:f,queue:f.opts.queue,elem:e})),f.progress(f.opts.progress).done(f.opts.done,f.opts.complete).fail(f.opts.fail).always(f.opts.always)}function Qn(e,t){var n,r,i,s,o;for(n in e){r=v.camelCase(n),i=t[r],s=e[n],v.isArray(s)&&(i=s[1],s=e[n]=s[0]),n!==r&&(e[r]=s,delete e[n]),o=v.cssHooks[r];if(o&&"expand"in o){s=o.expand(s),delete e[r];for(n in s)n in e||(e[n]=s[n],t[n]=i)}else t[r]=i}}function Gn(e,t,n){var r,i,s,o,u,a,f,l,c,h=this,p=e.style,d={},m=[],g=e.nodeType&&Gt(e);n.queue||(l=v._queueHooks(e,"fx"),l.unqueued==null&&(l.unqueued=0,c=l.empty.fire,l.empty.fire=function(){l.unqueued||c()}),l.unqueued++,h.always(function(){h.always(function(){l.unqueued--,v.queue(e,"fx").length||l.empty.fire()})})),e.nodeType===1&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],v.css(e,"display")==="inline"&&v.css(e,"float")==="none"&&(!v.support.inlineBlockNeedsLayout||nn(e.nodeName)==="inline"?p.display="inline-block":p.zoom=1)),n.overflow&&(p.overflow="hidden",v.support.shrinkWrapBlocks||h.done(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t){s=t[r];if(Un.exec(s)){delete t[r],a=a||s==="toggle";if(s===(g?"hide":"show"))continue;m.push(r)}}o=m.length;if(o){u=v._data(e,"fxshow")||v._data(e,"fxshow",{}),"hidden"in u&&(g=u.hidden),a&&(u.hidden=!g),g?v(e).show():h.done(function(){v(e).hide()}),h.done(function(){var t;v.removeData(e,"fxshow",!0);for(t in d)v.style(e,t,d[t])});for(r=0;r<o;r++)i=m[r],f=h.createTween(i,g?u[i]:0),d[i]=u[i]||v.style(e,i),i in u||(u[i]=f.start,g&&(f.end=f.start,f.start=i==="width"||i==="height"?1:0))}}function Yn(e,t,n,r,i){return new Yn.prototype.init(e,t,n,r,i)}function Zn(e,t){var n,r={height:e},i=0;t=t?1:0;for(;i<4;i+=2-t)n=$t[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}function tr(e){return v.isWindow(e)?e:e.nodeType===9?e.defaultView||e.parentWindow:!1}var n,r,i=e.document,s=e.location,o=e.navigator,u=e.jQuery,a=e.$,f=Array.prototype.push,l=Array.prototype.slice,c=Array.prototype.indexOf,h=Object.prototype.toString,p=Object.prototype.hasOwnProperty,d=String.prototype.trim,v=function(e,t){return new v.fn.init(e,t,n)},m=/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,g=/\S/,y=/\s+/,b=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,w=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,E=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,S=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,T=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,N=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,C=/^-ms-/,k=/-([\da-z])/gi,L=function(e,t){return(t+"").toUpperCase()},A=function(){i.addEventListener?(i.removeEventListener("DOMContentLoaded",A,!1),v.ready()):i.readyState==="complete"&&(i.detachEvent("onreadystatechange",A),v.ready())},O={};v.fn=v.prototype={constructor:v,init:function(e,n,r){var s,o,u,a;if(!e)return this;if(e.nodeType)return this.context=this[0]=e,this.length=1,this;if(typeof e=="string"){e.charAt(0)==="<"&&e.charAt(e.length-1)===">"&&e.length>=3?s=[null,e,null]:s=w.exec(e);if(s&&(s[1]||!n)){if(s[1])return n=n instanceof v?n[0]:n,a=n&&n.nodeType?n.ownerDocument||n:i,e=v.parseHTML(s[1],a,!0),E.test(s[1])&&v.isPlainObject(n)&&this.attr.call(e,n,!0),v.merge(this,e);o=i.getElementById(s[2]);if(o&&o.parentNode){if(o.id!==s[2])return r.find(e);this.length=1,this[0]=o}return this.context=i,this.selector=e,this}return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e)}return v.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),v.makeArray(e,this))},selector:"",jquery:"1.8.3",length:0,size:function(){return this.length},toArray:function(){return l.call(this)},get:function(e){return e==null?this.toArray():e<0?this[this.length+e]:this[e]},pushStack:function(e,t,n){var r=v.merge(this.constructor(),e);return r.prevObject=this,r.context=this.context,t==="find"?r.selector=this.selector+(this.selector?" ":"")+n:t&&(r.selector=this.selector+"."+t+"("+n+")"),r},each:function(e,t){return v.each(this,e,t)},ready:function(e){return v.ready.promise().done(e),this},eq:function(e){return e=+e,e===-1?this.slice(e):this.slice(e,e+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(l.apply(this,arguments),"slice",l.call(arguments).join(","))},map:function(e){return this.pushStack(v.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:[].sort,splice:[].splice},v.fn.init.prototype=v.fn,v.extend=v.fn.extend=function(){var e,n,r,i,s,o,u=arguments[0]||{},a=1,f=arguments.length,l=!1;typeof u=="boolean"&&(l=u,u=arguments[1]||{},a=2),typeof u!="object"&&!v.isFunction(u)&&(u={}),f===a&&(u=this,--a);for(;a<f;a++)if((e=arguments[a])!=null)for(n in e){r=u[n],i=e[n];if(u===i)continue;l&&i&&(v.isPlainObject(i)||(s=v.isArray(i)))?(s?(s=!1,o=r&&v.isArray(r)?r:[]):o=r&&v.isPlainObject(r)?r:{},u[n]=v.extend(l,o,i)):i!==t&&(u[n]=i)}return u},v.extend({noConflict:function(t){return e.$===v&&(e.$=a),t&&e.jQuery===v&&(e.jQuery=u),v},isReady:!1,readyWait:1,holdReady:function(e){e?v.readyWait++:v.ready(!0)},ready:function(e){if(e===!0?--v.readyWait:v.isReady)return;if(!i.body)return setTimeout(v.ready,1);v.isReady=!0;if(e!==!0&&--v.readyWait>0)return;r.resolveWith(i,[v]),v.fn.trigger&&v(i).trigger("ready").off("ready")},isFunction:function(e){return v.type(e)==="function"},isArray:Array.isArray||function(e){return v.type(e)==="array"},isWindow:function(e){return e!=null&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return e==null?String(e):O[h.call(e)]||"object"},isPlainObject:function(e){if(!e||v.type(e)!=="object"||e.nodeType||v.isWindow(e))return!1;try{if(e.constructor&&!p.call(e,"constructor")&&!p.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||p.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw new Error(e)},parseHTML:function(e,t,n){var r;return!e||typeof e!="string"?null:(typeof t=="boolean"&&(n=t,t=0),t=t||i,(r=E.exec(e))?[t.createElement(r[1])]:(r=v.buildFragment([e],t,n?null:[]),v.merge([],(r.cacheable?v.clone(r.fragment):r.fragment).childNodes)))},parseJSON:function(t){if(!t||typeof t!="string")return null;t=v.trim(t);if(e.JSON&&e.JSON.parse)return e.JSON.parse(t);if(S.test(t.replace(T,"@").replace(N,"]").replace(x,"")))return(new Function("return "+t))();v.error("Invalid JSON: "+t)},parseXML:function(n){var r,i;if(!n||typeof n!="string")return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(s){r=t}return(!r||!r.documentElement||r.getElementsByTagName("parsererror").length)&&v.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&g.test(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(C,"ms-").replace(k,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,n,r){var i,s=0,o=e.length,u=o===t||v.isFunction(e);if(r){if(u){for(i in e)if(n.apply(e[i],r)===!1)break}else for(;s<o;)if(n.apply(e[s++],r)===!1)break}else if(u){for(i in e)if(n.call(e[i],i,e[i])===!1)break}else for(;s<o;)if(n.call(e[s],s,e[s++])===!1)break;return e},trim:d&&!d.call("\ufeff\u00a0")?function(e){return e==null?"":d.call(e)}:function(e){return e==null?"":(e+"").replace(b,"")},makeArray:function(e,t){var n,r=t||[];return e!=null&&(n=v.type(e),e.length==null||n==="string"||n==="function"||n==="regexp"||v.isWindow(e)?f.call(r,e):v.merge(r,e)),r},inArray:function(e,t,n){var r;if(t){if(c)return c.call(t,e,n);r=t.length,n=n?n<0?Math.max(0,r+n):n:0;for(;n<r;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,s=0;if(typeof r=="number")for(;s<r;s++)e[i++]=n[s];else while(n[s]!==t)e[i++]=n[s++];return e.length=i,e},grep:function(e,t,n){var r,i=[],s=0,o=e.length;n=!!n;for(;s<o;s++)r=!!t(e[s],s),n!==r&&i.push(e[s]);return i},map:function(e,n,r){var i,s,o=[],u=0,a=e.length,f=e instanceof v||a!==t&&typeof a=="number"&&(a>0&&e[0]&&e[a-1]||a===0||v.isArray(e));if(f)for(;u<a;u++)i=n(e[u],u,r),i!=null&&(o[o.length]=i);else for(s in e)i=n(e[s],s,r),i!=null&&(o[o.length]=i);return o.concat.apply([],o)},guid:1,proxy:function(e,n){var r,i,s;return typeof n=="string"&&(r=e[n],n=e,e=r),v.isFunction(e)?(i=l.call(arguments,2),s=function(){return e.apply(n,i.concat(l.call(arguments)))},s.guid=e.guid=e.guid||v.guid++,s):t},access:function(e,n,r,i,s,o,u){var a,f=r==null,l=0,c=e.length;if(r&&typeof r=="object"){for(l in r)v.access(e,n,l,r[l],1,o,i);s=1}else if(i!==t){a=u===t&&v.isFunction(i),f&&(a?(a=n,n=function(e,t,n){return a.call(v(e),n)}):(n.call(e,i),n=null));if(n)for(;l<c;l++)n(e[l],r,a?i.call(e[l],l,n(e[l],r)):i,u);s=1}return s?e:f?n.call(e):c?n(e[0],r):o},now:function(){return(new Date).getTime()}}),v.ready.promise=function(t){if(!r){r=v.Deferred();if(i.readyState==="complete")setTimeout(v.ready,1);else if(i.addEventListener)i.addEventListener("DOMContentLoaded",A,!1),e.addEventListener("load",v.ready,!1);else{i.attachEvent("onreadystatechange",A),e.attachEvent("onload",v.ready);var n=!1;try{n=e.frameElement==null&&i.documentElement}catch(s){}n&&n.doScroll&&function o(){if(!v.isReady){try{n.doScroll("left")}catch(e){return setTimeout(o,50)}v.ready()}}()}}return r.promise(t)},v.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(e,t){O["[object "+t+"]"]=t.toLowerCase()}),n=v(i);var M={};v.Callbacks=function(e){e=typeof e=="string"?M[e]||_(e):v.extend({},e);var n,r,i,s,o,u,a=[],f=!e.once&&[],l=function(t){n=e.memory&&t,r=!0,u=s||0,s=0,o=a.length,i=!0;for(;a&&u<o;u++)if(a[u].apply(t[0],t[1])===!1&&e.stopOnFalse){n=!1;break}i=!1,a&&(f?f.length&&l(f.shift()):n?a=[]:c.disable())},c={add:function(){if(a){var t=a.length;(function r(t){v.each(t,function(t,n){var i=v.type(n);i==="function"?(!e.unique||!c.has(n))&&a.push(n):n&&n.length&&i!=="string"&&r(n)})})(arguments),i?o=a.length:n&&(s=t,l(n))}return this},remove:function(){return a&&v.each(arguments,function(e,t){var n;while((n=v.inArray(t,a,n))>-1)a.splice(n,1),i&&(n<=o&&o--,n<=u&&u--)}),this},has:function(e){return v.inArray(e,a)>-1},empty:function(){return a=[],this},disable:function(){return a=f=n=t,this},disabled:function(){return!a},lock:function(){return f=t,n||c.disable(),this},locked:function(){return!f},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],a&&(!r||f)&&(i?f.push(t):l(t)),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!r}};return c},v.extend({Deferred:function(e){var t=[["resolve","done",v.Callbacks("once memory"),"resolved"],["reject","fail",v.Callbacks("once memory"),"rejected"],["notify","progress",v.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return v.Deferred(function(n){v.each(t,function(t,r){var s=r[0],o=e[t];i[r[1]](v.isFunction(o)?function(){var e=o.apply(this,arguments);e&&v.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[s+"With"](this===i?n:this,[e])}:n[s])}),e=null}).promise()},promise:function(e){return e!=null?v.extend(e,r):r}},i={};return r.pipe=r.then,v.each(t,function(e,s){var o=s[2],u=s[3];r[s[1]]=o.add,u&&o.add(function(){n=u},t[e^1][2].disable,t[2][2].lock),i[s[0]]=o.fire,i[s[0]+"With"]=o.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=l.call(arguments),r=n.length,i=r!==1||e&&v.isFunction(e.promise)?r:0,s=i===1?e:v.Deferred(),o=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?l.call(arguments):r,n===u?s.notifyWith(t,n):--i||s.resolveWith(t,n)}},u,a,f;if(r>1){u=new Array(r),a=new Array(r),f=new Array(r);for(;t<r;t++)n[t]&&v.isFunction(n[t].promise)?n[t].promise().done(o(t,f,n)).fail(s.reject).progress(o(t,a,u)):--i}return i||s.resolveWith(f,n),s.promise()}}),v.support=function(){var t,n,r,s,o,u,a,f,l,c,h,p=i.createElement("div");p.setAttribute("className","t"),p.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=p.getElementsByTagName("*"),r=p.getElementsByTagName("a")[0];if(!n||!r||!n.length)return{};s=i.createElement("select"),o=s.appendChild(i.createElement("option")),u=p.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:r.getAttribute("href")==="/a",opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:u.value==="on",optSelected:o.selected,getSetAttribute:p.className!=="t",enctype:!!i.createElement("form").enctype,html5Clone:i.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",boxModel:i.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},u.checked=!0,t.noCloneChecked=u.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!o.disabled;try{delete p.test}catch(d){t.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",h=function(){t.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick"),p.detachEvent("onclick",h)),u=i.createElement("input"),u.value="t",u.setAttribute("type","radio"),t.radioValue=u.value==="t",u.setAttribute("checked","checked"),u.setAttribute("name","t"),p.appendChild(u),a=i.createDocumentFragment(),a.appendChild(p.lastChild),t.checkClone=a.cloneNode(!0).cloneNode(!0).lastChild.checked,t.appendChecked=u.checked,a.removeChild(u),a.appendChild(p);if(p.attachEvent)for(l in{submit:!0,change:!0,focusin:!0})f="on"+l,c=f in p,c||(p.setAttribute(f,"return;"),c=typeof p[f]=="function"),t[l+"Bubbles"]=c;return v(function(){var n,r,s,o,u="padding:0;margin:0;border:0;display:block;overflow:hidden;",a=i.getElementsByTagName("body")[0];if(!a)return;n=i.createElement("div"),n.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",a.insertBefore(n,a.firstChild),r=i.createElement("div"),n.appendChild(r),r.innerHTML="<table><tr><td></td><td>t</td></tr></table>",s=r.getElementsByTagName("td"),s[0].style.cssText="padding:0;margin:0;border:0;display:none",c=s[0].offsetHeight===0,s[0].style.display="",s[1].style.display="none",t.reliableHiddenOffsets=c&&s[0].offsetHeight===0,r.innerHTML="",r.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=r.offsetWidth===4,t.doesNotIncludeMarginInBodyOffset=a.offsetTop!==1,e.getComputedStyle&&(t.pixelPosition=(e.getComputedStyle(r,null)||{}).top!=="1%",t.boxSizingReliable=(e.getComputedStyle(r,null)||{width:"4px"}).width==="4px",o=i.createElement("div"),o.style.cssText=r.style.cssText=u,o.style.marginRight=o.style.width="0",r.style.width="1px",r.appendChild(o),t.reliableMarginRight=!parseFloat((e.getComputedStyle(o,null)||{}).marginRight)),typeof r.style.zoom!="undefined"&&(r.innerHTML="",r.style.cssText=u+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=r.offsetWidth===3,r.style.display="block",r.style.overflow="visible",r.innerHTML="<div></div>",r.firstChild.style.width="5px",t.shrinkWrapBlocks=r.offsetWidth!==3,n.style.zoom=1),a.removeChild(n),n=r=s=o=null}),a.removeChild(p),n=r=s=o=u=a=p=null,t}();var D=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;v.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(v.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?v.cache[e[v.expando]]:e[v.expando],!!e&&!B(e)},data:function(e,n,r,i){if(!v.acceptData(e))return;var s,o,u=v.expando,a=typeof n=="string",f=e.nodeType,l=f?v.cache:e,c=f?e[u]:e[u]&&u;if((!c||!l[c]||!i&&!l[c].data)&&a&&r===t)return;c||(f?e[u]=c=v.deletedIds.pop()||v.guid++:c=u),l[c]||(l[c]={},f||(l[c].toJSON=v.noop));if(typeof n=="object"||typeof n=="function")i?l[c]=v.extend(l[c],n):l[c].data=v.extend(l[c].data,n);return s=l[c],i||(s.data||(s.data={}),s=s.data),r!==t&&(s[v.camelCase(n)]=r),a?(o=s[n],o==null&&(o=s[v.camelCase(n)])):o=s,o},removeData:function(e,t,n){if(!v.acceptData(e))return;var r,i,s,o=e.nodeType,u=o?v.cache:e,a=o?e[v.expando]:v.expando;if(!u[a])return;if(t){r=n?u[a]:u[a].data;if(r){v.isArray(t)||(t in r?t=[t]:(t=v.camelCase(t),t in r?t=[t]:t=t.split(" ")));for(i=0,s=t.length;i<s;i++)delete r[t[i]];if(!(n?B:v.isEmptyObject)(r))return}}if(!n){delete u[a].data;if(!B(u[a]))return}o?v.cleanData([e],!0):v.support.deleteExpando||u!=u.window?delete u[a]:u[a]=null},_data:function(e,t,n){return v.data(e,t,n,!0)},acceptData:function(e){var t=e.nodeName&&v.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),v.fn.extend({data:function(e,n){var r,i,s,o,u,a=this[0],f=0,l=null;if(e===t){if(this.length){l=v.data(a);if(a.nodeType===1&&!v._data(a,"parsedAttrs")){s=a.attributes;for(u=s.length;f<u;f++)o=s[f].name,o.indexOf("data-")||(o=v.camelCase(o.substring(5)),H(a,o,l[o]));v._data(a,"parsedAttrs",!0)}}return l}return typeof e=="object"?this.each(function(){v.data(this,e)}):(r=e.split(".",2),r[1]=r[1]?"."+r[1]:"",i=r[1]+"!",v.access(this,function(n){if(n===t)return l=this.triggerHandler("getData"+i,[r[0]]),l===t&&a&&(l=v.data(a,e),l=H(a,e,l)),l===t&&r[1]?this.data(r[0]):l;r[1]=n,this.each(function(){var t=v(this);t.triggerHandler("setData"+i,r),v.data(this,e,n),t.triggerHandler("changeData"+i,r)})},null,n,arguments.length>1,null,!1))},removeData:function(e){return this.each(function(){v.removeData(this,e)})}}),v.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=v._data(e,t),n&&(!r||v.isArray(n)?r=v._data(e,t,v.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=v.queue(e,t),r=n.length,i=n.shift(),s=v._queueHooks(e,t),o=function(){v.dequeue(e,t)};i==="inprogress"&&(i=n.shift(),r--),i&&(t==="fx"&&n.unshift("inprogress"),delete s.stop,i.call(e,o,s)),!r&&s&&s.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return v._data(e,n)||v._data(e,n,{empty:v.Callbacks("once memory").add(function(){v.removeData(e,t+"queue",!0),v.removeData(e,n,!0)})})}}),v.fn.extend({queue:function(e,n){var r=2;return typeof e!="string"&&(n=e,e="fx",r--),arguments.length<r?v.queue(this[0],e):n===t?this:this.each(function(){var t=v.queue(this,e,n);v._queueHooks(this,e),e==="fx"&&t[0]!=="inprogress"&&v.dequeue(this,e)})},dequeue:function(e){return this.each(function(){v.dequeue(this,e)})},delay:function(e,t){return e=v.fx?v.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,s=v.Deferred(),o=this,u=this.length,a=function(){--i||s.resolveWith(o,[o])};typeof e!="string"&&(n=e,e=t),e=e||"fx";while(u--)r=v._data(o[u],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(a));return a(),s.promise(n)}});var j,F,I,q=/[\t\r\n]/g,R=/\r/g,U=/^(?:button|input)$/i,z=/^(?:button|input|object|select|textarea)$/i,W=/^a(?:rea|)$/i,X=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,V=v.support.getSetAttribute;v.fn.extend({attr:function(e,t){return v.access(this,v.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){v.removeAttr(this,e)})},prop:function(e,t){return v.access(this,v.prop,e,t,arguments.length>1)},removeProp:function(e){return e=v.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,s,o,u;if(v.isFunction(e))return this.each(function(t){v(this).addClass(e.call(this,t,this.className))});if(e&&typeof e=="string"){t=e.split(y);for(n=0,r=this.length;n<r;n++){i=this[n];if(i.nodeType===1)if(!i.className&&t.length===1)i.className=e;else{s=" "+i.className+" ";for(o=0,u=t.length;o<u;o++)s.indexOf(" "+t[o]+" ")<0&&(s+=t[o]+" ");i.className=v.trim(s)}}}return this},removeClass:function(e){var n,r,i,s,o,u,a;if(v.isFunction(e))return this.each(function(t){v(this).removeClass(e.call(this,t,this.className))});if(e&&typeof e=="string"||e===t){n=(e||"").split(y);for(u=0,a=this.length;u<a;u++){i=this[u];if(i.nodeType===1&&i.className){r=(" "+i.className+" ").replace(q," ");for(s=0,o=n.length;s<o;s++)while(r.indexOf(" "+n[s]+" ")>=0)r=r.replace(" "+n[s]+" "," ");i.className=e?v.trim(r):""}}}return this},toggleClass:function(e,t){var n=typeof e,r=typeof t=="boolean";return v.isFunction(e)?this.each(function(n){v(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if(n==="string"){var i,s=0,o=v(this),u=t,a=e.split(y);while(i=a[s++])u=r?u:!o.hasClass(i),o[u?"addClass":"removeClass"](i)}else if(n==="undefined"||n==="boolean")this.className&&v._data(this,"__className__",this.className),this.className=this.className||e===!1?"":v._data(this,"__className__")||""})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;n<r;n++)if(this[n].nodeType===1&&(" "+this[n].className+" ").replace(q," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,s=this[0];if(!arguments.length){if(s)return n=v.valHooks[s.type]||v.valHooks[s.nodeName.toLowerCase()],n&&"get"in n&&(r=n.get(s,"value"))!==t?r:(r=s.value,typeof r=="string"?r.replace(R,""):r==null?"":r);return}return i=v.isFunction(e),this.each(function(r){var s,o=v(this);if(this.nodeType!==1)return;i?s=e.call(this,r,o.val()):s=e,s==null?s="":typeof s=="number"?s+="":v.isArray(s)&&(s=v.map(s,function(e){return e==null?"":e+""})),n=v.valHooks[this.type]||v.valHooks[this.nodeName.toLowerCase()];if(!n||!("set"in n)||n.set(this,s,"value")===t)this.value=s})}}),v.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,s=e.type==="select-one"||i<0,o=s?null:[],u=s?i+1:r.length,a=i<0?u:s?i:0;for(;a<u;a++){n=r[a];if((n.selected||a===i)&&(v.support.optDisabled?!n.disabled:n.getAttribute("disabled")===null)&&(!n.parentNode.disabled||!v.nodeName(n.parentNode,"optgroup"))){t=v(n).val();if(s)return t;o.push(t)}}return o},set:function(e,t){var n=v.makeArray(t);return v(e).find("option").each(function(){this.selected=v.inArray(v(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attrFn:{},attr:function(e,n,r,i){var s,o,u,a=e.nodeType;if(!e||a===3||a===8||a===2)return;if(i&&v.isFunction(v.fn[n]))return v(e)[n](r);if(typeof e.getAttribute=="undefined")return v.prop(e,n,r);u=a!==1||!v.isXMLDoc(e),u&&(n=n.toLowerCase(),o=v.attrHooks[n]||(X.test(n)?F:j));if(r!==t){if(r===null){v.removeAttr(e,n);return}return o&&"set"in o&&u&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r)}return o&&"get"in o&&u&&(s=o.get(e,n))!==null?s:(s=e.getAttribute(n),s===null?t:s)},removeAttr:function(e,t){var n,r,i,s,o=0;if(t&&e.nodeType===1){r=t.split(y);for(;o<r.length;o++)i=r[o],i&&(n=v.propFix[i]||i,s=X.test(i),s||v.attr(e,i,""),e.removeAttribute(V?i:n),s&&n in e&&(e[n]=!1))}},attrHooks:{type:{set:function(e,t){if(U.test(e.nodeName)&&e.parentNode)v.error("type property can't be changed");else if(!v.support.radioValue&&t==="radio"&&v.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}},value:{get:function(e,t){return j&&v.nodeName(e,"button")?j.get(e,t):t in e?e.value:null},set:function(e,t,n){if(j&&v.nodeName(e,"button"))return j.set(e,t,n);e.value=t}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,s,o,u=e.nodeType;if(!e||u===3||u===8||u===2)return;return o=u!==1||!v.isXMLDoc(e),o&&(n=v.propFix[n]||n,s=v.propHooks[n]),r!==t?s&&"set"in s&&(i=s.set(e,r,n))!==t?i:e[n]=r:s&&"get"in s&&(i=s.get(e,n))!==null?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):z.test(e.nodeName)||W.test(e.nodeName)&&e.href?0:t}}}}),F={get:function(e,n){var r,i=v.prop(e,n);return i===!0||typeof i!="boolean"&&(r=e.getAttributeNode(n))&&r.nodeValue!==!1?n.toLowerCase():t},set:function(e,t,n){var r;return t===!1?v.removeAttr(e,n):(r=v.propFix[n]||n,r in e&&(e[r]=!0),e.setAttribute(n,n.toLowerCase())),n}},V||(I={name:!0,id:!0,coords:!0},j=v.valHooks.button={get:function(e,n){var r;return r=e.getAttributeNode(n),r&&(I[n]?r.value!=="":r.specified)?r.value:t},set:function(e,t,n){var r=e.getAttributeNode(n);return r||(r=i.createAttribute(n),e.setAttributeNode(r)),r.value=t+""}},v.each(["width","height"],function(e,t){v.attrHooks[t]=v.extend(v.attrHooks[t],{set:function(e,n){if(n==="")return e.setAttribute(t,"auto"),n}})}),v.attrHooks.contenteditable={get:j.get,set:function(e,t,n){t===""&&(t="false"),j.set(e,t,n)}}),v.support.hrefNormalized||v.each(["href","src","width","height"],function(e,n){v.attrHooks[n]=v.extend(v.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return r===null?t:r}})}),v.support.style||(v.attrHooks.style={get:function(e){return e.style.cssText.toLowerCase()||t},set:function(e,t){return e.style.cssText=t+""}}),v.support.optSelected||(v.propHooks.selected=v.extend(v.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),v.support.enctype||(v.propFix.enctype="encoding"),v.support.checkOn||v.each(["radio","checkbox"],function(){v.valHooks[this]={get:function(e){return e.getAttribute("value")===null?"on":e.value}}}),v.each(["radio","checkbox"],function(){v.valHooks[this]=v.extend(v.valHooks[this],{set:function(e,t){if(v.isArray(t))return e.checked=v.inArray(v(e).val(),t)>=0}})});var $=/^(?:textarea|input|select)$/i,J=/^([^\.]*|)(?:\.(.+)|)$/,K=/(?:^|\s)hover(\.\S+|)\b/,Q=/^key/,G=/^(?:mouse|contextmenu)|click/,Y=/^(?:focusinfocus|focusoutblur)$/,Z=function(e){return v.event.special.hover?e:e.replace(K,"mouseenter$1 mouseleave$1")};v.event={add:function(e,n,r,i,s){var o,u,a,f,l,c,h,p,d,m,g;if(e.nodeType===3||e.nodeType===8||!n||!r||!(o=v._data(e)))return;r.handler&&(d=r,r=d.handler,s=d.selector),r.guid||(r.guid=v.guid++),a=o.events,a||(o.events=a={}),u=o.handle,u||(o.handle=u=function(e){return typeof v=="undefined"||!!e&&v.event.triggered===e.type?t:v.event.dispatch.apply(u.elem,arguments)},u.elem=e),n=v.trim(Z(n)).split(" ");for(f=0;f<n.length;f++){l=J.exec(n[f])||[],c=l[1],h=(l[2]||"").split(".").sort(),g=v.event.special[c]||{},c=(s?g.delegateType:g.bindType)||c,g=v.event.special[c]||{},p=v.extend({type:c,origType:l[1],data:i,handler:r,guid:r.guid,selector:s,needsContext:s&&v.expr.match.needsContext.test(s),namespace:h.join(".")},d),m=a[c];if(!m){m=a[c]=[],m.delegateCount=0;if(!g.setup||g.setup.call(e,i,h,u)===!1)e.addEventListener?e.addEventListener(c,u,!1):e.attachEvent&&e.attachEvent("on"+c,u)}g.add&&(g.add.call(e,p),p.handler.guid||(p.handler.guid=r.guid)),s?m.splice(m.delegateCount++,0,p):m.push(p),v.event.global[c]=!0}e=null},global:{},remove:function(e,t,n,r,i){var s,o,u,a,f,l,c,h,p,d,m,g=v.hasData(e)&&v._data(e);if(!g||!(h=g.events))return;t=v.trim(Z(t||"")).split(" ");for(s=0;s<t.length;s++){o=J.exec(t[s])||[],u=a=o[1],f=o[2];if(!u){for(u in h)v.event.remove(e,u+t[s],n,r,!0);continue}p=v.event.special[u]||{},u=(r?p.delegateType:p.bindType)||u,d=h[u]||[],l=d.length,f=f?new RegExp("(^|\\.)"+f.split(".").sort().join("\\.(?:.*\\.|)")+"(\\.|$)"):null;for(c=0;c<d.length;c++)m=d[c],(i||a===m.origType)&&(!n||n.guid===m.guid)&&(!f||f.test(m.namespace))&&(!r||r===m.selector||r==="**"&&m.selector)&&(d.splice(c--,1),m.selector&&d.delegateCount--,p.remove&&p.remove.call(e,m));d.length===0&&l!==d.length&&((!p.teardown||p.teardown.call(e,f,g.handle)===!1)&&v.removeEvent(e,u,g.handle),delete h[u])}v.isEmptyObject(h)&&(delete g.handle,v.removeData(e,"events",!0))},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(n,r,s,o){if(!s||s.nodeType!==3&&s.nodeType!==8){var u,a,f,l,c,h,p,d,m,g,y=n.type||n,b=[];if(Y.test(y+v.event.triggered))return;y.indexOf("!")>=0&&(y=y.slice(0,-1),a=!0),y.indexOf(".")>=0&&(b=y.split("."),y=b.shift(),b.sort());if((!s||v.event.customEvent[y])&&!v.event.global[y])return;n=typeof n=="object"?n[v.expando]?n:new v.Event(y,n):new v.Event(y),n.type=y,n.isTrigger=!0,n.exclusive=a,n.namespace=b.join("."),n.namespace_re=n.namespace?new RegExp("(^|\\.)"+b.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,h=y.indexOf(":")<0?"on"+y:"";if(!s){u=v.cache;for(f in u)u[f].events&&u[f].events[y]&&v.event.trigger(n,r,u[f].handle.elem,!0);return}n.result=t,n.target||(n.target=s),r=r!=null?v.makeArray(r):[],r.unshift(n),p=v.event.special[y]||{};if(p.trigger&&p.trigger.apply(s,r)===!1)return;m=[[s,p.bindType||y]];if(!o&&!p.noBubble&&!v.isWindow(s)){g=p.delegateType||y,l=Y.test(g+y)?s:s.parentNode;for(c=s;l;l=l.parentNode)m.push([l,g]),c=l;c===(s.ownerDocument||i)&&m.push([c.defaultView||c.parentWindow||e,g])}for(f=0;f<m.length&&!n.isPropagationStopped();f++)l=m[f][0],n.type=m[f][1],d=(v._data(l,"events")||{})[n.type]&&v._data(l,"handle"),d&&d.apply(l,r),d=h&&l[h],d&&v.acceptData(l)&&d.apply&&d.apply(l,r)===!1&&n.preventDefault();return n.type=y,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(s.ownerDocument,r)===!1)&&(y!=="click"||!v.nodeName(s,"a"))&&v.acceptData(s)&&h&&s[y]&&(y!=="focus"&&y!=="blur"||n.target.offsetWidth!==0)&&!v.isWindow(s)&&(c=s[h],c&&(s[h]=null),v.event.triggered=y,s[y](),v.event.triggered=t,c&&(s[h]=c)),n.result}return},dispatch:function(n){n=v.event.fix(n||e.event);var r,i,s,o,u,a,f,c,h,p,d=(v._data(this,"events")||{})[n.type]||[],m=d.delegateCount,g=l.call(arguments),y=!n.exclusive&&!n.namespace,b=v.event.special[n.type]||{},w=[];g[0]=n,n.delegateTarget=this;if(b.preDispatch&&b.preDispatch.call(this,n)===!1)return;if(m&&(!n.button||n.type!=="click"))for(s=n.target;s!=this;s=s.parentNode||this)if(s.disabled!==!0||n.type!=="click"){u={},f=[];for(r=0;r<m;r++)c=d[r],h=c.selector,u[h]===t&&(u[h]=c.needsContext?v(h,this).index(s)>=0:v.find(h,this,null,[s]).length),u[h]&&f.push(c);f.length&&w.push({elem:s,matches:f})}d.length>m&&w.push({elem:this,matches:d.slice(m)});for(r=0;r<w.length&&!n.isPropagationStopped();r++){a=w[r],n.currentTarget=a.elem;for(i=0;i<a.matches.length&&!n.isImmediatePropagationStopped();i++){c=a.matches[i];if(y||!n.namespace&&!c.namespace||n.namespace_re&&n.namespace_re.test(c.namespace))n.data=c.data,n.handleObj=c,o=((v.event.special[c.origType]||{}).handle||c.handler).apply(a.elem,g),o!==t&&(n.result=o,o===!1&&(n.preventDefault(),n.stopPropagation()))}}return b.postDispatch&&b.postDispatch.call(this,n),n.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return e.which==null&&(e.which=t.charCode!=null?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,s,o,u=n.button,a=n.fromElement;return e.pageX==null&&n.clientX!=null&&(r=e.target.ownerDocument||i,s=r.documentElement,o=r.body,e.pageX=n.clientX+(s&&s.scrollLeft||o&&o.scrollLeft||0)-(s&&s.clientLeft||o&&o.clientLeft||0),e.pageY=n.clientY+(s&&s.scrollTop||o&&o.scrollTop||0)-(s&&s.clientTop||o&&o.clientTop||0)),!e.relatedTarget&&a&&(e.relatedTarget=a===e.target?n.toElement:a),!e.which&&u!==t&&(e.which=u&1?1:u&2?3:u&4?2:0),e}},fix:function(e){if(e[v.expando])return e;var t,n,r=e,s=v.event.fixHooks[e.type]||{},o=s.props?this.props.concat(s.props):this.props;e=v.Event(r);for(t=o.length;t;)n=o[--t],e[n]=r[n];return e.target||(e.target=r.srcElement||i),e.target.nodeType===3&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,r):e},special:{load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(e,t,n){v.isWindow(this)&&(this.onbeforeunload=n)},teardown:function(e,t){this.onbeforeunload===t&&(this.onbeforeunload=null)}}},simulate:function(e,t,n,r){var i=v.extend(new v.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?v.event.trigger(i,null,t):v.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},v.event.handle=v.event.dispatch,v.removeEvent=i.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]=="undefined"&&(e[r]=null),e.detachEvent(r,n))},v.Event=function(e,t){if(!(this instanceof v.Event))return new v.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?tt:et):this.type=e,t&&v.extend(this,t),this.timeStamp=e&&e.timeStamp||v.now(),this[v.expando]=!0},v.Event.prototype={preventDefault:function(){this.isDefaultPrevented=tt;var e=this.originalEvent;if(!e)return;e.preventDefault?e.preventDefault():e.returnValue=!1},stopPropagation:function(){this.isPropagationStopped=tt;var e=this.originalEvent;if(!e)return;e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=tt,this.stopPropagation()},isDefaultPrevented:et,isPropagationStopped:et,isImmediatePropagationStopped:et},v.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){v.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,s=e.handleObj,o=s.selector;if(!i||i!==r&&!v.contains(r,i))e.type=s.origType,n=s.handler.apply(this,arguments),e.type=t;return n}}}),v.support.submitBubbles||(v.event.special.submit={setup:function(){if(v.nodeName(this,"form"))return!1;v.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=v.nodeName(n,"input")||v.nodeName(n,"button")?n.form:t;r&&!v._data(r,"_submit_attached")&&(v.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),v._data(r,"_submit_attached",!0))})},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&v.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){if(v.nodeName(this,"form"))return!1;v.event.remove(this,"._submit")}}),v.support.changeBubbles||(v.event.special.change={setup:function(){if($.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")v.event.add(this,"propertychange._change",function(e){e.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),v.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),v.event.simulate("change",this,e,!0)});return!1}v.event.add(this,"beforeactivate._change",function(e){var t=e.target;$.test(t.nodeName)&&!v._data(t,"_change_attached")&&(v.event.add(t,"change._change",function(e){this.parentNode&&!e.isSimulated&&!e.isTrigger&&v.event.simulate("change",this.parentNode,e,!0)}),v._data(t,"_change_attached",!0))})},handle:function(e){var t=e.target;if(this!==t||e.isSimulated||e.isTrigger||t.type!=="radio"&&t.type!=="checkbox")return e.handleObj.handler.apply(this,arguments)},teardown:function(){return v.event.remove(this,"._change"),!$.test(this.nodeName)}}),v.support.focusinBubbles||v.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){v.event.simulate(t,e.target,v.event.fix(e),!0)};v.event.special[t]={setup:function(){n++===0&&i.addEventListener(e,r,!0)},teardown:function(){--n===0&&i.removeEventListener(e,r,!0)}}}),v.fn.extend({on:function(e,n,r,i,s){var o,u;if(typeof e=="object"){typeof n!="string"&&(r=r||n,n=t);for(u in e)this.on(u,n,r,e[u],s);return this}r==null&&i==null?(i=n,r=n=t):i==null&&(typeof n=="string"?(i=r,r=t):(i=r,r=n,n=t));if(i===!1)i=et;else if(!i)return this;return s===1&&(o=i,i=function(e){return v().off(e),o.apply(this,arguments)},i.guid=o.guid||(o.guid=v.guid++)),this.each(function(){v.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,s;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,v(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if(typeof e=="object"){for(s in e)this.off(s,n,e[s]);return this}if(n===!1||typeof n=="function")r=n,n=t;return r===!1&&(r=et),this.each(function(){v.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},live:function(e,t,n){return v(this.context).on(e,this.selector,t,n),this},die:function(e,t){return v(this.context).off(e,this.selector||"**",t),this},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return arguments.length===1?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){v.event.trigger(e,t,this)})},triggerHandler:function(e,t){if(this[0])return v.event.trigger(e,t,this[0],!0)},toggle:function(e){var t=arguments,n=e.guid||v.guid++,r=0,i=function(n){var i=(v._data(this,"lastToggle"+e.guid)||0)%r;return v._data(this,"lastToggle"+e.guid,i+1),n.preventDefault(),t[i].apply(this,arguments)||!1};i.guid=n;while(r<t.length)t[r++].guid=n;return this.click(i)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),v.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){v.fn[t]=function(e,n){return n==null&&(n=e,e=null),arguments.length>0?this.on(t,null,e,n):this.trigger(t)},Q.test(t)&&(v.event.fixHooks[t]=v.event.keyHooks),G.test(t)&&(v.event.fixHooks[t]=v.event.mouseHooks)}),function(e,t){function nt(e,t,n,r){n=n||[],t=t||g;var i,s,a,f,l=t.nodeType;if(!e||typeof e!="string")return n;if(l!==1&&l!==9)return[];a=o(t);if(!a&&!r)if(i=R.exec(e))if(f=i[1]){if(l===9){s=t.getElementById(f);if(!s||!s.parentNode)return n;if(s.id===f)return n.push(s),n}else if(t.ownerDocument&&(s=t.ownerDocument.getElementById(f))&&u(t,s)&&s.id===f)return n.push(s),n}else{if(i[2])return S.apply(n,x.call(t.getElementsByTagName(e),0)),n;if((f=i[3])&&Z&&t.getElementsByClassName)return S.apply(n,x.call(t.getElementsByClassName(f),0)),n}return vt(e.replace(j,"$1"),t,n,r,a)}function rt(e){return function(t){var n=t.nodeName.toLowerCase();return n==="input"&&t.type===e}}function it(e){return function(t){var n=t.nodeName.toLowerCase();return(n==="input"||n==="button")&&t.type===e}}function st(e){return N(function(t){return t=+t,N(function(n,r){var i,s=e([],n.length,t),o=s.length;while(o--)n[i=s[o]]&&(n[i]=!(r[i]=n[i]))})})}function ot(e,t,n){if(e===t)return n;var r=e.nextSibling;while(r){if(r===t)return-1;r=r.nextSibling}return 1}function ut(e,t){var n,r,s,o,u,a,f,l=L[d][e+" "];if(l)return t?0:l.slice(0);u=e,a=[],f=i.preFilter;while(u){if(!n||(r=F.exec(u)))r&&(u=u.slice(r[0].length)||u),a.push(s=[]);n=!1;if(r=I.exec(u))s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=r[0].replace(j," ");for(o in i.filter)(r=J[o].exec(u))&&(!f[o]||(r=f[o](r)))&&(s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=o,n.matches=r);if(!n)break}return t?u.length:u?nt.error(e):L(e,a).slice(0)}function at(e,t,r){var i=t.dir,s=r&&t.dir==="parentNode",o=w++;return t.first?function(t,n,r){while(t=t[i])if(s||t.nodeType===1)return e(t,n,r)}:function(t,r,u){if(!u){var a,f=b+" "+o+" ",l=f+n;while(t=t[i])if(s||t.nodeType===1){if((a=t[d])===l)return t.sizset;if(typeof a=="string"&&a.indexOf(f)===0){if(t.sizset)return t}else{t[d]=l;if(e(t,r,u))return t.sizset=!0,t;t.sizset=!1}}}else while(t=t[i])if(s||t.nodeType===1)if(e(t,r,u))return t}}function ft(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function lt(e,t,n,r,i){var s,o=[],u=0,a=e.length,f=t!=null;for(;u<a;u++)if(s=e[u])if(!n||n(s,r,i))o.push(s),f&&t.push(u);return o}function ct(e,t,n,r,i,s){return r&&!r[d]&&(r=ct(r)),i&&!i[d]&&(i=ct(i,s)),N(function(s,o,u,a){var f,l,c,h=[],p=[],d=o.length,v=s||dt(t||"*",u.nodeType?[u]:u,[]),m=e&&(s||!t)?lt(v,h,e,u,a):v,g=n?i||(s?e:d||r)?[]:o:m;n&&n(m,g,u,a);if(r){f=lt(g,p),r(f,[],u,a),l=f.length;while(l--)if(c=f[l])g[p[l]]=!(m[p[l]]=c)}if(s){if(i||e){if(i){f=[],l=g.length;while(l--)(c=g[l])&&f.push(m[l]=c);i(null,g=[],f,a)}l=g.length;while(l--)(c=g[l])&&(f=i?T.call(s,c):h[l])>-1&&(s[f]=!(o[f]=c))}}else g=lt(g===o?g.splice(d,g.length):g),i?i(null,o,g,a):S.apply(o,g)})}function ht(e){var t,n,r,s=e.length,o=i.relative[e[0].type],u=o||i.relative[" "],a=o?1:0,f=at(function(e){return e===t},u,!0),l=at(function(e){return T.call(t,e)>-1},u,!0),h=[function(e,n,r){return!o&&(r||n!==c)||((t=n).nodeType?f(e,n,r):l(e,n,r))}];for(;a<s;a++)if(n=i.relative[e[a].type])h=[at(ft(h),n)];else{n=i.filter[e[a].type].apply(null,e[a].matches);if(n[d]){r=++a;for(;r<s;r++)if(i.relative[e[r].type])break;return ct(a>1&&ft(h),a>1&&e.slice(0,a-1).join("").replace(j,"$1"),n,a<r&&ht(e.slice(a,r)),r<s&&ht(e=e.slice(r)),r<s&&e.join(""))}h.push(n)}return ft(h)}function pt(e,t){var r=t.length>0,s=e.length>0,o=function(u,a,f,l,h){var p,d,v,m=[],y=0,w="0",x=u&&[],T=h!=null,N=c,C=u||s&&i.find.TAG("*",h&&a.parentNode||a),k=b+=N==null?1:Math.E;T&&(c=a!==g&&a,n=o.el);for(;(p=C[w])!=null;w++){if(s&&p){for(d=0;v=e[d];d++)if(v(p,a,f)){l.push(p);break}T&&(b=k,n=++o.el)}r&&((p=!v&&p)&&y--,u&&x.push(p))}y+=w;if(r&&w!==y){for(d=0;v=t[d];d++)v(x,m,a,f);if(u){if(y>0)while(w--)!x[w]&&!m[w]&&(m[w]=E.call(l));m=lt(m)}S.apply(l,m),T&&!u&&m.length>0&&y+t.length>1&&nt.uniqueSort(l)}return T&&(b=k,c=N),x};return o.el=0,r?N(o):o}function dt(e,t,n){var r=0,i=t.length;for(;r<i;r++)nt(e,t[r],n);return n}function vt(e,t,n,r,s){var o,u,f,l,c,h=ut(e),p=h.length;if(!r&&h.length===1){u=h[0]=h[0].slice(0);if(u.length>2&&(f=u[0]).type==="ID"&&t.nodeType===9&&!s&&i.relative[u[1].type]){t=i.find.ID(f.matches[0].replace($,""),t,s)[0];if(!t)return n;e=e.slice(u.shift().length)}for(o=J.POS.test(e)?-1:u.length-1;o>=0;o--){f=u[o];if(i.relative[l=f.type])break;if(c=i.find[l])if(r=c(f.matches[0].replace($,""),z.test(u[0].type)&&t.parentNode||t,s)){u.splice(o,1),e=r.length&&u.join("");if(!e)return S.apply(n,x.call(r,0)),n;break}}}return a(e,h)(r,t,s,n,z.test(e)),n}function mt(){}var n,r,i,s,o,u,a,f,l,c,h=!0,p="undefined",d=("sizcache"+Math.random()).replace(".",""),m=String,g=e.document,y=g.documentElement,b=0,w=0,E=[].pop,S=[].push,x=[].slice,T=[].indexOf||function(e){var t=0,n=this.length;for(;t<n;t++)if(this[t]===e)return t;return-1},N=function(e,t){return e[d]=t==null||t,e},C=function(){var e={},t=[];return N(function(n,r){return t.push(n)>i.cacheLength&&delete e[t.shift()],e[n+" "]=r},e)},k=C(),L=C(),A=C(),O="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",_=M.replace("w","w#"),D="([*^$|!~]?=)",P="\\["+O+"*("+M+")"+O+"*(?:"+D+O+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+_+")|)|)"+O+"*\\]",H=":("+M+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:"+P+")|[^:]|\\\\.)*|.*))\\)|)",B=":(even|odd|eq|gt|lt|nth|first|last)(?:\\("+O+"*((?:-\\d)?\\d*)"+O+"*\\)|)(?=[^-]|$)",j=new RegExp("^"+O+"+|((?:^|[^\\\\])(?:\\\\.)*)"+O+"+$","g"),F=new RegExp("^"+O+"*,"+O+"*"),I=new RegExp("^"+O+"*([\\x20\\t\\r\\n\\f>+~])"+O+"*"),q=new RegExp(H),R=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,U=/^:not/,z=/[\x20\t\r\n\f]*[+~]/,W=/:not\($/,X=/h\d/i,V=/input|select|textarea|button/i,$=/\\(?!\\)/g,J={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),NAME:new RegExp("^\\[name=['\"]?("+M+")['\"]?\\]"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+H),POS:new RegExp(B,"i"),CHILD:new RegExp("^:(only|nth|first|last)-child(?:\\("+O+"*(even|odd|(([+-]|)(\\d*)n|)"+O+"*(?:([+-]|)"+O+"*(\\d+)|))"+O+"*\\)|)","i"),needsContext:new RegExp("^"+O+"*[>+~]|"+B,"i")},K=function(e){var t=g.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}},Q=K(function(e){return e.appendChild(g.createComment("")),!e.getElementsByTagName("*").length}),G=K(function(e){return e.innerHTML="<a href='#'></a>",e.firstChild&&typeof e.firstChild.getAttribute!==p&&e.firstChild.getAttribute("href")==="#"}),Y=K(function(e){e.innerHTML="<select></select>";var t=typeof e.lastChild.getAttribute("multiple");return t!=="boolean"&&t!=="string"}),Z=K(function(e){return e.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",!e.getElementsByClassName||!e.getElementsByClassName("e").length?!1:(e.lastChild.className="e",e.getElementsByClassName("e").length===2)}),et=K(function(e){e.id=d+0,e.innerHTML="<a name='"+d+"'></a><div name='"+d+"'></div>",y.insertBefore(e,y.firstChild);var t=g.getElementsByName&&g.getElementsByName(d).length===2+g.getElementsByName(d+0).length;return r=!g.getElementById(d),y.removeChild(e),t});try{x.call(y.childNodes,0)[0].nodeType}catch(tt){x=function(e){var t,n=[];for(;t=this[e];e++)n.push(t);return n}}nt.matches=function(e,t){return nt(e,null,null,t)},nt.matchesSelector=function(e,t){return nt(t,null,null,[e]).length>0},s=nt.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(i===1||i===9||i===11){if(typeof e.textContent=="string")return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=s(e)}else if(i===3||i===4)return e.nodeValue}else for(;t=e[r];r++)n+=s(t);return n},o=nt.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?t.nodeName!=="HTML":!1},u=nt.contains=y.contains?function(e,t){var n=e.nodeType===9?e.documentElement:e,r=t&&t.parentNode;return e===r||!!(r&&r.nodeType===1&&n.contains&&n.contains(r))}:y.compareDocumentPosition?function(e,t){return t&&!!(e.compareDocumentPosition(t)&16)}:function(e,t){while(t=t.parentNode)if(t===e)return!0;return!1},nt.attr=function(e,t){var n,r=o(e);return r||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):r||Y?e.getAttribute(t):(n=e.getAttributeNode(t),n?typeof e[t]=="boolean"?e[t]?t:null:n.specified?n.value:null:null)},i=nt.selectors={cacheLength:50,createPseudo:N,match:J,attrHandle:G?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},find:{ID:r?function(e,t,n){if(typeof t.getElementById!==p&&!n){var r=t.getElementById(e);return r&&r.parentNode?[r]:[]}}:function(e,n,r){if(typeof n.getElementById!==p&&!r){var i=n.getElementById(e);return i?i.id===e||typeof i.getAttributeNode!==p&&i.getAttributeNode("id").value===e?[i]:t:[]}},TAG:Q?function(e,t){if(typeof t.getElementsByTagName!==p)return t.getElementsByTagName(e)}:function(e,t){var n=t.getElementsByTagName(e);if(e==="*"){var r,i=[],s=0;for(;r=n[s];s++)r.nodeType===1&&i.push(r);return i}return n},NAME:et&&function(e,t){if(typeof t.getElementsByName!==p)return t.getElementsByName(name)},CLASS:Z&&function(e,t,n){if(typeof t.getElementsByClassName!==p&&!n)return t.getElementsByClassName(e)}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace($,""),e[3]=(e[4]||e[5]||"").replace($,""),e[2]==="~="&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),e[1]==="nth"?(e[2]||nt.error(e[0]),e[3]=+(e[3]?e[4]+(e[5]||1):2*(e[2]==="even"||e[2]==="odd")),e[4]=+(e[6]+e[7]||e[2]==="odd")):e[2]&&nt.error(e[0]),e},PSEUDO:function(e){var t,n;if(J.CHILD.test(e[0]))return null;if(e[3])e[2]=e[3];else if(t=e[4])q.test(t)&&(n=ut(t,!0))&&(n=t.indexOf(")",t.length-n)-t.length)&&(t=t.slice(0,n),e[0]=e[0].slice(0,n)),e[2]=t;return e.slice(0,3)}},filter:{ID:r?function(e){return e=e.replace($,""),function(t){return t.getAttribute("id")===e}}:function(e){return e=e.replace($,""),function(t){var n=typeof t.getAttributeNode!==p&&t.getAttributeNode("id");return n&&n.value===e}},TAG:function(e){return e==="*"?function(){return!0}:(e=e.replace($,"").toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[d][e+" "];return t||(t=new RegExp("(^|"+O+")"+e+"("+O+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==p&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r,i){var s=nt.attr(r,e);return s==null?t==="!=":t?(s+="",t==="="?s===n:t==="!="?s!==n:t==="^="?n&&s.indexOf(n)===0:t==="*="?n&&s.indexOf(n)>-1:t==="$="?n&&s.substr(s.length-n.length)===n:t==="~="?(" "+s+" ").indexOf(n)>-1:t==="|="?s===n||s.substr(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r){return e==="nth"?function(e){var t,i,s=e.parentNode;if(n===1&&r===0)return!0;if(s){i=0;for(t=s.firstChild;t;t=t.nextSibling)if(t.nodeType===1){i++;if(e===t)break}}return i-=r,i===n||i%n===0&&i/n>=0}:function(t){var n=t;switch(e){case"only":case"first":while(n=n.previousSibling)if(n.nodeType===1)return!1;if(e==="first")return!0;n=t;case"last":while(n=n.nextSibling)if(n.nodeType===1)return!1;return!0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||nt.error("unsupported pseudo: "+e);return r[d]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?N(function(e,n){var i,s=r(e,t),o=s.length;while(o--)i=T.call(e,s[o]),e[i]=!(n[i]=s[o])}):function(e){return r(e,0,n)}):r}},pseudos:{not:N(function(e){var t=[],n=[],r=a(e.replace(j,"$1"));return r[d]?N(function(e,t,n,i){var s,o=r(e,null,i,[]),u=e.length;while(u--)if(s=o[u])e[u]=!(t[u]=s)}):function(e,i,s){return t[0]=e,r(t,null,s,n),!n.pop()}}),has:N(function(e){return function(t){return nt(e,t).length>0}}),contains:N(function(e){return function(t){return(t.textContent||t.innerText||s(t)).indexOf(e)>-1}}),enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&!!e.checked||t==="option"&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},parent:function(e){return!i.pseudos.empty(e)},empty:function(e){var t;e=e.firstChild;while(e){if(e.nodeName>"@"||(t=e.nodeType)===3||t===4)return!1;e=e.nextSibling}return!0},header:function(e){return X.test(e.nodeName)},text:function(e){var t,n;return e.nodeName.toLowerCase()==="input"&&(t=e.type)==="text"&&((n=e.getAttribute("type"))==null||n.toLowerCase()===t)},radio:rt("radio"),checkbox:rt("checkbox"),file:rt("file"),password:rt("password"),image:rt("image"),submit:it("submit"),reset:it("reset"),button:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&e.type==="button"||t==="button"},input:function(e){return V.test(e.nodeName)},focus:function(e){var t=e.ownerDocument;return e===t.activeElement&&(!t.hasFocus||t.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},active:function(e){return e===e.ownerDocument.activeElement},first:st(function(){return[0]}),last:st(function(e,t){return[t-1]}),eq:st(function(e,t,n){return[n<0?n+t:n]}),even:st(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:st(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:st(function(e,t,n){for(var r=n<0?n+t:n;--r>=0;)e.push(r);return e}),gt:st(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}},f=y.compareDocumentPosition?function(e,t){return e===t?(l=!0,0):(!e.compareDocumentPosition||!t.compareDocumentPosition?e.compareDocumentPosition:e.compareDocumentPosition(t)&4)?-1:1}:function(e,t){if(e===t)return l=!0,0;if(e.sourceIndex&&t.sourceIndex)return e.sourceIndex-t.sourceIndex;var n,r,i=[],s=[],o=e.parentNode,u=t.parentNode,a=o;if(o===u)return ot(e,t);if(!o)return-1;if(!u)return 1;while(a)i.unshift(a),a=a.parentNode;a=u;while(a)s.unshift(a),a=a.parentNode;n=i.length,r=s.length;for(var f=0;f<n&&f<r;f++)if(i[f]!==s[f])return ot(i[f],s[f]);return f===n?ot(e,s[f],-1):ot(i[f],t,1)},[0,0].sort(f),h=!l,nt.uniqueSort=function(e){var t,n=[],r=1,i=0;l=h,e.sort(f);if(l){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e},nt.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},a=nt.compile=function(e,t){var n,r=[],i=[],s=A[d][e+" "];if(!s){t||(t=ut(e)),n=t.length;while(n--)s=ht(t[n]),s[d]?r.push(s):i.push(s);s=A(e,pt(i,r))}return s},g.querySelectorAll&&function(){var e,t=vt,n=/'|\\/g,r=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,i=[":focus"],s=[":active"],u=y.matchesSelector||y.mozMatchesSelector||y.webkitMatchesSelector||y.oMatchesSelector||y.msMatchesSelector;K(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||i.push("\\["+O+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||i.push(":checked")}),K(function(e){e.innerHTML="<p test=''></p>",e.querySelectorAll("[test^='']").length&&i.push("[*^$]="+O+"*(?:\"\"|'')"),e.innerHTML="<input type='hidden'/>",e.querySelectorAll(":enabled").length||i.push(":enabled",":disabled")}),i=new RegExp(i.join("|")),vt=function(e,r,s,o,u){if(!o&&!u&&!i.test(e)){var a,f,l=!0,c=d,h=r,p=r.nodeType===9&&e;if(r.nodeType===1&&r.nodeName.toLowerCase()!=="object"){a=ut(e),(l=r.getAttribute("id"))?c=l.replace(n,"\\$&"):r.setAttribute("id",c),c="[id='"+c+"'] ",f=a.length;while(f--)a[f]=c+a[f].join("");h=z.test(e)&&r.parentNode||r,p=a.join(",")}if(p)try{return S.apply(s,x.call(h.querySelectorAll(p),0)),s}catch(v){}finally{l||r.removeAttribute("id")}}return t(e,r,s,o,u)},u&&(K(function(t){e=u.call(t,"div");try{u.call(t,"[test!='']:sizzle"),s.push("!=",H)}catch(n){}}),s=new RegExp(s.join("|")),nt.matchesSelector=function(t,n){n=n.replace(r,"='$1']");if(!o(t)&&!s.test(n)&&!i.test(n))try{var a=u.call(t,n);if(a||e||t.document&&t.document.nodeType!==11)return a}catch(f){}return nt(n,null,null,[t]).length>0})}(),i.pseudos.nth=i.pseudos.eq,i.filters=mt.prototype=i.pseudos,i.setFilters=new mt,nt.attr=v.attr,v.find=nt,v.expr=nt.selectors,v.expr[":"]=v.expr.pseudos,v.unique=nt.uniqueSort,v.text=nt.getText,v.isXMLDoc=nt.isXML,v.contains=nt.contains}(e);var nt=/Until$/,rt=/^(?:parents|prev(?:Until|All))/,it=/^.[^:#\[\.,]*$/,st=v.expr.match.needsContext,ot={children:!0,contents:!0,next:!0,prev:!0};v.fn.extend({find:function(e){var t,n,r,i,s,o,u=this;if(typeof e!="string")return v(e).filter(function(){for(t=0,n=u.length;t<n;t++)if(v.contains(u[t],this))return!0});o=this.pushStack("","find",e);for(t=0,n=this.length;t<n;t++){r=o.length,v.find(e,this[t],o);if(t>0)for(i=r;i<o.length;i++)for(s=0;s<r;s++)if(o[s]===o[i]){o.splice(i--,1);break}}return o},has:function(e){var t,n=v(e,this),r=n.length;return this.filter(function(){for(t=0;t<r;t++)if(v.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1),"not",e)},filter:function(e){return this.pushStack(ft(this,e,!0),"filter",e)},is:function(e){return!!e&&(typeof e=="string"?st.test(e)?v(e,this.context).index(this[0])>=0:v.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,s=[],o=st.test(e)||typeof e!="string"?v(e,t||this.context):0;for(;r<i;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&n.nodeType!==11){if(o?o.index(n)>-1:v.find.matchesSelector(n,e)){s.push(n);break}n=n.parentNode}}return s=s.length>1?v.unique(s):s,this.pushStack(s,"closest",e)},index:function(e){return e?typeof e=="string"?v.inArray(this[0],v(e)):v.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(e,t){var n=typeof e=="string"?v(e,t):v.makeArray(e&&e.nodeType?[e]:e),r=v.merge(this.get(),n);return this.pushStack(ut(n[0])||ut(r[0])?r:v.unique(r))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}}),v.fn.andSelf=v.fn.addBack,v.each({parent:function(e){var t=e.parentNode;return t&&t.nodeType!==11?t:null},parents:function(e){return v.dir(e,"parentNode")},parentsUntil:function(e,t,n){return v.dir(e,"parentNode",n)},next:function(e){return at(e,"nextSibling")},prev:function(e){return at(e,"previousSibling")},nextAll:function(e){return v.dir(e,"nextSibling")},prevAll:function(e){return v.dir(e,"previousSibling")},nextUntil:function(e,t,n){return v.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return v.dir(e,"previousSibling",n)},siblings:function(e){return v.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return v.sibling(e.firstChild)},contents:function(e){return v.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:v.merge([],e.childNodes)}},function(e,t){v.fn[e]=function(n,r){var i=v.map(this,t,n);return nt.test(e)||(r=n),r&&typeof r=="string"&&(i=v.filter(r,i)),i=this.length>1&&!ot[e]?v.unique(i):i,this.length>1&&rt.test(e)&&(i=i.reverse()),this.pushStack(i,e,l.call(arguments).join(","))}}),v.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),t.length===1?v.find.matchesSelector(t[0],e)?[t[0]]:[]:v.find.matches(e,t)},dir:function(e,n,r){var i=[],s=e[n];while(s&&s.nodeType!==9&&(r===t||s.nodeType!==1||!v(s).is(r)))s.nodeType===1&&i.push(s),s=s[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)e.nodeType===1&&e!==t&&n.push(e);return n}});var ct="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",ht=/ jQuery\d+="(?:null|\d+)"/g,pt=/^\s+/,dt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,vt=/<([\w:]+)/,mt=/<tbody/i,gt=/<|&#?\w+;/,yt=/<(?:script|style|link)/i,bt=/<(?:script|object|embed|option|style)/i,wt=new RegExp("<(?:"+ct+")[\\s/>]","i"),Et=/^(?:checkbox|radio)$/,St=/checked\s*(?:[^=]|=\s*.checked.)/i,xt=/\/(java|ecma)script/i,Tt=/^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,Nt={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},Ct=lt(i),kt=Ct.appendChild(i.createElement("div"));Nt.optgroup=Nt.option,Nt.tbody=Nt.tfoot=Nt.colgroup=Nt.caption=Nt.thead,Nt.th=Nt.td,v.support.htmlSerialize||(Nt._default=[1,"X<div>","</div>"]),v.fn.extend({text:function(e){return v.access(this,function(e){return e===t?v.text(this):this.empty().append((this[0]&&this[0].ownerDocument||i).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(v.isFunction(e))return this.each(function(t){v(this).wrapAll(e.call(this,t))});if(this[0]){var t=v(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&e.firstChild.nodeType===1)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return v.isFunction(e)?this.each(function(t){v(this).wrapInner(e.call(this,t))}):this.each(function(){var t=v(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=v.isFunction(e);return this.each(function(n){v(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){v.nodeName(this,"body")||v(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(e,this.firstChild)})},before:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(e,this),"before",this.selector)}},after:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this.nextSibling)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(this,e),"after",this.selector)}},remove:function(e,t){var n,r=0;for(;(n=this[r])!=null;r++)if(!e||v.filter(e,[n]).length)!t&&n.nodeType===1&&(v.cleanData(n.getElementsByTagName("*")),v.cleanData([n])),n.parentNode&&n.parentNode.removeChild(n);return this},empty:function(){var e,t=0;for(;(e=this[t])!=null;t++){e.nodeType===1&&v.cleanData(e.getElementsByTagName("*"));while(e.firstChild)e.removeChild(e.firstChild)}return this},clone:function(e,t){return e=e==null?!1:e,t=t==null?e:t,this.map(function(){return v.clone(this,e,t)})},html:function(e){return v.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return n.nodeType===1?n.innerHTML.replace(ht,""):t;if(typeof e=="string"&&!yt.test(e)&&(v.support.htmlSerialize||!wt.test(e))&&(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt.exec(e)||["",""])[1].toLowerCase()]){e=e.replace(dt,"<$1></$2>");try{for(;r<i;r++)n=this[r]||{},n.nodeType===1&&(v.cleanData(n.getElementsByTagName("*")),n.innerHTML=e);n=0}catch(s){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){return ut(this[0])?this.length?this.pushStack(v(v.isFunction(e)?e():e),"replaceWith",e):this:v.isFunction(e)?this.each(function(t){var n=v(this),r=n.html();n.replaceWith(e.call(this,t,r))}):(typeof e!="string"&&(e=v(e).detach()),this.each(function(){var t=this.nextSibling,n=this.parentNode;v(this).remove(),t?v(t).before(e):v(n).append(e)}))},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=[].concat.apply([],e);var i,s,o,u,a=0,f=e[0],l=[],c=this.length;if(!v.support.checkClone&&c>1&&typeof f=="string"&&St.test(f))return this.each(function(){v(this).domManip(e,n,r)});if(v.isFunction(f))return this.each(function(i){var s=v(this);e[0]=f.call(this,i,n?s.html():t),s.domManip(e,n,r)});if(this[0]){i=v.buildFragment(e,this,l),o=i.fragment,s=o.firstChild,o.childNodes.length===1&&(o=s);if(s){n=n&&v.nodeName(s,"tr");for(u=i.cacheable||c-1;a<c;a++)r.call(n&&v.nodeName(this[a],"table")?Lt(this[a],"tbody"):this[a],a===u?o:v.clone(o,!0,!0))}o=s=null,l.length&&v.each(l,function(e,t){t.src?v.ajax?v.ajax({url:t.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):v.error("no ajax"):v.globalEval((t.text||t.textContent||t.innerHTML||"").replace(Tt,"")),t.parentNode&&t.parentNode.removeChild(t)})}return this}}),v.buildFragment=function(e,n,r){var s,o,u,a=e[0];return n=n||i,n=!n.nodeType&&n[0]||n,n=n.ownerDocument||n,e.length===1&&typeof a=="string"&&a.length<512&&n===i&&a.charAt(0)==="<"&&!bt.test(a)&&(v.support.checkClone||!St.test(a))&&(v.support.html5Clone||!wt.test(a))&&(o=!0,s=v.fragments[a],u=s!==t),s||(s=n.createDocumentFragment(),v.clean(e,n,s,r),o&&(v.fragments[a]=u&&s)),{fragment:s,cacheable:o}},v.fragments={},v.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){v.fn[e]=function(n){var r,i=0,s=[],o=v(n),u=o.length,a=this.length===1&&this[0].parentNode;if((a==null||a&&a.nodeType===11&&a.childNodes.length===1)&&u===1)return o[t](this[0]),this;for(;i<u;i++)r=(i>0?this.clone(!0):this).get(),v(o[i])[t](r),s=s.concat(r);return this.pushStack(s,e,o.selector)}}),v.extend({clone:function(e,t,n){var r,i,s,o;v.support.html5Clone||v.isXMLDoc(e)||!wt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(kt.innerHTML=e.outerHTML,kt.removeChild(o=kt.firstChild));if((!v.support.noCloneEvent||!v.support.noCloneChecked)&&(e.nodeType===1||e.nodeType===11)&&!v.isXMLDoc(e)){Ot(e,o),r=Mt(e),i=Mt(o);for(s=0;r[s];++s)i[s]&&Ot(r[s],i[s])}if(t){At(e,o);if(n){r=Mt(e),i=Mt(o);for(s=0;r[s];++s)At(r[s],i[s])}}return r=i=null,o},clean:function(e,t,n,r){var s,o,u,a,f,l,c,h,p,d,m,g,y=t===i&&Ct,b=[];if(!t||typeof t.createDocumentFragment=="undefined")t=i;for(s=0;(u=e[s])!=null;s++){typeof u=="number"&&(u+="");if(!u)continue;if(typeof u=="string")if(!gt.test(u))u=t.createTextNode(u);else{y=y||lt(t),c=t.createElement("div"),y.appendChild(c),u=u.replace(dt,"<$1></$2>"),a=(vt.exec(u)||["",""])[1].toLowerCase(),f=Nt[a]||Nt._default,l=f[0],c.innerHTML=f[1]+u+f[2];while(l--)c=c.lastChild;if(!v.support.tbody){h=mt.test(u),p=a==="table"&&!h?c.firstChild&&c.firstChild.childNodes:f[1]==="<table>"&&!h?c.childNodes:[];for(o=p.length-1;o>=0;--o)v.nodeName(p[o],"tbody")&&!p[o].childNodes.length&&p[o].parentNode.removeChild(p[o])}!v.support.leadingWhitespace&&pt.test(u)&&c.insertBefore(t.createTextNode(pt.exec(u)[0]),c.firstChild),u=c.childNodes,c.parentNode.removeChild(c)}u.nodeType?b.push(u):v.merge(b,u)}c&&(u=c=y=null);if(!v.support.appendChecked)for(s=0;(u=b[s])!=null;s++)v.nodeName(u,"input")?_t(u):typeof u.getElementsByTagName!="undefined"&&v.grep(u.getElementsByTagName("input"),_t);if(n){m=function(e){if(!e.type||xt.test(e.type))return r?r.push(e.parentNode?e.parentNode.removeChild(e):e):n.appendChild(e)};for(s=0;(u=b[s])!=null;s++)if(!v.nodeName(u,"script")||!m(u))n.appendChild(u),typeof u.getElementsByTagName!="undefined"&&(g=v.grep(v.merge([],u.getElementsByTagName("script")),m),b.splice.apply(b,[s+1,0].concat(g)),s+=g.length)}return b},cleanData:function(e,t){var n,r,i,s,o=0,u=v.expando,a=v.cache,f=v.support.deleteExpando,l=v.event.special;for(;(i=e[o])!=null;o++)if(t||v.acceptData(i)){r=i[u],n=r&&a[r];if(n){if(n.events)for(s in n.events)l[s]?v.event.remove(i,s):v.removeEvent(i,s,n.handle);a[r]&&(delete a[r],f?delete i[u]:i.removeAttribute?i.removeAttribute(u):i[u]=null,v.deletedIds.push(r))}}}}),function(){var e,t;v.uaMatch=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},e=v.uaMatch(o.userAgent),t={},e.browser&&(t[e.browser]=!0,t.version=e.version),t.chrome?t.webkit=!0:t.webkit&&(t.safari=!0),v.browser=t,v.sub=function(){function e(t,n){return new e.fn.init(t,n)}v.extend(!0,e,this),e.superclass=this,e.fn=e.prototype=this(),e.fn.constructor=e,e.sub=this.sub,e.fn.init=function(r,i){return i&&i instanceof v&&!(i instanceof e)&&(i=e(i)),v.fn.init.call(this,r,i,t)},e.fn.init.prototype=e.fn;var t=e(i);return e}}();var Dt,Pt,Ht,Bt=/alpha\([^)]*\)/i,jt=/opacity=([^)]*)/,Ft=/^(top|right|bottom|left)$/,It=/^(none|table(?!-c[ea]).+)/,qt=/^margin/,Rt=new RegExp("^("+m+")(.*)$","i"),Ut=new RegExp("^("+m+")(?!px)[a-z%]+$","i"),zt=new RegExp("^([-+])=("+m+")","i"),Wt={BODY:"block"},Xt={position:"absolute",visibility:"hidden",display:"block"},Vt={letterSpacing:0,fontWeight:400},$t=["Top","Right","Bottom","Left"],Jt=["Webkit","O","Moz","ms"],Kt=v.fn.toggle;v.fn.extend({css:function(e,n){return v.access(this,function(e,n,r){return r!==t?v.style(e,n,r):v.css(e,n)},e,n,arguments.length>1)},show:function(){return Yt(this,!0)},hide:function(){return Yt(this)},toggle:function(e,t){var n=typeof e=="boolean";return v.isFunction(e)&&v.isFunction(t)?Kt.apply(this,arguments):this.each(function(){(n?e:Gt(this))?v(this).show():v(this).hide()})}}),v.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Dt(e,"opacity");return n===""?"1":n}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":v.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(!e||e.nodeType===3||e.nodeType===8||!e.style)return;var s,o,u,a=v.camelCase(n),f=e.style;n=v.cssProps[a]||(v.cssProps[a]=Qt(f,a)),u=v.cssHooks[n]||v.cssHooks[a];if(r===t)return u&&"get"in u&&(s=u.get(e,!1,i))!==t?s:f[n];o=typeof r,o==="string"&&(s=zt.exec(r))&&(r=(s[1]+1)*s[2]+parseFloat(v.css(e,n)),o="number");if(r==null||o==="number"&&isNaN(r))return;o==="number"&&!v.cssNumber[a]&&(r+="px");if(!u||!("set"in u)||(r=u.set(e,r,i))!==t)try{f[n]=r}catch(l){}},css:function(e,n,r,i){var s,o,u,a=v.camelCase(n);return n=v.cssProps[a]||(v.cssProps[a]=Qt(e.style,a)),u=v.cssHooks[n]||v.cssHooks[a],u&&"get"in u&&(s=u.get(e,!0,i)),s===t&&(s=Dt(e,n)),s==="normal"&&n in Vt&&(s=Vt[n]),r||i!==t?(o=parseFloat(s),r||v.isNumeric(o)?o||0:s):s},swap:function(e,t,n){var r,i,s={};for(i in t)s[i]=e.style[i],e.style[i]=t[i];r=n.call(e);for(i in t)e.style[i]=s[i];return r}}),e.getComputedStyle?Dt=function(t,n){var r,i,s,o,u=e.getComputedStyle(t,null),a=t.style;return u&&(r=u.getPropertyValue(n)||u[n],r===""&&!v.contains(t.ownerDocument,t)&&(r=v.style(t,n)),Ut.test(r)&&qt.test(n)&&(i=a.width,s=a.minWidth,o=a.maxWidth,a.minWidth=a.maxWidth=a.width=r,r=u.width,a.width=i,a.minWidth=s,a.maxWidth=o)),r}:i.documentElement.currentStyle&&(Dt=function(e,t){var n,r,i=e.currentStyle&&e.currentStyle[t],s=e.style;return i==null&&s&&s[t]&&(i=s[t]),Ut.test(i)&&!Ft.test(t)&&(n=s.left,r=e.runtimeStyle&&e.runtimeStyle.left,r&&(e.runtimeStyle.left=e.currentStyle.left),s.left=t==="fontSize"?"1em":i,i=s.pixelLeft+"px",s.left=n,r&&(e.runtimeStyle.left=r)),i===""?"auto":i}),v.each(["height","width"],function(e,t){v.cssHooks[t]={get:function(e,n,r){if(n)return e.offsetWidth===0&&It.test(Dt(e,"display"))?v.swap(e,Xt,function(){return tn(e,t,r)}):tn(e,t,r)},set:function(e,n,r){return Zt(e,n,r?en(e,t,r,v.support.boxSizing&&v.css(e,"boxSizing")==="border-box"):0)}}}),v.support.opacity||(v.cssHooks.opacity={get:function(e,t){return jt.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=v.isNumeric(t)?"alpha(opacity="+t*100+")":"",s=r&&r.filter||n.filter||"";n.zoom=1;if(t>=1&&v.trim(s.replace(Bt,""))===""&&n.removeAttribute){n.removeAttribute("filter");if(r&&!r.filter)return}n.filter=Bt.test(s)?s.replace(Bt,i):s+" "+i}}),v(function(){v.support.reliableMarginRight||(v.cssHooks.marginRight={get:function(e,t){return v.swap(e,{display:"inline-block"},function(){if(t)return Dt(e,"marginRight")})}}),!v.support.pixelPosition&&v.fn.position&&v.each(["top","left"],function(e,t){v.cssHooks[t]={get:function(e,n){if(n){var r=Dt(e,t);return Ut.test(r)?v(e).position()[t]+"px":r}}}})}),v.expr&&v.expr.filters&&(v.expr.filters.hidden=function(e){return e.offsetWidth===0&&e.offsetHeight===0||!v.support.reliableHiddenOffsets&&(e.style&&e.style.display||Dt(e,"display"))==="none"},v.expr.filters.visible=function(e){return!v.expr.filters.hidden(e)}),v.each({margin:"",padding:"",border:"Width"},function(e,t){v.cssHooks[e+t]={expand:function(n){var r,i=typeof n=="string"?n.split(" "):[n],s={};for(r=0;r<4;r++)s[e+$t[r]+t]=i[r]||i[r-2]||i[0];return s}},qt.test(e)||(v.cssHooks[e+t].set=Zt)});var rn=/%20/g,sn=/\[\]$/,on=/\r?\n/g,un=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,an=/^(?:select|textarea)/i;v.fn.extend({serialize:function(){return v.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?v.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||an.test(this.nodeName)||un.test(this.type))}).map(function(e,t){var n=v(this).val();return n==null?null:v.isArray(n)?v.map(n,function(e,n){return{name:t.name,value:e.replace(on,"\r\n")}}):{name:t.name,value:n.replace(on,"\r\n")}}).get()}}),v.param=function(e,n){var r,i=[],s=function(e,t){t=v.isFunction(t)?t():t==null?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};n===t&&(n=v.ajaxSettings&&v.ajaxSettings.traditional);if(v.isArray(e)||e.jquery&&!v.isPlainObject(e))v.each(e,function(){s(this.name,this.value)});else for(r in e)fn(r,e[r],n,s);return i.join("&").replace(rn,"+")};var ln,cn,hn=/#.*$/,pn=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,dn=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,vn=/^(?:GET|HEAD)$/,mn=/^\/\//,gn=/\?/,yn=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bn=/([?&])_=[^&]*/,wn=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,En=v.fn.load,Sn={},xn={},Tn=["*/"]+["*"];try{cn=s.href}catch(Nn){cn=i.createElement("a"),cn.href="",cn=cn.href}ln=wn.exec(cn.toLowerCase())||[],v.fn.load=function(e,n,r){if(typeof e!="string"&&En)return En.apply(this,arguments);if(!this.length)return this;var i,s,o,u=this,a=e.indexOf(" ");return a>=0&&(i=e.slice(a,e.length),e=e.slice(0,a)),v.isFunction(n)?(r=n,n=t):n&&typeof n=="object"&&(s="POST"),v.ajax({url:e,type:s,dataType:"html",data:n,complete:function(e,t){r&&u.each(r,o||[e.responseText,t,e])}}).done(function(e){o=arguments,u.html(i?v("<div>").append(e.replace(yn,"")).find(i):e)}),this},v.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(e,t){v.fn[t]=function(e){return this.on(t,e)}}),v.each(["get","post"],function(e,n){v[n]=function(e,r,i,s){return v.isFunction(r)&&(s=s||i,i=r,r=t),v.ajax({type:n,url:e,data:r,success:i,dataType:s})}}),v.extend({getScript:function(e,n){return v.get(e,t,n,"script")},getJSON:function(e,t,n){return v.get(e,t,n,"json")},ajaxSetup:function(e,t){return t?Ln(e,v.ajaxSettings):(t=e,e=v.ajaxSettings),Ln(e,t),e},ajaxSettings:{url:cn,isLocal:dn.test(ln[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":Tn},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":v.parseJSON,"text xml":v.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:Cn(Sn),ajaxTransport:Cn(xn),ajax:function(e,n){function T(e,n,s,a){var l,y,b,w,S,T=n;if(E===2)return;E=2,u&&clearTimeout(u),o=t,i=a||"",x.readyState=e>0?4:0,s&&(w=An(c,x,s));if(e>=200&&e<300||e===304)c.ifModified&&(S=x.getResponseHeader("Last-Modified"),S&&(v.lastModified[r]=S),S=x.getResponseHeader("Etag"),S&&(v.etag[r]=S)),e===304?(T="notmodified",l=!0):(l=On(c,w),T=l.state,y=l.data,b=l.error,l=!b);else{b=T;if(!T||e)T="error",e<0&&(e=0)}x.status=e,x.statusText=(n||T)+"",l?d.resolveWith(h,[y,T,x]):d.rejectWith(h,[x,T,b]),x.statusCode(g),g=t,f&&p.trigger("ajax"+(l?"Success":"Error"),[x,c,l?y:b]),m.fireWith(h,[x,T]),f&&(p.trigger("ajaxComplete",[x,c]),--v.active||v.event.trigger("ajaxStop"))}typeof e=="object"&&(n=e,e=t),n=n||{};var r,i,s,o,u,a,f,l,c=v.ajaxSetup({},n),h=c.context||c,p=h!==c&&(h.nodeType||h instanceof v)?v(h):v.event,d=v.Deferred(),m=v.Callbacks("once memory"),g=c.statusCode||{},b={},w={},E=0,S="canceled",x={readyState:0,setRequestHeader:function(e,t){if(!E){var n=e.toLowerCase();e=w[n]=w[n]||e,b[e]=t}return this},getAllResponseHeaders:function(){return E===2?i:null},getResponseHeader:function(e){var n;if(E===2){if(!s){s={};while(n=pn.exec(i))s[n[1].toLowerCase()]=n[2]}n=s[e.toLowerCase()]}return n===t?null:n},overrideMimeType:function(e){return E||(c.mimeType=e),this},abort:function(e){return e=e||S,o&&o.abort(e),T(0,e),this}};d.promise(x),x.success=x.done,x.error=x.fail,x.complete=m.add,x.statusCode=function(e){if(e){var t;if(E<2)for(t in e)g[t]=[g[t],e[t]];else t=e[x.status],x.always(t)}return this},c.url=((e||c.url)+"").replace(hn,"").replace(mn,ln[1]+"//"),c.dataTypes=v.trim(c.dataType||"*").toLowerCase().split(y),c.crossDomain==null&&(a=wn.exec(c.url.toLowerCase()),c.crossDomain=!(!a||a[1]===ln[1]&&a[2]===ln[2]&&(a[3]||(a[1]==="http:"?80:443))==(ln[3]||(ln[1]==="http:"?80:443)))),c.data&&c.processData&&typeof c.data!="string"&&(c.data=v.param(c.data,c.traditional)),kn(Sn,c,n,x);if(E===2)return x;f=c.global,c.type=c.type.toUpperCase(),c.hasContent=!vn.test(c.type),f&&v.active++===0&&v.event.trigger("ajaxStart");if(!c.hasContent){c.data&&(c.url+=(gn.test(c.url)?"&":"?")+c.data,delete c.data),r=c.url;if(c.cache===!1){var N=v.now(),C=c.url.replace(bn,"$1_="+N);c.url=C+(C===c.url?(gn.test(c.url)?"&":"?")+"_="+N:"")}}(c.data&&c.hasContent&&c.contentType!==!1||n.contentType)&&x.setRequestHeader("Content-Type",c.contentType),c.ifModified&&(r=r||c.url,v.lastModified[r]&&x.setRequestHeader("If-Modified-Since",v.lastModified[r]),v.etag[r]&&x.setRequestHeader("If-None-Match",v.etag[r])),x.setRequestHeader("Accept",c.dataTypes[0]&&c.accepts[c.dataTypes[0]]?c.accepts[c.dataTypes[0]]+(c.dataTypes[0]!=="*"?", "+Tn+"; q=0.01":""):c.accepts["*"]);for(l in c.headers)x.setRequestHeader(l,c.headers[l]);if(!c.beforeSend||c.beforeSend.call(h,x,c)!==!1&&E!==2){S="abort";for(l in{success:1,error:1,complete:1})x[l](c[l]);o=kn(xn,c,n,x);if(!o)T(-1,"No Transport");else{x.readyState=1,f&&p.trigger("ajaxSend",[x,c]),c.async&&c.timeout>0&&(u=setTimeout(function(){x.abort("timeout")},c.timeout));try{E=1,o.send(b,T)}catch(k){if(!(E<2))throw k;T(-1,k)}}return x}return x.abort()},active:0,lastModified:{},etag:{}});var Mn=[],_n=/\?/,Dn=/(=)\?(?=&|$)|\?\?/,Pn=v.now();v.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Mn.pop()||v.expando+"_"+Pn++;return this[e]=!0,e}}),v.ajaxPrefilter("json jsonp",function(n,r,i){var s,o,u,a=n.data,f=n.url,l=n.jsonp!==!1,c=l&&Dn.test(f),h=l&&!c&&typeof a=="string"&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Dn.test(a);if(n.dataTypes[0]==="jsonp"||c||h)return s=n.jsonpCallback=v.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,o=e[s],c?n.url=f.replace(Dn,"$1"+s):h?n.data=a.replace(Dn,"$1"+s):l&&(n.url+=(_n.test(f)?"&":"?")+n.jsonp+"="+s),n.converters["script json"]=function(){return u||v.error(s+" was not called"),u[0]},n.dataTypes[0]="json",e[s]=function(){u=arguments},i.always(function(){e[s]=o,n[s]&&(n.jsonpCallback=r.jsonpCallback,Mn.push(s)),u&&v.isFunction(o)&&o(u[0]),u=o=t}),"script"}),v.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(e){return v.globalEval(e),e}}}),v.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),v.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=i.head||i.getElementsByTagName("head")[0]||i.documentElement;return{send:function(s,o){n=i.createElement("script"),n.async="async",e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,i){if(i||!n.readyState||/loaded|complete/.test(n.readyState))n.onload=n.onreadystatechange=null,r&&n.parentNode&&r.removeChild(n),n=t,i||o(200,"success")},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(0,1)}}}});var Hn,Bn=e.ActiveXObject?function(){for(var e in Hn)Hn[e](0,1)}:!1,jn=0;v.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&Fn()||In()}:Fn,function(e){v.extend(v.support,{ajax:!!e,cors:!!e&&"withCredentials"in e})}(v.ajaxSettings.xhr()),v.support.ajax&&v.ajaxTransport(function(n){if(!n.crossDomain||v.support.cors){var r;return{send:function(i,s){var o,u,a=n.xhr();n.username?a.open(n.type,n.url,n.async,n.username,n.password):a.open(n.type,n.url,n.async);if(n.xhrFields)for(u in n.xhrFields)a[u]=n.xhrFields[u];n.mimeType&&a.overrideMimeType&&a.overrideMimeType(n.mimeType),!n.crossDomain&&!i["X-Requested-With"]&&(i["X-Requested-With"]="XMLHttpRequest");try{for(u in i)a.setRequestHeader(u,i[u])}catch(f){}a.send(n.hasContent&&n.data||null),r=function(e,i){var u,f,l,c,h;try{if(r&&(i||a.readyState===4)){r=t,o&&(a.onreadystatechange=v.noop,Bn&&delete Hn[o]);if(i)a.readyState!==4&&a.abort();else{u=a.status,l=a.getAllResponseHeaders(),c={},h=a.responseXML,h&&h.documentElement&&(c.xml=h);try{c.text=a.responseText}catch(p){}try{f=a.statusText}catch(p){f=""}!u&&n.isLocal&&!n.crossDomain?u=c.text?200:404:u===1223&&(u=204)}}}catch(d){i||s(-1,d)}c&&s(u,f,c,l)},n.async?a.readyState===4?setTimeout(r,0):(o=++jn,Bn&&(Hn||(Hn={},v(e).unload(Bn)),Hn[o]=r),a.onreadystatechange=r):r()},abort:function(){r&&r(0,1)}}}});var qn,Rn,Un=/^(?:toggle|show|hide)$/,zn=new RegExp("^(?:([-+])=|)("+m+")([a-z%]*)$","i"),Wn=/queueHooks$/,Xn=[Gn],Vn={"*":[function(e,t){var n,r,i=this.createTween(e,t),s=zn.exec(t),o=i.cur(),u=+o||0,a=1,f=20;if(s){n=+s[2],r=s[3]||(v.cssNumber[e]?"":"px");if(r!=="px"&&u){u=v.css(i.elem,e,!0)||n||1;do a=a||".5",u/=a,v.style(i.elem,e,u+r);while(a!==(a=i.cur()/o)&&a!==1&&--f)}i.unit=r,i.start=u,i.end=s[1]?u+(s[1]+1)*n:n}return i}]};v.Animation=v.extend(Kn,{tweener:function(e,t){v.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;r<i;r++)n=e[r],Vn[n]=Vn[n]||[],Vn[n].unshift(t)},prefilter:function(e,t){t?Xn.unshift(e):Xn.push(e)}}),v.Tween=Yn,Yn.prototype={constructor:Yn,init:function(e,t,n,r,i,s){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=s||(v.cssNumber[n]?"":"px")},cur:function(){var e=Yn.propHooks[this.prop];return e&&e.get?e.get(this):Yn.propHooks._default.get(this)},run:function(e){var t,n=Yn.propHooks[this.prop];return this.options.duration?this.pos=t=v.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):Yn.propHooks._default.set(this),this}},Yn.prototype.init.prototype=Yn.prototype,Yn.propHooks={_default:{get:function(e){var t;return e.elem[e.prop]==null||!!e.elem.style&&e.elem.style[e.prop]!=null?(t=v.css(e.elem,e.prop,!1,""),!t||t==="auto"?0:t):e.elem[e.prop]},set:function(e){v.fx.step[e.prop]?v.fx.step[e.prop](e):e.elem.style&&(e.elem.style[v.cssProps[e.prop]]!=null||v.cssHooks[e.prop])?v.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},Yn.propHooks.scrollTop=Yn.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},v.each(["toggle","show","hide"],function(e,t){var n=v.fn[t];v.fn[t]=function(r,i,s){return r==null||typeof r=="boolean"||!e&&v.isFunction(r)&&v.isFunction(i)?n.apply(this,arguments):this.animate(Zn(t,!0),r,i,s)}}),v.fn.extend({fadeTo:function(e,t,n,r){return this.filter(Gt).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=v.isEmptyObject(e),s=v.speed(t,n,r),o=function(){var t=Kn(this,v.extend({},e),s);i&&t.stop(!0)};return i||s.queue===!1?this.each(o):this.queue(s.queue,o)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return typeof e!="string"&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=e!=null&&e+"queueHooks",s=v.timers,o=v._data(this);if(n)o[n]&&o[n].stop&&i(o[n]);else for(n in o)o[n]&&o[n].stop&&Wn.test(n)&&i(o[n]);for(n=s.length;n--;)s[n].elem===this&&(e==null||s[n].queue===e)&&(s[n].anim.stop(r),t=!1,s.splice(n,1));(t||!r)&&v.dequeue(this,e)})}}),v.each({slideDown:Zn("show"),slideUp:Zn("hide"),slideToggle:Zn("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){v.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),v.speed=function(e,t,n){var r=e&&typeof e=="object"?v.extend({},e):{complete:n||!n&&t||v.isFunction(e)&&e,duration:e,easing:n&&t||t&&!v.isFunction(t)&&t};r.duration=v.fx.off?0:typeof r.duration=="number"?r.duration:r.duration in v.fx.speeds?v.fx.speeds[r.duration]:v.fx.speeds._default;if(r.queue==null||r.queue===!0)r.queue="fx";return r.old=r.complete,r.complete=function(){v.isFunction(r.old)&&r.old.call(this),r.queue&&v.dequeue(this,r.queue)},r},v.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},v.timers=[],v.fx=Yn.prototype.init,v.fx.tick=function(){var e,n=v.timers,r=0;qn=v.now();for(;r<n.length;r++)e=n[r],!e()&&n[r]===e&&n.splice(r--,1);n.length||v.fx.stop(),qn=t},v.fx.timer=function(e){e()&&v.timers.push(e)&&!Rn&&(Rn=setInterval(v.fx.tick,v.fx.interval))},v.fx.interval=13,v.fx.stop=function(){clearInterval(Rn),Rn=null},v.fx.speeds={slow:600,fast:200,_default:400},v.fx.step={},v.expr&&v.expr.filters&&(v.expr.filters.animated=function(e){return v.grep(v.timers,function(t){return e===t.elem}).length});var er=/^(?:body|html)$/i;v.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){v.offset.setOffset(this,e,t)});var n,r,i,s,o,u,a,f={top:0,left:0},l=this[0],c=l&&l.ownerDocument;if(!c)return;return(r=c.body)===l?v.offset.bodyOffset(l):(n=c.documentElement,v.contains(n,l)?(typeof l.getBoundingClientRect!="undefined"&&(f=l.getBoundingClientRect()),i=tr(c),s=n.clientTop||r.clientTop||0,o=n.clientLeft||r.clientLeft||0,u=i.pageYOffset||n.scrollTop,a=i.pageXOffset||n.scrollLeft,{top:f.top+u-s,left:f.left+a-o}):f)},v.offset={bodyOffset:function(e){var t=e.offsetTop,n=e.offsetLeft;return v.support.doesNotIncludeMarginInBodyOffset&&(t+=parseFloat(v.css(e,"marginTop"))||0,n+=parseFloat(v.css(e,"marginLeft"))||0),{top:t,left:n}},setOffset:function(e,t,n){var r=v.css(e,"position");r==="static"&&(e.style.position="relative");var i=v(e),s=i.offset(),o=v.css(e,"top"),u=v.css(e,"left"),a=(r==="absolute"||r==="fixed")&&v.inArray("auto",[o,u])>-1,f={},l={},c,h;a?(l=i.position(),c=l.top,h=l.left):(c=parseFloat(o)||0,h=parseFloat(u)||0),v.isFunction(t)&&(t=t.call(e,n,s)),t.top!=null&&(f.top=t.top-s.top+c),t.left!=null&&(f.left=t.left-s.left+h),"using"in t?t.using.call(e,f):i.css(f)}},v.fn.extend({position:function(){if(!this[0])return;var e=this[0],t=this.offsetParent(),n=this.offset(),r=er.test(t[0].nodeName)?{top:0,left:0}:t.offset();return n.top-=parseFloat(v.css(e,"marginTop"))||0,n.left-=parseFloat(v.css(e,"marginLeft"))||0,r.top+=parseFloat(v.css(t[0],"borderTopWidth"))||0,r.left+=parseFloat(v.css(t[0],"borderLeftWidth"))||0,{top:n.top-r.top,left:n.left-r.left}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||i.body;while(e&&!er.test(e.nodeName)&&v.css(e,"position")==="static")e=e.offsetParent;return e||i.body})}}),v.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);v.fn[e]=function(i){return v.access(this,function(e,i,s){var o=tr(e);if(s===t)return o?n in o?o[n]:o.document.documentElement[i]:e[i];o?o.scrollTo(r?v(o).scrollLeft():s,r?s:v(o).scrollTop()):e[i]=s},e,i,arguments.length,null)}}),v.each({Height:"height",Width:"width"},function(e,n){v.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){v.fn[i]=function(i,s){var o=arguments.length&&(r||typeof i!="boolean"),u=r||(i===!0||s===!0?"margin":"border");return v.access(this,function(n,r,i){var s;return v.isWindow(n)?n.document.documentElement["client"+e]:n.nodeType===9?(s=n.documentElement,Math.max(n.body["scroll"+e],s["scroll"+e],n.body["offset"+e],s["offset"+e],s["client"+e])):i===t?v.css(n,r,i,u):v.style(n,r,i,u)},n,o?i:t,o,null)}})}),e.jQuery=e.$=v,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return v})})(window);
\ No newline at end of file
src/web/js/jqueryui/jquery-ui-1.9.2.custom.js 14879(+14879 -0)
diff --git a/src/web/js/jqueryui/jquery-ui-1.9.2.custom.js b/src/web/js/jqueryui/jquery-ui-1.9.2.custom.js
new file mode 100644
index 0000000..58c89a4
--- /dev/null
+++ b/src/web/js/jqueryui/jquery-ui-1.9.2.custom.js
@@ -0,0 +1,14879 @@
+/*! jQuery UI - v1.9.2 - 2012-12-13
+* http://jqueryui.com
+* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.menu.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js, jquery.ui.effect.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js
+* Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */
+
+(function( $, undefined ) {
+
+var uuid = 0,
+ runiqueId = /^ui-id-\d+$/;
+
+// prevent duplicate loading
+// this is only a problem because we proxy existing functions
+// and we don't want to double proxy them
+$.ui = $.ui || {};
+if ( $.ui.version ) {
+ return;
+}
+
+$.extend( $.ui, {
+ version: "1.9.2",
+
+ keyCode: {
+ BACKSPACE: 8,
+ COMMA: 188,
+ DELETE: 46,
+ DOWN: 40,
+ END: 35,
+ ENTER: 13,
+ ESCAPE: 27,
+ HOME: 36,
+ LEFT: 37,
+ NUMPAD_ADD: 107,
+ NUMPAD_DECIMAL: 110,
+ NUMPAD_DIVIDE: 111,
+ NUMPAD_ENTER: 108,
+ NUMPAD_MULTIPLY: 106,
+ NUMPAD_SUBTRACT: 109,
+ PAGE_DOWN: 34,
+ PAGE_UP: 33,
+ PERIOD: 190,
+ RIGHT: 39,
+ SPACE: 32,
+ TAB: 9,
+ UP: 38
+ }
+});
+
+// plugins
+$.fn.extend({
+ _focus: $.fn.focus,
+ focus: function( delay, fn ) {
+ return typeof delay === "number" ?
+ this.each(function() {
+ var elem = this;
+ setTimeout(function() {
+ $( elem ).focus();
+ if ( fn ) {
+ fn.call( elem );
+ }
+ }, delay );
+ }) :
+ this._focus.apply( this, arguments );
+ },
+
+ scrollParent: function() {
+ var scrollParent;
+ if (($.ui.ie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
+ scrollParent = this.parents().filter(function() {
+ return (/(relative|absolute|fixed)/).test($.css(this,'position')) && (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
+ }).eq(0);
+ } else {
+ scrollParent = this.parents().filter(function() {
+ return (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
+ }).eq(0);
+ }
+
+ return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
+ },
+
+ zIndex: function( zIndex ) {
+ if ( zIndex !== undefined ) {
+ return this.css( "zIndex", zIndex );
+ }
+
+ if ( this.length ) {
+ var elem = $( this[ 0 ] ), position, value;
+ while ( elem.length && elem[ 0 ] !== document ) {
+ // Ignore z-index if position is set to a value where z-index is ignored by the browser
+ // This makes behavior of this function consistent across browsers
+ // WebKit always returns auto if the element is positioned
+ position = elem.css( "position" );
+ if ( position === "absolute" || position === "relative" || position === "fixed" ) {
+ // IE returns 0 when zIndex is not specified
+ // other browsers return a string
+ // we ignore the case of nested elements with an explicit value of 0
+ // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
+ value = parseInt( elem.css( "zIndex" ), 10 );
+ if ( !isNaN( value ) && value !== 0 ) {
+ return value;
+ }
+ }
+ elem = elem.parent();
+ }
+ }
+
+ return 0;
+ },
+
+ uniqueId: function() {
+ return this.each(function() {
+ if ( !this.id ) {
+ this.id = "ui-id-" + (++uuid);
+ }
+ });
+ },
+
+ removeUniqueId: function() {
+ return this.each(function() {
+ if ( runiqueId.test( this.id ) ) {
+ $( this ).removeAttr( "id" );
+ }
+ });
+ }
+});
+
+// selectors
+function focusable( element, isTabIndexNotNaN ) {
+ var map, mapName, img,
+ nodeName = element.nodeName.toLowerCase();
+ if ( "area" === nodeName ) {
+ map = element.parentNode;
+ mapName = map.name;
+ if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
+ return false;
+ }
+ img = $( "img[usemap=#" + mapName + "]" )[0];
+ return !!img && visible( img );
+ }
+ return ( /input|select|textarea|button|object/.test( nodeName ) ?
+ !element.disabled :
+ "a" === nodeName ?
+ element.href || isTabIndexNotNaN :
+ isTabIndexNotNaN) &&
+ // the element and all of its ancestors must be visible
+ visible( element );
+}
+
+function visible( element ) {
+ return $.expr.filters.visible( element ) &&
+ !$( element ).parents().andSelf().filter(function() {
+ return $.css( this, "visibility" ) === "hidden";
+ }).length;
+}
+
+$.extend( $.expr[ ":" ], {
+ data: $.expr.createPseudo ?
+ $.expr.createPseudo(function( dataName ) {
+ return function( elem ) {
+ return !!$.data( elem, dataName );
+ };
+ }) :
+ // support: jQuery <1.8
+ function( elem, i, match ) {
+ return !!$.data( elem, match[ 3 ] );
+ },
+
+ focusable: function( element ) {
+ return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
+ },
+
+ tabbable: function( element ) {
+ var tabIndex = $.attr( element, "tabindex" ),
+ isTabIndexNaN = isNaN( tabIndex );
+ return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
+ }
+});
+
+// support
+$(function() {
+ var body = document.body,
+ div = body.appendChild( div = document.createElement( "div" ) );
+
+ // access offsetHeight before setting the style to prevent a layout bug
+ // in IE 9 which causes the element to continue to take up space even
+ // after it is removed from the DOM (#8026)
+ div.offsetHeight;
+
+ $.extend( div.style, {
+ minHeight: "100px",
+ height: "auto",
+ padding: 0,
+ borderWidth: 0
+ });
+
+ $.support.minHeight = div.offsetHeight === 100;
+ $.support.selectstart = "onselectstart" in div;
+
+ // set display to none to avoid a layout bug in IE
+ // http://dev.jquery.com/ticket/4014
+ body.removeChild( div ).style.display = "none";
+});
+
+// support: jQuery <1.8
+if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
+ $.each( [ "Width", "Height" ], function( i, name ) {
+ var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
+ type = name.toLowerCase(),
+ orig = {
+ innerWidth: $.fn.innerWidth,
+ innerHeight: $.fn.innerHeight,
+ outerWidth: $.fn.outerWidth,
+ outerHeight: $.fn.outerHeight
+ };
+
+ function reduce( elem, size, border, margin ) {
+ $.each( side, function() {
+ size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
+ if ( border ) {
+ size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
+ }
+ if ( margin ) {
+ size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
+ }
+ });
+ return size;
+ }
+
+ $.fn[ "inner" + name ] = function( size ) {
+ if ( size === undefined ) {
+ return orig[ "inner" + name ].call( this );
+ }
+
+ return this.each(function() {
+ $( this ).css( type, reduce( this, size ) + "px" );
+ });
+ };
+
+ $.fn[ "outer" + name] = function( size, margin ) {
+ if ( typeof size !== "number" ) {
+ return orig[ "outer" + name ].call( this, size );
+ }
+
+ return this.each(function() {
+ $( this).css( type, reduce( this, size, true, margin ) + "px" );
+ });
+ };
+ });
+}
+
+// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
+if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
+ $.fn.removeData = (function( removeData ) {
+ return function( key ) {
+ if ( arguments.length ) {
+ return removeData.call( this, $.camelCase( key ) );
+ } else {
+ return removeData.call( this );
+ }
+ };
+ })( $.fn.removeData );
+}
+
+
+
+
+
+// deprecated
+
+(function() {
+ var uaMatch = /msie ([\w.]+)/.exec( navigator.userAgent.toLowerCase() ) || [];
+ $.ui.ie = uaMatch.length ? true : false;
+ $.ui.ie6 = parseFloat( uaMatch[ 1 ], 10 ) === 6;
+})();
+
+$.fn.extend({
+ disableSelection: function() {
+ return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
+ ".ui-disableSelection", function( event ) {
+ event.preventDefault();
+ });
+ },
+
+ enableSelection: function() {
+ return this.unbind( ".ui-disableSelection" );
+ }
+});
+
+$.extend( $.ui, {
+ // $.ui.plugin is deprecated. Use the proxy pattern instead.
+ plugin: {
+ add: function( module, option, set ) {
+ var i,
+ proto = $.ui[ module ].prototype;
+ for ( i in set ) {
+ proto.plugins[ i ] = proto.plugins[ i ] || [];
+ proto.plugins[ i ].push( [ option, set[ i ] ] );
+ }
+ },
+ call: function( instance, name, args ) {
+ var i,
+ set = instance.plugins[ name ];
+ if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
+ return;
+ }
+
+ for ( i = 0; i < set.length; i++ ) {
+ if ( instance.options[ set[ i ][ 0 ] ] ) {
+ set[ i ][ 1 ].apply( instance.element, args );
+ }
+ }
+ }
+ },
+
+ contains: $.contains,
+
+ // only used by resizable
+ hasScroll: function( el, a ) {
+
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
+ if ( $( el ).css( "overflow" ) === "hidden") {
+ return false;
+ }
+
+ var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
+ has = false;
+
+ if ( el[ scroll ] > 0 ) {
+ return true;
+ }
+
+ // TODO: determine which cases actually cause this to happen
+ // if the element doesn't have the scroll set, see if it's possible to
+ // set the scroll
+ el[ scroll ] = 1;
+ has = ( el[ scroll ] > 0 );
+ el[ scroll ] = 0;
+ return has;
+ },
+
+ // these are odd functions, fix the API or move into individual plugins
+ isOverAxis: function( x, reference, size ) {
+ //Determines when x coordinate is over "b" element axis
+ return ( x > reference ) && ( x < ( reference + size ) );
+ },
+ isOver: function( y, x, top, left, height, width ) {
+ //Determines when x, y coordinates is over "b" element
+ return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
+ }
+});
+
+})( jQuery );
+(function( $, undefined ) {
+
+var uuid = 0,
+ slice = Array.prototype.slice,
+ _cleanData = $.cleanData;
+$.cleanData = function( elems ) {
+ for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
+ try {
+ $( elem ).triggerHandler( "remove" );
+ // http://bugs.jquery.com/ticket/8235
+ } catch( e ) {}
+ }
+ _cleanData( elems );
+};
+
+$.widget = function( name, base, prototype ) {
+ var fullName, existingConstructor, constructor, basePrototype,
+ namespace = name.split( "." )[ 0 ];
+
+ name = name.split( "." )[ 1 ];
+ fullName = namespace + "-" + name;
+
+ if ( !prototype ) {
+ prototype = base;
+ base = $.Widget;
+ }
+
+ // create selector for plugin
+ $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
+ return !!$.data( elem, fullName );
+ };
+
+ $[ namespace ] = $[ namespace ] || {};
+ existingConstructor = $[ namespace ][ name ];
+ constructor = $[ namespace ][ name ] = function( options, element ) {
+ // allow instantiation without "new" keyword
+ if ( !this._createWidget ) {
+ return new constructor( options, element );
+ }
+
+ // allow instantiation without initializing for simple inheritance
+ // must use "new" keyword (the code above always passes args)
+ if ( arguments.length ) {
+ this._createWidget( options, element );
+ }
+ };
+ // extend with the existing constructor to carry over any static properties
+ $.extend( constructor, existingConstructor, {
+ version: prototype.version,
+ // copy the object used to create the prototype in case we need to
+ // redefine the widget later
+ _proto: $.extend( {}, prototype ),
+ // track widgets that inherit from this widget in case this widget is
+ // redefined after a widget inherits from it
+ _childConstructors: []
+ });
+
+ basePrototype = new base();
+ // we need to make the options hash a property directly on the new instance
+ // otherwise we'll modify the options hash on the prototype that we're
+ // inheriting from
+ basePrototype.options = $.widget.extend( {}, basePrototype.options );
+ $.each( prototype, function( prop, value ) {
+ if ( $.isFunction( value ) ) {
+ prototype[ prop ] = (function() {
+ var _super = function() {
+ return base.prototype[ prop ].apply( this, arguments );
+ },
+ _superApply = function( args ) {
+ return base.prototype[ prop ].apply( this, args );
+ };
+ return function() {
+ var __super = this._super,
+ __superApply = this._superApply,
+ returnValue;
+
+ this._super = _super;
+ this._superApply = _superApply;
+
+ returnValue = value.apply( this, arguments );
+
+ this._super = __super;
+ this._superApply = __superApply;
+
+ return returnValue;
+ };
+ })();
+ }
+ });
+ constructor.prototype = $.widget.extend( basePrototype, {
+ // TODO: remove support for widgetEventPrefix
+ // always use the name + a colon as the prefix, e.g., draggable:start
+ // don't prefix for widgets that aren't DOM-based
+ widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
+ }, prototype, {
+ constructor: constructor,
+ namespace: namespace,
+ widgetName: name,
+ // TODO remove widgetBaseClass, see #8155
+ widgetBaseClass: fullName,
+ widgetFullName: fullName
+ });
+
+ // If this widget is being redefined then we need to find all widgets that
+ // are inheriting from it and redefine all of them so that they inherit from
+ // the new version of this widget. We're essentially trying to replace one
+ // level in the prototype chain.
+ if ( existingConstructor ) {
+ $.each( existingConstructor._childConstructors, function( i, child ) {
+ var childPrototype = child.prototype;
+
+ // redefine the child widget using the same prototype that was
+ // originally used, but inherit from the new version of the base
+ $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
+ });
+ // remove the list of existing child constructors from the old constructor
+ // so the old child constructors can be garbage collected
+ delete existingConstructor._childConstructors;
+ } else {
+ base._childConstructors.push( constructor );
+ }
+
+ $.widget.bridge( name, constructor );
+};
+
+$.widget.extend = function( target ) {
+ var input = slice.call( arguments, 1 ),
+ inputIndex = 0,
+ inputLength = input.length,
+ key,
+ value;
+ for ( ; inputIndex < inputLength; inputIndex++ ) {
+ for ( key in input[ inputIndex ] ) {
+ value = input[ inputIndex ][ key ];
+ if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
+ // Clone objects
+ if ( $.isPlainObject( value ) ) {
+ target[ key ] = $.isPlainObject( target[ key ] ) ?
+ $.widget.extend( {}, target[ key ], value ) :
+ // Don't extend strings, arrays, etc. with objects
+ $.widget.extend( {}, value );
+ // Copy everything else by reference
+ } else {
+ target[ key ] = value;
+ }
+ }
+ }
+ }
+ return target;
+};
+
+$.widget.bridge = function( name, object ) {
+ var fullName = object.prototype.widgetFullName || name;
+ $.fn[ name ] = function( options ) {
+ var isMethodCall = typeof options === "string",
+ args = slice.call( arguments, 1 ),
+ returnValue = this;
+
+ // allow multiple hashes to be passed on init
+ options = !isMethodCall && args.length ?
+ $.widget.extend.apply( null, [ options ].concat(args) ) :
+ options;
+
+ if ( isMethodCall ) {
+ this.each(function() {
+ var methodValue,
+ instance = $.data( this, fullName );
+ if ( !instance ) {
+ return $.error( "cannot call methods on " + name + " prior to initialization; " +
+ "attempted to call method '" + options + "'" );
+ }
+ if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
+ return $.error( "no such method '" + options + "' for " + name + " widget instance" );
+ }
+ methodValue = instance[ options ].apply( instance, args );
+ if ( methodValue !== instance && methodValue !== undefined ) {
+ returnValue = methodValue && methodValue.jquery ?
+ returnValue.pushStack( methodValue.get() ) :
+ methodValue;
+ return false;
+ }
+ });
+ } else {
+ this.each(function() {
+ var instance = $.data( this, fullName );
+ if ( instance ) {
+ instance.option( options || {} )._init();
+ } else {
+ $.data( this, fullName, new object( options, this ) );
+ }
+ });
+ }
+
+ return returnValue;
+ };
+};
+
+$.Widget = function( /* options, element */ ) {};
+$.Widget._childConstructors = [];
+
+$.Widget.prototype = {
+ widgetName: "widget",
+ widgetEventPrefix: "",
+ defaultElement: "<div>",
+ options: {
+ disabled: false,
+
+ // callbacks
+ create: null
+ },
+ _createWidget: function( options, element ) {
+ element = $( element || this.defaultElement || this )[ 0 ];
+ this.element = $( element );
+ this.uuid = uuid++;
+ this.eventNamespace = "." + this.widgetName + this.uuid;
+ this.options = $.widget.extend( {},
+ this.options,
+ this._getCreateOptions(),
+ options );
+
+ this.bindings = $();
+ this.hoverable = $();
+ this.focusable = $();
+
+ if ( element !== this ) {
+ // 1.9 BC for #7810
+ // TODO remove dual storage
+ $.data( element, this.widgetName, this );
+ $.data( element, this.widgetFullName, this );
+ this._on( true, this.element, {
+ remove: function( event ) {
+ if ( event.target === element ) {
+ this.destroy();
+ }
+ }
+ });
+ this.document = $( element.style ?
+ // element within the document
+ element.ownerDocument :
+ // element is window or document
+ element.document || element );
+ this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
+ }
+
+ this._create();
+ this._trigger( "create", null, this._getCreateEventData() );
+ this._init();
+ },
+ _getCreateOptions: $.noop,
+ _getCreateEventData: $.noop,
+ _create: $.noop,
+ _init: $.noop,
+
+ destroy: function() {
+ this._destroy();
+ // we can probably remove the unbind calls in 2.0
+ // all event bindings should go through this._on()
+ this.element
+ .unbind( this.eventNamespace )
+ // 1.9 BC for #7810
+ // TODO remove dual storage
+ .removeData( this.widgetName )
+ .removeData( this.widgetFullName )
+ // support: jquery <1.6.3
+ // http://bugs.jquery.com/ticket/9413
+ .removeData( $.camelCase( this.widgetFullName ) );
+ this.widget()
+ .unbind( this.eventNamespace )
+ .removeAttr( "aria-disabled" )
+ .removeClass(
+ this.widgetFullName + "-disabled " +
+ "ui-state-disabled" );
+
+ // clean up events and states
+ this.bindings.unbind( this.eventNamespace );
+ this.hoverable.removeClass( "ui-state-hover" );
+ this.focusable.removeClass( "ui-state-focus" );
+ },
+ _destroy: $.noop,
+
+ widget: function() {
+ return this.element;
+ },
+
+ option: function( key, value ) {
+ var options = key,
+ parts,
+ curOption,
+ i;
+
+ if ( arguments.length === 0 ) {
+ // don't return a reference to the internal hash
+ return $.widget.extend( {}, this.options );
+ }
+
+ if ( typeof key === "string" ) {
+ // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
+ options = {};
+ parts = key.split( "." );
+ key = parts.shift();
+ if ( parts.length ) {
+ curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
+ for ( i = 0; i < parts.length - 1; i++ ) {
+ curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
+ curOption = curOption[ parts[ i ] ];
+ }
+ key = parts.pop();
+ if ( value === undefined ) {
+ return curOption[ key ] === undefined ? null : curOption[ key ];
+ }
+ curOption[ key ] = value;
+ } else {
+ if ( value === undefined ) {
+ return this.options[ key ] === undefined ? null : this.options[ key ];
+ }
+ options[ key ] = value;
+ }
+ }
+
+ this._setOptions( options );
+
+ return this;
+ },
+ _setOptions: function( options ) {
+ var key;
+
+ for ( key in options ) {
+ this._setOption( key, options[ key ] );
+ }
+
+ return this;
+ },
+ _setOption: function( key, value ) {
+ this.options[ key ] = value;
+
+ if ( key === "disabled" ) {
+ this.widget()
+ .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
+ .attr( "aria-disabled", value );
+ this.hoverable.removeClass( "ui-state-hover" );
+ this.focusable.removeClass( "ui-state-focus" );
+ }
+
+ return this;
+ },
+
+ enable: function() {
+ return this._setOption( "disabled", false );
+ },
+ disable: function() {
+ return this._setOption( "disabled", true );
+ },
+
+ _on: function( suppressDisabledCheck, element, handlers ) {
+ var delegateElement,
+ instance = this;
+
+ // no suppressDisabledCheck flag, shuffle arguments
+ if ( typeof suppressDisabledCheck !== "boolean" ) {
+ handlers = element;
+ element = suppressDisabledCheck;
+ suppressDisabledCheck = false;
+ }
+
+ // no element argument, shuffle and use this.element
+ if ( !handlers ) {
+ handlers = element;
+ element = this.element;
+ delegateElement = this.widget();
+ } else {
+ // accept selectors, DOM elements
+ element = delegateElement = $( element );
+ this.bindings = this.bindings.add( element );
+ }
+
+ $.each( handlers, function( event, handler ) {
+ function handlerProxy() {
+ // allow widgets to customize the disabled handling
+ // - disabled as an array instead of boolean
+ // - disabled class as method for disabling individual parts
+ if ( !suppressDisabledCheck &&
+ ( instance.options.disabled === true ||
+ $( this ).hasClass( "ui-state-disabled" ) ) ) {
+ return;
+ }
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
+ .apply( instance, arguments );
+ }
+
+ // copy the guid so direct unbinding works
+ if ( typeof handler !== "string" ) {
+ handlerProxy.guid = handler.guid =
+ handler.guid || handlerProxy.guid || $.guid++;
+ }
+
+ var match = event.match( /^(\w+)\s*(.*)$/ ),
+ eventName = match[1] + instance.eventNamespace,
+ selector = match[2];
+ if ( selector ) {
+ delegateElement.delegate( selector, eventName, handlerProxy );
+ } else {
+ element.bind( eventName, handlerProxy );
+ }
+ });
+ },
+
+ _off: function( element, eventName ) {
+ eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
+ element.unbind( eventName ).undelegate( eventName );
+ },
+
+ _delay: function( handler, delay ) {
+ function handlerProxy() {
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
+ .apply( instance, arguments );
+ }
+ var instance = this;
+ return setTimeout( handlerProxy, delay || 0 );
+ },
+
+ _hoverable: function( element ) {
+ this.hoverable = this.hoverable.add( element );
+ this._on( element, {
+ mouseenter: function( event ) {
+ $( event.currentTarget ).addClass( "ui-state-hover" );
+ },
+ mouseleave: function( event ) {
+ $( event.currentTarget ).removeClass( "ui-state-hover" );
+ }
+ });
+ },
+
+ _focusable: function( element ) {
+ this.focusable = this.focusable.add( element );
+ this._on( element, {
+ focusin: function( event ) {
+ $( event.currentTarget ).addClass( "ui-state-focus" );
+ },
+ focusout: function( event ) {
+ $( event.currentTarget ).removeClass( "ui-state-focus" );
+ }
+ });
+ },
+
+ _trigger: function( type, event, data ) {
+ var prop, orig,
+ callback = this.options[ type ];
+
+ data = data || {};
+ event = $.Event( event );
+ event.type = ( type === this.widgetEventPrefix ?
+ type :
+ this.widgetEventPrefix + type ).toLowerCase();
+ // the original event may come from any element
+ // so we need to reset the target on the new event
+ event.target = this.element[ 0 ];
+
+ // copy original event properties over to the new event
+ orig = event.originalEvent;
+ if ( orig ) {
+ for ( prop in orig ) {
+ if ( !( prop in event ) ) {
+ event[ prop ] = orig[ prop ];
+ }
+ }
+ }
+
+ this.element.trigger( event, data );
+ return !( $.isFunction( callback ) &&
+ callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
+ event.isDefaultPrevented() );
+ }
+};
+
+$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
+ $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
+ if ( typeof options === "string" ) {
+ options = { effect: options };
+ }
+ var hasOptions,
+ effectName = !options ?
+ method :
+ options === true || typeof options === "number" ?
+ defaultEffect :
+ options.effect || defaultEffect;
+ options = options || {};
+ if ( typeof options === "number" ) {
+ options = { duration: options };
+ }
+ hasOptions = !$.isEmptyObject( options );
+ options.complete = callback;
+ if ( options.delay ) {
+ element.delay( options.delay );
+ }
+ if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) {
+ element[ method ]( options );
+ } else if ( effectName !== method && element[ effectName ] ) {
+ element[ effectName ]( options.duration, options.easing, callback );
+ } else {
+ element.queue(function( next ) {
+ $( this )[ method ]();
+ if ( callback ) {
+ callback.call( element[ 0 ] );
+ }
+ next();
+ });
+ }
+ };
+});
+
+// DEPRECATED
+if ( $.uiBackCompat !== false ) {
+ $.Widget.prototype._getCreateOptions = function() {
+ return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
+ };
+}
+
+})( jQuery );
+(function( $, undefined ) {
+
+var mouseHandled = false;
+$( document ).mouseup( function( e ) {
+ mouseHandled = false;
+});
+
+$.widget("ui.mouse", {
+ version: "1.9.2",
+ options: {
+ cancel: 'input,textarea,button,select,option',
+ distance: 1,
+ delay: 0
+ },
+ _mouseInit: function() {
+ var that = this;
+
+ this.element
+ .bind('mousedown.'+this.widgetName, function(event) {
+ return that._mouseDown(event);
+ })
+ .bind('click.'+this.widgetName, function(event) {
+ if (true === $.data(event.target, that.widgetName + '.preventClickEvent')) {
+ $.removeData(event.target, that.widgetName + '.preventClickEvent');
+ event.stopImmediatePropagation();
+ return false;
+ }
+ });
+
+ this.started = false;
+ },
+
+ // TODO: make sure destroying one instance of mouse doesn't mess with
+ // other instances of mouse
+ _mouseDestroy: function() {
+ this.element.unbind('.'+this.widgetName);
+ if ( this._mouseMoveDelegate ) {
+ $(document)
+ .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+ }
+ },
+
+ _mouseDown: function(event) {
+ // don't let more than one widget handle mouseStart
+ if( mouseHandled ) { return; }
+
+ // we may have missed mouseup (out of window)
+ (this._mouseStarted && this._mouseUp(event));
+
+ this._mouseDownEvent = event;
+
+ var that = this,
+ btnIsLeft = (event.which === 1),
+ // event.target.nodeName works around a bug in IE 8 with
+ // disabled inputs (#7620)
+ elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
+ if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
+ return true;
+ }
+
+ this.mouseDelayMet = !this.options.delay;
+ if (!this.mouseDelayMet) {
+ this._mouseDelayTimer = setTimeout(function() {
+ that.mouseDelayMet = true;
+ }, this.options.delay);
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted = (this._mouseStart(event) !== false);
+ if (!this._mouseStarted) {
+ event.preventDefault();
+ return true;
+ }
+ }
+
+ // Click event may never have fired (Gecko & Opera)
+ if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
+ $.removeData(event.target, this.widgetName + '.preventClickEvent');
+ }
+
+ // these delegates are required to keep context
+ this._mouseMoveDelegate = function(event) {
+ return that._mouseMove(event);
+ };
+ this._mouseUpDelegate = function(event) {
+ return that._mouseUp(event);
+ };
+ $(document)
+ .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ event.preventDefault();
+
+ mouseHandled = true;
+ return true;
+ },
+
+ _mouseMove: function(event) {
+ // IE mouseup check - mouseup happened when mouse was out of window
+ if ($.ui.ie && !(document.documentMode >= 9) && !event.button) {
+ return this._mouseUp(event);
+ }
+
+ if (this._mouseStarted) {
+ this._mouseDrag(event);
+ return event.preventDefault();
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted =
+ (this._mouseStart(this._mouseDownEvent, event) !== false);
+ (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
+ }
+
+ return !this._mouseStarted;
+ },
+
+ _mouseUp: function(event) {
+ $(document)
+ .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ if (this._mouseStarted) {
+ this._mouseStarted = false;
+
+ if (event.target === this._mouseDownEvent.target) {
+ $.data(event.target, this.widgetName + '.preventClickEvent', true);
+ }
+
+ this._mouseStop(event);
+ }
+
+ return false;
+ },
+
+ _mouseDistanceMet: function(event) {
+ return (Math.max(
+ Math.abs(this._mouseDownEvent.pageX - event.pageX),
+ Math.abs(this._mouseDownEvent.pageY - event.pageY)
+ ) >= this.options.distance
+ );
+ },
+
+ _mouseDelayMet: function(event) {
+ return this.mouseDelayMet;
+ },
+
+ // These are placeholder methods, to be overriden by extending plugin
+ _mouseStart: function(event) {},
+ _mouseDrag: function(event) {},
+ _mouseStop: function(event) {},
+ _mouseCapture: function(event) { return true; }
+});
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.ui = $.ui || {};
+
+var cachedScrollbarWidth,
+ max = Math.max,
+ abs = Math.abs,
+ round = Math.round,
+ rhorizontal = /left|center|right/,
+ rvertical = /top|center|bottom/,
+ roffset = /[\+\-]\d+%?/,
+ rposition = /^\w+/,
+ rpercent = /%$/,
+ _position = $.fn.position;
+
+function getOffsets( offsets, width, height ) {
+ return [
+ parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
+ parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
+ ];
+}
+function parseCss( element, property ) {
+ return parseInt( $.css( element, property ), 10 ) || 0;
+}
+
+$.position = {
+ scrollbarWidth: function() {
+ if ( cachedScrollbarWidth !== undefined ) {
+ return cachedScrollbarWidth;
+ }
+ var w1, w2,
+ div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
+ innerDiv = div.children()[0];
+
+ $( "body" ).append( div );
+ w1 = innerDiv.offsetWidth;
+ div.css( "overflow", "scroll" );
+
+ w2 = innerDiv.offsetWidth;
+
+ if ( w1 === w2 ) {
+ w2 = div[0].clientWidth;
+ }
+
+ div.remove();
+
+ return (cachedScrollbarWidth = w1 - w2);
+ },
+ getScrollInfo: function( within ) {
+ var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
+ overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
+ hasOverflowX = overflowX === "scroll" ||
+ ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
+ hasOverflowY = overflowY === "scroll" ||
+ ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
+ return {
+ width: hasOverflowX ? $.position.scrollbarWidth() : 0,
+ height: hasOverflowY ? $.position.scrollbarWidth() : 0
+ };
+ },
+ getWithinInfo: function( element ) {
+ var withinElement = $( element || window ),
+ isWindow = $.isWindow( withinElement[0] );
+ return {
+ element: withinElement,
+ isWindow: isWindow,
+ offset: withinElement.offset() || { left: 0, top: 0 },
+ scrollLeft: withinElement.scrollLeft(),
+ scrollTop: withinElement.scrollTop(),
+ width: isWindow ? withinElement.width() : withinElement.outerWidth(),
+ height: isWindow ? withinElement.height() : withinElement.outerHeight()
+ };
+ }
+};
+
+$.fn.position = function( options ) {
+ if ( !options || !options.of ) {
+ return _position.apply( this, arguments );
+ }
+
+ // make a copy, we don't want to modify arguments
+ options = $.extend( {}, options );
+
+ var atOffset, targetWidth, targetHeight, targetOffset, basePosition,
+ target = $( options.of ),
+ within = $.position.getWithinInfo( options.within ),
+ scrollInfo = $.position.getScrollInfo( within ),
+ targetElem = target[0],
+ collision = ( options.collision || "flip" ).split( " " ),
+ offsets = {};
+
+ if ( targetElem.nodeType === 9 ) {
+ targetWidth = target.width();
+ targetHeight = target.height();
+ targetOffset = { top: 0, left: 0 };
+ } else if ( $.isWindow( targetElem ) ) {
+ targetWidth = target.width();
+ targetHeight = target.height();
+ targetOffset = { top: target.scrollTop(), left: target.scrollLeft() };
+ } else if ( targetElem.preventDefault ) {
+ // force left top to allow flipping
+ options.at = "left top";
+ targetWidth = targetHeight = 0;
+ targetOffset = { top: targetElem.pageY, left: targetElem.pageX };
+ } else {
+ targetWidth = target.outerWidth();
+ targetHeight = target.outerHeight();
+ targetOffset = target.offset();
+ }
+ // clone to reuse original targetOffset later
+ basePosition = $.extend( {}, targetOffset );
+
+ // force my and at to have valid horizontal and vertical positions
+ // if a value is missing or invalid, it will be converted to center
+ $.each( [ "my", "at" ], function() {
+ var pos = ( options[ this ] || "" ).split( " " ),
+ horizontalOffset,
+ verticalOffset;
+
+ if ( pos.length === 1) {
+ pos = rhorizontal.test( pos[ 0 ] ) ?
+ pos.concat( [ "center" ] ) :
+ rvertical.test( pos[ 0 ] ) ?
+ [ "center" ].concat( pos ) :
+ [ "center", "center" ];
+ }
+ pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
+ pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
+
+ // calculate offsets
+ horizontalOffset = roffset.exec( pos[ 0 ] );
+ verticalOffset = roffset.exec( pos[ 1 ] );
+ offsets[ this ] = [
+ horizontalOffset ? horizontalOffset[ 0 ] : 0,
+ verticalOffset ? verticalOffset[ 0 ] : 0
+ ];
+
+ // reduce to just the positions without the offsets
+ options[ this ] = [
+ rposition.exec( pos[ 0 ] )[ 0 ],
+ rposition.exec( pos[ 1 ] )[ 0 ]
+ ];
+ });
+
+ // normalize collision option
+ if ( collision.length === 1 ) {
+ collision[ 1 ] = collision[ 0 ];
+ }
+
+ if ( options.at[ 0 ] === "right" ) {
+ basePosition.left += targetWidth;
+ } else if ( options.at[ 0 ] === "center" ) {
+ basePosition.left += targetWidth / 2;
+ }
+
+ if ( options.at[ 1 ] === "bottom" ) {
+ basePosition.top += targetHeight;
+ } else if ( options.at[ 1 ] === "center" ) {
+ basePosition.top += targetHeight / 2;
+ }
+
+ atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
+ basePosition.left += atOffset[ 0 ];
+ basePosition.top += atOffset[ 1 ];
+
+ return this.each(function() {
+ var collisionPosition, using,
+ elem = $( this ),
+ elemWidth = elem.outerWidth(),
+ elemHeight = elem.outerHeight(),
+ marginLeft = parseCss( this, "marginLeft" ),
+ marginTop = parseCss( this, "marginTop" ),
+ collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
+ collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
+ position = $.extend( {}, basePosition ),
+ myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
+
+ if ( options.my[ 0 ] === "right" ) {
+ position.left -= elemWidth;
+ } else if ( options.my[ 0 ] === "center" ) {
+ position.left -= elemWidth / 2;
+ }
+
+ if ( options.my[ 1 ] === "bottom" ) {
+ position.top -= elemHeight;
+ } else if ( options.my[ 1 ] === "center" ) {
+ position.top -= elemHeight / 2;
+ }
+
+ position.left += myOffset[ 0 ];
+ position.top += myOffset[ 1 ];
+
+ // if the browser doesn't support fractions, then round for consistent results
+ if ( !$.support.offsetFractions ) {
+ position.left = round( position.left );
+ position.top = round( position.top );
+ }
+
+ collisionPosition = {
+ marginLeft: marginLeft,
+ marginTop: marginTop
+ };
+
+ $.each( [ "left", "top" ], function( i, dir ) {
+ if ( $.ui.position[ collision[ i ] ] ) {
+ $.ui.position[ collision[ i ] ][ dir ]( position, {
+ targetWidth: targetWidth,
+ targetHeight: targetHeight,
+ elemWidth: elemWidth,
+ elemHeight: elemHeight,
+ collisionPosition: collisionPosition,
+ collisionWidth: collisionWidth,
+ collisionHeight: collisionHeight,
+ offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
+ my: options.my,
+ at: options.at,
+ within: within,
+ elem : elem
+ });
+ }
+ });
+
+ if ( $.fn.bgiframe ) {
+ elem.bgiframe();
+ }
+
+ if ( options.using ) {
+ // adds feedback as second argument to using callback, if present
+ using = function( props ) {
+ var left = targetOffset.left - position.left,
+ right = left + targetWidth - elemWidth,
+ top = targetOffset.top - position.top,
+ bottom = top + targetHeight - elemHeight,
+ feedback = {
+ target: {
+ element: target,
+ left: targetOffset.left,
+ top: targetOffset.top,
+ width: targetWidth,
+ height: targetHeight
+ },
+ element: {
+ element: elem,
+ left: position.left,
+ top: position.top,
+ width: elemWidth,
+ height: elemHeight
+ },
+ horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
+ vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
+ };
+ if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
+ feedback.horizontal = "center";
+ }
+ if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
+ feedback.vertical = "middle";
+ }
+ if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
+ feedback.important = "horizontal";
+ } else {
+ feedback.important = "vertical";
+ }
+ options.using.call( this, props, feedback );
+ };
+ }
+
+ elem.offset( $.extend( position, { using: using } ) );
+ });
+};
+
+$.ui.position = {
+ fit: {
+ left: function( position, data ) {
+ var within = data.within,
+ withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
+ outerWidth = within.width,
+ collisionPosLeft = position.left - data.collisionPosition.marginLeft,
+ overLeft = withinOffset - collisionPosLeft,
+ overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
+ newOverRight;
+
+ // element is wider than within
+ if ( data.collisionWidth > outerWidth ) {
+ // element is initially over the left side of within
+ if ( overLeft > 0 && overRight <= 0 ) {
+ newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
+ position.left += overLeft - newOverRight;
+ // element is initially over right side of within
+ } else if ( overRight > 0 && overLeft <= 0 ) {
+ position.left = withinOffset;
+ // element is initially over both left and right sides of within
+ } else {
+ if ( overLeft > overRight ) {
+ position.left = withinOffset + outerWidth - data.collisionWidth;
+ } else {
+ position.left = withinOffset;
+ }
+ }
+ // too far left -> align with left edge
+ } else if ( overLeft > 0 ) {
+ position.left += overLeft;
+ // too far right -> align with right edge
+ } else if ( overRight > 0 ) {
+ position.left -= overRight;
+ // adjust based on position and margin
+ } else {
+ position.left = max( position.left - collisionPosLeft, position.left );
+ }
+ },
+ top: function( position, data ) {
+ var within = data.within,
+ withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
+ outerHeight = data.within.height,
+ collisionPosTop = position.top - data.collisionPosition.marginTop,
+ overTop = withinOffset - collisionPosTop,
+ overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
+ newOverBottom;
+
+ // element is taller than within
+ if ( data.collisionHeight > outerHeight ) {
+ // element is initially over the top of within
+ if ( overTop > 0 && overBottom <= 0 ) {
+ newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
+ position.top += overTop - newOverBottom;
+ // element is initially over bottom of within
+ } else if ( overBottom > 0 && overTop <= 0 ) {
+ position.top = withinOffset;
+ // element is initially over both top and bottom of within
+ } else {
+ if ( overTop > overBottom ) {
+ position.top = withinOffset + outerHeight - data.collisionHeight;
+ } else {
+ position.top = withinOffset;
+ }
+ }
+ // too far up -> align with top
+ } else if ( overTop > 0 ) {
+ position.top += overTop;
+ // too far down -> align with bottom edge
+ } else if ( overBottom > 0 ) {
+ position.top -= overBottom;
+ // adjust based on position and margin
+ } else {
+ position.top = max( position.top - collisionPosTop, position.top );
+ }
+ }
+ },
+ flip: {
+ left: function( position, data ) {
+ var within = data.within,
+ withinOffset = within.offset.left + within.scrollLeft,
+ outerWidth = within.width,
+ offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
+ collisionPosLeft = position.left - data.collisionPosition.marginLeft,
+ overLeft = collisionPosLeft - offsetLeft,
+ overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
+ myOffset = data.my[ 0 ] === "left" ?
+ -data.elemWidth :
+ data.my[ 0 ] === "right" ?
+ data.elemWidth :
+ 0,
+ atOffset = data.at[ 0 ] === "left" ?
+ data.targetWidth :
+ data.at[ 0 ] === "right" ?
+ -data.targetWidth :
+ 0,
+ offset = -2 * data.offset[ 0 ],
+ newOverRight,
+ newOverLeft;
+
+ if ( overLeft < 0 ) {
+ newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
+ if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
+ position.left += myOffset + atOffset + offset;
+ }
+ }
+ else if ( overRight > 0 ) {
+ newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
+ if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
+ position.left += myOffset + atOffset + offset;
+ }
+ }
+ },
+ top: function( position, data ) {
+ var within = data.within,
+ withinOffset = within.offset.top + within.scrollTop,
+ outerHeight = within.height,
+ offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
+ collisionPosTop = position.top - data.collisionPosition.marginTop,
+ overTop = collisionPosTop - offsetTop,
+ overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
+ top = data.my[ 1 ] === "top",
+ myOffset = top ?
+ -data.elemHeight :
+ data.my[ 1 ] === "bottom" ?
+ data.elemHeight :
+ 0,
+ atOffset = data.at[ 1 ] === "top" ?
+ data.targetHeight :
+ data.at[ 1 ] === "bottom" ?
+ -data.targetHeight :
+ 0,
+ offset = -2 * data.offset[ 1 ],
+ newOverTop,
+ newOverBottom;
+ if ( overTop < 0 ) {
+ newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
+ if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
+ position.top += myOffset + atOffset + offset;
+ }
+ }
+ else if ( overBottom > 0 ) {
+ newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
+ if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
+ position.top += myOffset + atOffset + offset;
+ }
+ }
+ }
+ },
+ flipfit: {
+ left: function() {
+ $.ui.position.flip.left.apply( this, arguments );
+ $.ui.position.fit.left.apply( this, arguments );
+ },
+ top: function() {
+ $.ui.position.flip.top.apply( this, arguments );
+ $.ui.position.fit.top.apply( this, arguments );
+ }
+ }
+};
+
+// fraction support test
+(function () {
+ var testElement, testElementParent, testElementStyle, offsetLeft, i,
+ body = document.getElementsByTagName( "body" )[ 0 ],
+ div = document.createElement( "div" );
+
+ //Create a "fake body" for testing based on method used in jQuery.support
+ testElement = document.createElement( body ? "div" : "body" );
+ testElementStyle = {
+ visibility: "hidden",
+ width: 0,
+ height: 0,
+ border: 0,
+ margin: 0,
+ background: "none"
+ };
+ if ( body ) {
+ $.extend( testElementStyle, {
+ position: "absolute",
+ left: "-1000px",
+ top: "-1000px"
+ });
+ }
+ for ( i in testElementStyle ) {
+ testElement.style[ i ] = testElementStyle[ i ];
+ }
+ testElement.appendChild( div );
+ testElementParent = body || document.documentElement;
+ testElementParent.insertBefore( testElement, testElementParent.firstChild );
+
+ div.style.cssText = "position: absolute; left: 10.7432222px;";
+
+ offsetLeft = $( div ).offset().left;
+ $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
+
+ testElement.innerHTML = "";
+ testElementParent.removeChild( testElement );
+})();
+
+// DEPRECATED
+if ( $.uiBackCompat !== false ) {
+ // offset option
+ (function( $ ) {
+ var _position = $.fn.position;
+ $.fn.position = function( options ) {
+ if ( !options || !options.offset ) {
+ return _position.call( this, options );
+ }
+ var offset = options.offset.split( " " ),
+ at = options.at.split( " " );
+ if ( offset.length === 1 ) {
+ offset[ 1 ] = offset[ 0 ];
+ }
+ if ( /^\d/.test( offset[ 0 ] ) ) {
+ offset[ 0 ] = "+" + offset[ 0 ];
+ }
+ if ( /^\d/.test( offset[ 1 ] ) ) {
+ offset[ 1 ] = "+" + offset[ 1 ];
+ }
+ if ( at.length === 1 ) {
+ if ( /left|center|right/.test( at[ 0 ] ) ) {
+ at[ 1 ] = "center";
+ } else {
+ at[ 1 ] = at[ 0 ];
+ at[ 0 ] = "center";
+ }
+ }
+ return _position.call( this, $.extend( options, {
+ at: at[ 0 ] + offset[ 0 ] + " " + at[ 1 ] + offset[ 1 ],
+ offset: undefined
+ } ) );
+ };
+ }( jQuery ) );
+}
+
+}( jQuery ) );
+(function( $, undefined ) {
+
+$.widget("ui.draggable", $.ui.mouse, {
+ version: "1.9.2",
+ widgetEventPrefix: "drag",
+ options: {
+ addClasses: true,
+ appendTo: "parent",
+ axis: false,
+ connectToSortable: false,
+ containment: false,
+ cursor: "auto",
+ cursorAt: false,
+ grid: false,
+ handle: false,
+ helper: "original",
+ iframeFix: false,
+ opacity: false,
+ refreshPositions: false,
+ revert: false,
+ revertDuration: 500,
+ scope: "default",
+ scroll: true,
+ scrollSensitivity: 20,
+ scrollSpeed: 20,
+ snap: false,
+ snapMode: "both",
+ snapTolerance: 20,
+ stack: false,
+ zIndex: false
+ },
+ _create: function() {
+
+ if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
+ this.element[0].style.position = 'relative';
+
+ (this.options.addClasses && this.element.addClass("ui-draggable"));
+ (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
+
+ this._mouseInit();
+
+ },
+
+ _destroy: function() {
+ this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
+ this._mouseDestroy();
+ },
+
+ _mouseCapture: function(event) {
+
+ var o = this.options;
+
+ // among others, prevent a drag on a resizable-handle
+ if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
+ return false;
+
+ //Quit if we're not on a valid handle
+ this.handle = this._getHandle(event);
+ if (!this.handle)
+ return false;
+
+ $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
+ $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
+ .css({
+ width: this.offsetWidth+"px", height: this.offsetHeight+"px",
+ position: "absolute", opacity: "0.001", zIndex: 1000
+ })
+ .css($(this).offset())
+ .appendTo("body");
+ });
+
+ return true;
+
+ },
+
+ _mouseStart: function(event) {
+
+ var o = this.options;
+
+ //Create and append the visible helper
+ this.helper = this._createHelper(event);
+
+ this.helper.addClass("ui-draggable-dragging");
+
+ //Cache the helper size
+ this._cacheHelperProportions();
+
+ //If ddmanager is used for droppables, set the global draggable
+ if($.ui.ddmanager)
+ $.ui.ddmanager.current = this;
+
+ /*
+ * - Position generation -
+ * This block generates everything position related - it's the core of draggables.
+ */
+
+ //Cache the margins of the original element
+ this._cacheMargins();
+
+ //Store the helper's css position
+ this.cssPosition = this.helper.css("position");
+ this.scrollParent = this.helper.scrollParent();
+
+ //The element's absolute position on the page minus margins
+ this.offset = this.positionAbs = this.element.offset();
+ this.offset = {
+ top: this.offset.top - this.margins.top,
+ left: this.offset.left - this.margins.left
+ };
+
+ $.extend(this.offset, {
+ click: { //Where the click happened, relative to the element
+ left: event.pageX - this.offset.left,
+ top: event.pageY - this.offset.top
+ },
+ parent: this._getParentOffset(),
+ relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
+ });
+
+ //Generate the original position
+ this.originalPosition = this.position = this._generatePosition(event);
+ this.originalPageX = event.pageX;
+ this.originalPageY = event.pageY;
+
+ //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
+ (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
+
+ //Set a containment if given in the options
+ if(o.containment)
+ this._setContainment();
+
+ //Trigger event + callbacks
+ if(this._trigger("start", event) === false) {
+ this._clear();
+ return false;
+ }
+
+ //Recache the helper size
+ this._cacheHelperProportions();
+
+ //Prepare the droppable offsets
+ if ($.ui.ddmanager && !o.dropBehaviour)
+ $.ui.ddmanager.prepareOffsets(this, event);
+
+
+ this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
+
+ //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
+ if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
+
+ return true;
+ },
+
+ _mouseDrag: function(event, noPropagation) {
+
+ //Compute the helpers position
+ this.position = this._generatePosition(event);
+ this.positionAbs = this._convertPositionTo("absolute");
+
+ //Call plugins and callbacks and use the resulting position if something is returned
+ if (!noPropagation) {
+ var ui = this._uiHash();
+ if(this._trigger('drag', event, ui) === false) {
+ this._mouseUp({});
+ return false;
+ }
+ this.position = ui.position;
+ }
+
+ if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
+ if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
+
+ return false;
+ },
+
+ _mouseStop: function(event) {
+
+ //If we are using droppables, inform the manager about the drop
+ var dropped = false;
+ if ($.ui.ddmanager && !this.options.dropBehaviour)
+ dropped = $.ui.ddmanager.drop(this, event);
+
+ //if a drop comes from outside (a sortable)
+ if(this.dropped) {
+ dropped = this.dropped;
+ this.dropped = false;
+ }
+
+ //if the original element is no longer in the DOM don't bother to continue (see #8269)
+ var element = this.element[0], elementInDom = false;
+ while ( element && (element = element.parentNode) ) {
+ if (element == document ) {
+ elementInDom = true;
+ }
+ }
+ if ( !elementInDom && this.options.helper === "original" )
+ return false;
+
+ if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
+ var that = this;
+ $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
+ if(that._trigger("stop", event) !== false) {
+ that._clear();
+ }
+ });
+ } else {
+ if(this._trigger("stop", event) !== false) {
+ this._clear();
+ }
+ }
+
+ return false;
+ },
+
+ _mouseUp: function(event) {
+ //Remove frame helpers
+ $("div.ui-draggable-iframeFix").each(function() {
+ this.parentNode.removeChild(this);
+ });
+
+ //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
+ if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
+
+ return $.ui.mouse.prototype._mouseUp.call(this, event);
+ },
+
+ cancel: function() {
+
+ if(this.helper.is(".ui-draggable-dragging")) {
+ this._mouseUp({});
+ } else {
+ this._clear();
+ }
+
+ return this;
+
+ },
+
+ _getHandle: function(event) {
+
+ var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
+ $(this.options.handle, this.element)
+ .find("*")
+ .andSelf()
+ .each(function() {
+ if(this == event.target) handle = true;
+ });
+
+ return handle;
+
+ },
+
+ _createHelper: function(event) {
+
+ var o = this.options;
+ var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
+
+ if(!helper.parents('body').length)
+ helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
+
+ if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
+ helper.css("position", "absolute");
+
+ return helper;
+
+ },
+
+ _adjustOffsetFromHelper: function(obj) {
+ if (typeof obj == 'string') {
+ obj = obj.split(' ');
+ }
+ if ($.isArray(obj)) {
+ obj = {left: +obj[0], top: +obj[1] || 0};
+ }
+ if ('left' in obj) {
+ this.offset.click.left = obj.left + this.margins.left;
+ }
+ if ('right' in obj) {
+ this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
+ }
+ if ('top' in obj) {
+ this.offset.click.top = obj.top + this.margins.top;
+ }
+ if ('bottom' in obj) {
+ this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
+ }
+ },
+
+ _getParentOffset: function() {
+
+ //Get the offsetParent and cache its position
+ this.offsetParent = this.helper.offsetParent();
+ var po = this.offsetParent.offset();
+
+ // This is a special case where we need to modify a offset calculated on start, since the following happened:
+ // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
+ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
+ // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
+ if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
+ po.left += this.scrollParent.scrollLeft();
+ po.top += this.scrollParent.scrollTop();
+ }
+
+ if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
+ || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.ui.ie)) //Ugly IE fix
+ po = { top: 0, left: 0 };
+
+ return {
+ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
+ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
+ };
+
+ },
+
+ _getRelativeOffset: function() {
+
+ if(this.cssPosition == "relative") {
+ var p = this.element.position();
+ return {
+ top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
+ left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
+ };
+ } else {
+ return { top: 0, left: 0 };
+ }
+
+ },
+
+ _cacheMargins: function() {
+ this.margins = {
+ left: (parseInt(this.element.css("marginLeft"),10) || 0),
+ top: (parseInt(this.element.css("marginTop"),10) || 0),
+ right: (parseInt(this.element.css("marginRight"),10) || 0),
+ bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
+ };
+ },
+
+ _cacheHelperProportions: function() {
+ this.helperProportions = {
+ width: this.helper.outerWidth(),
+ height: this.helper.outerHeight()
+ };
+ },
+
+ _setContainment: function() {
+
+ var o = this.options;
+ if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
+ if(o.containment == 'document' || o.containment == 'window') this.containment = [
+ o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
+ o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
+ (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
+ (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
+ ];
+
+ if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
+ var c = $(o.containment);
+ var ce = c[0]; if(!ce) return;
+ var co = c.offset();
+ var over = ($(ce).css("overflow") != 'hidden');
+
+ this.containment = [
+ (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
+ (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
+ (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
+ (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom
+ ];
+ this.relative_container = c;
+
+ } else if(o.containment.constructor == Array) {
+ this.containment = o.containment;
+ }
+
+ },
+
+ _convertPositionTo: function(d, pos) {
+
+ if(!pos) pos = this.position;
+ var mod = d == "absolute" ? 1 : -1;
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+
+ return {
+ top: (
+ pos.top // The absolute mouse position
+ + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
+ + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
+ - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
+ ),
+ left: (
+ pos.left // The absolute mouse position
+ + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
+ + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
+ - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
+ )
+ };
+
+ },
+
+ _generatePosition: function(event) {
+
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ var pageX = event.pageX;
+ var pageY = event.pageY;
+
+ /*
+ * - Position constraining -
+ * Constrain the position to a mix of grid, containment.
+ */
+
+ if(this.originalPosition) { //If we are not dragging yet, we won't check for options
+ var containment;
+ if(this.containment) {
+ if (this.relative_container){
+ var co = this.relative_container.offset();
+ containment = [ this.containment[0] + co.left,
+ this.containment[1] + co.top,
+ this.containment[2] + co.left,
+ this.containment[3] + co.top ];
+ }
+ else {
+ containment = this.containment;
+ }
+
+ if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
+ if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
+ if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left;
+ if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top;
+ }
+
+ if(o.grid) {
+ //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
+ var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
+ pageY = containment ? (!(top - this.offset.click.top < containment[1] || top - this.offset.click.top > containment[3]) ? top : (!(top - this.offset.click.top < containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
+
+ var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
+ pageX = containment ? (!(left - this.offset.click.left < containment[0] || left - this.offset.click.left > containment[2]) ? left : (!(left - this.offset.click.left < containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
+ }
+
+ }
+
+ return {
+ top: (
+ pageY // The absolute mouse position
+ - this.offset.click.top // Click offset (relative to the element)
+ - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
+ - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
+ + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
+ ),
+ left: (
+ pageX // The absolute mouse position
+ - this.offset.click.left // Click offset (relative to the element)
+ - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
+ - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
+ + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
+ )
+ };
+
+ },
+
+ _clear: function() {
+ this.helper.removeClass("ui-draggable-dragging");
+ if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
+ //if($.ui.ddmanager) $.ui.ddmanager.current = null;
+ this.helper = null;
+ this.cancelHelperRemoval = false;
+ },
+
+ // From now on bulk stuff - mainly helpers
+
+ _trigger: function(type, event, ui) {
+ ui = ui || this._uiHash();
+ $.ui.plugin.call(this, type, [event, ui]);
+ if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
+ return $.Widget.prototype._trigger.call(this, type, event, ui);
+ },
+
+ plugins: {},
+
+ _uiHash: function(event) {
+ return {
+ helper: this.helper,
+ position: this.position,
+ originalPosition: this.originalPosition,
+ offset: this.positionAbs
+ };
+ }
+
+});
+
+$.ui.plugin.add("draggable", "connectToSortable", {
+ start: function(event, ui) {
+
+ var inst = $(this).data("draggable"), o = inst.options,
+ uiSortable = $.extend({}, ui, { item: inst.element });
+ inst.sortables = [];
+ $(o.connectToSortable).each(function() {
+ var sortable = $.data(this, 'sortable');
+ if (sortable && !sortable.options.disabled) {
+ inst.sortables.push({
+ instance: sortable,
+ shouldRevert: sortable.options.revert
+ });
+ sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
+ sortable._trigger("activate", event, uiSortable);
+ }
+ });
+
+ },
+ stop: function(event, ui) {
+
+ //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
+ var inst = $(this).data("draggable"),
+ uiSortable = $.extend({}, ui, { item: inst.element });
+
+ $.each(inst.sortables, function() {
+ if(this.instance.isOver) {
+
+ this.instance.isOver = 0;
+
+ inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
+ this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
+
+ //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
+ if(this.shouldRevert) this.instance.options.revert = true;
+
+ //Trigger the stop of the sortable
+ this.instance._mouseStop(event);
+
+ this.instance.options.helper = this.instance.options._helper;
+
+ //If the helper has been the original item, restore properties in the sortable
+ if(inst.options.helper == 'original')
+ this.instance.currentItem.css({ top: 'auto', left: 'auto' });
+
+ } else {
+ this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
+ this.instance._trigger("deactivate", event, uiSortable);
+ }
+
+ });
+
+ },
+ drag: function(event, ui) {
+
+ var inst = $(this).data("draggable"), that = this;
+
+ var checkPos = function(o) {
+ var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
+ var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
+ var itemHeight = o.height, itemWidth = o.width;
+ var itemTop = o.top, itemLeft = o.left;
+
+ return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
+ };
+
+ $.each(inst.sortables, function(i) {
+
+ var innermostIntersecting = false;
+ var thisSortable = this;
+ //Copy over some variables to allow calling the sortable's native _intersectsWith
+ this.instance.positionAbs = inst.positionAbs;
+ this.instance.helperProportions = inst.helperProportions;
+ this.instance.offset.click = inst.offset.click;
+
+ if(this.instance._intersectsWith(this.instance.containerCache)) {
+ innermostIntersecting = true;
+ $.each(inst.sortables, function () {
+ this.instance.positionAbs = inst.positionAbs;
+ this.instance.helperProportions = inst.helperProportions;
+ this.instance.offset.click = inst.offset.click;
+ if (this != thisSortable
+ && this.instance._intersectsWith(this.instance.containerCache)
+ && $.ui.contains(thisSortable.instance.element[0], this.instance.element[0]))
+ innermostIntersecting = false;
+ return innermostIntersecting;
+ });
+ }
+
+
+ if(innermostIntersecting) {
+ //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
+ if(!this.instance.isOver) {
+
+ this.instance.isOver = 1;
+ //Now we fake the start of dragging for the sortable instance,
+ //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
+ //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
+ this.instance.currentItem = $(that).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
+ this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
+ this.instance.options.helper = function() { return ui.helper[0]; };
+
+ event.target = this.instance.currentItem[0];
+ this.instance._mouseCapture(event, true);
+ this.instance._mouseStart(event, true, true);
+
+ //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
+ this.instance.offset.click.top = inst.offset.click.top;
+ this.instance.offset.click.left = inst.offset.click.left;
+ this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
+ this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
+
+ inst._trigger("toSortable", event);
+ inst.dropped = this.instance.element; //draggable revert needs that
+ //hack so receive/update callbacks work (mostly)
+ inst.currentItem = inst.element;
+ this.instance.fromOutside = inst;
+
+ }
+
+ //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
+ if(this.instance.currentItem) this.instance._mouseDrag(event);
+
+ } else {
+
+ //If it doesn't intersect with the sortable, and it intersected before,
+ //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
+ if(this.instance.isOver) {
+
+ this.instance.isOver = 0;
+ this.instance.cancelHelperRemoval = true;
+
+ //Prevent reverting on this forced stop
+ this.instance.options.revert = false;
+
+ // The out event needs to be triggered independently
+ this.instance._trigger('out', event, this.instance._uiHash(this.instance));
+
+ this.instance._mouseStop(event, true);
+ this.instance.options.helper = this.instance.options._helper;
+
+ //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
+ this.instance.currentItem.remove();
+ if(this.instance.placeholder) this.instance.placeholder.remove();
+
+ inst._trigger("fromSortable", event);
+ inst.dropped = false; //draggable revert needs that
+ }
+
+ };
+
+ });
+
+ }
+});
+
+$.ui.plugin.add("draggable", "cursor", {
+ start: function(event, ui) {
+ var t = $('body'), o = $(this).data('draggable').options;
+ if (t.css("cursor")) o._cursor = t.css("cursor");
+ t.css("cursor", o.cursor);
+ },
+ stop: function(event, ui) {
+ var o = $(this).data('draggable').options;
+ if (o._cursor) $('body').css("cursor", o._cursor);
+ }
+});
+
+$.ui.plugin.add("draggable", "opacity", {
+ start: function(event, ui) {
+ var t = $(ui.helper), o = $(this).data('draggable').options;
+ if(t.css("opacity")) o._opacity = t.css("opacity");
+ t.css('opacity', o.opacity);
+ },
+ stop: function(event, ui) {
+ var o = $(this).data('draggable').options;
+ if(o._opacity) $(ui.helper).css('opacity', o._opacity);
+ }
+});
+
+$.ui.plugin.add("draggable", "scroll", {
+ start: function(event, ui) {
+ var i = $(this).data("draggable");
+ if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
+ },
+ drag: function(event, ui) {
+
+ var i = $(this).data("draggable"), o = i.options, scrolled = false;
+
+ if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
+
+ if(!o.axis || o.axis != 'x') {
+ if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
+ i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
+ else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
+ i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
+ }
+
+ if(!o.axis || o.axis != 'y') {
+ if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
+ i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
+ else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
+ i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
+ }
+
+ } else {
+
+ if(!o.axis || o.axis != 'x') {
+ if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
+ scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
+ else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
+ scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
+ }
+
+ if(!o.axis || o.axis != 'y') {
+ if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
+ scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
+ else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
+ scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
+ }
+
+ }
+
+ if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
+ $.ui.ddmanager.prepareOffsets(i, event);
+
+ }
+});
+
+$.ui.plugin.add("draggable", "snap", {
+ start: function(event, ui) {
+
+ var i = $(this).data("draggable"), o = i.options;
+ i.snapElements = [];
+
+ $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
+ var $t = $(this); var $o = $t.offset();
+ if(this != i.element[0]) i.snapElements.push({
+ item: this,
+ width: $t.outerWidth(), height: $t.outerHeight(),
+ top: $o.top, left: $o.left
+ });
+ });
+
+ },
+ drag: function(event, ui) {
+
+ var inst = $(this).data("draggable"), o = inst.options;
+ var d = o.snapTolerance;
+
+ var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
+ y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
+
+ for (var i = inst.snapElements.length - 1; i >= 0; i--){
+
+ var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
+ t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
+
+ //Yes, I know, this is insane ;)
+ if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
+ if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
+ inst.snapElements[i].snapping = false;
+ continue;
+ }
+
+ if(o.snapMode != 'inner') {
+ var ts = Math.abs(t - y2) <= d;
+ var bs = Math.abs(b - y1) <= d;
+ var ls = Math.abs(l - x2) <= d;
+ var rs = Math.abs(r - x1) <= d;
+ if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
+ if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
+ if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
+ if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
+ }
+
+ var first = (ts || bs || ls || rs);
+
+ if(o.snapMode != 'outer') {
+ var ts = Math.abs(t - y1) <= d;
+ var bs = Math.abs(b - y2) <= d;
+ var ls = Math.abs(l - x1) <= d;
+ var rs = Math.abs(r - x2) <= d;
+ if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
+ if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
+ if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
+ if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
+ }
+
+ if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
+ (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
+ inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
+
+ };
+
+ }
+});
+
+$.ui.plugin.add("draggable", "stack", {
+ start: function(event, ui) {
+
+ var o = $(this).data("draggable").options;
+
+ var group = $.makeArray($(o.stack)).sort(function(a,b) {
+ return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
+ });
+ if (!group.length) { return; }
+
+ var min = parseInt(group[0].style.zIndex) || 0;
+ $(group).each(function(i) {
+ this.style.zIndex = min + i;
+ });
+
+ this[0].style.zIndex = min + group.length;
+
+ }
+});
+
+$.ui.plugin.add("draggable", "zIndex", {
+ start: function(event, ui) {
+ var t = $(ui.helper), o = $(this).data("draggable").options;
+ if(t.css("zIndex")) o._zIndex = t.css("zIndex");
+ t.css('zIndex', o.zIndex);
+ },
+ stop: function(event, ui) {
+ var o = $(this).data("draggable").options;
+ if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
+ }
+});
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.widget("ui.droppable", {
+ version: "1.9.2",
+ widgetEventPrefix: "drop",
+ options: {
+ accept: '*',
+ activeClass: false,
+ addClasses: true,
+ greedy: false,
+ hoverClass: false,
+ scope: 'default',
+ tolerance: 'intersect'
+ },
+ _create: function() {
+
+ var o = this.options, accept = o.accept;
+ this.isover = 0; this.isout = 1;
+
+ this.accept = $.isFunction(accept) ? accept : function(d) {
+ return d.is(accept);
+ };
+
+ //Store the droppable's proportions
+ this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
+
+ // Add the reference and positions to the manager
+ $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
+ $.ui.ddmanager.droppables[o.scope].push(this);
+
+ (o.addClasses && this.element.addClass("ui-droppable"));
+
+ },
+
+ _destroy: function() {
+ var drop = $.ui.ddmanager.droppables[this.options.scope];
+ for ( var i = 0; i < drop.length; i++ )
+ if ( drop[i] == this )
+ drop.splice(i, 1);
+
+ this.element.removeClass("ui-droppable ui-droppable-disabled");
+ },
+
+ _setOption: function(key, value) {
+
+ if(key == 'accept') {
+ this.accept = $.isFunction(value) ? value : function(d) {
+ return d.is(value);
+ };
+ }
+ $.Widget.prototype._setOption.apply(this, arguments);
+ },
+
+ _activate: function(event) {
+ var draggable = $.ui.ddmanager.current;
+ if(this.options.activeClass) this.element.addClass(this.options.activeClass);
+ (draggable && this._trigger('activate', event, this.ui(draggable)));
+ },
+
+ _deactivate: function(event) {
+ var draggable = $.ui.ddmanager.current;
+ if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
+ (draggable && this._trigger('deactivate', event, this.ui(draggable)));
+ },
+
+ _over: function(event) {
+
+ var draggable = $.ui.ddmanager.current;
+ if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
+
+ if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
+ if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
+ this._trigger('over', event, this.ui(draggable));
+ }
+
+ },
+
+ _out: function(event) {
+
+ var draggable = $.ui.ddmanager.current;
+ if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
+
+ if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
+ if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
+ this._trigger('out', event, this.ui(draggable));
+ }
+
+ },
+
+ _drop: function(event,custom) {
+
+ var draggable = custom || $.ui.ddmanager.current;
+ if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
+
+ var childrenIntersection = false;
+ this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
+ var inst = $.data(this, 'droppable');
+ if(
+ inst.options.greedy
+ && !inst.options.disabled
+ && inst.options.scope == draggable.options.scope
+ && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
+ && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
+ ) { childrenIntersection = true; return false; }
+ });
+ if(childrenIntersection) return false;
+
+ if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
+ if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
+ if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
+ this._trigger('drop', event, this.ui(draggable));
+ return this.element;
+ }
+
+ return false;
+
+ },
+
+ ui: function(c) {
+ return {
+ draggable: (c.currentItem || c.element),
+ helper: c.helper,
+ position: c.position,
+ offset: c.positionAbs
+ };
+ }
+
+});
+
+$.ui.intersect = function(draggable, droppable, toleranceMode) {
+
+ if (!droppable.offset) return false;
+
+ var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
+ y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
+ var l = droppable.offset.left, r = l + droppable.proportions.width,
+ t = droppable.offset.top, b = t + droppable.proportions.height;
+
+ switch (toleranceMode) {
+ case 'fit':
+ return (l <= x1 && x2 <= r
+ && t <= y1 && y2 <= b);
+ break;
+ case 'intersect':
+ return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
+ && x2 - (draggable.helperProportions.width / 2) < r // Left Half
+ && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
+ && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
+ break;
+ case 'pointer':
+ var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
+ draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
+ isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
+ return isOver;
+ break;
+ case 'touch':
+ return (
+ (y1 >= t && y1 <= b) || // Top edge touching
+ (y2 >= t && y2 <= b) || // Bottom edge touching
+ (y1 < t && y2 > b) // Surrounded vertically
+ ) && (
+ (x1 >= l && x1 <= r) || // Left edge touching
+ (x2 >= l && x2 <= r) || // Right edge touching
+ (x1 < l && x2 > r) // Surrounded horizontally
+ );
+ break;
+ default:
+ return false;
+ break;
+ }
+
+};
+
+/*
+ This manager tracks offsets of draggables and droppables
+*/
+$.ui.ddmanager = {
+ current: null,
+ droppables: { 'default': [] },
+ prepareOffsets: function(t, event) {
+
+ var m = $.ui.ddmanager.droppables[t.options.scope] || [];
+ var type = event ? event.type : null; // workaround for #2317
+ var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
+
+ droppablesLoop: for (var i = 0; i < m.length; i++) {
+
+ if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue; //No disabled and non-accepted
+ for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item
+ m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue
+
+ if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
+
+ m[i].offset = m[i].element.offset();
+ m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
+
+ }
+
+ },
+ drop: function(draggable, event) {
+
+ var dropped = false;
+ $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
+
+ if(!this.options) return;
+ if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
+ dropped = this._drop.call(this, event) || dropped;
+
+ if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
+ this.isout = 1; this.isover = 0;
+ this._deactivate.call(this, event);
+ }
+
+ });
+ return dropped;
+
+ },
+ dragStart: function( draggable, event ) {
+ //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
+ draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
+ if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
+ });
+ },
+ drag: function(draggable, event) {
+
+ //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
+ if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
+
+ //Run through all droppables and check their positions based on specific tolerance options
+ $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
+
+ if(this.options.disabled || this.greedyChild || !this.visible) return;
+ var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
+
+ var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
+ if(!c) return;
+
+ var parentInstance;
+ if (this.options.greedy) {
+ // find droppable parents with same scope
+ var scope = this.options.scope;
+ var parent = this.element.parents(':data(droppable)').filter(function () {
+ return $.data(this, 'droppable').options.scope === scope;
+ });
+
+ if (parent.length) {
+ parentInstance = $.data(parent[0], 'droppable');
+ parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
+ }
+ }
+
+ // we just moved into a greedy child
+ if (parentInstance && c == 'isover') {
+ parentInstance['isover'] = 0;
+ parentInstance['isout'] = 1;
+ parentInstance._out.call(parentInstance, event);
+ }
+
+ this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
+ this[c == "isover" ? "_over" : "_out"].call(this, event);
+
+ // we just moved out of a greedy child
+ if (parentInstance && c == 'isout') {
+ parentInstance['isout'] = 0;
+ parentInstance['isover'] = 1;
+ parentInstance._over.call(parentInstance, event);
+ }
+ });
+
+ },
+ dragStop: function( draggable, event ) {
+ draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
+ //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
+ if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
+ }
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.widget("ui.resizable", $.ui.mouse, {
+ version: "1.9.2",
+ widgetEventPrefix: "resize",
+ options: {
+ alsoResize: false,
+ animate: false,
+ animateDuration: "slow",
+ animateEasing: "swing",
+ aspectRatio: false,
+ autoHide: false,
+ containment: false,
+ ghost: false,
+ grid: false,
+ handles: "e,s,se",
+ helper: false,
+ maxHeight: null,
+ maxWidth: null,
+ minHeight: 10,
+ minWidth: 10,
+ zIndex: 1000
+ },
+ _create: function() {
+
+ var that = this, o = this.options;
+ this.element.addClass("ui-resizable");
+
+ $.extend(this, {
+ _aspectRatio: !!(o.aspectRatio),
+ aspectRatio: o.aspectRatio,
+ originalElement: this.element,
+ _proportionallyResizeElements: [],
+ _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
+ });
+
+ //Wrap the element if it cannot hold child nodes
+ if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
+
+ //Create a wrapper element and set the wrapper to the new current internal element
+ this.element.wrap(
+ $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
+ position: this.element.css('position'),
+ width: this.element.outerWidth(),
+ height: this.element.outerHeight(),
+ top: this.element.css('top'),
+ left: this.element.css('left')
+ })
+ );
+
+ //Overwrite the original this.element
+ this.element = this.element.parent().data(
+ "resizable", this.element.data('resizable')
+ );
+
+ this.elementIsWrapper = true;
+
+ //Move margins to the wrapper
+ this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
+ this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
+
+ //Prevent Safari textarea resize
+ this.originalResizeStyle = this.originalElement.css('resize');
+ this.originalElement.css('resize', 'none');
+
+ //Push the actual element to our proportionallyResize internal array
+ this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
+
+ // avoid IE jump (hard set the margin)
+ this.originalElement.css({ margin: this.originalElement.css('margin') });
+
+ // fix handlers offset
+ this._proportionallyResize();
+
+ }
+
+ this.handles = o.handles || (!$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' });
+ if(this.handles.constructor == String) {
+
+ if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw';
+ var n = this.handles.split(","); this.handles = {};
+
+ for(var i = 0; i < n.length; i++) {
+
+ var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
+ var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
+
+ // Apply zIndex to all handles - see #7960
+ axis.css({ zIndex: o.zIndex });
+
+ //TODO : What's going on here?
+ if ('se' == handle) {
+ axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
+ };
+
+ //Insert into internal handles object and append to element
+ this.handles[handle] = '.ui-resizable-'+handle;
+ this.element.append(axis);
+ }
+
+ }
+
+ this._renderAxis = function(target) {
+
+ target = target || this.element;
+
+ for(var i in this.handles) {
+
+ if(this.handles[i].constructor == String)
+ this.handles[i] = $(this.handles[i], this.element).show();
+
+ //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
+ if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
+
+ var axis = $(this.handles[i], this.element), padWrapper = 0;
+
+ //Checking the correct pad and border
+ padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
+
+ //The padding type i have to apply...
+ var padPos = [ 'padding',
+ /ne|nw|n/.test(i) ? 'Top' :
+ /se|sw|s/.test(i) ? 'Bottom' :
+ /^e$/.test(i) ? 'Right' : 'Left' ].join("");
+
+ target.css(padPos, padWrapper);
+
+ this._proportionallyResize();
+
+ }
+
+ //TODO: What's that good for? There's not anything to be executed left
+ if(!$(this.handles[i]).length)
+ continue;
+
+ }
+ };
+
+ //TODO: make renderAxis a prototype function
+ this._renderAxis(this.element);
+
+ this._handles = $('.ui-resizable-handle', this.element)
+ .disableSelection();
+
+ //Matching axis name
+ this._handles.mouseover(function() {
+ if (!that.resizing) {
+ if (this.className)
+ var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
+ //Axis, default = se
+ that.axis = axis && axis[1] ? axis[1] : 'se';
+ }
+ });
+
+ //If we want to auto hide the elements
+ if (o.autoHide) {
+ this._handles.hide();
+ $(this.element)
+ .addClass("ui-resizable-autohide")
+ .mouseenter(function() {
+ if (o.disabled) return;
+ $(this).removeClass("ui-resizable-autohide");
+ that._handles.show();
+ })
+ .mouseleave(function(){
+ if (o.disabled) return;
+ if (!that.resizing) {
+ $(this).addClass("ui-resizable-autohide");
+ that._handles.hide();
+ }
+ });
+ }
+
+ //Initialize the mouse interaction
+ this._mouseInit();
+
+ },
+
+ _destroy: function() {
+
+ this._mouseDestroy();
+
+ var _destroy = function(exp) {
+ $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
+ .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
+ };
+
+ //TODO: Unwrap at same DOM position
+ if (this.elementIsWrapper) {
+ _destroy(this.element);
+ var wrapper = this.element;
+ this.originalElement.css({
+ position: wrapper.css('position'),
+ width: wrapper.outerWidth(),
+ height: wrapper.outerHeight(),
+ top: wrapper.css('top'),
+ left: wrapper.css('left')
+ }).insertAfter( wrapper );
+ wrapper.remove();
+ }
+
+ this.originalElement.css('resize', this.originalResizeStyle);
+ _destroy(this.originalElement);
+
+ return this;
+ },
+
+ _mouseCapture: function(event) {
+ var handle = false;
+ for (var i in this.handles) {
+ if ($(this.handles[i])[0] == event.target) {
+ handle = true;
+ }
+ }
+
+ return !this.options.disabled && handle;
+ },
+
+ _mouseStart: function(event) {
+
+ var o = this.options, iniPos = this.element.position(), el = this.element;
+
+ this.resizing = true;
+ this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
+
+ // bugfix for http://dev.jquery.com/ticket/1749
+ if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
+ el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
+ }
+
+ this._renderProxy();
+
+ var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
+
+ if (o.containment) {
+ curleft += $(o.containment).scrollLeft() || 0;
+ curtop += $(o.containment).scrollTop() || 0;
+ }
+
+ //Store needed variables
+ this.offset = this.helper.offset();
+ this.position = { left: curleft, top: curtop };
+ this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
+ this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
+ this.originalPosition = { left: curleft, top: curtop };
+ this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
+ this.originalMousePosition = { left: event.pageX, top: event.pageY };
+
+ //Aspect Ratio
+ this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
+
+ var cursor = $('.ui-resizable-' + this.axis).css('cursor');
+ $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
+
+ el.addClass("ui-resizable-resizing");
+ this._propagate("start", event);
+ return true;
+ },
+
+ _mouseDrag: function(event) {
+
+ //Increase performance, avoid regex
+ var el = this.helper, o = this.options, props = {},
+ that = this, smp = this.originalMousePosition, a = this.axis;
+
+ var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
+ var trigger = this._change[a];
+ if (!trigger) return false;
+
+ // Calculate the attrs that will be change
+ var data = trigger.apply(this, [event, dx, dy]);
+
+ // Put this in the mouseDrag handler since the user can start pressing shift while resizing
+ this._updateVirtualBoundaries(event.shiftKey);
+ if (this._aspectRatio || event.shiftKey)
+ data = this._updateRatio(data, event);
+
+ data = this._respectSize(data, event);
+
+ // plugins callbacks need to be called first
+ this._propagate("resize", event);
+
+ el.css({
+ top: this.position.top + "px", left: this.position.left + "px",
+ width: this.size.width + "px", height: this.size.height + "px"
+ });
+
+ if (!this._helper && this._proportionallyResizeElements.length)
+ this._proportionallyResize();
+
+ this._updateCache(data);
+
+ // calling the user callback at the end
+ this._trigger('resize', event, this.ui());
+
+ return false;
+ },
+
+ _mouseStop: function(event) {
+
+ this.resizing = false;
+ var o = this.options, that = this;
+
+ if(this._helper) {
+ var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
+ soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
+ soffsetw = ista ? 0 : that.sizeDiff.width;
+
+ var s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) },
+ left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
+ top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
+
+ if (!o.animate)
+ this.element.css($.extend(s, { top: top, left: left }));
+
+ that.helper.height(that.size.height);
+ that.helper.width(that.size.width);
+
+ if (this._helper && !o.animate) this._proportionallyResize();
+ }
+
+ $('body').css('cursor', 'auto');
+
+ this.element.removeClass("ui-resizable-resizing");
+
+ this._propagate("stop", event);
+
+ if (this._helper) this.helper.remove();
+ return false;
+
+ },
+
+ _updateVirtualBoundaries: function(forceAspectRatio) {
+ var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b;
+
+ b = {
+ minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
+ maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
+ minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
+ maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
+ };
+
+ if(this._aspectRatio || forceAspectRatio) {
+ // We want to create an enclosing box whose aspect ration is the requested one
+ // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
+ pMinWidth = b.minHeight * this.aspectRatio;
+ pMinHeight = b.minWidth / this.aspectRatio;
+ pMaxWidth = b.maxHeight * this.aspectRatio;
+ pMaxHeight = b.maxWidth / this.aspectRatio;
+
+ if(pMinWidth > b.minWidth) b.minWidth = pMinWidth;
+ if(pMinHeight > b.minHeight) b.minHeight = pMinHeight;
+ if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth;
+ if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight;
+ }
+ this._vBoundaries = b;
+ },
+
+ _updateCache: function(data) {
+ var o = this.options;
+ this.offset = this.helper.offset();
+ if (isNumber(data.left)) this.position.left = data.left;
+ if (isNumber(data.top)) this.position.top = data.top;
+ if (isNumber(data.height)) this.size.height = data.height;
+ if (isNumber(data.width)) this.size.width = data.width;
+ },
+
+ _updateRatio: function(data, event) {
+
+ var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
+
+ if (isNumber(data.height)) data.width = (data.height * this.aspectRatio);
+ else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio);
+
+ if (a == 'sw') {
+ data.left = cpos.left + (csize.width - data.width);
+ data.top = null;
+ }
+ if (a == 'nw') {
+ data.top = cpos.top + (csize.height - data.height);
+ data.left = cpos.left + (csize.width - data.width);
+ }
+
+ return data;
+ },
+
+ _respectSize: function(data, event) {
+
+ var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis,
+ ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
+ isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
+
+ if (isminw) data.width = o.minWidth;
+ if (isminh) data.height = o.minHeight;
+ if (ismaxw) data.width = o.maxWidth;
+ if (ismaxh) data.height = o.maxHeight;
+
+ var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
+ var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
+
+ if (isminw && cw) data.left = dw - o.minWidth;
+ if (ismaxw && cw) data.left = dw - o.maxWidth;
+ if (isminh && ch) data.top = dh - o.minHeight;
+ if (ismaxh && ch) data.top = dh - o.maxHeight;
+
+ // fixing jump error on top/left - bug #2330
+ var isNotwh = !data.width && !data.height;
+ if (isNotwh && !data.left && data.top) data.top = null;
+ else if (isNotwh && !data.top && data.left) data.left = null;
+
+ return data;
+ },
+
+ _proportionallyResize: function() {
+
+ var o = this.options;
+ if (!this._proportionallyResizeElements.length) return;
+ var element = this.helper || this.element;
+
+ for (var i=0; i < this._proportionallyResizeElements.length; i++) {
+
+ var prel = this._proportionallyResizeElements[i];
+
+ if (!this.borderDif) {
+ var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
+ p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
+
+ this.borderDif = $.map(b, function(v, i) {
+ var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
+ return border + padding;
+ });
+ }
+
+ prel.css({
+ height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
+ width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
+ });
+
+ };
+
+ },
+
+ _renderProxy: function() {
+
+ var el = this.element, o = this.options;
+ this.elementOffset = el.offset();
+
+ if(this._helper) {
+
+ this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
+
+ // fix ie6 offset TODO: This seems broken
+ var ie6offset = ($.ui.ie6 ? 1 : 0),
+ pxyoffset = ( $.ui.ie6 ? 2 : -1 );
+
+ this.helper.addClass(this._helper).css({
+ width: this.element.outerWidth() + pxyoffset,
+ height: this.element.outerHeight() + pxyoffset,
+ position: 'absolute',
+ left: this.elementOffset.left - ie6offset +'px',
+ top: this.elementOffset.top - ie6offset +'px',
+ zIndex: ++o.zIndex //TODO: Don't modify option
+ });
+
+ this.helper
+ .appendTo("body")
+ .disableSelection();
+
+ } else {
+ this.helper = this.element;
+ }
+
+ },
+
+ _change: {
+ e: function(event, dx, dy) {
+ return { width: this.originalSize.width + dx };
+ },
+ w: function(event, dx, dy) {
+ var o = this.options, cs = this.originalSize, sp = this.originalPosition;
+ return { left: sp.left + dx, width: cs.width - dx };
+ },
+ n: function(event, dx, dy) {
+ var o = this.options, cs = this.originalSize, sp = this.originalPosition;
+ return { top: sp.top + dy, height: cs.height - dy };
+ },
+ s: function(event, dx, dy) {
+ return { height: this.originalSize.height + dy };
+ },
+ se: function(event, dx, dy) {
+ return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
+ },
+ sw: function(event, dx, dy) {
+ return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
+ },
+ ne: function(event, dx, dy) {
+ return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
+ },
+ nw: function(event, dx, dy) {
+ return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
+ }
+ },
+
+ _propagate: function(n, event) {
+ $.ui.plugin.call(this, n, [event, this.ui()]);
+ (n != "resize" && this._trigger(n, event, this.ui()));
+ },
+
+ plugins: {},
+
+ ui: function() {
+ return {
+ originalElement: this.originalElement,
+ element: this.element,
+ helper: this.helper,
+ position: this.position,
+ size: this.size,
+ originalSize: this.originalSize,
+ originalPosition: this.originalPosition
+ };
+ }
+
+});
+
+/*
+ * Resizable Extensions
+ */
+
+$.ui.plugin.add("resizable", "alsoResize", {
+
+ start: function (event, ui) {
+ var that = $(this).data("resizable"), o = that.options;
+
+ var _store = function (exp) {
+ $(exp).each(function() {
+ var el = $(this);
+ el.data("resizable-alsoresize", {
+ width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
+ left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
+ });
+ });
+ };
+
+ if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) {
+ if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
+ else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
+ }else{
+ _store(o.alsoResize);
+ }
+ },
+
+ resize: function (event, ui) {
+ var that = $(this).data("resizable"), o = that.options, os = that.originalSize, op = that.originalPosition;
+
+ var delta = {
+ height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
+ top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
+ },
+
+ _alsoResize = function (exp, c) {
+ $(exp).each(function() {
+ var el = $(this), start = $(this).data("resizable-alsoresize"), style = {},
+ css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
+
+ $.each(css, function (i, prop) {
+ var sum = (start[prop]||0) + (delta[prop]||0);
+ if (sum && sum >= 0)
+ style[prop] = sum || null;
+ });
+
+ el.css(style);
+ });
+ };
+
+ if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
+ $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
+ }else{
+ _alsoResize(o.alsoResize);
+ }
+ },
+
+ stop: function (event, ui) {
+ $(this).removeData("resizable-alsoresize");
+ }
+});
+
+$.ui.plugin.add("resizable", "animate", {
+
+ stop: function(event, ui) {
+ var that = $(this).data("resizable"), o = that.options;
+
+ var pr = that._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
+ soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
+ soffsetw = ista ? 0 : that.sizeDiff.width;
+
+ var style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
+ left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
+ top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
+
+ that.element.animate(
+ $.extend(style, top && left ? { top: top, left: left } : {}), {
+ duration: o.animateDuration,
+ easing: o.animateEasing,
+ step: function() {
+
+ var data = {
+ width: parseInt(that.element.css('width'), 10),
+ height: parseInt(that.element.css('height'), 10),
+ top: parseInt(that.element.css('top'), 10),
+ left: parseInt(that.element.css('left'), 10)
+ };
+
+ if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
+
+ // propagating resize, and updating values for each animation step
+ that._updateCache(data);
+ that._propagate("resize", event);
+
+ }
+ }
+ );
+ }
+
+});
+
+$.ui.plugin.add("resizable", "containment", {
+
+ start: function(event, ui) {
+ var that = $(this).data("resizable"), o = that.options, el = that.element;
+ var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
+ if (!ce) return;
+
+ that.containerElement = $(ce);
+
+ if (/document/.test(oc) || oc == document) {
+ that.containerOffset = { left: 0, top: 0 };
+ that.containerPosition = { left: 0, top: 0 };
+
+ that.parentData = {
+ element: $(document), left: 0, top: 0,
+ width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
+ };
+ }
+
+ // i'm a node, so compute top, left, right, bottom
+ else {
+ var element = $(ce), p = [];
+ $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
+
+ that.containerOffset = element.offset();
+ that.containerPosition = element.position();
+ that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
+
+ var co = that.containerOffset, ch = that.containerSize.height, cw = that.containerSize.width,
+ width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
+
+ that.parentData = {
+ element: ce, left: co.left, top: co.top, width: width, height: height
+ };
+ }
+ },
+
+ resize: function(event, ui) {
+ var that = $(this).data("resizable"), o = that.options,
+ ps = that.containerSize, co = that.containerOffset, cs = that.size, cp = that.position,
+ pRatio = that._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = that.containerElement;
+
+ if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
+
+ if (cp.left < (that._helper ? co.left : 0)) {
+ that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
+ if (pRatio) that.size.height = that.size.width / that.aspectRatio;
+ that.position.left = o.helper ? co.left : 0;
+ }
+
+ if (cp.top < (that._helper ? co.top : 0)) {
+ that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
+ if (pRatio) that.size.width = that.size.height * that.aspectRatio;
+ that.position.top = that._helper ? co.top : 0;
+ }
+
+ that.offset.left = that.parentData.left+that.position.left;
+ that.offset.top = that.parentData.top+that.position.top;
+
+ var woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width ),
+ hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
+
+ var isParent = that.containerElement.get(0) == that.element.parent().get(0),
+ isOffsetRelative = /relative|absolute/.test(that.containerElement.css('position'));
+
+ if(isParent && isOffsetRelative) woset -= that.parentData.left;
+
+ if (woset + that.size.width >= that.parentData.width) {
+ that.size.width = that.parentData.width - woset;
+ if (pRatio) that.size.height = that.size.width / that.aspectRatio;
+ }
+
+ if (hoset + that.size.height >= that.parentData.height) {
+ that.size.height = that.parentData.height - hoset;
+ if (pRatio) that.size.width = that.size.height * that.aspectRatio;
+ }
+ },
+
+ stop: function(event, ui){
+ var that = $(this).data("resizable"), o = that.options, cp = that.position,
+ co = that.containerOffset, cop = that.containerPosition, ce = that.containerElement;
+
+ var helper = $(that.helper), ho = helper.offset(), w = helper.outerWidth() - that.sizeDiff.width, h = helper.outerHeight() - that.sizeDiff.height;
+
+ if (that._helper && !o.animate && (/relative/).test(ce.css('position')))
+ $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
+
+ if (that._helper && !o.animate && (/static/).test(ce.css('position')))
+ $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
+
+ }
+});
+
+$.ui.plugin.add("resizable", "ghost", {
+
+ start: function(event, ui) {
+
+ var that = $(this).data("resizable"), o = that.options, cs = that.size;
+
+ that.ghost = that.originalElement.clone();
+ that.ghost
+ .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
+ .addClass('ui-resizable-ghost')
+ .addClass(typeof o.ghost == 'string' ? o.ghost : '');
+
+ that.ghost.appendTo(that.helper);
+
+ },
+
+ resize: function(event, ui){
+ var that = $(this).data("resizable"), o = that.options;
+ if (that.ghost) that.ghost.css({ position: 'relative', height: that.size.height, width: that.size.width });
+ },
+
+ stop: function(event, ui){
+ var that = $(this).data("resizable"), o = that.options;
+ if (that.ghost && that.helper) that.helper.get(0).removeChild(that.ghost.get(0));
+ }
+
+});
+
+$.ui.plugin.add("resizable", "grid", {
+
+ resize: function(event, ui) {
+ var that = $(this).data("resizable"), o = that.options, cs = that.size, os = that.originalSize, op = that.originalPosition, a = that.axis, ratio = o._aspectRatio || event.shiftKey;
+ o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
+ var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
+
+ if (/^(se|s|e)$/.test(a)) {
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ }
+ else if (/^(ne)$/.test(a)) {
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ that.position.top = op.top - oy;
+ }
+ else if (/^(sw)$/.test(a)) {
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ that.position.left = op.left - ox;
+ }
+ else {
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ that.position.top = op.top - oy;
+ that.position.left = op.left - ox;
+ }
+ }
+
+});
+
+var num = function(v) {
+ return parseInt(v, 10) || 0;
+};
+
+var isNumber = function(value) {
+ return !isNaN(parseInt(value, 10));
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.widget("ui.selectable", $.ui.mouse, {
+ version: "1.9.2",
+ options: {
+ appendTo: 'body',
+ autoRefresh: true,
+ distance: 0,
+ filter: '*',
+ tolerance: 'touch'
+ },
+ _create: function() {
+ var that = this;
+
+ this.element.addClass("ui-selectable");
+
+ this.dragged = false;
+
+ // cache selectee children based on filter
+ var selectees;
+ this.refresh = function() {
+ selectees = $(that.options.filter, that.element[0]);
+ selectees.addClass("ui-selectee");
+ selectees.each(function() {
+ var $this = $(this);
+ var pos = $this.offset();
+ $.data(this, "selectable-item", {
+ element: this,
+ $element: $this,
+ left: pos.left,
+ top: pos.top,
+ right: pos.left + $this.outerWidth(),
+ bottom: pos.top + $this.outerHeight(),
+ startselected: false,
+ selected: $this.hasClass('ui-selected'),
+ selecting: $this.hasClass('ui-selecting'),
+ unselecting: $this.hasClass('ui-unselecting')
+ });
+ });
+ };
+ this.refresh();
+
+ this.selectees = selectees.addClass("ui-selectee");
+
+ this._mouseInit();
+
+ this.helper = $("<div class='ui-selectable-helper'></div>");
+ },
+
+ _destroy: function() {
+ this.selectees
+ .removeClass("ui-selectee")
+ .removeData("selectable-item");
+ this.element
+ .removeClass("ui-selectable ui-selectable-disabled");
+ this._mouseDestroy();
+ },
+
+ _mouseStart: function(event) {
+ var that = this;
+
+ this.opos = [event.pageX, event.pageY];
+
+ if (this.options.disabled)
+ return;
+
+ var options = this.options;
+
+ this.selectees = $(options.filter, this.element[0]);
+
+ this._trigger("start", event);
+
+ $(options.appendTo).append(this.helper);
+ // position helper (lasso)
+ this.helper.css({
+ "left": event.clientX,
+ "top": event.clientY,
+ "width": 0,
+ "height": 0
+ });
+
+ if (options.autoRefresh) {
+ this.refresh();
+ }
+
+ this.selectees.filter('.ui-selected').each(function() {
+ var selectee = $.data(this, "selectable-item");
+ selectee.startselected = true;
+ if (!event.metaKey && !event.ctrlKey) {
+ selectee.$element.removeClass('ui-selected');
+ selectee.selected = false;
+ selectee.$element.addClass('ui-unselecting');
+ selectee.unselecting = true;
+ // selectable UNSELECTING callback
+ that._trigger("unselecting", event, {
+ unselecting: selectee.element
+ });
+ }
+ });
+
+ $(event.target).parents().andSelf().each(function() {
+ var selectee = $.data(this, "selectable-item");
+ if (selectee) {
+ var doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass('ui-selected');
+ selectee.$element
+ .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
+ .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
+ selectee.unselecting = !doSelect;
+ selectee.selecting = doSelect;
+ selectee.selected = doSelect;
+ // selectable (UN)SELECTING callback
+ if (doSelect) {
+ that._trigger("selecting", event, {
+ selecting: selectee.element
+ });
+ } else {
+ that._trigger("unselecting", event, {
+ unselecting: selectee.element
+ });
+ }
+ return false;
+ }
+ });
+
+ },
+
+ _mouseDrag: function(event) {
+ var that = this;
+ this.dragged = true;
+
+ if (this.options.disabled)
+ return;
+
+ var options = this.options;
+
+ var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
+ if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
+ if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
+ this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
+
+ this.selectees.each(function() {
+ var selectee = $.data(this, "selectable-item");
+ //prevent helper from being selected if appendTo: selectable
+ if (!selectee || selectee.element == that.element[0])
+ return;
+ var hit = false;
+ if (options.tolerance == 'touch') {
+ hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
+ } else if (options.tolerance == 'fit') {
+ hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
+ }
+
+ if (hit) {
+ // SELECT
+ if (selectee.selected) {
+ selectee.$element.removeClass('ui-selected');
+ selectee.selected = false;
+ }
+ if (selectee.unselecting) {
+ selectee.$element.removeClass('ui-unselecting');
+ selectee.unselecting = false;
+ }
+ if (!selectee.selecting) {
+ selectee.$element.addClass('ui-selecting');
+ selectee.selecting = true;
+ // selectable SELECTING callback
+ that._trigger("selecting", event, {
+ selecting: selectee.element
+ });
+ }
+ } else {
+ // UNSELECT
+ if (selectee.selecting) {
+ if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
+ selectee.$element.removeClass('ui-selecting');
+ selectee.selecting = false;
+ selectee.$element.addClass('ui-selected');
+ selectee.selected = true;
+ } else {
+ selectee.$element.removeClass('ui-selecting');
+ selectee.selecting = false;
+ if (selectee.startselected) {
+ selectee.$element.addClass('ui-unselecting');
+ selectee.unselecting = true;
+ }
+ // selectable UNSELECTING callback
+ that._trigger("unselecting", event, {
+ unselecting: selectee.element
+ });
+ }
+ }
+ if (selectee.selected) {
+ if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
+ selectee.$element.removeClass('ui-selected');
+ selectee.selected = false;
+
+ selectee.$element.addClass('ui-unselecting');
+ selectee.unselecting = true;
+ // selectable UNSELECTING callback
+ that._trigger("unselecting", event, {
+ unselecting: selectee.element
+ });
+ }
+ }
+ }
+ });
+
+ return false;
+ },
+
+ _mouseStop: function(event) {
+ var that = this;
+
+ this.dragged = false;
+
+ var options = this.options;
+
+ $('.ui-unselecting', this.element[0]).each(function() {
+ var selectee = $.data(this, "selectable-item");
+ selectee.$element.removeClass('ui-unselecting');
+ selectee.unselecting = false;
+ selectee.startselected = false;
+ that._trigger("unselected", event, {
+ unselected: selectee.element
+ });
+ });
+ $('.ui-selecting', this.element[0]).each(function() {
+ var selectee = $.data(this, "selectable-item");
+ selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
+ selectee.selecting = false;
+ selectee.selected = true;
+ selectee.startselected = true;
+ that._trigger("selected", event, {
+ selected: selectee.element
+ });
+ });
+ this._trigger("stop", event);
+
+ this.helper.remove();
+
+ return false;
+ }
+
+});
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.widget("ui.sortable", $.ui.mouse, {
+ version: "1.9.2",
+ widgetEventPrefix: "sort",
+ ready: false,
+ options: {
+ appendTo: "parent",
+ axis: false,
+ connectWith: false,
+ containment: false,
+ cursor: 'auto',
+ cursorAt: false,
+ dropOnEmpty: true,
+ forcePlaceholderSize: false,
+ forceHelperSize: false,
+ grid: false,
+ handle: false,
+ helper: "original",
+ items: '> *',
+ opacity: false,
+ placeholder: false,
+ revert: false,
+ scroll: true,
+ scrollSensitivity: 20,
+ scrollSpeed: 20,
+ scope: "default",
+ tolerance: "intersect",
+ zIndex: 1000
+ },
+ _create: function() {
+
+ var o = this.options;
+ this.containerCache = {};
+ this.element.addClass("ui-sortable");
+
+ //Get the items
+ this.refresh();
+
+ //Let's determine if the items are being displayed horizontally
+ this.floating = this.items.length ? o.axis === 'x' || (/left|right/).test(this.items[0].item.css('float')) || (/inline|table-cell/).test(this.items[0].item.css('display')) : false;
+
+ //Let's determine the parent's offset
+ this.offset = this.element.offset();
+
+ //Initialize mouse events for interaction
+ this._mouseInit();
+
+ //We're ready to go
+ this.ready = true
+
+ },
+
+ _destroy: function() {
+ this.element
+ .removeClass("ui-sortable ui-sortable-disabled");
+ this._mouseDestroy();
+
+ for ( var i = this.items.length - 1; i >= 0; i-- )
+ this.items[i].item.removeData(this.widgetName + "-item");
+
+ return this;
+ },
+
+ _setOption: function(key, value){
+ if ( key === "disabled" ) {
+ this.options[ key ] = value;
+
+ this.widget().toggleClass( "ui-sortable-disabled", !!value );
+ } else {
+ // Don't call widget base _setOption for disable as it adds ui-state-disabled class
+ $.Widget.prototype._setOption.apply(this, arguments);
+ }
+ },
+
+ _mouseCapture: function(event, overrideHandle) {
+ var that = this;
+
+ if (this.reverting) {
+ return false;
+ }
+
+ if(this.options.disabled || this.options.type == 'static') return false;
+
+ //We have to refresh the items data once first
+ this._refreshItems(event);
+
+ //Find out if the clicked node (or one of its parents) is a actual item in this.items
+ var currentItem = null, nodes = $(event.target).parents().each(function() {
+ if($.data(this, that.widgetName + '-item') == that) {
+ currentItem = $(this);
+ return false;
+ }
+ });
+ if($.data(event.target, that.widgetName + '-item') == that) currentItem = $(event.target);
+
+ if(!currentItem) return false;
+ if(this.options.handle && !overrideHandle) {
+ var validHandle = false;
+
+ $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
+ if(!validHandle) return false;
+ }
+
+ this.currentItem = currentItem;
+ this._removeCurrentsFromItems();
+ return true;
+
+ },
+
+ _mouseStart: function(event, overrideHandle, noActivation) {
+
+ var o = this.options;
+ this.currentContainer = this;
+
+ //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
+ this.refreshPositions();
+
+ //Create and append the visible helper
+ this.helper = this._createHelper(event);
+
+ //Cache the helper size
+ this._cacheHelperProportions();
+
+ /*
+ * - Position generation -
+ * This block generates everything position related - it's the core of draggables.
+ */
+
+ //Cache the margins of the original element
+ this._cacheMargins();
+
+ //Get the next scrolling parent
+ this.scrollParent = this.helper.scrollParent();
+
+ //The element's absolute position on the page minus margins
+ this.offset = this.currentItem.offset();
+ this.offset = {
+ top: this.offset.top - this.margins.top,
+ left: this.offset.left - this.margins.left
+ };
+
+ $.extend(this.offset, {
+ click: { //Where the click happened, relative to the element
+ left: event.pageX - this.offset.left,
+ top: event.pageY - this.offset.top
+ },
+ parent: this._getParentOffset(),
+ relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
+ });
+
+ // Only after we got the offset, we can change the helper's position to absolute
+ // TODO: Still need to figure out a way to make relative sorting possible
+ this.helper.css("position", "absolute");
+ this.cssPosition = this.helper.css("position");
+
+ //Generate the original position
+ this.originalPosition = this._generatePosition(event);
+ this.originalPageX = event.pageX;
+ this.originalPageY = event.pageY;
+
+ //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
+ (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
+
+ //Cache the former DOM position
+ this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
+
+ //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
+ if(this.helper[0] != this.currentItem[0]) {
+ this.currentItem.hide();
+ }
+
+ //Create the placeholder
+ this._createPlaceholder();
+
+ //Set a containment if given in the options
+ if(o.containment)
+ this._setContainment();
+
+ if(o.cursor) { // cursor option
+ if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
+ $('body').css("cursor", o.cursor);
+ }
+
+ if(o.opacity) { // opacity option
+ if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
+ this.helper.css("opacity", o.opacity);
+ }
+
+ if(o.zIndex) { // zIndex option
+ if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
+ this.helper.css("zIndex", o.zIndex);
+ }
+
+ //Prepare scrolling
+ if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')
+ this.overflowOffset = this.scrollParent.offset();
+
+ //Call callbacks
+ this._trigger("start", event, this._uiHash());
+
+ //Recache the helper size
+ if(!this._preserveHelperProportions)
+ this._cacheHelperProportions();
+
+
+ //Post 'activate' events to possible containers
+ if(!noActivation) {
+ for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, this._uiHash(this)); }
+ }
+
+ //Prepare possible droppables
+ if($.ui.ddmanager)
+ $.ui.ddmanager.current = this;
+
+ if ($.ui.ddmanager && !o.dropBehaviour)
+ $.ui.ddmanager.prepareOffsets(this, event);
+
+ this.dragging = true;
+
+ this.helper.addClass("ui-sortable-helper");
+ this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
+ return true;
+
+ },
+
+ _mouseDrag: function(event) {
+
+ //Compute the helpers position
+ this.position = this._generatePosition(event);
+ this.positionAbs = this._convertPositionTo("absolute");
+
+ if (!this.lastPositionAbs) {
+ this.lastPositionAbs = this.positionAbs;
+ }
+
+ //Do scrolling
+ if(this.options.scroll) {
+ var o = this.options, scrolled = false;
+ if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
+
+ if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
+ this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
+ else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
+ this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
+
+ if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
+ this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
+ else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
+ this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
+
+ } else {
+
+ if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
+ scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
+ else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
+ scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
+
+ if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
+ scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
+ else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
+ scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
+
+ }
+
+ if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
+ $.ui.ddmanager.prepareOffsets(this, event);
+ }
+
+ //Regenerate the absolute position used for position checks
+ this.positionAbs = this._convertPositionTo("absolute");
+
+ //Set the helper position
+ if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
+ if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
+
+ //Rearrange
+ for (var i = this.items.length - 1; i >= 0; i--) {
+
+ //Cache variables and intersection, continue if no intersection
+ var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
+ if (!intersection) continue;
+
+ // Only put the placeholder inside the current Container, skip all
+ // items form other containers. This works because when moving
+ // an item from one container to another the
+ // currentContainer is switched before the placeholder is moved.
+ //
+ // Without this moving items in "sub-sortables" can cause the placeholder to jitter
+ // beetween the outer and inner container.
+ if (item.instance !== this.currentContainer) continue;
+
+ if (itemElement != this.currentItem[0] //cannot intersect with itself
+ && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
+ && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
+ && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
+ //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
+ ) {
+
+ this.direction = intersection == 1 ? "down" : "up";
+
+ if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
+ this._rearrange(event, item);
+ } else {
+ break;
+ }
+
+ this._trigger("change", event, this._uiHash());
+ break;
+ }
+ }
+
+ //Post events to containers
+ this._contactContainers(event);
+
+ //Interconnect with droppables
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
+
+ //Call callbacks
+ this._trigger('sort', event, this._uiHash());
+
+ this.lastPositionAbs = this.positionAbs;
+ return false;
+
+ },
+
+ _mouseStop: function(event, noPropagation) {
+
+ if(!event) return;
+
+ //If we are using droppables, inform the manager about the drop
+ if ($.ui.ddmanager && !this.options.dropBehaviour)
+ $.ui.ddmanager.drop(this, event);
+
+ if(this.options.revert) {
+ var that = this;
+ var cur = this.placeholder.offset();
+
+ this.reverting = true;
+
+ $(this.helper).animate({
+ left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
+ top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
+ }, parseInt(this.options.revert, 10) || 500, function() {
+ that._clear(event);
+ });
+ } else {
+ this._clear(event, noPropagation);
+ }
+
+ return false;
+
+ },
+
+ cancel: function() {
+
+ if(this.dragging) {
+
+ this._mouseUp({ target: null });
+
+ if(this.options.helper == "original")
+ this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
+ else
+ this.currentItem.show();
+
+ //Post deactivating events to containers
+ for (var i = this.containers.length - 1; i >= 0; i--){
+ this.containers[i]._trigger("deactivate", null, this._uiHash(this));
+ if(this.containers[i].containerCache.over) {
+ this.containers[i]._trigger("out", null, this._uiHash(this));
+ this.containers[i].containerCache.over = 0;
+ }
+ }
+
+ }
+
+ if (this.placeholder) {
+ //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
+ if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
+ if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
+
+ $.extend(this, {
+ helper: null,
+ dragging: false,
+ reverting: false,
+ _noFinalSort: null
+ });
+
+ if(this.domPosition.prev) {
+ $(this.domPosition.prev).after(this.currentItem);
+ } else {
+ $(this.domPosition.parent).prepend(this.currentItem);
+ }
+ }
+
+ return this;
+
+ },
+
+ serialize: function(o) {
+
+ var items = this._getItemsAsjQuery(o && o.connected);
+ var str = []; o = o || {};
+
+ $(items).each(function() {
+ var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
+ if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
+ });
+
+ if(!str.length && o.key) {
+ str.push(o.key + '=');
+ }
+
+ return str.join('&');
+
+ },
+
+ toArray: function(o) {
+
+ var items = this._getItemsAsjQuery(o && o.connected);
+ var ret = []; o = o || {};
+
+ items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
+ return ret;
+
+ },
+
+ /* Be careful with the following core functions */
+ _intersectsWith: function(item) {
+
+ var x1 = this.positionAbs.left,
+ x2 = x1 + this.helperProportions.width,
+ y1 = this.positionAbs.top,
+ y2 = y1 + this.helperProportions.height;
+
+ var l = item.left,
+ r = l + item.width,
+ t = item.top,
+ b = t + item.height;
+
+ var dyClick = this.offset.click.top,
+ dxClick = this.offset.click.left;
+
+ var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
+
+ if( this.options.tolerance == "pointer"
+ || this.options.forcePointerForContainers
+ || (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
+ ) {
+ return isOverElement;
+ } else {
+
+ return (l < x1 + (this.helperProportions.width / 2) // Right Half
+ && x2 - (this.helperProportions.width / 2) < r // Left Half
+ && t < y1 + (this.helperProportions.height / 2) // Bottom Half
+ && y2 - (this.helperProportions.height / 2) < b ); // Top Half
+
+ }
+ },
+
+ _intersectsWithPointer: function(item) {
+
+ var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
+ isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
+ isOverElement = isOverElementHeight && isOverElementWidth,
+ verticalDirection = this._getDragVerticalDirection(),
+ horizontalDirection = this._getDragHorizontalDirection();
+
+ if (!isOverElement)
+ return false;
+
+ return this.floating ?
+ ( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
+ : ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
+
+ },
+
+ _intersectsWithSides: function(item) {
+
+ var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
+ isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
+ verticalDirection = this._getDragVerticalDirection(),
+ horizontalDirection = this._getDragHorizontalDirection();
+
+ if (this.floating && horizontalDirection) {
+ return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
+ } else {
+ return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
+ }
+
+ },
+
+ _getDragVerticalDirection: function() {
+ var delta = this.positionAbs.top - this.lastPositionAbs.top;
+ return delta != 0 && (delta > 0 ? "down" : "up");
+ },
+
+ _getDragHorizontalDirection: function() {
+ var delta = this.positionAbs.left - this.lastPositionAbs.left;
+ return delta != 0 && (delta > 0 ? "right" : "left");
+ },
+
+ refresh: function(event) {
+ this._refreshItems(event);
+ this.refreshPositions();
+ return this;
+ },
+
+ _connectWith: function() {
+ var options = this.options;
+ return options.connectWith.constructor == String
+ ? [options.connectWith]
+ : options.connectWith;
+ },
+
+ _getItemsAsjQuery: function(connected) {
+
+ var items = [];
+ var queries = [];
+ var connectWith = this._connectWith();
+
+ if(connectWith && connected) {
+ for (var i = connectWith.length - 1; i >= 0; i--){
+ var cur = $(connectWith[i]);
+ for (var j = cur.length - 1; j >= 0; j--){
+ var inst = $.data(cur[j], this.widgetName);
+ if(inst && inst != this && !inst.options.disabled) {
+ queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), inst]);
+ }
+ };
+ };
+ }
+
+ queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), this]);
+
+ for (var i = queries.length - 1; i >= 0; i--){
+ queries[i][0].each(function() {
+ items.push(this);
+ });
+ };
+
+ return $(items);
+
+ },
+
+ _removeCurrentsFromItems: function() {
+
+ var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
+
+ this.items = $.grep(this.items, function (item) {
+ for (var j=0; j < list.length; j++) {
+ if(list[j] == item.item[0])
+ return false;
+ };
+ return true;
+ });
+
+ },
+
+ _refreshItems: function(event) {
+
+ this.items = [];
+ this.containers = [this];
+ var items = this.items;
+ var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
+ var connectWith = this._connectWith();
+
+ if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
+ for (var i = connectWith.length - 1; i >= 0; i--){
+ var cur = $(connectWith[i]);
+ for (var j = cur.length - 1; j >= 0; j--){
+ var inst = $.data(cur[j], this.widgetName);
+ if(inst && inst != this && !inst.options.disabled) {
+ queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
+ this.containers.push(inst);
+ }
+ };
+ };
+ }
+
+ for (var i = queries.length - 1; i >= 0; i--) {
+ var targetData = queries[i][1];
+ var _queries = queries[i][0];
+
+ for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
+ var item = $(_queries[j]);
+
+ item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager)
+
+ items.push({
+ item: item,
+ instance: targetData,
+ width: 0, height: 0,
+ left: 0, top: 0
+ });
+ };
+ };
+
+ },
+
+ refreshPositions: function(fast) {
+
+ //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
+ if(this.offsetParent && this.helper) {
+ this.offset.parent = this._getParentOffset();
+ }
+
+ for (var i = this.items.length - 1; i >= 0; i--){
+ var item = this.items[i];
+
+ //We ignore calculating positions of all connected containers when we're not over them
+ if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0])
+ continue;
+
+ var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
+
+ if (!fast) {
+ item.width = t.outerWidth();
+ item.height = t.outerHeight();
+ }
+
+ var p = t.offset();
+ item.left = p.left;
+ item.top = p.top;
+ };
+
+ if(this.options.custom && this.options.custom.refreshContainers) {
+ this.options.custom.refreshContainers.call(this);
+ } else {
+ for (var i = this.containers.length - 1; i >= 0; i--){
+ var p = this.containers[i].element.offset();
+ this.containers[i].containerCache.left = p.left;
+ this.containers[i].containerCache.top = p.top;
+ this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
+ this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
+ };
+ }
+
+ return this;
+ },
+
+ _createPlaceholder: function(that) {
+ that = that || this;
+ var o = that.options;
+
+ if(!o.placeholder || o.placeholder.constructor == String) {
+ var className = o.placeholder;
+ o.placeholder = {
+ element: function() {
+
+ var el = $(document.createElement(that.currentItem[0].nodeName))
+ .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
+ .removeClass("ui-sortable-helper")[0];
+
+ if(!className)
+ el.style.visibility = "hidden";
+
+ return el;
+ },
+ update: function(container, p) {
+
+ // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
+ // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
+ if(className && !o.forcePlaceholderSize) return;
+
+ //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
+ if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css('paddingTop')||0, 10) - parseInt(that.currentItem.css('paddingBottom')||0, 10)); };
+ if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css('paddingLeft')||0, 10) - parseInt(that.currentItem.css('paddingRight')||0, 10)); };
+ }
+ };
+ }
+
+ //Create the placeholder
+ that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
+
+ //Append it after the actual current item
+ that.currentItem.after(that.placeholder);
+
+ //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
+ o.placeholder.update(that, that.placeholder);
+
+ },
+
+ _contactContainers: function(event) {
+
+ // get innermost container that intersects with item
+ var innermostContainer = null, innermostIndex = null;
+
+
+ for (var i = this.containers.length - 1; i >= 0; i--){
+
+ // never consider a container that's located within the item itself
+ if($.contains(this.currentItem[0], this.containers[i].element[0]))
+ continue;
+
+ if(this._intersectsWith(this.containers[i].containerCache)) {
+
+ // if we've already found a container and it's more "inner" than this, then continue
+ if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0]))
+ continue;
+
+ innermostContainer = this.containers[i];
+ innermostIndex = i;
+
+ } else {
+ // container doesn't intersect. trigger "out" event if necessary
+ if(this.containers[i].containerCache.over) {
+ this.containers[i]._trigger("out", event, this._uiHash(this));
+ this.containers[i].containerCache.over = 0;
+ }
+ }
+
+ }
+
+ // if no intersecting containers found, return
+ if(!innermostContainer) return;
+
+ // move the item into the container if it's not there already
+ if(this.containers.length === 1) {
+ this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
+ this.containers[innermostIndex].containerCache.over = 1;
+ } else {
+
+ //When entering a new container, we will find the item with the least distance and append our item near it
+ var dist = 10000; var itemWithLeastDistance = null;
+ var posProperty = this.containers[innermostIndex].floating ? 'left' : 'top';
+ var sizeProperty = this.containers[innermostIndex].floating ? 'width' : 'height';
+ var base = this.positionAbs[posProperty] + this.offset.click[posProperty];
+ for (var j = this.items.length - 1; j >= 0; j--) {
+ if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
+ if(this.items[j].item[0] == this.currentItem[0]) continue;
+ var cur = this.items[j].item.offset()[posProperty];
+ var nearBottom = false;
+ if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
+ nearBottom = true;
+ cur += this.items[j][sizeProperty];
+ }
+
+ if(Math.abs(cur - base) < dist) {
+ dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
+ this.direction = nearBottom ? "up": "down";
+ }
+ }
+
+ if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
+ return;
+
+ this.currentContainer = this.containers[innermostIndex];
+ itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
+ this._trigger("change", event, this._uiHash());
+ this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
+
+ //Update the placeholder
+ this.options.placeholder.update(this.currentContainer, this.placeholder);
+
+ this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
+ this.containers[innermostIndex].containerCache.over = 1;
+ }
+
+
+ },
+
+ _createHelper: function(event) {
+
+ var o = this.options;
+ var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
+
+ if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
+ $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
+
+ if(helper[0] == this.currentItem[0])
+ this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
+
+ if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
+ if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
+
+ return helper;
+
+ },
+
+ _adjustOffsetFromHelper: function(obj) {
+ if (typeof obj == 'string') {
+ obj = obj.split(' ');
+ }
+ if ($.isArray(obj)) {
+ obj = {left: +obj[0], top: +obj[1] || 0};
+ }
+ if ('left' in obj) {
+ this.offset.click.left = obj.left + this.margins.left;
+ }
+ if ('right' in obj) {
+ this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
+ }
+ if ('top' in obj) {
+ this.offset.click.top = obj.top + this.margins.top;
+ }
+ if ('bottom' in obj) {
+ this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
+ }
+ },
+
+ _getParentOffset: function() {
+
+
+ //Get the offsetParent and cache its position
+ this.offsetParent = this.helper.offsetParent();
+ var po = this.offsetParent.offset();
+
+ // This is a special case where we need to modify a offset calculated on start, since the following happened:
+ // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
+ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
+ // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
+ if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
+ po.left += this.scrollParent.scrollLeft();
+ po.top += this.scrollParent.scrollTop();
+ }
+
+ if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
+ || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.ui.ie)) //Ugly IE fix
+ po = { top: 0, left: 0 };
+
+ return {
+ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
+ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
+ };
+
+ },
+
+ _getRelativeOffset: function() {
+
+ if(this.cssPosition == "relative") {
+ var p = this.currentItem.position();
+ return {
+ top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
+ left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
+ };
+ } else {
+ return { top: 0, left: 0 };
+ }
+
+ },
+
+ _cacheMargins: function() {
+ this.margins = {
+ left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
+ top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
+ };
+ },
+
+ _cacheHelperProportions: function() {
+ this.helperProportions = {
+ width: this.helper.outerWidth(),
+ height: this.helper.outerHeight()
+ };
+ },
+
+ _setContainment: function() {
+
+ var o = this.options;
+ if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
+ if(o.containment == 'document' || o.containment == 'window') this.containment = [
+ 0 - this.offset.relative.left - this.offset.parent.left,
+ 0 - this.offset.relative.top - this.offset.parent.top,
+ $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
+ ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
+ ];
+
+ if(!(/^(document|window|parent)$/).test(o.containment)) {
+ var ce = $(o.containment)[0];
+ var co = $(o.containment).offset();
+ var over = ($(ce).css("overflow") != 'hidden');
+
+ this.containment = [
+ co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
+ co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
+ co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
+ co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
+ ];
+ }
+
+ },
+
+ _convertPositionTo: function(d, pos) {
+
+ if(!pos) pos = this.position;
+ var mod = d == "absolute" ? 1 : -1;
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+
+ return {
+ top: (
+ pos.top // The absolute mouse position
+ + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
+ + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
+ - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
+ ),
+ left: (
+ pos.left // The absolute mouse position
+ + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
+ + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
+ - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
+ )
+ };
+
+ },
+
+ _generatePosition: function(event) {
+
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+
+ // This is another very weird special case that only happens for relative elements:
+ // 1. If the css position is relative
+ // 2. and the scroll parent is the document or similar to the offset parent
+ // we have to refresh the relative offset during the scroll so there are no jumps
+ if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
+ this.offset.relative = this._getRelativeOffset();
+ }
+
+ var pageX = event.pageX;
+ var pageY = event.pageY;
+
+ /*
+ * - Position constraining -
+ * Constrain the position to a mix of grid, containment.
+ */
+
+ if(this.originalPosition) { //If we are not dragging yet, we won't check for options
+
+ if(this.containment) {
+ if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
+ if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
+ if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
+ if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
+ }
+
+ if(o.grid) {
+ var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
+ pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
+
+ var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
+ pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
+ }
+
+ }
+
+ return {
+ top: (
+ pageY // The absolute mouse position
+ - this.offset.click.top // Click offset (relative to the element)
+ - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
+ - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
+ + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
+ ),
+ left: (
+ pageX // The absolute mouse position
+ - this.offset.click.left // Click offset (relative to the element)
+ - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
+ - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
+ + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
+ )
+ };
+
+ },
+
+ _rearrange: function(event, i, a, hardRefresh) {
+
+ a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction == 'down' ? i.item[0] : i.item[0].nextSibling));
+
+ //Various things done here to improve the performance:
+ // 1. we create a setTimeout, that calls refreshPositions
+ // 2. on the instance, we have a counter variable, that get's higher after every append
+ // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
+ // 4. this lets only the last addition to the timeout stack through
+ this.counter = this.counter ? ++this.counter : 1;
+ var counter = this.counter;
+
+ this._delay(function() {
+ if(counter == this.counter) this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
+ });
+
+ },
+
+ _clear: function(event, noPropagation) {
+
+ this.reverting = false;
+ // We delay all events that have to be triggered to after the point where the placeholder has been removed and
+ // everything else normalized again
+ var delayedTriggers = [];
+
+ // We first have to update the dom position of the actual currentItem
+ // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
+ if(!this._noFinalSort && this.currentItem.parent().length) this.placeholder.before(this.currentItem);
+ this._noFinalSort = null;
+
+ if(this.helper[0] == this.currentItem[0]) {
+ for(var i in this._storedCSS) {
+ if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
+ }
+ this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
+ } else {
+ this.currentItem.show();
+ }
+
+ if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
+ if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
+
+ // Check if the items Container has Changed and trigger appropriate
+ // events.
+ if (this !== this.currentContainer) {
+ if(!noPropagation) {
+ delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
+ }
+ }
+
+
+ //Post events to containers
+ for (var i = this.containers.length - 1; i >= 0; i--){
+ if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
+ if(this.containers[i].containerCache.over) {
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
+ this.containers[i].containerCache.over = 0;
+ }
+ }
+
+ //Do what was originally in plugins
+ if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
+ if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity
+ if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
+
+ this.dragging = false;
+ if(this.cancelHelperRemoval) {
+ if(!noPropagation) {
+ this._trigger("beforeStop", event, this._uiHash());
+ for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
+ this._trigger("stop", event, this._uiHash());
+ }
+
+ this.fromOutside = false;
+ return false;
+ }
+
+ if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
+
+ //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
+ this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
+
+ if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
+
+ if(!noPropagation) {
+ for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
+ this._trigger("stop", event, this._uiHash());
+ }
+
+ this.fromOutside = false;
+ return true;
+
+ },
+
+ _trigger: function() {
+ if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
+ this.cancel();
+ }
+ },
+
+ _uiHash: function(_inst) {
+ var inst = _inst || this;
+ return {
+ helper: inst.helper,
+ placeholder: inst.placeholder || $([]),
+ position: inst.position,
+ originalPosition: inst.originalPosition,
+ offset: inst.positionAbs,
+ item: inst.currentItem,
+ sender: _inst ? _inst.element : null
+ };
+ }
+
+});
+
+})(jQuery);
+(function( $, undefined ) {
+
+var uid = 0,
+ hideProps = {},
+ showProps = {};
+
+hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
+ hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
+showProps.height = showProps.paddingTop = showProps.paddingBottom =
+ showProps.borderTopWidth = showProps.borderBottomWidth = "show";
+
+$.widget( "ui.accordion", {
+ version: "1.9.2",
+ options: {
+ active: 0,
+ animate: {},
+ collapsible: false,
+ event: "click",
+ header: "> li > :first-child,> :not(li):even",
+ heightStyle: "auto",
+ icons: {
+ activeHeader: "ui-icon-triangle-1-s",
+ header: "ui-icon-triangle-1-e"
+ },
+
+ // callbacks
+ activate: null,
+ beforeActivate: null
+ },
+
+ _create: function() {
+ var accordionId = this.accordionId = "ui-accordion-" +
+ (this.element.attr( "id" ) || ++uid),
+ options = this.options;
+
+ this.prevShow = this.prevHide = $();
+ this.element.addClass( "ui-accordion ui-widget ui-helper-reset" );
+
+ this.headers = this.element.find( options.header )
+ .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
+ this._hoverable( this.headers );
+ this._focusable( this.headers );
+
+ this.headers.next()
+ .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
+ .hide();
+
+ // don't allow collapsible: false and active: false / null
+ if ( !options.collapsible && (options.active === false || options.active == null) ) {
+ options.active = 0;
+ }
+ // handle negative values
+ if ( options.active < 0 ) {
+ options.active += this.headers.length;
+ }
+ this.active = this._findActive( options.active )
+ .addClass( "ui-accordion-header-active ui-state-active" )
+ .toggleClass( "ui-corner-all ui-corner-top" );
+ this.active.next()
+ .addClass( "ui-accordion-content-active" )
+ .show();
+
+ this._createIcons();
+ this.refresh();
+
+ // ARIA
+ this.element.attr( "role", "tablist" );
+
+ this.headers
+ .attr( "role", "tab" )
+ .each(function( i ) {
+ var header = $( this ),
+ headerId = header.attr( "id" ),
+ panel = header.next(),
+ panelId = panel.attr( "id" );
+ if ( !headerId ) {
+ headerId = accordionId + "-header-" + i;
+ header.attr( "id", headerId );
+ }
+ if ( !panelId ) {
+ panelId = accordionId + "-panel-" + i;
+ panel.attr( "id", panelId );
+ }
+ header.attr( "aria-controls", panelId );
+ panel.attr( "aria-labelledby", headerId );
+ })
+ .next()
+ .attr( "role", "tabpanel" );
+
+ this.headers
+ .not( this.active )
+ .attr({
+ "aria-selected": "false",
+ tabIndex: -1
+ })
+ .next()
+ .attr({
+ "aria-expanded": "false",
+ "aria-hidden": "true"
+ })
+ .hide();
+
+ // make sure at least one header is in the tab order
+ if ( !this.active.length ) {
+ this.headers.eq( 0 ).attr( "tabIndex", 0 );
+ } else {
+ this.active.attr({
+ "aria-selected": "true",
+ tabIndex: 0
+ })
+ .next()
+ .attr({
+ "aria-expanded": "true",
+ "aria-hidden": "false"
+ });
+ }
+
+ this._on( this.headers, { keydown: "_keydown" });
+ this._on( this.headers.next(), { keydown: "_panelKeyDown" });
+ this._setupEvents( options.event );
+ },
+
+ _getCreateEventData: function() {
+ return {
+ header: this.active,
+ content: !this.active.length ? $() : this.active.next()
+ };
+ },
+
+ _createIcons: function() {
+ var icons = this.options.icons;
+ if ( icons ) {
+ $( "<span>" )
+ .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
+ .prependTo( this.headers );
+ this.active.children( ".ui-accordion-header-icon" )
+ .removeClass( icons.header )
+ .addClass( icons.activeHeader );
+ this.headers.addClass( "ui-accordion-icons" );
+ }
+ },
+
+ _destroyIcons: function() {
+ this.headers
+ .removeClass( "ui-accordion-icons" )
+ .children( ".ui-accordion-header-icon" )
+ .remove();
+ },
+
+ _destroy: function() {
+ var contents;
+
+ // clean up main element
+ this.element
+ .removeClass( "ui-accordion ui-widget ui-helper-reset" )
+ .removeAttr( "role" );
+
+ // clean up headers
+ this.headers
+ .removeClass( "ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-selected" )
+ .removeAttr( "aria-controls" )
+ .removeAttr( "tabIndex" )
+ .each(function() {
+ if ( /^ui-accordion/.test( this.id ) ) {
+ this.removeAttribute( "id" );
+ }
+ });
+ this._destroyIcons();
+
+ // clean up content panels
+ contents = this.headers.next()
+ .css( "display", "" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-expanded" )
+ .removeAttr( "aria-hidden" )
+ .removeAttr( "aria-labelledby" )
+ .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
+ .each(function() {
+ if ( /^ui-accordion/.test( this.id ) ) {
+ this.removeAttribute( "id" );
+ }
+ });
+ if ( this.options.heightStyle !== "content" ) {
+ contents.css( "height", "" );
+ }
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "active" ) {
+ // _activate() will handle invalid values and update this.options
+ this._activate( value );
+ return;
+ }
+
+ if ( key === "event" ) {
+ if ( this.options.event ) {
+ this._off( this.headers, this.options.event );
+ }
+ this._setupEvents( value );
+ }
+
+ this._super( key, value );
+
+ // setting collapsible: false while collapsed; open first panel
+ if ( key === "collapsible" && !value && this.options.active === false ) {
+ this._activate( 0 );
+ }
+
+ if ( key === "icons" ) {
+ this._destroyIcons();
+ if ( value ) {
+ this._createIcons();
+ }
+ }
+
+ // #5332 - opacity doesn't cascade to positioned elements in IE
+ // so we need to add the disabled class to the headers and panels
+ if ( key === "disabled" ) {
+ this.headers.add( this.headers.next() )
+ .toggleClass( "ui-state-disabled", !!value );
+ }
+ },
+
+ _keydown: function( event ) {
+ if ( event.altKey || event.ctrlKey ) {
+ return;
+ }
+
+ var keyCode = $.ui.keyCode,
+ length = this.headers.length,
+ currentIndex = this.headers.index( event.target ),
+ toFocus = false;
+
+ switch ( event.keyCode ) {
+ case keyCode.RIGHT:
+ case keyCode.DOWN:
+ toFocus = this.headers[ ( currentIndex + 1 ) % length ];
+ break;
+ case keyCode.LEFT:
+ case keyCode.UP:
+ toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
+ break;
+ case keyCode.SPACE:
+ case keyCode.ENTER:
+ this._eventHandler( event );
+ break;
+ case keyCode.HOME:
+ toFocus = this.headers[ 0 ];
+ break;
+ case keyCode.END:
+ toFocus = this.headers[ length - 1 ];
+ break;
+ }
+
+ if ( toFocus ) {
+ $( event.target ).attr( "tabIndex", -1 );
+ $( toFocus ).attr( "tabIndex", 0 );
+ toFocus.focus();
+ event.preventDefault();
+ }
+ },
+
+ _panelKeyDown : function( event ) {
+ if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
+ $( event.currentTarget ).prev().focus();
+ }
+ },
+
+ refresh: function() {
+ var maxHeight, overflow,
+ heightStyle = this.options.heightStyle,
+ parent = this.element.parent();
+
+
+ if ( heightStyle === "fill" ) {
+ // IE 6 treats height like minHeight, so we need to turn off overflow
+ // in order to get a reliable height
+ // we use the minHeight support test because we assume that only
+ // browsers that don't support minHeight will treat height as minHeight
+ if ( !$.support.minHeight ) {
+ overflow = parent.css( "overflow" );
+ parent.css( "overflow", "hidden");
+ }
+ maxHeight = parent.height();
+ this.element.siblings( ":visible" ).each(function() {
+ var elem = $( this ),
+ position = elem.css( "position" );
+
+ if ( position === "absolute" || position === "fixed" ) {
+ return;
+ }
+ maxHeight -= elem.outerHeight( true );
+ });
+ if ( overflow ) {
+ parent.css( "overflow", overflow );
+ }
+
+ this.headers.each(function() {
+ maxHeight -= $( this ).outerHeight( true );
+ });
+
+ this.headers.next()
+ .each(function() {
+ $( this ).height( Math.max( 0, maxHeight -
+ $( this ).innerHeight() + $( this ).height() ) );
+ })
+ .css( "overflow", "auto" );
+ } else if ( heightStyle === "auto" ) {
+ maxHeight = 0;
+ this.headers.next()
+ .each(function() {
+ maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
+ })
+ .height( maxHeight );
+ }
+ },
+
+ _activate: function( index ) {
+ var active = this._findActive( index )[ 0 ];
+
+ // trying to activate the already active panel
+ if ( active === this.active[ 0 ] ) {
+ return;
+ }
+
+ // trying to collapse, simulate a click on the currently active header
+ active = active || this.active[ 0 ];
+
+ this._eventHandler({
+ target: active,
+ currentTarget: active,
+ preventDefault: $.noop
+ });
+ },
+
+ _findActive: function( selector ) {
+ return typeof selector === "number" ? this.headers.eq( selector ) : $();
+ },
+
+ _setupEvents: function( event ) {
+ var events = {};
+ if ( !event ) {
+ return;
+ }
+ $.each( event.split(" "), function( index, eventName ) {
+ events[ eventName ] = "_eventHandler";
+ });
+ this._on( this.headers, events );
+ },
+
+ _eventHandler: function( event ) {
+ var options = this.options,
+ active = this.active,
+ clicked = $( event.currentTarget ),
+ clickedIsActive = clicked[ 0 ] === active[ 0 ],
+ collapsing = clickedIsActive && options.collapsible,
+ toShow = collapsing ? $() : clicked.next(),
+ toHide = active.next(),
+ eventData = {
+ oldHeader: active,
+ oldPanel: toHide,
+ newHeader: collapsing ? $() : clicked,
+ newPanel: toShow
+ };
+
+ event.preventDefault();
+
+ if (
+ // click on active header, but not collapsible
+ ( clickedIsActive && !options.collapsible ) ||
+ // allow canceling activation
+ ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
+ return;
+ }
+
+ options.active = collapsing ? false : this.headers.index( clicked );
+
+ // when the call to ._toggle() comes after the class changes
+ // it causes a very odd bug in IE 8 (see #6720)
+ this.active = clickedIsActive ? $() : clicked;
+ this._toggle( eventData );
+
+ // switch classes
+ // corner classes on the previously active header stay after the animation
+ active.removeClass( "ui-accordion-header-active ui-state-active" );
+ if ( options.icons ) {
+ active.children( ".ui-accordion-header-icon" )
+ .removeClass( options.icons.activeHeader )
+ .addClass( options.icons.header );
+ }
+
+ if ( !clickedIsActive ) {
+ clicked
+ .removeClass( "ui-corner-all" )
+ .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
+ if ( options.icons ) {
+ clicked.children( ".ui-accordion-header-icon" )
+ .removeClass( options.icons.header )
+ .addClass( options.icons.activeHeader );
+ }
+
+ clicked
+ .next()
+ .addClass( "ui-accordion-content-active" );
+ }
+ },
+
+ _toggle: function( data ) {
+ var toShow = data.newPanel,
+ toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
+
+ // handle activating a panel during the animation for another activation
+ this.prevShow.add( this.prevHide ).stop( true, true );
+ this.prevShow = toShow;
+ this.prevHide = toHide;
+
+ if ( this.options.animate ) {
+ this._animate( toShow, toHide, data );
+ } else {
+ toHide.hide();
+ toShow.show();
+ this._toggleComplete( data );
+ }
+
+ toHide.attr({
+ "aria-expanded": "false",
+ "aria-hidden": "true"
+ });
+ toHide.prev().attr( "aria-selected", "false" );
+ // if we're switching panels, remove the old header from the tab order
+ // if we're opening from collapsed state, remove the previous header from the tab order
+ // if we're collapsing, then keep the collapsing header in the tab order
+ if ( toShow.length && toHide.length ) {
+ toHide.prev().attr( "tabIndex", -1 );
+ } else if ( toShow.length ) {
+ this.headers.filter(function() {
+ return $( this ).attr( "tabIndex" ) === 0;
+ })
+ .attr( "tabIndex", -1 );
+ }
+
+ toShow
+ .attr({
+ "aria-expanded": "true",
+ "aria-hidden": "false"
+ })
+ .prev()
+ .attr({
+ "aria-selected": "true",
+ tabIndex: 0
+ });
+ },
+
+ _animate: function( toShow, toHide, data ) {
+ var total, easing, duration,
+ that = this,
+ adjust = 0,
+ down = toShow.length &&
+ ( !toHide.length || ( toShow.index() < toHide.index() ) ),
+ animate = this.options.animate || {},
+ options = down && animate.down || animate,
+ complete = function() {
+ that._toggleComplete( data );
+ };
+
+ if ( typeof options === "number" ) {
+ duration = options;
+ }
+ if ( typeof options === "string" ) {
+ easing = options;
+ }
+ // fall back from options to animation in case of partial down settings
+ easing = easing || options.easing || animate.easing;
+ duration = duration || options.duration || animate.duration;
+
+ if ( !toHide.length ) {
+ return toShow.animate( showProps, duration, easing, complete );
+ }
+ if ( !toShow.length ) {
+ return toHide.animate( hideProps, duration, easing, complete );
+ }
+
+ total = toShow.show().outerHeight();
+ toHide.animate( hideProps, {
+ duration: duration,
+ easing: easing,
+ step: function( now, fx ) {
+ fx.now = Math.round( now );
+ }
+ });
+ toShow
+ .hide()
+ .animate( showProps, {
+ duration: duration,
+ easing: easing,
+ complete: complete,
+ step: function( now, fx ) {
+ fx.now = Math.round( now );
+ if ( fx.prop !== "height" ) {
+ adjust += fx.now;
+ } else if ( that.options.heightStyle !== "content" ) {
+ fx.now = Math.round( total - toHide.outerHeight() - adjust );
+ adjust = 0;
+ }
+ }
+ });
+ },
+
+ _toggleComplete: function( data ) {
+ var toHide = data.oldPanel;
+
+ toHide
+ .removeClass( "ui-accordion-content-active" )
+ .prev()
+ .removeClass( "ui-corner-top" )
+ .addClass( "ui-corner-all" );
+
+ // Work around for rendering bug in IE (#5421)
+ if ( toHide.length ) {
+ toHide.parent()[0].className = toHide.parent()[0].className;
+ }
+
+ this._trigger( "activate", null, data );
+ }
+});
+
+
+
+// DEPRECATED
+if ( $.uiBackCompat !== false ) {
+ // navigation options
+ (function( $, prototype ) {
+ $.extend( prototype.options, {
+ navigation: false,
+ navigationFilter: function() {
+ return this.href.toLowerCase() === location.href.toLowerCase();
+ }
+ });
+
+ var _create = prototype._create;
+ prototype._create = function() {
+ if ( this.options.navigation ) {
+ var that = this,
+ headers = this.element.find( this.options.header ),
+ content = headers.next(),
+ current = headers.add( content )
+ .find( "a" )
+ .filter( this.options.navigationFilter )
+ [ 0 ];
+ if ( current ) {
+ headers.add( content ).each( function( index ) {
+ if ( $.contains( this, current ) ) {
+ that.options.active = Math.floor( index / 2 );
+ return false;
+ }
+ });
+ }
+ }
+ _create.call( this );
+ };
+ }( jQuery, jQuery.ui.accordion.prototype ) );
+
+ // height options
+ (function( $, prototype ) {
+ $.extend( prototype.options, {
+ heightStyle: null, // remove default so we fall back to old values
+ autoHeight: true, // use heightStyle: "auto"
+ clearStyle: false, // use heightStyle: "content"
+ fillSpace: false // use heightStyle: "fill"
+ });
+
+ var _create = prototype._create,
+ _setOption = prototype._setOption;
+
+ $.extend( prototype, {
+ _create: function() {
+ this.options.heightStyle = this.options.heightStyle ||
+ this._mergeHeightStyle();
+
+ _create.call( this );
+ },
+
+ _setOption: function( key ) {
+ if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {
+ this.options.heightStyle = this._mergeHeightStyle();
+ }
+ _setOption.apply( this, arguments );
+ },
+
+ _mergeHeightStyle: function() {
+ var options = this.options;
+
+ if ( options.fillSpace ) {
+ return "fill";
+ }
+
+ if ( options.clearStyle ) {
+ return "content";
+ }
+
+ if ( options.autoHeight ) {
+ return "auto";
+ }
+ }
+ });
+ }( jQuery, jQuery.ui.accordion.prototype ) );
+
+ // icon options
+ (function( $, prototype ) {
+ $.extend( prototype.options.icons, {
+ activeHeader: null, // remove default so we fall back to old values
+ headerSelected: "ui-icon-triangle-1-s"
+ });
+
+ var _createIcons = prototype._createIcons;
+ prototype._createIcons = function() {
+ if ( this.options.icons ) {
+ this.options.icons.activeHeader = this.options.icons.activeHeader ||
+ this.options.icons.headerSelected;
+ }
+ _createIcons.call( this );
+ };
+ }( jQuery, jQuery.ui.accordion.prototype ) );
+
+ // expanded active option, activate method
+ (function( $, prototype ) {
+ prototype.activate = prototype._activate;
+
+ var _findActive = prototype._findActive;
+ prototype._findActive = function( index ) {
+ if ( index === -1 ) {
+ index = false;
+ }
+ if ( index && typeof index !== "number" ) {
+ index = this.headers.index( this.headers.filter( index ) );
+ if ( index === -1 ) {
+ index = false;
+ }
+ }
+ return _findActive.call( this, index );
+ };
+ }( jQuery, jQuery.ui.accordion.prototype ) );
+
+ // resize method
+ jQuery.ui.accordion.prototype.resize = jQuery.ui.accordion.prototype.refresh;
+
+ // change events
+ (function( $, prototype ) {
+ $.extend( prototype.options, {
+ change: null,
+ changestart: null
+ });
+
+ var _trigger = prototype._trigger;
+ prototype._trigger = function( type, event, data ) {
+ var ret = _trigger.apply( this, arguments );
+ if ( !ret ) {
+ return false;
+ }
+
+ if ( type === "beforeActivate" ) {
+ ret = _trigger.call( this, "changestart", event, {
+ oldHeader: data.oldHeader,
+ oldContent: data.oldPanel,
+ newHeader: data.newHeader,
+ newContent: data.newPanel
+ });
+ } else if ( type === "activate" ) {
+ ret = _trigger.call( this, "change", event, {
+ oldHeader: data.oldHeader,
+ oldContent: data.oldPanel,
+ newHeader: data.newHeader,
+ newContent: data.newPanel
+ });
+ }
+ return ret;
+ };
+ }( jQuery, jQuery.ui.accordion.prototype ) );
+
+ // animated option
+ // NOTE: this only provides support for "slide", "bounceslide", and easings
+ // not the full $.ui.accordion.animations API
+ (function( $, prototype ) {
+ $.extend( prototype.options, {
+ animate: null,
+ animated: "slide"
+ });
+
+ var _create = prototype._create;
+ prototype._create = function() {
+ var options = this.options;
+ if ( options.animate === null ) {
+ if ( !options.animated ) {
+ options.animate = false;
+ } else if ( options.animated === "slide" ) {
+ options.animate = 300;
+ } else if ( options.animated === "bounceslide" ) {
+ options.animate = {
+ duration: 200,
+ down: {
+ easing: "easeOutBounce",
+ duration: 1000
+ }
+ };
+ } else {
+ options.animate = options.animated;
+ }
+ }
+
+ _create.call( this );
+ };
+ }( jQuery, jQuery.ui.accordion.prototype ) );
+}
+
+})( jQuery );
+(function( $, undefined ) {
+
+// used to prevent race conditions with remote data sources
+var requestIndex = 0;
+
+$.widget( "ui.autocomplete", {
+ version: "1.9.2",
+ defaultElement: "<input>",
+ options: {
+ appendTo: "body",
+ autoFocus: false,
+ delay: 300,
+ minLength: 1,
+ position: {
+ my: "left top",
+ at: "left bottom",
+ collision: "none"
+ },
+ source: null,
+
+ // callbacks
+ change: null,
+ close: null,
+ focus: null,
+ open: null,
+ response: null,
+ search: null,
+ select: null
+ },
+
+ pending: 0,
+
+ _create: function() {
+ // Some browsers only repeat keydown events, not keypress events,
+ // so we use the suppressKeyPress flag to determine if we've already
+ // handled the keydown event. #7269
+ // Unfortunately the code for & in keypress is the same as the up arrow,
+ // so we use the suppressKeyPressRepeat flag to avoid handling keypress
+ // events when we know the keydown event was used to modify the
+ // search term. #7799
+ var suppressKeyPress, suppressKeyPressRepeat, suppressInput;
+
+ this.isMultiLine = this._isMultiLine();
+ this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
+ this.isNewMenu = true;
+
+ this.element
+ .addClass( "ui-autocomplete-input" )
+ .attr( "autocomplete", "off" );
+
+ this._on( this.element, {
+ keydown: function( event ) {
+ if ( this.element.prop( "readOnly" ) ) {
+ suppressKeyPress = true;
+ suppressInput = true;
+ suppressKeyPressRepeat = true;
+ return;
+ }
+
+ suppressKeyPress = false;
+ suppressInput = false;
+ suppressKeyPressRepeat = false;
+ var keyCode = $.ui.keyCode;
+ switch( event.keyCode ) {
+ case keyCode.PAGE_UP:
+ suppressKeyPress = true;
+ this._move( "previousPage", event );
+ break;
+ case keyCode.PAGE_DOWN:
+ suppressKeyPress = true;
+ this._move( "nextPage", event );
+ break;
+ case keyCode.UP:
+ suppressKeyPress = true;
+ this._keyEvent( "previous", event );
+ break;
+ case keyCode.DOWN:
+ suppressKeyPress = true;
+ this._keyEvent( "next", event );
+ break;
+ case keyCode.ENTER:
+ case keyCode.NUMPAD_ENTER:
+ // when menu is open and has focus
+ if ( this.menu.active ) {
+ // #6055 - Opera still allows the keypress to occur
+ // which causes forms to submit
+ suppressKeyPress = true;
+ event.preventDefault();
+ this.menu.select( event );
+ }
+ break;
+ case keyCode.TAB:
+ if ( this.menu.active ) {
+ this.menu.select( event );
+ }
+ break;
+ case keyCode.ESCAPE:
+ if ( this.menu.element.is( ":visible" ) ) {
+ this._value( this.term );
+ this.close( event );
+ // Different browsers have different default behavior for escape
+ // Single press can mean undo or clear
+ // Double press in IE means clear the whole form
+ event.preventDefault();
+ }
+ break;
+ default:
+ suppressKeyPressRepeat = true;
+ // search timeout should be triggered before the input value is changed
+ this._searchTimeout( event );
+ break;
+ }
+ },
+ keypress: function( event ) {
+ if ( suppressKeyPress ) {
+ suppressKeyPress = false;
+ event.preventDefault();
+ return;
+ }
+ if ( suppressKeyPressRepeat ) {
+ return;
+ }
+
+ // replicate some key handlers to allow them to repeat in Firefox and Opera
+ var keyCode = $.ui.keyCode;
+ switch( event.keyCode ) {
+ case keyCode.PAGE_UP:
+ this._move( "previousPage", event );
+ break;
+ case keyCode.PAGE_DOWN:
+ this._move( "nextPage", event );
+ break;
+ case keyCode.UP:
+ this._keyEvent( "previous", event );
+ break;
+ case keyCode.DOWN:
+ this._keyEvent( "next", event );
+ break;
+ }
+ },
+ input: function( event ) {
+ if ( suppressInput ) {
+ suppressInput = false;
+ event.preventDefault();
+ return;
+ }
+ this._searchTimeout( event );
+ },
+ focus: function() {
+ this.selectedItem = null;
+ this.previous = this._value();
+ },
+ blur: function( event ) {
+ if ( this.cancelBlur ) {
+ delete this.cancelBlur;
+ return;
+ }
+
+ clearTimeout( this.searching );
+ this.close( event );
+ this._change( event );
+ }
+ });
+
+ this._initSource();
+ this.menu = $( "<ul>" )
+ .addClass( "ui-autocomplete" )
+ .appendTo( this.document.find( this.options.appendTo || "body" )[ 0 ] )
+ .menu({
+ // custom key handling for now
+ input: $(),
+ // disable ARIA support, the live region takes care of that
+ role: null
+ })
+ .zIndex( this.element.zIndex() + 1 )
+ .hide()
+ .data( "menu" );
+
+ this._on( this.menu.element, {
+ mousedown: function( event ) {
+ // prevent moving focus out of the text field
+ event.preventDefault();
+
+ // IE doesn't prevent moving focus even with event.preventDefault()
+ // so we set a flag to know when we should ignore the blur event
+ this.cancelBlur = true;
+ this._delay(function() {
+ delete this.cancelBlur;
+ });
+
+ // clicking on the scrollbar causes focus to shift to the body
+ // but we can't detect a mouseup or a click immediately afterward
+ // so we have to track the next mousedown and close the menu if
+ // the user clicks somewhere outside of the autocomplete
+ var menuElement = this.menu.element[ 0 ];
+ if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
+ this._delay(function() {
+ var that = this;
+ this.document.one( "mousedown", function( event ) {
+ if ( event.target !== that.element[ 0 ] &&
+ event.target !== menuElement &&
+ !$.contains( menuElement, event.target ) ) {
+ that.close();
+ }
+ });
+ });
+ }
+ },
+ menufocus: function( event, ui ) {
+ // #7024 - Prevent accidental activation of menu items in Firefox
+ if ( this.isNewMenu ) {
+ this.isNewMenu = false;
+ if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
+ this.menu.blur();
+
+ this.document.one( "mousemove", function() {
+ $( event.target ).trigger( event.originalEvent );
+ });
+
+ return;
+ }
+ }
+
+ // back compat for _renderItem using item.autocomplete, via #7810
+ // TODO remove the fallback, see #8156
+ var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" );
+ if ( false !== this._trigger( "focus", event, { item: item } ) ) {
+ // use value to match what will end up in the input, if it was a key event
+ if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
+ this._value( item.value );
+ }
+ } else {
+ // Normally the input is populated with the item's value as the
+ // menu is navigated, causing screen readers to notice a change and
+ // announce the item. Since the focus event was canceled, this doesn't
+ // happen, so we update the live region so that screen readers can
+ // still notice the change and announce it.
+ this.liveRegion.text( item.value );
+ }
+ },
+ menuselect: function( event, ui ) {
+ // back compat for _renderItem using item.autocomplete, via #7810
+ // TODO remove the fallback, see #8156
+ var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ),
+ previous = this.previous;
+
+ // only trigger when focus was lost (click on menu)
+ if ( this.element[0] !== this.document[0].activeElement ) {
+ this.element.focus();
+ this.previous = previous;
+ // #6109 - IE triggers two focus events and the second
+ // is asynchronous, so we need to reset the previous
+ // term synchronously and asynchronously :-(
+ this._delay(function() {
+ this.previous = previous;
+ this.selectedItem = item;
+ });
+ }
+
+ if ( false !== this._trigger( "select", event, { item: item } ) ) {
+ this._value( item.value );
+ }
+ // reset the term after the select event
+ // this allows custom select handling to work properly
+ this.term = this._value();
+
+ this.close( event );
+ this.selectedItem = item;
+ }
+ });
+
+ this.liveRegion = $( "<span>", {
+ role: "status",
+ "aria-live": "polite"
+ })
+ .addClass( "ui-helper-hidden-accessible" )
+ .insertAfter( this.element );
+
+ if ( $.fn.bgiframe ) {
+ this.menu.element.bgiframe();
+ }
+
+ // turning off autocomplete prevents the browser from remembering the
+ // value when navigating through history, so we re-enable autocomplete
+ // if the page is unloaded before the widget is destroyed. #7790
+ this._on( this.window, {
+ beforeunload: function() {
+ this.element.removeAttr( "autocomplete" );
+ }
+ });
+ },
+
+ _destroy: function() {
+ clearTimeout( this.searching );
+ this.element
+ .removeClass( "ui-autocomplete-input" )
+ .removeAttr( "autocomplete" );
+ this.menu.element.remove();
+ this.liveRegion.remove();
+ },
+
+ _setOption: function( key, value ) {
+ this._super( key, value );
+ if ( key === "source" ) {
+ this._initSource();
+ }
+ if ( key === "appendTo" ) {
+ this.menu.element.appendTo( this.document.find( value || "body" )[0] );
+ }
+ if ( key === "disabled" && value && this.xhr ) {
+ this.xhr.abort();
+ }
+ },
+
+ _isMultiLine: function() {
+ // Textareas are always multi-line
+ if ( this.element.is( "textarea" ) ) {
+ return true;
+ }
+ // Inputs are always single-line, even if inside a contentEditable element
+ // IE also treats inputs as contentEditable
+ if ( this.element.is( "input" ) ) {
+ return false;
+ }
+ // All other element types are determined by whether or not they're contentEditable
+ return this.element.prop( "isContentEditable" );
+ },
+
+ _initSource: function() {
+ var array, url,
+ that = this;
+ if ( $.isArray(this.options.source) ) {
+ array = this.options.source;
+ this.source = function( request, response ) {
+ response( $.ui.autocomplete.filter( array, request.term ) );
+ };
+ } else if ( typeof this.options.source === "string" ) {
+ url = this.options.source;
+ this.source = function( request, response ) {
+ if ( that.xhr ) {
+ that.xhr.abort();
+ }
+ that.xhr = $.ajax({
+ url: url,
+ data: request,
+ dataType: "json",
+ success: function( data ) {
+ response( data );
+ },
+ error: function() {
+ response( [] );
+ }
+ });
+ };
+ } else {
+ this.source = this.options.source;
+ }
+ },
+
+ _searchTimeout: function( event ) {
+ clearTimeout( this.searching );
+ this.searching = this._delay(function() {
+ // only search if the value has changed
+ if ( this.term !== this._value() ) {
+ this.selectedItem = null;
+ this.search( null, event );
+ }
+ }, this.options.delay );
+ },
+
+ search: function( value, event ) {
+ value = value != null ? value : this._value();
+
+ // always save the actual value, not the one passed as an argument
+ this.term = this._value();
+
+ if ( value.length < this.options.minLength ) {
+ return this.close( event );
+ }
+
+ if ( this._trigger( "search", event ) === false ) {
+ return;
+ }
+
+ return this._search( value );
+ },
+
+ _search: function( value ) {
+ this.pending++;
+ this.element.addClass( "ui-autocomplete-loading" );
+ this.cancelSearch = false;
+
+ this.source( { term: value }, this._response() );
+ },
+
+ _response: function() {
+ var that = this,
+ index = ++requestIndex;
+
+ return function( content ) {
+ if ( index === requestIndex ) {
+ that.__response( content );
+ }
+
+ that.pending--;
+ if ( !that.pending ) {
+ that.element.removeClass( "ui-autocomplete-loading" );
+ }
+ };
+ },
+
+ __response: function( content ) {
+ if ( content ) {
+ content = this._normalize( content );
+ }
+ this._trigger( "response", null, { content: content } );
+ if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
+ this._suggest( content );
+ this._trigger( "open" );
+ } else {
+ // use ._close() instead of .close() so we don't cancel future searches
+ this._close();
+ }
+ },
+
+ close: function( event ) {
+ this.cancelSearch = true;
+ this._close( event );
+ },
+
+ _close: function( event ) {
+ if ( this.menu.element.is( ":visible" ) ) {
+ this.menu.element.hide();
+ this.menu.blur();
+ this.isNewMenu = true;
+ this._trigger( "close", event );
+ }
+ },
+
+ _change: function( event ) {
+ if ( this.previous !== this._value() ) {
+ this._trigger( "change", event, { item: this.selectedItem } );
+ }
+ },
+
+ _normalize: function( items ) {
+ // assume all items have the right format when the first item is complete
+ if ( items.length && items[0].label && items[0].value ) {
+ return items;
+ }
+ return $.map( items, function( item ) {
+ if ( typeof item === "string" ) {
+ return {
+ label: item,
+ value: item
+ };
+ }
+ return $.extend({
+ label: item.label || item.value,
+ value: item.value || item.label
+ }, item );
+ });
+ },
+
+ _suggest: function( items ) {
+ var ul = this.menu.element
+ .empty()
+ .zIndex( this.element.zIndex() + 1 );
+ this._renderMenu( ul, items );
+ this.menu.refresh();
+
+ // size and position menu
+ ul.show();
+ this._resizeMenu();
+ ul.position( $.extend({
+ of: this.element
+ }, this.options.position ));
+
+ if ( this.options.autoFocus ) {
+ this.menu.next();
+ }
+ },
+
+ _resizeMenu: function() {
+ var ul = this.menu.element;
+ ul.outerWidth( Math.max(
+ // Firefox wraps long text (possibly a rounding bug)
+ // so we add 1px to avoid the wrapping (#7513)
+ ul.width( "" ).outerWidth() + 1,
+ this.element.outerWidth()
+ ) );
+ },
+
+ _renderMenu: function( ul, items ) {
+ var that = this;
+ $.each( items, function( index, item ) {
+ that._renderItemData( ul, item );
+ });
+ },
+
+ _renderItemData: function( ul, item ) {
+ return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
+ },
+
+ _renderItem: function( ul, item ) {
+ return $( "<li>" )
+ .append( $( "<a>" ).text( item.label ) )
+ .appendTo( ul );
+ },
+
+ _move: function( direction, event ) {
+ if ( !this.menu.element.is( ":visible" ) ) {
+ this.search( null, event );
+ return;
+ }
+ if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
+ this.menu.isLastItem() && /^next/.test( direction ) ) {
+ this._value( this.term );
+ this.menu.blur();
+ return;
+ }
+ this.menu[ direction ]( event );
+ },
+
+ widget: function() {
+ return this.menu.element;
+ },
+
+ _value: function() {
+ return this.valueMethod.apply( this.element, arguments );
+ },
+
+ _keyEvent: function( keyEvent, event ) {
+ if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
+ this._move( keyEvent, event );
+
+ // prevents moving cursor to beginning/end of the text field in some browsers
+ event.preventDefault();
+ }
+ }
+});
+
+$.extend( $.ui.autocomplete, {
+ escapeRegex: function( value ) {
+ return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
+ },
+ filter: function(array, term) {
+ var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
+ return $.grep( array, function(value) {
+ return matcher.test( value.label || value.value || value );
+ });
+ }
+});
+
+
+// live region extension, adding a `messages` option
+// NOTE: This is an experimental API. We are still investigating
+// a full solution for string manipulation and internationalization.
+$.widget( "ui.autocomplete", $.ui.autocomplete, {
+ options: {
+ messages: {
+ noResults: "No search results.",
+ results: function( amount ) {
+ return amount + ( amount > 1 ? " results are" : " result is" ) +
+ " available, use up and down arrow keys to navigate.";
+ }
+ }
+ },
+
+ __response: function( content ) {
+ var message;
+ this._superApply( arguments );
+ if ( this.options.disabled || this.cancelSearch ) {
+ return;
+ }
+ if ( content && content.length ) {
+ message = this.options.messages.results( content.length );
+ } else {
+ message = this.options.messages.noResults;
+ }
+ this.liveRegion.text( message );
+ }
+});
+
+
+}( jQuery ));
+(function( $, undefined ) {
+
+var lastActive, startXPos, startYPos, clickDragged,
+ baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
+ stateClasses = "ui-state-hover ui-state-active ",
+ typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
+ formResetHandler = function() {
+ var buttons = $( this ).find( ":ui-button" );
+ setTimeout(function() {
+ buttons.button( "refresh" );
+ }, 1 );
+ },
+ radioGroup = function( radio ) {
+ var name = radio.name,
+ form = radio.form,
+ radios = $( [] );
+ if ( name ) {
+ if ( form ) {
+ radios = $( form ).find( "[name='" + name + "']" );
+ } else {
+ radios = $( "[name='" + name + "']", radio.ownerDocument )
+ .filter(function() {
+ return !this.form;
+ });
+ }
+ }
+ return radios;
+ };
+
+$.widget( "ui.button", {
+ version: "1.9.2",
+ defaultElement: "<button>",
+ options: {
+ disabled: null,
+ text: true,
+ label: null,
+ icons: {
+ primary: null,
+ secondary: null
+ }
+ },
+ _create: function() {
+ this.element.closest( "form" )
+ .unbind( "reset" + this.eventNamespace )
+ .bind( "reset" + this.eventNamespace, formResetHandler );
+
+ if ( typeof this.options.disabled !== "boolean" ) {
+ this.options.disabled = !!this.element.prop( "disabled" );
+ } else {
+ this.element.prop( "disabled", this.options.disabled );
+ }
+
+ this._determineButtonType();
+ this.hasTitle = !!this.buttonElement.attr( "title" );
+
+ var that = this,
+ options = this.options,
+ toggleButton = this.type === "checkbox" || this.type === "radio",
+ activeClass = !toggleButton ? "ui-state-active" : "",
+ focusClass = "ui-state-focus";
+
+ if ( options.label === null ) {
+ options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
+ }
+
+ this._hoverable( this.buttonElement );
+
+ this.buttonElement
+ .addClass( baseClasses )
+ .attr( "role", "button" )
+ .bind( "mouseenter" + this.eventNamespace, function() {
+ if ( options.disabled ) {
+ return;
+ }
+ if ( this === lastActive ) {
+ $( this ).addClass( "ui-state-active" );
+ }
+ })
+ .bind( "mouseleave" + this.eventNamespace, function() {
+ if ( options.disabled ) {
+ return;
+ }
+ $( this ).removeClass( activeClass );
+ })
+ .bind( "click" + this.eventNamespace, function( event ) {
+ if ( options.disabled ) {
+ event.preventDefault();
+ event.stopImmediatePropagation();
+ }
+ });
+
+ this.element
+ .bind( "focus" + this.eventNamespace, function() {
+ // no need to check disabled, focus won't be triggered anyway
+ that.buttonElement.addClass( focusClass );
+ })
+ .bind( "blur" + this.eventNamespace, function() {
+ that.buttonElement.removeClass( focusClass );
+ });
+
+ if ( toggleButton ) {
+ this.element.bind( "change" + this.eventNamespace, function() {
+ if ( clickDragged ) {
+ return;
+ }
+ that.refresh();
+ });
+ // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
+ // prevents issue where button state changes but checkbox/radio checked state
+ // does not in Firefox (see ticket #6970)
+ this.buttonElement
+ .bind( "mousedown" + this.eventNamespace, function( event ) {
+ if ( options.disabled ) {
+ return;
+ }
+ clickDragged = false;
+ startXPos = event.pageX;
+ startYPos = event.pageY;
+ })
+ .bind( "mouseup" + this.eventNamespace, function( event ) {
+ if ( options.disabled ) {
+ return;
+ }
+ if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
+ clickDragged = true;
+ }
+ });
+ }
+
+ if ( this.type === "checkbox" ) {
+ this.buttonElement.bind( "click" + this.eventNamespace, function() {
+ if ( options.disabled || clickDragged ) {
+ return false;
+ }
+ $( this ).toggleClass( "ui-state-active" );
+ that.buttonElement.attr( "aria-pressed", that.element[0].checked );
+ });
+ } else if ( this.type === "radio" ) {
+ this.buttonElement.bind( "click" + this.eventNamespace, function() {
+ if ( options.disabled || clickDragged ) {
+ return false;
+ }
+ $( this ).addClass( "ui-state-active" );
+ that.buttonElement.attr( "aria-pressed", "true" );
+
+ var radio = that.element[ 0 ];
+ radioGroup( radio )
+ .not( radio )
+ .map(function() {
+ return $( this ).button( "widget" )[ 0 ];
+ })
+ .removeClass( "ui-state-active" )
+ .attr( "aria-pressed", "false" );
+ });
+ } else {
+ this.buttonElement
+ .bind( "mousedown" + this.eventNamespace, function() {
+ if ( options.disabled ) {
+ return false;
+ }
+ $( this ).addClass( "ui-state-active" );
+ lastActive = this;
+ that.document.one( "mouseup", function() {
+ lastActive = null;
+ });
+ })
+ .bind( "mouseup" + this.eventNamespace, function() {
+ if ( options.disabled ) {
+ return false;
+ }
+ $( this ).removeClass( "ui-state-active" );
+ })
+ .bind( "keydown" + this.eventNamespace, function(event) {
+ if ( options.disabled ) {
+ return false;
+ }
+ if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
+ $( this ).addClass( "ui-state-active" );
+ }
+ })
+ .bind( "keyup" + this.eventNamespace, function() {
+ $( this ).removeClass( "ui-state-active" );
+ });
+
+ if ( this.buttonElement.is("a") ) {
+ this.buttonElement.keyup(function(event) {
+ if ( event.keyCode === $.ui.keyCode.SPACE ) {
+ // TODO pass through original event correctly (just as 2nd argument doesn't work)
+ $( this ).click();
+ }
+ });
+ }
+ }
+
+ // TODO: pull out $.Widget's handling for the disabled option into
+ // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
+ // be overridden by individual plugins
+ this._setOption( "disabled", options.disabled );
+ this._resetButton();
+ },
+
+ _determineButtonType: function() {
+ var ancestor, labelSelector, checked;
+
+ if ( this.element.is("[type=checkbox]") ) {
+ this.type = "checkbox";
+ } else if ( this.element.is("[type=radio]") ) {
+ this.type = "radio";
+ } else if ( this.element.is("input") ) {
+ this.type = "input";
+ } else {
+ this.type = "button";
+ }
+
+ if ( this.type === "checkbox" || this.type === "radio" ) {
+ // we don't search against the document in case the element
+ // is disconnected from the DOM
+ ancestor = this.element.parents().last();
+ labelSelector = "label[for='" + this.element.attr("id") + "']";
+ this.buttonElement = ancestor.find( labelSelector );
+ if ( !this.buttonElement.length ) {
+ ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
+ this.buttonElement = ancestor.filter( labelSelector );
+ if ( !this.buttonElement.length ) {
+ this.buttonElement = ancestor.find( labelSelector );
+ }
+ }
+ this.element.addClass( "ui-helper-hidden-accessible" );
+
+ checked = this.element.is( ":checked" );
+ if ( checked ) {
+ this.buttonElement.addClass( "ui-state-active" );
+ }
+ this.buttonElement.prop( "aria-pressed", checked );
+ } else {
+ this.buttonElement = this.element;
+ }
+ },
+
+ widget: function() {
+ return this.buttonElement;
+ },
+
+ _destroy: function() {
+ this.element
+ .removeClass( "ui-helper-hidden-accessible" );
+ this.buttonElement
+ .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
+ .removeAttr( "role" )
+ .removeAttr( "aria-pressed" )
+ .html( this.buttonElement.find(".ui-button-text").html() );
+
+ if ( !this.hasTitle ) {
+ this.buttonElement.removeAttr( "title" );
+ }
+ },
+
+ _setOption: function( key, value ) {
+ this._super( key, value );
+ if ( key === "disabled" ) {
+ if ( value ) {
+ this.element.prop( "disabled", true );
+ } else {
+ this.element.prop( "disabled", false );
+ }
+ return;
+ }
+ this._resetButton();
+ },
+
+ refresh: function() {
+ //See #8237 & #8828
+ var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
+
+ if ( isDisabled !== this.options.disabled ) {
+ this._setOption( "disabled", isDisabled );
+ }
+ if ( this.type === "radio" ) {
+ radioGroup( this.element[0] ).each(function() {
+ if ( $( this ).is( ":checked" ) ) {
+ $( this ).button( "widget" )
+ .addClass( "ui-state-active" )
+ .attr( "aria-pressed", "true" );
+ } else {
+ $( this ).button( "widget" )
+ .removeClass( "ui-state-active" )
+ .attr( "aria-pressed", "false" );
+ }
+ });
+ } else if ( this.type === "checkbox" ) {
+ if ( this.element.is( ":checked" ) ) {
+ this.buttonElement
+ .addClass( "ui-state-active" )
+ .attr( "aria-pressed", "true" );
+ } else {
+ this.buttonElement
+ .removeClass( "ui-state-active" )
+ .attr( "aria-pressed", "false" );
+ }
+ }
+ },
+
+ _resetButton: function() {
+ if ( this.type === "input" ) {
+ if ( this.options.label ) {
+ this.element.val( this.options.label );
+ }
+ return;
+ }
+ var buttonElement = this.buttonElement.removeClass( typeClasses ),
+ buttonText = $( "<span></span>", this.document[0] )
+ .addClass( "ui-button-text" )
+ .html( this.options.label )
+ .appendTo( buttonElement.empty() )
+ .text(),
+ icons = this.options.icons,
+ multipleIcons = icons.primary && icons.secondary,
+ buttonClasses = [];
+
+ if ( icons.primary || icons.secondary ) {
+ if ( this.options.text ) {
+ buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
+ }
+
+ if ( icons.primary ) {
+ buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
+ }
+
+ if ( icons.secondary ) {
+ buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
+ }
+
+ if ( !this.options.text ) {
+ buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
+
+ if ( !this.hasTitle ) {
+ buttonElement.attr( "title", $.trim( buttonText ) );
+ }
+ }
+ } else {
+ buttonClasses.push( "ui-button-text-only" );
+ }
+ buttonElement.addClass( buttonClasses.join( " " ) );
+ }
+});
+
+$.widget( "ui.buttonset", {
+ version: "1.9.2",
+ options: {
+ items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(button)"
+ },
+
+ _create: function() {
+ this.element.addClass( "ui-buttonset" );
+ },
+
+ _init: function() {
+ this.refresh();
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "disabled" ) {
+ this.buttons.button( "option", key, value );
+ }
+
+ this._super( key, value );
+ },
+
+ refresh: function() {
+ var rtl = this.element.css( "direction" ) === "rtl";
+
+ this.buttons = this.element.find( this.options.items )
+ .filter( ":ui-button" )
+ .button( "refresh" )
+ .end()
+ .not( ":ui-button" )
+ .button()
+ .end()
+ .map(function() {
+ return $( this ).button( "widget" )[ 0 ];
+ })
+ .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
+ .filter( ":first" )
+ .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
+ .end()
+ .filter( ":last" )
+ .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
+ .end()
+ .end();
+ },
+
+ _destroy: function() {
+ this.element.removeClass( "ui-buttonset" );
+ this.buttons
+ .map(function() {
+ return $( this ).button( "widget" )[ 0 ];
+ })
+ .removeClass( "ui-corner-left ui-corner-right" )
+ .end()
+ .button( "destroy" );
+ }
+});
+
+}( jQuery ) );
+(function( $, undefined ) {
+
+$.extend($.ui, { datepicker: { version: "1.9.2" } });
+
+var PROP_NAME = 'datepicker';
+var dpuuid = new Date().getTime();
+var instActive;
+
+/* Date picker manager.
+ Use the singleton instance of this class, $.datepicker, to interact with the date picker.
+ Settings for (groups of) date pickers are maintained in an instance object,
+ allowing multiple different settings on the same page. */
+
+function Datepicker() {
+ this.debug = false; // Change this to true to start debugging
+ this._curInst = null; // The current instance in use
+ this._keyEvent = false; // If the last event was a key event
+ this._disabledInputs = []; // List of date picker inputs that have been disabled
+ this._datepickerShowing = false; // True if the popup picker is showing , false if not
+ this._inDialog = false; // True if showing within a "dialog", false if not
+ this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
+ this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
+ this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
+ this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
+ this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
+ this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
+ this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
+ this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
+ this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
+ this.regional = []; // Available regional settings, indexed by language code
+ this.regional[''] = { // Default regional settings
+ closeText: 'Done', // Display text for close link
+ prevText: 'Prev', // Display text for previous month link
+ nextText: 'Next', // Display text for next month link
+ currentText: 'Today', // Display text for current month link
+ monthNames: ['January','February','March','April','May','June',
+ 'July','August','September','October','November','December'], // Names of months for drop-down and formatting
+ monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
+ dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
+ dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
+ dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
+ weekHeader: 'Wk', // Column header for week of the year
+ dateFormat: 'mm/dd/yy', // See format options on parseDate
+ firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
+ isRTL: false, // True if right-to-left language, false if left-to-right
+ showMonthAfterYear: false, // True if the year select precedes month, false for month then year
+ yearSuffix: '' // Additional text to append to the year in the month headers
+ };
+ this._defaults = { // Global defaults for all the date picker instances
+ showOn: 'focus', // 'focus' for popup on focus,
+ // 'button' for trigger button, or 'both' for either
+ showAnim: 'fadeIn', // Name of jQuery animation for popup
+ showOptions: {}, // Options for enhanced animations
+ defaultDate: null, // Used when field is blank: actual date,
+ // +/-number for offset from today, null for today
+ appendText: '', // Display text following the input box, e.g. showing the format
+ buttonText: '...', // Text for trigger button
+ buttonImage: '', // URL for trigger button image
+ buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
+ hideIfNoPrevNext: false, // True to hide next/previous month links
+ // if not applicable, false to just disable them
+ navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
+ gotoCurrent: false, // True if today link goes back to current selection instead
+ changeMonth: false, // True if month can be selected directly, false if only prev/next
+ changeYear: false, // True if year can be selected directly, false if only prev/next
+ yearRange: 'c-10:c+10', // Range of years to display in drop-down,
+ // either relative to today's year (-nn:+nn), relative to currently displayed year
+ // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
+ showOtherMonths: false, // True to show dates in other months, false to leave blank
+ selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
+ showWeek: false, // True to show week of the year, false to not show it
+ calculateWeek: this.iso8601Week, // How to calculate the week of the year,
+ // takes a Date and returns the number of the week for it
+ shortYearCutoff: '+10', // Short year values < this are in the current century,
+ // > this are in the previous century,
+ // string value starting with '+' for current year + value
+ minDate: null, // The earliest selectable date, or null for no limit
+ maxDate: null, // The latest selectable date, or null for no limit
+ duration: 'fast', // Duration of display/closure
+ beforeShowDay: null, // Function that takes a date and returns an array with
+ // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
+ // [2] = cell title (optional), e.g. $.datepicker.noWeekends
+ beforeShow: null, // Function that takes an input field and
+ // returns a set of custom settings for the date picker
+ onSelect: null, // Define a callback function when a date is selected
+ onChangeMonthYear: null, // Define a callback function when the month or year is changed
+ onClose: null, // Define a callback function when the datepicker is closed
+ numberOfMonths: 1, // Number of months to show at a time
+ showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
+ stepMonths: 1, // Number of months to step back/forward
+ stepBigMonths: 12, // Number of months to step back/forward for the big links
+ altField: '', // Selector for an alternate field to store selected dates into
+ altFormat: '', // The date format to use for the alternate field
+ constrainInput: true, // The input is constrained by the current date format
+ showButtonPanel: false, // True to show button panel, false to not show it
+ autoSize: false, // True to size the input for the date format, false to leave as is
+ disabled: false // The initial disabled state
+ };
+ $.extend(this._defaults, this.regional['']);
+ this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
+}
+
+$.extend(Datepicker.prototype, {
+ /* Class name added to elements to indicate already configured with a date picker. */
+ markerClassName: 'hasDatepicker',
+
+ //Keep track of the maximum number of rows displayed (see #7043)
+ maxRows: 4,
+
+ /* Debug logging (if enabled). */
+ log: function () {
+ if (this.debug)
+ console.log.apply('', arguments);
+ },
+
+ // TODO rename to "widget" when switching to widget factory
+ _widgetDatepicker: function() {
+ return this.dpDiv;
+ },
+
+ /* Override the default settings for all instances of the date picker.
+ @param settings object - the new settings to use as defaults (anonymous object)
+ @return the manager object */
+ setDefaults: function(settings) {
+ extendRemove(this._defaults, settings || {});
+ return this;
+ },
+
+ /* Attach the date picker to a jQuery selection.
+ @param target element - the target input field or division or span
+ @param settings object - the new settings to use for this date picker instance (anonymous) */
+ _attachDatepicker: function(target, settings) {
+ // check for settings on the control itself - in namespace 'date:'
+ var inlineSettings = null;
+ for (var attrName in this._defaults) {
+ var attrValue = target.getAttribute('date:' + attrName);
+ if (attrValue) {
+ inlineSettings = inlineSettings || {};
+ try {
+ inlineSettings[attrName] = eval(attrValue);
+ } catch (err) {
+ inlineSettings[attrName] = attrValue;
+ }
+ }
+ }
+ var nodeName = target.nodeName.toLowerCase();
+ var inline = (nodeName == 'div' || nodeName == 'span');
+ if (!target.id) {
+ this.uuid += 1;
+ target.id = 'dp' + this.uuid;
+ }
+ var inst = this._newInst($(target), inline);
+ inst.settings = $.extend({}, settings || {}, inlineSettings || {});
+ if (nodeName == 'input') {
+ this._connectDatepicker(target, inst);
+ } else if (inline) {
+ this._inlineDatepicker(target, inst);
+ }
+ },
+
+ /* Create a new instance object. */
+ _newInst: function(target, inline) {
+ var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
+ return {id: id, input: target, // associated target
+ selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
+ drawMonth: 0, drawYear: 0, // month being drawn
+ inline: inline, // is datepicker inline or not
+ dpDiv: (!inline ? this.dpDiv : // presentation div
+ bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))};
+ },
+
+ /* Attach the date picker to an input field. */
+ _connectDatepicker: function(target, inst) {
+ var input = $(target);
+ inst.append = $([]);
+ inst.trigger = $([]);
+ if (input.hasClass(this.markerClassName))
+ return;
+ this._attachments(input, inst);
+ input.addClass(this.markerClassName).keydown(this._doKeyDown).
+ keypress(this._doKeyPress).keyup(this._doKeyUp).
+ bind("setData.datepicker", function(event, key, value) {
+ inst.settings[key] = value;
+ }).bind("getData.datepicker", function(event, key) {
+ return this._get(inst, key);
+ });
+ this._autoSize(inst);
+ $.data(target, PROP_NAME, inst);
+ //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
+ if( inst.settings.disabled ) {
+ this._disableDatepicker( target );
+ }
+ },
+
+ /* Make attachments based on settings. */
+ _attachments: function(input, inst) {
+ var appendText = this._get(inst, 'appendText');
+ var isRTL = this._get(inst, 'isRTL');
+ if (inst.append)
+ inst.append.remove();
+ if (appendText) {
+ inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
+ input[isRTL ? 'before' : 'after'](inst.append);
+ }
+ input.unbind('focus', this._showDatepicker);
+ if (inst.trigger)
+ inst.trigger.remove();
+ var showOn = this._get(inst, 'showOn');
+ if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
+ input.focus(this._showDatepicker);
+ if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
+ var buttonText = this._get(inst, 'buttonText');
+ var buttonImage = this._get(inst, 'buttonImage');
+ inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
+ $('<img/>').addClass(this._triggerClass).
+ attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
+ $('<button type="button"></button>').addClass(this._triggerClass).
+ html(buttonImage == '' ? buttonText : $('<img/>').attr(
+ { src:buttonImage, alt:buttonText, title:buttonText })));
+ input[isRTL ? 'before' : 'after'](inst.trigger);
+ inst.trigger.click(function() {
+ if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
+ $.datepicker._hideDatepicker();
+ else if ($.datepicker._datepickerShowing && $.datepicker._lastInput != input[0]) {
+ $.datepicker._hideDatepicker();
+ $.datepicker._showDatepicker(input[0]);
+ } else
+ $.datepicker._showDatepicker(input[0]);
+ return false;
+ });
+ }
+ },
+
+ /* Apply the maximum length for the date format. */
+ _autoSize: function(inst) {
+ if (this._get(inst, 'autoSize') && !inst.inline) {
+ var date = new Date(2009, 12 - 1, 20); // Ensure double digits
+ var dateFormat = this._get(inst, 'dateFormat');
+ if (dateFormat.match(/[DM]/)) {
+ var findMax = function(names) {
+ var max = 0;
+ var maxI = 0;
+ for (var i = 0; i < names.length; i++) {
+ if (names[i].length > max) {
+ max = names[i].length;
+ maxI = i;
+ }
+ }
+ return maxI;
+ };
+ date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
+ 'monthNames' : 'monthNamesShort'))));
+ date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
+ 'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
+ }
+ inst.input.attr('size', this._formatDate(inst, date).length);
+ }
+ },
+
+ /* Attach an inline date picker to a div. */
+ _inlineDatepicker: function(target, inst) {
+ var divSpan = $(target);
+ if (divSpan.hasClass(this.markerClassName))
+ return;
+ divSpan.addClass(this.markerClassName).append(inst.dpDiv).
+ bind("setData.datepicker", function(event, key, value){
+ inst.settings[key] = value;
+ }).bind("getData.datepicker", function(event, key){
+ return this._get(inst, key);
+ });
+ $.data(target, PROP_NAME, inst);
+ this._setDate(inst, this._getDefaultDate(inst), true);
+ this._updateDatepicker(inst);
+ this._updateAlternate(inst);
+ //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
+ if( inst.settings.disabled ) {
+ this._disableDatepicker( target );
+ }
+ // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
+ // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
+ inst.dpDiv.css( "display", "block" );
+ },
+
+ /* Pop-up the date picker in a "dialog" box.
+ @param input element - ignored
+ @param date string or Date - the initial date to display
+ @param onSelect function - the function to call when a date is selected
+ @param settings object - update the dialog date picker instance's settings (anonymous object)
+ @param pos int[2] - coordinates for the dialog's position within the screen or
+ event - with x/y coordinates or
+ leave empty for default (screen centre)
+ @return the manager object */
+ _dialogDatepicker: function(input, date, onSelect, settings, pos) {
+ var inst = this._dialogInst; // internal instance
+ if (!inst) {
+ this.uuid += 1;
+ var id = 'dp' + this.uuid;
+ this._dialogInput = $('<input type="text" id="' + id +
+ '" style="position: absolute; top: -100px; width: 0px;"/>');
+ this._dialogInput.keydown(this._doKeyDown);
+ $('body').append(this._dialogInput);
+ inst = this._dialogInst = this._newInst(this._dialogInput, false);
+ inst.settings = {};
+ $.data(this._dialogInput[0], PROP_NAME, inst);
+ }
+ extendRemove(inst.settings, settings || {});
+ date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
+ this._dialogInput.val(date);
+
+ this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
+ if (!this._pos) {
+ var browserWidth = document.documentElement.clientWidth;
+ var browserHeight = document.documentElement.clientHeight;
+ var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
+ var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
+ this._pos = // should use actual width/height below
+ [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
+ }
+
+ // move input on screen for focus, but hidden behind dialog
+ this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
+ inst.settings.onSelect = onSelect;
+ this._inDialog = true;
+ this.dpDiv.addClass(this._dialogClass);
+ this._showDatepicker(this._dialogInput[0]);
+ if ($.blockUI)
+ $.blockUI(this.dpDiv);
+ $.data(this._dialogInput[0], PROP_NAME, inst);
+ return this;
+ },
+
+ /* Detach a datepicker from its control.
+ @param target element - the target input field or division or span */
+ _destroyDatepicker: function(target) {
+ var $target = $(target);
+ var inst = $.data(target, PROP_NAME);
+ if (!$target.hasClass(this.markerClassName)) {
+ return;
+ }
+ var nodeName = target.nodeName.toLowerCase();
+ $.removeData(target, PROP_NAME);
+ if (nodeName == 'input') {
+ inst.append.remove();
+ inst.trigger.remove();
+ $target.removeClass(this.markerClassName).
+ unbind('focus', this._showDatepicker).
+ unbind('keydown', this._doKeyDown).
+ unbind('keypress', this._doKeyPress).
+ unbind('keyup', this._doKeyUp);
+ } else if (nodeName == 'div' || nodeName == 'span')
+ $target.removeClass(this.markerClassName).empty();
+ },
+
+ /* Enable the date picker to a jQuery selection.
+ @param target element - the target input field or division or span */
+ _enableDatepicker: function(target) {
+ var $target = $(target);
+ var inst = $.data(target, PROP_NAME);
+ if (!$target.hasClass(this.markerClassName)) {
+ return;
+ }
+ var nodeName = target.nodeName.toLowerCase();
+ if (nodeName == 'input') {
+ target.disabled = false;
+ inst.trigger.filter('button').
+ each(function() { this.disabled = false; }).end().
+ filter('img').css({opacity: '1.0', cursor: ''});
+ }
+ else if (nodeName == 'div' || nodeName == 'span') {
+ var inline = $target.children('.' + this._inlineClass);
+ inline.children().removeClass('ui-state-disabled');
+ inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
+ prop("disabled", false);
+ }
+ this._disabledInputs = $.map(this._disabledInputs,
+ function(value) { return (value == target ? null : value); }); // delete entry
+ },
+
+ /* Disable the date picker to a jQuery selection.
+ @param target element - the target input field or division or span */
+ _disableDatepicker: function(target) {
+ var $target = $(target);
+ var inst = $.data(target, PROP_NAME);
+ if (!$target.hasClass(this.markerClassName)) {
+ return;
+ }
+ var nodeName = target.nodeName.toLowerCase();
+ if (nodeName == 'input') {
+ target.disabled = true;
+ inst.trigger.filter('button').
+ each(function() { this.disabled = true; }).end().
+ filter('img').css({opacity: '0.5', cursor: 'default'});
+ }
+ else if (nodeName == 'div' || nodeName == 'span') {
+ var inline = $target.children('.' + this._inlineClass);
+ inline.children().addClass('ui-state-disabled');
+ inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
+ prop("disabled", true);
+ }
+ this._disabledInputs = $.map(this._disabledInputs,
+ function(value) { return (value == target ? null : value); }); // delete entry
+ this._disabledInputs[this._disabledInputs.length] = target;
+ },
+
+ /* Is the first field in a jQuery collection disabled as a datepicker?
+ @param target element - the target input field or division or span
+ @return boolean - true if disabled, false if enabled */
+ _isDisabledDatepicker: function(target) {
+ if (!target) {
+ return false;
+ }
+ for (var i = 0; i < this._disabledInputs.length; i++) {
+ if (this._disabledInputs[i] == target)
+ return true;
+ }
+ return false;
+ },
+
+ /* Retrieve the instance data for the target control.
+ @param target element - the target input field or division or span
+ @return object - the associated instance data
+ @throws error if a jQuery problem getting data */
+ _getInst: function(target) {
+ try {
+ return $.data(target, PROP_NAME);
+ }
+ catch (err) {
+ throw 'Missing instance data for this datepicker';
+ }
+ },
+
+ /* Update or retrieve the settings for a date picker attached to an input field or division.
+ @param target element - the target input field or division or span
+ @param name object - the new settings to update or
+ string - the name of the setting to change or retrieve,
+ when retrieving also 'all' for all instance settings or
+ 'defaults' for all global defaults
+ @param value any - the new value for the setting
+ (omit if above is an object or to retrieve a value) */
+ _optionDatepicker: function(target, name, value) {
+ var inst = this._getInst(target);
+ if (arguments.length == 2 && typeof name == 'string') {
+ return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
+ (inst ? (name == 'all' ? $.extend({}, inst.settings) :
+ this._get(inst, name)) : null));
+ }
+ var settings = name || {};
+ if (typeof name == 'string') {
+ settings = {};
+ settings[name] = value;
+ }
+ if (inst) {
+ if (this._curInst == inst) {
+ this._hideDatepicker();
+ }
+ var date = this._getDateDatepicker(target, true);
+ var minDate = this._getMinMaxDate(inst, 'min');
+ var maxDate = this._getMinMaxDate(inst, 'max');
+ extendRemove(inst.settings, settings);
+ // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
+ if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
+ inst.settings.minDate = this._formatDate(inst, minDate);
+ if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined)
+ inst.settings.maxDate = this._formatDate(inst, maxDate);
+ this._attachments($(target), inst);
+ this._autoSize(inst);
+ this._setDate(inst, date);
+ this._updateAlternate(inst);
+ this._updateDatepicker(inst);
+ }
+ },
+
+ // change method deprecated
+ _changeDatepicker: function(target, name, value) {
+ this._optionDatepicker(target, name, value);
+ },
+
+ /* Redraw the date picker attached to an input field or division.
+ @param target element - the target input field or division or span */
+ _refreshDatepicker: function(target) {
+ var inst = this._getInst(target);
+ if (inst) {
+ this._updateDatepicker(inst);
+ }
+ },
+
+ /* Set the dates for a jQuery selection.
+ @param target element - the target input field or division or span
+ @param date Date - the new date */
+ _setDateDatepicker: function(target, date) {
+ var inst = this._getInst(target);
+ if (inst) {
+ this._setDate(inst, date);
+ this._updateDatepicker(inst);
+ this._updateAlternate(inst);
+ }
+ },
+
+ /* Get the date(s) for the first entry in a jQuery selection.
+ @param target element - the target input field or division or span
+ @param noDefault boolean - true if no default date is to be used
+ @return Date - the current date */
+ _getDateDatepicker: function(target, noDefault) {
+ var inst = this._getInst(target);
+ if (inst && !inst.inline)
+ this._setDateFromField(inst, noDefault);
+ return (inst ? this._getDate(inst) : null);
+ },
+
+ /* Handle keystrokes. */
+ _doKeyDown: function(event) {
+ var inst = $.datepicker._getInst(event.target);
+ var handled = true;
+ var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
+ inst._keyEvent = true;
+ if ($.datepicker._datepickerShowing)
+ switch (event.keyCode) {
+ case 9: $.datepicker._hideDatepicker();
+ handled = false;
+ break; // hide on tab out
+ case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
+ $.datepicker._currentClass + ')', inst.dpDiv);
+ if (sel[0])
+ $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
+ var onSelect = $.datepicker._get(inst, 'onSelect');
+ if (onSelect) {
+ var dateStr = $.datepicker._formatDate(inst);
+
+ // trigger custom callback
+ onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
+ }
+ else
+ $.datepicker._hideDatepicker();
+ return false; // don't submit the form
+ break; // select the value on enter
+ case 27: $.datepicker._hideDatepicker();
+ break; // hide on escape
+ case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
+ -$.datepicker._get(inst, 'stepBigMonths') :
+ -$.datepicker._get(inst, 'stepMonths')), 'M');
+ break; // previous month/year on page up/+ ctrl
+ case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
+ +$.datepicker._get(inst, 'stepBigMonths') :
+ +$.datepicker._get(inst, 'stepMonths')), 'M');
+ break; // next month/year on page down/+ ctrl
+ case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
+ handled = event.ctrlKey || event.metaKey;
+ break; // clear on ctrl or command +end
+ case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
+ handled = event.ctrlKey || event.metaKey;
+ break; // current on ctrl or command +home
+ case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
+ handled = event.ctrlKey || event.metaKey;
+ // -1 day on ctrl or command +left
+ if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
+ -$.datepicker._get(inst, 'stepBigMonths') :
+ -$.datepicker._get(inst, 'stepMonths')), 'M');
+ // next month/year on alt +left on Mac
+ break;
+ case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
+ handled = event.ctrlKey || event.metaKey;
+ break; // -1 week on ctrl or command +up
+ case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
+ handled = event.ctrlKey || event.metaKey;
+ // +1 day on ctrl or command +right
+ if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
+ +$.datepicker._get(inst, 'stepBigMonths') :
+ +$.datepicker._get(inst, 'stepMonths')), 'M');
+ // next month/year on alt +right
+ break;
+ case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
+ handled = event.ctrlKey || event.metaKey;
+ break; // +1 week on ctrl or command +down
+ default: handled = false;
+ }
+ else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
+ $.datepicker._showDatepicker(this);
+ else {
+ handled = false;
+ }
+ if (handled) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ },
+
+ /* Filter entered characters - based on date format. */
+ _doKeyPress: function(event) {
+ var inst = $.datepicker._getInst(event.target);
+ if ($.datepicker._get(inst, 'constrainInput')) {
+ var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
+ var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
+ return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
+ }
+ },
+
+ /* Synchronise manual entry and field/alternate field. */
+ _doKeyUp: function(event) {
+ var inst = $.datepicker._getInst(event.target);
+ if (inst.input.val() != inst.lastVal) {
+ try {
+ var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
+ (inst.input ? inst.input.val() : null),
+ $.datepicker._getFormatConfig(inst));
+ if (date) { // only if valid
+ $.datepicker._setDateFromField(inst);
+ $.datepicker._updateAlternate(inst);
+ $.datepicker._updateDatepicker(inst);
+ }
+ }
+ catch (err) {
+ $.datepicker.log(err);
+ }
+ }
+ return true;
+ },
+
+ /* Pop-up the date picker for a given input field.
+ If false returned from beforeShow event handler do not show.
+ @param input element - the input field attached to the date picker or
+ event - if triggered by focus */
+ _showDatepicker: function(input) {
+ input = input.target || input;
+ if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
+ input = $('input', input.parentNode)[0];
+ if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
+ return;
+ var inst = $.datepicker._getInst(input);
+ if ($.datepicker._curInst && $.datepicker._curInst != inst) {
+ $.datepicker._curInst.dpDiv.stop(true, true);
+ if ( inst && $.datepicker._datepickerShowing ) {
+ $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
+ }
+ }
+ var beforeShow = $.datepicker._get(inst, 'beforeShow');
+ var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
+ if(beforeShowSettings === false){
+ //false
+ return;
+ }
+ extendRemove(inst.settings, beforeShowSettings);
+ inst.lastVal = null;
+ $.datepicker._lastInput = input;
+ $.datepicker._setDateFromField(inst);
+ if ($.datepicker._inDialog) // hide cursor
+ input.value = '';
+ if (!$.datepicker._pos) { // position below input
+ $.datepicker._pos = $.datepicker._findPos(input);
+ $.datepicker._pos[1] += input.offsetHeight; // add the height
+ }
+ var isFixed = false;
+ $(input).parents().each(function() {
+ isFixed |= $(this).css('position') == 'fixed';
+ return !isFixed;
+ });
+ var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
+ $.datepicker._pos = null;
+ //to avoid flashes on Firefox
+ inst.dpDiv.empty();
+ // determine sizing offscreen
+ inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
+ $.datepicker._updateDatepicker(inst);
+ // fix width for dynamic number of date pickers
+ // and adjust position before showing
+ offset = $.datepicker._checkOffset(inst, offset, isFixed);
+ inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
+ 'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
+ left: offset.left + 'px', top: offset.top + 'px'});
+ if (!inst.inline) {
+ var showAnim = $.datepicker._get(inst, 'showAnim');
+ var duration = $.datepicker._get(inst, 'duration');
+ var postProcess = function() {
+ var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
+ if( !! cover.length ){
+ var borders = $.datepicker._getBorders(inst.dpDiv);
+ cover.css({left: -borders[0], top: -borders[1],
+ width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
+ }
+ };
+ inst.dpDiv.zIndex($(input).zIndex()+1);
+ $.datepicker._datepickerShowing = true;
+
+ // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
+ if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) )
+ inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
+ else
+ inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
+ if (!showAnim || !duration)
+ postProcess();
+ if (inst.input.is(':visible') && !inst.input.is(':disabled'))
+ inst.input.focus();
+ $.datepicker._curInst = inst;
+ }
+ },
+
+ /* Generate the date picker content. */
+ _updateDatepicker: function(inst) {
+ this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
+ var borders = $.datepicker._getBorders(inst.dpDiv);
+ instActive = inst; // for delegate hover events
+ inst.dpDiv.empty().append(this._generateHTML(inst));
+ this._attachHandlers(inst);
+ var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
+ if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6
+ cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
+ }
+ inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover();
+ var numMonths = this._getNumberOfMonths(inst);
+ var cols = numMonths[1];
+ var width = 17;
+ inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
+ if (cols > 1)
+ inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
+ inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
+ 'Class']('ui-datepicker-multi');
+ inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
+ 'Class']('ui-datepicker-rtl');
+ if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
+ // #6694 - don't focus the input if it's already focused
+ // this breaks the change event in IE
+ inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
+ inst.input.focus();
+ // deffered render of the years select (to avoid flashes on Firefox)
+ if( inst.yearshtml ){
+ var origyearshtml = inst.yearshtml;
+ setTimeout(function(){
+ //assure that inst.yearshtml didn't change.
+ if( origyearshtml === inst.yearshtml && inst.yearshtml ){
+ inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
+ }
+ origyearshtml = inst.yearshtml = null;
+ }, 0);
+ }
+ },
+
+ /* Retrieve the size of left and top borders for an element.
+ @param elem (jQuery object) the element of interest
+ @return (number[2]) the left and top borders */
+ _getBorders: function(elem) {
+ var convert = function(value) {
+ return {thin: 1, medium: 2, thick: 3}[value] || value;
+ };
+ return [parseFloat(convert(elem.css('border-left-width'))),
+ parseFloat(convert(elem.css('border-top-width')))];
+ },
+
+ /* Check positioning to remain on screen. */
+ _checkOffset: function(inst, offset, isFixed) {
+ var dpWidth = inst.dpDiv.outerWidth();
+ var dpHeight = inst.dpDiv.outerHeight();
+ var inputWidth = inst.input ? inst.input.outerWidth() : 0;
+ var inputHeight = inst.input ? inst.input.outerHeight() : 0;
+ var viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft());
+ var viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
+
+ offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
+ offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
+ offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
+
+ // now check if datepicker is showing outside window viewport - move to a better place if so.
+ offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
+ Math.abs(offset.left + dpWidth - viewWidth) : 0);
+ offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
+ Math.abs(dpHeight + inputHeight) : 0);
+
+ return offset;
+ },
+
+ /* Find an object's position on the screen. */
+ _findPos: function(obj) {
+ var inst = this._getInst(obj);
+ var isRTL = this._get(inst, 'isRTL');
+ while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
+ obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
+ }
+ var position = $(obj).offset();
+ return [position.left, position.top];
+ },
+
+ /* Hide the date picker from view.
+ @param input element - the input field attached to the date picker */
+ _hideDatepicker: function(input) {
+ var inst = this._curInst;
+ if (!inst || (input && inst != $.data(input, PROP_NAME)))
+ return;
+ if (this._datepickerShowing) {
+ var showAnim = this._get(inst, 'showAnim');
+ var duration = this._get(inst, 'duration');
+ var postProcess = function() {
+ $.datepicker._tidyDialog(inst);
+ };
+
+ // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
+ if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) )
+ inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
+ else
+ inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
+ (showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
+ if (!showAnim)
+ postProcess();
+ this._datepickerShowing = false;
+ var onClose = this._get(inst, 'onClose');
+ if (onClose)
+ onClose.apply((inst.input ? inst.input[0] : null),
+ [(inst.input ? inst.input.val() : ''), inst]);
+ this._lastInput = null;
+ if (this._inDialog) {
+ this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
+ if ($.blockUI) {
+ $.unblockUI();
+ $('body').append(this.dpDiv);
+ }
+ }
+ this._inDialog = false;
+ }
+ },
+
+ /* Tidy up after a dialog display. */
+ _tidyDialog: function(inst) {
+ inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
+ },
+
+ /* Close date picker if clicked elsewhere. */
+ _checkExternalClick: function(event) {
+ if (!$.datepicker._curInst)
+ return;
+
+ var $target = $(event.target),
+ inst = $.datepicker._getInst($target[0]);
+
+ if ( ( ( $target[0].id != $.datepicker._mainDivId &&
+ $target.parents('#' + $.datepicker._mainDivId).length == 0 &&
+ !$target.hasClass($.datepicker.markerClassName) &&
+ !$target.closest("." + $.datepicker._triggerClass).length &&
+ $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
+ ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
+ $.datepicker._hideDatepicker();
+ },
+
+ /* Adjust one of the date sub-fields. */
+ _adjustDate: function(id, offset, period) {
+ var target = $(id);
+ var inst = this._getInst(target[0]);
+ if (this._isDisabledDatepicker(target[0])) {
+ return;
+ }
+ this._adjustInstDate(inst, offset +
+ (period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
+ period);
+ this._updateDatepicker(inst);
+ },
+
+ /* Action for current link. */
+ _gotoToday: function(id) {
+ var target = $(id);
+ var inst = this._getInst(target[0]);
+ if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
+ inst.selectedDay = inst.currentDay;
+ inst.drawMonth = inst.selectedMonth = inst.currentMonth;
+ inst.drawYear = inst.selectedYear = inst.currentYear;
+ }
+ else {
+ var date = new Date();
+ inst.selectedDay = date.getDate();
+ inst.drawMonth = inst.selectedMonth = date.getMonth();
+ inst.drawYear = inst.selectedYear = date.getFullYear();
+ }
+ this._notifyChange(inst);
+ this._adjustDate(target);
+ },
+
+ /* Action for selecting a new month/year. */
+ _selectMonthYear: function(id, select, period) {
+ var target = $(id);
+ var inst = this._getInst(target[0]);
+ inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
+ inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
+ parseInt(select.options[select.selectedIndex].value,10);
+ this._notifyChange(inst);
+ this._adjustDate(target);
+ },
+
+ /* Action for selecting a day. */
+ _selectDay: function(id, month, year, td) {
+ var target = $(id);
+ if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
+ return;
+ }
+ var inst = this._getInst(target[0]);
+ inst.selectedDay = inst.currentDay = $('a', td).html();
+ inst.selectedMonth = inst.currentMonth = month;
+ inst.selectedYear = inst.currentYear = year;
+ this._selectDate(id, this._formatDate(inst,
+ inst.currentDay, inst.currentMonth, inst.currentYear));
+ },
+
+ /* Erase the input field and hide the date picker. */
+ _clearDate: function(id) {
+ var target = $(id);
+ var inst = this._getInst(target[0]);
+ this._selectDate(target, '');
+ },
+
+ /* Update the input field with the selected date. */
+ _selectDate: function(id, dateStr) {
+ var target = $(id);
+ var inst = this._getInst(target[0]);
+ dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
+ if (inst.input)
+ inst.input.val(dateStr);
+ this._updateAlternate(inst);
+ var onSelect = this._get(inst, 'onSelect');
+ if (onSelect)
+ onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
+ else if (inst.input)
+ inst.input.trigger('change'); // fire the change event
+ if (inst.inline)
+ this._updateDatepicker(inst);
+ else {
+ this._hideDatepicker();
+ this._lastInput = inst.input[0];
+ if (typeof(inst.input[0]) != 'object')
+ inst.input.focus(); // restore focus
+ this._lastInput = null;
+ }
+ },
+
+ /* Update any alternate field to synchronise with the main field. */
+ _updateAlternate: function(inst) {
+ var altField = this._get(inst, 'altField');
+ if (altField) { // update alternate field too
+ var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
+ var date = this._getDate(inst);
+ var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
+ $(altField).each(function() { $(this).val(dateStr); });
+ }
+ },
+
+ /* Set as beforeShowDay function to prevent selection of weekends.
+ @param date Date - the date to customise
+ @return [boolean, string] - is this date selectable?, what is its CSS class? */
+ noWeekends: function(date) {
+ var day = date.getDay();
+ return [(day > 0 && day < 6), ''];
+ },
+
+ /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
+ @param date Date - the date to get the week for
+ @return number - the number of the week within the year that contains this date */
+ iso8601Week: function(date) {
+ var checkDate = new Date(date.getTime());
+ // Find Thursday of this week starting on Monday
+ checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
+ var time = checkDate.getTime();
+ checkDate.setMonth(0); // Compare with Jan 1
+ checkDate.setDate(1);
+ return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
+ },
+
+ /* Parse a string value into a date object.
+ See formatDate below for the possible formats.
+
+ @param format string - the expected format of the date
+ @param value string - the date in the above format
+ @param settings Object - attributes include:
+ shortYearCutoff number - the cutoff year for determining the century (optional)
+ dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
+ dayNames string[7] - names of the days from Sunday (optional)
+ monthNamesShort string[12] - abbreviated names of the months (optional)
+ monthNames string[12] - names of the months (optional)
+ @return Date - the extracted date value or null if value is blank */
+ parseDate: function (format, value, settings) {
+ if (format == null || value == null)
+ throw 'Invalid arguments';
+ value = (typeof value == 'object' ? value.toString() : value + '');
+ if (value == '')
+ return null;
+ var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
+ shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
+ new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
+ var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
+ var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
+ var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
+ var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
+ var year = -1;
+ var month = -1;
+ var day = -1;
+ var doy = -1;
+ var literal = false;
+ // Check whether a format character is doubled
+ var lookAhead = function(match) {
+ var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
+ if (matches)
+ iFormat++;
+ return matches;
+ };
+ // Extract a number from the string value
+ var getNumber = function(match) {
+ var isDoubled = lookAhead(match);
+ var size = (match == '@' ? 14 : (match == '!' ? 20 :
+ (match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2))));
+ var digits = new RegExp('^\\d{1,' + size + '}');
+ var num = value.substring(iValue).match(digits);
+ if (!num)
+ throw 'Missing number at position ' + iValue;
+ iValue += num[0].length;
+ return parseInt(num[0], 10);
+ };
+ // Extract a name from the string value and convert to an index
+ var getName = function(match, shortNames, longNames) {
+ var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
+ return [ [k, v] ];
+ }).sort(function (a, b) {
+ return -(a[1].length - b[1].length);
+ });
+ var index = -1;
+ $.each(names, function (i, pair) {
+ var name = pair[1];
+ if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) {
+ index = pair[0];
+ iValue += name.length;
+ return false;
+ }
+ });
+ if (index != -1)
+ return index + 1;
+ else
+ throw 'Unknown name at position ' + iValue;
+ };
+ // Confirm that a literal character matches the string value
+ var checkLiteral = function() {
+ if (value.charAt(iValue) != format.charAt(iFormat))
+ throw 'Unexpected literal at position ' + iValue;
+ iValue++;
+ };
+ var iValue = 0;
+ for (var iFormat = 0; iFormat < format.length; iFormat++) {
+ if (literal)
+ if (format.charAt(iFormat) == "'" && !lookAhead("'"))
+ literal = false;
+ else
+ checkLiteral();
+ else
+ switch (format.charAt(iFormat)) {
+ case 'd':
+ day = getNumber('d');
+ break;
+ case 'D':
+ getName('D', dayNamesShort, dayNames);
+ break;
+ case 'o':
+ doy = getNumber('o');
+ break;
+ case 'm':
+ month = getNumber('m');
+ break;
+ case 'M':
+ month = getName('M', monthNamesShort, monthNames);
+ break;
+ case 'y':
+ year = getNumber('y');
+ break;
+ case '@':
+ var date = new Date(getNumber('@'));
+ year = date.getFullYear();
+ month = date.getMonth() + 1;
+ day = date.getDate();
+ break;
+ case '!':
+ var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
+ year = date.getFullYear();
+ month = date.getMonth() + 1;
+ day = date.getDate();
+ break;
+ case "'":
+ if (lookAhead("'"))
+ checkLiteral();
+ else
+ literal = true;
+ break;
+ default:
+ checkLiteral();
+ }
+ }
+ if (iValue < value.length){
+ var extra = value.substr(iValue);
+ if (!/^\s+/.test(extra)) {
+ throw "Extra/unparsed characters found in date: " + extra;
+ }
+ }
+ if (year == -1)
+ year = new Date().getFullYear();
+ else if (year < 100)
+ year += new Date().getFullYear() - new Date().getFullYear() % 100 +
+ (year <= shortYearCutoff ? 0 : -100);
+ if (doy > -1) {
+ month = 1;
+ day = doy;
+ do {
+ var dim = this._getDaysInMonth(year, month - 1);
+ if (day <= dim)
+ break;
+ month++;
+ day -= dim;
+ } while (true);
+ }
+ var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
+ if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
+ throw 'Invalid date'; // E.g. 31/02/00
+ return date;
+ },
+
+ /* Standard date formats. */
+ ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
+ COOKIE: 'D, dd M yy',
+ ISO_8601: 'yy-mm-dd',
+ RFC_822: 'D, d M y',
+ RFC_850: 'DD, dd-M-y',
+ RFC_1036: 'D, d M y',
+ RFC_1123: 'D, d M yy',
+ RFC_2822: 'D, d M yy',
+ RSS: 'D, d M y', // RFC 822
+ TICKS: '!',
+ TIMESTAMP: '@',
+ W3C: 'yy-mm-dd', // ISO 8601
+
+ _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
+ Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
+
+ /* Format a date object into a string value.
+ The format can be combinations of the following:
+ d - day of month (no leading zero)
+ dd - day of month (two digit)
+ o - day of year (no leading zeros)
+ oo - day of year (three digit)
+ D - day name short
+ DD - day name long
+ m - month of year (no leading zero)
+ mm - month of year (two digit)
+ M - month name short
+ MM - month name long
+ y - year (two digit)
+ yy - year (four digit)
+ @ - Unix timestamp (ms since 01/01/1970)
+ ! - Windows ticks (100ns since 01/01/0001)
+ '...' - literal text
+ '' - single quote
+
+ @param format string - the desired format of the date
+ @param date Date - the date value to format
+ @param settings Object - attributes include:
+ dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
+ dayNames string[7] - names of the days from Sunday (optional)
+ monthNamesShort string[12] - abbreviated names of the months (optional)
+ monthNames string[12] - names of the months (optional)
+ @return string - the date in the above format */
+ formatDate: function (format, date, settings) {
+ if (!date)
+ return '';
+ var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
+ var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
+ var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
+ var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
+ // Check whether a format character is doubled
+ var lookAhead = function(match) {
+ var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
+ if (matches)
+ iFormat++;
+ return matches;
+ };
+ // Format a number, with leading zero if necessary
+ var formatNumber = function(match, value, len) {
+ var num = '' + value;
+ if (lookAhead(match))
+ while (num.length < len)
+ num = '0' + num;
+ return num;
+ };
+ // Format a name, short or long as requested
+ var formatName = function(match, value, shortNames, longNames) {
+ return (lookAhead(match) ? longNames[value] : shortNames[value]);
+ };
+ var output = '';
+ var literal = false;
+ if (date)
+ for (var iFormat = 0; iFormat < format.length; iFormat++) {
+ if (literal)
+ if (format.charAt(iFormat) == "'" && !lookAhead("'"))
+ literal = false;
+ else
+ output += format.charAt(iFormat);
+ else
+ switch (format.charAt(iFormat)) {
+ case 'd':
+ output += formatNumber('d', date.getDate(), 2);
+ break;
+ case 'D':
+ output += formatName('D', date.getDay(), dayNamesShort, dayNames);
+ break;
+ case 'o':
+ output += formatNumber('o',
+ Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
+ break;
+ case 'm':
+ output += formatNumber('m', date.getMonth() + 1, 2);
+ break;
+ case 'M':
+ output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
+ break;
+ case 'y':
+ output += (lookAhead('y') ? date.getFullYear() :
+ (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
+ break;
+ case '@':
+ output += date.getTime();
+ break;
+ case '!':
+ output += date.getTime() * 10000 + this._ticksTo1970;
+ break;
+ case "'":
+ if (lookAhead("'"))
+ output += "'";
+ else
+ literal = true;
+ break;
+ default:
+ output += format.charAt(iFormat);
+ }
+ }
+ return output;
+ },
+
+ /* Extract all possible characters from the date format. */
+ _possibleChars: function (format) {
+ var chars = '';
+ var literal = false;
+ // Check whether a format character is doubled
+ var lookAhead = function(match) {
+ var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
+ if (matches)
+ iFormat++;
+ return matches;
+ };
+ for (var iFormat = 0; iFormat < format.length; iFormat++)
+ if (literal)
+ if (format.charAt(iFormat) == "'" && !lookAhead("'"))
+ literal = false;
+ else
+ chars += format.charAt(iFormat);
+ else
+ switch (format.charAt(iFormat)) {
+ case 'd': case 'm': case 'y': case '@':
+ chars += '0123456789';
+ break;
+ case 'D': case 'M':
+ return null; // Accept anything
+ case "'":
+ if (lookAhead("'"))
+ chars += "'";
+ else
+ literal = true;
+ break;
+ default:
+ chars += format.charAt(iFormat);
+ }
+ return chars;
+ },
+
+ /* Get a setting value, defaulting if necessary. */
+ _get: function(inst, name) {
+ return inst.settings[name] !== undefined ?
+ inst.settings[name] : this._defaults[name];
+ },
+
+ /* Parse existing date and initialise date picker. */
+ _setDateFromField: function(inst, noDefault) {
+ if (inst.input.val() == inst.lastVal) {
+ return;
+ }
+ var dateFormat = this._get(inst, 'dateFormat');
+ var dates = inst.lastVal = inst.input ? inst.input.val() : null;
+ var date, defaultDate;
+ date = defaultDate = this._getDefaultDate(inst);
+ var settings = this._getFormatConfig(inst);
+ try {
+ date = this.parseDate(dateFormat, dates, settings) || defaultDate;
+ } catch (event) {
+ this.log(event);
+ dates = (noDefault ? '' : dates);
+ }
+ inst.selectedDay = date.getDate();
+ inst.drawMonth = inst.selectedMonth = date.getMonth();
+ inst.drawYear = inst.selectedYear = date.getFullYear();
+ inst.currentDay = (dates ? date.getDate() : 0);
+ inst.currentMonth = (dates ? date.getMonth() : 0);
+ inst.currentYear = (dates ? date.getFullYear() : 0);
+ this._adjustInstDate(inst);
+ },
+
+ /* Retrieve the default date shown on opening. */
+ _getDefaultDate: function(inst) {
+ return this._restrictMinMax(inst,
+ this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
+ },
+
+ /* A date may be specified as an exact value or a relative one. */
+ _determineDate: function(inst, date, defaultDate) {
+ var offsetNumeric = function(offset) {
+ var date = new Date();
+ date.setDate(date.getDate() + offset);
+ return date;
+ };
+ var offsetString = function(offset) {
+ try {
+ return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
+ offset, $.datepicker._getFormatConfig(inst));
+ }
+ catch (e) {
+ // Ignore
+ }
+ var date = (offset.toLowerCase().match(/^c/) ?
+ $.datepicker._getDate(inst) : null) || new Date();
+ var year = date.getFullYear();
+ var month = date.getMonth();
+ var day = date.getDate();
+ var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
+ var matches = pattern.exec(offset);
+ while (matches) {
+ switch (matches[2] || 'd') {
+ case 'd' : case 'D' :
+ day += parseInt(matches[1],10); break;
+ case 'w' : case 'W' :
+ day += parseInt(matches[1],10) * 7; break;
+ case 'm' : case 'M' :
+ month += parseInt(matches[1],10);
+ day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
+ break;
+ case 'y': case 'Y' :
+ year += parseInt(matches[1],10);
+ day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
+ break;
+ }
+ matches = pattern.exec(offset);
+ }
+ return new Date(year, month, day);
+ };
+ var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
+ (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
+ newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
+ if (newDate) {
+ newDate.setHours(0);
+ newDate.setMinutes(0);
+ newDate.setSeconds(0);
+ newDate.setMilliseconds(0);
+ }
+ return this._daylightSavingAdjust(newDate);
+ },
+
+ /* Handle switch to/from daylight saving.
+ Hours may be non-zero on daylight saving cut-over:
+ > 12 when midnight changeover, but then cannot generate
+ midnight datetime, so jump to 1AM, otherwise reset.
+ @param date (Date) the date to check
+ @return (Date) the corrected date */
+ _daylightSavingAdjust: function(date) {
+ if (!date) return null;
+ date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
+ return date;
+ },
+
+ /* Set the date(s) directly. */
+ _setDate: function(inst, date, noChange) {
+ var clear = !date;
+ var origMonth = inst.selectedMonth;
+ var origYear = inst.selectedYear;
+ var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
+ inst.selectedDay = inst.currentDay = newDate.getDate();
+ inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
+ inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
+ if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
+ this._notifyChange(inst);
+ this._adjustInstDate(inst);
+ if (inst.input) {
+ inst.input.val(clear ? '' : this._formatDate(inst));
+ }
+ },
+
+ /* Retrieve the date(s) directly. */
+ _getDate: function(inst) {
+ var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
+ this._daylightSavingAdjust(new Date(
+ inst.currentYear, inst.currentMonth, inst.currentDay)));
+ return startDate;
+ },
+
+ /* Attach the onxxx handlers. These are declared statically so
+ * they work with static code transformers like Caja.
+ */
+ _attachHandlers: function(inst) {
+ var stepMonths = this._get(inst, 'stepMonths');
+ var id = '#' + inst.id.replace( /\\\\/g, "\\" );
+ inst.dpDiv.find('[data-handler]').map(function () {
+ var handler = {
+ prev: function () {
+ window['DP_jQuery_' + dpuuid].datepicker._adjustDate(id, -stepMonths, 'M');
+ },
+ next: function () {
+ window['DP_jQuery_' + dpuuid].datepicker._adjustDate(id, +stepMonths, 'M');
+ },
+ hide: function () {
+ window['DP_jQuery_' + dpuuid].datepicker._hideDatepicker();
+ },
+ today: function () {
+ window['DP_jQuery_' + dpuuid].datepicker._gotoToday(id);
+ },
+ selectDay: function () {
+ window['DP_jQuery_' + dpuuid].datepicker._selectDay(id, +this.getAttribute('data-month'), +this.getAttribute('data-year'), this);
+ return false;
+ },
+ selectMonth: function () {
+ window['DP_jQuery_' + dpuuid].datepicker._selectMonthYear(id, this, 'M');
+ return false;
+ },
+ selectYear: function () {
+ window['DP_jQuery_' + dpuuid].datepicker._selectMonthYear(id, this, 'Y');
+ return false;
+ }
+ };
+ $(this).bind(this.getAttribute('data-event'), handler[this.getAttribute('data-handler')]);
+ });
+ },
+
+ /* Generate the HTML for the current state of the date picker. */
+ _generateHTML: function(inst) {
+ var today = new Date();
+ today = this._daylightSavingAdjust(
+ new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
+ var isRTL = this._get(inst, 'isRTL');
+ var showButtonPanel = this._get(inst, 'showButtonPanel');
+ var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
+ var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
+ var numMonths = this._getNumberOfMonths(inst);
+ var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
+ var stepMonths = this._get(inst, 'stepMonths');
+ var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
+ var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
+ new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
+ var minDate = this._getMinMaxDate(inst, 'min');
+ var maxDate = this._getMinMaxDate(inst, 'max');
+ var drawMonth = inst.drawMonth - showCurrentAtPos;
+ var drawYear = inst.drawYear;
+ if (drawMonth < 0) {
+ drawMonth += 12;
+ drawYear--;
+ }
+ if (maxDate) {
+ var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
+ maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
+ maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
+ while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
+ drawMonth--;
+ if (drawMonth < 0) {
+ drawMonth = 11;
+ drawYear--;
+ }
+ }
+ }
+ inst.drawMonth = drawMonth;
+ inst.drawYear = drawYear;
+ var prevText = this._get(inst, 'prevText');
+ prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
+ this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
+ this._getFormatConfig(inst)));
+ var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
+ '<a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click"' +
+ ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
+ (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>'));
+ var nextText = this._get(inst, 'nextText');
+ nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
+ this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
+ this._getFormatConfig(inst)));
+ var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
+ '<a class="ui-datepicker-next ui-corner-all" data-handler="next" data-event="click"' +
+ ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
+ (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>'));
+ var currentText = this._get(inst, 'currentText');
+ var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
+ currentText = (!navigationAsDateFormat ? currentText :
+ this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
+ var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" data-handler="hide" data-event="click">' +
+ this._get(inst, 'closeText') + '</button>' : '');
+ var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
+ (this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" data-handler="today" data-event="click"' +
+ '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
+ var firstDay = parseInt(this._get(inst, 'firstDay'),10);
+ firstDay = (isNaN(firstDay) ? 0 : firstDay);
+ var showWeek = this._get(inst, 'showWeek');
+ var dayNames = this._get(inst, 'dayNames');
+ var dayNamesShort = this._get(inst, 'dayNamesShort');
+ var dayNamesMin = this._get(inst, 'dayNamesMin');
+ var monthNames = this._get(inst, 'monthNames');
+ var monthNamesShort = this._get(inst, 'monthNamesShort');
+ var beforeShowDay = this._get(inst, 'beforeShowDay');
+ var showOtherMonths = this._get(inst, 'showOtherMonths');
+ var selectOtherMonths = this._get(inst, 'selectOtherMonths');
+ var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
+ var defaultDate = this._getDefaultDate(inst);
+ var html = '';
+ for (var row = 0; row < numMonths[0]; row++) {
+ var group = '';
+ this.maxRows = 4;
+ for (var col = 0; col < numMonths[1]; col++) {
+ var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
+ var cornerClass = ' ui-corner-all';
+ var calender = '';
+ if (isMultiMonth) {
+ calender += '<div class="ui-datepicker-group';
+ if (numMonths[1] > 1)
+ switch (col) {
+ case 0: calender += ' ui-datepicker-group-first';
+ cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
+ case numMonths[1]-1: calender += ' ui-datepicker-group-last';
+ cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
+ default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break;
+ }
+ calender += '">';
+ }
+ calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
+ (/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
+ (/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
+ this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
+ row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
+ '</div><table class="ui-datepicker-calendar"><thead>' +
+ '<tr>';
+ var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : '');
+ for (var dow = 0; dow < 7; dow++) { // days of the week
+ var day = (dow + firstDay) % 7;
+ thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
+ '<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
+ }
+ calender += thead + '</tr></thead><tbody>';
+ var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
+ if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
+ inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
+ var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
+ var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
+ var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
+ this.maxRows = numRows;
+ var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
+ for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
+ calender += '<tr>';
+ var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' +
+ this._get(inst, 'calculateWeek')(printDate) + '</td>');
+ for (var dow = 0; dow < 7; dow++) { // create date picker days
+ var daySettings = (beforeShowDay ?
+ beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
+ var otherMonth = (printDate.getMonth() != drawMonth);
+ var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
+ (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
+ tbody += '<td class="' +
+ ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
+ (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
+ ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
+ (defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
+ // or defaultDate is current printedDate and defaultDate is selectedDate
+ ' ' + this._dayOverClass : '') + // highlight selected day
+ (unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days
+ (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
+ (printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
+ (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
+ ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
+ (unselectable ? '' : ' data-handler="selectDay" data-event="click" data-month="' + printDate.getMonth() + '" data-year="' + printDate.getFullYear() + '"') + '>' + // actions
+ (otherMonth && !showOtherMonths ? ' ' : // display for other months
+ (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
+ (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
+ (printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
+ (otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
+ '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
+ printDate.setDate(printDate.getDate() + 1);
+ printDate = this._daylightSavingAdjust(printDate);
+ }
+ calender += tbody + '</tr>';
+ }
+ drawMonth++;
+ if (drawMonth > 11) {
+ drawMonth = 0;
+ drawYear++;
+ }
+ calender += '</tbody></table>' + (isMultiMonth ? '</div>' +
+ ((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
+ group += calender;
+ }
+ html += group;
+ }
+ html += buttonPanel + ($.ui.ie6 && !inst.inline ?
+ '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
+ inst._keyEvent = false;
+ return html;
+ },
+
+ /* Generate the month and year header. */
+ _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
+ secondary, monthNames, monthNamesShort) {
+ var changeMonth = this._get(inst, 'changeMonth');
+ var changeYear = this._get(inst, 'changeYear');
+ var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
+ var html = '<div class="ui-datepicker-title">';
+ var monthHtml = '';
+ // month selection
+ if (secondary || !changeMonth)
+ monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>';
+ else {
+ var inMinYear = (minDate && minDate.getFullYear() == drawYear);
+ var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
+ monthHtml += '<select class="ui-datepicker-month" data-handler="selectMonth" data-event="change">';
+ for (var month = 0; month < 12; month++) {
+ if ((!inMinYear || month >= minDate.getMonth()) &&
+ (!inMaxYear || month <= maxDate.getMonth()))
+ monthHtml += '<option value="' + month + '"' +
+ (month == drawMonth ? ' selected="selected"' : '') +
+ '>' + monthNamesShort[month] + '</option>';
+ }
+ monthHtml += '</select>';
+ }
+ if (!showMonthAfterYear)
+ html += monthHtml + (secondary || !(changeMonth && changeYear) ? ' ' : '');
+ // year selection
+ if ( !inst.yearshtml ) {
+ inst.yearshtml = '';
+ if (secondary || !changeYear)
+ html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
+ else {
+ // determine range of years to display
+ var years = this._get(inst, 'yearRange').split(':');
+ var thisYear = new Date().getFullYear();
+ var determineYear = function(value) {
+ var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
+ (value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
+ parseInt(value, 10)));
+ return (isNaN(year) ? thisYear : year);
+ };
+ var year = determineYear(years[0]);
+ var endYear = Math.max(year, determineYear(years[1] || ''));
+ year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
+ endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
+ inst.yearshtml += '<select class="ui-datepicker-year" data-handler="selectYear" data-event="change">';
+ for (; year <= endYear; year++) {
+ inst.yearshtml += '<option value="' + year + '"' +
+ (year == drawYear ? ' selected="selected"' : '') +
+ '>' + year + '</option>';
+ }
+ inst.yearshtml += '</select>';
+
+ html += inst.yearshtml;
+ inst.yearshtml = null;
+ }
+ }
+ html += this._get(inst, 'yearSuffix');
+ if (showMonthAfterYear)
+ html += (secondary || !(changeMonth && changeYear) ? ' ' : '') + monthHtml;
+ html += '</div>'; // Close datepicker_header
+ return html;
+ },
+
+ /* Adjust one of the date sub-fields. */
+ _adjustInstDate: function(inst, offset, period) {
+ var year = inst.drawYear + (period == 'Y' ? offset : 0);
+ var month = inst.drawMonth + (period == 'M' ? offset : 0);
+ var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
+ (period == 'D' ? offset : 0);
+ var date = this._restrictMinMax(inst,
+ this._daylightSavingAdjust(new Date(year, month, day)));
+ inst.selectedDay = date.getDate();
+ inst.drawMonth = inst.selectedMonth = date.getMonth();
+ inst.drawYear = inst.selectedYear = date.getFullYear();
+ if (period == 'M' || period == 'Y')
+ this._notifyChange(inst);
+ },
+
+ /* Ensure a date is within any min/max bounds. */
+ _restrictMinMax: function(inst, date) {
+ var minDate = this._getMinMaxDate(inst, 'min');
+ var maxDate = this._getMinMaxDate(inst, 'max');
+ var newDate = (minDate && date < minDate ? minDate : date);
+ newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
+ return newDate;
+ },
+
+ /* Notify change of month/year. */
+ _notifyChange: function(inst) {
+ var onChange = this._get(inst, 'onChangeMonthYear');
+ if (onChange)
+ onChange.apply((inst.input ? inst.input[0] : null),
+ [inst.selectedYear, inst.selectedMonth + 1, inst]);
+ },
+
+ /* Determine the number of months to show. */
+ _getNumberOfMonths: function(inst) {
+ var numMonths = this._get(inst, 'numberOfMonths');
+ return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
+ },
+
+ /* Determine the current maximum date - ensure no time components are set. */
+ _getMinMaxDate: function(inst, minMax) {
+ return this._determineDate(inst, this._get(inst, minMax + 'Date'), null);
+ },
+
+ /* Find the number of days in a given month. */
+ _getDaysInMonth: function(year, month) {
+ return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
+ },
+
+ /* Find the day of the week of the first of a month. */
+ _getFirstDayOfMonth: function(year, month) {
+ return new Date(year, month, 1).getDay();
+ },
+
+ /* Determines if we should allow a "next/prev" month display change. */
+ _canAdjustMonth: function(inst, offset, curYear, curMonth) {
+ var numMonths = this._getNumberOfMonths(inst);
+ var date = this._daylightSavingAdjust(new Date(curYear,
+ curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
+ if (offset < 0)
+ date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
+ return this._isInRange(inst, date);
+ },
+
+ /* Is the given date in the accepted range? */
+ _isInRange: function(inst, date) {
+ var minDate = this._getMinMaxDate(inst, 'min');
+ var maxDate = this._getMinMaxDate(inst, 'max');
+ return ((!minDate || date.getTime() >= minDate.getTime()) &&
+ (!maxDate || date.getTime() <= maxDate.getTime()));
+ },
+
+ /* Provide the configuration settings for formatting/parsing. */
+ _getFormatConfig: function(inst) {
+ var shortYearCutoff = this._get(inst, 'shortYearCutoff');
+ shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
+ new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
+ return {shortYearCutoff: shortYearCutoff,
+ dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
+ monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
+ },
+
+ /* Format the given date for display. */
+ _formatDate: function(inst, day, month, year) {
+ if (!day) {
+ inst.currentDay = inst.selectedDay;
+ inst.currentMonth = inst.selectedMonth;
+ inst.currentYear = inst.selectedYear;
+ }
+ var date = (day ? (typeof day == 'object' ? day :
+ this._daylightSavingAdjust(new Date(year, month, day))) :
+ this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
+ return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
+ }
+});
+
+/*
+ * Bind hover events for datepicker elements.
+ * Done via delegate so the binding only occurs once in the lifetime of the parent div.
+ * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
+ */
+function bindHover(dpDiv) {
+ var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a';
+ return dpDiv.delegate(selector, 'mouseout', function() {
+ $(this).removeClass('ui-state-hover');
+ if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover');
+ if (this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover');
+ })
+ .delegate(selector, 'mouseover', function(){
+ if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
+ $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
+ $(this).addClass('ui-state-hover');
+ if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover');
+ if (this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover');
+ }
+ });
+}
+
+/* jQuery extend now ignores nulls! */
+function extendRemove(target, props) {
+ $.extend(target, props);
+ for (var name in props)
+ if (props[name] == null || props[name] == undefined)
+ target[name] = props[name];
+ return target;
+};
+
+/* Invoke the datepicker functionality.
+ @param options string - a command, optionally followed by additional parameters or
+ Object - settings for attaching new datepicker functionality
+ @return jQuery object */
+$.fn.datepicker = function(options){
+
+ /* Verify an empty collection wasn't passed - Fixes #6976 */
+ if ( !this.length ) {
+ return this;
+ }
+
+ /* Initialise the date picker. */
+ if (!$.datepicker.initialized) {
+ $(document).mousedown($.datepicker._checkExternalClick).
+ find(document.body).append($.datepicker.dpDiv);
+ $.datepicker.initialized = true;
+ }
+
+ var otherArgs = Array.prototype.slice.call(arguments, 1);
+ if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
+ return $.datepicker['_' + options + 'Datepicker'].
+ apply($.datepicker, [this[0]].concat(otherArgs));
+ if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
+ return $.datepicker['_' + options + 'Datepicker'].
+ apply($.datepicker, [this[0]].concat(otherArgs));
+ return this.each(function() {
+ typeof options == 'string' ?
+ $.datepicker['_' + options + 'Datepicker'].
+ apply($.datepicker, [this].concat(otherArgs)) :
+ $.datepicker._attachDatepicker(this, options);
+ });
+};
+
+$.datepicker = new Datepicker(); // singleton instance
+$.datepicker.initialized = false;
+$.datepicker.uuid = new Date().getTime();
+$.datepicker.version = "1.9.2";
+
+// Workaround for #4055
+// Add another global to avoid noConflict issues with inline event handlers
+window['DP_jQuery_' + dpuuid] = $;
+
+})(jQuery);
+(function( $, undefined ) {
+
+var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ",
+ sizeRelatedOptions = {
+ buttons: true,
+ height: true,
+ maxHeight: true,
+ maxWidth: true,
+ minHeight: true,
+ minWidth: true,
+ width: true
+ },
+ resizableRelatedOptions = {
+ maxHeight: true,
+ maxWidth: true,
+ minHeight: true,
+ minWidth: true
+ };
+
+$.widget("ui.dialog", {
+ version: "1.9.2",
+ options: {
+ autoOpen: true,
+ buttons: {},
+ closeOnEscape: true,
+ closeText: "close",
+ dialogClass: "",
+ draggable: true,
+ hide: null,
+ height: "auto",
+ maxHeight: false,
+ maxWidth: false,
+ minHeight: 150,
+ minWidth: 150,
+ modal: false,
+ position: {
+ my: "center",
+ at: "center",
+ of: window,
+ collision: "fit",
+ // ensure that the titlebar is never outside the document
+ using: function( pos ) {
+ var topOffset = $( this ).css( pos ).offset().top;
+ if ( topOffset < 0 ) {
+ $( this ).css( "top", pos.top - topOffset );
+ }
+ }
+ },
+ resizable: true,
+ show: null,
+ stack: true,
+ title: "",
+ width: 300,
+ zIndex: 1000
+ },
+
+ _create: function() {
+ this.originalTitle = this.element.attr( "title" );
+ // #5742 - .attr() might return a DOMElement
+ if ( typeof this.originalTitle !== "string" ) {
+ this.originalTitle = "";
+ }
+ this.oldPosition = {
+ parent: this.element.parent(),
+ index: this.element.parent().children().index( this.element )
+ };
+ this.options.title = this.options.title || this.originalTitle;
+ var that = this,
+ options = this.options,
+
+ title = options.title || " ",
+ uiDialog,
+ uiDialogTitlebar,
+ uiDialogTitlebarClose,
+ uiDialogTitle,
+ uiDialogButtonPane;
+
+ uiDialog = ( this.uiDialog = $( "<div>" ) )
+ .addClass( uiDialogClasses + options.dialogClass )
+ .css({
+ display: "none",
+ outline: 0, // TODO: move to stylesheet
+ zIndex: options.zIndex
+ })
+ // setting tabIndex makes the div focusable
+ .attr( "tabIndex", -1)
+ .keydown(function( event ) {
+ if ( options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
+ event.keyCode === $.ui.keyCode.ESCAPE ) {
+ that.close( event );
+ event.preventDefault();
+ }
+ })
+ .mousedown(function( event ) {
+ that.moveToTop( false, event );
+ })
+ .appendTo( "body" );
+
+ this.element
+ .show()
+ .removeAttr( "title" )
+ .addClass( "ui-dialog-content ui-widget-content" )
+ .appendTo( uiDialog );
+
+ uiDialogTitlebar = ( this.uiDialogTitlebar = $( "<div>" ) )
+ .addClass( "ui-dialog-titlebar ui-widget-header " +
+ "ui-corner-all ui-helper-clearfix" )
+ .bind( "mousedown", function() {
+ // Dialog isn't getting focus when dragging (#8063)
+ uiDialog.focus();
+ })
+ .prependTo( uiDialog );
+
+ uiDialogTitlebarClose = $( "<a href='#'></a>" )
+ .addClass( "ui-dialog-titlebar-close ui-corner-all" )
+ .attr( "role", "button" )
+ .click(function( event ) {
+ event.preventDefault();
+ that.close( event );
+ })
+ .appendTo( uiDialogTitlebar );
+
+ ( this.uiDialogTitlebarCloseText = $( "<span>" ) )
+ .addClass( "ui-icon ui-icon-closethick" )
+ .text( options.closeText )
+ .appendTo( uiDialogTitlebarClose );
+
+ uiDialogTitle = $( "<span>" )
+ .uniqueId()
+ .addClass( "ui-dialog-title" )
+ .html( title )
+ .prependTo( uiDialogTitlebar );
+
+ uiDialogButtonPane = ( this.uiDialogButtonPane = $( "<div>" ) )
+ .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
+
+ ( this.uiButtonSet = $( "<div>" ) )
+ .addClass( "ui-dialog-buttonset" )
+ .appendTo( uiDialogButtonPane );
+
+ uiDialog.attr({
+ role: "dialog",
+ "aria-labelledby": uiDialogTitle.attr( "id" )
+ });
+
+ uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();
+ this._hoverable( uiDialogTitlebarClose );
+ this._focusable( uiDialogTitlebarClose );
+
+ if ( options.draggable && $.fn.draggable ) {
+ this._makeDraggable();
+ }
+ if ( options.resizable && $.fn.resizable ) {
+ this._makeResizable();
+ }
+
+ this._createButtons( options.buttons );
+ this._isOpen = false;
+
+ if ( $.fn.bgiframe ) {
+ uiDialog.bgiframe();
+ }
+
+ // prevent tabbing out of modal dialogs
+ this._on( uiDialog, { keydown: function( event ) {
+ if ( !options.modal || event.keyCode !== $.ui.keyCode.TAB ) {
+ return;
+ }
+
+ var tabbables = $( ":tabbable", uiDialog ),
+ first = tabbables.filter( ":first" ),
+ last = tabbables.filter( ":last" );
+
+ if ( event.target === last[0] && !event.shiftKey ) {
+ first.focus( 1 );
+ return false;
+ } else if ( event.target === first[0] && event.shiftKey ) {
+ last.focus( 1 );
+ return false;
+ }
+ }});
+ },
+
+ _init: function() {
+ if ( this.options.autoOpen ) {
+ this.open();
+ }
+ },
+
+ _destroy: function() {
+ var next,
+ oldPosition = this.oldPosition;
+
+ if ( this.overlay ) {
+ this.overlay.destroy();
+ }
+ this.uiDialog.hide();
+ this.element
+ .removeClass( "ui-dialog-content ui-widget-content" )
+ .hide()
+ .appendTo( "body" );
+ this.uiDialog.remove();
+
+ if ( this.originalTitle ) {
+ this.element.attr( "title", this.originalTitle );
+ }
+
+ next = oldPosition.parent.children().eq( oldPosition.index );
+ // Don't try to place the dialog next to itself (#8613)
+ if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
+ next.before( this.element );
+ } else {
+ oldPosition.parent.append( this.element );
+ }
+ },
+
+ widget: function() {
+ return this.uiDialog;
+ },
+
+ close: function( event ) {
+ var that = this,
+ maxZ, thisZ;
+
+ if ( !this._isOpen ) {
+ return;
+ }
+
+ if ( false === this._trigger( "beforeClose", event ) ) {
+ return;
+ }
+
+ this._isOpen = false;
+
+ if ( this.overlay ) {
+ this.overlay.destroy();
+ }
+
+ if ( this.options.hide ) {
+ this._hide( this.uiDialog, this.options.hide, function() {
+ that._trigger( "close", event );
+ });
+ } else {
+ this.uiDialog.hide();
+ this._trigger( "close", event );
+ }
+
+ $.ui.dialog.overlay.resize();
+
+ // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
+ if ( this.options.modal ) {
+ maxZ = 0;
+ $( ".ui-dialog" ).each(function() {
+ if ( this !== that.uiDialog[0] ) {
+ thisZ = $( this ).css( "z-index" );
+ if ( !isNaN( thisZ ) ) {
+ maxZ = Math.max( maxZ, thisZ );
+ }
+ }
+ });
+ $.ui.dialog.maxZ = maxZ;
+ }
+
+ return this;
+ },
+
+ isOpen: function() {
+ return this._isOpen;
+ },
+
+ // the force parameter allows us to move modal dialogs to their correct
+ // position on open
+ moveToTop: function( force, event ) {
+ var options = this.options,
+ saveScroll;
+
+ if ( ( options.modal && !force ) ||
+ ( !options.stack && !options.modal ) ) {
+ return this._trigger( "focus", event );
+ }
+
+ if ( options.zIndex > $.ui.dialog.maxZ ) {
+ $.ui.dialog.maxZ = options.zIndex;
+ }
+ if ( this.overlay ) {
+ $.ui.dialog.maxZ += 1;
+ $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ;
+ this.overlay.$el.css( "z-index", $.ui.dialog.overlay.maxZ );
+ }
+
+ // Save and then restore scroll
+ // Opera 9.5+ resets when parent z-index is changed.
+ // http://bugs.jqueryui.com/ticket/3193
+ saveScroll = {
+ scrollTop: this.element.scrollTop(),
+ scrollLeft: this.element.scrollLeft()
+ };
+ $.ui.dialog.maxZ += 1;
+ this.uiDialog.css( "z-index", $.ui.dialog.maxZ );
+ this.element.attr( saveScroll );
+ this._trigger( "focus", event );
+
+ return this;
+ },
+
+ open: function() {
+ if ( this._isOpen ) {
+ return;
+ }
+
+ var hasFocus,
+ options = this.options,
+ uiDialog = this.uiDialog;
+
+ this._size();
+ this._position( options.position );
+ uiDialog.show( options.show );
+ this.overlay = options.modal ? new $.ui.dialog.overlay( this ) : null;
+ this.moveToTop( true );
+
+ // set focus to the first tabbable element in the content area or the first button
+ // if there are no tabbable elements, set focus on the dialog itself
+ hasFocus = this.element.find( ":tabbable" );
+ if ( !hasFocus.length ) {
+ hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
+ if ( !hasFocus.length ) {
+ hasFocus = uiDialog;
+ }
+ }
+ hasFocus.eq( 0 ).focus();
+
+ this._isOpen = true;
+ this._trigger( "open" );
+
+ return this;
+ },
+
+ _createButtons: function( buttons ) {
+ var that = this,
+ hasButtons = false;
+
+ // if we already have a button pane, remove it
+ this.uiDialogButtonPane.remove();
+ this.uiButtonSet.empty();
+
+ if ( typeof buttons === "object" && buttons !== null ) {
+ $.each( buttons, function() {
+ return !(hasButtons = true);
+ });
+ }
+ if ( hasButtons ) {
+ $.each( buttons, function( name, props ) {
+ var button, click;
+ props = $.isFunction( props ) ?
+ { click: props, text: name } :
+ props;
+ // Default to a non-submitting button
+ props = $.extend( { type: "button" }, props );
+ // Change the context for the click callback to be the main element
+ click = props.click;
+ props.click = function() {
+ click.apply( that.element[0], arguments );
+ };
+ button = $( "<button></button>", props )
+ .appendTo( that.uiButtonSet );
+ if ( $.fn.button ) {
+ button.button();
+ }
+ });
+ this.uiDialog.addClass( "ui-dialog-buttons" );
+ this.uiDialogButtonPane.appendTo( this.uiDialog );
+ } else {
+ this.uiDialog.removeClass( "ui-dialog-buttons" );
+ }
+ },
+
+ _makeDraggable: function() {
+ var that = this,
+ options = this.options;
+
+ function filteredUi( ui ) {
+ return {
+ position: ui.position,
+ offset: ui.offset
+ };
+ }
+
+ this.uiDialog.draggable({
+ cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
+ handle: ".ui-dialog-titlebar",
+ containment: "document",
+ start: function( event, ui ) {
+ $( this )
+ .addClass( "ui-dialog-dragging" );
+ that._trigger( "dragStart", event, filteredUi( ui ) );
+ },
+ drag: function( event, ui ) {
+ that._trigger( "drag", event, filteredUi( ui ) );
+ },
+ stop: function( event, ui ) {
+ options.position = [
+ ui.position.left - that.document.scrollLeft(),
+ ui.position.top - that.document.scrollTop()
+ ];
+ $( this )
+ .removeClass( "ui-dialog-dragging" );
+ that._trigger( "dragStop", event, filteredUi( ui ) );
+ $.ui.dialog.overlay.resize();
+ }
+ });
+ },
+
+ _makeResizable: function( handles ) {
+ handles = (handles === undefined ? this.options.resizable : handles);
+ var that = this,
+ options = this.options,
+ // .ui-resizable has position: relative defined in the stylesheet
+ // but dialogs have to use absolute or fixed positioning
+ position = this.uiDialog.css( "position" ),
+ resizeHandles = typeof handles === 'string' ?
+ handles :
+ "n,e,s,w,se,sw,ne,nw";
+
+ function filteredUi( ui ) {
+ return {
+ originalPosition: ui.originalPosition,
+ originalSize: ui.originalSize,
+ position: ui.position,
+ size: ui.size
+ };
+ }
+
+ this.uiDialog.resizable({
+ cancel: ".ui-dialog-content",
+ containment: "document",
+ alsoResize: this.element,
+ maxWidth: options.maxWidth,
+ maxHeight: options.maxHeight,
+ minWidth: options.minWidth,
+ minHeight: this._minHeight(),
+ handles: resizeHandles,
+ start: function( event, ui ) {
+ $( this ).addClass( "ui-dialog-resizing" );
+ that._trigger( "resizeStart", event, filteredUi( ui ) );
+ },
+ resize: function( event, ui ) {
+ that._trigger( "resize", event, filteredUi( ui ) );
+ },
+ stop: function( event, ui ) {
+ $( this ).removeClass( "ui-dialog-resizing" );
+ options.height = $( this ).height();
+ options.width = $( this ).width();
+ that._trigger( "resizeStop", event, filteredUi( ui ) );
+ $.ui.dialog.overlay.resize();
+ }
+ })
+ .css( "position", position )
+ .find( ".ui-resizable-se" )
+ .addClass( "ui-icon ui-icon-grip-diagonal-se" );
+ },
+
+ _minHeight: function() {
+ var options = this.options;
+
+ if ( options.height === "auto" ) {
+ return options.minHeight;
+ } else {
+ return Math.min( options.minHeight, options.height );
+ }
+ },
+
+ _position: function( position ) {
+ var myAt = [],
+ offset = [ 0, 0 ],
+ isVisible;
+
+ if ( position ) {
+ // deep extending converts arrays to objects in jQuery <= 1.3.2 :-(
+ // if (typeof position == 'string' || $.isArray(position)) {
+ // myAt = $.isArray(position) ? position : position.split(' ');
+
+ if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
+ myAt = position.split ? position.split( " " ) : [ position[ 0 ], position[ 1 ] ];
+ if ( myAt.length === 1 ) {
+ myAt[ 1 ] = myAt[ 0 ];
+ }
+
+ $.each( [ "left", "top" ], function( i, offsetPosition ) {
+ if ( +myAt[ i ] === myAt[ i ] ) {
+ offset[ i ] = myAt[ i ];
+ myAt[ i ] = offsetPosition;
+ }
+ });
+
+ position = {
+ my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
+ myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
+ at: myAt.join( " " )
+ };
+ }
+
+ position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
+ } else {
+ position = $.ui.dialog.prototype.options.position;
+ }
+
+ // need to show the dialog to get the actual offset in the position plugin
+ isVisible = this.uiDialog.is( ":visible" );
+ if ( !isVisible ) {
+ this.uiDialog.show();
+ }
+ this.uiDialog.position( position );
+ if ( !isVisible ) {
+ this.uiDialog.hide();
+ }
+ },
+
+ _setOptions: function( options ) {
+ var that = this,
+ resizableOptions = {},
+ resize = false;
+
+ $.each( options, function( key, value ) {
+ that._setOption( key, value );
+
+ if ( key in sizeRelatedOptions ) {
+ resize = true;
+ }
+ if ( key in resizableRelatedOptions ) {
+ resizableOptions[ key ] = value;
+ }
+ });
+
+ if ( resize ) {
+ this._size();
+ }
+ if ( this.uiDialog.is( ":data(resizable)" ) ) {
+ this.uiDialog.resizable( "option", resizableOptions );
+ }
+ },
+
+ _setOption: function( key, value ) {
+ var isDraggable, isResizable,
+ uiDialog = this.uiDialog;
+
+ switch ( key ) {
+ case "buttons":
+ this._createButtons( value );
+ break;
+ case "closeText":
+ // ensure that we always pass a string
+ this.uiDialogTitlebarCloseText.text( "" + value );
+ break;
+ case "dialogClass":
+ uiDialog
+ .removeClass( this.options.dialogClass )
+ .addClass( uiDialogClasses + value );
+ break;
+ case "disabled":
+ if ( value ) {
+ uiDialog.addClass( "ui-dialog-disabled" );
+ } else {
+ uiDialog.removeClass( "ui-dialog-disabled" );
+ }
+ break;
+ case "draggable":
+ isDraggable = uiDialog.is( ":data(draggable)" );
+ if ( isDraggable && !value ) {
+ uiDialog.draggable( "destroy" );
+ }
+
+ if ( !isDraggable && value ) {
+ this._makeDraggable();
+ }
+ break;
+ case "position":
+ this._position( value );
+ break;
+ case "resizable":
+ // currently resizable, becoming non-resizable
+ isResizable = uiDialog.is( ":data(resizable)" );
+ if ( isResizable && !value ) {
+ uiDialog.resizable( "destroy" );
+ }
+
+ // currently resizable, changing handles
+ if ( isResizable && typeof value === "string" ) {
+ uiDialog.resizable( "option", "handles", value );
+ }
+
+ // currently non-resizable, becoming resizable
+ if ( !isResizable && value !== false ) {
+ this._makeResizable( value );
+ }
+ break;
+ case "title":
+ // convert whatever was passed in o a string, for html() to not throw up
+ $( ".ui-dialog-title", this.uiDialogTitlebar )
+ .html( "" + ( value || " " ) );
+ break;
+ }
+
+ this._super( key, value );
+ },
+
+ _size: function() {
+ /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
+ * divs will both have width and height set, so we need to reset them
+ */
+ var nonContentHeight, minContentHeight, autoHeight,
+ options = this.options,
+ isVisible = this.uiDialog.is( ":visible" );
+
+ // reset content sizing
+ this.element.show().css({
+ width: "auto",
+ minHeight: 0,
+ height: 0
+ });
+
+ if ( options.minWidth > options.width ) {
+ options.width = options.minWidth;
+ }
+
+ // reset wrapper sizing
+ // determine the height of all the non-content elements
+ nonContentHeight = this.uiDialog.css({
+ height: "auto",
+ width: options.width
+ })
+ .outerHeight();
+ minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
+
+ if ( options.height === "auto" ) {
+ // only needed for IE6 support
+ if ( $.support.minHeight ) {
+ this.element.css({
+ minHeight: minContentHeight,
+ height: "auto"
+ });
+ } else {
+ this.uiDialog.show();
+ autoHeight = this.element.css( "height", "auto" ).height();
+ if ( !isVisible ) {
+ this.uiDialog.hide();
+ }
+ this.element.height( Math.max( autoHeight, minContentHeight ) );
+ }
+ } else {
+ this.element.height( Math.max( options.height - nonContentHeight, 0 ) );
+ }
+
+ if (this.uiDialog.is( ":data(resizable)" ) ) {
+ this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
+ }
+ }
+});
+
+$.extend($.ui.dialog, {
+ uuid: 0,
+ maxZ: 0,
+
+ getTitleId: function($el) {
+ var id = $el.attr( "id" );
+ if ( !id ) {
+ this.uuid += 1;
+ id = this.uuid;
+ }
+ return "ui-dialog-title-" + id;
+ },
+
+ overlay: function( dialog ) {
+ this.$el = $.ui.dialog.overlay.create( dialog );
+ }
+});
+
+$.extend( $.ui.dialog.overlay, {
+ instances: [],
+ // reuse old instances due to IE memory leak with alpha transparency (see #5185)
+ oldInstances: [],
+ maxZ: 0,
+ events: $.map(
+ "focus,mousedown,mouseup,keydown,keypress,click".split( "," ),
+ function( event ) {
+ return event + ".dialog-overlay";
+ }
+ ).join( " " ),
+ create: function( dialog ) {
+ if ( this.instances.length === 0 ) {
+ // prevent use of anchors and inputs
+ // we use a setTimeout in case the overlay is created from an
+ // event that we're going to be cancelling (see #2804)
+ setTimeout(function() {
+ // handle $(el).dialog().dialog('close') (see #4065)
+ if ( $.ui.dialog.overlay.instances.length ) {
+ $( document ).bind( $.ui.dialog.overlay.events, function( event ) {
+ // stop events if the z-index of the target is < the z-index of the overlay
+ // we cannot return true when we don't want to cancel the event (#3523)
+ if ( $( event.target ).zIndex() < $.ui.dialog.overlay.maxZ ) {
+ return false;
+ }
+ });
+ }
+ }, 1 );
+
+ // handle window resize
+ $( window ).bind( "resize.dialog-overlay", $.ui.dialog.overlay.resize );
+ }
+
+ var $el = ( this.oldInstances.pop() || $( "<div>" ).addClass( "ui-widget-overlay" ) );
+
+ // allow closing by pressing the escape key
+ $( document ).bind( "keydown.dialog-overlay", function( event ) {
+ var instances = $.ui.dialog.overlay.instances;
+ // only react to the event if we're the top overlay
+ if ( instances.length !== 0 && instances[ instances.length - 1 ] === $el &&
+ dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
+ event.keyCode === $.ui.keyCode.ESCAPE ) {
+
+ dialog.close( event );
+ event.preventDefault();
+ }
+ });
+
+ $el.appendTo( document.body ).css({
+ width: this.width(),
+ height: this.height()
+ });
+
+ if ( $.fn.bgiframe ) {
+ $el.bgiframe();
+ }
+
+ this.instances.push( $el );
+ return $el;
+ },
+
+ destroy: function( $el ) {
+ var indexOf = $.inArray( $el, this.instances ),
+ maxZ = 0;
+
+ if ( indexOf !== -1 ) {
+ this.oldInstances.push( this.instances.splice( indexOf, 1 )[ 0 ] );
+ }
+
+ if ( this.instances.length === 0 ) {
+ $( [ document, window ] ).unbind( ".dialog-overlay" );
+ }
+
+ $el.height( 0 ).width( 0 ).remove();
+
+ // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
+ $.each( this.instances, function() {
+ maxZ = Math.max( maxZ, this.css( "z-index" ) );
+ });
+ this.maxZ = maxZ;
+ },
+
+ height: function() {
+ var scrollHeight,
+ offsetHeight;
+ // handle IE
+ if ( $.ui.ie ) {
+ scrollHeight = Math.max(
+ document.documentElement.scrollHeight,
+ document.body.scrollHeight
+ );
+ offsetHeight = Math.max(
+ document.documentElement.offsetHeight,
+ document.body.offsetHeight
+ );
+
+ if ( scrollHeight < offsetHeight ) {
+ return $( window ).height() + "px";
+ } else {
+ return scrollHeight + "px";
+ }
+ // handle "good" browsers
+ } else {
+ return $( document ).height() + "px";
+ }
+ },
+
+ width: function() {
+ var scrollWidth,
+ offsetWidth;
+ // handle IE
+ if ( $.ui.ie ) {
+ scrollWidth = Math.max(
+ document.documentElement.scrollWidth,
+ document.body.scrollWidth
+ );
+ offsetWidth = Math.max(
+ document.documentElement.offsetWidth,
+ document.body.offsetWidth
+ );
+
+ if ( scrollWidth < offsetWidth ) {
+ return $( window ).width() + "px";
+ } else {
+ return scrollWidth + "px";
+ }
+ // handle "good" browsers
+ } else {
+ return $( document ).width() + "px";
+ }
+ },
+
+ resize: function() {
+ /* If the dialog is draggable and the user drags it past the
+ * right edge of the window, the document becomes wider so we
+ * need to stretch the overlay. If the user then drags the
+ * dialog back to the left, the document will become narrower,
+ * so we need to shrink the overlay to the appropriate size.
+ * This is handled by shrinking the overlay before setting it
+ * to the full document size.
+ */
+ var $overlays = $( [] );
+ $.each( $.ui.dialog.overlay.instances, function() {
+ $overlays = $overlays.add( this );
+ });
+
+ $overlays.css({
+ width: 0,
+ height: 0
+ }).css({
+ width: $.ui.dialog.overlay.width(),
+ height: $.ui.dialog.overlay.height()
+ });
+ }
+});
+
+$.extend( $.ui.dialog.overlay.prototype, {
+ destroy: function() {
+ $.ui.dialog.overlay.destroy( this.$el );
+ }
+});
+
+}( jQuery ) );
+(function( $, undefined ) {
+
+var mouseHandled = false;
+
+$.widget( "ui.menu", {
+ version: "1.9.2",
+ defaultElement: "<ul>",
+ delay: 300,
+ options: {
+ icons: {
+ submenu: "ui-icon-carat-1-e"
+ },
+ menus: "ul",
+ position: {
+ my: "left top",
+ at: "right top"
+ },
+ role: "menu",
+
+ // callbacks
+ blur: null,
+ focus: null,
+ select: null
+ },
+
+ _create: function() {
+ this.activeMenu = this.element;
+ this.element
+ .uniqueId()
+ .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
+ .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
+ .attr({
+ role: this.options.role,
+ tabIndex: 0
+ })
+ // need to catch all clicks on disabled menu
+ // not possible through _on
+ .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
+ if ( this.options.disabled ) {
+ event.preventDefault();
+ }
+ }, this ));
+
+ if ( this.options.disabled ) {
+ this.element
+ .addClass( "ui-state-disabled" )
+ .attr( "aria-disabled", "true" );
+ }
+
+ this._on({
+ // Prevent focus from sticking to links inside menu after clicking
+ // them (focus should always stay on UL during navigation).
+ "mousedown .ui-menu-item > a": function( event ) {
+ event.preventDefault();
+ },
+ "click .ui-state-disabled > a": function( event ) {
+ event.preventDefault();
+ },
+ "click .ui-menu-item:has(a)": function( event ) {
+ var target = $( event.target ).closest( ".ui-menu-item" );
+ if ( !mouseHandled && target.not( ".ui-state-disabled" ).length ) {
+ mouseHandled = true;
+
+ this.select( event );
+ // Open submenu on click
+ if ( target.has( ".ui-menu" ).length ) {
+ this.expand( event );
+ } else if ( !this.element.is( ":focus" ) ) {
+ // Redirect focus to the menu
+ this.element.trigger( "focus", [ true ] );
+
+ // If the active item is on the top level, let it stay active.
+ // Otherwise, blur the active item since it is no longer visible.
+ if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
+ clearTimeout( this.timer );
+ }
+ }
+ }
+ },
+ "mouseenter .ui-menu-item": function( event ) {
+ var target = $( event.currentTarget );
+ // Remove ui-state-active class from siblings of the newly focused menu item
+ // to avoid a jump caused by adjacent elements both having a class with a border
+ target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
+ this.focus( event, target );
+ },
+ mouseleave: "collapseAll",
+ "mouseleave .ui-menu": "collapseAll",
+ focus: function( event, keepActiveItem ) {
+ // If there's already an active item, keep it active
+ // If not, activate the first item
+ var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
+
+ if ( !keepActiveItem ) {
+ this.focus( event, item );
+ }
+ },
+ blur: function( event ) {
+ this._delay(function() {
+ if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
+ this.collapseAll( event );
+ }
+ });
+ },
+ keydown: "_keydown"
+ });
+
+ this.refresh();
+
+ // Clicks outside of a menu collapse any open menus
+ this._on( this.document, {
+ click: function( event ) {
+ if ( !$( event.target ).closest( ".ui-menu" ).length ) {
+ this.collapseAll( event );
+ }
+
+ // Reset the mouseHandled flag
+ mouseHandled = false;
+ }
+ });
+ },
+
+ _destroy: function() {
+ // Destroy (sub)menus
+ this.element
+ .removeAttr( "aria-activedescendant" )
+ .find( ".ui-menu" ).andSelf()
+ .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
+ .removeAttr( "role" )
+ .removeAttr( "tabIndex" )
+ .removeAttr( "aria-labelledby" )
+ .removeAttr( "aria-expanded" )
+ .removeAttr( "aria-hidden" )
+ .removeAttr( "aria-disabled" )
+ .removeUniqueId()
+ .show();
+
+ // Destroy menu items
+ this.element.find( ".ui-menu-item" )
+ .removeClass( "ui-menu-item" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-disabled" )
+ .children( "a" )
+ .removeUniqueId()
+ .removeClass( "ui-corner-all ui-state-hover" )
+ .removeAttr( "tabIndex" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-haspopup" )
+ .children().each( function() {
+ var elem = $( this );
+ if ( elem.data( "ui-menu-submenu-carat" ) ) {
+ elem.remove();
+ }
+ });
+
+ // Destroy menu dividers
+ this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
+ },
+
+ _keydown: function( event ) {
+ var match, prev, character, skip, regex,
+ preventDefault = true;
+
+ function escape( value ) {
+ return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
+ }
+
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.PAGE_UP:
+ this.previousPage( event );
+ break;
+ case $.ui.keyCode.PAGE_DOWN:
+ this.nextPage( event );
+ break;
+ case $.ui.keyCode.HOME:
+ this._move( "first", "first", event );
+ break;
+ case $.ui.keyCode.END:
+ this._move( "last", "last", event );
+ break;
+ case $.ui.keyCode.UP:
+ this.previous( event );
+ break;
+ case $.ui.keyCode.DOWN:
+ this.next( event );
+ break;
+ case $.ui.keyCode.LEFT:
+ this.collapse( event );
+ break;
+ case $.ui.keyCode.RIGHT:
+ if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
+ this.expand( event );
+ }
+ break;
+ case $.ui.keyCode.ENTER:
+ case $.ui.keyCode.SPACE:
+ this._activate( event );
+ break;
+ case $.ui.keyCode.ESCAPE:
+ this.collapse( event );
+ break;
+ default:
+ preventDefault = false;
+ prev = this.previousFilter || "";
+ character = String.fromCharCode( event.keyCode );
+ skip = false;
+
+ clearTimeout( this.filterTimer );
+
+ if ( character === prev ) {
+ skip = true;
+ } else {
+ character = prev + character;
+ }
+
+ regex = new RegExp( "^" + escape( character ), "i" );
+ match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
+ return regex.test( $( this ).children( "a" ).text() );
+ });
+ match = skip && match.index( this.active.next() ) !== -1 ?
+ this.active.nextAll( ".ui-menu-item" ) :
+ match;
+
+ // If no matches on the current filter, reset to the last character pressed
+ // to move down the menu to the first item that starts with that character
+ if ( !match.length ) {
+ character = String.fromCharCode( event.keyCode );
+ regex = new RegExp( "^" + escape( character ), "i" );
+ match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
+ return regex.test( $( this ).children( "a" ).text() );
+ });
+ }
+
+ if ( match.length ) {
+ this.focus( event, match );
+ if ( match.length > 1 ) {
+ this.previousFilter = character;
+ this.filterTimer = this._delay(function() {
+ delete this.previousFilter;
+ }, 1000 );
+ } else {
+ delete this.previousFilter;
+ }
+ } else {
+ delete this.previousFilter;
+ }
+ }
+
+ if ( preventDefault ) {
+ event.preventDefault();
+ }
+ },
+
+ _activate: function( event ) {
+ if ( !this.active.is( ".ui-state-disabled" ) ) {
+ if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
+ this.expand( event );
+ } else {
+ this.select( event );
+ }
+ }
+ },
+
+ refresh: function() {
+ var menus,
+ icon = this.options.icons.submenu,
+ submenus = this.element.find( this.options.menus );
+
+ // Initialize nested menus
+ submenus.filter( ":not(.ui-menu)" )
+ .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
+ .hide()
+ .attr({
+ role: this.options.role,
+ "aria-hidden": "true",
+ "aria-expanded": "false"
+ })
+ .each(function() {
+ var menu = $( this ),
+ item = menu.prev( "a" ),
+ submenuCarat = $( "<span>" )
+ .addClass( "ui-menu-icon ui-icon " + icon )
+ .data( "ui-menu-submenu-carat", true );
+
+ item
+ .attr( "aria-haspopup", "true" )
+ .prepend( submenuCarat );
+ menu.attr( "aria-labelledby", item.attr( "id" ) );
+ });
+
+ menus = submenus.add( this.element );
+
+ // Don't refresh list items that are already adapted
+ menus.children( ":not(.ui-menu-item):has(a)" )
+ .addClass( "ui-menu-item" )
+ .attr( "role", "presentation" )
+ .children( "a" )
+ .uniqueId()
+ .addClass( "ui-corner-all" )
+ .attr({
+ tabIndex: -1,
+ role: this._itemRole()
+ });
+
+ // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
+ menus.children( ":not(.ui-menu-item)" ).each(function() {
+ var item = $( this );
+ // hyphen, em dash, en dash
+ if ( !/[^\-—–\s]/.test( item.text() ) ) {
+ item.addClass( "ui-widget-content ui-menu-divider" );
+ }
+ });
+
+ // Add aria-disabled attribute to any disabled menu item
+ menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
+
+ // If the active item has been removed, blur the menu
+ if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
+ this.blur();
+ }
+ },
+
+ _itemRole: function() {
+ return {
+ menu: "menuitem",
+ listbox: "option"
+ }[ this.options.role ];
+ },
+
+ focus: function( event, item ) {
+ var nested, focused;
+ this.blur( event, event && event.type === "focus" );
+
+ this._scrollIntoView( item );
+
+ this.active = item.first();
+ focused = this.active.children( "a" ).addClass( "ui-state-focus" );
+ // Only update aria-activedescendant if there's a role
+ // otherwise we assume focus is managed elsewhere
+ if ( this.options.role ) {
+ this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
+ }
+
+ // Highlight active parent menu item, if any
+ this.active
+ .parent()
+ .closest( ".ui-menu-item" )
+ .children( "a:first" )
+ .addClass( "ui-state-active" );
+
+ if ( event && event.type === "keydown" ) {
+ this._close();
+ } else {
+ this.timer = this._delay(function() {
+ this._close();
+ }, this.delay );
+ }
+
+ nested = item.children( ".ui-menu" );
+ if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
+ this._startOpening(nested);
+ }
+ this.activeMenu = item.parent();
+
+ this._trigger( "focus", event, { item: item } );
+ },
+
+ _scrollIntoView: function( item ) {
+ var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
+ if ( this._hasScroll() ) {
+ borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
+ paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
+ offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
+ scroll = this.activeMenu.scrollTop();
+ elementHeight = this.activeMenu.height();
+ itemHeight = item.height();
+
+ if ( offset < 0 ) {
+ this.activeMenu.scrollTop( scroll + offset );
+ } else if ( offset + itemHeight > elementHeight ) {
+ this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
+ }
+ }
+ },
+
+ blur: function( event, fromFocus ) {
+ if ( !fromFocus ) {
+ clearTimeout( this.timer );
+ }
+
+ if ( !this.active ) {
+ return;
+ }
+
+ this.active.children( "a" ).removeClass( "ui-state-focus" );
+ this.active = null;
+
+ this._trigger( "blur", event, { item: this.active } );
+ },
+
+ _startOpening: function( submenu ) {
+ clearTimeout( this.timer );
+
+ // Don't open if already open fixes a Firefox bug that caused a .5 pixel
+ // shift in the submenu position when mousing over the carat icon
+ if ( submenu.attr( "aria-hidden" ) !== "true" ) {
+ return;
+ }
+
+ this.timer = this._delay(function() {
+ this._close();
+ this._open( submenu );
+ }, this.delay );
+ },
+
+ _open: function( submenu ) {
+ var position = $.extend({
+ of: this.active
+ }, this.options.position );
+
+ clearTimeout( this.timer );
+ this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
+ .hide()
+ .attr( "aria-hidden", "true" );
+
+ submenu
+ .show()
+ .removeAttr( "aria-hidden" )
+ .attr( "aria-expanded", "true" )
+ .position( position );
+ },
+
+ collapseAll: function( event, all ) {
+ clearTimeout( this.timer );
+ this.timer = this._delay(function() {
+ // If we were passed an event, look for the submenu that contains the event
+ var currentMenu = all ? this.element :
+ $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
+
+ // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
+ if ( !currentMenu.length ) {
+ currentMenu = this.element;
+ }
+
+ this._close( currentMenu );
+
+ this.blur( event );
+ this.activeMenu = currentMenu;
+ }, this.delay );
+ },
+
+ // With no arguments, closes the currently active menu - if nothing is active
+ // it closes all menus. If passed an argument, it will search for menus BELOW
+ _close: function( startMenu ) {
+ if ( !startMenu ) {
+ startMenu = this.active ? this.active.parent() : this.element;
+ }
+
+ startMenu
+ .find( ".ui-menu" )
+ .hide()
+ .attr( "aria-hidden", "true" )
+ .attr( "aria-expanded", "false" )
+ .end()
+ .find( "a.ui-state-active" )
+ .removeClass( "ui-state-active" );
+ },
+
+ collapse: function( event ) {
+ var newItem = this.active &&
+ this.active.parent().closest( ".ui-menu-item", this.element );
+ if ( newItem && newItem.length ) {
+ this._close();
+ this.focus( event, newItem );
+ }
+ },
+
+ expand: function( event ) {
+ var newItem = this.active &&
+ this.active
+ .children( ".ui-menu " )
+ .children( ".ui-menu-item" )
+ .first();
+
+ if ( newItem && newItem.length ) {
+ this._open( newItem.parent() );
+
+ // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
+ this._delay(function() {
+ this.focus( event, newItem );
+ });
+ }
+ },
+
+ next: function( event ) {
+ this._move( "next", "first", event );
+ },
+
+ previous: function( event ) {
+ this._move( "prev", "last", event );
+ },
+
+ isFirstItem: function() {
+ return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
+ },
+
+ isLastItem: function() {
+ return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
+ },
+
+ _move: function( direction, filter, event ) {
+ var next;
+ if ( this.active ) {
+ if ( direction === "first" || direction === "last" ) {
+ next = this.active
+ [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
+ .eq( -1 );
+ } else {
+ next = this.active
+ [ direction + "All" ]( ".ui-menu-item" )
+ .eq( 0 );
+ }
+ }
+ if ( !next || !next.length || !this.active ) {
+ next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
+ }
+
+ this.focus( event, next );
+ },
+
+ nextPage: function( event ) {
+ var item, base, height;
+
+ if ( !this.active ) {
+ this.next( event );
+ return;
+ }
+ if ( this.isLastItem() ) {
+ return;
+ }
+ if ( this._hasScroll() ) {
+ base = this.active.offset().top;
+ height = this.element.height();
+ this.active.nextAll( ".ui-menu-item" ).each(function() {
+ item = $( this );
+ return item.offset().top - base - height < 0;
+ });
+
+ this.focus( event, item );
+ } else {
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" )
+ [ !this.active ? "first" : "last" ]() );
+ }
+ },
+
+ previousPage: function( event ) {
+ var item, base, height;
+ if ( !this.active ) {
+ this.next( event );
+ return;
+ }
+ if ( this.isFirstItem() ) {
+ return;
+ }
+ if ( this._hasScroll() ) {
+ base = this.active.offset().top;
+ height = this.element.height();
+ this.active.prevAll( ".ui-menu-item" ).each(function() {
+ item = $( this );
+ return item.offset().top - base + height > 0;
+ });
+
+ this.focus( event, item );
+ } else {
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
+ }
+ },
+
+ _hasScroll: function() {
+ return this.element.outerHeight() < this.element.prop( "scrollHeight" );
+ },
+
+ select: function( event ) {
+ // TODO: It should never be possible to not have an active item at this
+ // point, but the tests don't trigger mouseenter before click.
+ this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
+ var ui = { item: this.active };
+ if ( !this.active.has( ".ui-menu" ).length ) {
+ this.collapseAll( event, true );
+ }
+ this._trigger( "select", event, ui );
+ }
+});
+
+}( jQuery ));
+(function( $, undefined ) {
+
+$.widget( "ui.progressbar", {
+ version: "1.9.2",
+ options: {
+ value: 0,
+ max: 100
+ },
+
+ min: 0,
+
+ _create: function() {
+ this.element
+ .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
+ .attr({
+ role: "progressbar",
+ "aria-valuemin": this.min,
+ "aria-valuemax": this.options.max,
+ "aria-valuenow": this._value()
+ });
+
+ this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
+ .appendTo( this.element );
+
+ this.oldValue = this._value();
+ this._refreshValue();
+ },
+
+ _destroy: function() {
+ this.element
+ .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-valuemin" )
+ .removeAttr( "aria-valuemax" )
+ .removeAttr( "aria-valuenow" );
+
+ this.valueDiv.remove();
+ },
+
+ value: function( newValue ) {
+ if ( newValue === undefined ) {
+ return this._value();
+ }
+
+ this._setOption( "value", newValue );
+ return this;
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "value" ) {
+ this.options.value = value;
+ this._refreshValue();
+ if ( this._value() === this.options.max ) {
+ this._trigger( "complete" );
+ }
+ }
+
+ this._super( key, value );
+ },
+
+ _value: function() {
+ var val = this.options.value;
+ // normalize invalid value
+ if ( typeof val !== "number" ) {
+ val = 0;
+ }
+ return Math.min( this.options.max, Math.max( this.min, val ) );
+ },
+
+ _percentage: function() {
+ return 100 * this._value() / this.options.max;
+ },
+
+ _refreshValue: function() {
+ var value = this.value(),
+ percentage = this._percentage();
+
+ if ( this.oldValue !== value ) {
+ this.oldValue = value;
+ this._trigger( "change" );
+ }
+
+ this.valueDiv
+ .toggle( value > this.min )
+ .toggleClass( "ui-corner-right", value === this.options.max )
+ .width( percentage.toFixed(0) + "%" );
+ this.element.attr( "aria-valuenow", value );
+ }
+});
+
+})( jQuery );
+(function( $, undefined ) {
+
+// number of pages in a slider
+// (how many times can you page up/down to go through the whole range)
+var numPages = 5;
+
+$.widget( "ui.slider", $.ui.mouse, {
+ version: "1.9.2",
+ widgetEventPrefix: "slide",
+
+ options: {
+ animate: false,
+ distance: 0,
+ max: 100,
+ min: 0,
+ orientation: "horizontal",
+ range: false,
+ step: 1,
+ value: 0,
+ values: null
+ },
+
+ _create: function() {
+ var i, handleCount,
+ o = this.options,
+ existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
+ handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
+ handles = [];
+
+ this._keySliding = false;
+ this._mouseSliding = false;
+ this._animateOff = true;
+ this._handleIndex = null;
+ this._detectOrientation();
+ this._mouseInit();
+
+ this.element
+ .addClass( "ui-slider" +
+ " ui-slider-" + this.orientation +
+ " ui-widget" +
+ " ui-widget-content" +
+ " ui-corner-all" +
+ ( o.disabled ? " ui-slider-disabled ui-disabled" : "" ) );
+
+ this.range = $([]);
+
+ if ( o.range ) {
+ if ( o.range === true ) {
+ if ( !o.values ) {
+ o.values = [ this._valueMin(), this._valueMin() ];
+ }
+ if ( o.values.length && o.values.length !== 2 ) {
+ o.values = [ o.values[0], o.values[0] ];
+ }
+ }
+
+ this.range = $( "<div></div>" )
+ .appendTo( this.element )
+ .addClass( "ui-slider-range" +
+ // note: this isn't the most fittingly semantic framework class for this element,
+ // but worked best visually with a variety of themes
+ " ui-widget-header" +
+ ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
+ }
+
+ handleCount = ( o.values && o.values.length ) || 1;
+
+ for ( i = existingHandles.length; i < handleCount; i++ ) {
+ handles.push( handle );
+ }
+
+ this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
+
+ this.handle = this.handles.eq( 0 );
+
+ this.handles.add( this.range ).filter( "a" )
+ .click(function( event ) {
+ event.preventDefault();
+ })
+ .mouseenter(function() {
+ if ( !o.disabled ) {
+ $( this ).addClass( "ui-state-hover" );
+ }
+ })
+ .mouseleave(function() {
+ $( this ).removeClass( "ui-state-hover" );
+ })
+ .focus(function() {
+ if ( !o.disabled ) {
+ $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" );
+ $( this ).addClass( "ui-state-focus" );
+ } else {
+ $( this ).blur();
+ }
+ })
+ .blur(function() {
+ $( this ).removeClass( "ui-state-focus" );
+ });
+
+ this.handles.each(function( i ) {
+ $( this ).data( "ui-slider-handle-index", i );
+ });
+
+ this._on( this.handles, {
+ keydown: function( event ) {
+ var allowed, curVal, newVal, step,
+ index = $( event.target ).data( "ui-slider-handle-index" );
+
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.HOME:
+ case $.ui.keyCode.END:
+ case $.ui.keyCode.PAGE_UP:
+ case $.ui.keyCode.PAGE_DOWN:
+ case $.ui.keyCode.UP:
+ case $.ui.keyCode.RIGHT:
+ case $.ui.keyCode.DOWN:
+ case $.ui.keyCode.LEFT:
+ event.preventDefault();
+ if ( !this._keySliding ) {
+ this._keySliding = true;
+ $( event.target ).addClass( "ui-state-active" );
+ allowed = this._start( event, index );
+ if ( allowed === false ) {
+ return;
+ }
+ }
+ break;
+ }
+
+ step = this.options.step;
+ if ( this.options.values && this.options.values.length ) {
+ curVal = newVal = this.values( index );
+ } else {
+ curVal = newVal = this.value();
+ }
+
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.HOME:
+ newVal = this._valueMin();
+ break;
+ case $.ui.keyCode.END:
+ newVal = this._valueMax();
+ break;
+ case $.ui.keyCode.PAGE_UP:
+ newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
+ break;
+ case $.ui.keyCode.PAGE_DOWN:
+ newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
+ break;
+ case $.ui.keyCode.UP:
+ case $.ui.keyCode.RIGHT:
+ if ( curVal === this._valueMax() ) {
+ return;
+ }
+ newVal = this._trimAlignValue( curVal + step );
+ break;
+ case $.ui.keyCode.DOWN:
+ case $.ui.keyCode.LEFT:
+ if ( curVal === this._valueMin() ) {
+ return;
+ }
+ newVal = this._trimAlignValue( curVal - step );
+ break;
+ }
+
+ this._slide( event, index, newVal );
+ },
+ keyup: function( event ) {
+ var index = $( event.target ).data( "ui-slider-handle-index" );
+
+ if ( this._keySliding ) {
+ this._keySliding = false;
+ this._stop( event, index );
+ this._change( event, index );
+ $( event.target ).removeClass( "ui-state-active" );
+ }
+ }
+ });
+
+ this._refreshValue();
+
+ this._animateOff = false;
+ },
+
+ _destroy: function() {
+ this.handles.remove();
+ this.range.remove();
+
+ this.element
+ .removeClass( "ui-slider" +
+ " ui-slider-horizontal" +
+ " ui-slider-vertical" +
+ " ui-slider-disabled" +
+ " ui-widget" +
+ " ui-widget-content" +
+ " ui-corner-all" );
+
+ this._mouseDestroy();
+ },
+
+ _mouseCapture: function( event ) {
+ var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
+ that = this,
+ o = this.options;
+
+ if ( o.disabled ) {
+ return false;
+ }
+
+ this.elementSize = {
+ width: this.element.outerWidth(),
+ height: this.element.outerHeight()
+ };
+ this.elementOffset = this.element.offset();
+
+ position = { x: event.pageX, y: event.pageY };
+ normValue = this._normValueFromMouse( position );
+ distance = this._valueMax() - this._valueMin() + 1;
+ this.handles.each(function( i ) {
+ var thisDistance = Math.abs( normValue - that.values(i) );
+ if ( distance > thisDistance ) {
+ distance = thisDistance;
+ closestHandle = $( this );
+ index = i;
+ }
+ });
+
+ // workaround for bug #3736 (if both handles of a range are at 0,
+ // the first is always used as the one with least distance,
+ // and moving it is obviously prevented by preventing negative ranges)
+ if( o.range === true && this.values(1) === o.min ) {
+ index += 1;
+ closestHandle = $( this.handles[index] );
+ }
+
+ allowed = this._start( event, index );
+ if ( allowed === false ) {
+ return false;
+ }
+ this._mouseSliding = true;
+
+ this._handleIndex = index;
+
+ closestHandle
+ .addClass( "ui-state-active" )
+ .focus();
+
+ offset = closestHandle.offset();
+ mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" );
+ this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
+ left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
+ top: event.pageY - offset.top -
+ ( closestHandle.height() / 2 ) -
+ ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
+ ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
+ ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
+ };
+
+ if ( !this.handles.hasClass( "ui-state-hover" ) ) {
+ this._slide( event, index, normValue );
+ }
+ this._animateOff = true;
+ return true;
+ },
+
+ _mouseStart: function() {
+ return true;
+ },
+
+ _mouseDrag: function( event ) {
+ var position = { x: event.pageX, y: event.pageY },
+ normValue = this._normValueFromMouse( position );
+
+ this._slide( event, this._handleIndex, normValue );
+
+ return false;
+ },
+
+ _mouseStop: function( event ) {
+ this.handles.removeClass( "ui-state-active" );
+ this._mouseSliding = false;
+
+ this._stop( event, this._handleIndex );
+ this._change( event, this._handleIndex );
+
+ this._handleIndex = null;
+ this._clickOffset = null;
+ this._animateOff = false;
+
+ return false;
+ },
+
+ _detectOrientation: function() {
+ this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
+ },
+
+ _normValueFromMouse: function( position ) {
+ var pixelTotal,
+ pixelMouse,
+ percentMouse,
+ valueTotal,
+ valueMouse;
+
+ if ( this.orientation === "horizontal" ) {
+ pixelTotal = this.elementSize.width;
+ pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
+ } else {
+ pixelTotal = this.elementSize.height;
+ pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
+ }
+
+ percentMouse = ( pixelMouse / pixelTotal );
+ if ( percentMouse > 1 ) {
+ percentMouse = 1;
+ }
+ if ( percentMouse < 0 ) {
+ percentMouse = 0;
+ }
+ if ( this.orientation === "vertical" ) {
+ percentMouse = 1 - percentMouse;
+ }
+
+ valueTotal = this._valueMax() - this._valueMin();
+ valueMouse = this._valueMin() + percentMouse * valueTotal;
+
+ return this._trimAlignValue( valueMouse );
+ },
+
+ _start: function( event, index ) {
+ var uiHash = {
+ handle: this.handles[ index ],
+ value: this.value()
+ };
+ if ( this.options.values && this.options.values.length ) {
+ uiHash.value = this.values( index );
+ uiHash.values = this.values();
+ }
+ return this._trigger( "start", event, uiHash );
+ },
+
+ _slide: function( event, index, newVal ) {
+ var otherVal,
+ newValues,
+ allowed;
+
+ if ( this.options.values && this.options.values.length ) {
+ otherVal = this.values( index ? 0 : 1 );
+
+ if ( ( this.options.values.length === 2 && this.options.range === true ) &&
+ ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
+ ) {
+ newVal = otherVal;
+ }
+
+ if ( newVal !== this.values( index ) ) {
+ newValues = this.values();
+ newValues[ index ] = newVal;
+ // A slide can be canceled by returning false from the slide callback
+ allowed = this._trigger( "slide", event, {
+ handle: this.handles[ index ],
+ value: newVal,
+ values: newValues
+ } );
+ otherVal = this.values( index ? 0 : 1 );
+ if ( allowed !== false ) {
+ this.values( index, newVal, true );
+ }
+ }
+ } else {
+ if ( newVal !== this.value() ) {
+ // A slide can be canceled by returning false from the slide callback
+ allowed = this._trigger( "slide", event, {
+ handle: this.handles[ index ],
+ value: newVal
+ } );
+ if ( allowed !== false ) {
+ this.value( newVal );
+ }
+ }
+ }
+ },
+
+ _stop: function( event, index ) {
+ var uiHash = {
+ handle: this.handles[ index ],
+ value: this.value()
+ };
+ if ( this.options.values && this.options.values.length ) {
+ uiHash.value = this.values( index );
+ uiHash.values = this.values();
+ }
+
+ this._trigger( "stop", event, uiHash );
+ },
+
+ _change: function( event, index ) {
+ if ( !this._keySliding && !this._mouseSliding ) {
+ var uiHash = {
+ handle: this.handles[ index ],
+ value: this.value()
+ };
+ if ( this.options.values && this.options.values.length ) {
+ uiHash.value = this.values( index );
+ uiHash.values = this.values();
+ }
+
+ this._trigger( "change", event, uiHash );
+ }
+ },
+
+ value: function( newValue ) {
+ if ( arguments.length ) {
+ this.options.value = this._trimAlignValue( newValue );
+ this._refreshValue();
+ this._change( null, 0 );
+ return;
+ }
+
+ return this._value();
+ },
+
+ values: function( index, newValue ) {
+ var vals,
+ newValues,
+ i;
+
+ if ( arguments.length > 1 ) {
+ this.options.values[ index ] = this._trimAlignValue( newValue );
+ this._refreshValue();
+ this._change( null, index );
+ return;
+ }
+
+ if ( arguments.length ) {
+ if ( $.isArray( arguments[ 0 ] ) ) {
+ vals = this.options.values;
+ newValues = arguments[ 0 ];
+ for ( i = 0; i < vals.length; i += 1 ) {
+ vals[ i ] = this._trimAlignValue( newValues[ i ] );
+ this._change( null, i );
+ }
+ this._refreshValue();
+ } else {
+ if ( this.options.values && this.options.values.length ) {
+ return this._values( index );
+ } else {
+ return this.value();
+ }
+ }
+ } else {
+ return this._values();
+ }
+ },
+
+ _setOption: function( key, value ) {
+ var i,
+ valsLength = 0;
+
+ if ( $.isArray( this.options.values ) ) {
+ valsLength = this.options.values.length;
+ }
+
+ $.Widget.prototype._setOption.apply( this, arguments );
+
+ switch ( key ) {
+ case "disabled":
+ if ( value ) {
+ this.handles.filter( ".ui-state-focus" ).blur();
+ this.handles.removeClass( "ui-state-hover" );
+ this.handles.prop( "disabled", true );
+ this.element.addClass( "ui-disabled" );
+ } else {
+ this.handles.prop( "disabled", false );
+ this.element.removeClass( "ui-disabled" );
+ }
+ break;
+ case "orientation":
+ this._detectOrientation();
+ this.element
+ .removeClass( "ui-slider-horizontal ui-slider-vertical" )
+ .addClass( "ui-slider-" + this.orientation );
+ this._refreshValue();
+ break;
+ case "value":
+ this._animateOff = true;
+ this._refreshValue();
+ this._change( null, 0 );
+ this._animateOff = false;
+ break;
+ case "values":
+ this._animateOff = true;
+ this._refreshValue();
+ for ( i = 0; i < valsLength; i += 1 ) {
+ this._change( null, i );
+ }
+ this._animateOff = false;
+ break;
+ case "min":
+ case "max":
+ this._animateOff = true;
+ this._refreshValue();
+ this._animateOff = false;
+ break;
+ }
+ },
+
+ //internal value getter
+ // _value() returns value trimmed by min and max, aligned by step
+ _value: function() {
+ var val = this.options.value;
+ val = this._trimAlignValue( val );
+
+ return val;
+ },
+
+ //internal values getter
+ // _values() returns array of values trimmed by min and max, aligned by step
+ // _values( index ) returns single value trimmed by min and max, aligned by step
+ _values: function( index ) {
+ var val,
+ vals,
+ i;
+
+ if ( arguments.length ) {
+ val = this.options.values[ index ];
+ val = this._trimAlignValue( val );
+
+ return val;
+ } else {
+ // .slice() creates a copy of the array
+ // this copy gets trimmed by min and max and then returned
+ vals = this.options.values.slice();
+ for ( i = 0; i < vals.length; i+= 1) {
+ vals[ i ] = this._trimAlignValue( vals[ i ] );
+ }
+
+ return vals;
+ }
+ },
+
+ // returns the step-aligned value that val is closest to, between (inclusive) min and max
+ _trimAlignValue: function( val ) {
+ if ( val <= this._valueMin() ) {
+ return this._valueMin();
+ }
+ if ( val >= this._valueMax() ) {
+ return this._valueMax();
+ }
+ var step = ( this.options.step > 0 ) ? this.options.step : 1,
+ valModStep = (val - this._valueMin()) % step,
+ alignValue = val - valModStep;
+
+ if ( Math.abs(valModStep) * 2 >= step ) {
+ alignValue += ( valModStep > 0 ) ? step : ( -step );
+ }
+
+ // Since JavaScript has problems with large floats, round
+ // the final value to 5 digits after the decimal point (see #4124)
+ return parseFloat( alignValue.toFixed(5) );
+ },
+
+ _valueMin: function() {
+ return this.options.min;
+ },
+
+ _valueMax: function() {
+ return this.options.max;
+ },
+
+ _refreshValue: function() {
+ var lastValPercent, valPercent, value, valueMin, valueMax,
+ oRange = this.options.range,
+ o = this.options,
+ that = this,
+ animate = ( !this._animateOff ) ? o.animate : false,
+ _set = {};
+
+ if ( this.options.values && this.options.values.length ) {
+ this.handles.each(function( i ) {
+ valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
+ _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
+ $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
+ if ( that.options.range === true ) {
+ if ( that.orientation === "horizontal" ) {
+ if ( i === 0 ) {
+ that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
+ }
+ if ( i === 1 ) {
+ that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
+ }
+ } else {
+ if ( i === 0 ) {
+ that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
+ }
+ if ( i === 1 ) {
+ that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
+ }
+ }
+ }
+ lastValPercent = valPercent;
+ });
+ } else {
+ value = this.value();
+ valueMin = this._valueMin();
+ valueMax = this._valueMax();
+ valPercent = ( valueMax !== valueMin ) ?
+ ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
+ 0;
+ _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
+ this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
+
+ if ( oRange === "min" && this.orientation === "horizontal" ) {
+ this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
+ }
+ if ( oRange === "max" && this.orientation === "horizontal" ) {
+ this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
+ }
+ if ( oRange === "min" && this.orientation === "vertical" ) {
+ this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
+ }
+ if ( oRange === "max" && this.orientation === "vertical" ) {
+ this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
+ }
+ }
+ }
+
+});
+
+}(jQuery));
+(function( $ ) {
+
+function modifier( fn ) {
+ return function() {
+ var previous = this.element.val();
+ fn.apply( this, arguments );
+ this._refresh();
+ if ( previous !== this.element.val() ) {
+ this._trigger( "change" );
+ }
+ };
+}
+
+$.widget( "ui.spinner", {
+ version: "1.9.2",
+ defaultElement: "<input>",
+ widgetEventPrefix: "spin",
+ options: {
+ culture: null,
+ icons: {
+ down: "ui-icon-triangle-1-s",
+ up: "ui-icon-triangle-1-n"
+ },
+ incremental: true,
+ max: null,
+ min: null,
+ numberFormat: null,
+ page: 10,
+ step: 1,
+
+ change: null,
+ spin: null,
+ start: null,
+ stop: null
+ },
+
+ _create: function() {
+ // handle string values that need to be parsed
+ this._setOption( "max", this.options.max );
+ this._setOption( "min", this.options.min );
+ this._setOption( "step", this.options.step );
+
+ // format the value, but don't constrain
+ this._value( this.element.val(), true );
+
+ this._draw();
+ this._on( this._events );
+ this._refresh();
+
+ // turning off autocomplete prevents the browser from remembering the
+ // value when navigating through history, so we re-enable autocomplete
+ // if the page is unloaded before the widget is destroyed. #7790
+ this._on( this.window, {
+ beforeunload: function() {
+ this.element.removeAttr( "autocomplete" );
+ }
+ });
+ },
+
+ _getCreateOptions: function() {
+ var options = {},
+ element = this.element;
+
+ $.each( [ "min", "max", "step" ], function( i, option ) {
+ var value = element.attr( option );
+ if ( value !== undefined && value.length ) {
+ options[ option ] = value;
+ }
+ });
+
+ return options;
+ },
+
+ _events: {
+ keydown: function( event ) {
+ if ( this._start( event ) && this._keydown( event ) ) {
+ event.preventDefault();
+ }
+ },
+ keyup: "_stop",
+ focus: function() {
+ this.previous = this.element.val();
+ },
+ blur: function( event ) {
+ if ( this.cancelBlur ) {
+ delete this.cancelBlur;
+ return;
+ }
+
+ this._refresh();
+ if ( this.previous !== this.element.val() ) {
+ this._trigger( "change", event );
+ }
+ },
+ mousewheel: function( event, delta ) {
+ if ( !delta ) {
+ return;
+ }
+ if ( !this.spinning && !this._start( event ) ) {
+ return false;
+ }
+
+ this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
+ clearTimeout( this.mousewheelTimer );
+ this.mousewheelTimer = this._delay(function() {
+ if ( this.spinning ) {
+ this._stop( event );
+ }
+ }, 100 );
+ event.preventDefault();
+ },
+ "mousedown .ui-spinner-button": function( event ) {
+ var previous;
+
+ // We never want the buttons to have focus; whenever the user is
+ // interacting with the spinner, the focus should be on the input.
+ // If the input is focused then this.previous is properly set from
+ // when the input first received focus. If the input is not focused
+ // then we need to set this.previous based on the value before spinning.
+ previous = this.element[0] === this.document[0].activeElement ?
+ this.previous : this.element.val();
+ function checkFocus() {
+ var isActive = this.element[0] === this.document[0].activeElement;
+ if ( !isActive ) {
+ this.element.focus();
+ this.previous = previous;
+ // support: IE
+ // IE sets focus asynchronously, so we need to check if focus
+ // moved off of the input because the user clicked on the button.
+ this._delay(function() {
+ this.previous = previous;
+ });
+ }
+ }
+
+ // ensure focus is on (or stays on) the text field
+ event.preventDefault();
+ checkFocus.call( this );
+
+ // support: IE
+ // IE doesn't prevent moving focus even with event.preventDefault()
+ // so we set a flag to know when we should ignore the blur event
+ // and check (again) if focus moved off of the input.
+ this.cancelBlur = true;
+ this._delay(function() {
+ delete this.cancelBlur;
+ checkFocus.call( this );
+ });
+
+ if ( this._start( event ) === false ) {
+ return;
+ }
+
+ this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
+ },
+ "mouseup .ui-spinner-button": "_stop",
+ "mouseenter .ui-spinner-button": function( event ) {
+ // button will add ui-state-active if mouse was down while mouseleave and kept down
+ if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
+ return;
+ }
+
+ if ( this._start( event ) === false ) {
+ return false;
+ }
+ this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
+ },
+ // TODO: do we really want to consider this a stop?
+ // shouldn't we just stop the repeater and wait until mouseup before
+ // we trigger the stop event?
+ "mouseleave .ui-spinner-button": "_stop"
+ },
+
+ _draw: function() {
+ var uiSpinner = this.uiSpinner = this.element
+ .addClass( "ui-spinner-input" )
+ .attr( "autocomplete", "off" )
+ .wrap( this._uiSpinnerHtml() )
+ .parent()
+ // add buttons
+ .append( this._buttonHtml() );
+
+ this.element.attr( "role", "spinbutton" );
+
+ // button bindings
+ this.buttons = uiSpinner.find( ".ui-spinner-button" )
+ .attr( "tabIndex", -1 )
+ .button()
+ .removeClass( "ui-corner-all" );
+
+ // IE 6 doesn't understand height: 50% for the buttons
+ // unless the wrapper has an explicit height
+ if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
+ uiSpinner.height() > 0 ) {
+ uiSpinner.height( uiSpinner.height() );
+ }
+
+ // disable spinner if element was already disabled
+ if ( this.options.disabled ) {
+ this.disable();
+ }
+ },
+
+ _keydown: function( event ) {
+ var options = this.options,
+ keyCode = $.ui.keyCode;
+
+ switch ( event.keyCode ) {
+ case keyCode.UP:
+ this._repeat( null, 1, event );
+ return true;
+ case keyCode.DOWN:
+ this._repeat( null, -1, event );
+ return true;
+ case keyCode.PAGE_UP:
+ this._repeat( null, options.page, event );
+ return true;
+ case keyCode.PAGE_DOWN:
+ this._repeat( null, -options.page, event );
+ return true;
+ }
+
+ return false;
+ },
+
+ _uiSpinnerHtml: function() {
+ return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
+ },
+
+ _buttonHtml: function() {
+ return "" +
+ "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
+ "<span class='ui-icon " + this.options.icons.up + "'>▲</span>" +
+ "</a>" +
+ "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
+ "<span class='ui-icon " + this.options.icons.down + "'>▼</span>" +
+ "</a>";
+ },
+
+ _start: function( event ) {
+ if ( !this.spinning && this._trigger( "start", event ) === false ) {
+ return false;
+ }
+
+ if ( !this.counter ) {
+ this.counter = 1;
+ }
+ this.spinning = true;
+ return true;
+ },
+
+ _repeat: function( i, steps, event ) {
+ i = i || 500;
+
+ clearTimeout( this.timer );
+ this.timer = this._delay(function() {
+ this._repeat( 40, steps, event );
+ }, i );
+
+ this._spin( steps * this.options.step, event );
+ },
+
+ _spin: function( step, event ) {
+ var value = this.value() || 0;
+
+ if ( !this.counter ) {
+ this.counter = 1;
+ }
+
+ value = this._adjustValue( value + step * this._increment( this.counter ) );
+
+ if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
+ this._value( value );
+ this.counter++;
+ }
+ },
+
+ _increment: function( i ) {
+ var incremental = this.options.incremental;
+
+ if ( incremental ) {
+ return $.isFunction( incremental ) ?
+ incremental( i ) :
+ Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
+ }
+
+ return 1;
+ },
+
+ _precision: function() {
+ var precision = this._precisionOf( this.options.step );
+ if ( this.options.min !== null ) {
+ precision = Math.max( precision, this._precisionOf( this.options.min ) );
+ }
+ return precision;
+ },
+
+ _precisionOf: function( num ) {
+ var str = num.toString(),
+ decimal = str.indexOf( "." );
+ return decimal === -1 ? 0 : str.length - decimal - 1;
+ },
+
+ _adjustValue: function( value ) {
+ var base, aboveMin,
+ options = this.options;
+
+ // make sure we're at a valid step
+ // - find out where we are relative to the base (min or 0)
+ base = options.min !== null ? options.min : 0;
+ aboveMin = value - base;
+ // - round to the nearest step
+ aboveMin = Math.round(aboveMin / options.step) * options.step;
+ // - rounding is based on 0, so adjust back to our base
+ value = base + aboveMin;
+
+ // fix precision from bad JS floating point math
+ value = parseFloat( value.toFixed( this._precision() ) );
+
+ // clamp the value
+ if ( options.max !== null && value > options.max) {
+ return options.max;
+ }
+ if ( options.min !== null && value < options.min ) {
+ return options.min;
+ }
+
+ return value;
+ },
+
+ _stop: function( event ) {
+ if ( !this.spinning ) {
+ return;
+ }
+
+ clearTimeout( this.timer );
+ clearTimeout( this.mousewheelTimer );
+ this.counter = 0;
+ this.spinning = false;
+ this._trigger( "stop", event );
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "culture" || key === "numberFormat" ) {
+ var prevValue = this._parse( this.element.val() );
+ this.options[ key ] = value;
+ this.element.val( this._format( prevValue ) );
+ return;
+ }
+
+ if ( key === "max" || key === "min" || key === "step" ) {
+ if ( typeof value === "string" ) {
+ value = this._parse( value );
+ }
+ }
+
+ this._super( key, value );
+
+ if ( key === "disabled" ) {
+ if ( value ) {
+ this.element.prop( "disabled", true );
+ this.buttons.button( "disable" );
+ } else {
+ this.element.prop( "disabled", false );
+ this.buttons.button( "enable" );
+ }
+ }
+ },
+
+ _setOptions: modifier(function( options ) {
+ this._super( options );
+ this._value( this.element.val() );
+ }),
+
+ _parse: function( val ) {
+ if ( typeof val === "string" && val !== "" ) {
+ val = window.Globalize && this.options.numberFormat ?
+ Globalize.parseFloat( val, 10, this.options.culture ) : +val;
+ }
+ return val === "" || isNaN( val ) ? null : val;
+ },
+
+ _format: function( value ) {
+ if ( value === "" ) {
+ return "";
+ }
+ return window.Globalize && this.options.numberFormat ?
+ Globalize.format( value, this.options.numberFormat, this.options.culture ) :
+ value;
+ },
+
+ _refresh: function() {
+ this.element.attr({
+ "aria-valuemin": this.options.min,
+ "aria-valuemax": this.options.max,
+ // TODO: what should we do with values that can't be parsed?
+ "aria-valuenow": this._parse( this.element.val() )
+ });
+ },
+
+ // update the value without triggering change
+ _value: function( value, allowAny ) {
+ var parsed;
+ if ( value !== "" ) {
+ parsed = this._parse( value );
+ if ( parsed !== null ) {
+ if ( !allowAny ) {
+ parsed = this._adjustValue( parsed );
+ }
+ value = this._format( parsed );
+ }
+ }
+ this.element.val( value );
+ this._refresh();
+ },
+
+ _destroy: function() {
+ this.element
+ .removeClass( "ui-spinner-input" )
+ .prop( "disabled", false )
+ .removeAttr( "autocomplete" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-valuemin" )
+ .removeAttr( "aria-valuemax" )
+ .removeAttr( "aria-valuenow" );
+ this.uiSpinner.replaceWith( this.element );
+ },
+
+ stepUp: modifier(function( steps ) {
+ this._stepUp( steps );
+ }),
+ _stepUp: function( steps ) {
+ this._spin( (steps || 1) * this.options.step );
+ },
+
+ stepDown: modifier(function( steps ) {
+ this._stepDown( steps );
+ }),
+ _stepDown: function( steps ) {
+ this._spin( (steps || 1) * -this.options.step );
+ },
+
+ pageUp: modifier(function( pages ) {
+ this._stepUp( (pages || 1) * this.options.page );
+ }),
+
+ pageDown: modifier(function( pages ) {
+ this._stepDown( (pages || 1) * this.options.page );
+ }),
+
+ value: function( newVal ) {
+ if ( !arguments.length ) {
+ return this._parse( this.element.val() );
+ }
+ modifier( this._value ).call( this, newVal );
+ },
+
+ widget: function() {
+ return this.uiSpinner;
+ }
+});
+
+}( jQuery ) );
+(function( $, undefined ) {
+
+var tabId = 0,
+ rhash = /#.*$/;
+
+function getNextTabId() {
+ return ++tabId;
+}
+
+function isLocal( anchor ) {
+ return anchor.hash.length > 1 &&
+ anchor.href.replace( rhash, "" ) ===
+ location.href.replace( rhash, "" )
+ // support: Safari 5.1
+ // Safari 5.1 doesn't encode spaces in window.location
+ // but it does encode spaces from anchors (#8777)
+ .replace( /\s/g, "%20" );
+}
+
+$.widget( "ui.tabs", {
+ version: "1.9.2",
+ delay: 300,
+ options: {
+ active: null,
+ collapsible: false,
+ event: "click",
+ heightStyle: "content",
+ hide: null,
+ show: null,
+
+ // callbacks
+ activate: null,
+ beforeActivate: null,
+ beforeLoad: null,
+ load: null
+ },
+
+ _create: function() {
+ var that = this,
+ options = this.options,
+ active = options.active,
+ locationHash = location.hash.substring( 1 );
+
+ this.running = false;
+
+ this.element
+ .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
+ .toggleClass( "ui-tabs-collapsible", options.collapsible )
+ // Prevent users from focusing disabled tabs via click
+ .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
+ if ( $( this ).is( ".ui-state-disabled" ) ) {
+ event.preventDefault();
+ }
+ })
+ // support: IE <9
+ // Preventing the default action in mousedown doesn't prevent IE
+ // from focusing the element, so if the anchor gets focused, blur.
+ // We don't have to worry about focusing the previously focused
+ // element since clicking on a non-focusable element should focus
+ // the body anyway.
+ .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
+ if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
+ this.blur();
+ }
+ });
+
+ this._processTabs();
+
+ if ( active === null ) {
+ // check the fragment identifier in the URL
+ if ( locationHash ) {
+ this.tabs.each(function( i, tab ) {
+ if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
+ active = i;
+ return false;
+ }
+ });
+ }
+
+ // check for a tab marked active via a class
+ if ( active === null ) {
+ active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
+ }
+
+ // no active tab, set to false
+ if ( active === null || active === -1 ) {
+ active = this.tabs.length ? 0 : false;
+ }
+ }
+
+ // handle numbers: negative, out of range
+ if ( active !== false ) {
+ active = this.tabs.index( this.tabs.eq( active ) );
+ if ( active === -1 ) {
+ active = options.collapsible ? false : 0;
+ }
+ }
+ options.active = active;
+
+ // don't allow collapsible: false and active: false
+ if ( !options.collapsible && options.active === false && this.anchors.length ) {
+ options.active = 0;
+ }
+
+ // Take disabling tabs via class attribute from HTML
+ // into account and update option properly.
+ if ( $.isArray( options.disabled ) ) {
+ options.disabled = $.unique( options.disabled.concat(
+ $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
+ return that.tabs.index( li );
+ })
+ ) ).sort();
+ }
+
+ // check for length avoids error when initializing empty list
+ if ( this.options.active !== false && this.anchors.length ) {
+ this.active = this._findActive( this.options.active );
+ } else {
+ this.active = $();
+ }
+
+ this._refresh();
+
+ if ( this.active.length ) {
+ this.load( options.active );
+ }
+ },
+
+ _getCreateEventData: function() {
+ return {
+ tab: this.active,
+ panel: !this.active.length ? $() : this._getPanelForTab( this.active )
+ };
+ },
+
+ _tabKeydown: function( event ) {
+ var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
+ selectedIndex = this.tabs.index( focusedTab ),
+ goingForward = true;
+
+ if ( this._handlePageNav( event ) ) {
+ return;
+ }
+
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.RIGHT:
+ case $.ui.keyCode.DOWN:
+ selectedIndex++;
+ break;
+ case $.ui.keyCode.UP:
+ case $.ui.keyCode.LEFT:
+ goingForward = false;
+ selectedIndex--;
+ break;
+ case $.ui.keyCode.END:
+ selectedIndex = this.anchors.length - 1;
+ break;
+ case $.ui.keyCode.HOME:
+ selectedIndex = 0;
+ break;
+ case $.ui.keyCode.SPACE:
+ // Activate only, no collapsing
+ event.preventDefault();
+ clearTimeout( this.activating );
+ this._activate( selectedIndex );
+ return;
+ case $.ui.keyCode.ENTER:
+ // Toggle (cancel delayed activation, allow collapsing)
+ event.preventDefault();
+ clearTimeout( this.activating );
+ // Determine if we should collapse or activate
+ this._activate( selectedIndex === this.options.active ? false : selectedIndex );
+ return;
+ default:
+ return;
+ }
+
+ // Focus the appropriate tab, based on which key was pressed
+ event.preventDefault();
+ clearTimeout( this.activating );
+ selectedIndex = this._focusNextTab( selectedIndex, goingForward );
+
+ // Navigating with control key will prevent automatic activation
+ if ( !event.ctrlKey ) {
+ // Update aria-selected immediately so that AT think the tab is already selected.
+ // Otherwise AT may confuse the user by stating that they need to activate the tab,
+ // but the tab will already be activated by the time the announcement finishes.
+ focusedTab.attr( "aria-selected", "false" );
+ this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
+
+ this.activating = this._delay(function() {
+ this.option( "active", selectedIndex );
+ }, this.delay );
+ }
+ },
+
+ _panelKeydown: function( event ) {
+ if ( this._handlePageNav( event ) ) {
+ return;
+ }
+
+ // Ctrl+up moves focus to the current tab
+ if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
+ event.preventDefault();
+ this.active.focus();
+ }
+ },
+
+ // Alt+page up/down moves focus to the previous/next tab (and activates)
+ _handlePageNav: function( event ) {
+ if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
+ this._activate( this._focusNextTab( this.options.active - 1, false ) );
+ return true;
+ }
+ if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
+ this._activate( this._focusNextTab( this.options.active + 1, true ) );
+ return true;
+ }
+ },
+
+ _findNextTab: function( index, goingForward ) {
+ var lastTabIndex = this.tabs.length - 1;
+
+ function constrain() {
+ if ( index > lastTabIndex ) {
+ index = 0;
+ }
+ if ( index < 0 ) {
+ index = lastTabIndex;
+ }
+ return index;
+ }
+
+ while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
+ index = goingForward ? index + 1 : index - 1;
+ }
+
+ return index;
+ },
+
+ _focusNextTab: function( index, goingForward ) {
+ index = this._findNextTab( index, goingForward );
+ this.tabs.eq( index ).focus();
+ return index;
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "active" ) {
+ // _activate() will handle invalid values and update this.options
+ this._activate( value );
+ return;
+ }
+
+ if ( key === "disabled" ) {
+ // don't use the widget factory's disabled handling
+ this._setupDisabled( value );
+ return;
+ }
+
+ this._super( key, value);
+
+ if ( key === "collapsible" ) {
+ this.element.toggleClass( "ui-tabs-collapsible", value );
+ // Setting collapsible: false while collapsed; open first panel
+ if ( !value && this.options.active === false ) {
+ this._activate( 0 );
+ }
+ }
+
+ if ( key === "event" ) {
+ this._setupEvents( value );
+ }
+
+ if ( key === "heightStyle" ) {
+ this._setupHeightStyle( value );
+ }
+ },
+
+ _tabId: function( tab ) {
+ return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
+ },
+
+ _sanitizeSelector: function( hash ) {
+ return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
+ },
+
+ refresh: function() {
+ var options = this.options,
+ lis = this.tablist.children( ":has(a[href])" );
+
+ // get disabled tabs from class attribute from HTML
+ // this will get converted to a boolean if needed in _refresh()
+ options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
+ return lis.index( tab );
+ });
+
+ this._processTabs();
+
+ // was collapsed or no tabs
+ if ( options.active === false || !this.anchors.length ) {
+ options.active = false;
+ this.active = $();
+ // was active, but active tab is gone
+ } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
+ // all remaining tabs are disabled
+ if ( this.tabs.length === options.disabled.length ) {
+ options.active = false;
+ this.active = $();
+ // activate previous tab
+ } else {
+ this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
+ }
+ // was active, active tab still exists
+ } else {
+ // make sure active index is correct
+ options.active = this.tabs.index( this.active );
+ }
+
+ this._refresh();
+ },
+
+ _refresh: function() {
+ this._setupDisabled( this.options.disabled );
+ this._setupEvents( this.options.event );
+ this._setupHeightStyle( this.options.heightStyle );
+
+ this.tabs.not( this.active ).attr({
+ "aria-selected": "false",
+ tabIndex: -1
+ });
+ this.panels.not( this._getPanelForTab( this.active ) )
+ .hide()
+ .attr({
+ "aria-expanded": "false",
+ "aria-hidden": "true"
+ });
+
+ // Make sure one tab is in the tab order
+ if ( !this.active.length ) {
+ this.tabs.eq( 0 ).attr( "tabIndex", 0 );
+ } else {
+ this.active
+ .addClass( "ui-tabs-active ui-state-active" )
+ .attr({
+ "aria-selected": "true",
+ tabIndex: 0
+ });
+ this._getPanelForTab( this.active )
+ .show()
+ .attr({
+ "aria-expanded": "true",
+ "aria-hidden": "false"
+ });
+ }
+ },
+
+ _processTabs: function() {
+ var that = this;
+
+ this.tablist = this._getList()
+ .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
+ .attr( "role", "tablist" );
+
+ this.tabs = this.tablist.find( "> li:has(a[href])" )
+ .addClass( "ui-state-default ui-corner-top" )
+ .attr({
+ role: "tab",
+ tabIndex: -1
+ });
+
+ this.anchors = this.tabs.map(function() {
+ return $( "a", this )[ 0 ];
+ })
+ .addClass( "ui-tabs-anchor" )
+ .attr({
+ role: "presentation",
+ tabIndex: -1
+ });
+
+ this.panels = $();
+
+ this.anchors.each(function( i, anchor ) {
+ var selector, panel, panelId,
+ anchorId = $( anchor ).uniqueId().attr( "id" ),
+ tab = $( anchor ).closest( "li" ),
+ originalAriaControls = tab.attr( "aria-controls" );
+
+ // inline tab
+ if ( isLocal( anchor ) ) {
+ selector = anchor.hash;
+ panel = that.element.find( that._sanitizeSelector( selector ) );
+ // remote tab
+ } else {
+ panelId = that._tabId( tab );
+ selector = "#" + panelId;
+ panel = that.element.find( selector );
+ if ( !panel.length ) {
+ panel = that._createPanel( panelId );
+ panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
+ }
+ panel.attr( "aria-live", "polite" );
+ }
+
+ if ( panel.length) {
+ that.panels = that.panels.add( panel );
+ }
+ if ( originalAriaControls ) {
+ tab.data( "ui-tabs-aria-controls", originalAriaControls );
+ }
+ tab.attr({
+ "aria-controls": selector.substring( 1 ),
+ "aria-labelledby": anchorId
+ });
+ panel.attr( "aria-labelledby", anchorId );
+ });
+
+ this.panels
+ .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
+ .attr( "role", "tabpanel" );
+ },
+
+ // allow overriding how to find the list for rare usage scenarios (#7715)
+ _getList: function() {
+ return this.element.find( "ol,ul" ).eq( 0 );
+ },
+
+ _createPanel: function( id ) {
+ return $( "<div>" )
+ .attr( "id", id )
+ .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
+ .data( "ui-tabs-destroy", true );
+ },
+
+ _setupDisabled: function( disabled ) {
+ if ( $.isArray( disabled ) ) {
+ if ( !disabled.length ) {
+ disabled = false;
+ } else if ( disabled.length === this.anchors.length ) {
+ disabled = true;
+ }
+ }
+
+ // disable tabs
+ for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
+ if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
+ $( li )
+ .addClass( "ui-state-disabled" )
+ .attr( "aria-disabled", "true" );
+ } else {
+ $( li )
+ .removeClass( "ui-state-disabled" )
+ .removeAttr( "aria-disabled" );
+ }
+ }
+
+ this.options.disabled = disabled;
+ },
+
+ _setupEvents: function( event ) {
+ var events = {
+ click: function( event ) {
+ event.preventDefault();
+ }
+ };
+ if ( event ) {
+ $.each( event.split(" "), function( index, eventName ) {
+ events[ eventName ] = "_eventHandler";
+ });
+ }
+
+ this._off( this.anchors.add( this.tabs ).add( this.panels ) );
+ this._on( this.anchors, events );
+ this._on( this.tabs, { keydown: "_tabKeydown" } );
+ this._on( this.panels, { keydown: "_panelKeydown" } );
+
+ this._focusable( this.tabs );
+ this._hoverable( this.tabs );
+ },
+
+ _setupHeightStyle: function( heightStyle ) {
+ var maxHeight, overflow,
+ parent = this.element.parent();
+
+ if ( heightStyle === "fill" ) {
+ // IE 6 treats height like minHeight, so we need to turn off overflow
+ // in order to get a reliable height
+ // we use the minHeight support test because we assume that only
+ // browsers that don't support minHeight will treat height as minHeight
+ if ( !$.support.minHeight ) {
+ overflow = parent.css( "overflow" );
+ parent.css( "overflow", "hidden");
+ }
+ maxHeight = parent.height();
+ this.element.siblings( ":visible" ).each(function() {
+ var elem = $( this ),
+ position = elem.css( "position" );
+
+ if ( position === "absolute" || position === "fixed" ) {
+ return;
+ }
+ maxHeight -= elem.outerHeight( true );
+ });
+ if ( overflow ) {
+ parent.css( "overflow", overflow );
+ }
+
+ this.element.children().not( this.panels ).each(function() {
+ maxHeight -= $( this ).outerHeight( true );
+ });
+
+ this.panels.each(function() {
+ $( this ).height( Math.max( 0, maxHeight -
+ $( this ).innerHeight() + $( this ).height() ) );
+ })
+ .css( "overflow", "auto" );
+ } else if ( heightStyle === "auto" ) {
+ maxHeight = 0;
+ this.panels.each(function() {
+ maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
+ }).height( maxHeight );
+ }
+ },
+
+ _eventHandler: function( event ) {
+ var options = this.options,
+ active = this.active,
+ anchor = $( event.currentTarget ),
+ tab = anchor.closest( "li" ),
+ clickedIsActive = tab[ 0 ] === active[ 0 ],
+ collapsing = clickedIsActive && options.collapsible,
+ toShow = collapsing ? $() : this._getPanelForTab( tab ),
+ toHide = !active.length ? $() : this._getPanelForTab( active ),
+ eventData = {
+ oldTab: active,
+ oldPanel: toHide,
+ newTab: collapsing ? $() : tab,
+ newPanel: toShow
+ };
+
+ event.preventDefault();
+
+ if ( tab.hasClass( "ui-state-disabled" ) ||
+ // tab is already loading
+ tab.hasClass( "ui-tabs-loading" ) ||
+ // can't switch durning an animation
+ this.running ||
+ // click on active header, but not collapsible
+ ( clickedIsActive && !options.collapsible ) ||
+ // allow canceling activation
+ ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
+ return;
+ }
+
+ options.active = collapsing ? false : this.tabs.index( tab );
+
+ this.active = clickedIsActive ? $() : tab;
+ if ( this.xhr ) {
+ this.xhr.abort();
+ }
+
+ if ( !toHide.length && !toShow.length ) {
+ $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
+ }
+
+ if ( toShow.length ) {
+ this.load( this.tabs.index( tab ), event );
+ }
+ this._toggle( event, eventData );
+ },
+
+ // handles show/hide for selecting tabs
+ _toggle: function( event, eventData ) {
+ var that = this,
+ toShow = eventData.newPanel,
+ toHide = eventData.oldPanel;
+
+ this.running = true;
+
+ function complete() {
+ that.running = false;
+ that._trigger( "activate", event, eventData );
+ }
+
+ function show() {
+ eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
+
+ if ( toShow.length && that.options.show ) {
+ that._show( toShow, that.options.show, complete );
+ } else {
+ toShow.show();
+ complete();
+ }
+ }
+
+ // start out by hiding, then showing, then completing
+ if ( toHide.length && this.options.hide ) {
+ this._hide( toHide, this.options.hide, function() {
+ eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
+ show();
+ });
+ } else {
+ eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
+ toHide.hide();
+ show();
+ }
+
+ toHide.attr({
+ "aria-expanded": "false",
+ "aria-hidden": "true"
+ });
+ eventData.oldTab.attr( "aria-selected", "false" );
+ // If we're switching tabs, remove the old tab from the tab order.
+ // If we're opening from collapsed state, remove the previous tab from the tab order.
+ // If we're collapsing, then keep the collapsing tab in the tab order.
+ if ( toShow.length && toHide.length ) {
+ eventData.oldTab.attr( "tabIndex", -1 );
+ } else if ( toShow.length ) {
+ this.tabs.filter(function() {
+ return $( this ).attr( "tabIndex" ) === 0;
+ })
+ .attr( "tabIndex", -1 );
+ }
+
+ toShow.attr({
+ "aria-expanded": "true",
+ "aria-hidden": "false"
+ });
+ eventData.newTab.attr({
+ "aria-selected": "true",
+ tabIndex: 0
+ });
+ },
+
+ _activate: function( index ) {
+ var anchor,
+ active = this._findActive( index );
+
+ // trying to activate the already active panel
+ if ( active[ 0 ] === this.active[ 0 ] ) {
+ return;
+ }
+
+ // trying to collapse, simulate a click on the current active header
+ if ( !active.length ) {
+ active = this.active;
+ }
+
+ anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
+ this._eventHandler({
+ target: anchor,
+ currentTarget: anchor,
+ preventDefault: $.noop
+ });
+ },
+
+ _findActive: function( index ) {
+ return index === false ? $() : this.tabs.eq( index );
+ },
+
+ _getIndex: function( index ) {
+ // meta-function to give users option to provide a href string instead of a numerical index.
+ if ( typeof index === "string" ) {
+ index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
+ }
+
+ return index;
+ },
+
+ _destroy: function() {
+ if ( this.xhr ) {
+ this.xhr.abort();
+ }
+
+ this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
+
+ this.tablist
+ .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
+ .removeAttr( "role" );
+
+ this.anchors
+ .removeClass( "ui-tabs-anchor" )
+ .removeAttr( "role" )
+ .removeAttr( "tabIndex" )
+ .removeData( "href.tabs" )
+ .removeData( "load.tabs" )
+ .removeUniqueId();
+
+ this.tabs.add( this.panels ).each(function() {
+ if ( $.data( this, "ui-tabs-destroy" ) ) {
+ $( this ).remove();
+ } else {
+ $( this )
+ .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
+ "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
+ .removeAttr( "tabIndex" )
+ .removeAttr( "aria-live" )
+ .removeAttr( "aria-busy" )
+ .removeAttr( "aria-selected" )
+ .removeAttr( "aria-labelledby" )
+ .removeAttr( "aria-hidden" )
+ .removeAttr( "aria-expanded" )
+ .removeAttr( "role" );
+ }
+ });
+
+ this.tabs.each(function() {
+ var li = $( this ),
+ prev = li.data( "ui-tabs-aria-controls" );
+ if ( prev ) {
+ li.attr( "aria-controls", prev );
+ } else {
+ li.removeAttr( "aria-controls" );
+ }
+ });
+
+ this.panels.show();
+
+ if ( this.options.heightStyle !== "content" ) {
+ this.panels.css( "height", "" );
+ }
+ },
+
+ enable: function( index ) {
+ var disabled = this.options.disabled;
+ if ( disabled === false ) {
+ return;
+ }
+
+ if ( index === undefined ) {
+ disabled = false;
+ } else {
+ index = this._getIndex( index );
+ if ( $.isArray( disabled ) ) {
+ disabled = $.map( disabled, function( num ) {
+ return num !== index ? num : null;
+ });
+ } else {
+ disabled = $.map( this.tabs, function( li, num ) {
+ return num !== index ? num : null;
+ });
+ }
+ }
+ this._setupDisabled( disabled );
+ },
+
+ disable: function( index ) {
+ var disabled = this.options.disabled;
+ if ( disabled === true ) {
+ return;
+ }
+
+ if ( index === undefined ) {
+ disabled = true;
+ } else {
+ index = this._getIndex( index );
+ if ( $.inArray( index, disabled ) !== -1 ) {
+ return;
+ }
+ if ( $.isArray( disabled ) ) {
+ disabled = $.merge( [ index ], disabled ).sort();
+ } else {
+ disabled = [ index ];
+ }
+ }
+ this._setupDisabled( disabled );
+ },
+
+ load: function( index, event ) {
+ index = this._getIndex( index );
+ var that = this,
+ tab = this.tabs.eq( index ),
+ anchor = tab.find( ".ui-tabs-anchor" ),
+ panel = this._getPanelForTab( tab ),
+ eventData = {
+ tab: tab,
+ panel: panel
+ };
+
+ // not remote
+ if ( isLocal( anchor[ 0 ] ) ) {
+ return;
+ }
+
+ this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
+
+ // support: jQuery <1.8
+ // jQuery <1.8 returns false if the request is canceled in beforeSend,
+ // but as of 1.8, $.ajax() always returns a jqXHR object.
+ if ( this.xhr && this.xhr.statusText !== "canceled" ) {
+ tab.addClass( "ui-tabs-loading" );
+ panel.attr( "aria-busy", "true" );
+
+ this.xhr
+ .success(function( response ) {
+ // support: jQuery <1.8
+ // http://bugs.jquery.com/ticket/11778
+ setTimeout(function() {
+ panel.html( response );
+ that._trigger( "load", event, eventData );
+ }, 1 );
+ })
+ .complete(function( jqXHR, status ) {
+ // support: jQuery <1.8
+ // http://bugs.jquery.com/ticket/11778
+ setTimeout(function() {
+ if ( status === "abort" ) {
+ that.panels.stop( false, true );
+ }
+
+ tab.removeClass( "ui-tabs-loading" );
+ panel.removeAttr( "aria-busy" );
+
+ if ( jqXHR === that.xhr ) {
+ delete that.xhr;
+ }
+ }, 1 );
+ });
+ }
+ },
+
+ // TODO: Remove this function in 1.10 when ajaxOptions is removed
+ _ajaxSettings: function( anchor, event, eventData ) {
+ var that = this;
+ return {
+ url: anchor.attr( "href" ),
+ beforeSend: function( jqXHR, settings ) {
+ return that._trigger( "beforeLoad", event,
+ $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
+ }
+ };
+ },
+
+ _getPanelForTab: function( tab ) {
+ var id = $( tab ).attr( "aria-controls" );
+ return this.element.find( this._sanitizeSelector( "#" + id ) );
+ }
+});
+
+// DEPRECATED
+if ( $.uiBackCompat !== false ) {
+
+ // helper method for a lot of the back compat extensions
+ $.ui.tabs.prototype._ui = function( tab, panel ) {
+ return {
+ tab: tab,
+ panel: panel,
+ index: this.anchors.index( tab )
+ };
+ };
+
+ // url method
+ $.widget( "ui.tabs", $.ui.tabs, {
+ url: function( index, url ) {
+ this.anchors.eq( index ).attr( "href", url );
+ }
+ });
+
+ // TODO: Remove _ajaxSettings() method when removing this extension
+ // ajaxOptions and cache options
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ ajaxOptions: null,
+ cache: false
+ },
+
+ _create: function() {
+ this._super();
+
+ var that = this;
+
+ this._on({ tabsbeforeload: function( event, ui ) {
+ // tab is already cached
+ if ( $.data( ui.tab[ 0 ], "cache.tabs" ) ) {
+ event.preventDefault();
+ return;
+ }
+
+ ui.jqXHR.success(function() {
+ if ( that.options.cache ) {
+ $.data( ui.tab[ 0 ], "cache.tabs", true );
+ }
+ });
+ }});
+ },
+
+ _ajaxSettings: function( anchor, event, ui ) {
+ var ajaxOptions = this.options.ajaxOptions;
+ return $.extend( {}, ajaxOptions, {
+ error: function( xhr, status ) {
+ try {
+ // Passing index avoid a race condition when this method is
+ // called after the user has selected another tab.
+ // Pass the anchor that initiated this request allows
+ // loadError to manipulate the tab content panel via $(a.hash)
+ ajaxOptions.error(
+ xhr, status, ui.tab.closest( "li" ).index(), ui.tab[ 0 ] );
+ }
+ catch ( error ) {}
+ }
+ }, this._superApply( arguments ) );
+ },
+
+ _setOption: function( key, value ) {
+ // reset cache if switching from cached to not cached
+ if ( key === "cache" && value === false ) {
+ this.anchors.removeData( "cache.tabs" );
+ }
+ this._super( key, value );
+ },
+
+ _destroy: function() {
+ this.anchors.removeData( "cache.tabs" );
+ this._super();
+ },
+
+ url: function( index ){
+ this.anchors.eq( index ).removeData( "cache.tabs" );
+ this._superApply( arguments );
+ }
+ });
+
+ // abort method
+ $.widget( "ui.tabs", $.ui.tabs, {
+ abort: function() {
+ if ( this.xhr ) {
+ this.xhr.abort();
+ }
+ }
+ });
+
+ // spinner
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ spinner: "<em>Loading…</em>"
+ },
+ _create: function() {
+ this._super();
+ this._on({
+ tabsbeforeload: function( event, ui ) {
+ // Don't react to nested tabs or tabs that don't use a spinner
+ if ( event.target !== this.element[ 0 ] ||
+ !this.options.spinner ) {
+ return;
+ }
+
+ var span = ui.tab.find( "span" ),
+ html = span.html();
+ span.html( this.options.spinner );
+ ui.jqXHR.complete(function() {
+ span.html( html );
+ });
+ }
+ });
+ }
+ });
+
+ // enable/disable events
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ enable: null,
+ disable: null
+ },
+
+ enable: function( index ) {
+ var options = this.options,
+ trigger;
+
+ if ( index && options.disabled === true ||
+ ( $.isArray( options.disabled ) && $.inArray( index, options.disabled ) !== -1 ) ) {
+ trigger = true;
+ }
+
+ this._superApply( arguments );
+
+ if ( trigger ) {
+ this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
+ }
+ },
+
+ disable: function( index ) {
+ var options = this.options,
+ trigger;
+
+ if ( index && options.disabled === false ||
+ ( $.isArray( options.disabled ) && $.inArray( index, options.disabled ) === -1 ) ) {
+ trigger = true;
+ }
+
+ this._superApply( arguments );
+
+ if ( trigger ) {
+ this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
+ }
+ }
+ });
+
+ // add/remove methods and events
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ add: null,
+ remove: null,
+ tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
+ },
+
+ add: function( url, label, index ) {
+ if ( index === undefined ) {
+ index = this.anchors.length;
+ }
+
+ var doInsertAfter, panel,
+ options = this.options,
+ li = $( options.tabTemplate
+ .replace( /#\{href\}/g, url )
+ .replace( /#\{label\}/g, label ) ),
+ id = !url.indexOf( "#" ) ?
+ url.replace( "#", "" ) :
+ this._tabId( li );
+
+ li.addClass( "ui-state-default ui-corner-top" ).data( "ui-tabs-destroy", true );
+ li.attr( "aria-controls", id );
+
+ doInsertAfter = index >= this.tabs.length;
+
+ // try to find an existing element before creating a new one
+ panel = this.element.find( "#" + id );
+ if ( !panel.length ) {
+ panel = this._createPanel( id );
+ if ( doInsertAfter ) {
+ if ( index > 0 ) {
+ panel.insertAfter( this.panels.eq( -1 ) );
+ } else {
+ panel.appendTo( this.element );
+ }
+ } else {
+ panel.insertBefore( this.panels[ index ] );
+ }
+ }
+ panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ).hide();
+
+ if ( doInsertAfter ) {
+ li.appendTo( this.tablist );
+ } else {
+ li.insertBefore( this.tabs[ index ] );
+ }
+
+ options.disabled = $.map( options.disabled, function( n ) {
+ return n >= index ? ++n : n;
+ });
+
+ this.refresh();
+ if ( this.tabs.length === 1 && options.active === false ) {
+ this.option( "active", 0 );
+ }
+
+ this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
+ return this;
+ },
+
+ remove: function( index ) {
+ index = this._getIndex( index );
+ var options = this.options,
+ tab = this.tabs.eq( index ).remove(),
+ panel = this._getPanelForTab( tab ).remove();
+
+ // If selected tab was removed focus tab to the right or
+ // in case the last tab was removed the tab to the left.
+ // We check for more than 2 tabs, because if there are only 2,
+ // then when we remove this tab, there will only be one tab left
+ // so we don't need to detect which tab to activate.
+ if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 2 ) {
+ this._activate( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
+ }
+
+ options.disabled = $.map(
+ $.grep( options.disabled, function( n ) {
+ return n !== index;
+ }),
+ function( n ) {
+ return n >= index ? --n : n;
+ });
+
+ this.refresh();
+
+ this._trigger( "remove", null, this._ui( tab.find( "a" )[ 0 ], panel[ 0 ] ) );
+ return this;
+ }
+ });
+
+ // length method
+ $.widget( "ui.tabs", $.ui.tabs, {
+ length: function() {
+ return this.anchors.length;
+ }
+ });
+
+ // panel ids (idPrefix option + title attribute)
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ idPrefix: "ui-tabs-"
+ },
+
+ _tabId: function( tab ) {
+ var a = tab.is( "li" ) ? tab.find( "a[href]" ) : tab;
+ a = a[0];
+ return $( a ).closest( "li" ).attr( "aria-controls" ) ||
+ a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF\-]/g, "" ) ||
+ this.options.idPrefix + getNextTabId();
+ }
+ });
+
+ // _createPanel method
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ panelTemplate: "<div></div>"
+ },
+
+ _createPanel: function( id ) {
+ return $( this.options.panelTemplate )
+ .attr( "id", id )
+ .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
+ .data( "ui-tabs-destroy", true );
+ }
+ });
+
+ // selected option
+ $.widget( "ui.tabs", $.ui.tabs, {
+ _create: function() {
+ var options = this.options;
+ if ( options.active === null && options.selected !== undefined ) {
+ options.active = options.selected === -1 ? false : options.selected;
+ }
+ this._super();
+ options.selected = options.active;
+ if ( options.selected === false ) {
+ options.selected = -1;
+ }
+ },
+
+ _setOption: function( key, value ) {
+ if ( key !== "selected" ) {
+ return this._super( key, value );
+ }
+
+ var options = this.options;
+ this._super( "active", value === -1 ? false : value );
+ options.selected = options.active;
+ if ( options.selected === false ) {
+ options.selected = -1;
+ }
+ },
+
+ _eventHandler: function() {
+ this._superApply( arguments );
+ this.options.selected = this.options.active;
+ if ( this.options.selected === false ) {
+ this.options.selected = -1;
+ }
+ }
+ });
+
+ // show and select event
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ show: null,
+ select: null
+ },
+ _create: function() {
+ this._super();
+ if ( this.options.active !== false ) {
+ this._trigger( "show", null, this._ui(
+ this.active.find( ".ui-tabs-anchor" )[ 0 ],
+ this._getPanelForTab( this.active )[ 0 ] ) );
+ }
+ },
+ _trigger: function( type, event, data ) {
+ var tab, panel,
+ ret = this._superApply( arguments );
+
+ if ( !ret ) {
+ return false;
+ }
+
+ if ( type === "beforeActivate" ) {
+ tab = data.newTab.length ? data.newTab : data.oldTab;
+ panel = data.newPanel.length ? data.newPanel : data.oldPanel;
+ ret = this._super( "select", event, {
+ tab: tab.find( ".ui-tabs-anchor" )[ 0],
+ panel: panel[ 0 ],
+ index: tab.closest( "li" ).index()
+ });
+ } else if ( type === "activate" && data.newTab.length ) {
+ ret = this._super( "show", event, {
+ tab: data.newTab.find( ".ui-tabs-anchor" )[ 0 ],
+ panel: data.newPanel[ 0 ],
+ index: data.newTab.closest( "li" ).index()
+ });
+ }
+ return ret;
+ }
+ });
+
+ // select method
+ $.widget( "ui.tabs", $.ui.tabs, {
+ select: function( index ) {
+ index = this._getIndex( index );
+ if ( index === -1 ) {
+ if ( this.options.collapsible && this.options.selected !== -1 ) {
+ index = this.options.selected;
+ } else {
+ return;
+ }
+ }
+ this.anchors.eq( index ).trigger( this.options.event + this.eventNamespace );
+ }
+ });
+
+ // cookie option
+ (function() {
+
+ var listId = 0;
+
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ cookie: null // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
+ },
+ _create: function() {
+ var options = this.options,
+ active;
+ if ( options.active == null && options.cookie ) {
+ active = parseInt( this._cookie(), 10 );
+ if ( active === -1 ) {
+ active = false;
+ }
+ options.active = active;
+ }
+ this._super();
+ },
+ _cookie: function( active ) {
+ var cookie = [ this.cookie ||
+ ( this.cookie = this.options.cookie.name || "ui-tabs-" + (++listId) ) ];
+ if ( arguments.length ) {
+ cookie.push( active === false ? -1 : active );
+ cookie.push( this.options.cookie );
+ }
+ return $.cookie.apply( null, cookie );
+ },
+ _refresh: function() {
+ this._super();
+ if ( this.options.cookie ) {
+ this._cookie( this.options.active, this.options.cookie );
+ }
+ },
+ _eventHandler: function() {
+ this._superApply( arguments );
+ if ( this.options.cookie ) {
+ this._cookie( this.options.active, this.options.cookie );
+ }
+ },
+ _destroy: function() {
+ this._super();
+ if ( this.options.cookie ) {
+ this._cookie( null, this.options.cookie );
+ }
+ }
+ });
+
+ })();
+
+ // load event
+ $.widget( "ui.tabs", $.ui.tabs, {
+ _trigger: function( type, event, data ) {
+ var _data = $.extend( {}, data );
+ if ( type === "load" ) {
+ _data.panel = _data.panel[ 0 ];
+ _data.tab = _data.tab.find( ".ui-tabs-anchor" )[ 0 ];
+ }
+ return this._super( type, event, _data );
+ }
+ });
+
+ // fx option
+ // The new animation options (show, hide) conflict with the old show callback.
+ // The old fx option wins over show/hide anyway (always favor back-compat).
+ // If a user wants to use the new animation API, they must give up the old API.
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ fx: null // e.g. { height: "toggle", opacity: "toggle", duration: 200 }
+ },
+
+ _getFx: function() {
+ var hide, show,
+ fx = this.options.fx;
+
+ if ( fx ) {
+ if ( $.isArray( fx ) ) {
+ hide = fx[ 0 ];
+ show = fx[ 1 ];
+ } else {
+ hide = show = fx;
+ }
+ }
+
+ return fx ? { show: show, hide: hide } : null;
+ },
+
+ _toggle: function( event, eventData ) {
+ var that = this,
+ toShow = eventData.newPanel,
+ toHide = eventData.oldPanel,
+ fx = this._getFx();
+
+ if ( !fx ) {
+ return this._super( event, eventData );
+ }
+
+ that.running = true;
+
+ function complete() {
+ that.running = false;
+ that._trigger( "activate", event, eventData );
+ }
+
+ function show() {
+ eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
+
+ if ( toShow.length && fx.show ) {
+ toShow
+ .animate( fx.show, fx.show.duration, function() {
+ complete();
+ });
+ } else {
+ toShow.show();
+ complete();
+ }
+ }
+
+ // start out by hiding, then showing, then completing
+ if ( toHide.length && fx.hide ) {
+ toHide.animate( fx.hide, fx.hide.duration, function() {
+ eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
+ show();
+ });
+ } else {
+ eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
+ toHide.hide();
+ show();
+ }
+ }
+ });
+}
+
+})( jQuery );
+(function( $ ) {
+
+var increments = 0;
+
+function addDescribedBy( elem, id ) {
+ var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
+ describedby.push( id );
+ elem
+ .data( "ui-tooltip-id", id )
+ .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
+}
+
+function removeDescribedBy( elem ) {
+ var id = elem.data( "ui-tooltip-id" ),
+ describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
+ index = $.inArray( id, describedby );
+ if ( index !== -1 ) {
+ describedby.splice( index, 1 );
+ }
+
+ elem.removeData( "ui-tooltip-id" );
+ describedby = $.trim( describedby.join( " " ) );
+ if ( describedby ) {
+ elem.attr( "aria-describedby", describedby );
+ } else {
+ elem.removeAttr( "aria-describedby" );
+ }
+}
+
+$.widget( "ui.tooltip", {
+ version: "1.9.2",
+ options: {
+ content: function() {
+ return $( this ).attr( "title" );
+ },
+ hide: true,
+ // Disabled elements have inconsistent behavior across browsers (#8661)
+ items: "[title]:not([disabled])",
+ position: {
+ my: "left top+15",
+ at: "left bottom",
+ collision: "flipfit flip"
+ },
+ show: true,
+ tooltipClass: null,
+ track: false,
+
+ // callbacks
+ close: null,
+ open: null
+ },
+
+ _create: function() {
+ this._on({
+ mouseover: "open",
+ focusin: "open"
+ });
+
+ // IDs of generated tooltips, needed for destroy
+ this.tooltips = {};
+ // IDs of parent tooltips where we removed the title attribute
+ this.parents = {};
+
+ if ( this.options.disabled ) {
+ this._disable();
+ }
+ },
+
+ _setOption: function( key, value ) {
+ var that = this;
+
+ if ( key === "disabled" ) {
+ this[ value ? "_disable" : "_enable" ]();
+ this.options[ key ] = value;
+ // disable element style changes
+ return;
+ }
+
+ this._super( key, value );
+
+ if ( key === "content" ) {
+ $.each( this.tooltips, function( id, element ) {
+ that._updateContent( element );
+ });
+ }
+ },
+
+ _disable: function() {
+ var that = this;
+
+ // close open tooltips
+ $.each( this.tooltips, function( id, element ) {
+ var event = $.Event( "blur" );
+ event.target = event.currentTarget = element[0];
+ that.close( event, true );
+ });
+
+ // remove title attributes to prevent native tooltips
+ this.element.find( this.options.items ).andSelf().each(function() {
+ var element = $( this );
+ if ( element.is( "[title]" ) ) {
+ element
+ .data( "ui-tooltip-title", element.attr( "title" ) )
+ .attr( "title", "" );
+ }
+ });
+ },
+
+ _enable: function() {
+ // restore title attributes
+ this.element.find( this.options.items ).andSelf().each(function() {
+ var element = $( this );
+ if ( element.data( "ui-tooltip-title" ) ) {
+ element.attr( "title", element.data( "ui-tooltip-title" ) );
+ }
+ });
+ },
+
+ open: function( event ) {
+ var that = this,
+ target = $( event ? event.target : this.element )
+ // we need closest here due to mouseover bubbling,
+ // but always pointing at the same event target
+ .closest( this.options.items );
+
+ // No element to show a tooltip for or the tooltip is already open
+ if ( !target.length || target.data( "ui-tooltip-id" ) ) {
+ return;
+ }
+
+ if ( target.attr( "title" ) ) {
+ target.data( "ui-tooltip-title", target.attr( "title" ) );
+ }
+
+ target.data( "ui-tooltip-open", true );
+
+ // kill parent tooltips, custom or native, for hover
+ if ( event && event.type === "mouseover" ) {
+ target.parents().each(function() {
+ var parent = $( this ),
+ blurEvent;
+ if ( parent.data( "ui-tooltip-open" ) ) {
+ blurEvent = $.Event( "blur" );
+ blurEvent.target = blurEvent.currentTarget = this;
+ that.close( blurEvent, true );
+ }
+ if ( parent.attr( "title" ) ) {
+ parent.uniqueId();
+ that.parents[ this.id ] = {
+ element: this,
+ title: parent.attr( "title" )
+ };
+ parent.attr( "title", "" );
+ }
+ });
+ }
+
+ this._updateContent( target, event );
+ },
+
+ _updateContent: function( target, event ) {
+ var content,
+ contentOption = this.options.content,
+ that = this,
+ eventType = event ? event.type : null;
+
+ if ( typeof contentOption === "string" ) {
+ return this._open( event, target, contentOption );
+ }
+
+ content = contentOption.call( target[0], function( response ) {
+ // ignore async response if tooltip was closed already
+ if ( !target.data( "ui-tooltip-open" ) ) {
+ return;
+ }
+ // IE may instantly serve a cached response for ajax requests
+ // delay this call to _open so the other call to _open runs first
+ that._delay(function() {
+ // jQuery creates a special event for focusin when it doesn't
+ // exist natively. To improve performance, the native event
+ // object is reused and the type is changed. Therefore, we can't
+ // rely on the type being correct after the event finished
+ // bubbling, so we set it back to the previous value. (#8740)
+ if ( event ) {
+ event.type = eventType;
+ }
+ this._open( event, target, response );
+ });
+ });
+ if ( content ) {
+ this._open( event, target, content );
+ }
+ },
+
+ _open: function( event, target, content ) {
+ var tooltip, events, delayedShow,
+ positionOption = $.extend( {}, this.options.position );
+
+ if ( !content ) {
+ return;
+ }
+
+ // Content can be updated multiple times. If the tooltip already
+ // exists, then just update the content and bail.
+ tooltip = this._find( target );
+ if ( tooltip.length ) {
+ tooltip.find( ".ui-tooltip-content" ).html( content );
+ return;
+ }
+
+ // if we have a title, clear it to prevent the native tooltip
+ // we have to check first to avoid defining a title if none exists
+ // (we don't want to cause an element to start matching [title])
+ //
+ // We use removeAttr only for key events, to allow IE to export the correct
+ // accessible attributes. For mouse events, set to empty string to avoid
+ // native tooltip showing up (happens only when removing inside mouseover).
+ if ( target.is( "[title]" ) ) {
+ if ( event && event.type === "mouseover" ) {
+ target.attr( "title", "" );
+ } else {
+ target.removeAttr( "title" );
+ }
+ }
+
+ tooltip = this._tooltip( target );
+ addDescribedBy( target, tooltip.attr( "id" ) );
+ tooltip.find( ".ui-tooltip-content" ).html( content );
+
+ function position( event ) {
+ positionOption.of = event;
+ if ( tooltip.is( ":hidden" ) ) {
+ return;
+ }
+ tooltip.position( positionOption );
+ }
+ if ( this.options.track && event && /^mouse/.test( event.type ) ) {
+ this._on( this.document, {
+ mousemove: position
+ });
+ // trigger once to override element-relative positioning
+ position( event );
+ } else {
+ tooltip.position( $.extend({
+ of: target
+ }, this.options.position ) );
+ }
+
+ tooltip.hide();
+
+ this._show( tooltip, this.options.show );
+ // Handle tracking tooltips that are shown with a delay (#8644). As soon
+ // as the tooltip is visible, position the tooltip using the most recent
+ // event.
+ if ( this.options.show && this.options.show.delay ) {
+ delayedShow = setInterval(function() {
+ if ( tooltip.is( ":visible" ) ) {
+ position( positionOption.of );
+ clearInterval( delayedShow );
+ }
+ }, $.fx.interval );
+ }
+
+ this._trigger( "open", event, { tooltip: tooltip } );
+
+ events = {
+ keyup: function( event ) {
+ if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
+ var fakeEvent = $.Event(event);
+ fakeEvent.currentTarget = target[0];
+ this.close( fakeEvent, true );
+ }
+ },
+ remove: function() {
+ this._removeTooltip( tooltip );
+ }
+ };
+ if ( !event || event.type === "mouseover" ) {
+ events.mouseleave = "close";
+ }
+ if ( !event || event.type === "focusin" ) {
+ events.focusout = "close";
+ }
+ this._on( true, target, events );
+ },
+
+ close: function( event ) {
+ var that = this,
+ target = $( event ? event.currentTarget : this.element ),
+ tooltip = this._find( target );
+
+ // disabling closes the tooltip, so we need to track when we're closing
+ // to avoid an infinite loop in case the tooltip becomes disabled on close
+ if ( this.closing ) {
+ return;
+ }
+
+ // only set title if we had one before (see comment in _open())
+ if ( target.data( "ui-tooltip-title" ) ) {
+ target.attr( "title", target.data( "ui-tooltip-title" ) );
+ }
+
+ removeDescribedBy( target );
+
+ tooltip.stop( true );
+ this._hide( tooltip, this.options.hide, function() {
+ that._removeTooltip( $( this ) );
+ });
+
+ target.removeData( "ui-tooltip-open" );
+ this._off( target, "mouseleave focusout keyup" );
+ // Remove 'remove' binding only on delegated targets
+ if ( target[0] !== this.element[0] ) {
+ this._off( target, "remove" );
+ }
+ this._off( this.document, "mousemove" );
+
+ if ( event && event.type === "mouseleave" ) {
+ $.each( this.parents, function( id, parent ) {
+ $( parent.element ).attr( "title", parent.title );
+ delete that.parents[ id ];
+ });
+ }
+
+ this.closing = true;
+ this._trigger( "close", event, { tooltip: tooltip } );
+ this.closing = false;
+ },
+
+ _tooltip: function( element ) {
+ var id = "ui-tooltip-" + increments++,
+ tooltip = $( "<div>" )
+ .attr({
+ id: id,
+ role: "tooltip"
+ })
+ .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
+ ( this.options.tooltipClass || "" ) );
+ $( "<div>" )
+ .addClass( "ui-tooltip-content" )
+ .appendTo( tooltip );
+ tooltip.appendTo( this.document[0].body );
+ if ( $.fn.bgiframe ) {
+ tooltip.bgiframe();
+ }
+ this.tooltips[ id ] = element;
+ return tooltip;
+ },
+
+ _find: function( target ) {
+ var id = target.data( "ui-tooltip-id" );
+ return id ? $( "#" + id ) : $();
+ },
+
+ _removeTooltip: function( tooltip ) {
+ tooltip.remove();
+ delete this.tooltips[ tooltip.attr( "id" ) ];
+ },
+
+ _destroy: function() {
+ var that = this;
+
+ // close open tooltips
+ $.each( this.tooltips, function( id, element ) {
+ // Delegate to close method to handle common cleanup
+ var event = $.Event( "blur" );
+ event.target = event.currentTarget = element[0];
+ that.close( event, true );
+
+ // Remove immediately; destroying an open tooltip doesn't use the
+ // hide animation
+ $( "#" + id ).remove();
+
+ // Restore the title
+ if ( element.data( "ui-tooltip-title" ) ) {
+ element.attr( "title", element.data( "ui-tooltip-title" ) );
+ element.removeData( "ui-tooltip-title" );
+ }
+ });
+ }
+});
+
+}( jQuery ) );
+;(jQuery.effects || (function($, undefined) {
+
+var backCompat = $.uiBackCompat !== false,
+ // prefix used for storing data on .data()
+ dataSpace = "ui-effects-";
+
+$.effects = {
+ effect: {}
+};
+
+/*!
+ * jQuery Color Animations v2.0.0
+ * http://jquery.com/
+ *
+ * Copyright 2012 jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ *
+ * Date: Mon Aug 13 13:41:02 2012 -0500
+ */
+(function( jQuery, undefined ) {
+
+ var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "),
+
+ // plusequals test for += 100 -= 100
+ rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
+ // a set of RE's that can match strings and generate color tuples.
+ stringParsers = [{
+ re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
+ parse: function( execResult ) {
+ return [
+ execResult[ 1 ],
+ execResult[ 2 ],
+ execResult[ 3 ],
+ execResult[ 4 ]
+ ];
+ }
+ }, {
+ re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
+ parse: function( execResult ) {
+ return [
+ execResult[ 1 ] * 2.55,
+ execResult[ 2 ] * 2.55,
+ execResult[ 3 ] * 2.55,
+ execResult[ 4 ]
+ ];
+ }
+ }, {
+ // this regex ignores A-F because it's compared against an already lowercased string
+ re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
+ parse: function( execResult ) {
+ return [
+ parseInt( execResult[ 1 ], 16 ),
+ parseInt( execResult[ 2 ], 16 ),
+ parseInt( execResult[ 3 ], 16 )
+ ];
+ }
+ }, {
+ // this regex ignores A-F because it's compared against an already lowercased string
+ re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
+ parse: function( execResult ) {
+ return [
+ parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
+ parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
+ parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
+ ];
+ }
+ }, {
+ re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
+ space: "hsla",
+ parse: function( execResult ) {
+ return [
+ execResult[ 1 ],
+ execResult[ 2 ] / 100,
+ execResult[ 3 ] / 100,
+ execResult[ 4 ]
+ ];
+ }
+ }],
+
+ // jQuery.Color( )
+ color = jQuery.Color = function( color, green, blue, alpha ) {
+ return new jQuery.Color.fn.parse( color, green, blue, alpha );
+ },
+ spaces = {
+ rgba: {
+ props: {
+ red: {
+ idx: 0,
+ type: "byte"
+ },
+ green: {
+ idx: 1,
+ type: "byte"
+ },
+ blue: {
+ idx: 2,
+ type: "byte"
+ }
+ }
+ },
+
+ hsla: {
+ props: {
+ hue: {
+ idx: 0,
+ type: "degrees"
+ },
+ saturation: {
+ idx: 1,
+ type: "percent"
+ },
+ lightness: {
+ idx: 2,
+ type: "percent"
+ }
+ }
+ }
+ },
+ propTypes = {
+ "byte": {
+ floor: true,
+ max: 255
+ },
+ "percent": {
+ max: 1
+ },
+ "degrees": {
+ mod: 360,
+ floor: true
+ }
+ },
+ support = color.support = {},
+
+ // element for support tests
+ supportElem = jQuery( "<p>" )[ 0 ],
+
+ // colors = jQuery.Color.names
+ colors,
+
+ // local aliases of functions called often
+ each = jQuery.each;
+
+// determine rgba support immediately
+supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
+support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
+
+// define cache name and alpha properties
+// for rgba and hsla spaces
+each( spaces, function( spaceName, space ) {
+ space.cache = "_" + spaceName;
+ space.props.alpha = {
+ idx: 3,
+ type: "percent",
+ def: 1
+ };
+});
+
+function clamp( value, prop, allowEmpty ) {
+ var type = propTypes[ prop.type ] || {};
+
+ if ( value == null ) {
+ return (allowEmpty || !prop.def) ? null : prop.def;
+ }
+
+ // ~~ is an short way of doing floor for positive numbers
+ value = type.floor ? ~~value : parseFloat( value );
+
+ // IE will pass in empty strings as value for alpha,
+ // which will hit this case
+ if ( isNaN( value ) ) {
+ return prop.def;
+ }
+
+ if ( type.mod ) {
+ // we add mod before modding to make sure that negatives values
+ // get converted properly: -10 -> 350
+ return (value + type.mod) % type.mod;
+ }
+
+ // for now all property types without mod have min and max
+ return 0 > value ? 0 : type.max < value ? type.max : value;
+}
+
+function stringParse( string ) {
+ var inst = color(),
+ rgba = inst._rgba = [];
+
+ string = string.toLowerCase();
+
+ each( stringParsers, function( i, parser ) {
+ var parsed,
+ match = parser.re.exec( string ),
+ values = match && parser.parse( match ),
+ spaceName = parser.space || "rgba";
+
+ if ( values ) {
+ parsed = inst[ spaceName ]( values );
+
+ // if this was an rgba parse the assignment might happen twice
+ // oh well....
+ inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
+ rgba = inst._rgba = parsed._rgba;
+
+ // exit each( stringParsers ) here because we matched
+ return false;
+ }
+ });
+
+ // Found a stringParser that handled it
+ if ( rgba.length ) {
+
+ // if this came from a parsed string, force "transparent" when alpha is 0
+ // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
+ if ( rgba.join() === "0,0,0,0" ) {
+ jQuery.extend( rgba, colors.transparent );
+ }
+ return inst;
+ }
+
+ // named colors
+ return colors[ string ];
+}
+
+color.fn = jQuery.extend( color.prototype, {
+ parse: function( red, green, blue, alpha ) {
+ if ( red === undefined ) {
+ this._rgba = [ null, null, null, null ];
+ return this;
+ }
+ if ( red.jquery || red.nodeType ) {
+ red = jQuery( red ).css( green );
+ green = undefined;
+ }
+
+ var inst = this,
+ type = jQuery.type( red ),
+ rgba = this._rgba = [];
+
+ // more than 1 argument specified - assume ( red, green, blue, alpha )
+ if ( green !== undefined ) {
+ red = [ red, green, blue, alpha ];
+ type = "array";
+ }
+
+ if ( type === "string" ) {
+ return this.parse( stringParse( red ) || colors._default );
+ }
+
+ if ( type === "array" ) {
+ each( spaces.rgba.props, function( key, prop ) {
+ rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
+ });
+ return this;
+ }
+
+ if ( type === "object" ) {
+ if ( red instanceof color ) {
+ each( spaces, function( spaceName, space ) {
+ if ( red[ space.cache ] ) {
+ inst[ space.cache ] = red[ space.cache ].slice();
+ }
+ });
+ } else {
+ each( spaces, function( spaceName, space ) {
+ var cache = space.cache;
+ each( space.props, function( key, prop ) {
+
+ // if the cache doesn't exist, and we know how to convert
+ if ( !inst[ cache ] && space.to ) {
+
+ // if the value was null, we don't need to copy it
+ // if the key was alpha, we don't need to copy it either
+ if ( key === "alpha" || red[ key ] == null ) {
+ return;
+ }
+ inst[ cache ] = space.to( inst._rgba );
+ }
+
+ // this is the only case where we allow nulls for ALL properties.
+ // call clamp with alwaysAllowEmpty
+ inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
+ });
+
+ // everything defined but alpha?
+ if ( inst[ cache ] && $.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
+ // use the default of 1
+ inst[ cache ][ 3 ] = 1;
+ if ( space.from ) {
+ inst._rgba = space.from( inst[ cache ] );
+ }
+ }
+ });
+ }
+ return this;
+ }
+ },
+ is: function( compare ) {
+ var is = color( compare ),
+ same = true,
+ inst = this;
+
+ each( spaces, function( _, space ) {
+ var localCache,
+ isCache = is[ space.cache ];
+ if (isCache) {
+ localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
+ each( space.props, function( _, prop ) {
+ if ( isCache[ prop.idx ] != null ) {
+ same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
+ return same;
+ }
+ });
+ }
+ return same;
+ });
+ return same;
+ },
+ _space: function() {
+ var used = [],
+ inst = this;
+ each( spaces, function( spaceName, space ) {
+ if ( inst[ space.cache ] ) {
+ used.push( spaceName );
+ }
+ });
+ return used.pop();
+ },
+ transition: function( other, distance ) {
+ var end = color( other ),
+ spaceName = end._space(),
+ space = spaces[ spaceName ],
+ startColor = this.alpha() === 0 ? color( "transparent" ) : this,
+ start = startColor[ space.cache ] || space.to( startColor._rgba ),
+ result = start.slice();
+
+ end = end[ space.cache ];
+ each( space.props, function( key, prop ) {
+ var index = prop.idx,
+ startValue = start[ index ],
+ endValue = end[ index ],
+ type = propTypes[ prop.type ] || {};
+
+ // if null, don't override start value
+ if ( endValue === null ) {
+ return;
+ }
+ // if null - use end
+ if ( startValue === null ) {
+ result[ index ] = endValue;
+ } else {
+ if ( type.mod ) {
+ if ( endValue - startValue > type.mod / 2 ) {
+ startValue += type.mod;
+ } else if ( startValue - endValue > type.mod / 2 ) {
+ startValue -= type.mod;
+ }
+ }
+ result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
+ }
+ });
+ return this[ spaceName ]( result );
+ },
+ blend: function( opaque ) {
+ // if we are already opaque - return ourself
+ if ( this._rgba[ 3 ] === 1 ) {
+ return this;
+ }
+
+ var rgb = this._rgba.slice(),
+ a = rgb.pop(),
+ blend = color( opaque )._rgba;
+
+ return color( jQuery.map( rgb, function( v, i ) {
+ return ( 1 - a ) * blend[ i ] + a * v;
+ }));
+ },
+ toRgbaString: function() {
+ var prefix = "rgba(",
+ rgba = jQuery.map( this._rgba, function( v, i ) {
+ return v == null ? ( i > 2 ? 1 : 0 ) : v;
+ });
+
+ if ( rgba[ 3 ] === 1 ) {
+ rgba.pop();
+ prefix = "rgb(";
+ }
+
+ return prefix + rgba.join() + ")";
+ },
+ toHslaString: function() {
+ var prefix = "hsla(",
+ hsla = jQuery.map( this.hsla(), function( v, i ) {
+ if ( v == null ) {
+ v = i > 2 ? 1 : 0;
+ }
+
+ // catch 1 and 2
+ if ( i && i < 3 ) {
+ v = Math.round( v * 100 ) + "%";
+ }
+ return v;
+ });
+
+ if ( hsla[ 3 ] === 1 ) {
+ hsla.pop();
+ prefix = "hsl(";
+ }
+ return prefix + hsla.join() + ")";
+ },
+ toHexString: function( includeAlpha ) {
+ var rgba = this._rgba.slice(),
+ alpha = rgba.pop();
+
+ if ( includeAlpha ) {
+ rgba.push( ~~( alpha * 255 ) );
+ }
+
+ return "#" + jQuery.map( rgba, function( v ) {
+
+ // default to 0 when nulls exist
+ v = ( v || 0 ).toString( 16 );
+ return v.length === 1 ? "0" + v : v;
+ }).join("");
+ },
+ toString: function() {
+ return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
+ }
+});
+color.fn.parse.prototype = color.fn;
+
+// hsla conversions adapted from:
+// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
+
+function hue2rgb( p, q, h ) {
+ h = ( h + 1 ) % 1;
+ if ( h * 6 < 1 ) {
+ return p + (q - p) * h * 6;
+ }
+ if ( h * 2 < 1) {
+ return q;
+ }
+ if ( h * 3 < 2 ) {
+ return p + (q - p) * ((2/3) - h) * 6;
+ }
+ return p;
+}
+
+spaces.hsla.to = function ( rgba ) {
+ if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
+ return [ null, null, null, rgba[ 3 ] ];
+ }
+ var r = rgba[ 0 ] / 255,
+ g = rgba[ 1 ] / 255,
+ b = rgba[ 2 ] / 255,
+ a = rgba[ 3 ],
+ max = Math.max( r, g, b ),
+ min = Math.min( r, g, b ),
+ diff = max - min,
+ add = max + min,
+ l = add * 0.5,
+ h, s;
+
+ if ( min === max ) {
+ h = 0;
+ } else if ( r === max ) {
+ h = ( 60 * ( g - b ) / diff ) + 360;
+ } else if ( g === max ) {
+ h = ( 60 * ( b - r ) / diff ) + 120;
+ } else {
+ h = ( 60 * ( r - g ) / diff ) + 240;
+ }
+
+ if ( l === 0 || l === 1 ) {
+ s = l;
+ } else if ( l <= 0.5 ) {
+ s = diff / add;
+ } else {
+ s = diff / ( 2 - add );
+ }
+ return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
+};
+
+spaces.hsla.from = function ( hsla ) {
+ if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
+ return [ null, null, null, hsla[ 3 ] ];
+ }
+ var h = hsla[ 0 ] / 360,
+ s = hsla[ 1 ],
+ l = hsla[ 2 ],
+ a = hsla[ 3 ],
+ q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
+ p = 2 * l - q;
+
+ return [
+ Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
+ Math.round( hue2rgb( p, q, h ) * 255 ),
+ Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
+ a
+ ];
+};
+
+
+each( spaces, function( spaceName, space ) {
+ var props = space.props,
+ cache = space.cache,
+ to = space.to,
+ from = space.from;
+
+ // makes rgba() and hsla()
+ color.fn[ spaceName ] = function( value ) {
+
+ // generate a cache for this space if it doesn't exist
+ if ( to && !this[ cache ] ) {
+ this[ cache ] = to( this._rgba );
+ }
+ if ( value === undefined ) {
+ return this[ cache ].slice();
+ }
+
+ var ret,
+ type = jQuery.type( value ),
+ arr = ( type === "array" || type === "object" ) ? value : arguments,
+ local = this[ cache ].slice();
+
+ each( props, function( key, prop ) {
+ var val = arr[ type === "object" ? key : prop.idx ];
+ if ( val == null ) {
+ val = local[ prop.idx ];
+ }
+ local[ prop.idx ] = clamp( val, prop );
+ });
+
+ if ( from ) {
+ ret = color( from( local ) );
+ ret[ cache ] = local;
+ return ret;
+ } else {
+ return color( local );
+ }
+ };
+
+ // makes red() green() blue() alpha() hue() saturation() lightness()
+ each( props, function( key, prop ) {
+ // alpha is included in more than one space
+ if ( color.fn[ key ] ) {
+ return;
+ }
+ color.fn[ key ] = function( value ) {
+ var vtype = jQuery.type( value ),
+ fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
+ local = this[ fn ](),
+ cur = local[ prop.idx ],
+ match;
+
+ if ( vtype === "undefined" ) {
+ return cur;
+ }
+
+ if ( vtype === "function" ) {
+ value = value.call( this, cur );
+ vtype = jQuery.type( value );
+ }
+ if ( value == null && prop.empty ) {
+ return this;
+ }
+ if ( vtype === "string" ) {
+ match = rplusequals.exec( value );
+ if ( match ) {
+ value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
+ }
+ }
+ local[ prop.idx ] = value;
+ return this[ fn ]( local );
+ };
+ });
+});
+
+// add .fx.step functions
+each( stepHooks, function( i, hook ) {
+ jQuery.cssHooks[ hook ] = {
+ set: function( elem, value ) {
+ var parsed, curElem,
+ backgroundColor = "";
+
+ if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) {
+ value = color( parsed || value );
+ if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
+ curElem = hook === "backgroundColor" ? elem.parentNode : elem;
+ while (
+ (backgroundColor === "" || backgroundColor === "transparent") &&
+ curElem && curElem.style
+ ) {
+ try {
+ backgroundColor = jQuery.css( curElem, "backgroundColor" );
+ curElem = curElem.parentNode;
+ } catch ( e ) {
+ }
+ }
+
+ value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
+ backgroundColor :
+ "_default" );
+ }
+
+ value = value.toRgbaString();
+ }
+ try {
+ elem.style[ hook ] = value;
+ } catch( error ) {
+ // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
+ }
+ }
+ };
+ jQuery.fx.step[ hook ] = function( fx ) {
+ if ( !fx.colorInit ) {
+ fx.start = color( fx.elem, hook );
+ fx.end = color( fx.end );
+ fx.colorInit = true;
+ }
+ jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
+ };
+});
+
+jQuery.cssHooks.borderColor = {
+ expand: function( value ) {
+ var expanded = {};
+
+ each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
+ expanded[ "border" + part + "Color" ] = value;
+ });
+ return expanded;
+ }
+};
+
+// Basic color names only.
+// Usage of any of the other color names requires adding yourself or including
+// jquery.color.svg-names.js.
+colors = jQuery.Color.names = {
+ // 4.1. Basic color keywords
+ aqua: "#00ffff",
+ black: "#000000",
+ blue: "#0000ff",
+ fuchsia: "#ff00ff",
+ gray: "#808080",
+ green: "#008000",
+ lime: "#00ff00",
+ maroon: "#800000",
+ navy: "#000080",
+ olive: "#808000",
+ purple: "#800080",
+ red: "#ff0000",
+ silver: "#c0c0c0",
+ teal: "#008080",
+ white: "#ffffff",
+ yellow: "#ffff00",
+
+ // 4.2.3. "transparent" color keyword
+ transparent: [ null, null, null, 0 ],
+
+ _default: "#ffffff"
+};
+
+})( jQuery );
+
+
+
+/******************************************************************************/
+/****************************** CLASS ANIMATIONS ******************************/
+/******************************************************************************/
+(function() {
+
+var classAnimationActions = [ "add", "remove", "toggle" ],
+ shorthandStyles = {
+ border: 1,
+ borderBottom: 1,
+ borderColor: 1,
+ borderLeft: 1,
+ borderRight: 1,
+ borderTop: 1,
+ borderWidth: 1,
+ margin: 1,
+ padding: 1
+ };
+
+$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
+ $.fx.step[ prop ] = function( fx ) {
+ if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
+ jQuery.style( fx.elem, prop, fx.end );
+ fx.setAttr = true;
+ }
+ };
+});
+
+function getElementStyles() {
+ var style = this.ownerDocument.defaultView ?
+ this.ownerDocument.defaultView.getComputedStyle( this, null ) :
+ this.currentStyle,
+ newStyle = {},
+ key,
+ len;
+
+ // webkit enumerates style porperties
+ if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
+ len = style.length;
+ while ( len-- ) {
+ key = style[ len ];
+ if ( typeof style[ key ] === "string" ) {
+ newStyle[ $.camelCase( key ) ] = style[ key ];
+ }
+ }
+ } else {
+ for ( key in style ) {
+ if ( typeof style[ key ] === "string" ) {
+ newStyle[ key ] = style[ key ];
+ }
+ }
+ }
+
+ return newStyle;
+}
+
+
+function styleDifference( oldStyle, newStyle ) {
+ var diff = {},
+ name, value;
+
+ for ( name in newStyle ) {
+ value = newStyle[ name ];
+ if ( oldStyle[ name ] !== value ) {
+ if ( !shorthandStyles[ name ] ) {
+ if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
+ diff[ name ] = value;
+ }
+ }
+ }
+ }
+
+ return diff;
+}
+
+$.effects.animateClass = function( value, duration, easing, callback ) {
+ var o = $.speed( duration, easing, callback );
+
+ return this.queue( function() {
+ var animated = $( this ),
+ baseClass = animated.attr( "class" ) || "",
+ applyClassChange,
+ allAnimations = o.children ? animated.find( "*" ).andSelf() : animated;
+
+ // map the animated objects to store the original styles.
+ allAnimations = allAnimations.map(function() {
+ var el = $( this );
+ return {
+ el: el,
+ start: getElementStyles.call( this )
+ };
+ });
+
+ // apply class change
+ applyClassChange = function() {
+ $.each( classAnimationActions, function(i, action) {
+ if ( value[ action ] ) {
+ animated[ action + "Class" ]( value[ action ] );
+ }
+ });
+ };
+ applyClassChange();
+
+ // map all animated objects again - calculate new styles and diff
+ allAnimations = allAnimations.map(function() {
+ this.end = getElementStyles.call( this.el[ 0 ] );
+ this.diff = styleDifference( this.start, this.end );
+ return this;
+ });
+
+ // apply original class
+ animated.attr( "class", baseClass );
+
+ // map all animated objects again - this time collecting a promise
+ allAnimations = allAnimations.map(function() {
+ var styleInfo = this,
+ dfd = $.Deferred(),
+ opts = jQuery.extend({}, o, {
+ queue: false,
+ complete: function() {
+ dfd.resolve( styleInfo );
+ }
+ });
+
+ this.el.animate( this.diff, opts );
+ return dfd.promise();
+ });
+
+ // once all animations have completed:
+ $.when.apply( $, allAnimations.get() ).done(function() {
+
+ // set the final class
+ applyClassChange();
+
+ // for each animated element,
+ // clear all css properties that were animated
+ $.each( arguments, function() {
+ var el = this.el;
+ $.each( this.diff, function(key) {
+ el.css( key, '' );
+ });
+ });
+
+ // this is guarnteed to be there if you use jQuery.speed()
+ // it also handles dequeuing the next anim...
+ o.complete.call( animated[ 0 ] );
+ });
+ });
+};
+
+$.fn.extend({
+ _addClass: $.fn.addClass,
+ addClass: function( classNames, speed, easing, callback ) {
+ return speed ?
+ $.effects.animateClass.call( this,
+ { add: classNames }, speed, easing, callback ) :
+ this._addClass( classNames );
+ },
+
+ _removeClass: $.fn.removeClass,
+ removeClass: function( classNames, speed, easing, callback ) {
+ return speed ?
+ $.effects.animateClass.call( this,
+ { remove: classNames }, speed, easing, callback ) :
+ this._removeClass( classNames );
+ },
+
+ _toggleClass: $.fn.toggleClass,
+ toggleClass: function( classNames, force, speed, easing, callback ) {
+ if ( typeof force === "boolean" || force === undefined ) {
+ if ( !speed ) {
+ // without speed parameter
+ return this._toggleClass( classNames, force );
+ } else {
+ return $.effects.animateClass.call( this,
+ (force ? { add: classNames } : { remove: classNames }),
+ speed, easing, callback );
+ }
+ } else {
+ // without force parameter
+ return $.effects.animateClass.call( this,
+ { toggle: classNames }, force, speed, easing );
+ }
+ },
+
+ switchClass: function( remove, add, speed, easing, callback) {
+ return $.effects.animateClass.call( this, {
+ add: add,
+ remove: remove
+ }, speed, easing, callback );
+ }
+});
+
+})();
+
+/******************************************************************************/
+/*********************************** EFFECTS **********************************/
+/******************************************************************************/
+
+(function() {
+
+$.extend( $.effects, {
+ version: "1.9.2",
+
+ // Saves a set of properties in a data storage
+ save: function( element, set ) {
+ for( var i=0; i < set.length; i++ ) {
+ if ( set[ i ] !== null ) {
+ element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
+ }
+ }
+ },
+
+ // Restores a set of previously saved properties from a data storage
+ restore: function( element, set ) {
+ var val, i;
+ for( i=0; i < set.length; i++ ) {
+ if ( set[ i ] !== null ) {
+ val = element.data( dataSpace + set[ i ] );
+ // support: jQuery 1.6.2
+ // http://bugs.jquery.com/ticket/9917
+ // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
+ // We can't differentiate between "" and 0 here, so we just assume
+ // empty string since it's likely to be a more common value...
+ if ( val === undefined ) {
+ val = "";
+ }
+ element.css( set[ i ], val );
+ }
+ }
+ },
+
+ setMode: function( el, mode ) {
+ if (mode === "toggle") {
+ mode = el.is( ":hidden" ) ? "show" : "hide";
+ }
+ return mode;
+ },
+
+ // Translates a [top,left] array into a baseline value
+ // this should be a little more flexible in the future to handle a string & hash
+ getBaseline: function( origin, original ) {
+ var y, x;
+ switch ( origin[ 0 ] ) {
+ case "top": y = 0; break;
+ case "middle": y = 0.5; break;
+ case "bottom": y = 1; break;
+ default: y = origin[ 0 ] / original.height;
+ }
+ switch ( origin[ 1 ] ) {
+ case "left": x = 0; break;
+ case "center": x = 0.5; break;
+ case "right": x = 1; break;
+ default: x = origin[ 1 ] / original.width;
+ }
+ return {
+ x: x,
+ y: y
+ };
+ },
+
+ // Wraps the element around a wrapper that copies position properties
+ createWrapper: function( element ) {
+
+ // if the element is already wrapped, return it
+ if ( element.parent().is( ".ui-effects-wrapper" )) {
+ return element.parent();
+ }
+
+ // wrap the element
+ var props = {
+ width: element.outerWidth(true),
+ height: element.outerHeight(true),
+ "float": element.css( "float" )
+ },
+ wrapper = $( "<div></div>" )
+ .addClass( "ui-effects-wrapper" )
+ .css({
+ fontSize: "100%",
+ background: "transparent",
+ border: "none",
+ margin: 0,
+ padding: 0
+ }),
+ // Store the size in case width/height are defined in % - Fixes #5245
+ size = {
+ width: element.width(),
+ height: element.height()
+ },
+ active = document.activeElement;
+
+ // support: Firefox
+ // Firefox incorrectly exposes anonymous content
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
+ try {
+ active.id;
+ } catch( e ) {
+ active = document.body;
+ }
+
+ element.wrap( wrapper );
+
+ // Fixes #7595 - Elements lose focus when wrapped.
+ if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
+ $( active ).focus();
+ }
+
+ wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
+
+ // transfer positioning properties to the wrapper
+ if ( element.css( "position" ) === "static" ) {
+ wrapper.css({ position: "relative" });
+ element.css({ position: "relative" });
+ } else {
+ $.extend( props, {
+ position: element.css( "position" ),
+ zIndex: element.css( "z-index" )
+ });
+ $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
+ props[ pos ] = element.css( pos );
+ if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
+ props[ pos ] = "auto";
+ }
+ });
+ element.css({
+ position: "relative",
+ top: 0,
+ left: 0,
+ right: "auto",
+ bottom: "auto"
+ });
+ }
+ element.css(size);
+
+ return wrapper.css( props ).show();
+ },
+
+ removeWrapper: function( element ) {
+ var active = document.activeElement;
+
+ if ( element.parent().is( ".ui-effects-wrapper" ) ) {
+ element.parent().replaceWith( element );
+
+ // Fixes #7595 - Elements lose focus when wrapped.
+ if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
+ $( active ).focus();
+ }
+ }
+
+
+ return element;
+ },
+
+ setTransition: function( element, list, factor, value ) {
+ value = value || {};
+ $.each( list, function( i, x ) {
+ var unit = element.cssUnit( x );
+ if ( unit[ 0 ] > 0 ) {
+ value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
+ }
+ });
+ return value;
+ }
+});
+
+// return an effect options object for the given parameters:
+function _normalizeArguments( effect, options, speed, callback ) {
+
+ // allow passing all options as the first parameter
+ if ( $.isPlainObject( effect ) ) {
+ options = effect;
+ effect = effect.effect;
+ }
+
+ // convert to an object
+ effect = { effect: effect };
+
+ // catch (effect, null, ...)
+ if ( options == null ) {
+ options = {};
+ }
+
+ // catch (effect, callback)
+ if ( $.isFunction( options ) ) {
+ callback = options;
+ speed = null;
+ options = {};
+ }
+
+ // catch (effect, speed, ?)
+ if ( typeof options === "number" || $.fx.speeds[ options ] ) {
+ callback = speed;
+ speed = options;
+ options = {};
+ }
+
+ // catch (effect, options, callback)
+ if ( $.isFunction( speed ) ) {
+ callback = speed;
+ speed = null;
+ }
+
+ // add options to effect
+ if ( options ) {
+ $.extend( effect, options );
+ }
+
+ speed = speed || options.duration;
+ effect.duration = $.fx.off ? 0 :
+ typeof speed === "number" ? speed :
+ speed in $.fx.speeds ? $.fx.speeds[ speed ] :
+ $.fx.speeds._default;
+
+ effect.complete = callback || options.complete;
+
+ return effect;
+}
+
+function standardSpeed( speed ) {
+ // valid standard speeds
+ if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
+ return true;
+ }
+
+ // invalid strings - treat as "normal" speed
+ if ( typeof speed === "string" && !$.effects.effect[ speed ] ) {
+ // TODO: remove in 2.0 (#7115)
+ if ( backCompat && $.effects[ speed ] ) {
+ return false;
+ }
+ return true;
+ }
+
+ return false;
+}
+
+$.fn.extend({
+ effect: function( /* effect, options, speed, callback */ ) {
+ var args = _normalizeArguments.apply( this, arguments ),
+ mode = args.mode,
+ queue = args.queue,
+ effectMethod = $.effects.effect[ args.effect ],
+
+ // DEPRECATED: remove in 2.0 (#7115)
+ oldEffectMethod = !effectMethod && backCompat && $.effects[ args.effect ];
+
+ if ( $.fx.off || !( effectMethod || oldEffectMethod ) ) {
+ // delegate to the original method (e.g., .show()) if possible
+ if ( mode ) {
+ return this[ mode ]( args.duration, args.complete );
+ } else {
+ return this.each( function() {
+ if ( args.complete ) {
+ args.complete.call( this );
+ }
+ });
+ }
+ }
+
+ function run( next ) {
+ var elem = $( this ),
+ complete = args.complete,
+ mode = args.mode;
+
+ function done() {
+ if ( $.isFunction( complete ) ) {
+ complete.call( elem[0] );
+ }
+ if ( $.isFunction( next ) ) {
+ next();
+ }
+ }
+
+ // if the element is hiddden and mode is hide,
+ // or element is visible and mode is show
+ if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
+ done();
+ } else {
+ effectMethod.call( elem[0], args, done );
+ }
+ }
+
+ // TODO: remove this check in 2.0, effectMethod will always be true
+ if ( effectMethod ) {
+ return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
+ } else {
+ // DEPRECATED: remove in 2.0 (#7115)
+ return oldEffectMethod.call(this, {
+ options: args,
+ duration: args.duration,
+ callback: args.complete,
+ mode: args.mode
+ });
+ }
+ },
+
+ _show: $.fn.show,
+ show: function( speed ) {
+ if ( standardSpeed( speed ) ) {
+ return this._show.apply( this, arguments );
+ } else {
+ var args = _normalizeArguments.apply( this, arguments );
+ args.mode = "show";
+ return this.effect.call( this, args );
+ }
+ },
+
+ _hide: $.fn.hide,
+ hide: function( speed ) {
+ if ( standardSpeed( speed ) ) {
+ return this._hide.apply( this, arguments );
+ } else {
+ var args = _normalizeArguments.apply( this, arguments );
+ args.mode = "hide";
+ return this.effect.call( this, args );
+ }
+ },
+
+ // jQuery core overloads toggle and creates _toggle
+ __toggle: $.fn.toggle,
+ toggle: function( speed ) {
+ if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
+ return this.__toggle.apply( this, arguments );
+ } else {
+ var args = _normalizeArguments.apply( this, arguments );
+ args.mode = "toggle";
+ return this.effect.call( this, args );
+ }
+ },
+
+ // helper functions
+ cssUnit: function(key) {
+ var style = this.css( key ),
+ val = [];
+
+ $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
+ if ( style.indexOf( unit ) > 0 ) {
+ val = [ parseFloat( style ), unit ];
+ }
+ });
+ return val;
+ }
+});
+
+})();
+
+/******************************************************************************/
+/*********************************** EASING ***********************************/
+/******************************************************************************/
+
+(function() {
+
+// based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
+
+var baseEasings = {};
+
+$.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
+ baseEasings[ name ] = function( p ) {
+ return Math.pow( p, i + 2 );
+ };
+});
+
+$.extend( baseEasings, {
+ Sine: function ( p ) {
+ return 1 - Math.cos( p * Math.PI / 2 );
+ },
+ Circ: function ( p ) {
+ return 1 - Math.sqrt( 1 - p * p );
+ },
+ Elastic: function( p ) {
+ return p === 0 || p === 1 ? p :
+ -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
+ },
+ Back: function( p ) {
+ return p * p * ( 3 * p - 2 );
+ },
+ Bounce: function ( p ) {
+ var pow2,
+ bounce = 4;
+
+ while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
+ return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
+ }
+});
+
+$.each( baseEasings, function( name, easeIn ) {
+ $.easing[ "easeIn" + name ] = easeIn;
+ $.easing[ "easeOut" + name ] = function( p ) {
+ return 1 - easeIn( 1 - p );
+ };
+ $.easing[ "easeInOut" + name ] = function( p ) {
+ return p < 0.5 ?
+ easeIn( p * 2 ) / 2 :
+ 1 - easeIn( p * -2 + 2 ) / 2;
+ };
+});
+
+})();
+
+})(jQuery));
+(function( $, undefined ) {
+
+var rvertical = /up|down|vertical/,
+ rpositivemotion = /up|left|vertical|horizontal/;
+
+$.effects.effect.blind = function( o, done ) {
+ // Create element
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+ mode = $.effects.setMode( el, o.mode || "hide" ),
+ direction = o.direction || "up",
+ vertical = rvertical.test( direction ),
+ ref = vertical ? "height" : "width",
+ ref2 = vertical ? "top" : "left",
+ motion = rpositivemotion.test( direction ),
+ animation = {},
+ show = mode === "show",
+ wrapper, distance, margin;
+
+ // if already wrapped, the wrapper's properties are my property. #6245
+ if ( el.parent().is( ".ui-effects-wrapper" ) ) {
+ $.effects.save( el.parent(), props );
+ } else {
+ $.effects.save( el, props );
+ }
+ el.show();
+ wrapper = $.effects.createWrapper( el ).css({
+ overflow: "hidden"
+ });
+
+ distance = wrapper[ ref ]();
+ margin = parseFloat( wrapper.css( ref2 ) ) || 0;
+
+ animation[ ref ] = show ? distance : 0;
+ if ( !motion ) {
+ el
+ .css( vertical ? "bottom" : "right", 0 )
+ .css( vertical ? "top" : "left", "auto" )
+ .css({ position: "absolute" });
+
+ animation[ ref2 ] = show ? margin : distance + margin;
+ }
+
+ // start at 0 if we are showing
+ if ( show ) {
+ wrapper.css( ref, 0 );
+ if ( ! motion ) {
+ wrapper.css( ref2, margin + distance );
+ }
+ }
+
+ // Animate
+ wrapper.animate( animation, {
+ duration: o.duration,
+ easing: o.easing,
+ queue: false,
+ complete: function() {
+ if ( mode === "hide" ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ }
+ });
+
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.effects.effect.bounce = function( o, done ) {
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+
+ // defaults:
+ mode = $.effects.setMode( el, o.mode || "effect" ),
+ hide = mode === "hide",
+ show = mode === "show",
+ direction = o.direction || "up",
+ distance = o.distance,
+ times = o.times || 5,
+
+ // number of internal animations
+ anims = times * 2 + ( show || hide ? 1 : 0 ),
+ speed = o.duration / anims,
+ easing = o.easing,
+
+ // utility:
+ ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
+ motion = ( direction === "up" || direction === "left" ),
+ i,
+ upAnim,
+ downAnim,
+
+ // we will need to re-assemble the queue to stack our animations in place
+ queue = el.queue(),
+ queuelen = queue.length;
+
+ // Avoid touching opacity to prevent clearType and PNG issues in IE
+ if ( show || hide ) {
+ props.push( "opacity" );
+ }
+
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el ); // Create Wrapper
+
+ // default distance for the BIGGEST bounce is the outer Distance / 3
+ if ( !distance ) {
+ distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
+ }
+
+ if ( show ) {
+ downAnim = { opacity: 1 };
+ downAnim[ ref ] = 0;
+
+ // if we are showing, force opacity 0 and set the initial position
+ // then do the "first" animation
+ el.css( "opacity", 0 )
+ .css( ref, motion ? -distance * 2 : distance * 2 )
+ .animate( downAnim, speed, easing );
+ }
+
+ // start at the smallest distance if we are hiding
+ if ( hide ) {
+ distance = distance / Math.pow( 2, times - 1 );
+ }
+
+ downAnim = {};
+ downAnim[ ref ] = 0;
+ // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
+ for ( i = 0; i < times; i++ ) {
+ upAnim = {};
+ upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
+
+ el.animate( upAnim, speed, easing )
+ .animate( downAnim, speed, easing );
+
+ distance = hide ? distance * 2 : distance / 2;
+ }
+
+ // Last Bounce when Hiding
+ if ( hide ) {
+ upAnim = { opacity: 0 };
+ upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
+
+ el.animate( upAnim, speed, easing );
+ }
+
+ el.queue(function() {
+ if ( hide ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ });
+
+ // inject all the animations we just queued to be first in line (after "inprogress")
+ if ( queuelen > 1) {
+ queue.splice.apply( queue,
+ [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
+ }
+ el.dequeue();
+
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.effects.effect.clip = function( o, done ) {
+ // Create element
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+ mode = $.effects.setMode( el, o.mode || "hide" ),
+ show = mode === "show",
+ direction = o.direction || "vertical",
+ vert = direction === "vertical",
+ size = vert ? "height" : "width",
+ position = vert ? "top" : "left",
+ animation = {},
+ wrapper, animate, distance;
+
+ // Save & Show
+ $.effects.save( el, props );
+ el.show();
+
+ // Create Wrapper
+ wrapper = $.effects.createWrapper( el ).css({
+ overflow: "hidden"
+ });
+ animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
+ distance = animate[ size ]();
+
+ // Shift
+ if ( show ) {
+ animate.css( size, 0 );
+ animate.css( position, distance / 2 );
+ }
+
+ // Create Animation Object:
+ animation[ size ] = show ? distance : 0;
+ animation[ position ] = show ? 0 : distance / 2;
+
+ // Animate
+ animate.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: function() {
+ if ( !show ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ }
+ });
+
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.effects.effect.drop = function( o, done ) {
+
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
+ mode = $.effects.setMode( el, o.mode || "hide" ),
+ show = mode === "show",
+ direction = o.direction || "left",
+ ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
+ motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
+ animation = {
+ opacity: show ? 1 : 0
+ },
+ distance;
+
+ // Adjust
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el );
+
+ distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
+
+ if ( show ) {
+ el
+ .css( "opacity", 0 )
+ .css( ref, motion === "pos" ? -distance : distance );
+ }
+
+ // Animation
+ animation[ ref ] = ( show ?
+ ( motion === "pos" ? "+=" : "-=" ) :
+ ( motion === "pos" ? "-=" : "+=" ) ) +
+ distance;
+
+ // Animate
+ el.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: function() {
+ if ( mode === "hide" ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ }
+ });
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.effects.effect.explode = function( o, done ) {
+
+ var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
+ cells = rows,
+ el = $( this ),
+ mode = $.effects.setMode( el, o.mode || "hide" ),
+ show = mode === "show",
+
+ // show and then visibility:hidden the element before calculating offset
+ offset = el.show().css( "visibility", "hidden" ).offset(),
+
+ // width and height of a piece
+ width = Math.ceil( el.outerWidth() / cells ),
+ height = Math.ceil( el.outerHeight() / rows ),
+ pieces = [],
+
+ // loop
+ i, j, left, top, mx, my;
+
+ // children animate complete:
+ function childComplete() {
+ pieces.push( this );
+ if ( pieces.length === rows * cells ) {
+ animComplete();
+ }
+ }
+
+ // clone the element for each row and cell.
+ for( i = 0; i < rows ; i++ ) { // ===>
+ top = offset.top + i * height;
+ my = i - ( rows - 1 ) / 2 ;
+
+ for( j = 0; j < cells ; j++ ) { // |||
+ left = offset.left + j * width;
+ mx = j - ( cells - 1 ) / 2 ;
+
+ // Create a clone of the now hidden main element that will be absolute positioned
+ // within a wrapper div off the -left and -top equal to size of our pieces
+ el
+ .clone()
+ .appendTo( "body" )
+ .wrap( "<div></div>" )
+ .css({
+ position: "absolute",
+ visibility: "visible",
+ left: -j * width,
+ top: -i * height
+ })
+
+ // select the wrapper - make it overflow: hidden and absolute positioned based on
+ // where the original was located +left and +top equal to the size of pieces
+ .parent()
+ .addClass( "ui-effects-explode" )
+ .css({
+ position: "absolute",
+ overflow: "hidden",
+ width: width,
+ height: height,
+ left: left + ( show ? mx * width : 0 ),
+ top: top + ( show ? my * height : 0 ),
+ opacity: show ? 0 : 1
+ }).animate({
+ left: left + ( show ? 0 : mx * width ),
+ top: top + ( show ? 0 : my * height ),
+ opacity: show ? 1 : 0
+ }, o.duration || 500, o.easing, childComplete );
+ }
+ }
+
+ function animComplete() {
+ el.css({
+ visibility: "visible"
+ });
+ $( pieces ).remove();
+ if ( !show ) {
+ el.hide();
+ }
+ done();
+ }
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.effects.effect.fade = function( o, done ) {
+ var el = $( this ),
+ mode = $.effects.setMode( el, o.mode || "toggle" );
+
+ el.animate({
+ opacity: mode
+ }, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: done
+ });
+};
+
+})( jQuery );
+(function( $, undefined ) {
+
+$.effects.effect.fold = function( o, done ) {
+
+ // Create element
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+ mode = $.effects.setMode( el, o.mode || "hide" ),
+ show = mode === "show",
+ hide = mode === "hide",
+ size = o.size || 15,
+ percent = /([0-9]+)%/.exec( size ),
+ horizFirst = !!o.horizFirst,
+ widthFirst = show !== horizFirst,
+ ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
+ duration = o.duration / 2,
+ wrapper, distance,
+ animation1 = {},
+ animation2 = {};
+
+ $.effects.save( el, props );
+ el.show();
+
+ // Create Wrapper
+ wrapper = $.effects.createWrapper( el ).css({
+ overflow: "hidden"
+ });
+ distance = widthFirst ?
+ [ wrapper.width(), wrapper.height() ] :
+ [ wrapper.height(), wrapper.width() ];
+
+ if ( percent ) {
+ size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
+ }
+ if ( show ) {
+ wrapper.css( horizFirst ? {
+ height: 0,
+ width: size
+ } : {
+ height: size,
+ width: 0
+ });
+ }
+
+ // Animation
+ animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
+ animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
+
+ // Animate
+ wrapper
+ .animate( animation1, duration, o.easing )
+ .animate( animation2, duration, o.easing, function() {
+ if ( hide ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ });
+
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.effects.effect.highlight = function( o, done ) {
+ var elem = $( this ),
+ props = [ "backgroundImage", "backgroundColor", "opacity" ],
+ mode = $.effects.setMode( elem, o.mode || "show" ),
+ animation = {
+ backgroundColor: elem.css( "backgroundColor" )
+ };
+
+ if (mode === "hide") {
+ animation.opacity = 0;
+ }
+
+ $.effects.save( elem, props );
+
+ elem
+ .show()
+ .css({
+ backgroundImage: "none",
+ backgroundColor: o.color || "#ffff99"
+ })
+ .animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: function() {
+ if ( mode === "hide" ) {
+ elem.hide();
+ }
+ $.effects.restore( elem, props );
+ done();
+ }
+ });
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.effects.effect.pulsate = function( o, done ) {
+ var elem = $( this ),
+ mode = $.effects.setMode( elem, o.mode || "show" ),
+ show = mode === "show",
+ hide = mode === "hide",
+ showhide = ( show || mode === "hide" ),
+
+ // showing or hiding leaves of the "last" animation
+ anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
+ duration = o.duration / anims,
+ animateTo = 0,
+ queue = elem.queue(),
+ queuelen = queue.length,
+ i;
+
+ if ( show || !elem.is(":visible")) {
+ elem.css( "opacity", 0 ).show();
+ animateTo = 1;
+ }
+
+ // anims - 1 opacity "toggles"
+ for ( i = 1; i < anims; i++ ) {
+ elem.animate({
+ opacity: animateTo
+ }, duration, o.easing );
+ animateTo = 1 - animateTo;
+ }
+
+ elem.animate({
+ opacity: animateTo
+ }, duration, o.easing);
+
+ elem.queue(function() {
+ if ( hide ) {
+ elem.hide();
+ }
+ done();
+ });
+
+ // We just queued up "anims" animations, we need to put them next in the queue
+ if ( queuelen > 1 ) {
+ queue.splice.apply( queue,
+ [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
+ }
+ elem.dequeue();
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.effects.effect.puff = function( o, done ) {
+ var elem = $( this ),
+ mode = $.effects.setMode( elem, o.mode || "hide" ),
+ hide = mode === "hide",
+ percent = parseInt( o.percent, 10 ) || 150,
+ factor = percent / 100,
+ original = {
+ height: elem.height(),
+ width: elem.width(),
+ outerHeight: elem.outerHeight(),
+ outerWidth: elem.outerWidth()
+ };
+
+ $.extend( o, {
+ effect: "scale",
+ queue: false,
+ fade: true,
+ mode: mode,
+ complete: done,
+ percent: hide ? percent : 100,
+ from: hide ?
+ original :
+ {
+ height: original.height * factor,
+ width: original.width * factor,
+ outerHeight: original.outerHeight * factor,
+ outerWidth: original.outerWidth * factor
+ }
+ });
+
+ elem.effect( o );
+};
+
+$.effects.effect.scale = function( o, done ) {
+
+ // Create element
+ var el = $( this ),
+ options = $.extend( true, {}, o ),
+ mode = $.effects.setMode( el, o.mode || "effect" ),
+ percent = parseInt( o.percent, 10 ) ||
+ ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
+ direction = o.direction || "both",
+ origin = o.origin,
+ original = {
+ height: el.height(),
+ width: el.width(),
+ outerHeight: el.outerHeight(),
+ outerWidth: el.outerWidth()
+ },
+ factor = {
+ y: direction !== "horizontal" ? (percent / 100) : 1,
+ x: direction !== "vertical" ? (percent / 100) : 1
+ };
+
+ // We are going to pass this effect to the size effect:
+ options.effect = "size";
+ options.queue = false;
+ options.complete = done;
+
+ // Set default origin and restore for show/hide
+ if ( mode !== "effect" ) {
+ options.origin = origin || ["middle","center"];
+ options.restore = true;
+ }
+
+ options.from = o.from || ( mode === "show" ? {
+ height: 0,
+ width: 0,
+ outerHeight: 0,
+ outerWidth: 0
+ } : original );
+ options.to = {
+ height: original.height * factor.y,
+ width: original.width * factor.x,
+ outerHeight: original.outerHeight * factor.y,
+ outerWidth: original.outerWidth * factor.x
+ };
+
+ // Fade option to support puff
+ if ( options.fade ) {
+ if ( mode === "show" ) {
+ options.from.opacity = 0;
+ options.to.opacity = 1;
+ }
+ if ( mode === "hide" ) {
+ options.from.opacity = 1;
+ options.to.opacity = 0;
+ }
+ }
+
+ // Animate
+ el.effect( options );
+
+};
+
+$.effects.effect.size = function( o, done ) {
+
+ // Create element
+ var original, baseline, factor,
+ el = $( this ),
+ props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
+
+ // Always restore
+ props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
+
+ // Copy for children
+ props2 = [ "width", "height", "overflow" ],
+ cProps = [ "fontSize" ],
+ vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
+ hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
+
+ // Set options
+ mode = $.effects.setMode( el, o.mode || "effect" ),
+ restore = o.restore || mode !== "effect",
+ scale = o.scale || "both",
+ origin = o.origin || [ "middle", "center" ],
+ position = el.css( "position" ),
+ props = restore ? props0 : props1,
+ zero = {
+ height: 0,
+ width: 0,
+ outerHeight: 0,
+ outerWidth: 0
+ };
+
+ if ( mode === "show" ) {
+ el.show();
+ }
+ original = {
+ height: el.height(),
+ width: el.width(),
+ outerHeight: el.outerHeight(),
+ outerWidth: el.outerWidth()
+ };
+
+ if ( o.mode === "toggle" && mode === "show" ) {
+ el.from = o.to || zero;
+ el.to = o.from || original;
+ } else {
+ el.from = o.from || ( mode === "show" ? zero : original );
+ el.to = o.to || ( mode === "hide" ? zero : original );
+ }
+
+ // Set scaling factor
+ factor = {
+ from: {
+ y: el.from.height / original.height,
+ x: el.from.width / original.width
+ },
+ to: {
+ y: el.to.height / original.height,
+ x: el.to.width / original.width
+ }
+ };
+
+ // Scale the css box
+ if ( scale === "box" || scale === "both" ) {
+
+ // Vertical props scaling
+ if ( factor.from.y !== factor.to.y ) {
+ props = props.concat( vProps );
+ el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
+ el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
+ }
+
+ // Horizontal props scaling
+ if ( factor.from.x !== factor.to.x ) {
+ props = props.concat( hProps );
+ el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
+ el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
+ }
+ }
+
+ // Scale the content
+ if ( scale === "content" || scale === "both" ) {
+
+ // Vertical props scaling
+ if ( factor.from.y !== factor.to.y ) {
+ props = props.concat( cProps ).concat( props2 );
+ el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
+ el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
+ }
+ }
+
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el );
+ el.css( "overflow", "hidden" ).css( el.from );
+
+ // Adjust
+ if (origin) { // Calculate baseline shifts
+ baseline = $.effects.getBaseline( origin, original );
+ el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
+ el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
+ el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
+ el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
+ }
+ el.css( el.from ); // set top & left
+
+ // Animate
+ if ( scale === "content" || scale === "both" ) { // Scale the children
+
+ // Add margins/font-size
+ vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
+ hProps = hProps.concat([ "marginLeft", "marginRight" ]);
+ props2 = props0.concat(vProps).concat(hProps);
+
+ el.find( "*[width]" ).each( function(){
+ var child = $( this ),
+ c_original = {
+ height: child.height(),
+ width: child.width(),
+ outerHeight: child.outerHeight(),
+ outerWidth: child.outerWidth()
+ };
+ if (restore) {
+ $.effects.save(child, props2);
+ }
+
+ child.from = {
+ height: c_original.height * factor.from.y,
+ width: c_original.width * factor.from.x,
+ outerHeight: c_original.outerHeight * factor.from.y,
+ outerWidth: c_original.outerWidth * factor.from.x
+ };
+ child.to = {
+ height: c_original.height * factor.to.y,
+ width: c_original.width * factor.to.x,
+ outerHeight: c_original.height * factor.to.y,
+ outerWidth: c_original.width * factor.to.x
+ };
+
+ // Vertical props scaling
+ if ( factor.from.y !== factor.to.y ) {
+ child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
+ child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
+ }
+
+ // Horizontal props scaling
+ if ( factor.from.x !== factor.to.x ) {
+ child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
+ child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
+ }
+
+ // Animate children
+ child.css( child.from );
+ child.animate( child.to, o.duration, o.easing, function() {
+
+ // Restore children
+ if ( restore ) {
+ $.effects.restore( child, props2 );
+ }
+ });
+ });
+ }
+
+ // Animate
+ el.animate( el.to, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: function() {
+ if ( el.to.opacity === 0 ) {
+ el.css( "opacity", el.from.opacity );
+ }
+ if( mode === "hide" ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ if ( !restore ) {
+
+ // we need to calculate our new positioning based on the scaling
+ if ( position === "static" ) {
+ el.css({
+ position: "relative",
+ top: el.to.top,
+ left: el.to.left
+ });
+ } else {
+ $.each([ "top", "left" ], function( idx, pos ) {
+ el.css( pos, function( _, str ) {
+ var val = parseInt( str, 10 ),
+ toRef = idx ? el.to.left : el.to.top;
+
+ // if original was "auto", recalculate the new value from wrapper
+ if ( str === "auto" ) {
+ return toRef + "px";
+ }
+
+ return val + toRef + "px";
+ });
+ });
+ }
+ }
+
+ $.effects.removeWrapper( el );
+ done();
+ }
+ });
+
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.effects.effect.shake = function( o, done ) {
+
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+ mode = $.effects.setMode( el, o.mode || "effect" ),
+ direction = o.direction || "left",
+ distance = o.distance || 20,
+ times = o.times || 3,
+ anims = times * 2 + 1,
+ speed = Math.round(o.duration/anims),
+ ref = (direction === "up" || direction === "down") ? "top" : "left",
+ positiveMotion = (direction === "up" || direction === "left"),
+ animation = {},
+ animation1 = {},
+ animation2 = {},
+ i,
+
+ // we will need to re-assemble the queue to stack our animations in place
+ queue = el.queue(),
+ queuelen = queue.length;
+
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el );
+
+ // Animation
+ animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
+ animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
+ animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
+
+ // Animate
+ el.animate( animation, speed, o.easing );
+
+ // Shakes
+ for ( i = 1; i < times; i++ ) {
+ el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
+ }
+ el
+ .animate( animation1, speed, o.easing )
+ .animate( animation, speed / 2, o.easing )
+ .queue(function() {
+ if ( mode === "hide" ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ });
+
+ // inject all the animations we just queued to be first in line (after "inprogress")
+ if ( queuelen > 1) {
+ queue.splice.apply( queue,
+ [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
+ }
+ el.dequeue();
+
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.effects.effect.slide = function( o, done ) {
+
+ // Create element
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
+ mode = $.effects.setMode( el, o.mode || "show" ),
+ show = mode === "show",
+ direction = o.direction || "left",
+ ref = (direction === "up" || direction === "down") ? "top" : "left",
+ positiveMotion = (direction === "up" || direction === "left"),
+ distance,
+ animation = {};
+
+ // Adjust
+ $.effects.save( el, props );
+ el.show();
+ distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
+
+ $.effects.createWrapper( el ).css({
+ overflow: "hidden"
+ });
+
+ if ( show ) {
+ el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
+ }
+
+ // Animation
+ animation[ ref ] = ( show ?
+ ( positiveMotion ? "+=" : "-=") :
+ ( positiveMotion ? "-=" : "+=")) +
+ distance;
+
+ // Animate
+ el.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: function() {
+ if ( mode === "hide" ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ }
+ });
+};
+
+})(jQuery);
+(function( $, undefined ) {
+
+$.effects.effect.transfer = function( o, done ) {
+ var elem = $( this ),
+ target = $( o.to ),
+ targetFixed = target.css( "position" ) === "fixed",
+ body = $("body"),
+ fixTop = targetFixed ? body.scrollTop() : 0,
+ fixLeft = targetFixed ? body.scrollLeft() : 0,
+ endPosition = target.offset(),
+ animation = {
+ top: endPosition.top - fixTop ,
+ left: endPosition.left - fixLeft ,
+ height: target.innerHeight(),
+ width: target.innerWidth()
+ },
+ startPosition = elem.offset(),
+ transfer = $( '<div class="ui-effects-transfer"></div>' )
+ .appendTo( document.body )
+ .addClass( o.className )
+ .css({
+ top: startPosition.top - fixTop ,
+ left: startPosition.left - fixLeft ,
+ height: elem.innerHeight(),
+ width: elem.innerWidth(),
+ position: targetFixed ? "fixed" : "absolute"
+ })
+ .animate( animation, o.duration, o.easing, function() {
+ transfer.remove();
+ done();
+ });
+};
+
+})(jQuery);
diff --git a/src/web/js/jqueryui/jquery-ui-1.9.2.custom.min.js b/src/web/js/jqueryui/jquery-ui-1.9.2.custom.min.js
new file mode 100644
index 0000000..345d723
--- /dev/null
+++ b/src/web/js/jqueryui/jquery-ui-1.9.2.custom.min.js
@@ -0,0 +1,6 @@
+/*! jQuery UI - v1.9.2 - 2012-12-13
+* http://jqueryui.com
+* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.menu.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js, jquery.ui.effect.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js
+* Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */
+
+(function(e,t){function i(t,n){var r,i,o,u=t.nodeName.toLowerCase();return"area"===u?(r=t.parentNode,i=r.name,!t.href||!i||r.nodeName.toLowerCase()!=="map"?!1:(o=e("img[usemap=#"+i+"]")[0],!!o&&s(o))):(/input|select|textarea|button|object/.test(u)?!t.disabled:"a"===u?t.href||n:n)&&s(t)}function s(t){return e.expr.filters.visible(t)&&!e(t).parents().andSelf().filter(function(){return e.css(this,"visibility")==="hidden"}).length}var n=0,r=/^ui-id-\d+$/;e.ui=e.ui||{};if(e.ui.version)return;e.extend(e.ui,{version:"1.9.2",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({_focus:e.fn.focus,focus:function(t,n){return typeof t=="number"?this.each(function(){var r=this;setTimeout(function(){e(r).focus(),n&&n.call(r)},t)}):this._focus.apply(this,arguments)},scrollParent:function(){var t;return e.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?t=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.css(this,"position"))&&/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0):t=this.parents().filter(function(){return/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!t.length?e(document):t},zIndex:function(n){if(n!==t)return this.css("zIndex",n);if(this.length){var r=e(this[0]),i,s;while(r.length&&r[0]!==document){i=r.css("position");if(i==="absolute"||i==="relative"||i==="fixed"){s=parseInt(r.css("zIndex"),10);if(!isNaN(s)&&s!==0)return s}r=r.parent()}}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++n)})},removeUniqueId:function(){return this.each(function(){r.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(n){return!!e.data(n,t)}}):function(t,n,r){return!!e.data(t,r[3])},focusable:function(t){return i(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var n=e.attr(t,"tabindex"),r=isNaN(n);return(r||n>=0)&&i(t,!r)}}),e(function(){var t=document.body,n=t.appendChild(n=document.createElement("div"));n.offsetHeight,e.extend(n.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),e.support.minHeight=n.offsetHeight===100,e.support.selectstart="onselectstart"in n,t.removeChild(n).style.display="none"}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(n,r){function u(t,n,r,s){return e.each(i,function(){n-=parseFloat(e.css(t,"padding"+this))||0,r&&(n-=parseFloat(e.css(t,"border"+this+"Width"))||0),s&&(n-=parseFloat(e.css(t,"margin"+this))||0)}),n}var i=r==="Width"?["Left","Right"]:["Top","Bottom"],s=r.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+r]=function(n){return n===t?o["inner"+r].call(this):this.each(function(){e(this).css(s,u(this,n)+"px")})},e.fn["outer"+r]=function(t,n){return typeof t!="number"?o["outer"+r].call(this,t):this.each(function(){e(this).css(s,u(this,t,!0,n)+"px")})}}),e("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(n){return arguments.length?t.call(this,e.camelCase(n)):t.call(this)}}(e.fn.removeData)),function(){var t=/msie ([\w.]+)/.exec(navigator.userAgent.toLowerCase())||[];e.ui.ie=t.length?!0:!1,e.ui.ie6=parseFloat(t[1],10)===6}(),e.fn.extend({disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),e.extend(e.ui,{plugin:{add:function(t,n,r){var i,s=e.ui[t].prototype;for(i in r)s.plugins[i]=s.plugins[i]||[],s.plugins[i].push([n,r[i]])},call:function(e,t,n){var r,i=e.plugins[t];if(!i||!e.element[0].parentNode||e.element[0].parentNode.nodeType===11)return;for(r=0;r<i.length;r++)e.options[i[r][0]]&&i[r][1].apply(e.element,n)}},contains:e.contains,hasScroll:function(t,n){if(e(t).css("overflow")==="hidden")return!1;var r=n&&n==="left"?"scrollLeft":"scrollTop",i=!1;return t[r]>0?!0:(t[r]=1,i=t[r]>0,t[r]=0,i)},isOverAxis:function(e,t,n){return e>t&&e<t+n},isOver:function(t,n,r,i,s,o){return e.ui.isOverAxis(t,r,s)&&e.ui.isOverAxis(n,i,o)}})})(jQuery);(function(e,t){var n=0,r=Array.prototype.slice,i=e.cleanData;e.cleanData=function(t){for(var n=0,r;(r=t[n])!=null;n++)try{e(r).triggerHandler("remove")}catch(s){}i(t)},e.widget=function(t,n,r){var i,s,o,u,a=t.split(".")[0];t=t.split(".")[1],i=a+"-"+t,r||(r=n,n=e.Widget),e.expr[":"][i.toLowerCase()]=function(t){return!!e.data(t,i)},e[a]=e[a]||{},s=e[a][t],o=e[a][t]=function(e,t){if(!this._createWidget)return new o(e,t);arguments.length&&this._createWidget(e,t)},e.extend(o,s,{version:r.version,_proto:e.extend({},r),_childConstructors:[]}),u=new n,u.options=e.widget.extend({},u.options),e.each(r,function(t,i){e.isFunction(i)&&(r[t]=function(){var e=function(){return n.prototype[t].apply(this,arguments)},r=function(e){return n.prototype[t].apply(this,e)};return function(){var t=this._super,n=this._superApply,s;return this._super=e,this._superApply=r,s=i.apply(this,arguments),this._super=t,this._superApply=n,s}}())}),o.prototype=e.widget.extend(u,{widgetEventPrefix:s?u.widgetEventPrefix:t},r,{constructor:o,namespace:a,widgetName:t,widgetBaseClass:i,widgetFullName:i}),s?(e.each(s._childConstructors,function(t,n){var r=n.prototype;e.widget(r.namespace+"."+r.widgetName,o,n._proto)}),delete s._childConstructors):n._childConstructors.push(o),e.widget.bridge(t,o)},e.widget.extend=function(n){var i=r.call(arguments,1),s=0,o=i.length,u,a;for(;s<o;s++)for(u in i[s])a=i[s][u],i[s].hasOwnProperty(u)&&a!==t&&(e.isPlainObject(a)?n[u]=e.isPlainObject(n[u])?e.widget.extend({},n[u],a):e.widget.extend({},a):n[u]=a);return n},e.widget.bridge=function(n,i){var s=i.prototype.widgetFullName||n;e.fn[n]=function(o){var u=typeof o=="string",a=r.call(arguments,1),f=this;return o=!u&&a.length?e.widget.extend.apply(null,[o].concat(a)):o,u?this.each(function(){var r,i=e.data(this,s);if(!i)return e.error("cannot call methods on "+n+" prior to initialization; "+"attempted to call method '"+o+"'");if(!e.isFunction(i[o])||o.charAt(0)==="_")return e.error("no such method '"+o+"' for "+n+" widget instance");r=i[o].apply(i,a);if(r!==i&&r!==t)return f=r&&r.jquery?f.pushStack(r.get()):r,!1}):this.each(function(){var t=e.data(this,s);t?t.option(o||{})._init():e.data(this,s,new i(o,this))}),f}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(t,r){r=e(r||this.defaultElement||this)[0],this.element=e(r),this.uuid=n++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),r!==this&&(e.data(r,this.widgetName,this),e.data(r,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===r&&this.destroy()}}),this.document=e(r.style?r.ownerDocument:r.document||r),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(n,r){var i=n,s,o,u;if(arguments.length===0)return e.widget.extend({},this.options);if(typeof n=="string"){i={},s=n.split("."),n=s.shift();if(s.length){o=i[n]=e.widget.extend({},this.options[n]);for(u=0;u<s.length-1;u++)o[s[u]]=o[s[u]]||{},o=o[s[u]];n=s.pop();if(r===t)return o[n]===t?null:o[n];o[n]=r}else{if(r===t)return this.options[n]===t?null:this.options[n];i[n]=r}}return this._setOptions(i),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,e==="disabled"&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!t).attr("aria-disabled",t),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(t,n,r){var i,s=this;typeof t!="boolean"&&(r=n,n=t,t=!1),r?(n=i=e(n),this.bindings=this.bindings.add(n)):(r=n,n=this.element,i=this.widget()),e.each(r,function(r,o){function u(){if(!t&&(s.options.disabled===!0||e(this).hasClass("ui-state-disabled")))return;return(typeof o=="string"?s[o]:o).apply(s,arguments)}typeof o!="string"&&(u.guid=o.guid=o.guid||u.guid||e.guid++);var a=r.match(/^(\w+)\s*(.*)$/),f=a[1]+s.eventNamespace,l=a[2];l?i.delegate(l,f,u):n.bind(f,u)})},_off:function(e,t){t=(t||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(t).undelegate(t)},_delay:function(e,t){function n(){return(typeof e=="string"?r[e]:e).apply(r,arguments)}var r=this;return setTimeout(n,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,n,r){var i,s,o=this.options[t];r=r||{},n=e.Event(n),n.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),n.target=this.element[0],s=n.originalEvent;if(s)for(i in s)i in n||(n[i]=s[i]);return this.element.trigger(n,r),!(e.isFunction(o)&&o.apply(this.element[0],[n].concat(r))===!1||n.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,n){e.Widget.prototype["_"+t]=function(r,i,s){typeof i=="string"&&(i={effect:i});var o,u=i?i===!0||typeof i=="number"?n:i.effect||n:t;i=i||{},typeof i=="number"&&(i={duration:i}),o=!e.isEmptyObject(i),i.complete=s,i.delay&&r.delay(i.delay),o&&e.effects&&(e.effects.effect[u]||e.uiBackCompat!==!1&&e.effects[u])?r[t](i):u!==t&&r[u]?r[u](i.duration,i.easing,s):r.queue(function(n){e(this)[t](),s&&s.call(r[0]),n()})}}),e.uiBackCompat!==!1&&(e.Widget.prototype._getCreateOptions=function(){return e.metadata&&e.metadata.get(this.element[0])[this.widgetName]})})(jQuery);(function(e,t){var n=!1;e(document).mouseup(function(e){n=!1}),e.widget("ui.mouse",{version:"1.9.2",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(n){if(!0===e.data(n.target,t.widgetName+".preventClickEvent"))return e.removeData(n.target,t.widgetName+".preventClickEvent"),n.stopImmediatePropagation(),!1}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&e(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(t){if(n)return;this._mouseStarted&&this._mouseUp(t),this._mouseDownEvent=t;var r=this,i=t.which===1,s=typeof this.options.cancel=="string"&&t.target.nodeName?e(t.target).closest(this.options.cancel).length:!1;if(!i||s||!this._mouseCapture(t))return!0;this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){r.mouseDelayMet=!0},this.options.delay));if(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)){this._mouseStarted=this._mouseStart(t)!==!1;if(!this._mouseStarted)return t.preventDefault(),!0}return!0===e.data(t.target,this.widgetName+".preventClickEvent")&&e.removeData(t.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return r._mouseMove(e)},this._mouseUpDelegate=function(e){return r._mouseUp(e)},e(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),t.preventDefault(),n=!0,!0},_mouseMove:function(t){return!e.ui.ie||document.documentMode>=9||!!t.button?this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted):this._mouseUp(t)},_mouseUp:function(t){return e(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(e){return this.mouseDelayMet},_mouseStart:function(e){},_mouseDrag:function(e){},_mouseStop:function(e){},_mouseCapture:function(e){return!0}})})(jQuery);(function(e,t){function h(e,t,n){return[parseInt(e[0],10)*(l.test(e[0])?t/100:1),parseInt(e[1],10)*(l.test(e[1])?n/100:1)]}function p(t,n){return parseInt(e.css(t,n),10)||0}e.ui=e.ui||{};var n,r=Math.max,i=Math.abs,s=Math.round,o=/left|center|right/,u=/top|center|bottom/,a=/[\+\-]\d+%?/,f=/^\w+/,l=/%$/,c=e.fn.position;e.position={scrollbarWidth:function(){if(n!==t)return n;var r,i,s=e("<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),o=s.children()[0];return e("body").append(s),r=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,r===i&&(i=s[0].clientWidth),s.remove(),n=r-i},getScrollInfo:function(t){var n=t.isWindow?"":t.element.css("overflow-x"),r=t.isWindow?"":t.element.css("overflow-y"),i=n==="scroll"||n==="auto"&&t.width<t.element[0].scrollWidth,s=r==="scroll"||r==="auto"&&t.height<t.element[0].scrollHeight;return{width:i?e.position.scrollbarWidth():0,height:s?e.position.scrollbarWidth():0}},getWithinInfo:function(t){var n=e(t||window),r=e.isWindow(n[0]);return{element:n,isWindow:r,offset:n.offset()||{left:0,top:0},scrollLeft:n.scrollLeft(),scrollTop:n.scrollTop(),width:r?n.width():n.outerWidth(),height:r?n.height():n.outerHeight()}}},e.fn.position=function(t){if(!t||!t.of)return c.apply(this,arguments);t=e.extend({},t);var n,l,d,v,m,g=e(t.of),y=e.position.getWithinInfo(t.within),b=e.position.getScrollInfo(y),w=g[0],E=(t.collision||"flip").split(" "),S={};return w.nodeType===9?(l=g.width(),d=g.height(),v={top:0,left:0}):e.isWindow(w)?(l=g.width(),d=g.height(),v={top:g.scrollTop(),left:g.scrollLeft()}):w.preventDefault?(t.at="left top",l=d=0,v={top:w.pageY,left:w.pageX}):(l=g.outerWidth(),d=g.outerHeight(),v=g.offset()),m=e.extend({},v),e.each(["my","at"],function(){var e=(t[this]||"").split(" "),n,r;e.length===1&&(e=o.test(e[0])?e.concat(["center"]):u.test(e[0])?["center"].concat(e):["center","center"]),e[0]=o.test(e[0])?e[0]:"center",e[1]=u.test(e[1])?e[1]:"center",n=a.exec(e[0]),r=a.exec(e[1]),S[this]=[n?n[0]:0,r?r[0]:0],t[this]=[f.exec(e[0])[0],f.exec(e[1])[0]]}),E.length===1&&(E[1]=E[0]),t.at[0]==="right"?m.left+=l:t.at[0]==="center"&&(m.left+=l/2),t.at[1]==="bottom"?m.top+=d:t.at[1]==="center"&&(m.top+=d/2),n=h(S.at,l,d),m.left+=n[0],m.top+=n[1],this.each(function(){var o,u,a=e(this),f=a.outerWidth(),c=a.outerHeight(),w=p(this,"marginLeft"),x=p(this,"marginTop"),T=f+w+p(this,"marginRight")+b.width,N=c+x+p(this,"marginBottom")+b.height,C=e.extend({},m),k=h(S.my,a.outerWidth(),a.outerHeight());t.my[0]==="right"?C.left-=f:t.my[0]==="center"&&(C.left-=f/2),t.my[1]==="bottom"?C.top-=c:t.my[1]==="center"&&(C.top-=c/2),C.left+=k[0],C.top+=k[1],e.support.offsetFractions||(C.left=s(C.left),C.top=s(C.top)),o={marginLeft:w,marginTop:x},e.each(["left","top"],function(r,i){e.ui.position[E[r]]&&e.ui.position[E[r]][i](C,{targetWidth:l,targetHeight:d,elemWidth:f,elemHeight:c,collisionPosition:o,collisionWidth:T,collisionHeight:N,offset:[n[0]+k[0],n[1]+k[1]],my:t.my,at:t.at,within:y,elem:a})}),e.fn.bgiframe&&a.bgiframe(),t.using&&(u=function(e){var n=v.left-C.left,s=n+l-f,o=v.top-C.top,u=o+d-c,h={target:{element:g,left:v.left,top:v.top,width:l,height:d},element:{element:a,left:C.left,top:C.top,width:f,height:c},horizontal:s<0?"left":n>0?"right":"center",vertical:u<0?"top":o>0?"bottom":"middle"};l<f&&i(n+s)<l&&(h.horizontal="center"),d<c&&i(o+u)<d&&(h.vertical="middle"),r(i(n),i(s))>r(i(o),i(u))?h.important="horizontal":h.important="vertical",t.using.call(this,e,h)}),a.offset(e.extend(C,{using:u}))})},e.ui.position={fit:{left:function(e,t){var n=t.within,i=n.isWindow?n.scrollLeft:n.offset.left,s=n.width,o=e.left-t.collisionPosition.marginLeft,u=i-o,a=o+t.collisionWidth-s-i,f;t.collisionWidth>s?u>0&&a<=0?(f=e.left+u+t.collisionWidth-s-i,e.left+=u-f):a>0&&u<=0?e.left=i:u>a?e.left=i+s-t.collisionWidth:e.left=i:u>0?e.left+=u:a>0?e.left-=a:e.left=r(e.left-o,e.left)},top:function(e,t){var n=t.within,i=n.isWindow?n.scrollTop:n.offset.top,s=t.within.height,o=e.top-t.collisionPosition.marginTop,u=i-o,a=o+t.collisionHeight-s-i,f;t.collisionHeight>s?u>0&&a<=0?(f=e.top+u+t.collisionHeight-s-i,e.top+=u-f):a>0&&u<=0?e.top=i:u>a?e.top=i+s-t.collisionHeight:e.top=i:u>0?e.top+=u:a>0?e.top-=a:e.top=r(e.top-o,e.top)}},flip:{left:function(e,t){var n=t.within,r=n.offset.left+n.scrollLeft,s=n.width,o=n.isWindow?n.scrollLeft:n.offset.left,u=e.left-t.collisionPosition.marginLeft,a=u-o,f=u+t.collisionWidth-s-o,l=t.my[0]==="left"?-t.elemWidth:t.my[0]==="right"?t.elemWidth:0,c=t.at[0]==="left"?t.targetWidth:t.at[0]==="right"?-t.targetWidth:0,h=-2*t.offset[0],p,d;if(a<0){p=e.left+l+c+h+t.collisionWidth-s-r;if(p<0||p<i(a))e.left+=l+c+h}else if(f>0){d=e.left-t.collisionPosition.marginLeft+l+c+h-o;if(d>0||i(d)<f)e.left+=l+c+h}},top:function(e,t){var n=t.within,r=n.offset.top+n.scrollTop,s=n.height,o=n.isWindow?n.scrollTop:n.offset.top,u=e.top-t.collisionPosition.marginTop,a=u-o,f=u+t.collisionHeight-s-o,l=t.my[1]==="top",c=l?-t.elemHeight:t.my[1]==="bottom"?t.elemHeight:0,h=t.at[1]==="top"?t.targetHeight:t.at[1]==="bottom"?-t.targetHeight:0,p=-2*t.offset[1],d,v;a<0?(v=e.top+c+h+p+t.collisionHeight-s-r,e.top+c+h+p>a&&(v<0||v<i(a))&&(e.top+=c+h+p)):f>0&&(d=e.top-t.collisionPosition.marginTop+c+h+p-o,e.top+c+h+p>f&&(d>0||i(d)<f)&&(e.top+=c+h+p))}},flipfit:{left:function(){e.ui.position.flip.left.apply(this,arguments),e.ui.position.fit.left.apply(this,arguments)},top:function(){e.ui.position.flip.top.apply(this,arguments),e.ui.position.fit.top.apply(this,arguments)}}},function(){var t,n,r,i,s,o=document.getElementsByTagName("body")[0],u=document.createElement("div");t=document.createElement(o?"div":"body"),r={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},o&&e.extend(r,{position:"absolute",left:"-1000px",top:"-1000px"});for(s in r)t.style[s]=r[s];t.appendChild(u),n=o||document.documentElement,n.insertBefore(t,n.firstChild),u.style.cssText="position: absolute; left: 10.7432222px;",i=e(u).offset().left,e.support.offsetFractions=i>10&&i<11,t.innerHTML="",n.removeChild(t)}(),e.uiBackCompat!==!1&&function(e){var n=e.fn.position;e.fn.position=function(r){if(!r||!r.offset)return n.call(this,r);var i=r.offset.split(" "),s=r.at.split(" ");return i.length===1&&(i[1]=i[0]),/^\d/.test(i[0])&&(i[0]="+"+i[0]),/^\d/.test(i[1])&&(i[1]="+"+i[1]),s.length===1&&(/left|center|right/.test(s[0])?s[1]="center":(s[1]=s[0],s[0]="center")),n.call(this,e.extend(r,{at:s[0]+i[0]+" "+s[1]+i[1],offset:t}))}}(jQuery)})(jQuery);(function(e,t){e.widget("ui.draggable",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1},_create:function(){this.options.helper=="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy()},_mouseCapture:function(t){var n=this.options;return this.helper||n.disabled||e(t.target).is(".ui-resizable-handle")?!1:(this.handle=this._getHandle(t),this.handle?(e(n.iframeFix===!0?"iframe":n.iframeFix).each(function(){e('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(e(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(t){var n=this.options;return this.helper=this._createHelper(t),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,n.cursorAt&&this._adjustOffsetFromHelper(n.cursorAt),n.containment&&this._setContainment(),this._trigger("start",t)===!1?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!n.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_mouseDrag:function(t,n){this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute");if(!n){var r=this._uiHash();if(this._trigger("drag",t,r)===!1)return this._mouseUp({}),!1;this.position=r.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";return e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var n=!1;e.ui.ddmanager&&!this.options.dropBehaviour&&(n=e.ui.ddmanager.drop(this,t)),this.dropped&&(n=this.dropped,this.dropped=!1);var r=this.element[0],i=!1;while(r&&(r=r.parentNode))r==document&&(i=!0);if(!i&&this.options.helper==="original")return!1;if(this.options.revert=="invalid"&&!n||this.options.revert=="valid"&&n||this.options.revert===!0||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,n)){var s=this;e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){s._trigger("stop",t)!==!1&&s._clear()})}else this._trigger("stop",t)!==!1&&this._clear();return!1},_mouseUp:function(t){return e("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(t){var n=!this.options.handle||!e(this.options.handle,this.element).length?!0:!1;return e(this.options.handle,this.element).find("*").andSelf().each(function(){this==t.target&&(n=!0)}),n},_createHelper:function(t){var n=this.options,r=e.isFunction(n.helper)?e(n.helper.apply(this.element[0],[t])):n.helper=="clone"?this.element.clone().removeAttr("id"):this.element;return r.parents("body").length||r.appendTo(n.appendTo=="parent"?this.element[0].parentNode:n.appendTo),r[0]!=this.element[0]&&!/(fixed|absolute)/.test(r.css("position"))&&r.css("position","absolute"),r},_adjustOffsetFromHelper:function(t){typeof t=="string"&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&e.ui.ie)t={top:0,left:0};return{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var e=this.element.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t=this.options;t.containment=="parent"&&(t.containment=this.helper[0].parentNode);if(t.containment=="document"||t.containment=="window")this.containment=[t.containment=="document"?0:e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,t.containment=="document"?0:e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,(t.containment=="document"?0:e(window).scrollLeft())+e(t.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(t.containment=="document"?0:e(window).scrollTop())+(e(t.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(t.containment)&&t.containment.constructor!=Array){var n=e(t.containment),r=n[0];if(!r)return;var i=n.offset(),s=e(r).css("overflow")!="hidden";this.containment=[(parseInt(e(r).css("borderLeftWidth"),10)||0)+(parseInt(e(r).css("paddingLeft"),10)||0),(parseInt(e(r).css("borderTopWidth"),10)||0)+(parseInt(e(r).css("paddingTop"),10)||0),(s?Math.max(r.scrollWidth,r.offsetWidth):r.offsetWidth)-(parseInt(e(r).css("borderLeftWidth"),10)||0)-(parseInt(e(r).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(s?Math.max(r.scrollHeight,r.offsetHeight):r.offsetHeight)-(parseInt(e(r).css("borderTopWidth"),10)||0)-(parseInt(e(r).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=n}else t.containment.constructor==Array&&(this.containment=t.containment)},_convertPositionTo:function(t,n){n||(n=this.position);var r=t=="absolute"?1:-1,i=this.options,s=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(s[0].tagName);return{top:n.top+this.offset.relative.top*r+this.offset.parent.top*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():o?0:s.scrollTop())*r,left:n.left+this.offset.relative.left*r+this.offset.parent.left*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():o?0:s.scrollLeft())*r}},_generatePosition:function(t){var n=this.options,r=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,i=/(html|body)/i.test(r[0].tagName),s=t.pageX,o=t.pageY;if(this.originalPosition){var u;if(this.containment){if(this.relative_container){var a=this.relative_container.offset();u=[this.containment[0]+a.left,this.containment[1]+a.top,this.containment[2]+a.left,this.containment[3]+a.top]}else u=this.containment;t.pageX-this.offset.click.left<u[0]&&(s=u[0]+this.offset.click.left),t.pageY-this.offset.click.top<u[1]&&(o=u[1]+this.offset.click.top),t.pageX-this.offset.click.left>u[2]&&(s=u[2]+this.offset.click.left),t.pageY-this.offset.click.top>u[3]&&(o=u[3]+this.offset.click.top)}if(n.grid){var f=n.grid[1]?this.originalPageY+Math.round((o-this.originalPageY)/n.grid[1])*n.grid[1]:this.originalPageY;o=u?f-this.offset.click.top<u[1]||f-this.offset.click.top>u[3]?f-this.offset.click.top<u[1]?f+n.grid[1]:f-n.grid[1]:f:f;var l=n.grid[0]?this.originalPageX+Math.round((s-this.originalPageX)/n.grid[0])*n.grid[0]:this.originalPageX;s=u?l-this.offset.click.left<u[0]||l-this.offset.click.left>u[2]?l-this.offset.click.left<u[0]?l+n.grid[0]:l-n.grid[0]:l:l}}return{top:o-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():i?0:r.scrollTop()),left:s-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():i?0:r.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(t,n,r){return r=r||this._uiHash(),e.ui.plugin.call(this,t,[n,r]),t=="drag"&&(this.positionAbs=this._convertPositionTo("absolute")),e.Widget.prototype._trigger.call(this,t,n,r)},plugins:{},_uiHash:function(e){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),e.ui.plugin.add("draggable","connectToSortable",{start:function(t,n){var r=e(this).data("draggable"),i=r.options,s=e.extend({},n,{item:r.element});r.sortables=[],e(i.connectToSortable).each(function(){var n=e.data(this,"sortable");n&&!n.options.disabled&&(r.sortables.push({instance:n,shouldRevert:n.options.revert}),n.refreshPositions(),n._trigger("activate",t,s))})},stop:function(t,n){var r=e(this).data("draggable"),i=e.extend({},n,{item:r.element});e.each(r.sortables,function(){this.instance.isOver?(this.instance.isOver=0,r.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=!0),this.instance._mouseStop(t),this.instance.options.helper=this.instance.options._helper,r.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",t,i))})},drag:function(t,n){var r=e(this).data("draggable"),i=this,s=function(t){var n=this.offset.click.top,r=this.offset.click.left,i=this.positionAbs.top,s=this.positionAbs.left,o=t.height,u=t.width,a=t.top,f=t.left;return e.ui.isOver(i+n,s+r,a,f,o,u)};e.each(r.sortables,function(s){var o=!1,u=this;this.instance.positionAbs=r.positionAbs,this.instance.helperProportions=r.helperProportions,this.instance.offset.click=r.offset.click,this.instance._intersectsWith(this.instance.containerCache)&&(o=!0,e.each(r.sortables,function(){return this.instance.positionAbs=r.positionAbs,this.instance.helperProportions=r.helperProportions,this.instance.offset.click=r.offset.click,this!=u&&this.instance._intersectsWith(this.instance.containerCache)&&e.ui.contains(u.instance.element[0],this.instance.element[0])&&(o=!1),o})),o?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=e(i).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return n.helper[0]},t.target=this.instance.currentItem[0],this.instance._mouseCapture(t,!0),this.instance._mouseStart(t,!0,!0),this.instance.offset.click.top=r.offset.click.top,this.instance.offset.click.left=r.offset.click.left,this.instance.offset.parent.left-=r.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=r.offset.parent.top-this.instance.offset.parent.top,r._trigger("toSortable",t),r.dropped=this.instance.element,r.currentItem=r.element,this.instance.fromOutside=r),this.instance.currentItem&&this.instance._mouseDrag(t)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",t,this.instance._uiHash(this.instance)),this.instance._mouseStop(t,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),r._trigger("fromSortable",t),r.dropped=!1)})}}),e.ui.plugin.add("draggable","cursor",{start:function(t,n){var r=e("body"),i=e(this).data("draggable").options;r.css("cursor")&&(i._cursor=r.css("cursor")),r.css("cursor",i.cursor)},stop:function(t,n){var r=e(this).data("draggable").options;r._cursor&&e("body").css("cursor",r._cursor)}}),e.ui.plugin.add("draggable","opacity",{start:function(t,n){var r=e(n.helper),i=e(this).data("draggable").options;r.css("opacity")&&(i._opacity=r.css("opacity")),r.css("opacity",i.opacity)},stop:function(t,n){var r=e(this).data("draggable").options;r._opacity&&e(n.helper).css("opacity",r._opacity)}}),e.ui.plugin.add("draggable","scroll",{start:function(t,n){var r=e(this).data("draggable");r.scrollParent[0]!=document&&r.scrollParent[0].tagName!="HTML"&&(r.overflowOffset=r.scrollParent.offset())},drag:function(t,n){var r=e(this).data("draggable"),i=r.options,s=!1;if(r.scrollParent[0]!=document&&r.scrollParent[0].tagName!="HTML"){if(!i.axis||i.axis!="x")r.overflowOffset.top+r.scrollParent[0].offsetHeight-t.pageY<i.scrollSensitivity?r.scrollParent[0].scrollTop=s=r.scrollParent[0].scrollTop+i.scrollSpeed:t.pageY-r.overflowOffset.top<i.scrollSensitivity&&(r.scrollParent[0].scrollTop=s=r.scrollParent[0].scrollTop-i.scrollSpeed);if(!i.axis||i.axis!="y")r.overflowOffset.left+r.scrollParent[0].offsetWidth-t.pageX<i.scrollSensitivity?r.scrollParent[0].scrollLeft=s=r.scrollParent[0].scrollLeft+i.scrollSpeed:t.pageX-r.overflowOffset.left<i.scrollSensitivity&&(r.scrollParent[0].scrollLeft=s=r.scrollParent[0].scrollLeft-i.scrollSpeed)}else{if(!i.axis||i.axis!="x")t.pageY-e(document).scrollTop()<i.scrollSensitivity?s=e(document).scrollTop(e(document).scrollTop()-i.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<i.scrollSensitivity&&(s=e(document).scrollTop(e(document).scrollTop()+i.scrollSpeed));if(!i.axis||i.axis!="y")t.pageX-e(document).scrollLeft()<i.scrollSensitivity?s=e(document).scrollLeft(e(document).scrollLeft()-i.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<i.scrollSensitivity&&(s=e(document).scrollLeft(e(document).scrollLeft()+i.scrollSpeed))}s!==!1&&e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(r,t)}}),e.ui.plugin.add("draggable","snap",{start:function(t,n){var r=e(this).data("draggable"),i=r.options;r.snapElements=[],e(i.snap.constructor!=String?i.snap.items||":data(draggable)":i.snap).each(function(){var t=e(this),n=t.offset();this!=r.element[0]&&r.snapElements.push({item:this,width:t.outerWidth(),height:t.outerHeight(),top:n.top,left:n.left})})},drag:function(t,n){var r=e(this).data("draggable"),i=r.options,s=i.snapTolerance,o=n.offset.left,u=o+r.helperProportions.width,a=n.offset.top,f=a+r.helperProportions.height;for(var l=r.snapElements.length-1;l>=0;l--){var c=r.snapElements[l].left,h=c+r.snapElements[l].width,p=r.snapElements[l].top,d=p+r.snapElements[l].height;if(!(c-s<o&&o<h+s&&p-s<a&&a<d+s||c-s<o&&o<h+s&&p-s<f&&f<d+s||c-s<u&&u<h+s&&p-s<a&&a<d+s||c-s<u&&u<h+s&&p-s<f&&f<d+s)){r.snapElements[l].snapping&&r.options.snap.release&&r.options.snap.release.call(r.element,t,e.extend(r._uiHash(),{snapItem:r.snapElements[l].item})),r.snapElements[l].snapping=!1;continue}if(i.snapMode!="inner"){var v=Math.abs(p-f)<=s,m=Math.abs(d-a)<=s,g=Math.abs(c-u)<=s,y=Math.abs(h-o)<=s;v&&(n.position.top=r._convertPositionTo("relative",{top:p-r.helperProportions.height,left:0}).top-r.margins.top),m&&(n.position.top=r._convertPositionTo("relative",{top:d,left:0}).top-r.margins.top),g&&(n.position.left=r._convertPositionTo("relative",{top:0,left:c-r.helperProportions.width}).left-r.margins.left),y&&(n.position.left=r._convertPositionTo("relative",{top:0,left:h}).left-r.margins.left)}var b=v||m||g||y;if(i.snapMode!="outer"){var v=Math.abs(p-a)<=s,m=Math.abs(d-f)<=s,g=Math.abs(c-o)<=s,y=Math.abs(h-u)<=s;v&&(n.position.top=r._convertPositionTo("relative",{top:p,left:0}).top-r.margins.top),m&&(n.position.top=r._convertPositionTo("relative",{top:d-r.helperProportions.height,left:0}).top-r.margins.top),g&&(n.position.left=r._convertPositionTo("relative",{top:0,left:c}).left-r.margins.left),y&&(n.position.left=r._convertPositionTo("relative",{top:0,left:h-r.helperProportions.width}).left-r.margins.left)}!r.snapElements[l].snapping&&(v||m||g||y||b)&&r.options.snap.snap&&r.options.snap.snap.call(r.element,t,e.extend(r._uiHash(),{snapItem:r.snapElements[l].item})),r.snapElements[l].snapping=v||m||g||y||b}}}),e.ui.plugin.add("draggable","stack",{start:function(t,n){var r=e(this).data("draggable").options,i=e.makeArray(e(r.stack)).sort(function(t,n){return(parseInt(e(t).css("zIndex"),10)||0)-(parseInt(e(n).css("zIndex"),10)||0)});if(!i.length)return;var s=parseInt(i[0].style.zIndex)||0;e(i).each(function(e){this.style.zIndex=s+e}),this[0].style.zIndex=s+i.length}}),e.ui.plugin.add("draggable","zIndex",{start:function(t,n){var r=e(n.helper),i=e(this).data("draggable").options;r.css("zIndex")&&(i._zIndex=r.css("zIndex")),r.css("zIndex",i.zIndex)},stop:function(t,n){var r=e(this).data("draggable").options;r._zIndex&&e(n.helper).css("zIndex",r._zIndex)}})})(jQuery);(function(e,t){e.widget("ui.droppable",{version:"1.9.2",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect"},_create:function(){var t=this.options,n=t.accept;this.isover=0,this.isout=1,this.accept=e.isFunction(n)?n:function(e){return e.is(n)},this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},e.ui.ddmanager.droppables[t.scope]=e.ui.ddmanager.droppables[t.scope]||[],e.ui.ddmanager.droppables[t.scope].push(this),t.addClasses&&this.element.addClass("ui-droppable")},_destroy:function(){var t=e.ui.ddmanager.droppables[this.options.scope];for(var n=0;n<t.length;n++)t[n]==this&&t.splice(n,1);this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(t,n){t=="accept"&&(this.accept=e.isFunction(n)?n:function(e){return e.is(n)}),e.Widget.prototype._setOption.apply(this,arguments)},_activate:function(t){var n=e.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),n&&this._trigger("activate",t,this.ui(n))},_deactivate:function(t){var n=e.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),n&&this._trigger("deactivate",t,this.ui(n))},_over:function(t){var n=e.ui.ddmanager.current;if(!n||(n.currentItem||n.element)[0]==this.element[0])return;this.accept.call(this.element[0],n.currentItem||n.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",t,this.ui(n)))},_out:function(t){var n=e.ui.ddmanager.current;if(!n||(n.currentItem||n.element)[0]==this.element[0])return;this.accept.call(this.element[0],n.currentItem||n.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",t,this.ui(n)))},_drop:function(t,n){var r=n||e.ui.ddmanager.current;if(!r||(r.currentItem||r.element)[0]==this.element[0])return!1;var i=!1;return this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var t=e.data(this,"droppable");if(t.options.greedy&&!t.options.disabled&&t.options.scope==r.options.scope&&t.accept.call(t.element[0],r.currentItem||r.element)&&e.ui.intersect(r,e.extend(t,{offset:t.element.offset()}),t.options.tolerance))return i=!0,!1}),i?!1:this.accept.call(this.element[0],r.currentItem||r.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",t,this.ui(r)),this.element):!1},ui:function(e){return{draggable:e.currentItem||e.element,helper:e.helper,position:e.position,offset:e.positionAbs}}}),e.ui.intersect=function(t,n,r){if(!n.offset)return!1;var i=(t.positionAbs||t.position.absolute).left,s=i+t.helperProportions.width,o=(t.positionAbs||t.position.absolute).top,u=o+t.helperProportions.height,a=n.offset.left,f=a+n.proportions.width,l=n.offset.top,c=l+n.proportions.height;switch(r){case"fit":return a<=i&&s<=f&&l<=o&&u<=c;case"intersect":return a<i+t.helperProportions.width/2&&s-t.helperProportions.width/2<f&&l<o+t.helperProportions.height/2&&u-t.helperProportions.height/2<c;case"pointer":var h=(t.positionAbs||t.position.absolute).left+(t.clickOffset||t.offset.click).left,p=(t.positionAbs||t.position.absolute).top+(t.clickOffset||t.offset.click).top,d=e.ui.isOver(p,h,l,a,n.proportions.height,n.proportions.width);return d;case"touch":return(o>=l&&o<=c||u>=l&&u<=c||o<l&&u>c)&&(i>=a&&i<=f||s>=a&&s<=f||i<a&&s>f);default:return!1}},e.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(t,n){var r=e.ui.ddmanager.droppables[t.options.scope]||[],i=n?n.type:null,s=(t.currentItem||t.element).find(":data(droppable)").andSelf();e:for(var o=0;o<r.length;o++){if(r[o].options.disabled||t&&!r[o].accept.call(r[o].element[0],t.currentItem||t.element))continue;for(var u=0;u<s.length;u++)if(s[u]==r[o].element[0]){r[o].proportions.height=0;continue e}r[o].visible=r[o].element.css("display")!="none";if(!r[o].visible)continue;i=="mousedown"&&r[o]._activate.call(r[o],n),r[o].offset=r[o].element.offset(),r[o].proportions={width:r[o].element[0].offsetWidth,height:r[o].element[0].offsetHeight}}},drop:function(t,n){var r=!1;return e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(!this.options)return;!this.options.disabled&&this.visible&&e.ui.intersect(t,this,this.options.tolerance)&&(r=this._drop.call(this,n)||r),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.isout=1,this.isover=0,this._deactivate.call(this,n))}),r},dragStart:function(t,n){t.element.parentsUntil("body").bind("scroll.droppable",function(){t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,n)})},drag:function(t,n){t.options.refreshPositions&&e.ui.ddmanager.prepareOffsets(t,n),e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(this.options.disabled||this.greedyChild||!this.visible)return;var r=e.ui.intersect(t,this,this.options.tolerance),i=!r&&this.isover==1?"isout":r&&this.isover==0?"isover":null;if(!i)return;var s;if(this.options.greedy){var o=this.options.scope,u=this.element.parents(":data(droppable)").filter(function(){return e.data(this,"droppable").options.scope===o});u.length&&(s=e.data(u[0],"droppable"),s.greedyChild=i=="isover"?1:0)}s&&i=="isover"&&(s.isover=0,s.isout=1,s._out.call(s,n)),this[i]=1,this[i=="isout"?"isover":"isout"]=0,this[i=="isover"?"_over":"_out"].call(this,n),s&&i=="isout"&&(s.isout=0,s.isover=1,s._over.call(s,n))})},dragStop:function(t,n){t.element.parentsUntil("body").unbind("scroll.droppable"),t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,n)}}})(jQuery);(function(e,t){e.widget("ui.resizable",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1e3},_create:function(){var t=this,n=this.options;this.element.addClass("ui-resizable"),e.extend(this,{_aspectRatio:!!n.aspectRatio,aspectRatio:n.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:n.helper||n.ghost||n.animate?n.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(e('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("resizable",this.element.data("resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=n.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se");if(this.handles.constructor==String){this.handles=="all"&&(this.handles="n,e,s,w,se,sw,ne,nw");var r=this.handles.split(",");this.handles={};for(var i=0;i<r.length;i++){var s=e.trim(r[i]),o="ui-resizable-"+s,u=e('<div class="ui-resizable-handle '+o+'"></div>');u.css({zIndex:n.zIndex}),"se"==s&&u.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[s]=".ui-resizable-"+s,this.element.append(u)}}this._renderAxis=function(t){t=t||this.element;for(var n in this.handles){this.handles[n].constructor==String&&(this.handles[n]=e(this.handles[n],this.element).show());if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var r=e(this.handles[n],this.element),i=0;i=/sw|ne|nw|se|n|s/.test(n)?r.outerHeight():r.outerWidth();var s=["padding",/ne|nw|n/.test(n)?"Top":/se|sw|s/.test(n)?"Bottom":/^e$/.test(n)?"Right":"Left"].join("");t.css(s,i),this._proportionallyResize()}if(!e(this.handles[n]).length)continue}},this._renderAxis(this.element),this._handles=e(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){if(!t.resizing){if(this.className)var e=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);t.axis=e&&e[1]?e[1]:"se"}}),n.autoHide&&(this._handles.hide(),e(this.element).addClass("ui-resizable-autohide").mouseenter(function(){if(n.disabled)return;e(this).removeClass("ui-resizable-autohide"),t._handles.show()}).mouseleave(function(){if(n.disabled)return;t.resizing||(e(this).addClass("ui-resizable-autohide"),t._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t=function(t){e(t).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){t(this.element);var n=this.element;this.originalElement.css({position:n.css("position"),width:n.outerWidth(),height:n.outerHeight(),top:n.css("top"),left:n.css("left")}).insertAfter(n),n.remove()}return this.originalElement.css("resize",this.originalResizeStyle),t(this.originalElement),this},_mouseCapture:function(t){var n=!1;for(var r in this.handles)e(this.handles[r])[0]==t.target&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(t){var r=this.options,i=this.element.position(),s=this.element;this.resizing=!0,this.documentScroll={top:e(document).scrollTop(),left:e(document).scrollLeft()},(s.is(".ui-draggable")||/absolute/.test(s.css("position")))&&s.css({position:"absolute",top:i.top,left:i.left}),this._renderProxy();var o=n(this.helper.css("left")),u=n(this.helper.css("top"));r.containment&&(o+=e(r.containment).scrollLeft()||0,u+=e(r.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:o,top:u},this.size=this._helper?{width:s.outerWidth(),height:s.outerHeight()}:{width:s.width(),height:s.height()},this.originalSize=this._helper?{width:s.outerWidth(),height:s.outerHeight()}:{width:s.width(),height:s.height()},this.originalPosition={left:o,top:u},this.sizeDiff={width:s.outerWidth()-s.width(),height:s.outerHeight()-s.height()},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio=typeof r.aspectRatio=="number"?r.aspectRatio:this.originalSize.width/this.originalSize.height||1;var a=e(".ui-resizable-"+this.axis).css("cursor");return e("body").css("cursor",a=="auto"?this.axis+"-resize":a),s.addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(e){var t=this.helper,n=this.options,r={},i=this,s=this.originalMousePosition,o=this.axis,u=e.pageX-s.left||0,a=e.pageY-s.top||0,f=this._change[o];if(!f)return!1;var l=f.apply(this,[e,u,a]);this._updateVirtualBoundaries(e.shiftKey);if(this._aspectRatio||e.shiftKey)l=this._updateRatio(l,e);return l=this._respectSize(l,e),this._propagate("resize",e),t.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"}),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),this._updateCache(l),this._trigger("resize",e,this.ui()),!1},_mouseStop:function(t){this.resizing=!1;var n=this.options,r=this;if(this._helper){var i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),o=s&&e.ui.hasScroll(i[0],"left")?0:r.sizeDiff.height,u=s?0:r.sizeDiff.width,a={width:r.helper.width()-u,height:r.helper.height()-o},f=parseInt(r.element.css("left"),10)+(r.position.left-r.originalPosition.left)||null,l=parseInt(r.element.css("top"),10)+(r.position.top-r.originalPosition.top)||null;n.animate||this.element.css(e.extend(a,{top:l,left:f})),r.helper.height(r.size.height),r.helper.width(r.size.width),this._helper&&!n.animate&&this._proportionallyResize()}return e("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(e){var t=this.options,n,i,s,o,u;u={minWidth:r(t.minWidth)?t.minWidth:0,maxWidth:r(t.maxWidth)?t.maxWidth:Infinity,minHeight:r(t.minHeight)?t.minHeight:0,maxHeight:r(t.maxHeight)?t.maxHeight:Infinity};if(this._aspectRatio||e)n=u.minHeight*this.aspectRatio,s=u.minWidth/this.aspectRatio,i=u.maxHeight*this.aspectRatio,o=u.maxWidth/this.aspectRatio,n>u.minWidth&&(u.minWidth=n),s>u.minHeight&&(u.minHeight=s),i<u.maxWidth&&(u.maxWidth=i),o<u.maxHeight&&(u.maxHeight=o);this._vBoundaries=u},_updateCache:function(e){var t=this.options;this.offset=this.helper.offset(),r(e.left)&&(this.position.left=e.left),r(e.top)&&(this.position.top=e.top),r(e.height)&&(this.size.height=e.height),r(e.width)&&(this.size.width=e.width)},_updateRatio:function(e,t){var n=this.options,i=this.position,s=this.size,o=this.axis;return r(e.height)?e.width=e.height*this.aspectRatio:r(e.width)&&(e.height=e.width/this.aspectRatio),o=="sw"&&(e.left=i.left+(s.width-e.width),e.top=null),o=="nw"&&(e.top=i.top+(s.height-e.height),e.left=i.left+(s.width-e.width)),e},_respectSize:function(e,t){var n=this.helper,i=this._vBoundaries,s=this._aspectRatio||t.shiftKey,o=this.axis,u=r(e.width)&&i.maxWidth&&i.maxWidth<e.width,a=r(e.height)&&i.maxHeight&&i.maxHeight<e.height,f=r(e.width)&&i.minWidth&&i.minWidth>e.width,l=r(e.height)&&i.minHeight&&i.minHeight>e.height;f&&(e.width=i.minWidth),l&&(e.height=i.minHeight),u&&(e.width=i.maxWidth),a&&(e.height=i.maxHeight);var c=this.originalPosition.left+this.originalSize.width,h=this.position.top+this.size.height,p=/sw|nw|w/.test(o),d=/nw|ne|n/.test(o);f&&p&&(e.left=c-i.minWidth),u&&p&&(e.left=c-i.maxWidth),l&&d&&(e.top=h-i.minHeight),a&&d&&(e.top=h-i.maxHeight);var v=!e.width&&!e.height;return v&&!e.left&&e.top?e.top=null:v&&!e.top&&e.left&&(e.left=null),e},_proportionallyResize:function(){var t=this.options;if(!this._proportionallyResizeElements.length)return;var n=this.helper||this.element;for(var r=0;r<this._proportionallyResizeElements.length;r++){var i=this._proportionallyResizeElements[r];if(!this.borderDif){var s=[i.css("borderTopWidth"),i.css("borderRightWidth"),i.css("borderBottomWidth"),i.css("borderLeftWidth")],o=[i.css("paddingTop"),i.css("paddingRight"),i.css("paddingBottom"),i.css("paddingLeft")];this.borderDif=e.map(s,function(e,t){var n=parseInt(e,10)||0,r=parseInt(o[t],10)||0;return n+r})}i.css({height:n.height()-this.borderDif[0]-this.borderDif[2]||0,width:n.width()-this.borderDif[1]-this.borderDif[3]||0})}},_renderProxy:function(){var t=this.element,n=this.options;this.elementOffset=t.offset();if(this._helper){this.helper=this.helper||e('<div style="overflow:hidden;"></div>');var r=e.ui.ie6?1:0,i=e.ui.ie6?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+i,height:this.element.outerHeight()+i,position:"absolute",left:this.elementOffset.left-r+"px",top:this.elementOffset.top-r+"px",zIndex:++n.zIndex}),this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(e,t,n){return{width:this.originalSize.width+t}},w:function(e,t,n){var r=this.options,i=this.originalSize,s=this.originalPosition;return{left:s.left+t,width:i.width-t}},n:function(e,t,n){var r=this.options,i=this.originalSize,s=this.originalPosition;return{top:s.top+n,height:i.height-n}},s:function(e,t,n){return{height:this.originalSize.height+n}},se:function(t,n,r){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,n,r]))},sw:function(t,n,r){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,n,r]))},ne:function(t,n,r){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,n,r]))},nw:function(t,n,r){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,n,r]))}},_propagate:function(t,n){e.ui.plugin.call(this,t,[n,this.ui()]),t!="resize"&&this._trigger(t,n,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","alsoResize",{start:function(t,n){var r=e(this).data("resizable"),i=r.options,s=function(t){e(t).each(function(){var t=e(this);t.data("resizable-alsoresize",{width:parseInt(t.width(),10),height:parseInt(t.height(),10),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)})})};typeof i.alsoResize=="object"&&!i.alsoResize.parentNode?i.alsoResize.length?(i.alsoResize=i.alsoResize[0],s(i.alsoResize)):e.each(i.alsoResize,function(e){s(e)}):s(i.alsoResize)},resize:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.originalSize,o=r.originalPosition,u={height:r.size.height-s.height||0,width:r.size.width-s.width||0,top:r.position.top-o.top||0,left:r.position.left-o.left||0},a=function(t,r){e(t).each(function(){var t=e(this),i=e(this).data("resizable-alsoresize"),s={},o=r&&r.length?r:t.parents(n.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(o,function(e,t){var n=(i[t]||0)+(u[t]||0);n&&n>=0&&(s[t]=n||null)}),t.css(s)})};typeof i.alsoResize=="object"&&!i.alsoResize.nodeType?e.each(i.alsoResize,function(e,t){a(e,t)}):a(i.alsoResize)},stop:function(t,n){e(this).removeData("resizable-alsoresize")}}),e.ui.plugin.add("resizable","animate",{stop:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r._proportionallyResizeElements,o=s.length&&/textarea/i.test(s[0].nodeName),u=o&&e.ui.hasScroll(s[0],"left")?0:r.sizeDiff.height,a=o?0:r.sizeDiff.width,f={width:r.size.width-a,height:r.size.height-u},l=parseInt(r.element.css("left"),10)+(r.position.left-r.originalPosition.left)||null,c=parseInt(r.element.css("top"),10)+(r.position.top-r.originalPosition.top)||null;r.element.animate(e.extend(f,c&&l?{top:c,left:l}:{}),{duration:i.animateDuration,easing:i.animateEasing,step:function(){var n={width:parseInt(r.element.css("width"),10),height:parseInt(r.element.css("height"),10),top:parseInt(r.element.css("top"),10),left:parseInt(r.element.css("left"),10)};s&&s.length&&e(s[0]).css({width:n.width,height:n.height}),r._updateCache(n),r._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(t,r){var i=e(this).data("resizable"),s=i.options,o=i.element,u=s.containment,a=u instanceof e?u.get(0):/parent/.test(u)?o.parent().get(0):u;if(!a)return;i.containerElement=e(a);if(/document/.test(u)||u==document)i.containerOffset={left:0,top:0},i.containerPosition={left:0,top:0},i.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight};else{var f=e(a),l=[];e(["Top","Right","Left","Bottom"]).each(function(e,t){l[e]=n(f.css("padding"+t))}),i.containerOffset=f.offset(),i.containerPosition=f.position(),i.containerSize={height:f.innerHeight()-l[3],width:f.innerWidth()-l[1]};var c=i.containerOffset,h=i.containerSize.height,p=i.containerSize.width,d=e.ui.hasScroll(a,"left")?a.scrollWidth:p,v=e.ui.hasScroll(a)?a.scrollHeight:h;i.parentData={element:a,left:c.left,top:c.top,width:d,height:v}}},resize:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.containerSize,o=r.containerOffset,u=r.size,a=r.position,f=r._aspectRatio||t.shiftKey,l={top:0,left:0},c=r.containerElement;c[0]!=document&&/static/.test(c.css("position"))&&(l=o),a.left<(r._helper?o.left:0)&&(r.size.width=r.size.width+(r._helper?r.position.left-o.left:r.position.left-l.left),f&&(r.size.height=r.size.width/r.aspectRatio),r.position.left=i.helper?o.left:0),a.top<(r._helper?o.top:0)&&(r.size.height=r.size.height+(r._helper?r.position.top-o.top:r.position.top),f&&(r.size.width=r.size.height*r.aspectRatio),r.position.top=r._helper?o.top:0),r.offset.left=r.parentData.left+r.position.left,r.offset.top=r.parentData.top+r.position.top;var h=Math.abs((r._helper?r.offset.left-l.left:r.offset.left-l.left)+r.sizeDiff.width),p=Math.abs((r._helper?r.offset.top-l.top:r.offset.top-o.top)+r.sizeDiff.height),d=r.containerElement.get(0)==r.element.parent().get(0),v=/relative|absolute/.test(r.containerElement.css("position"));d&&v&&(h-=r.parentData.left),h+r.size.width>=r.parentData.width&&(r.size.width=r.parentData.width-h,f&&(r.size.height=r.size.width/r.aspectRatio)),p+r.size.height>=r.parentData.height&&(r.size.height=r.parentData.height-p,f&&(r.size.width=r.size.height*r.aspectRatio))},stop:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.position,o=r.containerOffset,u=r.containerPosition,a=r.containerElement,f=e(r.helper),l=f.offset(),c=f.outerWidth()-r.sizeDiff.width,h=f.outerHeight()-r.sizeDiff.height;r._helper&&!i.animate&&/relative/.test(a.css("position"))&&e(this).css({left:l.left-u.left-o.left,width:c,height:h}),r._helper&&!i.animate&&/static/.test(a.css("position"))&&e(this).css({left:l.left-u.left-o.left,width:c,height:h})}}),e.ui.plugin.add("resizable","ghost",{start:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.size;r.ghost=r.originalElement.clone(),r.ghost.css({opacity:.25,display:"block",position:"relative",height:s.height,width:s.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof i.ghost=="string"?i.ghost:""),r.ghost.appendTo(r.helper)},resize:function(t,n){var r=e(this).data("resizable"),i=r.options;r.ghost&&r.ghost.css({position:"relative",height:r.size.height,width:r.size.width})},stop:function(t,n){var r=e(this).data("resizable"),i=r.options;r.ghost&&r.helper&&r.helper.get(0).removeChild(r.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.size,o=r.originalSize,u=r.originalPosition,a=r.axis,f=i._aspectRatio||t.shiftKey;i.grid=typeof i.grid=="number"?[i.grid,i.grid]:i.grid;var l=Math.round((s.width-o.width)/(i.grid[0]||1))*(i.grid[0]||1),c=Math.round((s.height-o.height)/(i.grid[1]||1))*(i.grid[1]||1);/^(se|s|e)$/.test(a)?(r.size.width=o.width+l,r.size.height=o.height+c):/^(ne)$/.test(a)?(r.size.width=o.width+l,r.size.height=o.height+c,r.position.top=u.top-c):/^(sw)$/.test(a)?(r.size.width=o.width+l,r.size.height=o.height+c,r.position.left=u.left-l):(r.size.width=o.width+l,r.size.height=o.height+c,r.position.top=u.top-c,r.position.left=u.left-l)}});var n=function(e){return parseInt(e,10)||0},r=function(e){return!isNaN(parseInt(e,10))}})(jQuery);(function(e,t){e.widget("ui.selectable",e.ui.mouse,{version:"1.9.2",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch"},_create:function(){var t=this;this.element.addClass("ui-selectable"),this.dragged=!1;var n;this.refresh=function(){n=e(t.options.filter,t.element[0]),n.addClass("ui-selectee"),n.each(function(){var t=e(this),n=t.offset();e.data(this,"selectable-item",{element:this,$element:t,left:n.left,top:n.top,right:n.left+t.outerWidth(),bottom:n.top+t.outerHeight(),startselected:!1,selected:t.hasClass("ui-selected"),selecting:t.hasClass("ui-selecting"),unselecting:t.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=n.addClass("ui-selectee"),this._mouseInit(),this.helper=e("<div class='ui-selectable-helper'></div>")},_destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled"),this._mouseDestroy()},_mouseStart:function(t){var n=this;this.opos=[t.pageX,t.pageY];if(this.options.disabled)return;var r=this.options;this.selectees=e(r.filter,this.element[0]),this._trigger("start",t),e(r.appendTo).append(this.helper),this.helper.css({left:t.clientX,top:t.clientY,width:0,height:0}),r.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var r=e.data(this,"selectable-item");r.startselected=!0,!t.metaKey&&!t.ctrlKey&&(r.$element.removeClass("ui-selected"),r.selected=!1,r.$element.addClass("ui-unselecting"),r.unselecting=!0,n._trigger("unselecting",t,{unselecting:r.element}))}),e(t.target).parents().andSelf().each(function(){var r=e.data(this,"selectable-item");if(r){var i=!t.metaKey&&!t.ctrlKey||!r.$element.hasClass("ui-selected");return r.$element.removeClass(i?"ui-unselecting":"ui-selected").addClass(i?"ui-selecting":"ui-unselecting"),r.unselecting=!i,r.selecting=i,r.selected=i,i?n._trigger("selecting",t,{selecting:r.element}):n._trigger("unselecting",t,{unselecting:r.element}),!1}})},_mouseDrag:function(t){var n=this;this.dragged=!0;if(this.options.disabled)return;var r=this.options,i=this.opos[0],s=this.opos[1],o=t.pageX,u=t.pageY;if(i>o){var a=o;o=i,i=a}if(s>u){var a=u;u=s,s=a}return this.helper.css({left:i,top:s,width:o-i,height:u-s}),this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!a||a.element==n.element[0])return;var f=!1;r.tolerance=="touch"?f=!(a.left>o||a.right<i||a.top>u||a.bottom<s):r.tolerance=="fit"&&(f=a.left>i&&a.right<o&&a.top>s&&a.bottom<u),f?(a.selected&&(a.$element.removeClass("ui-selected"),a.selected=!1),a.unselecting&&(a.$element.removeClass("ui-unselecting"),a.unselecting=!1),a.selecting||(a.$element.addClass("ui-selecting"),a.selecting=!0,n._trigger("selecting",t,{selecting:a.element}))):(a.selecting&&((t.metaKey||t.ctrlKey)&&a.startselected?(a.$element.removeClass("ui-selecting"),a.selecting=!1,a.$element.addClass("ui-selected"),a.selected=!0):(a.$element.removeClass("ui-selecting"),a.selecting=!1,a.startselected&&(a.$element.addClass("ui-unselecting"),a.unselecting=!0),n._trigger("unselecting",t,{unselecting:a.element}))),a.selected&&!t.metaKey&&!t.ctrlKey&&!a.startselected&&(a.$element.removeClass("ui-selected"),a.selected=!1,a.$element.addClass("ui-unselecting"),a.unselecting=!0,n._trigger("unselecting",t,{unselecting:a.element})))}),!1},_mouseStop:function(t){var n=this;this.dragged=!1;var r=this.options;return e(".ui-unselecting",this.element[0]).each(function(){var r=e.data(this,"selectable-item");r.$element.removeClass("ui-unselecting"),r.unselecting=!1,r.startselected=!1,n._trigger("unselected",t,{unselected:r.element})}),e(".ui-selecting",this.element[0]).each(function(){var r=e.data(this,"selectable-item");r.$element.removeClass("ui-selecting").addClass("ui-selected"),r.selecting=!1,r.selected=!0,r.startselected=!0,n._trigger("selected",t,{selected:r.element})}),this._trigger("stop",t),this.helper.remove(),!1}})})(jQuery);(function(e,t){e.widget("ui.sortable",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3},_create:function(){var e=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?e.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var e=this.items.length-1;e>=0;e--)this.items[e].item.removeData(this.widgetName+"-item");return this},_setOption:function(t,n){t==="disabled"?(this.options[t]=n,this.widget().toggleClass("ui-sortable-disabled",!!n)):e.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(t,n){var r=this;if(this.reverting)return!1;if(this.options.disabled||this.options.type=="static")return!1;this._refreshItems(t);var i=null,s=e(t.target).parents().each(function(){if(e.data(this,r.widgetName+"-item")==r)return i=e(this),!1});e.data(t.target,r.widgetName+"-item")==r&&(i=e(t.target));if(!i)return!1;if(this.options.handle&&!n){var o=!1;e(this.options.handle,i).find("*").andSelf().each(function(){this==t.target&&(o=!0)});if(!o)return!1}return this.currentItem=i,this._removeCurrentsFromItems(),!0},_mouseStart:function(t,n,r){var i=this.options;this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(t),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!=this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),i.containment&&this._setContainment(),i.cursor&&(e("body").css("cursor")&&(this._storedCursor=e("body").css("cursor")),e("body").css("cursor",i.cursor)),i.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",i.opacity)),i.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",i.zIndex)),this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions();if(!r)for(var s=this.containers.length-1;s>=0;s--)this.containers[s]._trigger("activate",t,this._uiHash(this));return e.ui.ddmanager&&(e.ui.ddmanager.current=this),e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(t),!0},_mouseDrag:function(t){this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs);if(this.options.scroll){var n=this.options,r=!1;this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageY<n.scrollSensitivity?this.scrollParent[0].scrollTop=r=this.scrollParent[0].scrollTop+n.scrollSpeed:t.pageY-this.overflowOffset.top<n.scrollSensitivity&&(this.scrollParent[0].scrollTop=r=this.scrollParent[0].scrollTop-n.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-t.pageX<n.scrollSensitivity?this.scrollParent[0].scrollLeft=r=this.scrollParent[0].scrollLeft+n.scrollSpeed:t.pageX-this.overflowOffset.left<n.scrollSensitivity&&(this.scrollParent[0].scrollLeft=r=this.scrollParent[0].scrollLeft-n.scrollSpeed)):(t.pageY-e(document).scrollTop()<n.scrollSensitivity?r=e(document).scrollTop(e(document).scrollTop()-n.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<n.scrollSensitivity&&(r=e(document).scrollTop(e(document).scrollTop()+n.scrollSpeed)),t.pageX-e(document).scrollLeft()<n.scrollSensitivity?r=e(document).scrollLeft(e(document).scrollLeft()-n.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<n.scrollSensitivity&&(r=e(document).scrollLeft(e(document).scrollLeft()+n.scrollSpeed))),r!==!1&&e.ui.ddmanager&&!n.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t)}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";for(var i=this.items.length-1;i>=0;i--){var s=this.items[i],o=s.item[0],u=this._intersectsWithPointer(s);if(!u)continue;if(s.instance!==this.currentContainer)continue;if(o!=this.currentItem[0]&&this.placeholder[u==1?"next":"prev"]()[0]!=o&&!e.contains(this.placeholder[0],o)&&(this.options.type=="semi-dynamic"?!e.contains(this.element[0],o):!0)){this.direction=u==1?"down":"up";if(this.options.tolerance!="pointer"&&!this._intersectsWithSides(s))break;this._rearrange(t,s),this._trigger("change",t,this._uiHash());break}}return this._contactContainers(t),e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),this._trigger("sort",t,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(t,n){if(!t)return;e.ui.ddmanager&&!this.options.dropBehaviour&&e.ui.ddmanager.drop(this,t);if(this.options.revert){var r=this,i=this.placeholder.offset();this.reverting=!0,e(this.helper).animate({left:i.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:i.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){r._clear(t)})}else this._clear(t,n);return!1},cancel:function(){if(this.dragging){this._mouseUp({target:null}),this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var t=this.containers.length-1;t>=0;t--)this.containers[t]._trigger("deactivate",null,this._uiHash(this)),this.containers[t].containerCache.over&&(this.containers[t]._trigger("out",null,this._uiHash(this)),this.containers[t].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),e.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?e(this.domPosition.prev).after(this.currentItem):e(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(t){var n=this._getItemsAsjQuery(t&&t.connected),r=[];return t=t||{},e(n).each(function(){var n=(e(t.item||this).attr(t.attribute||"id")||"").match(t.expression||/(.+)[-=_](.+)/);n&&r.push((t.key||n[1]+"[]")+"="+(t.key&&t.expression?n[1]:n[2]))}),!r.length&&t.key&&r.push(t.key+"="),r.join("&")},toArray:function(t){var n=this._getItemsAsjQuery(t&&t.connected),r=[];return t=t||{},n.each(function(){r.push(e(t.item||this).attr(t.attribute||"id")||"")}),r},_intersectsWith:function(e){var t=this.positionAbs.left,n=t+this.helperProportions.width,r=this.positionAbs.top,i=r+this.helperProportions.height,s=e.left,o=s+e.width,u=e.top,a=u+e.height,f=this.offset.click.top,l=this.offset.click.left,c=r+f>u&&r+f<a&&t+l>s&&t+l<o;return this.options.tolerance=="pointer"||this.options.forcePointerForContainers||this.options.tolerance!="pointer"&&this.helperProportions[this.floating?"width":"height"]>e[this.floating?"width":"height"]?c:s<t+this.helperProportions.width/2&&n-this.helperProportions.width/2<o&&u<r+this.helperProportions.height/2&&i-this.helperProportions.height/2<a},_intersectsWithPointer:function(t){var n=this.options.axis==="x"||e.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,t.top,t.height),r=this.options.axis==="y"||e.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,t.left,t.width),i=n&&r,s=this._getDragVerticalDirection(),o=this._getDragHorizontalDirection();return i?this.floating?o&&o=="right"||s=="down"?2:1:s&&(s=="down"?2:1):!1},_intersectsWithSides:function(t){var n=e.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),r=e.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),i=this._getDragVerticalDirection(),s=this._getDragHorizontalDirection();return this.floating&&s?s=="right"&&r||s=="left"&&!r:i&&(i=="down"&&n||i=="up"&&!n)},_getDragVerticalDirection:function(){var e=this.positionAbs.top-this.lastPositionAbs.top;return e!=0&&(e>0?"down":"up")},_getDragHorizontalDirection:function(){var e=this.positionAbs.left-this.lastPositionAbs.left;return e!=0&&(e>0?"right":"left")},refresh:function(e){return this._refreshItems(e),this.refreshPositions(),this},_connectWith:function(){var e=this.options;return e.connectWith.constructor==String?[e.connectWith]:e.connectWith},_getItemsAsjQuery:function(t){var n=[],r=[],i=this._connectWith();if(i&&t)for(var s=i.length-1;s>=0;s--){var o=e(i[s]);for(var u=o.length-1;u>=0;u--){var a=e.data(o[u],this.widgetName);a&&a!=this&&!a.options.disabled&&r.push([e.isFunction(a.options.items)?a.options.items.call(a.element):e(a.options.items,a.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),a])}}r.push([e.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):e(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(var s=r.length-1;s>=0;s--)r[s][0].each(function(){n.push(this)});return e(n)},_removeCurrentsFromItems:function(){var t=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=e.grep(this.items,function(e){for(var n=0;n<t.length;n++)if(t[n]==e.item[0])return!1;return!0})},_refreshItems:function(t){this.items=[],this.containers=[this];var n=this.items,r=[[e.isFunction(this.options.items)?this.options.items.call(this.element[0],t,{item:this.currentItem}):e(this.options.items,this.element),this]],i=this._connectWith();if(i&&this.ready)for(var s=i.length-1;s>=0;s--){var o=e(i[s]);for(var u=o.length-1;u>=0;u--){var a=e.data(o[u],this.widgetName);a&&a!=this&&!a.options.disabled&&(r.push([e.isFunction(a.options.items)?a.options.items.call(a.element[0],t,{item:this.currentItem}):e(a.options.items,a.element),a]),this.containers.push(a))}}for(var s=r.length-1;s>=0;s--){var f=r[s][1],l=r[s][0];for(var u=0,c=l.length;u<c;u++){var h=e(l[u]);h.data(this.widgetName+"-item",f),n.push({item:h,instance:f,width:0,height:0,left:0,top:0})}}},refreshPositions:function(t){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());for(var n=this.items.length-1;n>=0;n--){var r=this.items[n];if(r.instance!=this.currentContainer&&this.currentContainer&&r.item[0]!=this.currentItem[0])continue;var i=this.options.toleranceElement?e(this.options.toleranceElement,r.item):r.item;t||(r.width=i.outerWidth(),r.height=i.outerHeight());var s=i.offset();r.left=s.left,r.top=s.top}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(var n=this.containers.length-1;n>=0;n--){var s=this.containers[n].element.offset();this.containers[n].containerCache.left=s.left,this.containers[n].containerCache.top=s.top,this.containers[n].containerCache.width=this.containers[n].element.outerWidth(),this.containers[n].containerCache.height=this.containers[n].element.outerHeight()}return this},_createPlaceholder:function(t){t=t||this;var n=t.options;if(!n.placeholder||n.placeholder.constructor==String){var r=n.placeholder;n.placeholder={element:function(){var n=e(document.createElement(t.currentItem[0].nodeName)).addClass(r||t.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];return r||(n.style.visibility="hidden"),n},update:function(e,i){if(r&&!n.forcePlaceholderSize)return;i.height()||i.height(t.currentItem.innerHeight()-parseInt(t.currentItem.css("paddingTop")||0,10)-parseInt(t.currentItem.css("paddingBottom")||0,10)),i.width()||i.width(t.currentItem.innerWidth()-parseInt(t.currentItem.css("paddingLeft")||0,10)-parseInt(t.currentItem.css("paddingRight")||0,10))}}}t.placeholder=e(n.placeholder.element.call(t.element,t.currentItem)),t.currentItem.after(t.placeholder),n.placeholder.update(t,t.placeholder)},_contactContainers:function(t){var n=null,r=null;for(var i=this.containers.length-1;i>=0;i--){if(e.contains(this.currentItem[0],this.containers[i].element[0]))continue;if(this._intersectsWith(this.containers[i].containerCache)){if(n&&e.contains(this.containers[i].element[0],n.element[0]))continue;n=this.containers[i],r=i}else this.containers[i].containerCache.over&&(this.containers[i]._trigger("out",t,this._uiHash(this)),this.containers[i].containerCache.over=0)}if(!n)return;if(this.containers.length===1)this.containers[r]._trigger("over",t,this._uiHash(this)),this.containers[r].containerCache.over=1;else{var s=1e4,o=null,u=this.containers[r].floating?"left":"top",a=this.containers[r].floating?"width":"height",f=this.positionAbs[u]+this.offset.click[u];for(var l=this.items.length-1;l>=0;l--){if(!e.contains(this.containers[r].element[0],this.items[l].item[0]))continue;if(this.items[l].item[0]==this.currentItem[0])continue;var c=this.items[l].item.offset()[u],h=!1;Math.abs(c-f)>Math.abs(c+this.items[l][a]-f)&&(h=!0,c+=this.items[l][a]),Math.abs(c-f)<s&&(s=Math.abs(c-f),o=this.items[l],this.direction=h?"up":"down")}if(!o&&!this.options.dropOnEmpty)return;this.currentContainer=this.containers[r],o?this._rearrange(t,o,null,!0):this._rearrange(t,null,this.containers[r].element,!0),this._trigger("change",t,this._uiHash()),this.containers[r]._trigger("change",t,this._uiHash(this)),this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[r]._trigger("over",t,this._uiHash(this)),this.containers[r].containerCache.over=1}},_createHelper:function(t){var n=this.options,r=e.isFunction(n.helper)?e(n.helper.apply(this.element[0],[t,this.currentItem])):n.helper=="clone"?this.currentItem.clone():this.currentItem;return r.parents("body").length||e(n.appendTo!="parent"?n.appendTo:this.currentItem[0].parentNode)[0].appendChild(r[0]),r[0]==this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(r[0].style.width==""||n.forceHelperSize)&&r.width(this.currentItem.width()),(r[0].style.height==""||n.forceHelperSize)&&r.height(this.currentItem.height()),r},_adjustOffsetFromHelper:function(t){typeof t=="string"&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&e.ui.ie)t={top:0,left:0};return{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var e=this.currentItem.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t=this.options;t.containment=="parent"&&(t.containment=this.helper[0].parentNode);if(t.containment=="document"||t.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,e(t.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(e(t.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(t.containment)){var n=e(t.containment)[0],r=e(t.containment).offset(),i=e(n).css("overflow")!="hidden";this.containment=[r.left+(parseInt(e(n).css("borderLeftWidth"),10)||0)+(parseInt(e(n).css("paddingLeft"),10)||0)-this.margins.left,r.top+(parseInt(e(n).css("borderTopWidth"),10)||0)+(parseInt(e(n).css("paddingTop"),10)||0)-this.margins.top,r.left+(i?Math.max(n.scrollWidth,n.offsetWidth):n.offsetWidth)-(parseInt(e(n).css("borderLeftWidth"),10)||0)-(parseInt(e(n).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,r.top+(i?Math.max(n.scrollHeight,n.offsetHeight):n.offsetHeight)-(parseInt(e(n).css("borderTopWidth"),10)||0)-(parseInt(e(n).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(t,n){n||(n=this.position);var r=t=="absolute"?1:-1,i=this.options,s=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(s[0].tagName);return{top:n.top+this.offset.relative.top*r+this.offset.parent.top*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():o?0:s.scrollTop())*r,left:n.left+this.offset.relative.left*r+this.offset.parent.left*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():o?0:s.scrollLeft())*r}},_generatePosition:function(t){var n=this.options,r=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,i=/(html|body)/i.test(r[0].tagName);this.cssPosition=="relative"&&(this.scrollParent[0]==document||this.scrollParent[0]==this.offsetParent[0])&&(this.offset.relative=this._getRelativeOffset());var s=t.pageX,o=t.pageY;if(this.originalPosition){this.containment&&(t.pageX-this.offset.click.left<this.containment[0]&&(s=this.containment[0]+this.offset.click.left),t.pageY-this.offset.click.top<this.containment[1]&&(o=this.containment[1]+this.offset.click.top),t.pageX-this.offset.click.left>this.containment[2]&&(s=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(o=this.containment[3]+this.offset.click.top));if(n.grid){var u=this.originalPageY+Math.round((o-this.originalPageY)/n.grid[1])*n.grid[1];o=this.containment?u-this.offset.click.top<this.containment[1]||u-this.offset.click.top>this.containment[3]?u-this.offset.click.top<this.containment[1]?u+n.grid[1]:u-n.grid[1]:u:u;var a=this.originalPageX+Math.round((s-this.originalPageX)/n.grid[0])*n.grid[0];s=this.containment?a-this.offset.click.left<this.containment[0]||a-this.offset.click.left>this.containment[2]?a-this.offset.click.left<this.containment[0]?a+n.grid[0]:a-n.grid[0]:a:a}}return{top:o-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():i?0:r.scrollTop()),left:s-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():i?0:r.scrollLeft())}},_rearrange:function(e,t,n,r){n?n[0].appendChild(this.placeholder[0]):t.item[0].parentNode.insertBefore(this.placeholder[0],this.direction=="down"?t.item[0]:t.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var i=this.counter;this._delay(function(){i==this.counter&&this.refreshPositions(!r)})},_clear:function(t,n){this.reverting=!1;var r=[];!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var i in this._storedCSS)if(this._storedCSS[i]=="auto"||this._storedCSS[i]=="static")this._storedCSS[i]="";this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();this.fromOutside&&!n&&r.push(function(e){this._trigger("receive",e,this._uiHash(this.fromOutside))}),(this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!n&&r.push(function(e){this._trigger("update",e,this._uiHash())}),this!==this.currentContainer&&(n||(r.push(function(e){this._trigger("remove",e,this._uiHash())}),r.push(function(e){return function(t){e._trigger("receive",t,this._uiHash(this))}}.call(this,this.currentContainer)),r.push(function(e){return function(t){e._trigger("update",t,this._uiHash(this))}}.call(this,this.currentContainer))));for(var i=this.containers.length-1;i>=0;i--)n||r.push(function(e){return function(t){e._trigger("deactivate",t,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over&&(r.push(function(e){return function(t){e._trigger("out",t,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over=0);this._storedCursor&&e("body").css("cursor",this._storedCursor),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex),this.dragging=!1;if(this.cancelHelperRemoval){if(!n){this._trigger("beforeStop",t,this._uiHash());for(var i=0;i<r.length;i++)r[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!1}n||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!=this.currentItem[0]&&this.helper.remove(),this.helper=null;if(!n){for(var i=0;i<r.length;i++)r[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){e.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(t){var n=t||this;return{helper:n.helper,placeholder:n.placeholder||e([]),position:n.position,originalPosition:n.originalPosition,offset:n.positionAbs,item:n.currentItem,sender:t?t.element:null}}})})(jQuery);(function(e,t){var n=0,r={},i={};r.height=r.paddingTop=r.paddingBottom=r.borderTopWidth=r.borderBottomWidth="hide",i.height=i.paddingTop=i.paddingBottom=i.borderTopWidth=i.borderBottomWidth="show",e.widget("ui.accordion",{version:"1.9.2",options:{active:0,animate:{},collapsible:!1,event:"click",header:"> li > :first-child,> :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},_create:function(){var t=this.accordionId="ui-accordion-"+(this.element.attr("id")||++n),r=this.options;this.prevShow=this.prevHide=e(),this.element.addClass("ui-accordion ui-widget ui-helper-reset"),this.headers=this.element.find(r.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"),this._hoverable(this.headers),this._focusable(this.headers),this.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").hide(),!r.collapsible&&(r.active===!1||r.active==null)&&(r.active=0),r.active<0&&(r.active+=this.headers.length),this.active=this._findActive(r.active).addClass("ui-accordion-header-active ui-state-active").toggleClass("ui-corner-all ui-corner-top"),this.active.next().addClass("ui-accordion-content-active").show(),this._createIcons(),this.refresh(),this.element.attr("role","tablist"),this.headers.attr("role","tab").each(function(n){var r=e(this),i=r.attr("id"),s=r.next(),o=s.attr("id");i||(i=t+"-header-"+n,r.attr("id",i)),o||(o=t+"-panel-"+n,s.attr("id",o)),r.attr("aria-controls",o),s.attr("aria-labelledby",i)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false",tabIndex:-1}).next().attr({"aria-expanded":"false","aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true",tabIndex:0}).next().attr({"aria-expanded":"true","aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._on(this.headers,{keydown:"_keydown"}),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._setupEvents(r.event)},_getCreateEventData:function(){return{header:this.active,content:this.active.length?this.active.next():e()}},_createIcons:function(){var t=this.options.icons;t&&(e("<span>").addClass("ui-accordion-header-icon ui-icon "+t.header).prependTo(this.headers),this.active.children(".ui-accordion-header-icon").removeClass(t.header).addClass(t.activeHeader),this.headers.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.removeClass("ui-accordion-icons").children(".ui-accordion-header-icon").remove()},_destroy:function(){var e;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.removeClass("ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("tabIndex").each(function(){/^ui-accordion/.test(this.id)&&this.removeAttribute("id")}),this._destroyIcons(),e=this.headers.next().css("display","").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled").each(function(){/^ui-accordion/.test(this.id)&&this.removeAttribute("id")}),this.options.heightStyle!=="content"&&e.css("height","")},_setOption:function(e,t){if(e==="active"){this._activate(t);return}e==="event"&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(t)),this._super(e,t),e==="collapsible"&&!t&&this.options.active===!1&&this._activate(0),e==="icons"&&(this._destroyIcons(),t&&this._createIcons()),e==="disabled"&&this.headers.add(this.headers.next()).toggleClass("ui-state-disabled",!!t)},_keydown:function(t){if(t.altKey||t.ctrlKey)return;var n=e.ui.keyCode,r=this.headers.length,i=this.headers.index(t.target),s=!1;switch(t.keyCode){case n.RIGHT:case n.DOWN:s=this.headers[(i+1)%r];break;case n.LEFT:case n.UP:s=this.headers[(i-1+r)%r];break;case n.SPACE:case n.ENTER:this._eventHandler(t);break;case n.HOME:s=this.headers[0];break;case n.END:s=this.headers[r-1]}s&&(e(t.target).attr("tabIndex",-1),e(s).attr("tabIndex",0),s.focus(),t.preventDefault())},_panelKeyDown:function(t){t.keyCode===e.ui.keyCode.UP&&t.ctrlKey&&e(t.currentTarget).prev().focus()},refresh:function(){var t,n,r=this.options.heightStyle,i=this.element.parent();r==="fill"?(e.support.minHeight||(n=i.css("overflow"),i.css("overflow","hidden")),t=i.height(),this.element.siblings(":visible").each(function(){var n=e(this),r=n.css("position");if(r==="absolute"||r==="fixed")return;t-=n.outerHeight(!0)}),n&&i.css("overflow",n),this.headers.each(function(){t-=e(this).outerHeight(!0)}),this.headers.next().each(function(){e(this).height(Math.max(0,t-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):r==="auto"&&(t=0,this.headers.next().each(function(){t=Math.max(t,e(this).css("height","").height())}).height(t))},_activate:function(t){var n=this._findActive(t)[0];if(n===this.active[0])return;n=n||this.active[0],this._eventHandler({target:n,currentTarget:n,preventDefault:e.noop})},_findActive:function(t){return typeof t=="number"?this.headers.eq(t):e()},_setupEvents:function(t){var n={};if(!t)return;e.each(t.split(" "),function(e,t){n[t]="_eventHandler"}),this._on(this.headers,n)},_eventHandler:function(t){var n=this.options,r=this.active,i=e(t.currentTarget),s=i[0]===r[0],o=s&&n.collapsible,u=o?e():i.next(),a=r.next(),f={oldHeader:r,oldPanel:a,newHeader:o?e():i,newPanel:u};t.preventDefault();if(s&&!n.collapsible||this._trigger("beforeActivate",t,f)===!1)return;n.active=o?!1:this.headers.index(i),this.active=s?e():i,this._toggle(f),r.removeClass("ui-accordion-header-active ui-state-active"),n.icons&&r.children(".ui-accordion-header-icon").removeClass(n.icons.activeHeader).addClass(n.icons.header),s||(i.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"),n.icons&&i.children(".ui-accordion-header-icon").removeClass(n.icons.header).addClass(n.icons.activeHeader),i.next().addClass("ui-accordion-content-active"))},_toggle:function(t){var n=t.newPanel,r=this.prevShow.length?this.prevShow:t.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=n,this.prevHide=r,this.options.animate?this._animate(n,r,t):(r.hide(),n.show(),this._toggleComplete(t)),r.attr({"aria-expanded":"false","aria-hidden":"true"}),r.prev().attr("aria-selected","false"),n.length&&r.length?r.prev().attr("tabIndex",-1):n.length&&this.headers.filter(function(){return e(this).attr("tabIndex")===0}).attr("tabIndex",-1),n.attr({"aria-expanded":"true","aria-hidden":"false"}).prev().attr({"aria-selected":"true",tabIndex:0})},_animate:function(e,t,n){var s,o,u,a=this,f=0,l=e.length&&(!t.length||e.index()<t.index()),c=this.options.animate||{},h=l&&c.down||c,p=function(){a._toggleComplete(n)};typeof h=="number"&&(u=h),typeof h=="string"&&(o=h),o=o||h.easing||c.easing,u=u||h.duration||c.duration;if(!t.length)return e.animate(i,u,o,p);if(!e.length)return t.animate(r,u,o,p);s=e.show().outerHeight(),t.animate(r,{duration:u,easing:o,step:function(e,t){t.now=Math.round(e)}}),e.hide().animate(i,{duration:u,easing:o,complete:p,step:function(e,n){n.now=Math.round(e),n.prop!=="height"?f+=n.now:a.options.heightStyle!=="content"&&(n.now=Math.round(s-t.outerHeight()-f),f=0)}})},_toggleComplete:function(e){var t=e.oldPanel;t.removeClass("ui-accordion-content-active").prev().removeClass("ui-corner-top").addClass("ui-corner-all"),t.length&&(t.parent()[0].className=t.parent()[0].className),this._trigger("activate",null,e)}}),e.uiBackCompat!==!1&&(function(e,t){e.extend(t.options,{navigation:!1,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}});var n=t._create;t._create=function(){if(this.options.navigation){var t=this,r=this.element.find(this.options.header),i=r.next(),s=r.add(i).find("a").filter(this.options.navigationFilter)[0];s&&r.add(i).each(function(n){if(e.contains(this,s))return t.options.active=Math.floor(n/2),!1})}n.call(this)}}(jQuery,jQuery.ui.accordion.prototype),function(e,t){e.extend(t.options,{heightStyle:null,autoHeight:!0,clearStyle:!1,fillSpace:!1});var n=t._create,r=t._setOption;e.extend(t,{_create:function(){this.options.heightStyle=this.options.heightStyle||this._mergeHeightStyle(),n.call(this)},_setOption:function(e){if(e==="autoHeight"||e==="clearStyle"||e==="fillSpace")this.options.heightStyle=this._mergeHeightStyle();r.apply(this,arguments)},_mergeHeightStyle:function(){var e=this.options;if(e.fillSpace)return"fill";if(e.clearStyle)return"content";if(e.autoHeight)return"auto"}})}(jQuery,jQuery.ui.accordion.prototype),function(e,t){e.extend(t.options.icons,{activeHeader:null,headerSelected:"ui-icon-triangle-1-s"});var n=t._createIcons;t._createIcons=function(){this.options.icons&&(this.options.icons.activeHeader=this.options.icons.activeHeader||this.options.icons.headerSelected),n.call(this)}}(jQuery,jQuery.ui.accordion.prototype),function(e,t){t.activate=t._activate;var n=t._findActive;t._findActive=function(e){return e===-1&&(e=!1),e&&typeof e!="number"&&(e=this.headers.index(this.headers.filter(e)),e===-1&&(e=!1)),n.call(this,e)}}(jQuery,jQuery.ui.accordion.prototype),jQuery.ui.accordion.prototype.resize=jQuery.ui.accordion.prototype.refresh,function(e,t){e.extend(t.options,{change:null,changestart:null});var n=t._trigger;t._trigger=function(e,t,r){var i=n.apply(this,arguments);return i?(e==="beforeActivate"?i=n.call(this,"changestart",t,{oldHeader:r.oldHeader,oldContent:r.oldPanel,newHeader:r.newHeader,newContent:r.newPanel}):e==="activate"&&(i=n.call(this,"change",t,{oldHeader:r.oldHeader,oldContent:r.oldPanel,newHeader:r.newHeader,newContent:r.newPanel})),i):!1}}(jQuery,jQuery.ui.accordion.prototype),function(e,t){e.extend(t.options,{animate:null,animated:"slide"});var n=t._create;t._create=function(){var e=this.options;e.animate===null&&(e.animated?e.animated==="slide"?e.animate=300:e.animated==="bounceslide"?e.animate={duration:200,down:{easing:"easeOutBounce",duration:1e3}}:e.animate=e.animated:e.animate=!1),n.call(this)}}(jQuery,jQuery.ui.accordion.prototype))})(jQuery);(function(e,t){var n=0;e.widget("ui.autocomplete",{version:"1.9.2",defaultElement:"<input>",options:{appendTo:"body",autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},pending:0,_create:function(){var t,n,r;this.isMultiLine=this._isMultiLine(),this.valueMethod=this.element[this.element.is("input,textarea")?"val":"text"],this.isNewMenu=!0,this.element.addClass("ui-autocomplete-input").attr("autocomplete","off"),this._on(this.element,{keydown:function(i){if(this.element.prop("readOnly")){t=!0,r=!0,n=!0;return}t=!1,r=!1,n=!1;var s=e.ui.keyCode;switch(i.keyCode){case s.PAGE_UP:t=!0,this._move("previousPage",i);break;case s.PAGE_DOWN:t=!0,this._move("nextPage",i);break;case s.UP:t=!0,this._keyEvent("previous",i);break;case s.DOWN:t=!0,this._keyEvent("next",i);break;case s.ENTER:case s.NUMPAD_ENTER:this.menu.active&&(t=!0,i.preventDefault(),this.menu.select(i));break;case s.TAB:this.menu.active&&this.menu.select(i);break;case s.ESCAPE:this.menu.element.is(":visible")&&(this._value(this.term),this.close(i),i.preventDefault());break;default:n=!0,this._searchTimeout(i)}},keypress:function(r){if(t){t=!1,r.preventDefault();return}if(n)return;var i=e.ui.keyCode;switch(r.keyCode){case i.PAGE_UP:this._move("previousPage",r);break;case i.PAGE_DOWN:this._move("nextPage",r);break;case i.UP:this._keyEvent("previous",r);break;case i.DOWN:this._keyEvent("next",r)}},input:function(e){if(r){r=!1,e.preventDefault();return}this._searchTimeout(e)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(e){if(this.cancelBlur){delete this.cancelBlur;return}clearTimeout(this.searching),this.close(e),this._change(e)}}),this._initSource(),this.menu=e("<ul>").addClass("ui-autocomplete").appendTo(this.document.find(this.options.appendTo||"body")[0]).menu({input:e(),role:null}).zIndex(this.element.zIndex()+1).hide().data("menu"),this._on(this.menu.element,{mousedown:function(t){t.preventDefault(),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur});var n=this.menu.element[0];e(t.target).closest(".ui-menu-item").length||this._delay(function(){var t=this;this.document.one("mousedown",function(r){r.target!==t.element[0]&&r.target!==n&&!e.contains(n,r.target)&&t.close()})})},menufocus:function(t,n){if(this.isNewMenu){this.isNewMenu=!1;if(t.originalEvent&&/^mouse/.test(t.originalEvent.type)){this.menu.blur(),this.document.one("mousemove",function(){e(t.target).trigger(t.originalEvent)});return}}var r=n.item.data("ui-autocomplete-item")||n.item.data("item.autocomplete");!1!==this._trigger("focus",t,{item:r})?t.originalEvent&&/^key/.test(t.originalEvent.type)&&this._value(r.value):this.liveRegion.text(r.value)},menuselect:function(e,t){var n=t.item.data("ui-autocomplete-item")||t.item.data("item.autocomplete"),r=this.previous;this.element[0]!==this.document[0].activeElement&&(this.element.focus(),this.previous=r,this._delay(function(){this.previous=r,this.selectedItem=n})),!1!==this._trigger("select",e,{item:n})&&this._value(n.value),this.term=this._value(),this.close(e),this.selectedItem=n}}),this.liveRegion=e("<span>",{role:"status","aria-live":"polite"}).addClass("ui-helper-hidden-accessible").insertAfter(this.element),e.fn.bgiframe&&this.menu.element.bgiframe(),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_destroy:function(){clearTimeout(this.searching),this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete"),this.menu.element.remove(),this.liveRegion.remove()},_setOption:function(e,t){this._super(e,t),e==="source"&&this._initSource(),e==="appendTo"&&this.menu.element.appendTo(this.document.find(t||"body")[0]),e==="disabled"&&t&&this.xhr&&this.xhr.abort()},_isMultiLine:function(){return this.element.is("textarea")?!0:this.element.is("input")?!1:this.element.prop("isContentEditable")},_initSource:function(){var t,n,r=this;e.isArray(this.options.source)?(t=this.options.source,this.source=function(n,r){r(e.ui.autocomplete.filter(t,n.term))}):typeof this.options.source=="string"?(n=this.options.source,this.source=function(t,i){r.xhr&&r.xhr.abort(),r.xhr=e.ajax({url:n,data:t,dataType:"json",success:function(e){i(e)},error:function(){i([])}})}):this.source=this.options.source},_searchTimeout:function(e){clearTimeout(this.searching),this.searching=this._delay(function(){this.term!==this._value()&&(this.selectedItem=null,this.search(null,e))},this.options.delay)},search:function(e,t){e=e!=null?e:this._value(),this.term=this._value();if(e.length<this.options.minLength)return this.close(t);if(this._trigger("search",t)===!1)return;return this._search(e)},_search:function(e){this.pending++,this.element.addClass("ui-autocomplete-loading"),this.cancelSearch=!1,this.source({term:e},this._response())},_response:function(){var e=this,t=++n;return function(r){t===n&&e.__response(r),e.pending--,e.pending||e.element.removeClass("ui-autocomplete-loading")}},__response:function(e){e&&(e=this._normalize(e)),this._trigger("response",null,{content:e}),!this.options.disabled&&e&&e.length&&!this.cancelSearch?(this._suggest(e),this._trigger("open")):this._close()},close:function(e){this.cancelSearch=!0,this._close(e)},_close:function(e){this.menu.element.is(":visible")&&(this.menu.element.hide(),this.menu.blur(),this.isNewMenu=!0,this._trigger("close",e))},_change:function(e){this.previous!==this._value()&&this._trigger("change",e,{item:this.selectedItem})},_normalize:function(t){return t.length&&t[0].label&&t[0].value?t:e.map(t,function(t){return typeof t=="string"?{label:t,value:t}:e.extend({label:t.label||t.value,value:t.value||t.label},t)})},_suggest:function(t){var n=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(n,t),this.menu.refresh(),n.show(),this._resizeMenu(),n.position(e.extend({of:this.element},this.options.position)),this.options.autoFocus&&this.menu.next()},_resizeMenu:function(){var e=this.menu.element;e.outerWidth(Math.max(e.width("").outerWidth()+1,this.element.outerWidth()))},_renderMenu:function(t,n){var r=this;e.each(n,function(e,n){r._renderItemData(t,n)})},_renderItemData:function(e,t){return this._renderItem(e,t).data("ui-autocomplete-item",t)},_renderItem:function(t,n){return e("<li>").append(e("<a>").text(n.label)).appendTo(t)},_move:function(e,t){if(!this.menu.element.is(":visible")){this.search(null,t);return}if(this.menu.isFirstItem()&&/^previous/.test(e)||this.menu.isLastItem()&&/^next/.test(e)){this._value(this.term),this.menu.blur();return}this.menu[e](t)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(e,t){if(!this.isMultiLine||this.menu.element.is(":visible"))this._move(e,t),t.preventDefault()}}),e.extend(e.ui.autocomplete,{escapeRegex:function(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(t,n){var r=new RegExp(e.ui.autocomplete.escapeRegex(n),"i");return e.grep(t,function(e){return r.test(e.label||e.value||e)})}}),e.widget("ui.autocomplete",e.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(e){return e+(e>1?" results are":" result is")+" available, use up and down arrow keys to navigate."}}},__response:function(e){var t;this._superApply(arguments);if(this.options.disabled||this.cancelSearch)return;e&&e.length?t=this.options.messages.results(e.length):t=this.options.messages.noResults,this.liveRegion.text(t)}})})(jQuery);(function(e,t){var n,r,i,s,o="ui-button ui-widget ui-state-default ui-corner-all",u="ui-state-hover ui-state-active ",a="ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",f=function(){var t=e(this).find(":ui-button");setTimeout(function(){t.button("refresh")},1)},l=function(t){var n=t.name,r=t.form,i=e([]);return n&&(r?i=e(r).find("[name='"+n+"']"):i=e("[name='"+n+"']",t.ownerDocument).filter(function(){return!this.form})),i};e.widget("ui.button",{version:"1.9.2",defaultElement:"<button>",options:{disabled:null,text:!0,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset"+this.eventNamespace).bind("reset"+this.eventNamespace,f),typeof this.options.disabled!="boolean"?this.options.disabled=!!this.element.prop("disabled"):this.element.prop("disabled",this.options.disabled),this._determineButtonType(),this.hasTitle=!!this.buttonElement.attr("title");var t=this,u=this.options,a=this.type==="checkbox"||this.type==="radio",c=a?"":"ui-state-active",h="ui-state-focus";u.label===null&&(u.label=this.type==="input"?this.buttonElement.val():this.buttonElement.html()),this._hoverable(this.buttonElement),this.buttonElement.addClass(o).attr("role","button").bind("mouseenter"+this.eventNamespace,function(){if(u.disabled)return;this===n&&e(this).addClass("ui-state-active")}).bind("mouseleave"+this.eventNamespace,function(){if(u.disabled)return;e(this).removeClass(c)}).bind("click"+this.eventNamespace,function(e){u.disabled&&(e.preventDefault(),e.stopImmediatePropagation())}),this.element.bind("focus"+this.eventNamespace,function(){t.buttonElement.addClass(h)}).bind("blur"+this.eventNamespace,function(){t.buttonElement.removeClass(h)}),a&&(this.element.bind("change"+this.eventNamespace,function(){if(s)return;t.refresh()}),this.buttonElement.bind("mousedown"+this.eventNamespace,function(e){if(u.disabled)return;s=!1,r=e.pageX,i=e.pageY}).bind("mouseup"+this.eventNamespace,function(e){if(u.disabled)return;if(r!==e.pageX||i!==e.pageY)s=!0})),this.type==="checkbox"?this.buttonElement.bind("click"+this.eventNamespace,function(){if(u.disabled||s)return!1;e(this).toggleClass("ui-state-active"),t.buttonElement.attr("aria-pressed",t.element[0].checked)}):this.type==="radio"?this.buttonElement.bind("click"+this.eventNamespace,function(){if(u.disabled||s)return!1;e(this).addClass("ui-state-active"),t.buttonElement.attr("aria-pressed","true");var n=t.element[0];l(n).not(n).map(function(){return e(this).button("widget")[0]}).removeClass("ui-state-active").attr("aria-pressed","false")}):(this.buttonElement.bind("mousedown"+this.eventNamespace,function(){if(u.disabled)return!1;e(this).addClass("ui-state-active"),n=this,t.document.one("mouseup",function(){n=null})}).bind("mouseup"+this.eventNamespace,function(){if(u.disabled)return!1;e(this).removeClass("ui-state-active")}).bind("keydown"+this.eventNamespace,function(t){if(u.disabled)return!1;(t.keyCode===e.ui.keyCode.SPACE||t.keyCode===e.ui.keyCode.ENTER)&&e(this).addClass("ui-state-active")}).bind("keyup"+this.eventNamespace,function(){e(this).removeClass("ui-state-active")}),this.buttonElement.is("a")&&this.buttonElement.keyup(function(t){t.keyCode===e.ui.keyCode.SPACE&&e(this).click()})),this._setOption("disabled",u.disabled),this._resetButton()},_determineButtonType:function(){var e,t,n;this.element.is("[type=checkbox]")?this.type="checkbox":this.element.is("[type=radio]")?this.type="radio":this.element.is("input")?this.type="input":this.type="button",this.type==="checkbox"||this.type==="radio"?(e=this.element.parents().last(),t="label[for='"+this.element.attr("id")+"']",this.buttonElement=e.find(t),this.buttonElement.length||(e=e.length?e.siblings():this.element.siblings(),this.buttonElement=e.filter(t),this.buttonElement.length||(this.buttonElement=e.find(t))),this.element.addClass("ui-helper-hidden-accessible"),n=this.element.is(":checked"),n&&this.buttonElement.addClass("ui-state-active"),this.buttonElement.prop("aria-pressed",n)):this.buttonElement=this.element},widget:function(){return this.buttonElement},_destroy:function(){this.element.removeClass("ui-helper-hidden-accessible"),this.buttonElement.removeClass(o+" "+u+" "+a).removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html()),this.hasTitle||this.buttonElement.removeAttr("title")},_setOption:function(e,t){this._super(e,t);if(e==="disabled"){t?this.element.prop("disabled",!0):this.element.prop("disabled",!1);return}this._resetButton()},refresh:function(){var t=this.element.is("input, button")?this.element.is(":disabled"):this.element.hasClass("ui-button-disabled");t!==this.options.disabled&&this._setOption("disabled",t),this.type==="radio"?l(this.element[0]).each(function(){e(this).is(":checked")?e(this).button("widget").addClass("ui-state-active").attr("aria-pressed","true"):e(this).button("widget").removeClass("ui-state-active").attr("aria-pressed","false")}):this.type==="checkbox"&&(this.element.is(":checked")?this.buttonElement.addClass("ui-state-active").attr("aria-pressed","true"):this.buttonElement.removeClass("ui-state-active").attr("aria-pressed","false"))},_resetButton:function(){if(this.type==="input"){this.options.label&&this.element.val(this.options.label);return}var t=this.buttonElement.removeClass(a),n=e("<span></span>",this.document[0]).addClass("ui-button-text").html(this.options.label).appendTo(t.empty()).text(),r=this.options.icons,i=r.primary&&r.secondary,s=[];r.primary||r.secondary?(this.options.text&&s.push("ui-button-text-icon"+(i?"s":r.primary?"-primary":"-secondary")),r.primary&&t.prepend("<span class='ui-button-icon-primary ui-icon "+r.primary+"'></span>"),r.secondary&&t.append("<span class='ui-button-icon-secondary ui-icon "+r.secondary+"'></span>"),this.options.text||(s.push(i?"ui-button-icons-only":"ui-button-icon-only"),this.hasTitle||t.attr("title",e.trim(n)))):s.push("ui-button-text-only"),t.addClass(s.join(" "))}}),e.widget("ui.buttonset",{version:"1.9.2",options:{items:"button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(e,t){e==="disabled"&&this.buttons.button("option",e,t),this._super(e,t)},refresh:function(){var t=this.element.css("direction")==="rtl";this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return e(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(t?"ui-corner-right":"ui-corner-left").end().filter(":last").addClass(t?"ui-corner-left":"ui-corner-right").end().end()},_destroy:function(){this.element.removeClass("ui-buttonset"),this.buttons.map(function(){return e(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy")}})})(jQuery);(function($,undefined){function Datepicker(){this.debug=!1,this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},$.extend(this._defaults,this.regional[""]),this.dpDiv=bindHover($('<div id="'+this._mainDivId+'" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}function bindHover(e){var t="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return e.delegate(t,"mouseout",function(){$(this).removeClass("ui-state-hover"),this.className.indexOf("ui-datepicker-prev")!=-1&&$(this).removeClass("ui-datepicker-prev-hover"),this.className.indexOf("ui-datepicker-next")!=-1&&$(this).removeClass("ui-datepicker-next-hover")}).delegate(t,"mouseover",function(){$.datepicker._isDisabledDatepicker(instActive.inline?e.parent()[0]:instActive.input[0])||($(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),$(this).addClass("ui-state-hover"),this.className.indexOf("ui-datepicker-prev")!=-1&&$(this).addClass("ui-datepicker-prev-hover"),this.className.indexOf("ui-datepicker-next")!=-1&&$(this).addClass("ui-datepicker-next-hover"))})}function extendRemove(e,t){$.extend(e,t);for(var n in t)if(t[n]==null||t[n]==undefined)e[n]=t[n];return e}$.extend($.ui,{datepicker:{version:"1.9.2"}});var PROP_NAME="datepicker",dpuuid=(new Date).getTime(),instActive;$.extend(Datepicker.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(e){return extendRemove(this._defaults,e||{}),this},_attachDatepicker:function(target,settings){var inlineSettings=null;for(var attrName in this._defaults){var attrValue=target.getAttribute("date:"+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}var nodeName=target.nodeName.toLowerCase(),inline=nodeName=="div"||nodeName=="span";target.id||(this.uuid+=1,target.id="dp"+this.uuid);var inst=this._newInst($(target),inline);inst.settings=$.extend({},settings||{},inlineSettings||{}),nodeName=="input"?this._connectDatepicker(target,inst):inline&&this._inlineDatepicker(target,inst)},_newInst:function(e,t){var n=e[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1");return{id:n,input:e,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:t,dpDiv:t?bindHover($('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')):this.dpDiv}},_connectDatepicker:function(e,t){var n=$(e);t.append=$([]),t.trigger=$([]);if(n.hasClass(this.markerClassName))return;this._attachments(n,t),n.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(e,n,r){t.settings[n]=r}).bind("getData.datepicker",function(e,n){return this._get(t,n)}),this._autoSize(t),$.data(e,PROP_NAME,t),t.settings.disabled&&this._disableDatepicker(e)},_attachments:function(e,t){var n=this._get(t,"appendText"),r=this._get(t,"isRTL");t.append&&t.append.remove(),n&&(t.append=$('<span class="'+this._appendClass+'">'+n+"</span>"),e[r?"before":"after"](t.append)),e.unbind("focus",this._showDatepicker),t.trigger&&t.trigger.remove();var i=this._get(t,"showOn");(i=="focus"||i=="both")&&e.focus(this._showDatepicker);if(i=="button"||i=="both"){var s=this._get(t,"buttonText"),o=this._get(t,"buttonImage");t.trigger=$(this._get(t,"buttonImageOnly")?$("<img/>").addClass(this._triggerClass).attr({src:o,alt:s,title:s}):$('<button type="button"></button>').addClass(this._triggerClass).html(o==""?s:$("<img/>").attr({src:o,alt:s,title:s}))),e[r?"before":"after"](t.trigger),t.trigger.click(function(){return $.datepicker._datepickerShowing&&$.datepicker._lastInput==e[0]?$.datepicker._hideDatepicker():$.datepicker._datepickerShowing&&$.datepicker._lastInput!=e[0]?($.datepicker._hideDatepicker(),$.datepicker._showDatepicker(e[0])):$.datepicker._showDatepicker(e[0]),!1})}},_autoSize:function(e){if(this._get(e,"autoSize")&&!e.inline){var t=new Date(2009,11,20),n=this._get(e,"dateFormat");if(n.match(/[DM]/)){var r=function(e){var t=0,n=0;for(var r=0;r<e.length;r++)e[r].length>t&&(t=e[r].length,n=r);return n};t.setMonth(r(this._get(e,n.match(/MM/)?"monthNames":"monthNamesShort"))),t.setDate(r(this._get(e,n.match(/DD/)?"dayNames":"dayNamesShort"))+20-t.getDay())}e.input.attr("size",this._formatDate(e,t).length)}},_inlineDatepicker:function(e,t){var n=$(e);if(n.hasClass(this.markerClassName))return;n.addClass(this.markerClassName).append(t.dpDiv).bind("setData.datepicker",function(e,n,r){t.settings[n]=r}).bind("getData.datepicker",function(e,n){return this._get(t,n)}),$.data(e,PROP_NAME,t),this._setDate(t,this._getDefaultDate(t),!0),this._updateDatepicker(t),this._updateAlternate(t),t.settings.disabled&&this._disableDatepicker(e),t.dpDiv.css("display","block")},_dialogDatepicker:function(e,t,n,r,i){var s=this._dialogInst;if(!s){this.uuid+=1;var o="dp"+this.uuid;this._dialogInput=$('<input type="text" id="'+o+'" style="position: absolute; top: -100px; width: 0px;"/>'),this._dialogInput.keydown(this._doKeyDown),$("body").append(this._dialogInput),s=this._dialogInst=this._newInst(this._dialogInput,!1),s.settings={},$.data(this._dialogInput[0],PROP_NAME,s)}extendRemove(s.settings,r||{}),t=t&&t.constructor==Date?this._formatDate(s,t):t,this._dialogInput.val(t),this._pos=i?i.length?i:[i.pageX,i.pageY]:null;if(!this._pos){var u=document.documentElement.clientWidth,a=document.documentElement.clientHeight,f=document.documentElement.scrollLeft||document.body.scrollLeft,l=document.documentElement.scrollTop||document.body.scrollTop;this._pos=[u/2-100+f,a/2-150+l]}return this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),s.settings.onSelect=n,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),$.blockUI&&$.blockUI(this.dpDiv),$.data(this._dialogInput[0],PROP_NAME,s),this},_destroyDatepicker:function(e){var t=$(e),n=$.data(e,PROP_NAME);if(!t.hasClass(this.markerClassName))return;var r=e.nodeName.toLowerCase();$.removeData(e,PROP_NAME),r=="input"?(n.append.remove(),n.trigger.remove(),t.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):(r=="div"||r=="span")&&t.removeClass(this.markerClassName).empty()},_enableDatepicker:function(e){var t=$(e),n=$.data(e,PROP_NAME);if(!t.hasClass(this.markerClassName))return;var r=e.nodeName.toLowerCase();if(r=="input")e.disabled=!1,n.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""});else if(r=="div"||r=="span"){var i=t.children("."+this._inlineClass);i.children().removeClass("ui-state-disabled"),i.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!1)}this._disabledInputs=$.map(this._disabledInputs,function(t){return t==e?null:t})},_disableDatepicker:function(e){var t=$(e),n=$.data(e,PROP_NAME);if(!t.hasClass(this.markerClassName))return;var r=e.nodeName.toLowerCase();if(r=="input")e.disabled=!0,n.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"});else if(r=="div"||r=="span"){var i=t.children("."+this._inlineClass);i.children().addClass("ui-state-disabled"),i.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!0)}this._disabledInputs=$.map(this._disabledInputs,function(t){return t==e?null:t}),this._disabledInputs[this._disabledInputs.length]=e},_isDisabledDatepicker:function(e){if(!e)return!1;for(var t=0;t<this._disabledInputs.length;t++)if(this._disabledInputs[t]==e)return!0;return!1},_getInst:function(e){try{return $.data(e,PROP_NAME)}catch(t){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(e,t,n){var r=this._getInst(e);if(arguments.length==2&&typeof t=="string")return t=="defaults"?$.extend({},$.datepicker._defaults):r?t=="all"?$.extend({},r.settings):this._get(r,t):null;var i=t||{};typeof t=="string"&&(i={},i[t]=n);if(r){this._curInst==r&&this._hideDatepicker();var s=this._getDateDatepicker(e,!0),o=this._getMinMaxDate(r,"min"),u=this._getMinMaxDate(r,"max");extendRemove(r.settings,i),o!==null&&i.dateFormat!==undefined&&i.minDate===undefined&&(r.settings.minDate=this._formatDate(r,o)),u!==null&&i.dateFormat!==undefined&&i.maxDate===undefined&&(r.settings.maxDate=this._formatDate(r,u)),this._attachments($(e),r),this._autoSize(r),this._setDate(r,s),this._updateAlternate(r),this._updateDatepicker(r)}},_changeDatepicker:function(e,t,n){this._optionDatepicker(e,t,n)},_refreshDatepicker:function(e){var t=this._getInst(e);t&&this._updateDatepicker(t)},_setDateDatepicker:function(e,t){var n=this._getInst(e);n&&(this._setDate(n,t),this._updateDatepicker(n),this._updateAlternate(n))},_getDateDatepicker:function(e,t){var n=this._getInst(e);return n&&!n.inline&&this._setDateFromField(n,t),n?this._getDate(n):null},_doKeyDown:function(e){var t=$.datepicker._getInst(e.target),n=!0,r=t.dpDiv.is(".ui-datepicker-rtl");t._keyEvent=!0;if($.datepicker._datepickerShowing)switch(e.keyCode){case 9:$.datepicker._hideDatepicker(),n=!1;break;case 13:var i=$("td."+$.datepicker._dayOverClass+":not(."+$.datepicker._currentClass+")",t.dpDiv);i[0]&&$.datepicker._selectDay(e.target,t.selectedMonth,t.selectedYear,i[0]);var s=$.datepicker._get(t,"onSelect");if(s){var o=$.datepicker._formatDate(t);s.apply(t.input?t.input[0]:null,[o,t])}else $.datepicker._hideDatepicker();return!1;case 27:$.datepicker._hideDatepicker();break;case 33:$.datepicker._adjustDate(e.target,e.ctrlKey?-$.datepicker._get(t,"stepBigMonths"):-$.datepicker._get(t,"stepMonths"),"M");break;case 34:$.datepicker._adjustDate(e.target,e.ctrlKey?+$.datepicker._get(t,"stepBigMonths"):+$.datepicker._get(t,"stepMonths"),"M");break;case 35:(e.ctrlKey||e.metaKey)&&$.datepicker._clearDate(e.target),n=e.ctrlKey||e.metaKey;break;case 36:(e.ctrlKey||e.metaKey)&&$.datepicker._gotoToday(e.target),n=e.ctrlKey||e.metaKey;break;case 37:(e.ctrlKey||e.metaKey)&&$.datepicker._adjustDate(e.target,r?1:-1,"D"),n=e.ctrlKey||e.metaKey,e.originalEvent.altKey&&$.datepicker._adjustDate(e.target,e.ctrlKey?-$.datepicker._get(t,"stepBigMonths"):-$.datepicker._get(t,"stepMonths"),"M");break;case 38:(e.ctrlKey||e.metaKey)&&$.datepicker._adjustDate(e.target,-7,"D"),n=e.ctrlKey||e.metaKey;break;case 39:(e.ctrlKey||e.metaKey)&&$.datepicker._adjustDate(e.target,r?-1:1,"D"),n=e.ctrlKey||e.metaKey,e.originalEvent.altKey&&$.datepicker._adjustDate(e.target,e.ctrlKey?+$.datepicker._get(t,"stepBigMonths"):+$.datepicker._get(t,"stepMonths"),"M");break;case 40:(e.ctrlKey||e.metaKey)&&$.datepicker._adjustDate(e.target,7,"D"),n=e.ctrlKey||e.metaKey;break;default:n=!1}else e.keyCode==36&&e.ctrlKey?$.datepicker._showDatepicker(this):n=!1;n&&(e.preventDefault(),e.stopPropagation())},_doKeyPress:function(e){var t=$.datepicker._getInst(e.target);if($.datepicker._get(t,"constrainInput")){var n=$.datepicker._possibleChars($.datepicker._get(t,"dateFormat")),r=String.fromCharCode(e.charCode==undefined?e.keyCode:e.charCode);return e.ctrlKey||e.metaKey||r<" "||!n||n.indexOf(r)>-1}},_doKeyUp:function(e){var t=$.datepicker._getInst(e.target);if(t.input.val()!=t.lastVal)try{var n=$.datepicker.parseDate($.datepicker._get(t,"dateFormat"),t.input?t.input.val():null,$.datepicker._getFormatConfig(t));n&&($.datepicker._setDateFromField(t),$.datepicker._updateAlternate(t),$.datepicker._updateDatepicker(t))}catch(r){$.datepicker.log(r)}return!0},_showDatepicker:function(e){e=e.target||e,e.nodeName.toLowerCase()!="input"&&(e=$("input",e.parentNode)[0]);if($.datepicker._isDisabledDatepicker(e)||$.datepicker._lastInput==e)return;var t=$.datepicker._getInst(e);$.datepicker._curInst&&$.datepicker._curInst!=t&&($.datepicker._curInst.dpDiv.stop(!0,!0),t&&$.datepicker._datepickerShowing&&$.datepicker._hideDatepicker($.datepicker._curInst.input[0]));var n=$.datepicker._get(t,"beforeShow"),r=n?n.apply(e,[e,t]):{};if(r===!1)return;extendRemove(t.settings,r),t.lastVal=null,$.datepicker._lastInput=e,$.datepicker._setDateFromField(t),$.datepicker._inDialog&&(e.value=""),$.datepicker._pos||($.datepicker._pos=$.datepicker._findPos(e),$.datepicker._pos[1]+=e.offsetHeight);var i=!1;$(e).parents().each(function(){return i|=$(this).css("position")=="fixed",!i});var s={left:$.datepicker._pos[0],top:$.datepicker._pos[1]};$.datepicker._pos=null,t.dpDiv.empty(),t.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),$.datepicker._updateDatepicker(t),s=$.datepicker._checkOffset(t,s,i),t.dpDiv.css({position:$.datepicker._inDialog&&$.blockUI?"static":i?"fixed":"absolute",display:"none",left:s.left+"px",top:s.top+"px"});if(!t.inline){var o=$.datepicker._get(t,"showAnim"),u=$.datepicker._get(t,"duration"),a=function(){var e=t.dpDiv.find("iframe.ui-datepicker-cover");if(!!e.length){var n=$.datepicker._getBorders(t.dpDiv);e.css({left:-n[0],top:-n[1],width:t.dpDiv.outerWidth(),height:t.dpDiv.outerHeight()})}};t.dpDiv.zIndex($(e).zIndex()+1),$.datepicker._datepickerShowing=!0,$.effects&&($.effects.effect[o]||$.effects[o])?t.dpDiv.show(o,$.datepicker._get(t,"showOptions"),u,a):t.dpDiv[o||"show"](o?u:null,a),(!o||!u)&&a(),t.input.is(":visible")&&!t.input.is(":disabled")&&t.input.focus(),$.datepicker._curInst=t}},_updateDatepicker:function(e){this.maxRows=4;var t=$.datepicker._getBorders(e.dpDiv);instActive=e,e.dpDiv.empty().append(this._generateHTML(e)),this._attachHandlers(e);var n=e.dpDiv.find("iframe.ui-datepicker-cover");!n.length||n.css({left:-t[0],top:-t[1],width:e.dpDiv.outerWidth(),height:e.dpDiv.outerHeight()}),e.dpDiv.find("."+this._dayOverClass+" a").mouseover();var r=this._getNumberOfMonths(e),i=r[1],s=17;e.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),i>1&&e.dpDiv.addClass("ui-datepicker-multi-"+i).css("width",s*i+"em"),e.dpDiv[(r[0]!=1||r[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi"),e.dpDiv[(this._get(e,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),e==$.datepicker._curInst&&$.datepicker._datepickerShowing&&e.input&&e.input.is(":visible")&&!e.input.is(":disabled")&&e.input[0]!=document.activeElement&&e.input.focus();if(e.yearshtml){var o=e.yearshtml;setTimeout(function(){o===e.yearshtml&&e.yearshtml&&e.dpDiv.find("select.ui-datepicker-year:first").replaceWith(e.yearshtml),o=e.yearshtml=null},0)}},_getBorders:function(e){var t=function(e){return{thin:1,medium:2,thick:3}[e]||e};return[parseFloat(t(e.css("border-left-width"))),parseFloat(t(e.css("border-top-width")))]},_checkOffset:function(e,t,n){var r=e.dpDiv.outerWidth(),i=e.dpDiv.outerHeight(),s=e.input?e.input.outerWidth():0,o=e.input?e.input.outerHeight():0,u=document.documentElement.clientWidth+(n?0:$(document).scrollLeft()),a=document.documentElement.clientHeight+(n?0:$(document).scrollTop());return t.left-=this._get(e,"isRTL")?r-s:0,t.left-=n&&t.left==e.input.offset().left?$(document).scrollLeft():0,t.top-=n&&t.top==e.input.offset().top+o?$(document).scrollTop():0,t.left-=Math.min(t.left,t.left+r>u&&u>r?Math.abs(t.left+r-u):0),t.top-=Math.min(t.top,t.top+i>a&&a>i?Math.abs(i+o):0),t},_findPos:function(e){var t=this._getInst(e),n=this._get(t,"isRTL");while(e&&(e.type=="hidden"||e.nodeType!=1||$.expr.filters.hidden(e)))e=e[n?"previousSibling":"nextSibling"];var r=$(e).offset();return[r.left,r.top]},_hideDatepicker:function(e){var t=this._curInst;if(!t||e&&t!=$.data(e,PROP_NAME))return;if(this._datepickerShowing){var n=this._get(t,"showAnim"),r=this._get(t,"duration"),i=function(){$.datepicker._tidyDialog(t)};$.effects&&($.effects.effect[n]||$.effects[n])?t.dpDiv.hide(n,$.datepicker._get(t,"showOptions"),r,i):t.dpDiv[n=="slideDown"?"slideUp":n=="fadeIn"?"fadeOut":"hide"](n?r:null,i),n||i(),this._datepickerShowing=!1;var s=this._get(t,"onClose");s&&s.apply(t.input?t.input[0]:null,[t.input?t.input.val():"",t]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),$.blockUI&&($.unblockUI(),$("body").append(this.dpDiv))),this._inDialog=!1}},_tidyDialog:function(e){e.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(e){if(!$.datepicker._curInst)return;var t=$(e.target),n=$.datepicker._getInst(t[0]);(t[0].id!=$.datepicker._mainDivId&&t.parents("#"+$.datepicker._mainDivId).length==0&&!t.hasClass($.datepicker.markerClassName)&&!t.closest("."+$.datepicker._triggerClass).length&&$.datepicker._datepickerShowing&&(!$.datepicker._inDialog||!$.blockUI)||t.hasClass($.datepicker.markerClassName)&&$.datepicker._curInst!=n)&&$.datepicker._hideDatepicker()},_adjustDate:function(e,t,n){var r=$(e),i=this._getInst(r[0]);if(this._isDisabledDatepicker(r[0]))return;this._adjustInstDate(i,t+(n=="M"?this._get(i,"showCurrentAtPos"):0),n),this._updateDatepicker(i)},_gotoToday:function(e){var t=$(e),n=this._getInst(t[0]);if(this._get(n,"gotoCurrent")&&n.currentDay)n.selectedDay=n.currentDay,n.drawMonth=n.selectedMonth=n.currentMonth,n.drawYear=n.selectedYear=n.currentYear;else{var r=new Date;n.selectedDay=r.getDate(),n.drawMonth=n.selectedMonth=r.getMonth(),n.drawYear=n.selectedYear=r.getFullYear()}this._notifyChange(n),this._adjustDate(t)},_selectMonthYear:function(e,t,n){var r=$(e),i=this._getInst(r[0]);i["selected"+(n=="M"?"Month":"Year")]=i["draw"+(n=="M"?"Month":"Year")]=parseInt(t.options[t.selectedIndex].value,10),this._notifyChange(i),this._adjustDate(r)},_selectDay:function(e,t,n,r){var i=$(e);if($(r).hasClass(this._unselectableClass)||this._isDisabledDatepicker(i[0]))return;var s=this._getInst(i[0]);s.selectedDay=s.currentDay=$("a",r).html(),s.selectedMonth=s.currentMonth=t,s.selectedYear=s.currentYear=n,this._selectDate(e,this._formatDate(s,s.currentDay,s.currentMonth,s.currentYear))},_clearDate:function(e){var t=$(e),n=this._getInst(t[0]);this._selectDate(t,"")},_selectDate:function(e,t){var n=$(e),r=this._getInst(n[0]);t=t!=null?t:this._formatDate(r),r.input&&r.input.val(t),this._updateAlternate(r);var i=this._get(r,"onSelect");i?i.apply(r.input?r.input[0]:null,[t,r]):r.input&&r.input.trigger("change"),r.inline?this._updateDatepicker(r):(this._hideDatepicker(),this._lastInput=r.input[0],typeof r.input[0]!="object"&&r.input.focus(),this._lastInput=null)},_updateAlternate:function(e){var t=this._get(e,"altField");if(t){var n=this._get(e,"altFormat")||this._get(e,"dateFormat"),r=this._getDate(e),i=this.formatDate(n,r,this._getFormatConfig(e));$(t).each(function(){$(this).val(i)})}},noWeekends:function(e){var t=e.getDay();return[t>0&&t<6,""]},iso8601Week:function(e){var t=new Date(e.getTime());t.setDate(t.getDate()+4-(t.getDay()||7));var n=t.getTime();return t.setMonth(0),t.setDate(1),Math.floor(Math.round((n-t)/864e5)/7)+1},parseDate:function(e,t,n){if(e==null||t==null)throw"Invalid arguments";t=typeof t=="object"?t.toString():t+"";if(t=="")return null;var r=(n?n.shortYearCutoff:null)||this._defaults.shortYearCutoff;r=typeof r!="string"?r:(new Date).getFullYear()%100+parseInt(r,10);var i=(n?n.dayNamesShort:null)||this._defaults.dayNamesShort,s=(n?n.dayNames:null)||this._defaults.dayNames,o=(n?n.monthNamesShort:null)||this._defaults.monthNamesShort,u=(n?n.monthNames:null)||this._defaults.monthNames,a=-1,f=-1,l=-1,c=-1,h=!1,p=function(t){var n=y+1<e.length&&e.charAt(y+1)==t;return n&&y++,n},d=function(e){var n=p(e),r=e=="@"?14:e=="!"?20:e=="y"&&n?4:e=="o"?3:2,i=new RegExp("^\\d{1,"+r+"}"),s=t.substring(g).match(i);if(!s)throw"Missing number at position "+g;return g+=s[0].length,parseInt(s[0],10)},v=function(e,n,r){var i=$.map(p(e)?r:n,function(e,t){return[[t,e]]}).sort(function(e,t){return-(e[1].length-t[1].length)}),s=-1;$.each(i,function(e,n){var r=n[1];if(t.substr(g,r.length).toLowerCase()==r.toLowerCase())return s=n[0],g+=r.length,!1});if(s!=-1)return s+1;throw"Unknown name at position "+g},m=function(){if(t.charAt(g)!=e.charAt(y))throw"Unexpected literal at position "+g;g++},g=0;for(var y=0;y<e.length;y++)if(h)e.charAt(y)=="'"&&!p("'")?h=!1:m();else switch(e.charAt(y)){case"d":l=d("d");break;case"D":v("D",i,s);break;case"o":c=d("o");break;case"m":f=d("m");break;case"M":f=v("M",o,u);break;case"y":a=d("y");break;case"@":var b=new Date(d("@"));a=b.getFullYear(),f=b.getMonth()+1,l=b.getDate();break;case"!":var b=new Date((d("!")-this._ticksTo1970)/1e4);a=b.getFullYear(),f=b.getMonth()+1,l=b.getDate();break;case"'":p("'")?m():h=!0;break;default:m()}if(g<t.length){var w=t.substr(g);if(!/^\s+/.test(w))throw"Extra/unparsed characters found in date: "+w}a==-1?a=(new Date).getFullYear():a<100&&(a+=(new Date).getFullYear()-(new Date).getFullYear()%100+(a<=r?0:-100));if(c>-1){f=1,l=c;do{var E=this._getDaysInMonth(a,f-1);if(l<=E)break;f++,l-=E}while(!0)}var b=this._daylightSavingAdjust(new Date(a,f-1,l));if(b.getFullYear()!=a||b.getMonth()+1!=f||b.getDate()!=l)throw"Invalid date";return b},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*1e7,formatDate:function(e,t,n){if(!t)return"";var r=(n?n.dayNamesShort:null)||this._defaults.dayNamesShort,i=(n?n.dayNames:null)||this._defaults.dayNames,s=(n?n.monthNamesShort:null)||this._defaults.monthNamesShort,o=(n?n.monthNames:null)||this._defaults.monthNames,u=function(t){var n=h+1<e.length&&e.charAt(h+1)==t;return n&&h++,n},a=function(e,t,n){var r=""+t;if(u(e))while(r.length<n)r="0"+r;return r},f=function(e,t,n,r){return u(e)?r[t]:n[t]},l="",c=!1;if(t)for(var h=0;h<e.length;h++)if(c)e.charAt(h)=="'"&&!u("'")?c=!1:l+=e.charAt(h);else switch(e.charAt(h)){case"d":l+=a("d",t.getDate(),2);break;case"D":l+=f("D",t.getDay(),r,i);break;case"o":l+=a("o",Math.round(((new Date(t.getFullYear(),t.getMonth(),t.getDate())).getTime()-(new Date(t.getFullYear(),0,0)).getTime())/864e5),3);break;case"m":l+=a("m",t.getMonth()+1,2);break;case"M":l+=f("M",t.getMonth(),s,o);break;case"y":l+=u("y")?t.getFullYear():(t.getYear()%100<10?"0":"")+t.getYear()%100;break;case"@":l+=t.getTime();break;case"!":l+=t.getTime()*1e4+this._ticksTo1970;break;case"'":u("'")?l+="'":c=!0;break;default:l+=e.charAt(h)}return l},_possibleChars:function(e){var t="",n=!1,r=function(t){var n=i+1<e.length&&e.charAt(i+1)==t;return n&&i++,n};for(var i=0;i<e.length;i++)if(n)e.charAt(i)=="'"&&!r("'")?n=!1:t+=e.charAt(i);else switch(e.charAt(i)){case"d":case"m":case"y":case"@":t+="0123456789";break;case"D":case"M":return null;case"'":r("'")?t+="'":n=!0;break;default:t+=e.charAt(i)}return t},_get:function(e,t){return e.settings[t]!==undefined?e.settings[t]:this._defaults[t]},_setDateFromField:function(e,t){if(e.input.val()==e.lastVal)return;var n=this._get(e,"dateFormat"),r=e.lastVal=e.input?e.input.val():null,i,s;i=s=this._getDefaultDate(e);var o=this._getFormatConfig(e);try{i=this.parseDate(n,r,o)||s}catch(u){this.log(u),r=t?"":r}e.selectedDay=i.getDate(),e.drawMonth=e.selectedMonth=i.getMonth(),e.drawYear=e.selectedYear=i.getFullYear(),e.currentDay=r?i.getDate():0,e.currentMonth=r?i.getMonth():0,e.currentYear=r?i.getFullYear():0,this._adjustInstDate(e)},_getDefaultDate:function(e){return this._restrictMinMax(e,this._determineDate(e,this._get(e,"defaultDate"),new Date))},_determineDate:function(e,t,n){var r=function(e){var t=new Date;return t.setDate(t.getDate()+e),t},i=function(t){try{return $.datepicker.parseDate($.datepicker._get(e,"dateFormat"),t,$.datepicker._getFormatConfig(e))}catch(n){}var r=(t.toLowerCase().match(/^c/)?$.datepicker._getDate(e):null)||new Date,i=r.getFullYear(),s=r.getMonth(),o=r.getDate(),u=/([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,a=u.exec(t);while(a){switch(a[2]||"d"){case"d":case"D":o+=parseInt(a[1],10);break;case"w":case"W":o+=parseInt(a[1],10)*7;break;case"m":case"M":s+=parseInt(a[1],10),o=Math.min(o,$.datepicker._getDaysInMonth(i,s));break;case"y":case"Y":i+=parseInt(a[1],10),o=Math.min(o,$.datepicker._getDaysInMonth(i,s))}a=u.exec(t)}return new Date(i,s,o)},s=t==null||t===""?n:typeof t=="string"?i(t):typeof t=="number"?isNaN(t)?n:r(t):new Date(t.getTime());return s=s&&s.toString()=="Invalid Date"?n:s,s&&(s.setHours(0),s.setMinutes(0),s.setSeconds(0),s.setMilliseconds(0)),this._daylightSavingAdjust(s)},_daylightSavingAdjust:function(e){return e?(e.setHours(e.getHours()>12?e.getHours()+2:0),e):null},_setDate:function(e,t,n){var r=!t,i=e.selectedMonth,s=e.selectedYear,o=this._restrictMinMax(e,this._determineDate(e,t,new Date));e.selectedDay=e.currentDay=o.getDate(),e.drawMonth=e.selectedMonth=e.currentMonth=o.getMonth(),e.drawYear=e.selectedYear=e.currentYear=o.getFullYear(),(i!=e.selectedMonth||s!=e.selectedYear)&&!n&&this._notifyChange(e),this._adjustInstDate(e),e.input&&e.input.val(r?"":this._formatDate(e))},_getDate:function(e){var t=!e.currentYear||e.input&&e.input.val()==""?null:this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return t},_attachHandlers:function(e){var t=this._get(e,"stepMonths"),n="#"+e.id.replace(/\\\\/g,"\\");e.dpDiv.find("[data-handler]").map(function(){var e={prev:function(){window["DP_jQuery_"+dpuuid].datepicker._adjustDate(n,-t,"M")},next:function(){window["DP_jQuery_"+dpuuid].datepicker._adjustDate(n,+t,"M")},hide:function(){window["DP_jQuery_"+dpuuid].datepicker._hideDatepicker()},today:function(){window["DP_jQuery_"+dpuuid].datepicker._gotoToday(n)},selectDay:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectDay(n,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectMonthYear(n,this,"M"),!1},selectYear:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectMonthYear(n,this,"Y"),!1}};$(this).bind(this.getAttribute("data-event"),e[this.getAttribute("data-handler")])})},_generateHTML:function(e){var t=new Date;t=this._daylightSavingAdjust(new Date(t.getFullYear(),t.getMonth(),t.getDate()));var n=this._get(e,"isRTL"),r=this._get(e,"showButtonPanel"),i=this._get(e,"hideIfNoPrevNext"),s=this._get(e,"navigationAsDateFormat"),o=this._getNumberOfMonths(e),u=this._get(e,"showCurrentAtPos"),a=this._get(e,"stepMonths"),f=o[0]!=1||o[1]!=1,l=this._daylightSavingAdjust(e.currentDay?new Date(e.currentYear,e.currentMonth,e.currentDay):new Date(9999,9,9)),c=this._getMinMaxDate(e,"min"),h=this._getMinMaxDate(e,"max"),p=e.drawMonth-u,d=e.drawYear;p<0&&(p+=12,d--);if(h){var v=this._daylightSavingAdjust(new Date(h.getFullYear(),h.getMonth()-o[0]*o[1]+1,h.getDate()));v=c&&v<c?c:v;while(this._daylightSavingAdjust(new Date(d,p,1))>v)p--,p<0&&(p=11,d--)}e.drawMonth=p,e.drawYear=d;var m=this._get(e,"prevText");m=s?this.formatDate(m,this._daylightSavingAdjust(new Date(d,p-a,1)),this._getFormatConfig(e)):m;var g=this._canAdjustMonth(e,-1,d,p)?'<a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click" title="'+m+'"><span class="ui-icon ui-icon-circle-triangle-'+(n?"e":"w")+'">'+m+"</span></a>":i?"":'<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+m+'"><span class="ui-icon ui-icon-circle-triangle-'+(n?"e":"w")+'">'+m+"</span></a>",y=this._get(e,"nextText");y=s?this.formatDate(y,this._daylightSavingAdjust(new Date(d,p+a,1)),this._getFormatConfig(e)):y;var b=this._canAdjustMonth(e,1,d,p)?'<a class="ui-datepicker-next ui-corner-all" data-handler="next" data-event="click" title="'+y+'"><span class="ui-icon ui-icon-circle-triangle-'+(n?"w":"e")+'">'+y+"</span></a>":i?"":'<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+y+'"><span class="ui-icon ui-icon-circle-triangle-'+(n?"w":"e")+'">'+y+"</span></a>",w=this._get(e,"currentText"),E=this._get(e,"gotoCurrent")&&e.currentDay?l:t;w=s?this.formatDate(w,E,this._getFormatConfig(e)):w;var S=e.inline?"":'<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" data-handler="hide" data-event="click">'+this._get(e,"closeText")+"</button>",x=r?'<div class="ui-datepicker-buttonpane ui-widget-content">'+(n?S:"")+(this._isInRange(e,E)?'<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" data-handler="today" data-event="click">'+w+"</button>":"")+(n?"":S)+"</div>":"",T=parseInt(this._get(e,"firstDay"),10);T=isNaN(T)?0:T;var N=this._get(e,"showWeek"),C=this._get(e,"dayNames"),k=this._get(e,"dayNamesShort"),L=this._get(e,"dayNamesMin"),A=this._get(e,"monthNames"),O=this._get(e,"monthNamesShort"),M=this._get(e,"beforeShowDay"),_=this._get(e,"showOtherMonths"),D=this._get(e,"selectOtherMonths"),P=this._get(e,"calculateWeek")||this.iso8601Week,H=this._getDefaultDate(e),B="";for(var j=0;j<o[0];j++){var F="";this.maxRows=4;for(var I=0;I<o[1];I++){var q=this._daylightSavingAdjust(new Date(d,p,e.selectedDay)),R=" ui-corner-all",U="";if(f){U+='<div class="ui-datepicker-group';if(o[1]>1)switch(I){case 0:U+=" ui-datepicker-group-first",R=" ui-corner-"+(n?"right":"left");break;case o[1]-1:U+=" ui-datepicker-group-last",R=" ui-corner-"+(n?"left":"right");break;default:U+=" ui-datepicker-group-middle",R=""}U+='">'}U+='<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix'+R+'">'+(/all|left/.test(R)&&j==0?n?b:g:"")+(/all|right/.test(R)&&j==0?n?g:b:"")+this._generateMonthYearHeader(e,p,d,c,h,j>0||I>0,A,O)+'</div><table class="ui-datepicker-calendar"><thead>'+"<tr>";var z=N?'<th class="ui-datepicker-week-col">'+this._get(e,"weekHeader")+"</th>":"";for(var W=0;W<7;W++){var X=(W+T)%7;z+="<th"+((W+T+6)%7>=5?' class="ui-datepicker-week-end"':"")+">"+'<span title="'+C[X]+'">'+L[X]+"</span></th>"}U+=z+"</tr></thead><tbody>";var V=this._getDaysInMonth(d,p);d==e.selectedYear&&p==e.selectedMonth&&(e.selectedDay=Math.min(e.selectedDay,V));var J=(this._getFirstDayOfMonth(d,p)-T+7)%7,K=Math.ceil((J+V)/7),Q=f?this.maxRows>K?this.maxRows:K:K;this.maxRows=Q;var G=this._daylightSavingAdjust(new Date(d,p,1-J));for(var Y=0;Y<Q;Y++){U+="<tr>";var Z=N?'<td class="ui-datepicker-week-col">'+this._get(e,"calculateWeek")(G)+"</td>":"";for(var W=0;W<7;W++){var et=M?M.apply(e.input?e.input[0]:null,[G]):[!0,""],tt=G.getMonth()!=p,nt=tt&&!D||!et[0]||c&&G<c||h&&G>h;Z+='<td class="'+((W+T+6)%7>=5?" ui-datepicker-week-end":"")+(tt?" ui-datepicker-other-month":"")+(G.getTime()==q.getTime()&&p==e.selectedMonth&&e._keyEvent||H.getTime()==G.getTime()&&H.getTime()==q.getTime()?" "+this._dayOverClass:"")+(nt?" "+this._unselectableClass+" ui-state-disabled":"")+(tt&&!_?"":" "+et[1]+(G.getTime()==l.getTime()?" "+this._currentClass:"")+(G.getTime()==t.getTime()?" ui-datepicker-today":""))+'"'+((!tt||_)&&et[2]?' title="'+et[2]+'"':"")+(nt?"":' data-handler="selectDay" data-event="click" data-month="'+G.getMonth()+'" data-year="'+G.getFullYear()+'"')+">"+(tt&&!_?" ":nt?'<span class="ui-state-default">'+G.getDate()+"</span>":'<a class="ui-state-default'+(G.getTime()==t.getTime()?" ui-state-highlight":"")+(G.getTime()==l.getTime()?" ui-state-active":"")+(tt?" ui-priority-secondary":"")+'" href="#">'+G.getDate()+"</a>")+"</td>",G.setDate(G.getDate()+1),G=this._daylightSavingAdjust(G)}U+=Z+"</tr>"}p++,p>11&&(p=0,d++),U+="</tbody></table>"+(f?"</div>"+(o[0]>0&&I==o[1]-1?'<div class="ui-datepicker-row-break"></div>':""):""),F+=U}B+=F}return B+=x+($.ui.ie6&&!e.inline?'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>':""),e._keyEvent=!1,B},_generateMonthYearHeader:function(e,t,n,r,i,s,o,u){var a=this._get(e,"changeMonth"),f=this._get(e,"changeYear"),l=this._get(e,"showMonthAfterYear"),c='<div class="ui-datepicker-title">',h="";if(s||!a)h+='<span class="ui-datepicker-month">'+o[t]+"</span>";else{var p=r&&r.getFullYear()==n,d=i&&i.getFullYear()==n;h+='<select class="ui-datepicker-month" data-handler="selectMonth" data-event="change">';for(var v=0;v<12;v++)(!p||v>=r.getMonth())&&(!d||v<=i.getMonth())&&(h+='<option value="'+v+'"'+(v==t?' selected="selected"':"")+">"+u[v]+"</option>");h+="</select>"}l||(c+=h+(s||!a||!f?" ":""));if(!e.yearshtml){e.yearshtml="";if(s||!f)c+='<span class="ui-datepicker-year">'+n+"</span>";else{var m=this._get(e,"yearRange").split(":"),g=(new Date).getFullYear(),y=function(e){var t=e.match(/c[+-].*/)?n+parseInt(e.substring(1),10):e.match(/[+-].*/)?g+parseInt(e,10):parseInt(e,10);return isNaN(t)?g:t},b=y(m[0]),w=Math.max(b,y(m[1]||""));b=r?Math.max(b,r.getFullYear()):b,w=i?Math.min(w,i.getFullYear()):w,e.yearshtml+='<select class="ui-datepicker-year" data-handler="selectYear" data-event="change">';for(;b<=w;b++)e.yearshtml+='<option value="'+b+'"'+(b==n?' selected="selected"':"")+">"+b+"</option>";e.yearshtml+="</select>",c+=e.yearshtml,e.yearshtml=null}}return c+=this._get(e,"yearSuffix"),l&&(c+=(s||!a||!f?" ":"")+h),c+="</div>",c},_adjustInstDate:function(e,t,n){var r=e.drawYear+(n=="Y"?t:0),i=e.drawMonth+(n=="M"?t:0),s=Math.min(e.selectedDay,this._getDaysInMonth(r,i))+(n=="D"?t:0),o=this._restrictMinMax(e,this._daylightSavingAdjust(new Date(r,i,s)));e.selectedDay=o.getDate(),e.drawMonth=e.selectedMonth=o.getMonth(),e.drawYear=e.selectedYear=o.getFullYear(),(n=="M"||n=="Y")&&this._notifyChange(e)},_restrictMinMax:function(e,t){var n=this._getMinMaxDate(e,"min"),r=this._getMinMaxDate(e,"max"),i=n&&t<n?n:t;return i=r&&i>r?r:i,i},_notifyChange:function(e){var t=this._get(e,"onChangeMonthYear");t&&t.apply(e.input?e.input[0]:null,[e.selectedYear,e.selectedMonth+1,e])},_getNumberOfMonths:function(e){var t=this._get(e,"numberOfMonths");return t==null?[1,1]:typeof t=="number"?[1,t]:t},_getMinMaxDate:function(e,t){return this._determineDate(e,this._get(e,t+"Date"),null)},_getDaysInMonth:function(e,t){return 32-this._daylightSavingAdjust(new Date(e,t,32)).getDate()},_getFirstDayOfMonth:function(e,t){return(new Date(e,t,1)).getDay()},_canAdjustMonth:function(e,t,n,r){var i=this._getNumberOfMonths(e),s=this._daylightSavingAdjust(new Date(n,r+(t<0?t:i[0]*i[1]),1));return t<0&&s.setDate(this._getDaysInMonth(s.getFullYear(),s.getMonth())),this._isInRange(e,s)},_isInRange:function(e,t){var n=this._getMinMaxDate(e,"min"),r=this._getMinMaxDate(e,"max");return(!n||t.getTime()>=n.getTime())&&(!r||t.getTime()<=r.getTime())},_getFormatConfig:function(e){var t=this._get(e,"shortYearCutoff");return t=typeof t!="string"?t:(new Date).getFullYear()%100+parseInt(t,10),{shortYearCutoff:t,dayNamesShort:this._get(e,"dayNamesShort"),dayNames:this._get(e,"dayNames"),monthNamesShort:this._get(e,"monthNamesShort"),monthNames:this._get(e,"monthNames")}},_formatDate:function(e,t,n,r){t||(e.currentDay=e.selectedDay,e.currentMonth=e.selectedMonth,e.currentYear=e.selectedYear);var i=t?typeof t=="object"?t:this._daylightSavingAdjust(new Date(r,n,t)):this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return this.formatDate(this._get(e,"dateFormat"),i,this._getFormatConfig(e))}}),$.fn.datepicker=function(e){if(!this.length)return this;$.datepicker.initialized||($(document).mousedown($.datepicker._checkExternalClick).find(document.body).append($.datepicker.dpDiv),$.datepicker.initialized=!0);var t=Array.prototype.slice.call(arguments,1);return typeof e!="string"||e!="isDisabled"&&e!="getDate"&&e!="widget"?e=="option"&&arguments.length==2&&typeof arguments[1]=="string"?$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this[0]].concat(t)):this.each(function(){typeof e=="string"?$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this].concat(t)):$.datepicker._attachDatepicker(this,e)}):$.datepicker["_"+e+"Datepicker"].apply($.datepicker,[this[0]].concat(t))},$.datepicker=new Datepicker,$.datepicker.initialized=!1,$.datepicker.uuid=(new Date).getTime(),$.datepicker.version="1.9.2",window["DP_jQuery_"+dpuuid]=$})(jQuery);(function(e,t){var n="ui-dialog ui-widget ui-widget-content ui-corner-all ",r={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},i={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0};e.widget("ui.dialog",{version:"1.9.2",options:{autoOpen:!0,buttons:{},closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:!1,maxWidth:!1,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(t){var n=e(this).css(t).offset().top;n<0&&e(this).css("top",t.top-n)}},resizable:!0,show:null,stack:!0,title:"",width:300,zIndex:1e3},_create:function(){this.originalTitle=this.element.attr("title"),typeof this.originalTitle!="string"&&(this.originalTitle=""),this.oldPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)},this.options.title=this.options.title||this.originalTitle;var t=this,r=this.options,i=r.title||" ",s,o,u,a,f;s=(this.uiDialog=e("<div>")).addClass(n+r.dialogClass).css({display:"none",outline:0,zIndex:r.zIndex}).attr("tabIndex",-1).keydown(function(n){r.closeOnEscape&&!n.isDefaultPrevented()&&n.keyCode&&n.keyCode===e.ui.keyCode.ESCAPE&&(t.close(n),n.preventDefault())}).mousedown(function(e){t.moveToTop(!1,e)}).appendTo("body"),this.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(s),o=(this.uiDialogTitlebar=e("<div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").bind("mousedown",function(){s.focus()}).prependTo(s),u=e("<a href='#'></a>").addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").click(function(e){e.preventDefault(),t.close(e)}).appendTo(o),(this.uiDialogTitlebarCloseText=e("<span>")).addClass("ui-icon ui-icon-closethick").text(r.closeText).appendTo(u),a=e("<span>").uniqueId().addClass("ui-dialog-title").html(i).prependTo(o),f=(this.uiDialogButtonPane=e("<div>")).addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),(this.uiButtonSet=e("<div>")).addClass("ui-dialog-buttonset").appendTo(f),s.attr({role:"dialog","aria-labelledby":a.attr("id")}),o.find("*").add(o).disableSelection(),this._hoverable(u),this._focusable(u),r.draggable&&e.fn.draggable&&this._makeDraggable(),r.resizable&&e.fn.resizable&&this._makeResizable(),this._createButtons(r.buttons),this._isOpen=!1,e.fn.bgiframe&&s.bgiframe(),this._on(s,{keydown:function(t){if(!r.modal||t.keyCode!==e.ui.keyCode.TAB)return;var n=e(":tabbable",s),i=n.filter(":first"),o=n.filter(":last");if(t.target===o[0]&&!t.shiftKey)return i.focus(1),!1;if(t.target===i[0]&&t.shiftKey)return o.focus(1),!1}})},_init:function(){this.options.autoOpen&&this.open()},_destroy:function(){var e,t=this.oldPosition;this.overlay&&this.overlay.destroy(),this.uiDialog.hide(),this.element.removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"),this.uiDialog.remove(),this.originalTitle&&this.element.attr("title",this.originalTitle),e=t.parent.children().eq(t.index),e.length&&e[0]!==this.element[0]?e.before(this.element):t.parent.append(this.element)},widget:function(){return this.uiDialog},close:function(t){var n=this,r,i;if(!this._isOpen)return;if(!1===this._trigger("beforeClose",t))return;return this._isOpen=!1,this.overlay&&this.overlay.destroy(),this.options.hide?this._hide(this.uiDialog,this.options.hide,function(){n._trigger("close",t)}):(this.uiDialog.hide(),this._trigger("close",t)),e.ui.dialog.overlay.resize(),this.options.modal&&(r=0,e(".ui-dialog").each(function(){this!==n.uiDialog[0]&&(i=e(this).css("z-index"),isNaN(i)||(r=Math.max(r,i)))}),e.ui.dialog.maxZ=r),this},isOpen:function(){return this._isOpen},moveToTop:function(t,n){var r=this.options,i;return r.modal&&!t||!r.stack&&!r.modal?this._trigger("focus",n):(r.zIndex>e.ui.dialog.maxZ&&(e.ui.dialog.maxZ=r.zIndex),this.overlay&&(e.ui.dialog.maxZ+=1,e.ui.dialog.overlay.maxZ=e.ui.dialog.maxZ,this.overlay.$el.css("z-index",e.ui.dialog.overlay.maxZ)),i={scrollTop:this.element.scrollTop(),scrollLeft:this.element.scrollLeft()},e.ui.dialog.maxZ+=1,this.uiDialog.css("z-index",e.ui.dialog.maxZ),this.element.attr(i),this._trigger("focus",n),this)},open:function(){if(this._isOpen)return;var t,n=this.options,r=this.uiDialog;return this._size(),this._position(n.position),r.show(n.show),this.overlay=n.modal?new e.ui.dialog.overlay(this):null,this.moveToTop(!0),t=this.element.find(":tabbable"),t.length||(t=this.uiDialogButtonPane.find(":tabbable"),t.length||(t=r)),t.eq(0).focus(),this._isOpen=!0,this._trigger("open"),this},_createButtons:function(t){var n=this,r=!1;this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),typeof t=="object"&&t!==null&&e.each(t,function(){return!(r=!0)}),r?(e.each(t,function(t,r){var i,s;r=e.isFunction(r)?{click:r,text:t}:r,r=e.extend({type:"button"},r),s=r.click,r.click=function(){s.apply(n.element[0],arguments)},i=e("<button></button>",r).appendTo(n.uiButtonSet),e.fn.button&&i.button()}),this.uiDialog.addClass("ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog)):this.uiDialog.removeClass("ui-dialog-buttons")},_makeDraggable:function(){function r(e){return{position:e.position,offset:e.offset}}var t=this,n=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(n,i){e(this).addClass("ui-dialog-dragging"),t._trigger("dragStart",n,r(i))},drag:function(e,n){t._trigger("drag",e,r(n))},stop:function(i,s){n.position=[s.position.left-t.document.scrollLeft(),s.position.top-t.document.scrollTop()],e(this).removeClass("ui-dialog-dragging"),t._trigger("dragStop",i,r(s)),e.ui.dialog.overlay.resize()}})},_makeResizable:function(n){function u(e){return{originalPosition:e.originalPosition,originalSize:e.originalSize,position:e.position,size:e.size}}n=n===t?this.options.resizable:n;var r=this,i=this.options,s=this.uiDialog.css("position"),o=typeof n=="string"?n:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:i.maxWidth,maxHeight:i.maxHeight,minWidth:i.minWidth,minHeight:this._minHeight(),handles:o,start:function(t,n){e(this).addClass("ui-dialog-resizing"),r._trigger("resizeStart",t,u(n))},resize:function(e,t){r._trigger("resize",e,u(t))},stop:function(t,n){e(this).removeClass("ui-dialog-resizing"),i.height=e(this).height(),i.width=e(this).width(),r._trigger("resizeStop",t,u(n)),e.ui.dialog.overlay.resize()}}).css("position",s).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var e=this.options;return e.height==="auto"?e.minHeight:Math.min(e.minHeight,e.height)},_position:function(t){var n=[],r=[0,0],i;if(t){if(typeof t=="string"||typeof t=="object"&&"0"in t)n=t.split?t.split(" "):[t[0],t[1]],n.length===1&&(n[1]=n[0]),e.each(["left","top"],function(e,t){+n[e]===n[e]&&(r[e]=n[e],n[e]=t)}),t={my:n[0]+(r[0]<0?r[0]:"+"+r[0])+" "+n[1]+(r[1]<0?r[1]:"+"+r[1]),at:n.join(" ")};t=e.extend({},e.ui.dialog.prototype.options.position,t)}else t=e.ui.dialog.prototype.options.position;i=this.uiDialog.is(":visible"),i||this.uiDialog.show(),this.uiDialog.position(t),i||this.uiDialog.hide()},_setOptions:function(t){var n=this,s={},o=!1;e.each(t,function(e,t){n._setOption(e,t),e in r&&(o=!0),e in i&&(s[e]=t)}),o&&this._size(),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",s)},_setOption:function(t,r){var i,s,o=this.uiDialog;switch(t){case"buttons":this._createButtons(r);break;case"closeText":this.uiDialogTitlebarCloseText.text(""+r);break;case"dialogClass":o.removeClass(this.options.dialogClass).addClass(n+r);break;case"disabled":r?o.addClass("ui-dialog-disabled"):o.removeClass("ui-dialog-disabled");break;case"draggable":i=o.is(":data(draggable)"),i&&!r&&o.draggable("destroy"),!i&&r&&this._makeDraggable();break;case"position":this._position(r);break;case"resizable":s=o.is(":data(resizable)"),s&&!r&&o.resizable("destroy"),s&&typeof r=="string"&&o.resizable("option","handles",r),!s&&r!==!1&&this._makeResizable(r);break;case"title":e(".ui-dialog-title",this.uiDialogTitlebar).html(""+(r||" "))}this._super(t,r)},_size:function(){var t,n,r,i=this.options,s=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0}),i.minWidth>i.width&&(i.width=i.minWidth),t=this.uiDialog.css({height:"auto",width:i.width}).outerHeight(),n=Math.max(0,i.minHeight-t),i.height==="auto"?e.support.minHeight?this.element.css({minHeight:n,height:"auto"}):(this.uiDialog.show(),r=this.element.css("height","auto").height(),s||this.uiDialog.hide(),this.element.height(Math.max(r,n))):this.element.height(Math.max(i.height-t,0)),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}}),e.extend(e.ui.dialog,{uuid:0,maxZ:0,getTitleId:function(e){var t=e.attr("id");return t||(this.uuid+=1,t=this.uuid),"ui-dialog-title-"+t},overlay:function(t){this.$el=e.ui.dialog.overlay.create(t)}}),e.extend(e.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:e.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(e){return e+".dialog-overlay"}).join(" "),create:function(t){this.instances.length===0&&(setTimeout(function(){e.ui.dialog.overlay.instances.length&&e(document).bind(e.ui.dialog.overlay.events,function(t){if(e(t.target).zIndex()<e.ui.dialog.overlay.maxZ)return!1})},1),e(window).bind("resize.dialog-overlay",e.ui.dialog.overlay.resize));var n=this.oldInstances.pop()||e("<div>").addClass("ui-widget-overlay");return e(document).bind("keydown.dialog-overlay",function(r){var i=e.ui.dialog.overlay.instances;i.length!==0&&i[i.length-1]===n&&t.options.closeOnEscape&&!r.isDefaultPrevented()&&r.keyCode&&r.keyCode===e.ui.keyCode.ESCAPE&&(t.close(r),r.preventDefault())}),n.appendTo(document.body).css({width:this.width(),height:this.height()}),e.fn.bgiframe&&n.bgiframe(),this.instances.push(n),n},destroy:function(t){var n=e.inArray(t,this.instances),r=0;n!==-1&&this.oldInstances.push(this.instances.splice(n,1)[0]),this.instances.length===0&&e([document,window]).unbind(".dialog-overlay"),t.height(0).width(0).remove(),e.each(this.instances,function(){r=Math.max(r,this.css("z-index"))}),this.maxZ=r},height:function(){var t,n;return e.ui.ie?(t=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),n=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight),t<n?e(window).height()+"px":t+"px"):e(document).height()+"px"},width:function(){var t,n;return e.ui.ie?(t=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),n=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth),t<n?e(window).width()+"px":t+"px"):e(document).width()+"px"},resize:function(){var t=e([]);e.each(e.ui.dialog.overlay.instances,function(){t=t.add(this)}),t.css({width:0,height:0}).css({width:e.ui.dialog.overlay.width(),height:e.ui.dialog.overlay.height()})}}),e.extend(e.ui.dialog.overlay.prototype,{destroy:function(){e.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);(function(e,t){var n=!1;e.widget("ui.menu",{version:"1.9.2",defaultElement:"<ul>",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},menus:"ul",position:{my:"left top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content ui-corner-all").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}).bind("click"+this.eventNamespace,e.proxy(function(e){this.options.disabled&&e.preventDefault()},this)),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item > a":function(e){e.preventDefault()},"click .ui-state-disabled > a":function(e){e.preventDefault()},"click .ui-menu-item:has(a)":function(t){var r=e(t.target).closest(".ui-menu-item");!n&&r.not(".ui-state-disabled").length&&(n=!0,this.select(t),r.has(".ui-menu").length?this.expand(t):this.element.is(":focus")||(this.element.trigger("focus",[!0]),this.active&&this.active.parents(".ui-menu").length===1&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(t){var n=e(t.currentTarget);n.siblings().children(".ui-state-active").removeClass("ui-state-active"),this.focus(t,n)},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(e,t){var n=this.active||this.element.children(".ui-menu-item").eq(0);t||this.focus(e,n)},blur:function(t){this._delay(function(){e.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(t)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(t){e(t.target).closest(".ui-menu").length||this.collapseAll(t),n=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").andSelf().removeClass("ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").children("a").removeUniqueId().removeClass("ui-corner-all ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var t=e(this);t.data("ui-menu-submenu-carat")&&t.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(t){function a(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}var n,r,i,s,o,u=!0;switch(t.keyCode){case e.ui.keyCode.PAGE_UP:this.previousPage(t);break;case e.ui.keyCode.PAGE_DOWN:this.nextPage(t);break;case e.ui.keyCode.HOME:this._move("first","first",t);break;case e.ui.keyCode.END:this._move("last","last",t);break;case e.ui.keyCode.UP:this.previous(t);break;case e.ui.keyCode.DOWN:this.next(t);break;case e.ui.keyCode.LEFT:this.collapse(t);break;case e.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(t);break;case e.ui.keyCode.ENTER:case e.ui.keyCode.SPACE:this._activate(t);break;case e.ui.keyCode.ESCAPE:this.collapse(t);break;default:u=!1,r=this.previousFilter||"",i=String.fromCharCode(t.keyCode),s=!1,clearTimeout(this.filterTimer),i===r?s=!0:i=r+i,o=new RegExp("^"+a(i),"i"),n=this.activeMenu.children(".ui-menu-item").filter(function(){return o.test(e(this).children("a").text())}),n=s&&n.index(this.active.next())!==-1?this.active.nextAll(".ui-menu-item"):n,n.length||(i=String.fromCharCode(t.keyCode),o=new RegExp("^"+a(i),"i"),n=this.activeMenu.children(".ui-menu-item").filter(function(){return o.test(e(this).children("a").text())})),n.length?(this.focus(t,n),n.length>1?(this.previousFilter=i,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter):delete this.previousFilter}u&&t.preventDefault()},_activate:function(e){this.active.is(".ui-state-disabled")||(this.active.children("a[aria-haspopup='true']").length?this.expand(e):this.select(e))},refresh:function(){var t,n=this.options.icons.submenu,r=this.element.find(this.options.menus);r.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-corner-all").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var t=e(this),r=t.prev("a"),i=e("<span>").addClass("ui-menu-icon ui-icon "+n).data("ui-menu-submenu-carat",!0);r.attr("aria-haspopup","true").prepend(i),t.attr("aria-labelledby",r.attr("id"))}),t=r.add(this.element),t.children(":not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","presentation").children("a").uniqueId().addClass("ui-corner-all").attr({tabIndex:-1,role:this._itemRole()}),t.children(":not(.ui-menu-item)").each(function(){var t=e(this);/[^\-—–\s]/.test(t.text())||t.addClass("ui-widget-content ui-menu-divider")}),t.children(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!e.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},focus:function(e,t){var n,r;this.blur(e,e&&e.type==="focus"),this._scrollIntoView(t),this.active=t.first(),r=this.active.children("a").addClass("ui-state-focus"),this.options.role&&this.element.attr("aria-activedescendant",r.attr("id")),this.active.parent().closest(".ui-menu-item").children("a:first").addClass("ui-state-active"),e&&e.type==="keydown"?this._close():this.timer=this._delay(function(){this._close()},this.delay),n=t.children(".ui-menu"),n.length&&/^mouse/.test(e.type)&&this._startOpening(n),this.activeMenu=t.parent(),this._trigger("focus",e,{item:t})},_scrollIntoView:function(t){var n,r,i,s,o,u;this._hasScroll()&&(n=parseFloat(e.css(this.activeMenu[0],"borderTopWidth"))||0,r=parseFloat(e.css(this.activeMenu[0],"paddingTop"))||0,i=t.offset().top-this.activeMenu.offset().top-n-r,s=this.activeMenu.scrollTop(),o=this.activeMenu.height(),u=t.height(),i<0?this.activeMenu.scrollTop(s+i):i+u>o&&this.activeMenu.scrollTop(s+i-o+u))},blur:function(e,t){t||clearTimeout(this.timer);if(!this.active)return;this.active.children("a").removeClass("ui-state-focus"),this.active=null,this._trigger("blur",e,{item:this.active})},_startOpening:function(e){clearTimeout(this.timer);if(e.attr("aria-hidden")!=="true")return;this.timer=this._delay(function(){this._close(),this._open(e)},this.delay)},_open:function(t){var n=e.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(t.parents(".ui-menu")).hide().attr("aria-hidden","true"),t.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(n)},collapseAll:function(t,n){clearTimeout(this.timer),this.timer=this._delay(function(){var r=n?this.element:e(t&&t.target).closest(this.element.find(".ui-menu"));r.length||(r=this.element),this._close(r),this.blur(t),this.activeMenu=r},this.delay)},_close:function(e){e||(e=this.active?this.active.parent():this.element),e.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false").end().find("a.ui-state-active").removeClass("ui-state-active")},collapse:function(e){var t=this.active&&this.active.parent().closest(".ui-menu-item",this.element);t&&t.length&&(this._close(),this.focus(e,t))},expand:function(e){var t=this.active&&this.active.children(".ui-menu ").children(".ui-menu-item").first();t&&t.length&&(this._open(t.parent()),this._delay(function(){this.focus(e,t)}))},next:function(e){this._move("next","first",e)},previous:function(e){this._move("prev","last",e)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(e,t,n){var r;this.active&&(e==="first"||e==="last"?r=this.active[e==="first"?"prevAll":"nextAll"](".ui-menu-item").eq(-1):r=this.active[e+"All"](".ui-menu-item").eq(0));if(!r||!r.length||!this.active)r=this.activeMenu.children(".ui-menu-item")[t]();this.focus(n,r)},nextPage:function(t){var n,r,i;if(!this.active){this.next(t);return}if(this.isLastItem())return;this._hasScroll()?(r=this.active.offset().top,i=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return n=e(this),n.offset().top-r-i<0}),this.focus(t,n)):this.focus(t,this.activeMenu.children(".ui-menu-item")[this.active?"last":"first"]())},previousPage:function(t){var n,r,i;if(!this.active){this.next(t);return}if(this.isFirstItem())return;this._hasScroll()?(r=this.active.offset().top,i=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return n=e(this),n.offset().top-r+i>0}),this.focus(t,n)):this.focus(t,this.activeMenu.children(".ui-menu-item").first())},_hasScroll:function(){return this.element.outerHeight()<this.element.prop("scrollHeight")},select:function(t){this.active=this.active||e(t.target).closest(".ui-menu-item");var n={item:this.active};this.active.has(".ui-menu").length||this.collapseAll(t,!0),this._trigger("select",t,n)}})})(jQuery);(function(e,t){e.widget("ui.progressbar",{version:"1.9.2",options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()}),this.valueDiv=e("<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>").appendTo(this.element),this.oldValue=this._value(),this._refreshValue()},_destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove()},value:function(e){return e===t?this._value():(this._setOption("value",e),this)},_setOption:function(e,t){e==="value"&&(this.options.value=t,this._refreshValue(),this._value()===this.options.max&&this._trigger("complete")),this._super(e,t)},_value:function(){var e=this.options.value;return typeof e!="number"&&(e=0),Math.min(this.options.max,Math.max(this.min,e))},_percentage:function(){return 100*this._value()/this.options.max},_refreshValue:function(){var e=this.value(),t=this._percentage();this.oldValue!==e&&(this.oldValue=e,this._trigger("change")),this.valueDiv.toggle(e>this.min).toggleClass("ui-corner-right",e===this.options.max).width(t.toFixed(0)+"%"),this.element.attr("aria-valuenow",e)}})})(jQuery);(function(e,t){var n=5;e.widget("ui.slider",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null},_create:function(){var t,r,i=this.options,s=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),o="<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",u=[];this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"+(i.disabled?" ui-slider-disabled ui-disabled":"")),this.range=e([]),i.range&&(i.range===!0&&(i.values||(i.values=[this._valueMin(),this._valueMin()]),i.values.length&&i.values.length!==2&&(i.values=[i.values[0],i.values[0]])),this.range=e("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(i.range==="min"||i.range==="max"?" ui-slider-range-"+i.range:""))),r=i.values&&i.values.length||1;for(t=s.length;t<r;t++)u.push(o);this.handles=s.add(e(u.join("")).appendTo(this.element)),this.handle=this.handles.eq(0),this.handles.add(this.range).filter("a").click(function(e){e.preventDefault()}).mouseenter(function(){i.disabled||e(this).addClass("ui-state-hover")}).mouseleave(function(){e(this).removeClass("ui-state-hover")}).focus(function(){i.disabled?e(this).blur():(e(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),e(this).addClass("ui-state-focus"))}).blur(function(){e(this).removeClass("ui-state-focus")}),this.handles.each(function(t){e(this).data("ui-slider-handle-index",t)}),this._on(this.handles,{keydown:function(t){var r,i,s,o,u=e(t.target).data("ui-slider-handle-index");switch(t.keyCode){case e.ui.keyCode.HOME:case e.ui.keyCode.END:case e.ui.keyCode.PAGE_UP:case e.ui.keyCode.PAGE_DOWN:case e.ui.keyCode.UP:case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:case e.ui.keyCode.LEFT:t.preventDefault();if(!this._keySliding){this._keySliding=!0,e(t.target).addClass("ui-state-active"),r=this._start(t,u);if(r===!1)return}}o=this.options.step,this.options.values&&this.options.values.length?i=s=this.values(u):i=s=this.value();switch(t.keyCode){case e.ui.keyCode.HOME:s=this._valueMin();break;case e.ui.keyCode.END:s=this._valueMax();break;case e.ui.keyCode.PAGE_UP:s=this._trimAlignValue(i+(this._valueMax()-this._valueMin())/n);break;case e.ui.keyCode.PAGE_DOWN:s=this._trimAlignValue(i-(this._valueMax()-this._valueMin())/n);break;case e.ui.keyCode.UP:case e.ui.keyCode.RIGHT:if(i===this._valueMax())return;s=this._trimAlignValue(i+o);break;case e.ui.keyCode.DOWN:case e.ui.keyCode.LEFT:if(i===this._valueMin())return;s=this._trimAlignValue(i-o)}this._slide(t,u,s)},keyup:function(t){var n=e(t.target).data("ui-slider-handle-index");this._keySliding&&(this._keySliding=!1,this._stop(t,n),this._change(t,n),e(t.target).removeClass("ui-state-active"))}}),this._refreshValue(),this._animateOff=!1},_destroy:function(){this.handles.remove(),this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all"),this._mouseDestroy()},_mouseCapture:function(t){var n,r,i,s,o,u,a,f,l=this,c=this.options;return c.disabled?!1:(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),n={x:t.pageX,y:t.pageY},r=this._normValueFromMouse(n),i=this._valueMax()-this._valueMin()+1,this.handles.each(function(t){var n=Math.abs(r-l.values(t));i>n&&(i=n,s=e(this),o=t)}),c.range===!0&&this.values(1)===c.min&&(o+=1,s=e(this.handles[o])),u=this._start(t,o),u===!1?!1:(this._mouseSliding=!0,this._handleIndex=o,s.addClass("ui-state-active").focus(),a=s.offset(),f=!e(t.target).parents().andSelf().is(".ui-slider-handle"),this._clickOffset=f?{left:0,top:0}:{left:t.pageX-a.left-s.width()/2,top:t.pageY-a.top-s.height()/2-(parseInt(s.css("borderTopWidth"),10)||0)-(parseInt(s.css("borderBottomWidth"),10)||0)+(parseInt(s.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(t,o,r),this._animateOff=!0,!0))},_mouseStart:function(){return!0},_mouseDrag:function(e){var t={x:e.pageX,y:e.pageY},n=this._normValueFromMouse(t);return this._slide(e,this._handleIndex,n),!1},_mouseStop:function(e){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(e,this._handleIndex),this._change(e,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(e){var t,n,r,i,s;return this.orientation==="horizontal"?(t=this.elementSize.width,n=e.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(t=this.elementSize.height,n=e.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),r=n/t,r>1&&(r=1),r<0&&(r=0),this.orientation==="vertical"&&(r=1-r),i=this._valueMax()-this._valueMin(),s=this._valueMin()+r*i,this._trimAlignValue(s)},_start:function(e,t){var n={handle:this.handles[t],value:this.value()};return this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._trigger("start",e,n)},_slide:function(e,t,n){var r,i,s;this.options.values&&this.options.values.length?(r=this.values(t?0:1),this.options.values.length===2&&this.options.range===!0&&(t===0&&n>r||t===1&&n<r)&&(n=r),n!==this.values(t)&&(i=this.values(),i[t]=n,s=this._trigger("slide",e,{handle:this.handles[t],value:n,values:i}),r=this.values(t?0:1),s!==!1&&this.values(t,n,!0))):n!==this.value()&&(s=this._trigger("slide",e,{handle:this.handles[t],value:n}),s!==!1&&this.value(n))},_stop:function(e,t){var n={handle:this.handles[t],value:this.value()};this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._trigger("stop",e,n)},_change:function(e,t){if(!this._keySliding&&!this._mouseSliding){var n={handle:this.handles[t],value:this.value()};this.options.values&&this.options.values.length&&(n.value=this.values(t),n.values=this.values()),this._trigger("change",e,n)}},value:function(e){if(arguments.length){this.options.value=this._trimAlignValue(e),this._refreshValue(),this._change(null,0);return}return this._value()},values:function(t,n){var r,i,s;if(arguments.length>1){this.options.values[t]=this._trimAlignValue(n),this._refreshValue(),this._change(null,t);return}if(!arguments.length)return this._values();if(!e.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(t):this.value();r=this.options.values,i=arguments[0];for(s=0;s<r.length;s+=1)r[s]=this._trimAlignValue(i[s]),this._change(null,s);this._refreshValue()},_setOption:function(t,n){var r,i=0;e.isArray(this.options.values)&&(i=this.options.values.length),e.Widget.prototype._setOption.apply(this,arguments);switch(t){case"disabled":n?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.prop("disabled",!0),this.element.addClass("ui-disabled")):(this.handles.prop("disabled",!1),this.element.removeClass("ui-disabled"));break;case"orientation":this._detectOrientation(),this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation),this._refreshValue();break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":this._animateOff=!0,this._refreshValue();for(r=0;r<i;r+=1)this._change(null,r);this._animateOff=!1;break;case"min":case"max":this._animateOff=!0,this._refreshValue(),this._animateOff=!1}},_value:function(){var e=this.options.value;return e=this._trimAlignValue(e),e},_values:function(e){var t,n,r;if(arguments.length)return t=this.options.values[e],t=this._trimAlignValue(t),t;n=this.options.values.slice();for(r=0;r<n.length;r+=1)n[r]=this._trimAlignValue(n[r]);return n},_trimAlignValue:function(e){if(e<=this._valueMin())return this._valueMin();if(e>=this._valueMax())return this._valueMax();var t=this.options.step>0?this.options.step:1,n=(e-this._valueMin())%t,r=e-n;return Math.abs(n)*2>=t&&(r+=n>0?t:-t),parseFloat(r.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var t,n,r,i,s,o=this.options.range,u=this.options,a=this,f=this._animateOff?!1:u.animate,l={};this.options.values&&this.options.values.length?this.handles.each(function(r){n=(a.values(r)-a._valueMin())/(a._valueMax()-a._valueMin())*100,l[a.orientation==="horizontal"?"left":"bottom"]=n+"%",e(this).stop(1,1)[f?"animate":"css"](l,u.animate),a.options.range===!0&&(a.orientation==="horizontal"?(r===0&&a.range.stop(1,1)[f?"animate":"css"]({left:n+"%"},u.animate),r===1&&a.range[f?"animate":"css"]({width:n-t+"%"},{queue:!1,duration:u.animate})):(r===0&&a.range.stop(1,1)[f?"animate":"css"]({bottom:n+"%"},u.animate),r===1&&a.range[f?"animate":"css"]({height:n-t+"%"},{queue:!1,duration:u.animate}))),t=n}):(r=this.value(),i=this._valueMin(),s=this._valueMax(),n=s!==i?(r-i)/(s-i)*100:0,l[this.orientation==="horizontal"?"left":"bottom"]=n+"%",this.handle.stop(1,1)[f?"animate":"css"](l,u.animate),o==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[f?"animate":"css"]({width:n+"%"},u.animate),o==="max"&&this.orientation==="horizontal"&&this.range[f?"animate":"css"]({width:100-n+"%"},{queue:!1,duration:u.animate}),o==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[f?"animate":"css"]({height:n+"%"},u.animate),o==="max"&&this.orientation==="vertical"&&this.range[f?"animate":"css"]({height:100-n+"%"},{queue:!1,duration:u.animate}))}})})(jQuery);(function(e){function t(e){return function(){var t=this.element.val();e.apply(this,arguments),this._refresh(),t!==this.element.val()&&this._trigger("change")}}e.widget("ui.spinner",{version:"1.9.2",defaultElement:"<input>",widgetEventPrefix:"spin",options:{culture:null,icons:{down:"ui-icon-triangle-1-s",up:"ui-icon-triangle-1-n"},incremental:!0,max:null,min:null,numberFormat:null,page:10,step:1,change:null,spin:null,start:null,stop:null},_create:function(){this._setOption("max",this.options.max),this._setOption("min",this.options.min),this._setOption("step",this.options.step),this._value(this.element.val(),!0),this._draw(),this._on(this._events),this._refresh(),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_getCreateOptions:function(){var t={},n=this.element;return e.each(["min","max","step"],function(e,r){var i=n.attr(r);i!==undefined&&i.length&&(t[r]=i)}),t},_events:{keydown:function(e){this._start(e)&&this._keydown(e)&&e.preventDefault()},keyup:"_stop",focus:function(){this.previous=this.element.val()},blur:function(e){if(this.cancelBlur){delete this.cancelBlur;return}this._refresh(),this.previous!==this.element.val()&&this._trigger("change",e)},mousewheel:function(e,t){if(!t)return;if(!this.spinning&&!this._start(e))return!1;this._spin((t>0?1:-1)*this.options.step,e),clearTimeout(this.mousewheelTimer),this.mousewheelTimer=this._delay(function(){this.spinning&&this._stop(e)},100),e.preventDefault()},"mousedown .ui-spinner-button":function(t){function r(){var e=this.element[0]===this.document[0].activeElement;e||(this.element.focus(),this.previous=n,this._delay(function(){this.previous=n}))}var n;n=this.element[0]===this.document[0].activeElement?this.previous:this.element.val(),t.preventDefault(),r.call(this),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,r.call(this)});if(this._start(t)===!1)return;this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseup .ui-spinner-button":"_stop","mouseenter .ui-spinner-button":function(t){if(!e(t.currentTarget).hasClass("ui-state-active"))return;if(this._start(t)===!1)return!1;this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseleave .ui-spinner-button":"_stop"},_draw:function(){var e=this.uiSpinner=this.element.addClass("ui-spinner-input").attr("autocomplete","off").wrap(this._uiSpinnerHtml()).parent().append(this._buttonHtml());this.element.attr("role","spinbutton"),this.buttons=e.find(".ui-spinner-button").attr("tabIndex",-1).button().removeClass("ui-corner-all"),this.buttons.height()>Math.ceil(e.height()*.5)&&e.height()>0&&e.height(e.height()),this.options.disabled&&this.disable()},_keydown:function(t){var n=this.options,r=e.ui.keyCode;switch(t.keyCode){case r.UP:return this._repeat(null,1,t),!0;case r.DOWN:return this._repeat(null,-1,t),!0;case r.PAGE_UP:return this._repeat(null,n.page,t),!0;case r.PAGE_DOWN:return this._repeat(null,-n.page,t),!0}return!1},_uiSpinnerHtml:function(){return"<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>"},_buttonHtml:function(){return"<a class='ui-spinner-button ui-spinner-up ui-corner-tr'><span class='ui-icon "+this.options.icons.up+"'>▲</span>"+"</a>"+"<a class='ui-spinner-button ui-spinner-down ui-corner-br'>"+"<span class='ui-icon "+this.options.icons.down+"'>▼</span>"+"</a>"},_start:function(e){return!this.spinning&&this._trigger("start",e)===!1?!1:(this.counter||(this.counter=1),this.spinning=!0,!0)},_repeat:function(e,t,n){e=e||500,clearTimeout(this.timer),this.timer=this._delay(function(){this._repeat(40,t,n)},e),this._spin(t*this.options.step,n)},_spin:function(e,t){var n=this.value()||0;this.counter||(this.counter=1),n=this._adjustValue(n+e*this._increment(this.counter));if(!this.spinning||this._trigger("spin",t,{value:n})!==!1)this._value(n),this.counter++},_increment:function(t){var n=this.options.incremental;return n?e.isFunction(n)?n(t):Math.floor(t*t*t/5e4-t*t/500+17*t/200+1):1},_precision:function(){var e=this._precisionOf(this.options.step);return this.options.min!==null&&(e=Math.max(e,this._precisionOf(this.options.min))),e},_precisionOf:function(e){var t=e.toString(),n=t.indexOf(".");return n===-1?0:t.length-n-1},_adjustValue:function(e){var t,n,r=this.options;return t=r.min!==null?r.min:0,n=e-t,n=Math.round(n/r.step)*r.step,e=t+n,e=parseFloat(e.toFixed(this._precision())),r.max!==null&&e>r.max?r.max:r.min!==null&&e<r.min?r.min:e},_stop:function(e){if(!this.spinning)return;clearTimeout(this.timer),clearTimeout(this.mousewheelTimer),this.counter=0,this.spinning=!1,this._trigger("stop",e)},_setOption:function(e,t){if(e==="culture"||e==="numberFormat"){var n=this._parse(this.element.val());this.options[e]=t,this.element.val(this._format(n));return}(e==="max"||e==="min"||e==="step")&&typeof t=="string"&&(t=this._parse(t)),this._super(e,t),e==="disabled"&&(t?(this.element.prop("disabled",!0),this.buttons.button("disable")):(this.element.prop("disabled",!1),this.buttons.button("enable")))},_setOptions:t(function(e){this._super(e),this._value(this.element.val())}),_parse:function(e){return typeof e=="string"&&e!==""&&(e=window.Globalize&&this.options.numberFormat?Globalize.parseFloat(e,10,this.options.culture):+e),e===""||isNaN(e)?null:e},_format:function(e){return e===""?"":window.Globalize&&this.options.numberFormat?Globalize.format(e,this.options.numberFormat,this.options.culture):e},_refresh:function(){this.element.attr({"aria-valuemin":this.options.min,"aria-valuemax":this.options.max,"aria-valuenow":this._parse(this.element.val())})},_value:function(e,t){var n;e!==""&&(n=this._parse(e),n!==null&&(t||(n=this._adjustValue(n)),e=this._format(n))),this.element.val(e),this._refresh()},_destroy:function(){this.element.removeClass("ui-spinner-input").prop("disabled",!1).removeAttr("autocomplete").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.uiSpinner.replaceWith(this.element)},stepUp:t(function(e){this._stepUp(e)}),_stepUp:function(e){this._spin((e||1)*this.options.step)},stepDown:t(function(e){this._stepDown(e)}),_stepDown:function(e){this._spin((e||1)*-this.options.step)},pageUp:t(function(e){this._stepUp((e||1)*this.options.page)}),pageDown:t(function(e){this._stepDown((e||1)*this.options.page)}),value:function(e){if(!arguments.length)return this._parse(this.element.val());t(this._value).call(this,e)},widget:function(){return this.uiSpinner}})})(jQuery);(function(e,t){function i(){return++n}function s(e){return e.hash.length>1&&e.href.replace(r,"")===location.href.replace(r,"").replace(/\s/g,"%20")}var n=0,r=/#.*$/;e.widget("ui.tabs",{version:"1.9.2",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_create:function(){var t=this,n=this.options,r=n.active,i=location.hash.substring(1);this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",n.collapsible).delegate(".ui-tabs-nav > li","mousedown"+this.eventNamespace,function(t){e(this).is(".ui-state-disabled")&&t.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){e(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this._processTabs();if(r===null){i&&this.tabs.each(function(t,n){if(e(n).attr("aria-controls")===i)return r=t,!1}),r===null&&(r=this.tabs.index(this.tabs.filter(".ui-tabs-active")));if(r===null||r===-1)r=this.tabs.length?0:!1}r!==!1&&(r=this.tabs.index(this.tabs.eq(r)),r===-1&&(r=n.collapsible?!1:0)),n.active=r,!n.collapsible&&n.active===!1&&this.anchors.length&&(n.active=0),e.isArray(n.disabled)&&(n.disabled=e.unique(n.disabled.concat(e.map(this.tabs.filter(".ui-state-disabled"),function(e){return t.tabs.index(e)}))).sort()),this.options.active!==!1&&this.anchors.length?this.active=this._findActive(this.options.active):this.active=e(),this._refresh(),this.active.length&&this.load(n.active)},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):e()}},_tabKeydown:function(t){var n=e(this.document[0].activeElement).closest("li"),r=this.tabs.index(n),i=!0;if(this._handlePageNav(t))return;switch(t.keyCode){case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:r++;break;case e.ui.keyCode.UP:case e.ui.keyCode.LEFT:i=!1,r--;break;case e.ui.keyCode.END:r=this.anchors.length-1;break;case e.ui.keyCode.HOME:r=0;break;case e.ui.keyCode.SPACE:t.preventDefault(),clearTimeout(this.activating),this._activate(r);return;case e.ui.keyCode.ENTER:t.preventDefault(),clearTimeout(this.activating),this._activate(r===this.options.active?!1:r);return;default:return}t.preventDefault(),clearTimeout(this.activating),r=this._focusNextTab(r,i),t.ctrlKey||(n.attr("aria-selected","false"),this.tabs.eq(r).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",r)},this.delay))},_panelKeydown:function(t){if(this._handlePageNav(t))return;t.ctrlKey&&t.keyCode===e.ui.keyCode.UP&&(t.preventDefault(),this.active.focus())},_handlePageNav:function(t){if(t.altKey&&t.keyCode===e.ui.keyCode.PAGE_UP)return this._activate(this._focusNextTab(this.options.active-1,!1)),!0;if(t.altKey&&t.keyCode===e.ui.keyCode.PAGE_DOWN)return this._activate(this._focusNextTab(this.options.active+1,!0)),!0},_findNextTab:function(t,n){function i(){return t>r&&(t=0),t<0&&(t=r),t}var r=this.tabs.length-1;while(e.inArray(i(),this.options.disabled)!==-1)t=n?t+1:t-1;return t},_focusNextTab:function(e,t){return e=this._findNextTab(e,t),this.tabs.eq(e).focus(),e},_setOption:function(e,t){if(e==="active"){this._activate(t);return}if(e==="disabled"){this._setupDisabled(t);return}this._super(e,t),e==="collapsible"&&(this.element.toggleClass("ui-tabs-collapsible",t),!t&&this.options.active===!1&&this._activate(0)),e==="event"&&this._setupEvents(t),e==="heightStyle"&&this._setupHeightStyle(t)},_tabId:function(e){return e.attr("aria-controls")||"ui-tabs-"+i()},_sanitizeSelector:function(e){return e?e.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var t=this.options,n=this.tablist.children(":has(a[href])");t.disabled=e.map(n.filter(".ui-state-disabled"),function(e){return n.index(e)}),this._processTabs(),t.active===!1||!this.anchors.length?(t.active=!1,this.active=e()):this.active.length&&!e.contains(this.tablist[0],this.active[0])?this.tabs.length===t.disabled.length?(t.active=!1,this.active=e()):this._activate(this._findNextTab(Math.max(0,t.active-1),!1)):t.active=this.tabs.index(this.active),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-expanded":"false","aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-expanded":"true","aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var t=this;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist"),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return e("a",this)[0]}).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=e(),this.anchors.each(function(n,r){var i,o,u,a=e(r).uniqueId().attr("id"),f=e(r).closest("li"),l=f.attr("aria-controls");s(r)?(i=r.hash,o=t.element.find(t._sanitizeSelector(i))):(u=t._tabId(f),i="#"+u,o=t.element.find(i),o.length||(o=t._createPanel(u),o.insertAfter(t.panels[n-1]||t.tablist)),o.attr("aria-live","polite")),o.length&&(t.panels=t.panels.add(o)),l&&f.data("ui-tabs-aria-controls",l),f.attr({"aria-controls":i.substring(1),"aria-labelledby":a}),o.attr("aria-labelledby",a)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel")},_getList:function(){return this.element.find("ol,ul").eq(0)},_createPanel:function(t){return e("<div>").attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(t){e.isArray(t)&&(t.length?t.length===this.anchors.length&&(t=!0):t=!1);for(var n=0,r;r=this.tabs[n];n++)t===!0||e.inArray(n,t)!==-1?e(r).addClass("ui-state-disabled").attr("aria-disabled","true"):e(r).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=t},_setupEvents:function(t){var n={click:function(e){e.preventDefault()}};t&&e.each(t.split(" "),function(e,t){n[t]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(this.anchors,n),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(t){var n,r,i=this.element.parent();t==="fill"?(e.support.minHeight||(r=i.css("overflow"),i.css("overflow","hidden")),n=i.height(),this.element.siblings(":visible").each(function(){var t=e(this),r=t.css("position");if(r==="absolute"||r==="fixed")return;n-=t.outerHeight(!0)}),r&&i.css("overflow",r),this.element.children().not(this.panels).each(function(){n-=e(this).outerHeight(!0)}),this.panels.each(function(){e(this).height(Math.max(0,n-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):t==="auto"&&(n=0,this.panels.each(function(){n=Math.max(n,e(this).height("").height())}).height(n))},_eventHandler:function(t){var n=this.options,r=this.active,i=e(t.currentTarget),s=i.closest("li"),o=s[0]===r[0],u=o&&n.collapsible,a=u?e():this._getPanelForTab(s),f=r.length?this._getPanelForTab(r):e(),l={oldTab:r,oldPanel:f,newTab:u?e():s,newPanel:a};t.preventDefault();if(s.hasClass("ui-state-disabled")||s.hasClass("ui-tabs-loading")||this.running||o&&!n.collapsible||this._trigger("beforeActivate",t,l)===!1)return;n.active=u?!1:this.tabs.index(s),this.active=o?e():s,this.xhr&&this.xhr.abort(),!f.length&&!a.length&&e.error("jQuery UI Tabs: Mismatching fragment identifier."),a.length&&this.load(this.tabs.index(s),t),this._toggle(t,l)},_toggle:function(t,n){function o(){r.running=!1,r._trigger("activate",t,n)}function u(){n.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),i.length&&r.options.show?r._show(i,r.options.show,o):(i.show(),o())}var r=this,i=n.newPanel,s=n.oldPanel;this.running=!0,s.length&&this.options.hide?this._hide(s,this.options.hide,function(){n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),u()}):(n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),s.hide(),u()),s.attr({"aria-expanded":"false","aria-hidden":"true"}),n.oldTab.attr("aria-selected","false"),i.length&&s.length?n.oldTab.attr("tabIndex",-1):i.length&&this.tabs.filter(function(){return e(this).attr("tabIndex")===0}).attr("tabIndex",-1),i.attr({"aria-expanded":"true","aria-hidden":"false"}),n.newTab.attr({"aria-selected":"true",tabIndex:0})},_activate:function(t){var n,r=this._findActive(t);if(r[0]===this.active[0])return;r.length||(r=this.active),n=r.find(".ui-tabs-anchor")[0],this._eventHandler({target:n,currentTarget:n,preventDefault:e.noop})},_findActive:function(t){return t===!1?e():this.tabs.eq(t)},_getIndex:function(e){return typeof e=="string"&&(e=this.anchors.index(this.anchors.filter("[href$='"+e+"']"))),e},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeData("href.tabs").removeData("load.tabs").removeUniqueId(),this.tabs.add(this.panels).each(function(){e.data(this,"ui-tabs-destroy")?e(this).remove():e(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var t=e(this),n=t.data("ui-tabs-aria-controls");n?t.attr("aria-controls",n):t.removeAttr("aria-controls")}),this.panels.show(),this.options.heightStyle!=="content"&&this.panels.css("height","")},enable:function(n){var r=this.options.disabled;if(r===!1)return;n===t?r=!1:(n=this._getIndex(n),e.isArray(r)?r=e.map(r,function(e){return e!==n?e:null}):r=e.map(this.tabs,function(e,t){return t!==n?t:null})),this._setupDisabled(r)},disable:function(n){var r=this.options.disabled;if(r===!0)return;if(n===t)r=!0;else{n=this._getIndex(n);if(e.inArray(n,r)!==-1)return;e.isArray(r)?r=e.merge([n],r).sort():r=[n]}this._setupDisabled(r)},load:function(t,n){t=this._getIndex(t);var r=this,i=this.tabs.eq(t),o=i.find(".ui-tabs-anchor"),u=this._getPanelForTab(i),a={tab:i,panel:u};if(s(o[0]))return;this.xhr=e.ajax(this._ajaxSettings(o,n,a)),this.xhr&&this.xhr.statusText!=="canceled"&&(i.addClass("ui-tabs-loading"),u.attr("aria-busy","true"),this.xhr.success(function(e){setTimeout(function(){u.html(e),r._trigger("load",n,a)},1)}).complete(function(e,t){setTimeout(function(){t==="abort"&&r.panels.stop(!1,!0),i.removeClass("ui-tabs-loading"),u.removeAttr("aria-busy"),e===r.xhr&&delete r.xhr},1)}))},_ajaxSettings:function(t,n,r){var i=this;return{url:t.attr("href"),beforeSend:function(t,s){return i._trigger("beforeLoad",n,e.extend({jqXHR:t,ajaxSettings:s},r))}}},_getPanelForTab:function(t){var n=e(t).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+n))}}),e.uiBackCompat!==!1&&(e.ui.tabs.prototype._ui=function(e,t){return{tab:e,panel:t,index:this.anchors.index(e)}},e.widget("ui.tabs",e.ui.tabs,{url:function(e,t){this.anchors.eq(e).attr("href",t)}}),e.widget("ui.tabs",e.ui.tabs,{options:{ajaxOptions:null,cache:!1},_create:function(){this._super();var t=this;this._on({tabsbeforeload:function(n,r){if(e.data(r.tab[0],"cache.tabs")){n.preventDefault();return}r.jqXHR.success(function(){t.options.cache&&e.data(r.tab[0],"cache.tabs",!0)})}})},_ajaxSettings:function(t,n,r){var i=this.options.ajaxOptions;return e.extend({},i,{error:function(e,t){try{i.error(e,t,r.tab.closest("li").index(),r.tab[0])}catch(n){}}},this._superApply(arguments))},_setOption:function(e,t){e==="cache"&&t===!1&&this.anchors.removeData("cache.tabs"),this._super(e,t)},_destroy:function(){this.anchors.removeData("cache.tabs"),this._super()},url:function(e){this.anchors.eq(e).removeData("cache.tabs"),this._superApply(arguments)}}),e.widget("ui.tabs",e.ui.tabs,{abort:function(){this.xhr&&this.xhr.abort()}}),e.widget("ui.tabs",e.ui.tabs,{options:{spinner:"<em>Loading…</em>"},_create:function(){this._super(),this._on({tabsbeforeload:function(e,t){if(e.target!==this.element[0]||!this.options.spinner)return;var n=t.tab.find("span"),r=n.html();n.html(this.options.spinner),t.jqXHR.complete(function(){n.html(r)})}})}}),e.widget("ui.tabs",e.ui.tabs,{options:{enable:null,disable:null},enable:function(t){var n=this.options,r;if(t&&n.disabled===!0||e.isArray(n.disabled)&&e.inArray(t,n.disabled)!==-1)r=!0;this._superApply(arguments),r&&this._trigger("enable",null,this._ui(this.anchors[t],this.panels[t]))},disable:function(t){var n=this.options,r;if(t&&n.disabled===!1||e.isArray(n.disabled)&&e.inArray(t,n.disabled)===-1)r=!0;this._superApply(arguments),r&&this._trigger("disable",null,this._ui(this.anchors[t],this.panels[t]))}}),e.widget("ui.tabs",e.ui.tabs,{options:{add:null,remove:null,tabTemplate:"<li><a href='#{href}'><span>#{label}</span></a></li>"},add:function(n,r,i){i===t&&(i=this.anchors.length);var s,o,u=this.options,a=e(u.tabTemplate.replace(/#\{href\}/g,n).replace(/#\{label\}/g,r)),f=n.indexOf("#")?this._tabId(a):n.replace("#","");return a.addClass("ui-state-default ui-corner-top").data("ui-tabs-destroy",!0),a.attr("aria-controls",f),s=i>=this.tabs.length,o=this.element.find("#"+f),o.length||(o=this._createPanel(f),s?i>0?o.insertAfter(this.panels.eq(-1)):o.appendTo(this.element):o.insertBefore(this.panels[i])),o.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").hide(),s?a.appendTo(this.tablist):a.insertBefore(this.tabs[i]),u.disabled=e.map(u.disabled,function(e){return e>=i?++e:e}),this.refresh(),this.tabs.length===1&&u.active===!1&&this.option("active",0),this._trigger("add",null,this._ui(this.anchors[i],this.panels[i])),this},remove:function(t){t=this._getIndex(t);var n=this.options,r=this.tabs.eq(t).remove(),i=this._getPanelForTab(r).remove();return r.hasClass("ui-tabs-active")&&this.anchors.length>2&&this._activate(t+(t+1<this.anchors.length?1:-1)),n.disabled=e.map(e.grep(n.disabled,function(e){return e!==t}),function(e){return e>=t?--e:e}),this.refresh(),this._trigger("remove",null,this._ui(r.find("a")[0],i[0])),this}}),e.widget("ui.tabs",e.ui.tabs,{length:function(){return this.anchors.length}}),e.widget("ui.tabs",e.ui.tabs,{options:{idPrefix:"ui-tabs-"},_tabId:function(t){var n=t.is("li")?t.find("a[href]"):t;return n=n[0],e(n).closest("li").attr("aria-controls")||n.title&&n.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF\-]/g,"")||this.options.idPrefix+i()}}),e.widget("ui.tabs",e.ui.tabs,{options:{panelTemplate:"<div></div>"},_createPanel:function(t){return e(this.options.panelTemplate).attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)}}),e.widget("ui.tabs",e.ui.tabs,{_create:function(){var e=this.options;e.active===null&&e.selected!==t&&(e.active=e.selected===-1?!1:e.selected),this._super(),e.selected=e.active,e.selected===!1&&(e.selected=-1)},_setOption:function(e,t){if(e!=="selected")return this._super(e,t);var n=this.options;this._super("active",t===-1?!1:t),n.selected=n.active,n.selected===!1&&(n.selected=-1)},_eventHandler:function(){this._superApply(arguments),this.options.selected=this.options.active,this.options.selected===!1&&(this.options.selected=-1)}}),e.widget("ui.tabs",e.ui.tabs,{options:{show:null,select:null},_create:function(){this._super(),this.options.active!==!1&&this._trigger("show",null,this._ui(this.active.find(".ui-tabs-anchor")[0],this._getPanelForTab(this.active)[0]))},_trigger:function(e,t,n){var r,i,s=this._superApply(arguments);return s?(e==="beforeActivate"?(r=n.newTab.length?n.newTab:n.oldTab,i=n.newPanel.length?n.newPanel:n.oldPanel,s=this._super("select",t,{tab:r.find(".ui-tabs-anchor")[0],panel:i[0],index:r.closest("li").index()})):e==="activate"&&n.newTab.length&&(s=this._super("show",t,{tab:n.newTab.find(".ui-tabs-anchor")[0],panel:n.newPanel[0],index:n.newTab.closest("li").index()})),s):!1}}),e.widget("ui.tabs",e.ui.tabs,{select:function(e){e=this._getIndex(e);if(e===-1){if(!this.options.collapsible||this.options.selected===-1)return;e=this.options.selected}this.anchors.eq(e).trigger(this.options.event+this.eventNamespace)}}),function(){var t=0;e.widget("ui.tabs",e.ui.tabs,{options:{cookie:null},_create:function(){var e=this.options,t;e.active==null&&e.cookie&&(t=parseInt(this._cookie(),10),t===-1&&(t=!1),e.active=t),this._super()},_cookie:function(n){var r=[this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+ ++t)];return arguments.length&&(r.push(n===!1?-1:n),r.push(this.options.cookie)),e.cookie.apply(null,r)},_refresh:function(){this._super(),this.options.cookie&&this._cookie(this.options.active,this.options.cookie)},_eventHandler:function(){this._superApply(arguments),this.options.cookie&&this._cookie(this.options.active,this.options.cookie)},_destroy:function(){this._super(),this.options.cookie&&this._cookie(null,this.options.cookie)}})}(),e.widget("ui.tabs",e.ui.tabs,{_trigger:function(t,n,r){var i=e.extend({},r);return t==="load"&&(i.panel=i.panel[0],i.tab=i.tab.find(".ui-tabs-anchor")[0]),this._super(t,n,i)}}),e.widget("ui.tabs",e.ui.tabs,{options:{fx:null},_getFx:function(){var t,n,r=this.options.fx;return r&&(e.isArray(r)?(t=r[0],n=r[1]):t=n=r),r?{show:n,hide:t}:null},_toggle:function(e,t){function o(){n.running=!1,n._trigger("activate",e,t)}function u(){t.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),r.length&&s.show?r.animate(s.show,s.show.duration,function(){o()}):(r.show(),o())}var n=this,r=t.newPanel,i=t.oldPanel,s=this._getFx();if(!s)return this._super(e,t);n.running=!0,i.length&&s.hide?i.animate(s.hide,s.hide.duration,function(){t.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),u()}):(t.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),i.hide(),u())}}))})(jQuery);(function(e){function n(t,n){var r=(t.attr("aria-describedby")||"").split(/\s+/);r.push(n),t.data("ui-tooltip-id",n).attr("aria-describedby",e.trim(r.join(" ")))}function r(t){var n=t.data("ui-tooltip-id"),r=(t.attr("aria-describedby")||"").split(/\s+/),i=e.inArray(n,r);i!==-1&&r.splice(i,1),t.removeData("ui-tooltip-id"),r=e.trim(r.join(" ")),r?t.attr("aria-describedby",r):t.removeAttr("aria-describedby")}var t=0;e.widget("ui.tooltip",{version:"1.9.2",options:{content:function(){return e(this).attr("title")},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flip"},show:!0,tooltipClass:null,track:!1,close:null,open:null},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.options.disabled&&this._disable()},_setOption:function(t,n){var r=this;if(t==="disabled"){this[n?"_disable":"_enable"](),this.options[t]=n;return}this._super(t,n),t==="content"&&e.each(this.tooltips,function(e,t){r._updateContent(t)})},_disable:function(){var t=this;e.each(this.tooltips,function(n,r){var i=e.Event("blur");i.target=i.currentTarget=r[0],t.close(i,!0)}),this.element.find(this.options.items).andSelf().each(function(){var t=e(this);t.is("[title]")&&t.data("ui-tooltip-title",t.attr("title")).attr("title","")})},_enable:function(){this.element.find(this.options.items).andSelf().each(function(){var t=e(this);t.data("ui-tooltip-title")&&t.attr("title",t.data("ui-tooltip-title"))})},open:function(t){var n=this,r=e(t?t.target:this.element).closest(this.options.items);if(!r.length||r.data("ui-tooltip-id"))return;r.attr("title")&&r.data("ui-tooltip-title",r.attr("title")),r.data("ui-tooltip-open",!0),t&&t.type==="mouseover"&&r.parents().each(function(){var t=e(this),r;t.data("ui-tooltip-open")&&(r=e.Event("blur"),r.target=r.currentTarget=this,n.close(r,!0)),t.attr("title")&&(t.uniqueId(),n.parents[this.id]={element:this,title:t.attr("title")},t.attr("title",""))}),this._updateContent(r,t)},_updateContent:function(e,t){var n,r=this.options.content,i=this,s=t?t.type:null;if(typeof r=="string")return this._open(t,e,r);n=r.call(e[0],function(n){if(!e.data("ui-tooltip-open"))return;i._delay(function(){t&&(t.type=s),this._open(t,e,n)})}),n&&this._open(t,e,n)},_open:function(t,r,i){function f(e){a.of=e;if(s.is(":hidden"))return;s.position(a)}var s,o,u,a=e.extend({},this.options.position);if(!i)return;s=this._find(r);if(s.length){s.find(".ui-tooltip-content").html(i);return}r.is("[title]")&&(t&&t.type==="mouseover"?r.attr("title",""):r.removeAttr("title")),s=this._tooltip(r),n(r,s.attr("id")),s.find(".ui-tooltip-content").html(i),this.options.track&&t&&/^mouse/.test(t.type)?(this._on(this.document,{mousemove:f}),f(t)):s.position(e.extend({of:r},this.options.position)),s.hide(),this._show(s,this.options.show),this.options.show&&this.options.show.delay&&(u=setInterval(function(){s.is(":visible")&&(f(a.of),clearInterval(u))},e.fx.interval)),this._trigger("open",t,{tooltip:s}),o={keyup:function(t){if(t.keyCode===e.ui.keyCode.ESCAPE){var n=e.Event(t);n.currentTarget=r[0],this.close(n,!0)}},remove:function(){this._removeTooltip(s)}};if(!t||t.type==="mouseover")o.mouseleave="close";if(!t||t.type==="focusin")o.focusout="close";this._on(!0,r,o)},close:function(t){var n=this,i=e(t?t.currentTarget:this.element),s=this._find(i);if(this.closing)return;i.data("ui-tooltip-title")&&i.attr("title",i.data("ui-tooltip-title")),r(i),s.stop(!0),this._hide(s,this.options.hide,function(){n._removeTooltip(e(this))}),i.removeData("ui-tooltip-open"),this._off(i,"mouseleave focusout keyup"),i[0]!==this.element[0]&&this._off(i,"remove"),this._off(this.document,"mousemove"),t&&t.type==="mouseleave"&&e.each(this.parents,function(t,r){e(r.element).attr("title",r.title),delete n.parents[t]}),this.closing=!0,this._trigger("close",t,{tooltip:s}),this.closing=!1},_tooltip:function(n){var r="ui-tooltip-"+t++,i=e("<div>").attr({id:r,role:"tooltip"}).addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content "+(this.options.tooltipClass||""));return e("<div>").addClass("ui-tooltip-content").appendTo(i),i.appendTo(this.document[0].body),e.fn.bgiframe&&i.bgiframe(),this.tooltips[r]=n,i},_find:function(t){var n=t.data("ui-tooltip-id");return n?e("#"+n):e()},_removeTooltip:function(e){e.remove(),delete this.tooltips[e.attr("id")]},_destroy:function(){var t=this;e.each(this.tooltips,function(n,r){var i=e.Event("blur");i.target=i.currentTarget=r[0],t.close(i,!0),e("#"+n).remove(),r.data("ui-tooltip-title")&&(r.attr("title",r.data("ui-tooltip-title")),r.removeData("ui-tooltip-title"))})}})})(jQuery);jQuery.effects||function(e,t){var n=e.uiBackCompat!==!1,r="ui-effects-";e.effects={effect:{}},function(t,n){function p(e,t,n){var r=a[t.type]||{};return e==null?n||!t.def?null:t.def:(e=r.floor?~~e:parseFloat(e),isNaN(e)?t.def:r.mod?(e+r.mod)%r.mod:0>e?0:r.max<e?r.max:e)}function d(e){var n=o(),r=n._rgba=[];return e=e.toLowerCase(),h(s,function(t,i){var s,o=i.re.exec(e),a=o&&i.parse(o),f=i.space||"rgba";if(a)return s=n[f](a),n[u[f].cache]=s[u[f].cache],r=n._rgba=s._rgba,!1}),r.length?(r.join()==="0,0,0,0"&&t.extend(r,c.transparent),n):c[e]}function v(e,t,n){return n=(n+1)%1,n*6<1?e+(t-e)*n*6:n*2<1?t:n*3<2?e+(t-e)*(2/3-n)*6:e}var r="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "),i=/^([\-+])=\s*(\d+\.?\d*)/,s=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,parse:function(e){return[e[1],e[2],e[3],e[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,parse:function(e){return[e[1]*2.55,e[2]*2.55,e[3]*2.55,e[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(e){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(e){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(e){return[e[1],e[2]/100,e[3]/100,e[4]]}}],o=t.Color=function(e,n,r,i){return new t.Color.fn.parse(e,n,r,i)},u={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},a={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},f=o.support={},l=t("<p>")[0],c,h=t.each;l.style.cssText="background-color:rgba(1,1,1,.5)",f.rgba=l.style.backgroundColor.indexOf("rgba")>-1,h(u,function(e,t){t.cache="_"+e,t.props.alpha={idx:3,type:"percent",def:1}}),o.fn=t.extend(o.prototype,{parse:function(r,i,s,a){if(r===n)return this._rgba=[null,null,null,null],this;if(r.jquery||r.nodeType)r=t(r).css(i),i=n;var f=this,l=t.type(r),v=this._rgba=[];i!==n&&(r=[r,i,s,a],l="array");if(l==="string")return this.parse(d(r)||c._default);if(l==="array")return h(u.rgba.props,function(e,t){v[t.idx]=p(r[t.idx],t)}),this;if(l==="object")return r instanceof o?h(u,function(e,t){r[t.cache]&&(f[t.cache]=r[t.cache].slice())}):h(u,function(t,n){var i=n.cache;h(n.props,function(e,t){if(!f[i]&&n.to){if(e==="alpha"||r[e]==null)return;f[i]=n.to(f._rgba)}f[i][t.idx]=p(r[e],t,!0)}),f[i]&&e.inArray(null,f[i].slice(0,3))<0&&(f[i][3]=1,n.from&&(f._rgba=n.from(f[i])))}),this},is:function(e){var t=o(e),n=!0,r=this;return h(u,function(e,i){var s,o=t[i.cache];return o&&(s=r[i.cache]||i.to&&i.to(r._rgba)||[],h(i.props,function(e,t){if(o[t.idx]!=null)return n=o[t.idx]===s[t.idx],n})),n}),n},_space:function(){var e=[],t=this;return h(u,function(n,r){t[r.cache]&&e.push(n)}),e.pop()},transition:function(e,t){var n=o(e),r=n._space(),i=u[r],s=this.alpha()===0?o("transparent"):this,f=s[i.cache]||i.to(s._rgba),l=f.slice();return n=n[i.cache],h(i.props,function(e,r){var i=r.idx,s=f[i],o=n[i],u=a[r.type]||{};if(o===null)return;s===null?l[i]=o:(u.mod&&(o-s>u.mod/2?s+=u.mod:s-o>u.mod/2&&(s-=u.mod)),l[i]=p((o-s)*t+s,r))}),this[r](l)},blend:function(e){if(this._rgba[3]===1)return this;var n=this._rgba.slice(),r=n.pop(),i=o(e)._rgba;return o(t.map(n,function(e,t){return(1-r)*i[t]+r*e}))},toRgbaString:function(){var e="rgba(",n=t.map(this._rgba,function(e,t){return e==null?t>2?1:0:e});return n[3]===1&&(n.pop(),e="rgb("),e+n.join()+")"},toHslaString:function(){var e="hsla(",n=t.map(this.hsla(),function(e,t){return e==null&&(e=t>2?1:0),t&&t<3&&(e=Math.round(e*100)+"%"),e});return n[3]===1&&(n.pop(),e="hsl("),e+n.join()+")"},toHexString:function(e){var n=this._rgba.slice(),r=n.pop();return e&&n.push(~~(r*255)),"#"+t.map(n,function(e){return e=(e||0).toString(16),e.length===1?"0"+e:e}).join("")},toString:function(){return this._rgba[3]===0?"transparent":this.toRgbaString()}}),o.fn.parse.prototype=o.fn,u.hsla.to=function(e){if(e[0]==null||e[1]==null||e[2]==null)return[null,null,null,e[3]];var t=e[0]/255,n=e[1]/255,r=e[2]/255,i=e[3],s=Math.max(t,n,r),o=Math.min(t,n,r),u=s-o,a=s+o,f=a*.5,l,c;return o===s?l=0:t===s?l=60*(n-r)/u+360:n===s?l=60*(r-t)/u+120:l=60*(t-n)/u+240,f===0||f===1?c=f:f<=.5?c=u/a:c=u/(2-a),[Math.round(l)%360,c,f,i==null?1:i]},u.hsla.from=function(e){if(e[0]==null||e[1]==null||e[2]==null)return[null,null,null,e[3]];var t=e[0]/360,n=e[1],r=e[2],i=e[3],s=r<=.5?r*(1+n):r+n-r*n,o=2*r-s;return[Math.round(v(o,s,t+1/3)*255),Math.round(v(o,s,t)*255),Math.round(v(o,s,t-1/3)*255),i]},h(u,function(e,r){var s=r.props,u=r.cache,a=r.to,f=r.from;o.fn[e]=function(e){a&&!this[u]&&(this[u]=a(this._rgba));if(e===n)return this[u].slice();var r,i=t.type(e),l=i==="array"||i==="object"?e:arguments,c=this[u].slice();return h(s,function(e,t){var n=l[i==="object"?e:t.idx];n==null&&(n=c[t.idx]),c[t.idx]=p(n,t)}),f?(r=o(f(c)),r[u]=c,r):o(c)},h(s,function(n,r){if(o.fn[n])return;o.fn[n]=function(s){var o=t.type(s),u=n==="alpha"?this._hsla?"hsla":"rgba":e,a=this[u](),f=a[r.idx],l;return o==="undefined"?f:(o==="function"&&(s=s.call(this,f),o=t.type(s)),s==null&&r.empty?this:(o==="string"&&(l=i.exec(s),l&&(s=f+parseFloat(l[2])*(l[1]==="+"?1:-1))),a[r.idx]=s,this[u](a)))}})}),h(r,function(e,n){t.cssHooks[n]={set:function(e,r){var i,s,u="";if(t.type(r)!=="string"||(i=d(r))){r=o(i||r);if(!f.rgba&&r._rgba[3]!==1){s=n==="backgroundColor"?e.parentNode:e;while((u===""||u==="transparent")&&s&&s.style)try{u=t.css(s,"backgroundColor"),s=s.parentNode}catch(a){}r=r.blend(u&&u!=="transparent"?u:"_default")}r=r.toRgbaString()}try{e.style[n]=r}catch(l){}}},t.fx.step[n]=function(e){e.colorInit||(e.start=o(e.elem,n),e.end=o(e.end),e.colorInit=!0),t.cssHooks[n].set(e.elem,e.start.transition(e.end,e.pos))}}),t.cssHooks.borderColor={expand:function(e){var t={};return h(["Top","Right","Bottom","Left"],function(n,r){t["border"+r+"Color"]=e}),t}},c=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(jQuery),function(){function i(){var t=this.ownerDocument.defaultView?this.ownerDocument.defaultView.getComputedStyle(this,null):this.currentStyle,n={},r,i;if(t&&t.length&&t[0]&&t[t[0]]){i=t.length;while(i--)r=t[i],typeof t[r]=="string"&&(n[e.camelCase(r)]=t[r])}else for(r in t)typeof t[r]=="string"&&(n[r]=t[r]);return n}function s(t,n){var i={},s,o;for(s in n)o=n[s],t[s]!==o&&!r[s]&&(e.fx.step[s]||!isNaN(parseFloat(o)))&&(i[s]=o);return i}var n=["add","remove","toggle"],r={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};e.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(t,n){e.fx.step[n]=function(e){if(e.end!=="none"&&!e.setAttr||e.pos===1&&!e.setAttr)jQuery.style(e.elem,n,e.end),e.setAttr=!0}}),e.effects.animateClass=function(t,r,o,u){var a=e.speed(r,o,u);return this.queue(function(){var r=e(this),o=r.attr("class")||"",u,f=a.children?r.find("*").andSelf():r;f=f.map(function(){var t=e(this);return{el:t,start:i.call(this)}}),u=function(){e.each(n,function(e,n){t[n]&&r[n+"Class"](t[n])})},u(),f=f.map(function(){return this.end=i.call(this.el[0]),this.diff=s(this.start,this.end),this}),r.attr("class",o),f=f.map(function(){var t=this,n=e.Deferred(),r=jQuery.extend({},a,{queue:!1,complete:function(){n.resolve(t)}});return this.el.animate(this.diff,r),n.promise()}),e.when.apply(e,f.get()).done(function(){u(),e.each(arguments,function(){var t=this.el;e.each(this.diff,function(e){t.css(e,"")})}),a.complete.call(r[0])})})},e.fn.extend({_addClass:e.fn.addClass,addClass:function(t,n,r,i){return n?e.effects.animateClass.call(this,{add:t},n,r,i):this._addClass(t)},_removeClass:e.fn.removeClass,removeClass:function(t,n,r,i){return n?e.effects.animateClass.call(this,{remove:t},n,r,i):this._removeClass(t)},_toggleClass:e.fn.toggleClass,toggleClass:function(n,r,i,s,o){return typeof r=="boolean"||r===t?i?e.effects.animateClass.call(this,r?{add:n}:{remove:n},i,s,o):this._toggleClass(n,r):e.effects.animateClass.call(this,{toggle:n},r,i,s)},switchClass:function(t,n,r,i,s){return e.effects.animateClass.call(this,{add:n,remove:t},r,i,s)}})}(),function(){function i(t,n,r,i){e.isPlainObject(t)&&(n=t,t=t.effect),t={effect:t},n==null&&(n={}),e.isFunction(n)&&(i=n,r=null,n={});if(typeof n=="number"||e.fx.speeds[n])i=r,r=n,n={};return e.isFunction(r)&&(i=r,r=null),n&&e.extend(t,n),r=r||n.duration,t.duration=e.fx.off?0:typeof r=="number"?r:r in e.fx.speeds?e.fx.speeds[r]:e.fx.speeds._default,t.complete=i||n.complete,t}function s(t){return!t||typeof t=="number"||e.fx.speeds[t]?!0:typeof t=="string"&&!e.effects.effect[t]?n&&e.effects[t]?!1:!0:!1}e.extend(e.effects,{version:"1.9.2",save:function(e,t){for(var n=0;n<t.length;n++)t[n]!==null&&e.data(r+t[n],e[0].style[t[n]])},restore:function(e,n){var i,s;for(s=0;s<n.length;s++)n[s]!==null&&(i=e.data(r+n[s]),i===t&&(i=""),e.css(n[s],i))},setMode:function(e,t){return t==="toggle"&&(t=e.is(":hidden")?"show":"hide"),t},getBaseline:function(e,t){var n,r;switch(e[0]){case"top":n=0;break;case"middle":n=.5;break;case"bottom":n=1;break;default:n=e[0]/t.height}switch(e[1]){case"left":r=0;break;case"center":r=.5;break;case"right":r=1;break;default:r=e[1]/t.width}return{x:r,y:n}},createWrapper:function(t){if(t.parent().is(".ui-effects-wrapper"))return t.parent();var n={width:t.outerWidth(!0),height:t.outerHeight(!0),"float":t.css("float")},r=e("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),i={width:t.width(),height:t.height()},s=document.activeElement;try{s.id}catch(o){s=document.body}return t.wrap(r),(t[0]===s||e.contains(t[0],s))&&e(s).focus(),r=t.parent(),t.css("position")==="static"?(r.css({position:"relative"}),t.css({position:"relative"})):(e.extend(n,{position:t.css("position"),zIndex:t.css("z-index")}),e.each(["top","left","bottom","right"],function(e,r){n[r]=t.css(r),isNaN(parseInt(n[r],10))&&(n[r]="auto")}),t.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),t.css(i),r.css(n).show()},removeWrapper:function(t){var n=document.activeElement;return t.parent().is(".ui-effects-wrapper")&&(t.parent().replaceWith(t),(t[0]===n||e.contains(t[0],n))&&e(n).focus()),t},setTransition:function(t,n,r,i){return i=i||{},e.each(n,function(e,n){var s=t.cssUnit(n);s[0]>0&&(i[n]=s[0]*r+s[1])}),i}}),e.fn.extend({effect:function(){function a(n){function u(){e.isFunction(i)&&i.call(r[0]),e.isFunction(n)&&n()}var r=e(this),i=t.complete,s=t.mode;(r.is(":hidden")?s==="hide":s==="show")?u():o.call(r[0],t,u)}var t=i.apply(this,arguments),r=t.mode,s=t.queue,o=e.effects.effect[t.effect],u=!o&&n&&e.effects[t.effect];return e.fx.off||!o&&!u?r?this[r](t.duration,t.complete):this.each(function(){t.complete&&t.complete.call(this)}):o?s===!1?this.each(a):this.queue(s||"fx",a):u.call(this,{options:t,duration:t.duration,callback:t.complete,mode:t.mode})},_show:e.fn.show,show:function(e){if(s(e))return this._show.apply(this,arguments);var t=i.apply(this,arguments);return t.mode="show",this.effect.call(this,t)},_hide:e.fn.hide,hide:function(e){if(s(e))return this._hide.apply(this,arguments);var t=i.apply(this,arguments);return t.mode="hide",this.effect.call(this,t)},__toggle:e.fn.toggle,toggle:function(t){if(s(t)||typeof t=="boolean"||e.isFunction(t))return this.__toggle.apply(this,arguments);var n=i.apply(this,arguments);return n.mode="toggle",this.effect.call(this,n)},cssUnit:function(t){var n=this.css(t),r=[];return e.each(["em","px","%","pt"],function(e,t){n.indexOf(t)>0&&(r=[parseFloat(n),t])}),r}})}(),function(){var t={};e.each(["Quad","Cubic","Quart","Quint","Expo"],function(e,n){t[n]=function(t){return Math.pow(t,e+2)}}),e.extend(t,{Sine:function(e){return 1-Math.cos(e*Math.PI/2)},Circ:function(e){return 1-Math.sqrt(1-e*e)},Elastic:function(e){return e===0||e===1?e:-Math.pow(2,8*(e-1))*Math.sin(((e-1)*80-7.5)*Math.PI/15)},Back:function(e){return e*e*(3*e-2)},Bounce:function(e){var t,n=4;while(e<((t=Math.pow(2,--n))-1)/11);return 1/Math.pow(4,3-n)-7.5625*Math.pow((t*3-2)/22-e,2)}}),e.each(t,function(t,n){e.easing["easeIn"+t]=n,e.easing["easeOut"+t]=function(e){return 1-n(1-e)},e.easing["easeInOut"+t]=function(e){return e<.5?n(e*2)/2:1-n(e*-2+2)/2}})}()}(jQuery);(function(e,t){var n=/up|down|vertical/,r=/up|left|vertical|horizontal/;e.effects.effect.blind=function(t,i){var s=e(this),o=["position","top","bottom","left","right","height","width"],u=e.effects.setMode(s,t.mode||"hide"),a=t.direction||"up",f=n.test(a),l=f?"height":"width",c=f?"top":"left",h=r.test(a),p={},d=u==="show",v,m,g;s.parent().is(".ui-effects-wrapper")?e.effects.save(s.parent(),o):e.effects.save(s,o),s.show(),v=e.effects.createWrapper(s).css({overflow:"hidden"}),m=v[l](),g=parseFloat(v.css(c))||0,p[l]=d?m:0,h||(s.css(f?"bottom":"right",0).css(f?"top":"left","auto").css({position:"absolute"}),p[c]=d?g:m+g),d&&(v.css(l,0),h||v.css(c,g+m)),v.animate(p,{duration:t.duration,easing:t.easing,queue:!1,complete:function(){u==="hide"&&s.hide(),e.effects.restore(s,o),e.effects.removeWrapper(s),i()}})}})(jQuery);(function(e,t){e.effects.effect.bounce=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"effect"),o=s==="hide",u=s==="show",a=t.direction||"up",f=t.distance,l=t.times||5,c=l*2+(u||o?1:0),h=t.duration/c,p=t.easing,d=a==="up"||a==="down"?"top":"left",v=a==="up"||a==="left",m,g,y,b=r.queue(),w=b.length;(u||o)&&i.push("opacity"),e.effects.save(r,i),r.show(),e.effects.createWrapper(r),f||(f=r[d==="top"?"outerHeight":"outerWidth"]()/3),u&&(y={opacity:1},y[d]=0,r.css("opacity",0).css(d,v?-f*2:f*2).animate(y,h,p)),o&&(f/=Math.pow(2,l-1)),y={},y[d]=0;for(m=0;m<l;m++)g={},g[d]=(v?"-=":"+=")+f,r.animate(g,h,p).animate(y,h,p),f=o?f*2:f/2;o&&(g={opacity:0},g[d]=(v?"-=":"+=")+f,r.animate(g,h,p)),r.queue(function(){o&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}),w>1&&b.splice.apply(b,[1,0].concat(b.splice(w,c+1))),r.dequeue()}})(jQuery);(function(e,t){e.effects.effect.clip=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=t.direction||"vertical",a=u==="vertical",f=a?"height":"width",l=a?"top":"left",c={},h,p,d;e.effects.save(r,i),r.show(),h=e.effects.createWrapper(r).css({overflow:"hidden"}),p=r[0].tagName==="IMG"?h:r,d=p[f](),o&&(p.css(f,0),p.css(l,d/2)),c[f]=o?d:0,c[l]=o?0:d/2,p.animate(c,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){o||r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}})(jQuery);(function(e,t){e.effects.effect.drop=function(t,n){var r=e(this),i=["position","top","bottom","left","right","opacity","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=t.direction||"left",a=u==="up"||u==="down"?"top":"left",f=u==="up"||u==="left"?"pos":"neg",l={opacity:o?1:0},c;e.effects.save(r,i),r.show(),e.effects.createWrapper(r),c=t.distance||r[a==="top"?"outerHeight":"outerWidth"](!0)/2,o&&r.css("opacity",0).css(a,f==="pos"?-c:c),l[a]=(o?f==="pos"?"+=":"-=":f==="pos"?"-=":"+=")+c,r.animate(l,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}})(jQuery);(function(e,t){e.effects.effect.explode=function(t,n){function y(){c.push(this),c.length===r*i&&b()}function b(){s.css({visibility:"visible"}),e(c).remove(),u||s.hide(),n()}var r=t.pieces?Math.round(Math.sqrt(t.pieces)):3,i=r,s=e(this),o=e.effects.setMode(s,t.mode||"hide"),u=o==="show",a=s.show().css("visibility","hidden").offset(),f=Math.ceil(s.outerWidth()/i),l=Math.ceil(s.outerHeight()/r),c=[],h,p,d,v,m,g;for(h=0;h<r;h++){v=a.top+h*l,g=h-(r-1)/2;for(p=0;p<i;p++)d=a.left+p*f,m=p-(i-1)/2,s.clone().appendTo("body").wrap("<div></div>").css({position:"absolute",visibility:"visible",left:-p*f,top:-h*l}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:f,height:l,left:d+(u?m*f:0),top:v+(u?g*l:0),opacity:u?0:1}).animate({left:d+(u?0:m*f),top:v+(u?0:g*l),opacity:u?1:0},t.duration||500,t.easing,y)}}})(jQuery);(function(e,t){e.effects.effect.fade=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"toggle");r.animate({opacity:i},{queue:!1,duration:t.duration,easing:t.easing,complete:n})}})(jQuery);(function(e,t){e.effects.effect.fold=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=s==="hide",a=t.size||15,f=/([0-9]+)%/.exec(a),l=!!t.horizFirst,c=o!==l,h=c?["width","height"]:["height","width"],p=t.duration/2,d,v,m={},g={};e.effects.save(r,i),r.show(),d=e.effects.createWrapper(r).css({overflow:"hidden"}),v=c?[d.width(),d.height()]:[d.height(),d.width()],f&&(a=parseInt(f[1],10)/100*v[u?0:1]),o&&d.css(l?{height:0,width:a}:{height:a,width:0}),m[h[0]]=o?v[0]:a,g[h[1]]=o?v[1]:0,d.animate(m,p,t.easing).animate(g,p,t.easing,function(){u&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()})}})(jQuery);(function(e,t){e.effects.effect.highlight=function(t,n){var r=e(this),i=["backgroundImage","backgroundColor","opacity"],s=e.effects.setMode(r,t.mode||"show"),o={backgroundColor:r.css("backgroundColor")};s==="hide"&&(o.opacity=0),e.effects.save(r,i),r.show().css({backgroundImage:"none",backgroundColor:t.color||"#ffff99"}).animate(o,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),n()}})}})(jQuery);(function(e,t){e.effects.effect.pulsate=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"show"),s=i==="show",o=i==="hide",u=s||i==="hide",a=(t.times||5)*2+(u?1:0),f=t.duration/a,l=0,c=r.queue(),h=c.length,p;if(s||!r.is(":visible"))r.css("opacity",0).show(),l=1;for(p=1;p<a;p++)r.animate({opacity:l},f,t.easing),l=1-l;r.animate({opacity:l},f,t.easing),r.queue(function(){o&&r.hide(),n()}),h>1&&c.splice.apply(c,[1,0].concat(c.splice(h,a+1))),r.dequeue()}})(jQuery);(function(e,t){e.effects.effect.puff=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"hide"),s=i==="hide",o=parseInt(t.percent,10)||150,u=o/100,a={height:r.height(),width:r.width(),outerHeight:r.outerHeight(),outerWidth:r.outerWidth()};e.extend(t,{effect:"scale",queue:!1,fade:!0,mode:i,complete:n,percent:s?o:100,from:s?a:{height:a.height*u,width:a.width*u,outerHeight:a.outerHeight*u,outerWidth:a.outerWidth*u}}),r.effect(t)},e.effects.effect.scale=function(t,n){var r=e(this),i=e.extend(!0,{},t),s=e.effects.setMode(r,t.mode||"effect"),o=parseInt(t.percent,10)||(parseInt(t.percent,10)===0?0:s==="hide"?0:100),u=t.direction||"both",a=t.origin,f={height:r.height(),width:r.width(),outerHeight:r.outerHeight(),outerWidth:r.outerWidth()},l={y:u!=="horizontal"?o/100:1,x:u!=="vertical"?o/100:1};i.effect="size",i.queue=!1,i.complete=n,s!=="effect"&&(i.origin=a||["middle","center"],i.restore=!0),i.from=t.from||(s==="show"?{height:0,width:0,outerHeight:0,outerWidth:0}:f),i.to={height:f.height*l.y,width:f.width*l.x,outerHeight:f.outerHeight*l.y,outerWidth:f.outerWidth*l.x},i.fade&&(s==="show"&&(i.from.opacity=0,i.to.opacity=1),s==="hide"&&(i.from.opacity=1,i.to.opacity=0)),r.effect(i)},e.effects.effect.size=function(t,n){var r,i,s,o=e(this),u=["position","top","bottom","left","right","width","height","overflow","opacity"],a=["position","top","bottom","left","right","overflow","opacity"],f=["width","height","overflow"],l=["fontSize"],c=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],h=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],p=e.effects.setMode(o,t.mode||"effect"),d=t.restore||p!=="effect",v=t.scale||"both",m=t.origin||["middle","center"],g=o.css("position"),y=d?u:a,b={height:0,width:0,outerHeight:0,outerWidth:0};p==="show"&&o.show(),r={height:o.height(),width:o.width(),outerHeight:o.outerHeight(),outerWidth:o.outerWidth()},t.mode==="toggle"&&p==="show"?(o.from=t.to||b,o.to=t.from||r):(o.from=t.from||(p==="show"?b:r),o.to=t.to||(p==="hide"?b:r)),s={from:{y:o.from.height/r.height,x:o.from.width/r.width},to:{y:o.to.height/r.height,x:o.to.width/r.width}};if(v==="box"||v==="both")s.from.y!==s.to.y&&(y=y.concat(c),o.from=e.effects.setTransition(o,c,s.from.y,o.from),o.to=e.effects.setTransition(o,c,s.to.y,o.to)),s.from.x!==s.to.x&&(y=y.concat(h),o.from=e.effects.setTransition(o,h,s.from.x,o.from),o.to=e.effects.setTransition(o,h,s.to.x,o.to));(v==="content"||v==="both")&&s.from.y!==s.to.y&&(y=y.concat(l).concat(f),o.from=e.effects.setTransition(o,l,s.from.y,o.from),o.to=e.effects.setTransition(o,l,s.to.y,o.to)),e.effects.save(o,y),o.show(),e.effects.createWrapper(o),o.css("overflow","hidden").css(o.from),m&&(i=e.effects.getBaseline(m,r),o.from.top=(r.outerHeight-o.outerHeight())*i.y,o.from.left=(r.outerWidth-o.outerWidth())*i.x,o.to.top=(r.outerHeight-o.to.outerHeight)*i.y,o.to.left=(r.outerWidth-o.to.outerWidth)*i.x),o.css(o.from);if(v==="content"||v==="both")c=c.concat(["marginTop","marginBottom"]).concat(l),h=h.concat(["marginLeft","marginRight"]),f=u.concat(c).concat(h),o.find("*[width]").each(function(){var n=e(this),r={height:n.height(),width:n.width(),outerHeight:n.outerHeight(),outerWidth:n.outerWidth()};d&&e.effects.save(n,f),n.from={height:r.height*s.from.y,width:r.width*s.from.x,outerHeight:r.outerHeight*s.from.y,outerWidth:r.outerWidth*s.from.x},n.to={height:r.height*s.to.y,width:r.width*s.to.x,outerHeight:r.height*s.to.y,outerWidth:r.width*s.to.x},s.from.y!==s.to.y&&(n.from=e.effects.setTransition(n,c,s.from.y,n.from),n.to=e.effects.setTransition(n,c,s.to.y,n.to)),s.from.x!==s.to.x&&(n.from=e.effects.setTransition(n,h,s.from.x,n.from),n.to=e.effects.setTransition(n,h,s.to.x,n.to)),n.css(n.from),n.animate(n.to,t.duration,t.easing,function(){d&&e.effects.restore(n,f)})});o.animate(o.to,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){o.to.opacity===0&&o.css("opacity",o.from.opacity),p==="hide"&&o.hide(),e.effects.restore(o,y),d||(g==="static"?o.css({position:"relative",top:o.to.top,left:o.to.left}):e.each(["top","left"],function(e,t){o.css(t,function(t,n){var r=parseInt(n,10),i=e?o.to.left:o.to.top;return n==="auto"?i+"px":r+i+"px"})})),e.effects.removeWrapper(o),n()}})}})(jQuery);(function(e,t){e.effects.effect.shake=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"effect"),o=t.direction||"left",u=t.distance||20,a=t.times||3,f=a*2+1,l=Math.round(t.duration/f),c=o==="up"||o==="down"?"top":"left",h=o==="up"||o==="left",p={},d={},v={},m,g=r.queue(),y=g.length;e.effects.save(r,i),r.show(),e.effects.createWrapper(r),p[c]=(h?"-=":"+=")+u,d[c]=(h?"+=":"-=")+u*2,v[c]=(h?"-=":"+=")+u*2,r.animate(p,l,t.easing);for(m=1;m<a;m++)r.animate(d,l,t.easing).animate(v,l,t.easing);r.animate(d,l,t.easing).animate(p,l/2,t.easing).queue(function(){s==="hide"&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}),y>1&&g.splice.apply(g,[1,0].concat(g.splice(y,f+1))),r.dequeue()}})(jQuery);(function(e,t){e.effects.effect.slide=function(t,n){var r=e(this),i=["position","top","bottom","left","right","width","height"],s=e.effects.setMode(r,t.mode||"show"),o=s==="show",u=t.direction||"left",a=u==="up"||u==="down"?"top":"left",f=u==="up"||u==="left",l,c={};e.effects.save(r,i),r.show(),l=t.distance||r[a==="top"?"outerHeight":"outerWidth"](!0),e.effects.createWrapper(r).css({overflow:"hidden"}),o&&r.css(a,f?isNaN(l)?"-"+l:-l:l),c[a]=(o?f?"+=":"-=":f?"-=":"+=")+l,r.animate(c,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}})(jQuery);(function(e,t){e.effects.effect.transfer=function(t,n){var r=e(this),i=e(t.to),s=i.css("position")==="fixed",o=e("body"),u=s?o.scrollTop():0,a=s?o.scrollLeft():0,f=i.offset(),l={top:f.top-u,left:f.left-a,height:i.innerHeight(),width:i.innerWidth()},c=r.offset(),h=e('<div class="ui-effects-transfer"></div>').appendTo(document.body).addClass(t.className).css({top:c.top-u,left:c.left-a,height:r.innerHeight(),width:r.innerWidth(),position:s?"fixed":"absolute"}).animate(l,t.duration,t.easing,function(){h.remove(),n()})}})(jQuery);
\ No newline at end of file
diff --git a/src/web/js/jqueryui/jquery-ui-sliderAccess.js b/src/web/js/jqueryui/jquery-ui-sliderAccess.js
new file mode 100644
index 0000000..a54cf4a
--- /dev/null
+++ b/src/web/js/jqueryui/jquery-ui-sliderAccess.js
@@ -0,0 +1,89 @@
+/*
+ * jQuery UI Slider Access
+ * By: Trent Richardson [http://trentrichardson.com]
+ * Version 0.3
+ * Last Modified: 10/20/2012
+ *
+ * Copyright 2011 Trent Richardson
+ * Dual licensed under the MIT and GPL licenses.
+ * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
+ * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
+ *
+ */
+ (function($){
+
+ $.fn.extend({
+ sliderAccess: function(options){
+ options = options || {};
+ options.touchonly = options.touchonly !== undefined? options.touchonly : true; // by default only show it if touch device
+
+ if(options.touchonly === true && !("ontouchend" in document))
+ return $(this);
+
+ return $(this).each(function(i,obj){
+ var $t = $(this),
+ o = $.extend({},{
+ where: 'after',
+ step: $t.slider('option','step'),
+ upIcon: 'ui-icon-plus',
+ downIcon: 'ui-icon-minus',
+ text: false,
+ upText: '+',
+ downText: '-',
+ buttonset: true,
+ buttonsetTag: 'span',
+ isRTL: false
+ }, options),
+ $buttons = $('<'+ o.buttonsetTag +' class="ui-slider-access">'+
+ '<button data-icon="'+ o.downIcon +'" data-step="'+ (o.isRTL? o.step : o.step*-1) +'">'+ o.downText +'</button>'+
+ '<button data-icon="'+ o.upIcon +'" data-step="'+ (o.isRTL? o.step*-1 : o.step) +'">'+ o.upText +'</button>'+
+ '</'+ o.buttonsetTag +'>');
+
+ $buttons.children('button').each(function(j, jobj){
+ var $jt = $(this);
+ $jt.button({
+ text: o.text,
+ icons: { primary: $jt.data('icon') }
+ })
+ .click(function(e){
+ var step = $jt.data('step'),
+ curr = $t.slider('value'),
+ newval = curr += step*1,
+ minval = $t.slider('option','min'),
+ maxval = $t.slider('option','max'),
+ slidee = $t.slider("option", "slide") || function(){},
+ stope = $t.slider("option", "stop") || function(){};
+
+ e.preventDefault();
+
+ if(newval < minval || newval > maxval)
+ return;
+
+ $t.slider('value', newval);
+
+ slidee.call($t, null, { value: newval });
+ stope.call($t, null, { value: newval });
+ });
+ });
+
+ // before or after
+ $t[o.where]($buttons);
+
+ if(o.buttonset){
+ $buttons.removeClass('ui-corner-right').removeClass('ui-corner-left').buttonset();
+ $buttons.eq(0).addClass('ui-corner-left');
+ $buttons.eq(1).addClass('ui-corner-right');
+ }
+
+ // adjust the width so we don't break the original layout
+ var bOuterWidth = $buttons.css({
+ marginLeft: ((o.where == 'after' && !o.isRTL) || (o.where == 'before' && o.isRTL)? 10:0),
+ marginRight: ((o.where == 'before' && !o.isRTL) || (o.where == 'after' && o.isRTL)? 10:0)
+ }).outerWidth(true) + 5;
+ var tOuterWidth = $t.outerWidth(true);
+ $t.css('display','inline-block').width(tOuterWidth-bOuterWidth);
+ });
+ }
+ });
+
+})(jQuery);
\ No newline at end of file
src/web/js/jqueryui/jquery-ui-timepicker-addon.js 1882(+1882 -0)
diff --git a/src/web/js/jqueryui/jquery-ui-timepicker-addon.js b/src/web/js/jqueryui/jquery-ui-timepicker-addon.js
new file mode 100644
index 0000000..b8616da
--- /dev/null
+++ b/src/web/js/jqueryui/jquery-ui-timepicker-addon.js
@@ -0,0 +1,1882 @@
+/*
+ * jQuery timepicker addon
+ * By: Trent Richardson [http://trentrichardson.com]
+ * Version 1.1.1
+ * Last Modified: 11/07/2012
+ *
+ * Copyright 2012 Trent Richardson
+ * You may use this project under MIT or GPL licenses.
+ * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
+ * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
+ */
+
+/*jslint evil: true, white: false, undef: false, nomen: false */
+
+(function($) {
+
+ /*
+ * Lets not redefine timepicker, Prevent "Uncaught RangeError: Maximum call stack size exceeded"
+ */
+ $.ui.timepicker = $.ui.timepicker || {};
+ if ($.ui.timepicker.version) {
+ return;
+ }
+
+ /*
+ * Extend jQueryUI, get it started with our version number
+ */
+ $.extend($.ui, {
+ timepicker: {
+ version: "1.1.1"
+ }
+ });
+
+ /*
+ * Timepicker manager.
+ * Use the singleton instance of this class, $.timepicker, to interact with the time picker.
+ * Settings for (groups of) time pickers are maintained in an instance object,
+ * allowing multiple different settings on the same page.
+ */
+ function Timepicker() {
+ this.regional = []; // Available regional settings, indexed by language code
+ this.regional[''] = { // Default regional settings
+ currentText: 'Now',
+ closeText: 'Done',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ timeFormat: 'HH:mm',
+ timeSuffix: '',
+ timeOnlyTitle: 'Choose Time',
+ timeText: 'Time',
+ hourText: 'Hour',
+ minuteText: 'Minute',
+ secondText: 'Second',
+ millisecText: 'Millisecond',
+ timezoneText: 'Time Zone',
+ isRTL: false
+ };
+ this._defaults = { // Global defaults for all the datetime picker instances
+ showButtonPanel: true,
+ timeOnly: false,
+ showHour: true,
+ showMinute: true,
+ showSecond: false,
+ showMillisec: false,
+ showTimezone: false,
+ showTime: true,
+ stepHour: 1,
+ stepMinute: 1,
+ stepSecond: 1,
+ stepMillisec: 1,
+ hour: 0,
+ minute: 0,
+ second: 0,
+ millisec: 0,
+ timezone: null,
+ useLocalTimezone: false,
+ defaultTimezone: "+0000",
+ hourMin: 0,
+ minuteMin: 0,
+ secondMin: 0,
+ millisecMin: 0,
+ hourMax: 23,
+ minuteMax: 59,
+ secondMax: 59,
+ millisecMax: 999,
+ minDateTime: null,
+ maxDateTime: null,
+ onSelect: null,
+ hourGrid: 0,
+ minuteGrid: 0,
+ secondGrid: 0,
+ millisecGrid: 0,
+ alwaysSetTime: true,
+ separator: ' ',
+ altFieldTimeOnly: true,
+ altTimeFormat: null,
+ altSeparator: null,
+ altTimeSuffix: null,
+ pickerTimeFormat: null,
+ pickerTimeSuffix: null,
+ showTimepicker: true,
+ timezoneIso8601: false,
+ timezoneList: null,
+ addSliderAccess: false,
+ sliderAccessArgs: null,
+ controlType: 'slider',
+ defaultValue: null,
+ parse: 'strict'
+ };
+ $.extend(this._defaults, this.regional['']);
+ }
+
+ $.extend(Timepicker.prototype, {
+ $input: null,
+ $altInput: null,
+ $timeObj: null,
+ inst: null,
+ hour_slider: null,
+ minute_slider: null,
+ second_slider: null,
+ millisec_slider: null,
+ timezone_select: null,
+ hour: 0,
+ minute: 0,
+ second: 0,
+ millisec: 0,
+ timezone: null,
+ defaultTimezone: "+0000",
+ hourMinOriginal: null,
+ minuteMinOriginal: null,
+ secondMinOriginal: null,
+ millisecMinOriginal: null,
+ hourMaxOriginal: null,
+ minuteMaxOriginal: null,
+ secondMaxOriginal: null,
+ millisecMaxOriginal: null,
+ ampm: '',
+ formattedDate: '',
+ formattedTime: '',
+ formattedDateTime: '',
+ timezoneList: null,
+ units: ['hour','minute','second','millisec'],
+ control: null,
+
+ /*
+ * Override the default settings for all instances of the time picker.
+ * @param settings object - the new settings to use as defaults (anonymous object)
+ * @return the manager object
+ */
+ setDefaults: function(settings) {
+ extendRemove(this._defaults, settings || {});
+ return this;
+ },
+
+ /*
+ * Create a new Timepicker instance
+ */
+ _newInst: function($input, o) {
+ var tp_inst = new Timepicker(),
+ inlineSettings = {},
+ fns = {},
+ overrides, i;
+
+ for (var attrName in this._defaults) {
+ if(this._defaults.hasOwnProperty(attrName)){
+ var attrValue = $input.attr('time:' + attrName);
+ if (attrValue) {
+ try {
+ inlineSettings[attrName] = eval(attrValue);
+ } catch (err) {
+ inlineSettings[attrName] = attrValue;
+ }
+ }
+ }
+ }
+ overrides = {
+ beforeShow: function (input, dp_inst) {
+ if ($.isFunction(tp_inst._defaults.evnts.beforeShow)) {
+ return tp_inst._defaults.evnts.beforeShow.call($input[0], input, dp_inst, tp_inst);
+ }
+ },
+ onChangeMonthYear: function (year, month, dp_inst) {
+ // Update the time as well : this prevents the time from disappearing from the $input field.
+ tp_inst._updateDateTime(dp_inst);
+ if ($.isFunction(tp_inst._defaults.evnts.onChangeMonthYear)) {
+ tp_inst._defaults.evnts.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
+ }
+ },
+ onClose: function (dateText, dp_inst) {
+ if (tp_inst.timeDefined === true && $input.val() !== '') {
+ tp_inst._updateDateTime(dp_inst);
+ }
+ if ($.isFunction(tp_inst._defaults.evnts.onClose)) {
+ tp_inst._defaults.evnts.onClose.call($input[0], dateText, dp_inst, tp_inst);
+ }
+ }
+ };
+ for (i in overrides) {
+ if (overrides.hasOwnProperty(i)) {
+ fns[i] = o[i] || null;
+ }
+ }
+ tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, overrides, {
+ evnts:fns,
+ timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
+ });
+ tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) {
+ return val.toUpperCase();
+ });
+ tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) {
+ return val.toUpperCase();
+ });
+
+ // controlType is string - key to our this._controls
+ if(typeof(tp_inst._defaults.controlType) === 'string'){
+ if($.fn[tp_inst._defaults.controlType] === undefined){
+ tp_inst._defaults.controlType = 'select';
+ }
+ tp_inst.control = tp_inst._controls[tp_inst._defaults.controlType];
+ }
+ // controlType is an object and must implement create, options, value methods
+ else{
+ tp_inst.control = tp_inst._defaults.controlType;
+ }
+
+ if (tp_inst._defaults.timezoneList === null) {
+ var timezoneList = ['-1200', '-1100', '-1000', '-0930', '-0900', '-0800', '-0700', '-0600', '-0500', '-0430', '-0400', '-0330', '-0300', '-0200', '-0100', '+0000',
+ '+0100', '+0200', '+0300', '+0330', '+0400', '+0430', '+0500', '+0530', '+0545', '+0600', '+0630', '+0700', '+0800', '+0845', '+0900', '+0930',
+ '+1000', '+1030', '+1100', '+1130', '+1200', '+1245', '+1300', '+1400'];
+
+ if (tp_inst._defaults.timezoneIso8601) {
+ timezoneList = $.map(timezoneList, function(val) {
+ return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3));
+ });
+ }
+ tp_inst._defaults.timezoneList = timezoneList;
+ }
+
+ tp_inst.timezone = tp_inst._defaults.timezone;
+ tp_inst.hour = tp_inst._defaults.hour;
+ tp_inst.minute = tp_inst._defaults.minute;
+ tp_inst.second = tp_inst._defaults.second;
+ tp_inst.millisec = tp_inst._defaults.millisec;
+ tp_inst.ampm = '';
+ tp_inst.$input = $input;
+
+ if (o.altField) {
+ tp_inst.$altInput = $(o.altField).css({
+ cursor: 'pointer'
+ }).focus(function() {
+ $input.trigger("focus");
+ });
+ }
+
+ if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) {
+ tp_inst._defaults.minDate = new Date();
+ }
+ if (tp_inst._defaults.maxDate === 0 || tp_inst._defaults.maxDateTime === 0) {
+ tp_inst._defaults.maxDate = new Date();
+ }
+
+ // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
+ if (tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) {
+ tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
+ }
+ if (tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date) {
+ tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
+ }
+ if (tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date) {
+ tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
+ }
+ if (tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date) {
+ tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
+ }
+ tp_inst.$input.bind('focus', function() {
+ tp_inst._onFocus();
+ });
+
+ return tp_inst;
+ },
+
+ /*
+ * add our sliders to the calendar
+ */
+ _addTimePicker: function(dp_inst) {
+ var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? this.$input.val() + ' ' + this.$altInput.val() : this.$input.val();
+
+ this.timeDefined = this._parseTime(currDT);
+ this._limitMinMaxDateTime(dp_inst, false);
+ this._injectTimePicker();
+ },
+
+ /*
+ * parse the time string from input value or _setTime
+ */
+ _parseTime: function(timeString, withDate) {
+ if (!this.inst) {
+ this.inst = $.datepicker._getInst(this.$input[0]);
+ }
+
+ if (withDate || !this._defaults.timeOnly) {
+ var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
+ try {
+ var parseRes = parseDateTimeInternal(dp_dateFormat, this._defaults.timeFormat, timeString, $.datepicker._getFormatConfig(this.inst), this._defaults);
+ if (!parseRes.timeObj) {
+ return false;
+ }
+ $.extend(this, parseRes.timeObj);
+ } catch (err) {
+ $.datepicker.log("Error parsing the date/time string: " + err +
+ "\ndate/time string = " + timeString +
+ "\ntimeFormat = " + this._defaults.timeFormat +
+ "\ndateFormat = " + dp_dateFormat);
+ return false;
+ }
+ return true;
+ } else {
+ var timeObj = $.datepicker.parseTime(this._defaults.timeFormat, timeString, this._defaults);
+ if (!timeObj) {
+ return false;
+ }
+ $.extend(this, timeObj);
+ return true;
+ }
+ },
+
+ /*
+ * generate and inject html for timepicker into ui datepicker
+ */
+ _injectTimePicker: function() {
+ var $dp = this.inst.dpDiv,
+ o = this.inst.settings,
+ tp_inst = this,
+ litem = '',
+ uitem = '',
+ max = {},
+ gridSize = {},
+ size = null;
+
+ // Prevent displaying twice
+ if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
+ var noDisplay = ' style="display:none;"',
+ html = '<div class="ui-timepicker-div'+ (o.isRTL? ' ui-timepicker-rtl' : '') +'"><dl>' + '<dt class="ui_tpicker_time_label"' + ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
+ '<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>';
+
+ // Create the markup
+ for(var i=0,l=this.units.length; i<l; i++){
+ litem = this.units[i];
+ uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
+ // Added by Peter Medeiros:
+ // - Figure out what the hour/minute/second max should be based on the step values.
+ // - Example: if stepMinute is 15, then minMax is 45.
+ max[litem] = parseInt((o[litem+'Max'] - ((o[litem+'Max'] - o[litem+'Min']) % o['step'+uitem])), 10);
+ gridSize[litem] = 0;
+
+ html += '<dt class="ui_tpicker_'+ litem +'_label"' + ((o['show'+uitem]) ? '' : noDisplay) + '>' + o[litem +'Text'] + '</dt>' +
+ '<dd class="ui_tpicker_'+ litem +'"><div class="ui_tpicker_'+ litem +'_slider"' + ((o['show'+uitem]) ? '' : noDisplay) + '></div>';
+
+ if (o['show'+uitem] && o[litem+'Grid'] > 0) {
+ html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
+
+ if(litem == 'hour'){
+ for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) {
+ gridSize[litem]++;
+ var tmph = $.datepicker.formatTime(useAmpm(o.pickerTimeFormat || o.timeFormat)? 'hht':'HH', {hour:h}, o);
+ html += '<td data-for="'+litem+'">' + tmph + '</td>';
+ }
+ }
+ else{
+ for (var m = o[litem+'Min']; m <= max[litem]; m += parseInt(o[litem+'Grid'], 10)) {
+ gridSize[litem]++;
+ html += '<td data-for="'+litem+'">' + ((m < 10) ? '0' : '') + m + '</td>';
+ }
+ }
+
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';
+ }
+
+ // Timezone
+ html += '<dt class="ui_tpicker_timezone_label"' + ((o.showTimezone) ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
+ html += '<dd class="ui_tpicker_timezone" ' + ((o.showTimezone) ? '' : noDisplay) + '></dd>';
+
+ // Create the elements from string
+ html += '</dl></div>';
+ var $tp = $(html);
+
+ // if we only want time picker...
+ if (o.timeOnly === true) {
+ $tp.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' + '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' + '</div>');
+ $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
+ }
+
+ // add sliders, adjust grids, add events
+ for(var i=0,l=tp_inst.units.length; i<l; i++){
+ litem = tp_inst.units[i];
+ uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
+
+ // add the slider
+ tp_inst[litem+'_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_'+litem+'_slider'), litem, tp_inst[litem], o[litem+'Min'], max[litem], o['step'+uitem]);
+
+ // adjust the grid and add click event
+ if (o['show'+uitem] && o[litem+'Grid'] > 0) {
+ size = 100 * gridSize[litem] * o[litem+'Grid'] / (max[litem] - o[litem+'Min']);
+ $tp.find('.ui_tpicker_'+litem+' table').css({
+ width: size + "%",
+ marginLeft: o.isRTL? '0' : ((size / (-2 * gridSize[litem])) + "%"),
+ marginRight: o.isRTL? ((size / (-2 * gridSize[litem])) + "%") : '0',
+ borderCollapse: 'collapse'
+ }).find("td").click(function(e){
+ var $t = $(this),
+ h = $t.html(),
+ n = parseInt(h.replace(/[^0-9]/g),10),
+ ap = h.replace(/[^apm]/ig),
+ f = $t.data('for'); // loses scope, so we use data-for
+
+ if(f == 'hour'){
+ if(ap.indexOf('p') !== -1 && n < 12){
+ n += 12;
+ }
+ else{
+ if(ap.indexOf('a') !== -1 && n === 12){
+ n = 0;
+ }
+ }
+ }
+
+ tp_inst.control.value(tp_inst, tp_inst[f+'_slider'], litem, n);
+
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ })
+ .css({
+ cursor: 'pointer',
+ width: (100 / gridSize[litem]) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ } // end if grid > 0
+ } // end for loop
+
+ // Add timezone options
+ this.timezone_select = $tp.find('.ui_tpicker_timezone').append('<select></select>').find("select");
+ $.fn.append.apply(this.timezone_select,
+ $.map(o.timezoneList, function(val, idx) {
+ return $("<option />").val(typeof val == "object" ? val.value : val).text(typeof val == "object" ? val.label : val);
+ }));
+ if (typeof(this.timezone) != "undefined" && this.timezone !== null && this.timezone !== "") {
+ var local_date = new Date(this.inst.selectedYear, this.inst.selectedMonth, this.inst.selectedDay, 12);
+ var local_timezone = $.timepicker.timeZoneOffsetString(local_date);
+ if (local_timezone == this.timezone) {
+ selectLocalTimeZone(tp_inst);
+ } else {
+ this.timezone_select.val(this.timezone);
+ }
+ } else {
+ if (typeof(this.hour) != "undefined" && this.hour !== null && this.hour !== "") {
+ this.timezone_select.val(o.defaultTimezone);
+ } else {
+ selectLocalTimeZone(tp_inst);
+ }
+ }
+ this.timezone_select.change(function() {
+ tp_inst._defaults.useLocalTimezone = false;
+ tp_inst._onTimeChange();
+ });
+ // End timezone options
+
+ // inject timepicker into datepicker
+ var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
+ if ($buttonPanel.length) {
+ $buttonPanel.before($tp);
+ } else {
+ $dp.append($tp);
+ }
+
+ this.$timeObj = $tp.find('.ui_tpicker_time');
+
+ if (this.inst !== null) {
+ var timeDefined = this.timeDefined;
+ this._onTimeChange();
+ this.timeDefined = timeDefined;
+ }
+
+ // slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
+ if (this._defaults.addSliderAccess) {
+ var sliderAccessArgs = this._defaults.sliderAccessArgs,
+ rtl = this._defaults.isRTL;
+ sliderAccessArgs.isRTL = rtl;
+
+ setTimeout(function() { // fix for inline mode
+ if ($tp.find('.ui-slider-access').length === 0) {
+ $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
+
+ // fix any grids since sliders are shorter
+ var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
+ if (sliderAccessWidth) {
+ $tp.find('table:visible').each(function() {
+ var $g = $(this),
+ oldWidth = $g.outerWidth(),
+ oldMarginLeft = $g.css(rtl? 'marginRight':'marginLeft').toString().replace('%', ''),
+ newWidth = oldWidth - sliderAccessWidth,
+ newMarginLeft = ((oldMarginLeft * newWidth) / oldWidth) + '%',
+ css = { width: newWidth, marginRight: 0, marginLeft: 0 };
+ css[rtl? 'marginRight':'marginLeft'] = newMarginLeft;
+ $g.css(css);
+ });
+ }
+ }
+ }, 10);
+ }
+ // end slideAccess integration
+
+ }
+ },
+
+ /*
+ * This function tries to limit the ability to go outside the
+ * min/max date range
+ */
+ _limitMinMaxDateTime: function(dp_inst, adjustSliders) {
+ var o = this._defaults,
+ dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
+
+ if (!this._defaults.showTimepicker) {
+ return;
+ } // No time so nothing to check here
+
+ if ($.datepicker._get(dp_inst, 'minDateTime') !== null && $.datepicker._get(dp_inst, 'minDateTime') !== undefined && dp_date) {
+ var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
+ minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
+
+ if (this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null) {
+ this.hourMinOriginal = o.hourMin;
+ this.minuteMinOriginal = o.minuteMin;
+ this.secondMinOriginal = o.secondMin;
+ this.millisecMinOriginal = o.millisecMin;
+ }
+
+ if (dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
+ this._defaults.hourMin = minDateTime.getHours();
+ if (this.hour <= this._defaults.hourMin) {
+ this.hour = this._defaults.hourMin;
+ this._defaults.minuteMin = minDateTime.getMinutes();
+ if (this.minute <= this._defaults.minuteMin) {
+ this.minute = this._defaults.minuteMin;
+ this._defaults.secondMin = minDateTime.getSeconds();
+ if (this.second <= this._defaults.secondMin) {
+ this.second = this._defaults.secondMin;
+ this._defaults.millisecMin = minDateTime.getMilliseconds();
+ } else {
+ if (this.millisec < this._defaults.millisecMin) {
+ this.millisec = this._defaults.millisecMin;
+ }
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ }
+ } else {
+ this._defaults.secondMin = this.secondMinOriginal;
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ }
+ } else {
+ this._defaults.minuteMin = this.minuteMinOriginal;
+ this._defaults.secondMin = this.secondMinOriginal;
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ }
+ } else {
+ this._defaults.hourMin = this.hourMinOriginal;
+ this._defaults.minuteMin = this.minuteMinOriginal;
+ this._defaults.secondMin = this.secondMinOriginal;
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ }
+ }
+
+ if ($.datepicker._get(dp_inst, 'maxDateTime') !== null && $.datepicker._get(dp_inst, 'maxDateTime') !== undefined && dp_date) {
+ var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
+ maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
+
+ if (this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null) {
+ this.hourMaxOriginal = o.hourMax;
+ this.minuteMaxOriginal = o.minuteMax;
+ this.secondMaxOriginal = o.secondMax;
+ this.millisecMaxOriginal = o.millisecMax;
+ }
+
+ if (dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()) {
+ this._defaults.hourMax = maxDateTime.getHours();
+ if (this.hour >= this._defaults.hourMax) {
+ this.hour = this._defaults.hourMax;
+ this._defaults.minuteMax = maxDateTime.getMinutes();
+ if (this.minute >= this._defaults.minuteMax) {
+ this.minute = this._defaults.minuteMax;
+ this._defaults.secondMax = maxDateTime.getSeconds();
+ } else if (this.second >= this._defaults.secondMax) {
+ this.second = this._defaults.secondMax;
+ this._defaults.millisecMax = maxDateTime.getMilliseconds();
+ } else {
+ if (this.millisec > this._defaults.millisecMax) {
+ this.millisec = this._defaults.millisecMax;
+ }
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ }
+ } else {
+ this._defaults.minuteMax = this.minuteMaxOriginal;
+ this._defaults.secondMax = this.secondMaxOriginal;
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ }
+ } else {
+ this._defaults.hourMax = this.hourMaxOriginal;
+ this._defaults.minuteMax = this.minuteMaxOriginal;
+ this._defaults.secondMax = this.secondMaxOriginal;
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ }
+ }
+
+ if (adjustSliders !== undefined && adjustSliders === true) {
+ var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
+ minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
+ secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
+ millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10);
+
+ if (this.hour_slider) {
+ this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax });
+ this.control.value(this, this.hour_slider, 'hour', this.hour);
+ }
+ if (this.minute_slider) {
+ this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax });
+ this.control.value(this, this.minute_slider, 'minute', this.minute);
+ }
+ if (this.second_slider) {
+ this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax });
+ this.control.value(this, this.second_slider, 'second', this.second);
+ }
+ if (this.millisec_slider) {
+ this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax });
+ this.control.value(this, this.millisec_slider, 'millisec', this.millisec);
+ }
+ }
+
+ },
+
+ /*
+ * when a slider moves, set the internal time...
+ * on time change is also called when the time is updated in the text field
+ */
+ _onTimeChange: function() {
+ var hour = (this.hour_slider) ? this.control.value(this, this.hour_slider, 'hour') : false,
+ minute = (this.minute_slider) ? this.control.value(this, this.minute_slider, 'minute') : false,
+ second = (this.second_slider) ? this.control.value(this, this.second_slider, 'second') : false,
+ millisec = (this.millisec_slider) ? this.control.value(this, this.millisec_slider, 'millisec') : false,
+ timezone = (this.timezone_select) ? this.timezone_select.val() : false,
+ o = this._defaults,
+ pickerTimeFormat = o.pickerTimeFormat || o.timeFormat,
+ pickerTimeSuffix = o.pickerTimeSuffix || o.timeSuffix;
+
+ if (typeof(hour) == 'object') {
+ hour = false;
+ }
+ if (typeof(minute) == 'object') {
+ minute = false;
+ }
+ if (typeof(second) == 'object') {
+ second = false;
+ }
+ if (typeof(millisec) == 'object') {
+ millisec = false;
+ }
+ if (typeof(timezone) == 'object') {
+ timezone = false;
+ }
+
+ if (hour !== false) {
+ hour = parseInt(hour, 10);
+ }
+ if (minute !== false) {
+ minute = parseInt(minute, 10);
+ }
+ if (second !== false) {
+ second = parseInt(second, 10);
+ }
+ if (millisec !== false) {
+ millisec = parseInt(millisec, 10);
+ }
+
+ var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0];
+
+ // If the update was done in the input field, the input field should not be updated.
+ // If the update was done using the sliders, update the input field.
+ var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || millisec != this.millisec
+ || (this.ampm.length > 0 && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
+ || ((this.timezone === null && timezone != this.defaultTimezone) || (this.timezone !== null && timezone != this.timezone)));
+
+ if (hasChanged) {
+
+ if (hour !== false) {
+ this.hour = hour;
+ }
+ if (minute !== false) {
+ this.minute = minute;
+ }
+ if (second !== false) {
+ this.second = second;
+ }
+ if (millisec !== false) {
+ this.millisec = millisec;
+ }
+ if (timezone !== false) {
+ this.timezone = timezone;
+ }
+
+ if (!this.inst) {
+ this.inst = $.datepicker._getInst(this.$input[0]);
+ }
+
+ this._limitMinMaxDateTime(this.inst, true);
+ }
+ if (useAmpm(o.timeFormat)) {
+ this.ampm = ampm;
+ }
+
+ // Updates the time within the timepicker
+ this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
+ if (this.$timeObj) {
+ if(pickerTimeFormat === o.timeFormat){
+ this.$timeObj.text(this.formattedTime + pickerTimeSuffix);
+ }
+ else{
+ this.$timeObj.text($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
+ }
+ }
+
+ this.timeDefined = true;
+ if (hasChanged) {
+ this._updateDateTime();
+ }
+ },
+
+ /*
+ * call custom onSelect.
+ * bind to sliders slidestop, and grid click.
+ */
+ _onSelectHandler: function() {
+ var onSelect = this._defaults.onSelect || this.inst.settings.onSelect;
+ var inputEl = this.$input ? this.$input[0] : null;
+ if (onSelect && inputEl) {
+ onSelect.apply(inputEl, [this.formattedDateTime, this]);
+ }
+ },
+
+ /*
+ * update our input with the new date time..
+ */
+ _updateDateTime: function(dp_inst) {
+ dp_inst = this.inst || dp_inst;
+ var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
+ dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
+ formatCfg = $.datepicker._getFormatConfig(dp_inst),
+ timeAvailable = dt !== null && this.timeDefined;
+ this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
+ var formattedDateTime = this.formattedDate;
+
+ /*
+ * remove following lines to force every changes in date picker to change the input value
+ * Bug descriptions: when an input field has a default value, and click on the field to pop up the date picker.
+ * If the user manually empty the value in the input field, the date picker will never change selected value.
+ */
+ //if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0)) {
+ // return;
+ //}
+
+ if (this._defaults.timeOnly === true) {
+ formattedDateTime = this.formattedTime;
+ } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
+ formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
+ }
+
+ this.formattedDateTime = formattedDateTime;
+
+ if (!this._defaults.showTimepicker) {
+ this.$input.val(this.formattedDate);
+ } else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
+ this.$altInput.val(this.formattedTime);
+ this.$input.val(this.formattedDate);
+ } else if (this.$altInput) {
+ this.$input.val(formattedDateTime);
+ var altFormattedDateTime = '',
+ altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
+ altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
+
+ if (this._defaults.altFormat) altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
+ else altFormattedDateTime = this.formattedDate;
+ if (altFormattedDateTime) altFormattedDateTime += altSeparator;
+ if (this._defaults.altTimeFormat) altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
+ else altFormattedDateTime += this.formattedTime + altTimeSuffix;
+ this.$altInput.val(altFormattedDateTime);
+ } else {
+ this.$input.val(formattedDateTime);
+ }
+
+ this.$input.trigger("change");
+ },
+
+ _onFocus: function() {
+ if (!this.$input.val() && this._defaults.defaultValue) {
+ this.$input.val(this._defaults.defaultValue);
+ var inst = $.datepicker._getInst(this.$input.get(0)),
+ tp_inst = $.datepicker._get(inst, 'timepicker');
+ if (tp_inst) {
+ if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
+ try {
+ $.datepicker._updateDatepicker(inst);
+ } catch (err) {
+ $.datepicker.log(err);
+ }
+ }
+ }
+ }
+ },
+
+ /*
+ * Small abstraction to control types
+ * We can add more, just be sure to follow the pattern: create, options, value
+ */
+ _controls: {
+ // slider methods
+ slider: {
+ create: function(tp_inst, obj, unit, val, min, max, step){
+ var rtl = tp_inst._defaults.isRTL; // if rtl go -60->0 instead of 0->60
+ return obj.prop('slide', null).slider({
+ orientation: "horizontal",
+ value: rtl? val*-1 : val,
+ min: rtl? max*-1 : min,
+ max: rtl? min*-1 : max,
+ step: step,
+ slide: function(event, ui) {
+ tp_inst.control.value(tp_inst, $(this), unit, rtl? ui.value*-1:ui.value);
+ tp_inst._onTimeChange();
+ },
+ stop: function(event, ui) {
+ tp_inst._onSelectHandler();
+ }
+ });
+ },
+ options: function(tp_inst, obj, unit, opts, val){
+ if(tp_inst._defaults.isRTL){
+ if(typeof(opts) == 'string'){
+ if(opts == 'min' || opts == 'max'){
+ if(val !== undefined)
+ return obj.slider(opts, val*-1);
+ return Math.abs(obj.slider(opts));
+ }
+ return obj.slider(opts);
+ }
+ var min = opts.min,
+ max = opts.max;
+ opts.min = opts.max = null;
+ if(min !== undefined)
+ opts.max = min * -1;
+ if(max !== undefined)
+ opts.min = max * -1;
+ return obj.slider(opts);
+ }
+ if(typeof(opts) == 'string' && val !== undefined)
+ return obj.slider(opts, val);
+ return obj.slider(opts);
+ },
+ value: function(tp_inst, obj, unit, val){
+ if(tp_inst._defaults.isRTL){
+ if(val !== undefined)
+ return obj.slider('value', val*-1);
+ return Math.abs(obj.slider('value'));
+ }
+ if(val !== undefined)
+ return obj.slider('value', val);
+ return obj.slider('value');
+ }
+ },
+ // select methods
+ select: {
+ create: function(tp_inst, obj, unit, val, min, max, step){
+ var sel = '<select class="ui-timepicker-select" data-unit="'+ unit +'" data-min="'+ min +'" data-max="'+ max +'" data-step="'+ step +'">',
+ ul = tp_inst._defaults.timeFormat.indexOf('t') !== -1? 'toLowerCase':'toUpperCase',
+ m = 0;
+
+ for(var i=min; i<=max; i+=step){
+ sel += '<option value="'+ i +'"'+ (i==val? ' selected':'') +'>';
+ if(unit == 'hour' && useAmpm(tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat))
+ sel += $.datepicker.formatTime("hh TT", {hour:i}, tp_inst._defaults);
+ else if(unit == 'millisec' || i >= 10) sel += i;
+ else sel += '0'+ i.toString();
+ sel += '</option>';
+ }
+ sel += '</select>';
+
+ obj.children('select').remove();
+
+ $(sel).appendTo(obj).change(function(e){
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ });
+
+ return obj;
+ },
+ options: function(tp_inst, obj, unit, opts, val){
+ var o = {},
+ $t = obj.children('select');
+ if(typeof(opts) == 'string'){
+ if(val === undefined)
+ return $t.data(opts);
+ o[opts] = val;
+ }
+ else o = opts;
+ return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min || $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
+ },
+ value: function(tp_inst, obj, unit, val){
+ var $t = obj.children('select');
+ if(val !== undefined)
+ return $t.val(val);
+ return $t.val();
+ }
+ }
+ } // end _controls
+
+ });
+
+ $.fn.extend({
+ /*
+ * shorthand just to use timepicker..
+ */
+ timepicker: function(o) {
+ o = o || {};
+ var tmp_args = Array.prototype.slice.call(arguments);
+
+ if (typeof o == 'object') {
+ tmp_args[0] = $.extend(o, {
+ timeOnly: true
+ });
+ }
+
+ return $(this).each(function() {
+ $.fn.datetimepicker.apply($(this), tmp_args);
+ });
+ },
+
+ /*
+ * extend timepicker to datepicker
+ */
+ datetimepicker: function(o) {
+ o = o || {};
+ var tmp_args = arguments;
+
+ if (typeof(o) == 'string') {
+ if (o == 'getDate') {
+ return $.fn.datepicker.apply($(this[0]), tmp_args);
+ } else {
+ return this.each(function() {
+ var $t = $(this);
+ $t.datepicker.apply($t, tmp_args);
+ });
+ }
+ } else {
+ return this.each(function() {
+ var $t = $(this);
+ $t.datepicker($.timepicker._newInst($t, o)._defaults);
+ });
+ }
+ }
+ });
+
+ /*
+ * Public Utility to parse date and time
+ */
+ $.datepicker.parseDateTime = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
+ var parseRes = parseDateTimeInternal(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings);
+ if (parseRes.timeObj) {
+ var t = parseRes.timeObj;
+ parseRes.date.setHours(t.hour, t.minute, t.second, t.millisec);
+ }
+
+ return parseRes.date;
+ };
+
+ /*
+ * Public utility to parse time
+ */
+ $.datepicker.parseTime = function(timeFormat, timeString, options) {
+ var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {});
+
+ // Strict parse requires the timeString to match the timeFormat exactly
+ var strictParse = function(f, s, o){
+
+ // pattern for standard and localized AM/PM markers
+ var getPatternAmpm = function(amNames, pmNames) {
+ var markers = [];
+ if (amNames) {
+ $.merge(markers, amNames);
+ }
+ if (pmNames) {
+ $.merge(markers, pmNames);
+ }
+ markers = $.map(markers, function(val) {
+ return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&');
+ });
+ return '(' + markers.join('|') + ')?';
+ };
+
+ // figure out position of time elements.. cause js cant do named captures
+ var getFormatPositions = function(timeFormat) {
+ var finds = timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z|'.*?')/g),
+ orders = {
+ h: -1,
+ m: -1,
+ s: -1,
+ l: -1,
+ t: -1,
+ z: -1
+ };
+
+ if (finds) {
+ for (var i = 0; i < finds.length; i++) {
+ if (orders[finds[i].toString().charAt(0)] == -1) {
+ orders[finds[i].toString().charAt(0)] = i + 1;
+ }
+ }
+ }
+ return orders;
+ };
+
+ var regstr = '^' + f.toString()
+ .replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[lz]|'.*?')/g, function (match) {
+ switch (match.charAt(0).toLowerCase()) {
+ case 'h': return '(\\d?\\d)';
+ case 'm': return '(\\d?\\d)';
+ case 's': return '(\\d?\\d)';
+ case 'l': return '(\\d?\\d?\\d)';
+ case 'z': return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
+ case 't': return getPatternAmpm(o.amNames, o.pmNames);
+ default: // literal escaped in quotes
+ return '(' + match.replace(/\'/g, "").replace(/(\.|\$|\^|\\|\/|\(|\)|\[|\]|\?|\+|\*)/g, function (m) { return "\\" + m; }) + ')?';
+ }
+ })
+ .replace(/\s/g, '\\s?') +
+ o.timeSuffix + '$',
+ order = getFormatPositions(f),
+ ampm = '',
+ treg;
+
+ treg = s.match(new RegExp(regstr, 'i'));
+
+ var resTime = {
+ hour: 0,
+ minute: 0,
+ second: 0,
+ millisec: 0
+ };
+
+ if (treg) {
+ if (order.t !== -1) {
+ if (treg[order.t] === undefined || treg[order.t].length === 0) {
+ ampm = '';
+ resTime.ampm = '';
+ } else {
+ ampm = $.inArray(treg[order.t].toUpperCase(), o.amNames) !== -1 ? 'AM' : 'PM';
+ resTime.ampm = o[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
+ }
+ }
+
+ if (order.h !== -1) {
+ if (ampm == 'AM' && treg[order.h] == '12') {
+ resTime.hour = 0; // 12am = 0 hour
+ } else {
+ if (ampm == 'PM' && treg[order.h] != '12') {
+ resTime.hour = parseInt(treg[order.h], 10) + 12; // 12pm = 12 hour, any other pm = hour + 12
+ } else {
+ resTime.hour = Number(treg[order.h]);
+ }
+ }
+ }
+
+ if (order.m !== -1) {
+ resTime.minute = Number(treg[order.m]);
+ }
+ if (order.s !== -1) {
+ resTime.second = Number(treg[order.s]);
+ }
+ if (order.l !== -1) {
+ resTime.millisec = Number(treg[order.l]);
+ }
+ if (order.z !== -1 && treg[order.z] !== undefined) {
+ var tz = treg[order.z].toUpperCase();
+ switch (tz.length) {
+ case 1:
+ // Z
+ tz = o.timezoneIso8601 ? 'Z' : '+0000';
+ break;
+ case 5:
+ // +hhmm
+ if (o.timezoneIso8601) {
+ tz = tz.substring(1) == '0000' ? 'Z' : tz.substring(0, 3) + ':' + tz.substring(3);
+ }
+ break;
+ case 6:
+ // +hh:mm
+ if (!o.timezoneIso8601) {
+ tz = tz == 'Z' || tz.substring(1) == '00:00' ? '+0000' : tz.replace(/:/, '');
+ } else {
+ if (tz.substring(1) == '00:00') {
+ tz = 'Z';
+ }
+ }
+ break;
+ }
+ resTime.timezone = tz;
+ }
+
+
+ return resTime;
+ }
+ return false;
+ };// end strictParse
+
+ // First try JS Date, if that fails, use strictParse
+ var looseParse = function(f,s,o){
+ try{
+ var d = new Date('2012-01-01 '+ s);
+ return {
+ hour: d.getHours(),
+ minutes: d.getMinutes(),
+ seconds: d.getSeconds(),
+ millisec: d.getMilliseconds(),
+ timezone: $.timepicker.timeZoneOffsetString(d)
+ };
+ }
+ catch(err){
+ try{
+ return strictParse(f,s,o);
+ }
+ catch(err2){
+ $.datepicker.log("Unable to parse \ntimeString: "+ s +"\ntimeFormat: "+ f);
+ }
+ }
+ return false;
+ }; // end looseParse
+
+ if(typeof o.parse === "function"){
+ return o.parse(timeFormat, timeString, o)
+ }
+ if(o.parse === 'loose'){
+ return looseParse(timeFormat, timeString, o);
+ }
+ return strictParse(timeFormat, timeString, o);
+ };
+
+ /*
+ * Public utility to format the time
+ * format = string format of the time
+ * time = a {}, not a Date() for timezones
+ * options = essentially the regional[].. amNames, pmNames, ampm
+ */
+ $.datepicker.formatTime = function(format, time, options) {
+ options = options || {};
+ options = $.extend({}, $.timepicker._defaults, options);
+ time = $.extend({
+ hour: 0,
+ minute: 0,
+ second: 0,
+ millisec: 0,
+ timezone: '+0000'
+ }, time);
+
+ var tmptime = format,
+ ampmName = options.amNames[0],
+ hour = parseInt(time.hour, 10);
+
+ if (hour > 11) {
+ ampmName = options.pmNames[0];
+ }
+
+ tmptime = tmptime.replace(/(?:HH?|hh?|mm?|ss?|[tT]{1,2}|[lz]|('.*?'|".*?"))/g, function(match) {
+ switch (match) {
+ case 'HH':
+ return ('0' + hour).slice(-2);
+ case 'H':
+ return hour;
+ case 'hh':
+ return ('0' + convert24to12(hour)).slice(-2);
+ case 'h':
+ return convert24to12(hour);
+ case 'mm':
+ return ('0' + time.minute).slice(-2);
+ case 'm':
+ return time.minute;
+ case 'ss':
+ return ('0' + time.second).slice(-2);
+ case 's':
+ return time.second;
+ case 'l':
+ return ('00' + time.millisec).slice(-3);
+ case 'z':
+ return time.timezone === null? options.defaultTimezone : time.timezone;
+ case 'T':
+ return ampmName.charAt(0).toUpperCase();
+ case 'TT':
+ return ampmName.toUpperCase();
+ case 't':
+ return ampmName.charAt(0).toLowerCase();
+ case 'tt':
+ return ampmName.toLowerCase();
+ default:
+ return match.replace(/\'/g, "") || "'";
+ }
+ });
+
+ tmptime = $.trim(tmptime);
+ return tmptime;
+ };
+
+ /*
+ * the bad hack :/ override datepicker so it doesnt close on select
+ // inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
+ */
+ $.datepicker._base_selectDate = $.datepicker._selectDate;
+ $.datepicker._selectDate = function(id, dateStr) {
+ var inst = this._getInst($(id)[0]),
+ tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ tp_inst._limitMinMaxDateTime(inst, true);
+ inst.inline = inst.stay_open = true;
+ //This way the onSelect handler called from calendarpicker get the full dateTime
+ this._base_selectDate(id, dateStr);
+ inst.inline = inst.stay_open = false;
+ this._notifyChange(inst);
+ this._updateDatepicker(inst);
+ } else {
+ this._base_selectDate(id, dateStr);
+ }
+ };
+
+ /*
+ * second bad hack :/ override datepicker so it triggers an event when changing the input field
+ * and does not redraw the datepicker on every selectDate event
+ */
+ $.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
+ $.datepicker._updateDatepicker = function(inst) {
+
+ // don't popup the datepicker if there is another instance already opened
+ var input = inst.input[0];
+ if ($.datepicker._curInst && $.datepicker._curInst != inst && $.datepicker._datepickerShowing && $.datepicker._lastInput != input) {
+ return;
+ }
+
+ if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
+
+ this._base_updateDatepicker(inst);
+
+ // Reload the time control when changing something in the input text field.
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ tp_inst._addTimePicker(inst);
+
+ if (tp_inst._defaults.useLocalTimezone) { //checks daylight saving with the new date.
+ var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 12);
+ selectLocalTimeZone(tp_inst, date);
+ tp_inst._onTimeChange();
+ }
+ }
+ }
+ };
+
+ /*
+ * third bad hack :/ override datepicker so it allows spaces and colon in the input field
+ */
+ $.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
+ $.datepicker._doKeyPress = function(event) {
+ var inst = $.datepicker._getInst(event.target),
+ tp_inst = $.datepicker._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ if ($.datepicker._get(inst, 'constrainInput')) {
+ var ampm = useAmpm(tp_inst._defaults.timeFormat),
+ dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
+ datetimeChars = tp_inst._defaults.timeFormat.toString()
+ .replace(/[hms]/g, '')
+ .replace(/TT/g, ampm ? 'APM' : '')
+ .replace(/Tt/g, ampm ? 'AaPpMm' : '')
+ .replace(/tT/g, ampm ? 'AaPpMm' : '')
+ .replace(/T/g, ampm ? 'AP' : '')
+ .replace(/tt/g, ampm ? 'apm' : '')
+ .replace(/t/g, ampm ? 'ap' : '') +
+ " " + tp_inst._defaults.separator +
+ tp_inst._defaults.timeSuffix +
+ (tp_inst._defaults.showTimezone ? tp_inst._defaults.timezoneList.join('') : '') +
+ (tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) +
+ dateChars,
+ chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
+ return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
+ }
+ }
+
+ return $.datepicker._base_doKeyPress(event);
+ };
+
+ /*
+ * Fourth bad hack :/ override _updateAlternate function used in inline mode to init altField
+ */
+ $.datepicker._base_updateAlternate = $.datepicker._updateAlternate;
+ /* Update any alternate field to synchronise with the main field. */
+ $.datepicker._updateAlternate = function(inst) {
+ var tp_inst = this._get(inst, 'timepicker');
+ if(tp_inst){
+ var altField = tp_inst._defaults.altField;
+ if (altField) { // update alternate field too
+ var altFormat = tp_inst._defaults.altFormat || tp_inst._defaults.dateFormat,
+ date = this._getDate(inst),
+ formatCfg = $.datepicker._getFormatConfig(inst),
+ altFormattedDateTime = '',
+ altSeparator = tp_inst._defaults.altSeparator ? tp_inst._defaults.altSeparator : tp_inst._defaults.separator,
+ altTimeSuffix = tp_inst._defaults.altTimeSuffix ? tp_inst._defaults.altTimeSuffix : tp_inst._defaults.timeSuffix,
+ altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
+
+ altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
+ if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly){
+ if(tp_inst._defaults.altFormat)
+ altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, (date === null ? new Date() : date), formatCfg) + altSeparator + altFormattedDateTime;
+ else altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
+ }
+ $(altField).val(altFormattedDateTime);
+ }
+ }
+ else{
+ $.datepicker._base_updateAlternate(inst);
+ }
+ };
+
+ /*
+ * Override key up event to sync manual input changes.
+ */
+ $.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
+ $.datepicker._doKeyUp = function(event) {
+ var inst = $.datepicker._getInst(event.target),
+ tp_inst = $.datepicker._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
+ try {
+ $.datepicker._updateDatepicker(inst);
+ } catch (err) {
+ $.datepicker.log(err);
+ }
+ }
+ }
+
+ return $.datepicker._base_doKeyUp(event);
+ };
+
+ /*
+ * override "Today" button to also grab the time.
+ */
+ $.datepicker._base_gotoToday = $.datepicker._gotoToday;
+ $.datepicker._gotoToday = function(id) {
+ var inst = this._getInst($(id)[0]),
+ $dp = inst.dpDiv;
+ this._base_gotoToday(id);
+ var tp_inst = this._get(inst, 'timepicker');
+ selectLocalTimeZone(tp_inst);
+ var now = new Date();
+ this._setTime(inst, now);
+ $('.ui-datepicker-today', $dp).click();
+ };
+
+ /*
+ * Disable & enable the Time in the datetimepicker
+ */
+ $.datepicker._disableTimepickerDatepicker = function(target) {
+ var inst = this._getInst(target);
+ if (!inst) {
+ return;
+ }
+
+ var tp_inst = this._get(inst, 'timepicker');
+ $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
+ if (tp_inst) {
+ tp_inst._defaults.showTimepicker = false;
+ tp_inst._updateDateTime(inst);
+ }
+ };
+
+ $.datepicker._enableTimepickerDatepicker = function(target) {
+ var inst = this._getInst(target);
+ if (!inst) {
+ return;
+ }
+
+ var tp_inst = this._get(inst, 'timepicker');
+ $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
+ if (tp_inst) {
+ tp_inst._defaults.showTimepicker = true;
+ tp_inst._addTimePicker(inst); // Could be disabled on page load
+ tp_inst._updateDateTime(inst);
+ }
+ };
+
+ /*
+ * Create our own set time function
+ */
+ $.datepicker._setTime = function(inst, date) {
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ var defaults = tp_inst._defaults;
+
+ // calling _setTime with no date sets time to defaults
+ tp_inst.hour = date ? date.getHours() : defaults.hour;
+ tp_inst.minute = date ? date.getMinutes() : defaults.minute;
+ tp_inst.second = date ? date.getSeconds() : defaults.second;
+ tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
+
+ //check if within min/max times..
+ tp_inst._limitMinMaxDateTime(inst, true);
+
+ tp_inst._onTimeChange();
+ tp_inst._updateDateTime(inst);
+ }
+ };
+
+ /*
+ * Create new public method to set only time, callable as $().datepicker('setTime', date)
+ */
+ $.datepicker._setTimeDatepicker = function(target, date, withDate) {
+ var inst = this._getInst(target);
+ if (!inst) {
+ return;
+ }
+
+ var tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ this._setDateFromField(inst);
+ var tp_date;
+ if (date) {
+ if (typeof date == "string") {
+ tp_inst._parseTime(date, withDate);
+ tp_date = new Date();
+ tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
+ } else {
+ tp_date = new Date(date.getTime());
+ }
+ if (tp_date.toString() == 'Invalid Date') {
+ tp_date = undefined;
+ }
+ this._setTime(inst, tp_date);
+ }
+ }
+
+ };
+
+ /*
+ * override setDate() to allow setting time too within Date object
+ */
+ $.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
+ $.datepicker._setDateDatepicker = function(target, date) {
+ var inst = this._getInst(target);
+ if (!inst) {
+ return;
+ }
+
+ var tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
+
+ this._updateDatepicker(inst);
+ this._base_setDateDatepicker.apply(this, arguments);
+ this._setTimeDatepicker(target, tp_date, true);
+ };
+
+ /*
+ * override getDate() to allow getting time too within Date object
+ */
+ $.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
+ $.datepicker._getDateDatepicker = function(target, noDefault) {
+ var inst = this._getInst(target);
+ if (!inst) {
+ return;
+ }
+
+ var tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ // if it hasn't yet been defined, grab from field
+ if(inst.lastVal === undefined){
+ this._setDateFromField(inst, noDefault);
+ }
+
+ var date = this._getDate(inst);
+ if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) {
+ date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
+ }
+ return date;
+ }
+ return this._base_getDateDatepicker(target, noDefault);
+ };
+
+ /*
+ * override parseDate() because UI 1.8.14 throws an error about "Extra characters"
+ * An option in datapicker to ignore extra format characters would be nicer.
+ */
+ $.datepicker._base_parseDate = $.datepicker.parseDate;
+ $.datepicker.parseDate = function(format, value, settings) {
+ var date;
+ try {
+ date = this._base_parseDate(format, value, settings);
+ } catch (err) {
+ // Hack! The error message ends with a colon, a space, and
+ // the "extra" characters. We rely on that instead of
+ // attempting to perfectly reproduce the parsing algorithm.
+ date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
+ $.datepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
+ }
+ return date;
+ };
+
+ /*
+ * override formatDate to set date with time to the input
+ */
+ $.datepicker._base_formatDate = $.datepicker._formatDate;
+ $.datepicker._formatDate = function(inst, day, month, year) {
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ tp_inst._updateDateTime(inst);
+ return tp_inst.$input.val();
+ }
+ return this._base_formatDate(inst);
+ };
+
+ /*
+ * override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
+ */
+ $.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
+ $.datepicker._optionDatepicker = function(target, name, value) {
+ var inst = this._getInst(target),
+ name_clone;
+ if (!inst) {
+ return null;
+ }
+
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ var min = null,
+ max = null,
+ onselect = null,
+ overrides = tp_inst._defaults.evnts,
+ fns = {},
+ prop;
+ if (typeof name == 'string') { // if min/max was set with the string
+ if (name === 'minDate' || name === 'minDateTime') {
+ min = value;
+ } else if (name === 'maxDate' || name === 'maxDateTime') {
+ max = value;
+ } else if (name === 'onSelect') {
+ onselect = value;
+ } else if (overrides.hasOwnProperty(name)) {
+ if (typeof (value) === 'undefined') {
+ return overrides[name];
+ }
+ fns[name] = value;
+ name_clone = {}; //empty results in exiting function after overrides updated
+ }
+ } else if (typeof name == 'object') { //if min/max was set with the JSON
+ if (name.minDate) {
+ min = name.minDate;
+ } else if (name.minDateTime) {
+ min = name.minDateTime;
+ } else if (name.maxDate) {
+ max = name.maxDate;
+ } else if (name.maxDateTime) {
+ max = name.maxDateTime;
+ }
+ for (prop in overrides) {
+ if (overrides.hasOwnProperty(prop) && name[prop]) {
+ fns[prop] = name[prop];
+ }
+ }
+ }
+ for (prop in fns) {
+ if (fns.hasOwnProperty(prop)) {
+ overrides[prop] = fns[prop];
+ if (!name_clone) { name_clone = $.extend({}, name);}
+ delete name_clone[prop];
+ }
+ }
+ if (name_clone && isEmptyObject(name_clone)) { return; }
+ if (min) { //if min was set
+ if (min === 0) {
+ min = new Date();
+ } else {
+ min = new Date(min);
+ }
+ tp_inst._defaults.minDate = min;
+ tp_inst._defaults.minDateTime = min;
+ } else if (max) { //if max was set
+ if (max === 0) {
+ max = new Date();
+ } else {
+ max = new Date(max);
+ }
+ tp_inst._defaults.maxDate = max;
+ tp_inst._defaults.maxDateTime = max;
+ } else if (onselect) {
+ tp_inst._defaults.onSelect = onselect;
+ }
+ }
+ if (value === undefined) {
+ return this._base_optionDatepicker.call($.datepicker, target, name);
+ }
+ return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
+ };
+ /*
+ * jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
+ * it will return false for all objects
+ */
+ var isEmptyObject = function(obj) {
+ var prop;
+ for (prop in obj) {
+ if (obj.hasOwnProperty(obj)) {
+ return false;
+ }
+ }
+ return true;
+ };
+
+ /*
+ * jQuery extend now ignores nulls!
+ */
+ var extendRemove = function(target, props) {
+ $.extend(target, props);
+ for (var name in props) {
+ if (props[name] === null || props[name] === undefined) {
+ target[name] = props[name];
+ }
+ }
+ return target;
+ };
+
+ /*
+ * Determine by the time format if should use ampm
+ * Returns true if should use ampm, false if not
+ */
+ var useAmpm = function(timeFormat){
+ return (timeFormat.indexOf('t') !== -1 && timeFormat.indexOf('h') !== -1);
+ };
+
+ /*
+ * Converts 24 hour format into 12 hour
+ * Returns 12 hour without leading 0
+ */
+ var convert24to12 = function(hour) {
+ if (hour > 12) {
+ hour = hour - 12;
+ }
+
+ if (hour == 0) {
+ hour = 12;
+ }
+
+ return String(hour);
+ };
+
+ /*
+ * Splits datetime string into date ans time substrings.
+ * Throws exception when date can't be parsed
+ * Returns [dateString, timeString]
+ */
+ var splitDateTime = function(dateFormat, dateTimeString, dateSettings, timeSettings) {
+ try {
+ // The idea is to get the number separator occurances in datetime and the time format requested (since time has
+ // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
+ var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator,
+ format = timeSettings && timeSettings.timeFormat ? timeSettings.timeFormat : $.timepicker._defaults.timeFormat,
+ timeParts = format.split(separator), // how many occurances of separator may be in our format?
+ timePartsLen = timeParts.length,
+ allParts = dateTimeString.split(separator),
+ allPartsLen = allParts.length;
+
+ if (allPartsLen > 1) {
+ return [
+ allParts.splice(0,allPartsLen-timePartsLen).join(separator),
+ allParts.splice(0,timePartsLen).join(separator)
+ ];
+ }
+
+ } catch (err) {
+ $.datepicker.log('Could not split the date from the time. Please check the following datetimepicker options' +
+ "\nthrown error: " + err +
+ "\ndateTimeString" + dateTimeString +
+ "\ndateFormat = " + dateFormat +
+ "\nseparator = " + timeSettings.separator +
+ "\ntimeFormat = " + timeSettings.timeFormat);
+
+ if (err.indexOf(":") >= 0) {
+ // Hack! The error message ends with a colon, a space, and
+ // the "extra" characters. We rely on that instead of
+ // attempting to perfectly reproduce the parsing algorithm.
+ var dateStringLength = dateTimeString.length - (err.length - err.indexOf(':') - 2),
+ timeString = dateTimeString.substring(dateStringLength);
+
+ return [$.trim(dateTimeString.substring(0, dateStringLength)), $.trim(dateTimeString.substring(dateStringLength))];
+
+ } else {
+ throw err;
+ }
+ }
+ return [dateTimeString, ''];
+ };
+
+ /*
+ * Internal function to parse datetime interval
+ * Returns: {date: Date, timeObj: Object}, where
+ * date - parsed date without time (type Date)
+ * timeObj = {hour: , minute: , second: , millisec: } - parsed time. Optional
+ */
+ var parseDateTimeInternal = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
+ var date;
+ var splitRes = splitDateTime(dateFormat, dateTimeString, dateSettings, timeSettings);
+ date = $.datepicker._base_parseDate(dateFormat, splitRes[0], dateSettings);
+ if (splitRes[1] !== '') {
+ var timeString = splitRes[1],
+ parsedTime = $.datepicker.parseTime(timeFormat, timeString, timeSettings);
+
+ if (parsedTime === null) {
+ throw 'Wrong time format';
+ }
+ return {
+ date: date,
+ timeObj: parsedTime
+ };
+ } else {
+ return {
+ date: date
+ };
+ }
+ };
+
+ /*
+ * Internal function to set timezone_select to the local timezone
+ */
+ var selectLocalTimeZone = function(tp_inst, date) {
+ if (tp_inst && tp_inst.timezone_select) {
+ tp_inst._defaults.useLocalTimezone = true;
+ var now = typeof date !== 'undefined' ? date : new Date();
+ var tzoffset = $.timepicker.timeZoneOffsetString(now);
+ if (tp_inst._defaults.timezoneIso8601) {
+ tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
+ }
+ tp_inst.timezone_select.val(tzoffset);
+ }
+ };
+
+ /*
+ * Create a Singleton Insance
+ */
+ $.timepicker = new Timepicker();
+
+ /**
+ * Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
+ * @param date
+ * @return string
+ */
+ $.timepicker.timeZoneOffsetString = function(date) {
+ var off = date.getTimezoneOffset() * -1,
+ minutes = off % 60,
+ hours = (off - minutes) / 60;
+ return (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).substr(-2) + ('0' + (minutes * 101).toString()).substr(-2);
+ };
+
+ /**
+ * Calls `timepicker()` on the `startTime` and `endTime` elements, and configures them to
+ * enforce date range limits.
+ * n.b. The input value must be correctly formatted (reformatting is not supported)
+ * @param Element startTime
+ * @param Element endTime
+ * @param obj options Options for the timepicker() call
+ * @return jQuery
+ */
+ $.timepicker.timeRange = function(startTime, endTime, options) {
+ return $.timepicker.handleRange('timepicker', startTime, endTime, options);
+ };
+
+ /**
+ * Calls `datetimepicker` on the `startTime` and `endTime` elements, and configures them to
+ * enforce date range limits.
+ * @param Element startTime
+ * @param Element endTime
+ * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
+ * a boolean value that can be used to reformat the input values to the `dateFormat`.
+ * @param string method Can be used to specify the type of picker to be added
+ * @return jQuery
+ */
+ $.timepicker.dateTimeRange = function(startTime, endTime, options) {
+ $.timepicker.dateRange(startTime, endTime, options, 'datetimepicker');
+ };
+
+ /**
+ * Calls `method` on the `startTime` and `endTime` elements, and configures them to
+ * enforce date range limits.
+ * @param Element startTime
+ * @param Element endTime
+ * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
+ * a boolean value that can be used to reformat the input values to the `dateFormat`.
+ * @param string method Can be used to specify the type of picker to be added
+ * @return jQuery
+ */
+ $.timepicker.dateRange = function(startTime, endTime, options, method) {
+ method = method || 'datepicker';
+ $.timepicker.handleRange(method, startTime, endTime, options);
+ };
+
+ /**
+ * Calls `method` on the `startTime` and `endTime` elements, and configures them to
+ * enforce date range limits.
+ * @param string method Can be used to specify the type of picker to be added
+ * @param Element startTime
+ * @param Element endTime
+ * @param obj options Options for the `timepicker()` call. Also supports `reformat`,
+ * a boolean value that can be used to reformat the input values to the `dateFormat`.
+ * @return jQuery
+ */
+ $.timepicker.handleRange = function(method, startTime, endTime, options) {
+ $.fn[method].call(startTime, $.extend({
+ onClose: function(dateText, inst) {
+ checkDates(this, endTime, dateText);
+ },
+ onSelect: function(selectedDateTime) {
+ selected(this, endTime, 'minDate');
+ }
+ }, options, options.start));
+ $.fn[method].call(endTime, $.extend({
+ onClose: function(dateText, inst) {
+ checkDates(this, startTime, dateText);
+ },
+ onSelect: function(selectedDateTime) {
+ selected(this, startTime, 'maxDate');
+ }
+ }, options, options.end));
+ // timepicker doesn't provide access to its 'timeFormat' option,
+ // nor could I get datepicker.formatTime() to behave with times, so I
+ // have disabled reformatting for timepicker
+ if (method != 'timepicker' && options.reformat) {
+ $([startTime, endTime]).each(function() {
+ var format = $(this)[method].call($(this), 'option', 'dateFormat'),
+ date = new Date($(this).val());
+ if ($(this).val() && date) {
+ $(this).val($.datepicker.formatDate(format, date));
+ }
+ });
+ }
+ checkDates(startTime, endTime, startTime.val());
+
+ function checkDates(changed, other, dateText) {
+ if (other.val() && (new Date(startTime.val()) > new Date(endTime.val()))) {
+ other.val(dateText);
+ }
+ }
+ selected(startTime, endTime, 'minDate');
+ selected(endTime, startTime, 'maxDate');
+
+ function selected(changed, other, option) {
+ if (!$(changed).val()) {
+ return;
+ }
+ var date = $(changed)[method].call($(changed), 'getDate');
+ // timepicker doesn't implement 'getDate' and returns a jQuery
+ if (date.getTime) {
+ $(other)[method].call($(other), 'option', option, date);
+ }
+ }
+ return $([startTime.get(0), endTime.get(0)]);
+ };
+
+ /*
+ * Keep up with the version
+ */
+ $.timepicker.version = "1.1.1";
+
+})(jQuery);
\ No newline at end of file
unit/build.xml 57(+57 -0)
diff --git a/unit/build.xml b/unit/build.xml
new file mode 100644
index 0000000..d949de5
--- /dev/null
+++ b/unit/build.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+
+<project name="azkaban-testjob" basedir="." default="all">
+ <property name="base.dir" value="${basedir}/.." />
+ <property name="dist.jar.dir" value="${base.dir}/dist/unit/jars" />
+ <property name="dist.classes.dir" value="${base.dir}/dist/unit/classes" />
+ <property name="dist.packages.dir" value="${base.dir}/dist/unit/packages" />
+
+ <property name="java.src.dir" value="${base.dir}/unit/java" />
+ <property name="job.conf.dir" value="${base.dir}/unit/executions/exectest1" />
+
+ <property environment="env" />
+
+ <!-- set the build number based on environment variable, otherwise blank -->
+ <property environment="env" description="System environment variables (including those set by Hudson)" />
+
+ <target name="all" depends="clean, jars" description="Builds all jars" />
+
+ <target name="clean" description="Delete generated files.">
+ <echo message="Deleting generated files in dist" />
+ <delete dir="${dist.jar.dir}" />
+ <delete dir="${dist.classes.dir}" />
+ <delete dir="${dist.packages.dir}" />
+ </target>
+
+ <target name="build" description="Compile main source tree java files">
+ <delete dir="${dist.classes.dir}" />
+ <mkdir dir="${dist.classes.dir}" />
+ <mkdir dir="${dist.packages.dir}" />
+
+ <javac fork="true" destdir="${dist.classes.dir}"
+ target="1.6" debug="true" deprecation="false" failonerror="true" srcdir="${java.src.dir}/azkaban/test/executor" includes="*Job.java">
+ </javac>
+ </target>
+
+ <target name="jars" depends="build" description="Create azkaban jar">
+ <delete dir="${dist.jar.dir}" />
+ <mkdir dir="${dist.jar.dir}" />
+ <jar destfile="${dist.jar.dir}/test.jar">
+ <fileset dir="${dist.classes.dir}">
+ <include name="**/*.*" />
+ </fileset>
+ </jar>
+ </target>
+
+ <target name="package-testjob" depends="jars" description="Creates a test zip">
+ <delete dir="${dist.packages.dir}" />
+ <mkdir dir="${dist.packages.dir}" />
+
+ <!-- Tarball it -->
+ <zip destfile="${dist.packages.dir}/testjob.zip">
+ <zipfileset dir="${dist.jar.dir}" />
+ <zipfileset dir="${job.conf.dir}" />
+ </zip>
+ </target>
+
+</project>
unit/executions/exectest1/exec1.flow 2(+2 -0)
diff --git a/unit/executions/exectest1/exec1.flow b/unit/executions/exectest1/exec1.flow
index 4684cd6..3612d58 100644
--- a/unit/executions/exectest1/exec1.flow
+++ b/unit/executions/exectest1/exec1.flow
@@ -1,4 +1,6 @@
{
+ "project.id":1,
+ "version":2,
"id" : "derived-member-data",
"success.email" : [],
"edges" : [ {
unit/executions/exectest1/exec2.flow 2(+2 -0)
diff --git a/unit/executions/exectest1/exec2.flow b/unit/executions/exectest1/exec2.flow
index f31c99e..7197af9 100644
--- a/unit/executions/exectest1/exec2.flow
+++ b/unit/executions/exectest1/exec2.flow
@@ -1,4 +1,6 @@
{
+ "project.id":1,
+ "version":2,
"id" : "derived-member-data",
"success.email" : [],
"edges" : [ {
unit/executions/exectest1/exec3.flow 2(+2 -0)
diff --git a/unit/executions/exectest1/exec3.flow b/unit/executions/exectest1/exec3.flow
index 4a137b0..d1ea3ac 100644
--- a/unit/executions/exectest1/exec3.flow
+++ b/unit/executions/exectest1/exec3.flow
@@ -1,4 +1,6 @@
{
+ "project.id":1,
+ "version":2,
"id" : "derived-member-data",
"success.email" : [],
"edges" : [ {
unit/executions/logtest/largeLog1.log 3240(+3240 -0)
diff --git a/unit/executions/logtest/largeLog1.log b/unit/executions/logtest/largeLog1.log
new file mode 100644
index 0000000..76e9006
--- /dev/null
+++ b/unit/executions/logtest/largeLog1.log
@@ -0,0 +1,3240 @@
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
\ No newline at end of file
diff --git a/unit/executions/logtest/largeLog2.log b/unit/executions/logtest/largeLog2.log
new file mode 100644
index 0000000..8a0ce3f
--- /dev/null
+++ b/unit/executions/logtest/largeLog2.log
@@ -0,0 +1,8 @@
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
\ No newline at end of file
unit/executions/logtest/largeLog3.log 7200(+7200 -0)
diff --git a/unit/executions/logtest/largeLog3.log b/unit/executions/logtest/largeLog3.log
new file mode 100644
index 0000000..95bafdc
--- /dev/null
+++ b/unit/executions/logtest/largeLog3.log
@@ -0,0 +1,7200 @@
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
+I'm Henery the Eighth, I am,
+Henery the Eighth I am, I am!
+I got married to the widow next door,
+She's been married seven times before.
+And every one was an Henery
+It wouldn't be a Willie or a Sam
+I'm her eighth old man I'm Henery
+Henery the Eighth, I am!
+Second verse, same as the first!
\ No newline at end of file
unit/executions/logtest/log1.log 1(+1 -0)
diff --git a/unit/executions/logtest/log1.log b/unit/executions/logtest/log1.log
new file mode 100644
index 0000000..f721b7e
--- /dev/null
+++ b/unit/executions/logtest/log1.log
@@ -0,0 +1 @@
+My name is R
\ No newline at end of file
unit/executions/logtest/log2.log 1(+1 -0)
diff --git a/unit/executions/logtest/log2.log b/unit/executions/logtest/log2.log
new file mode 100644
index 0000000..2621270
--- /dev/null
+++ b/unit/executions/logtest/log2.log
@@ -0,0 +1 @@
+ichard Park. This is a multiple l
\ No newline at end of file
unit/executions/logtest/log3.log 1(+1 -0)
diff --git a/unit/executions/logtest/log3.log b/unit/executions/logtest/log3.log
new file mode 100644
index 0000000..baa8422
--- /dev/null
+++ b/unit/executions/logtest/log3.log
@@ -0,0 +1 @@
+og test.
\ No newline at end of file
diff --git a/unit/java/azkaban/scheduler/JdbcScheduleLoaderTest.java b/unit/java/azkaban/scheduler/JdbcScheduleLoaderTest.java
new file mode 100644
index 0000000..84dd074
--- /dev/null
+++ b/unit/java/azkaban/scheduler/JdbcScheduleLoaderTest.java
@@ -0,0 +1,248 @@
+package azkaban.scheduler;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import junit.framework.Assert;
+
+import org.apache.commons.dbutils.DbUtils;
+import org.apache.commons.dbutils.QueryRunner;
+import org.apache.commons.dbutils.ResultSetHandler;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+import azkaban.utils.DataSourceUtils;
+import azkaban.utils.Props;
+
+public class JdbcScheduleLoaderTest {
+ private static boolean testDBExists;
+ private static final String host = "localhost";
+ private static final int port = 3306;
+ private static final String database = "azkaban";
+ private static final String user = "azkaban";
+ private static final String password = "azkaban";
+ private static final int numConnections = 10;
+
+ @BeforeClass
+ public static void setupDB() {
+ DataSource dataSource = DataSourceUtils.getMySQLDataSource(host, port, database, user, password, numConnections);
+ testDBExists = true;
+
+ Connection connection = null;
+ try {
+ connection = dataSource.getConnection();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ CountHandler countHandler = new CountHandler();
+ QueryRunner runner = new QueryRunner();
+ try {
+ int count = runner.query(connection, "SELECT COUNT(1) FROM schedules", countHandler);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+ }
+
+ @AfterClass
+ public static void clearDB() {
+ if (!testDBExists) {
+ return;
+ }
+
+ DataSource dataSource = DataSourceUtils.getMySQLDataSource(host, port, database, user, password, numConnections);
+ Connection connection = null;
+ try {
+ connection = dataSource.getConnection();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+// CountHandler countHandler = new CountHandler();
+ QueryRunner runner = new QueryRunner();
+ try {
+ int count = runner.update(connection, "DELETE FROM schedules");
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+ finally {
+ DbUtils.closeQuietly(connection);
+ }
+ }
+
+// @Test
+// public void testLoadSchedule() {
+// if (!testDBExists) {
+// return;
+// }
+//
+// DataSource dataSource = DataSourceUtils.getMySQLDataSource(host, port, database, user, password, numConnections);
+// Connection connection = null;
+// try {
+// connection = dataSource.getConnection();
+// } catch (SQLException e) {
+// e.printStackTrace();
+// testDBExists = false;
+// DbUtils.closeQuietly(connection);
+// return;
+// }
+//
+//// CountHandler countHandler = new CountHandler();
+// QueryRunner runner = new QueryRunner();
+// try {
+// int count = runner.update(connection, "DELETE FROM schedules");
+//
+// } catch (SQLException e) {
+// e.printStackTrace();
+// testDBExists = false;
+// DbUtils.closeQuietly(connection);
+// return;
+// }
+// finally {
+// DbUtils.closeQuietly(connection);
+// }
+// }
+
+ @Test
+ public void testInsertAndLoadSchedule() throws ScheduleManagerException {
+ if (!isTestSetup()) {
+ return;
+ }
+ clearDB();
+
+ JdbcScheduleLoader loader = createLoader();
+
+ Schedule s1 = new Schedule(1, "proj1", "flow1", "ready", 11111, "America/Los_Angeles", "1d", 22222, 33333, 44444, "cyu");
+ Schedule s2 = new Schedule(1, "proj1", "flow2", "ready", 11111, "America/Los_Angeles", "1d", 22222, 33333, 44444, "ccc");
+ Schedule s3 = new Schedule(2, "proj1", "flow1", "ready", 11111, "America/Los_Angeles", "1d", 22222, 33333, 44444, "cyu");
+ Schedule s4 = new Schedule(3, "proj2", "flow1", "ready", 11111, "America/Los_Angeles", "1d", 22222, 33333, 44444, "cyu");
+ Schedule s5 = new Schedule(3, "proj2", "flow2", "ready", 11111, "America/Los_Angeles", "1d", 22222, 33333, 44444, "cyu");
+ Schedule s6 = new Schedule(3, "proj2", "flow3", "error", 11111, "America/Los_Angeles", "1d", 22222, 33333, 44444, "cyu");
+
+ loader.insertSchedule(s1);
+ loader.insertSchedule(s2);
+ loader.insertSchedule(s3);
+ loader.insertSchedule(s4);
+ loader.insertSchedule(s5);
+ loader.insertSchedule(s6);
+
+ List<Schedule> schedules = loader.loadSchedules();
+
+ Assert.assertEquals(6, schedules.size());
+ Assert.assertEquals("America/Los_Angeles", schedules.get(0).getTimezone().getID());
+ Assert.assertEquals(44444, schedules.get(0).getSubmitTime());
+ Assert.assertEquals("1d", Schedule.createPeriodString(schedules.get(0).getPeriod()));
+
+ }
+
+ @Test
+ public void testInsertAndRemoveSchedule() {
+ if (!testDBExists) {
+ return;
+ }
+
+ clearDB();
+
+ JdbcScheduleLoader loader = createLoader();
+
+ List<Schedule> schedules = new ArrayList<Schedule>();
+
+ int stress = 100;
+
+ for(int i=0; i<stress; i++)
+ {
+ Schedule s = new Schedule(i+1, "proj"+(i+1), "flow1", "ready", 11111, "America/Los_Angeles", "1d", 22222, 33333, 44444, "cyu");
+ schedules.add(s);
+ try {
+ loader.insertSchedule(s);
+ } catch (ScheduleManagerException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ for(Schedule s : schedules)
+ {
+ try {
+ loader.removeSchedule(s);
+ } catch (ScheduleManagerException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ // should have cleaned up
+ List<Schedule> otherSchedules = null;
+ try {
+ otherSchedules = loader.loadSchedules();
+ } catch (ScheduleManagerException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Assert.assertEquals(0, otherSchedules.size());
+
+ }
+
+
+ private JdbcScheduleLoader createLoader() {
+ Props props = new Props();
+ props.put("database.type", "mysql");
+
+ props.put("mysql.host", host);
+ props.put("mysql.port", port);
+ props.put("mysql.user", user);
+ props.put("mysql.database", database);
+ props.put("mysql.password", password);
+ props.put("mysql.numconnections", numConnections);
+
+ return new JdbcScheduleLoader(props);
+ }
+
+ private boolean isTestSetup() {
+ if (!testDBExists) {
+ System.err.println("Skipping DB test because Db not setup.");
+ return false;
+ }
+
+ System.out.println("Running DB test because Db setup.");
+ return true;
+ }
+
+ public static class CountHandler implements ResultSetHandler<Integer> {
+ @Override
+ public Integer handle(ResultSet rs) throws SQLException {
+ int val = 0;
+ while (rs.next()) {
+ val++;
+ }
+
+ return val;
+ }
+
+ }
+}
diff --git a/unit/java/azkaban/test/execapp/MockExecutorLoader.java b/unit/java/azkaban/test/execapp/MockExecutorLoader.java
new file mode 100644
index 0000000..1e5fc79
--- /dev/null
+++ b/unit/java/azkaban/test/execapp/MockExecutorLoader.java
@@ -0,0 +1,166 @@
+package azkaban.test.execapp;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import azkaban.executor.ExecutableFlow;
+import azkaban.executor.ExecutableJobInfo;
+import azkaban.executor.ExecutableNode;
+import azkaban.executor.ExecutionReference;
+import azkaban.executor.ExecutorLoader;
+import azkaban.executor.ExecutorManagerException;
+import azkaban.utils.FileIOUtils.LogData;
+import azkaban.utils.Pair;
+import azkaban.utils.Props;
+
+public class MockExecutorLoader implements ExecutorLoader {
+
+ HashMap<Integer, ExecutableFlow> flows = new HashMap<Integer, ExecutableFlow>();
+ HashMap<String, ExecutableNode> nodes = new HashMap<String, ExecutableNode>();
+ HashMap<Integer, ExecutionReference> refs = new HashMap<Integer, ExecutionReference>();
+ int flowUpdateCount = 0;
+ HashMap<String, Integer> jobUpdateCount = new HashMap<String,Integer>();
+
+ @Override
+ public void uploadExecutableFlow(ExecutableFlow flow) throws ExecutorManagerException {
+ flows.put(flow.getExecutionId(), flow);
+ flowUpdateCount++;
+ }
+
+ @Override
+ public ExecutableFlow fetchExecutableFlow(int execId) throws ExecutorManagerException {
+ ExecutableFlow flow = flows.get(execId);
+ return ExecutableFlow.createExecutableFlowFromObject(flow.toObject());
+ }
+
+ @Override
+ public Map<Integer, Pair<ExecutionReference, ExecutableFlow>> fetchActiveFlows() throws ExecutorManagerException {
+ return null;
+ }
+
+ @Override
+ public List<ExecutableFlow> fetchFlowHistory(int projectId, String flowId, int skip, int num) throws ExecutorManagerException {
+ return null;
+ }
+
+ @Override
+ public void addActiveExecutableReference(ExecutionReference ref) throws ExecutorManagerException {
+ refs.put(ref.getExecId(), ref);
+ }
+
+ @Override
+ public void removeActiveExecutableReference(int execId) throws ExecutorManagerException {
+ refs.remove(execId);
+ }
+
+ public boolean hasActiveExecutableReference(int execId) {
+ return refs.containsKey(execId);
+ }
+
+ @Override
+ public void uploadLogFile(int execId, String name, File... files) throws ExecutorManagerException {
+
+ }
+
+ @Override
+ public void updateExecutableFlow(ExecutableFlow flow) throws ExecutorManagerException {
+ ExecutableFlow toUpdate = flows.get(flow.getExecutionId());
+
+ toUpdate.applyUpdateObject((Map<String,Object>)flow.toUpdateObject(0));
+ flowUpdateCount++;
+ }
+
+ @Override
+ public void uploadExecutableNode(ExecutableNode node, Props inputParams) throws ExecutorManagerException {
+ nodes.put(node.getJobId(), ExecutableNode.createNodeFromObject(node.toObject(), null));
+ jobUpdateCount.put(node.getJobId(), 1);
+ }
+
+ @Override
+ public void updateExecutableNode(ExecutableNode node, Props outputParams) throws ExecutorManagerException {
+ ExecutableNode foundNode = nodes.get(node.getJobId());
+ foundNode.setEndTime(node.getEndTime());
+ foundNode.setStartTime(node.getStartTime());
+ foundNode.setStatus(node.getStatus());
+ foundNode.setUpdateTime(node.getUpdateTime());
+
+ Integer value = jobUpdateCount.get(node.getJobId());
+ if (value == null) {
+ throw new ExecutorManagerException("The node has not been uploaded");
+ }
+ else {
+ jobUpdateCount.put(node.getJobId(), ++value);
+ }
+
+ flowUpdateCount++;
+ }
+
+ @Override
+ public int fetchNumExecutableFlows(int projectId, String flowId) throws ExecutorManagerException {
+ return 0;
+ }
+
+ @Override
+ public int fetchNumExecutableFlows() throws ExecutorManagerException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getFlowUpdateCount() {
+ return flowUpdateCount;
+ }
+
+ public Integer getNodeUpdateCount(String jobId) {
+ return jobUpdateCount.get(jobId);
+ }
+
+ @Override
+ public ExecutableJobInfo fetchJobInfo(int execId, String jobId)
+ throws ExecutorManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean updateExecutableReference(int execId, long updateTime) throws ExecutorManagerException {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ @Override
+ public LogData fetchLogs(int execId, String name, int startByte, int endByte) throws ExecutorManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<ExecutableFlow> fetchFlowHistory(int skip, int num) throws ExecutorManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<ExecutableFlow> fetchFlowHistory(String projectContains, String flowContains, String userNameContains, int status,
+ long startData, long endData, int skip, int num) throws ExecutorManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<ExecutableJobInfo> fetchJobHistory(int projectId, String jobId, int skip, int size)
+ throws ExecutorManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int fetchNumExecutableNodes(int projectId, String jobId) throws ExecutorManagerException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+
+}
\ No newline at end of file
diff --git a/unit/java/azkaban/test/execapp/MockProjectLoader.java b/unit/java/azkaban/test/execapp/MockProjectLoader.java
new file mode 100644
index 0000000..a9c560d
--- /dev/null
+++ b/unit/java/azkaban/test/execapp/MockProjectLoader.java
@@ -0,0 +1,198 @@
+package azkaban.test.execapp;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import azkaban.flow.Flow;
+import azkaban.project.Project;
+import azkaban.project.ProjectFileHandler;
+import azkaban.project.ProjectLoader;
+import azkaban.project.ProjectLogEvent;
+import azkaban.project.ProjectLogEvent.EventType;
+import azkaban.project.ProjectManagerException;
+import azkaban.user.Permission;
+import azkaban.user.User;
+import azkaban.utils.Props;
+
+public class MockProjectLoader implements ProjectLoader {
+ public File dir;
+
+ public MockProjectLoader(File dir) {
+ this.dir = dir;
+ }
+
+ @Override
+ public List<Project> fetchAllActiveProjects()
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Project fetchProjectById(int id) throws ProjectManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Project createNewProject(String name, String description,
+ User creator) throws ProjectManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void removeProject(Project project, String user)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updatePermission(Project project, String name, Permission perm,
+ boolean isGroup) throws ProjectManagerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateDescription(Project project, String description,
+ String user) throws ProjectManagerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean postEvent(Project project, EventType type, String user,
+ String message) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public List<ProjectLogEvent> getProjectEvents(Project project, int num,
+ int skip) throws ProjectManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void uploadProjectFile(Project project, int version,
+ String filetype, String filename, File localFile, String user)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public ProjectFileHandler getUploadedFile(Project project, int version)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ProjectFileHandler getUploadedFile(int projectId, int version)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void changeProjectVersion(Project project, int version, String user)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uploadFlows(Project project, int version, Collection<Flow> flows)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uploadFlow(Project project, int version, Flow flow)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Flow fetchFlow(Project project, String flowId)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<Flow> fetchAllProjectFlows(Project project)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getLatestProjectVersion(Project project)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void uploadProjectProperty(Project project, Props props)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void uploadProjectProperties(Project project, List<Props> properties)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Props fetchProjectProperty(Project project, String propsName)
+ throws ProjectManagerException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Map<String, Props> fetchProjectProperties(int projectId, int version)
+ throws ProjectManagerException {
+ Map<String, Props> propertyMap = new HashMap<String, Props>();
+ for (File file: dir.listFiles()) {
+ String name = file.getName();
+ if (name.endsWith(".job") || name.endsWith(".properties")) {
+ try {
+ Props props = new Props(null, file);
+ propertyMap.put(name, props);
+ } catch (IOException e) {
+ throw new ProjectManagerException(e.getMessage());
+ }
+ }
+ }
+
+ return propertyMap;
+ }
+
+ @Override
+ public void cleanOlderProjectVersion(int projectId, int version) throws ProjectManagerException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removePermission(Project project, String name, boolean isGroup) throws ProjectManagerException {
+ // TODO Auto-generated method stub
+
+ }
+}
\ No newline at end of file
diff --git a/unit/java/azkaban/test/execapp/ProjectVersionsTest.java b/unit/java/azkaban/test/execapp/ProjectVersionsTest.java
new file mode 100644
index 0000000..5a0a31b
--- /dev/null
+++ b/unit/java/azkaban/test/execapp/ProjectVersionsTest.java
@@ -0,0 +1,29 @@
+package azkaban.test.execapp;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+import azkaban.execapp.ProjectVersion;
+
+public class ProjectVersionsTest {
+
+ @Test
+ public void testVersionOrdering() {
+ ArrayList<ProjectVersion> pversion = new ArrayList<ProjectVersion>();
+ pversion.add(new ProjectVersion(1, 2));
+ pversion.add(new ProjectVersion(1, 3));
+ pversion.add(new ProjectVersion(1, 1));
+
+ Collections.sort(pversion);
+
+ int i = 0;
+ for (ProjectVersion version: pversion) {
+ Assert.assertTrue(i < version.getVersion());
+ i = version.getVersion();
+ }
+ }
+}
\ No newline at end of file
diff --git a/unit/java/azkaban/test/executor/JdbcExecutorLoaderTest.java b/unit/java/azkaban/test/executor/JdbcExecutorLoaderTest.java
new file mode 100644
index 0000000..19175a1
--- /dev/null
+++ b/unit/java/azkaban/test/executor/JdbcExecutorLoaderTest.java
@@ -0,0 +1,405 @@
+package azkaban.test.executor;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import junit.framework.Assert;
+
+import org.apache.commons.dbutils.DbUtils;
+import org.apache.commons.dbutils.QueryRunner;
+import org.apache.commons.dbutils.ResultSetHandler;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+import azkaban.executor.ExecutableFlow;
+import azkaban.executor.ExecutableJobInfo;
+import azkaban.executor.ExecutableNode;
+import azkaban.executor.ExecutionReference;
+import azkaban.executor.ExecutorLoader;
+import azkaban.executor.ExecutorManagerException;
+import azkaban.executor.JdbcExecutorLoader;
+import azkaban.executor.ExecutableFlow.Status;
+import azkaban.flow.Flow;
+
+import azkaban.utils.DataSourceUtils;
+import azkaban.utils.FileIOUtils.LogData;
+import azkaban.utils.JSONUtils;
+import azkaban.utils.Pair;
+import azkaban.utils.Props;
+
+public class JdbcExecutorLoaderTest {
+ private static boolean testDBExists;
+ //@TODO remove this and turn into local host.
+ private static final String host = "rpark-ld.linkedin.biz";
+ private static final int port = 3306;
+ private static final String database = "test";
+ private static final String user = "azkaban";
+ private static final String password = "azkaban";
+ private static final int numConnections = 10;
+
+ private File flowDir = new File("unit/executions/exectest1");
+
+ @BeforeClass
+ public static void setupDB() {
+ DataSource dataSource = DataSourceUtils.getMySQLDataSource(host, port, database, user, password, numConnections);
+ testDBExists = true;
+
+ Connection connection = null;
+ try {
+ connection = dataSource.getConnection();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ CountHandler countHandler = new CountHandler();
+ QueryRunner runner = new QueryRunner();
+ try {
+ runner.query(connection, "SELECT COUNT(1) FROM active_executing_flows", countHandler);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.query(connection, "SELECT COUNT(1) FROM execution_flows", countHandler);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.query(connection, "SELECT COUNT(1) FROM execution_jobs", countHandler);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.query(connection, "SELECT COUNT(1) FROM execution_logs", countHandler);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ DbUtils.closeQuietly(connection);
+
+ clearDB();
+ }
+
+ private static void clearDB() {
+ if (!testDBExists) {
+ return;
+ }
+
+ DataSource dataSource = DataSourceUtils.getMySQLDataSource(host, port, database, user, password, numConnections);
+ Connection connection = null;
+ try {
+ connection = dataSource.getConnection();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ QueryRunner runner = new QueryRunner();
+ try {
+ runner.update(connection, "DELETE FROM active_executing_flows");
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.update(connection, "DELETE FROM execution_flows");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.update(connection, "DELETE FROM execution_jobs");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.update(connection, "DELETE FROM execution_logs");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ DbUtils.closeQuietly(connection);
+ }
+
+ @Test
+ public void testUploadExecutionFlows() throws Exception {
+ if (!isTestSetup()) {
+ return;
+ }
+
+ ExecutorLoader loader = createLoader();
+ ExecutableFlow flow = createExecutableFlow("exec1");
+
+ loader.uploadExecutableFlow(flow);
+
+ ExecutableFlow fetchFlow = loader.fetchExecutableFlow(flow.getExecutionId());
+
+ // Shouldn't be the same object.
+ Assert.assertTrue(flow != fetchFlow);
+ Assert.assertEquals(flow.getExecutionId(), fetchFlow.getExecutionId());
+ Assert.assertEquals(flow.getEndTime(), fetchFlow.getEndTime());
+ Assert.assertEquals(flow.getStartTime(), fetchFlow.getStartTime());
+ Assert.assertEquals(flow.getSubmitTime(), fetchFlow.getSubmitTime());
+ Assert.assertEquals(flow.getFlowId(), fetchFlow.getFlowId());
+ Assert.assertEquals(flow.getProjectId(), fetchFlow.getProjectId());
+ Assert.assertEquals(flow.getVersion(), fetchFlow.getVersion());
+ Assert.assertEquals(flow.getFailureAction(), fetchFlow.getFailureAction());
+ Assert.assertEquals(new HashSet<String>(flow.getEndNodes()), new HashSet<String>(fetchFlow.getEndNodes()));
+ }
+
+ @Test
+ public void testUpdateExecutionFlows() throws Exception {
+ if (!isTestSetup()) {
+ return;
+ }
+
+ ExecutorLoader loader = createLoader();
+ ExecutableFlow flow = createExecutableFlow("exec1");
+
+ loader.uploadExecutableFlow(flow);
+
+ ExecutableFlow fetchFlow2 = loader.fetchExecutableFlow(flow.getExecutionId());
+
+ fetchFlow2.setEndTime(System.currentTimeMillis());
+ fetchFlow2.setStatus(Status.SUCCEEDED);
+ loader.updateExecutableFlow(fetchFlow2);
+ ExecutableFlow fetchFlow = loader.fetchExecutableFlow(flow.getExecutionId());
+
+ // Shouldn't be the same object.
+ Assert.assertTrue(flow != fetchFlow);
+ Assert.assertEquals(flow.getExecutionId(), fetchFlow.getExecutionId());
+ Assert.assertEquals(fetchFlow2.getEndTime(), fetchFlow.getEndTime());
+ Assert.assertEquals(fetchFlow2.getStatus(), fetchFlow.getStatus());
+ Assert.assertEquals(flow.getStartTime(), fetchFlow.getStartTime());
+ Assert.assertEquals(flow.getSubmitTime(), fetchFlow.getSubmitTime());
+ Assert.assertEquals(flow.getFlowId(), fetchFlow.getFlowId());
+ Assert.assertEquals(flow.getProjectId(), fetchFlow.getProjectId());
+ Assert.assertEquals(flow.getVersion(), fetchFlow.getVersion());
+ Assert.assertEquals(flow.getFailureAction(), fetchFlow.getFailureAction());
+ Assert.assertEquals(new HashSet<String>(flow.getEndNodes()), new HashSet<String>(fetchFlow.getEndNodes()));
+ }
+
+ @Test
+ public void testUploadExecutableNode() throws Exception {
+ if (!isTestSetup()) {
+ return;
+ }
+
+ ExecutorLoader loader = createLoader();
+ ExecutableFlow flow = createExecutableFlow("exec1");
+ flow.setExecutionId(10);
+
+ File jobFile = new File(flowDir, "job10.job");
+ Props props = new Props(null, jobFile);
+ props.put("test","test2");
+ ExecutableNode oldNode = flow.getExecutableNode("job10");
+ loader.uploadExecutableNode(oldNode, props);
+
+ ExecutableJobInfo info = loader.fetchJobInfo(10, "job10");
+ Assert.assertEquals(flow.getExecutionId(), info.getExecId());
+ Assert.assertEquals(flow.getProjectId(), info.getProjectId());
+ Assert.assertEquals(flow.getVersion(), info.getVersion());
+ Assert.assertEquals(flow.getFlowId(), info.getFlowId());
+ Assert.assertEquals(oldNode.getJobId(), info.getJobId());
+ Assert.assertEquals(oldNode.getStatus(), info.getStatus());
+ Assert.assertEquals(oldNode.getStartTime(), info.getStartTime());
+ Assert.assertEquals("endTime = " + oldNode.getEndTime() + " info endTime = " + info.getEndTime(), oldNode.getEndTime(), info.getEndTime());
+ }
+
+ @Test
+ public void testActiveReference() throws Exception {
+ if (!isTestSetup()) {
+ return;
+ }
+
+ ExecutorLoader loader = createLoader();
+ ExecutableFlow flow1 = createExecutableFlow("exec1");
+ loader.uploadExecutableFlow(flow1);
+ ExecutionReference ref1 = new ExecutionReference(flow1.getExecutionId(), "test", 1);
+ loader.addActiveExecutableReference(ref1);
+
+ ExecutableFlow flow2 = createExecutableFlow("exec1");
+ loader.uploadExecutableFlow(flow2);
+ ExecutionReference ref2 = new ExecutionReference(flow2.getExecutionId(), "test", 1);
+ loader.addActiveExecutableReference(ref2);
+
+ ExecutableFlow flow3 = createExecutableFlow("exec1");
+ loader.uploadExecutableFlow(flow3);
+
+ Map<Integer, Pair<ExecutionReference, ExecutableFlow>> activeFlows1 = loader.fetchActiveFlows();
+ ExecutableFlow flow1Result = activeFlows1.get(flow1.getExecutionId()).getSecond();
+ Assert.assertNotNull(flow1Result);
+ Assert.assertTrue(flow1 != flow1Result);
+ Assert.assertEquals(flow1.getExecutionId(), flow1Result.getExecutionId());
+ Assert.assertEquals(flow1.getEndTime(), flow1Result.getEndTime());
+ Assert.assertEquals(flow1.getStartTime(), flow1Result.getStartTime());
+ Assert.assertEquals(flow1.getSubmitTime(), flow1Result.getSubmitTime());
+ Assert.assertEquals(flow1.getFlowId(), flow1Result.getFlowId());
+ Assert.assertEquals(flow1.getProjectId(), flow1Result.getProjectId());
+ Assert.assertEquals(flow1.getVersion(), flow1Result.getVersion());
+ Assert.assertEquals(flow1.getFailureAction(), flow1Result.getFailureAction());
+
+ ExecutableFlow flow1Result2 = activeFlows1.get(flow2.getExecutionId()).getSecond();
+ Assert.assertNotNull(flow1Result2);
+ Assert.assertTrue(flow2 != flow1Result2);
+ Assert.assertEquals(flow2.getExecutionId(), flow1Result2.getExecutionId());
+ Assert.assertEquals(flow2.getEndTime(), flow1Result2.getEndTime());
+ Assert.assertEquals(flow2.getStartTime(), flow1Result2.getStartTime());
+ Assert.assertEquals(flow2.getSubmitTime(), flow1Result2.getSubmitTime());
+ Assert.assertEquals(flow2.getFlowId(), flow1Result2.getFlowId());
+ Assert.assertEquals(flow2.getProjectId(), flow1Result2.getProjectId());
+ Assert.assertEquals(flow2.getVersion(), flow1Result2.getVersion());
+ Assert.assertEquals(flow2.getFailureAction(), flow1Result2.getFailureAction());
+
+ loader.removeActiveExecutableReference(flow2.getExecutionId());
+ Map<Integer, Pair<ExecutionReference,ExecutableFlow>> activeFlows2 = loader.fetchActiveFlows();
+
+ Assert.assertTrue(activeFlows2.containsKey(flow1.getExecutionId()));
+ Assert.assertFalse(activeFlows2.containsKey(flow3.getExecutionId()));
+ Assert.assertFalse(activeFlows2.containsKey(flow2.getExecutionId()));
+ }
+
+ @Test
+ public void testSmallUploadLog() throws ExecutorManagerException {
+ File logDir = new File("unit/executions/logtest");
+ File[] smalllog = {new File(logDir, "log1.log"), new File(logDir, "log2.log"), new File(logDir, "log3.log")};
+
+ ExecutorLoader loader = createLoader();
+ loader.uploadLogFile(1, "smallFiles", smalllog);
+
+ LogData data = loader.fetchLogs(1, "smallFiles", 0, 50000);
+ Assert.assertNotNull(data);
+ Assert.assertEquals("Logs length is " + data.getLength(), data.getLength(), 53);
+
+ System.out.println(data.toString());
+
+ LogData data2 = loader.fetchLogs(1, "smallFiles", 10, 20);
+ Assert.assertNotNull(data2);
+ Assert.assertEquals("Logs length is " + data2.getLength(), data2.getLength(), 10);
+
+ System.out.println(data2.toString());
+ }
+
+ @Test
+ public void testLargeUploadLog() throws ExecutorManagerException {
+ File logDir = new File("unit/executions/logtest");
+
+ // Multiple of 255 for Henry the Eigth
+ File[] largelog = {new File(logDir, "largeLog1.log"), new File(logDir, "largeLog2.log"), new File(logDir, "largeLog3.log")};
+
+ ExecutorLoader loader = createLoader();
+ loader.uploadLogFile(1, "largeFiles", largelog);
+
+ LogData logsResult = loader.fetchLogs(1, "largeFiles", 0, 64000);
+ Assert.assertNotNull(logsResult);
+ Assert.assertEquals("Logs length is " + logsResult.getLength(), logsResult.getLength(), 64000);
+
+ LogData logsResult2 = loader.fetchLogs(1, "largeFiles", 1000, 64000);
+ Assert.assertNotNull(logsResult2);
+ Assert.assertEquals("Logs length is " + logsResult2.getLength(), logsResult2.getLength(), 63000);
+
+ LogData logsResult3 = loader.fetchLogs(1, "largeFiles", 330000, 400000);
+ Assert.assertNotNull(logsResult3);
+ Assert.assertEquals("Logs length is " + logsResult3.getLength(), logsResult3.getLength(), 5493);
+
+ LogData logsResult4 = loader.fetchLogs(1, "largeFiles", 340000, 400000);
+ Assert.assertNull(logsResult4);
+
+ LogData logsResult5 = loader.fetchLogs(1, "largeFiles", 153600, 204800);
+ Assert.assertNotNull(logsResult5);
+ Assert.assertEquals("Logs length is " + logsResult5.getLength(), logsResult5.getLength(), 51200);
+
+ LogData logsResult6 = loader.fetchLogs(1, "largeFiles", 150000, 250000);
+ Assert.assertNotNull(logsResult6);
+ Assert.assertEquals("Logs length is " + logsResult6.getLength(), logsResult6.getLength(), 100000);
+ }
+
+ private ExecutableFlow createExecutableFlow(String flowName) throws IOException {
+ File jsonFlowFile = new File(flowDir, flowName + ".flow");
+ @SuppressWarnings("unchecked")
+ HashMap<String, Object> flowObj = (HashMap<String, Object>) JSONUtils.parseJSONFromFile(jsonFlowFile);
+
+ Flow flow = Flow.flowFromObject(flowObj);
+ ExecutableFlow execFlow = new ExecutableFlow(flow);
+
+ return execFlow;
+ }
+
+ private ExecutorLoader createLoader() {
+ Props props = new Props();
+ props.put("database.type", "mysql");
+
+ props.put("mysql.host", host);
+ props.put("mysql.port", port);
+ props.put("mysql.user", user);
+ props.put("mysql.database", database);
+ props.put("mysql.password", password);
+ props.put("mysql.numconnections", numConnections);
+
+ return new JdbcExecutorLoader(props);
+ }
+
+ private boolean isTestSetup() {
+ if (!testDBExists) {
+ System.err.println("Skipping DB test because Db not setup.");
+ return false;
+ }
+
+ System.out.println("Running DB test because Db setup.");
+ return true;
+ }
+
+ public static class CountHandler implements ResultSetHandler<Integer> {
+ @Override
+ public Integer handle(ResultSet rs) throws SQLException {
+ int val = 0;
+ while (rs.next()) {
+ val++;
+ }
+
+ return val;
+ }
+ }
+}
\ No newline at end of file
diff --git a/unit/java/azkaban/test/executor/SleepJavaJob.java b/unit/java/azkaban/test/executor/SleepJavaJob.java
index 1ff0ec8..6c0fa4d 100644
--- a/unit/java/azkaban/test/executor/SleepJavaJob.java
+++ b/unit/java/azkaban/test/executor/SleepJavaJob.java
@@ -2,25 +2,35 @@ package azkaban.test.executor;
import java.util.Map;
-import azkaban.utils.Props;
-
public class SleepJavaJob {
- private Props props;
+ private boolean fail;
+ private String seconds;
@SuppressWarnings("unchecked")
public SleepJavaJob(String id, Map<String, String> parameters) {
- props = new Props(null, parameters);
-
+ String failStr = parameters.get("fail");
+ if (failStr == null || failStr.equals("false")) {
+ fail = false;
+ }
+ else {
+ fail = true;
+ }
+
+ seconds = parameters.get("seconds");
System.out.println("Properly created");
}
public void run() throws Exception {
- int sec = props.getInt("seconds");
- boolean fail = props.getBoolean("fail", false);
+ if (seconds == null) {
+ throw new RuntimeException("Seconds not set");
+ }
+
+ int sec = Integer.parseInt(seconds);
+ System.out.println("Sec " + sec);
synchronized(this) {
try {
this.wait(sec*1000);
} catch (InterruptedException e) {
- System.out.println("Interrupted");
+ System.out.println("Interrupted " + fail);
}
}
@@ -30,7 +40,10 @@ public class SleepJavaJob {
}
public void cancel() throws Exception {
- System.out.println("Cancelled called");
- this.notifyAll();
+ System.out.println("Cancelled called on Sleep job");
+ fail = true;
+ synchronized(this) {
+ this.notifyAll();
+ }
}
}
diff --git a/unit/java/azkaban/test/jobExecutor/ProcessJobTest.java b/unit/java/azkaban/test/jobExecutor/ProcessJobTest.java
index 48b1b1b..fabefe3 100644
--- a/unit/java/azkaban/test/jobExecutor/ProcessJobTest.java
+++ b/unit/java/azkaban/test/jobExecutor/ProcessJobTest.java
@@ -73,6 +73,19 @@ public class ProcessJobTest
job.run();
}
+
+ @Test
+ public void testPartitionCommand() throws Exception {
+ String test1 = "a b c";
+
+ Assert.assertArrayEquals(new String[] {"a", "b", "c"}, ProcessJob.partitionCommandLine(test1));
+
+ String test2 = "a 'b c'";
+ Assert.assertArrayEquals(new String[] {"a", "b c"}, ProcessJob.partitionCommandLine(test2));
+
+ String test3 = "a e='b c'";
+ Assert.assertArrayEquals(new String[] {"a", "e=b c"}, ProcessJob.partitionCommandLine(test3));
+ }
}
diff --git a/unit/java/azkaban/test/project/JdbcProjectLoaderTest.java b/unit/java/azkaban/test/project/JdbcProjectLoaderTest.java
new file mode 100644
index 0000000..acb21a3
--- /dev/null
+++ b/unit/java/azkaban/test/project/JdbcProjectLoaderTest.java
@@ -0,0 +1,547 @@
+package azkaban.test.project;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import junit.framework.Assert;
+
+import org.apache.commons.dbutils.DbUtils;
+import org.apache.commons.dbutils.QueryRunner;
+import org.apache.commons.dbutils.ResultSetHandler;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+import azkaban.flow.Edge;
+import azkaban.flow.Flow;
+import azkaban.flow.Node;
+import azkaban.project.JdbcProjectLoader;
+import azkaban.project.JdbcProjectLoader.EncodingType;
+import azkaban.project.Project;
+import azkaban.project.ProjectFileHandler;
+import azkaban.project.ProjectLoader;
+import azkaban.project.ProjectLogEvent;
+import azkaban.project.ProjectLogEvent.EventType;
+import azkaban.project.ProjectManagerException;
+import azkaban.user.Permission;
+import azkaban.user.User;
+import azkaban.utils.DataSourceUtils;
+import azkaban.utils.Pair;
+import azkaban.utils.Props;
+import azkaban.utils.PropsUtils;
+
+public class JdbcProjectLoaderTest {
+ private static boolean testDBExists;
+ //@TODO remove this and turn into local host.
+ private static final String host = "rpark-ld.linkedin.biz";
+ private static final int port = 3306;
+ private static final String database = "test";
+ private static final String user = "azkaban";
+ private static final String password = "azkaban";
+ private static final int numConnections = 10;
+
+ @BeforeClass
+ public static void setupDB() {
+ DataSource dataSource = DataSourceUtils.getMySQLDataSource(host, port, database, user, password, numConnections);
+ testDBExists = true;
+
+ Connection connection = null;
+ try {
+ connection = dataSource.getConnection();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ CountHandler countHandler = new CountHandler();
+ QueryRunner runner = new QueryRunner();
+ try {
+ runner.query(connection, "SELECT COUNT(1) FROM projects", countHandler);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.query(connection, "SELECT COUNT(1) FROM project_events", countHandler);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.query(connection, "SELECT COUNT(1) FROM project_permissions", countHandler);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.query(connection, "SELECT COUNT(1) FROM project_files", countHandler);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.query(connection, "SELECT COUNT(1) FROM project_flows", countHandler);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.query(connection, "SELECT COUNT(1) FROM project_properties", countHandler);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ DbUtils.closeQuietly(connection);
+
+ clearDB();
+ }
+
+ private static void clearDB() {
+ if (!testDBExists) {
+ return;
+ }
+
+ DataSource dataSource = DataSourceUtils.getMySQLDataSource(host, port, database, user, password, numConnections);
+ Connection connection = null;
+ try {
+ connection = dataSource.getConnection();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ QueryRunner runner = new QueryRunner();
+ try {
+ runner.update(connection, "DELETE FROM projects");
+
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.update(connection, "DELETE FROM project_events");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.update(connection, "DELETE FROM project_permissions");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.update(connection, "DELETE FROM project_files");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.update(connection, "DELETE FROM project_flows");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+ try {
+ runner.update(connection, "DELETE FROM project_properties");
+ } catch (SQLException e) {
+ e.printStackTrace();
+ testDBExists = false;
+ DbUtils.closeQuietly(connection);
+ return;
+ }
+
+
+ DbUtils.closeQuietly(connection);
+ }
+
+ @Test
+ public void testCreateProject() throws ProjectManagerException {
+ if (!isTestSetup()) {
+ return;
+ }
+
+ ProjectLoader loader = createLoader();
+ String projectName = "mytestProject";
+ String projectDescription = "This is my new project";
+ User user = new User("testUser");
+
+ Project project = loader.createNewProject(projectName, projectDescription, user);
+ Assert.assertTrue("Project Id set", project.getId() > -1);
+ Assert.assertEquals("Project name", projectName, project.getName());
+ Assert.assertEquals("Project description", projectDescription, project.getDescription());
+
+ System.out.println("Test true");
+ Project project2 = loader.fetchProjectById(project.getId());
+ assertProjectMemberEquals(project, project2);
+ }
+
+ @Test
+ public void testRemoveProject() throws ProjectManagerException {
+ if (!isTestSetup()) {
+ return;
+ }
+
+ ProjectLoader loader = createLoader();
+ String projectName = "testRemoveProject";
+ String projectDescription = "This is my new project";
+ User user = new User("testUser");
+
+ Project project = loader.createNewProject(projectName, projectDescription, user);
+ Assert.assertTrue("Project Id set", project.getId() > -1);
+ Assert.assertEquals("Project name", projectName, project.getName());
+ Assert.assertEquals("Project description", projectDescription, project.getDescription());
+
+ Project project2 = loader.fetchProjectById(project.getId());
+ assertProjectMemberEquals(project, project2);
+ loader.removeProject(project, user.getUserId());
+
+ Project project3 = loader.fetchProjectById(project.getId());
+ Assert.assertFalse(project3.isActive());
+
+ List<Project> projList = loader.fetchAllActiveProjects();
+ for (Project proj: projList) {
+ Assert.assertTrue(proj.getId() != project.getId());
+ }
+ }
+
+ @Test
+ public void testAddRemovePermissions() throws ProjectManagerException {
+ if (!isTestSetup()) {
+ return;
+ }
+
+ ProjectLoader loader = createLoader();
+ String projectName = "mytestProject1";
+ String projectDescription = "This is my new project";
+ User user = new User("testUser");
+
+ Project project = loader.createNewProject(projectName, projectDescription, user);
+ Assert.assertTrue("Project Id set", project.getId() > -1);
+ Assert.assertEquals("Project name", projectName, project.getName());
+ Assert.assertEquals("Project description", projectDescription, project.getDescription());
+
+ Permission perm = new Permission(0x2);
+ loader.updatePermission(project, user.getUserId(), new Permission(0x2), false);
+ loader.updatePermission(project, "group1", new Permission(0x2), true);
+ Assert.assertEquals(perm, project.getUserPermission(user.getUserId()));
+
+ Permission permOverride = new Permission(0x6);
+ loader.updatePermission(project, user.getUserId(), permOverride, false);
+ Assert.assertEquals(permOverride, project.getUserPermission(user.getUserId()));
+
+ Project project2 = loader.fetchProjectById(project.getId());
+ assertProjectMemberEquals(project, project2);
+ Assert.assertEquals(permOverride, project2.getUserPermission(user.getUserId()));
+ }
+
+ @Test
+ public void testProjectEventLogs() throws ProjectManagerException {
+ if (!isTestSetup()) {
+ return;
+ }
+
+ ProjectLoader loader = createLoader();
+ String projectName = "testProjectEventLogs";
+ String projectDescription = "This is my new project";
+ User user = new User("testUser");
+
+ String message = "My message";
+ EventType type = EventType.USER_PERMISSION;
+ Project project = loader.createNewProject(projectName, projectDescription, user);
+ loader.postEvent(project, type, user.getUserId(), message);
+
+ List<ProjectLogEvent> events = loader.getProjectEvents(project, 10, 0);
+ Assert.assertTrue(events.size() == 1);
+
+ ProjectLogEvent event = events.get(0);
+ Assert.assertEquals(event.getProjectId(), project.getId());
+ Assert.assertEquals(event.getUser(), user.getUserId());
+ Assert.assertEquals(event.getMessage(), message);
+ Assert.assertEquals(event.getType(), type);
+ }
+
+ @Test
+ public void testFlowUpload() throws ProjectManagerException {
+ ProjectLoader loader = createLoader();
+ ((JdbcProjectLoader)loader).setDefaultEncodingType(EncodingType.GZIP);
+ String projectName = "mytestFlowUpload1";
+ String projectDescription = "This is my new project";
+ User user = new User("testUser");
+
+ Project project = loader.createNewProject(projectName, projectDescription, user);
+
+ Flow flow = new Flow("MyNewFlow");
+
+ flow.addNode(new Node("A"));
+ flow.addNode(new Node("B"));
+ flow.addNode(new Node("C"));
+ flow.addNode(new Node("D"));
+
+ flow.addEdge(new Edge("A", "B"));
+ flow.addEdge(new Edge("A", "C"));
+ flow.addEdge(new Edge("B", "D"));
+ flow.addEdge(new Edge("C", "D"));
+
+ flow.initialize();
+
+ loader.uploadFlow(project, 4, flow);
+ project.setVersion(4);
+ Flow newFlow = loader.fetchFlow(project, flow.getId());
+ Assert.assertTrue(newFlow != null);
+ Assert.assertEquals(flow.getId(), newFlow.getId());
+ Assert.assertEquals(flow.getEdges().size(), newFlow.getEdges().size());
+ Assert.assertEquals(flow.getNodes().size(), newFlow.getNodes().size());
+ }
+
+ @Test
+ public void testFlowUploadPlain() throws ProjectManagerException {
+ ProjectLoader loader = createLoader();
+ ((JdbcProjectLoader)loader).setDefaultEncodingType(EncodingType.PLAIN);
+ String projectName = "mytestFlowUpload2";
+ String projectDescription = "This is my new project";
+ User user = new User("testUser");
+
+ Project project = loader.createNewProject(projectName, projectDescription, user);
+
+ Flow flow = new Flow("MyNewFlow2");
+
+ flow.addNode(new Node("A1"));
+ flow.addNode(new Node("B1"));
+ flow.addNode(new Node("C1"));
+ flow.addNode(new Node("D1"));
+
+ flow.addEdge(new Edge("A1", "B1"));
+ flow.addEdge(new Edge("A1", "C1"));
+ flow.addEdge(new Edge("B1", "D1"));
+ flow.addEdge(new Edge("C1", "D1"));
+
+ flow.initialize();
+
+ loader.uploadFlow(project, 4, flow);
+ project.setVersion(4);
+ Flow newFlow = loader.fetchFlow(project, flow.getId());
+ Assert.assertTrue(newFlow != null);
+ Assert.assertEquals(flow.getId(), newFlow.getId());
+ Assert.assertEquals(flow.getEdges().size(), newFlow.getEdges().size());
+ Assert.assertEquals(flow.getNodes().size(), newFlow.getNodes().size());
+
+ List<Flow> flows = loader.fetchAllProjectFlows(project);
+ Assert.assertTrue(flows.size() == 1);
+ }
+
+ @Test
+ public void testProjectProperties() throws ProjectManagerException {
+ ProjectLoader loader = createLoader();
+ ((JdbcProjectLoader)loader).setDefaultEncodingType(EncodingType.PLAIN);
+ String projectName = "testProjectProperties";
+ String projectDescription = "This is my new project";
+ User user = new User("testUser");
+
+ Project project = loader.createNewProject(projectName, projectDescription, user);
+ project.setVersion(5);
+ Props props = new Props();
+ props.put("a", "abc");
+ props.put("b", "bcd");
+ props.put("c", "cde");
+ props.setSource("mysource");
+ loader.uploadProjectProperty(project, props);
+
+ Props retProps = loader.fetchProjectProperty(project, "mysource");
+
+ Assert.assertEquals(retProps.getSource(), props.getSource());
+ Assert.assertEquals(retProps.getKeySet(), props.getKeySet());
+ Assert.assertEquals(PropsUtils.toStringMap(retProps, true), PropsUtils.toStringMap(props, true));
+ }
+
+ @Test
+ public void testProjectFilesUpload() throws ProjectManagerException {
+ if (!isTestSetup()) {
+ return;
+ }
+
+ ProjectLoader loader = createLoader();
+ String projectName = "testProjectFilesUpload1";
+ String projectDescription = "This is my new project";
+ User user = new User("testUser");
+
+ Project project = loader.createNewProject(projectName, projectDescription, user);
+ Assert.assertTrue("Project Id set", project.getId() > -1);
+ Assert.assertEquals("Project name", projectName, project.getName());
+ Assert.assertEquals("Project description", projectDescription, project.getDescription());
+
+ File testDir = new File("unit/project/testjob/testjob.zip");
+
+ loader.uploadProjectFile(project, 1, "zip", "testjob.zip", testDir, user.getUserId());
+
+ ProjectFileHandler handler = loader.getUploadedFile(project, 1);
+ Assert.assertEquals(handler.getProjectId(), project.getId());
+ Assert.assertEquals(handler.getFileName(), "testjob.zip");
+ Assert.assertEquals(handler.getVersion(), 1);
+ Assert.assertEquals(handler.getFileType(), "zip");
+ File file = handler.getLocalFile();
+ Assert.assertTrue(handler.getLocalFile().exists());
+ Assert.assertEquals(handler.getFileName(), "testjob.zip");
+ Assert.assertEquals(handler.getUploader(), user.getUserId());
+
+ handler.deleteLocalFile();
+ Assert.assertTrue(handler.getLocalFile() == null);
+ Assert.assertFalse(file.exists());
+ }
+
+ // Custom equals for what I think is important
+ private void assertProjectMemberEquals(Project p1, Project p2) {
+ Assert.assertEquals(p1.getId(), p2.getId());
+ Assert.assertEquals(p1.getName(), p2.getName());
+ Assert.assertEquals(p1.getCreateTimestamp(), p2.getCreateTimestamp());
+ Assert.assertEquals(p1.getDescription(), p2.getDescription());
+ Assert.assertEquals(p1.getLastModifiedUser(), p2.getLastModifiedUser());
+ Assert.assertEquals(p1.getVersion(), p2.getVersion());
+ Assert.assertEquals(p1.isActive(), p2.isActive());
+ Assert.assertEquals(p1.getLastModifiedUser(), p2.getLastModifiedUser());
+
+ assertUserPermissionsEqual(p1, p2);
+ assertGroupPermissionsEqual(p1, p2);
+ }
+
+ private void assertUserPermissionsEqual(Project p1, Project p2) {
+ List<Pair<String, Permission>> perm1 = p1.getUserPermissions();
+ List<Pair<String, Permission>> perm2 = p2.getUserPermissions();
+
+ Assert.assertEquals(perm1.size(), perm2.size());
+
+ {
+ HashMap<String, Permission> perm1Map = new HashMap<String, Permission>();
+ for (Pair<String, Permission> p: perm1) {
+ perm1Map.put(p.getFirst(), p.getSecond());
+ }
+ for (Pair<String, Permission> p: perm2) {
+ Assert.assertTrue(perm1Map.containsKey(p.getFirst()));
+ Permission perm = perm1Map.get(p.getFirst());
+ Assert.assertEquals(perm, p.getSecond());
+ }
+ }
+
+ {
+ HashMap<String, Permission> perm2Map = new HashMap<String, Permission>();
+ for (Pair<String, Permission> p: perm2) {
+ perm2Map.put(p.getFirst(), p.getSecond());
+ }
+ for (Pair<String, Permission> p: perm1) {
+ Assert.assertTrue(perm2Map.containsKey(p.getFirst()));
+ Permission perm = perm2Map.get(p.getFirst());
+ Assert.assertEquals(perm, p.getSecond());
+ }
+ }
+ }
+
+ private void assertGroupPermissionsEqual(Project p1, Project p2) {
+ List<Pair<String, Permission>> perm1 = p1.getGroupPermissions();
+ List<Pair<String, Permission>> perm2 = p2.getGroupPermissions();
+
+ Assert.assertEquals(perm1.size(), perm2.size());
+
+ {
+ HashMap<String, Permission> perm1Map = new HashMap<String, Permission>();
+ for (Pair<String, Permission> p: perm1) {
+ perm1Map.put(p.getFirst(), p.getSecond());
+ }
+ for (Pair<String, Permission> p: perm2) {
+ Assert.assertTrue(perm1Map.containsKey(p.getFirst()));
+ Permission perm = perm1Map.get(p.getFirst());
+ Assert.assertEquals(perm, p.getSecond());
+ }
+ }
+
+ {
+ HashMap<String, Permission> perm2Map = new HashMap<String, Permission>();
+ for (Pair<String, Permission> p: perm2) {
+ perm2Map.put(p.getFirst(), p.getSecond());
+ }
+ for (Pair<String, Permission> p: perm1) {
+ Assert.assertTrue(perm2Map.containsKey(p.getFirst()));
+ Permission perm = perm2Map.get(p.getFirst());
+ Assert.assertEquals(perm, p.getSecond());
+ }
+ }
+ }
+
+ private ProjectLoader createLoader() {
+ Props props = new Props();
+ props.put("database.type", "mysql");
+
+ props.put("mysql.host", host);
+ props.put("mysql.port", port);
+ props.put("mysql.user", user);
+ props.put("mysql.database", database);
+ props.put("mysql.password", password);
+ props.put("mysql.numconnections", numConnections);
+
+ return new JdbcProjectLoader(props);
+ }
+
+ private boolean isTestSetup() {
+ if (!testDBExists) {
+ System.err.println("Skipping DB test because Db not setup.");
+ return false;
+ }
+
+ System.out.println("Running DB test because Db setup.");
+ return true;
+ }
+
+ public static class CountHandler implements ResultSetHandler<Integer> {
+ @Override
+ public Integer handle(ResultSet rs) throws SQLException {
+ int val = 0;
+ while (rs.next()) {
+ val++;
+ }
+
+ return val;
+ }
+ }
+}
\ No newline at end of file
diff --git a/unit/java/azkaban/test/project/ProjectTest.java b/unit/java/azkaban/test/project/ProjectTest.java
index b2c15d6..c4021c0 100644
--- a/unit/java/azkaban/test/project/ProjectTest.java
+++ b/unit/java/azkaban/test/project/ProjectTest.java
@@ -12,7 +12,7 @@ import azkaban.utils.JSONUtils;
public class ProjectTest {
@Test
public void testToAndFromObject() throws Exception {
- Project project = new Project("tesTing");
+ Project project = new Project(1, "tesTing");
project.setCreateTimestamp(1l);
project.setLastModifiedTimestamp(2l);
project.setDescription("I am a test");
diff --git a/unit/java/azkaban/test/user/PermissionTest.java b/unit/java/azkaban/test/user/PermissionTest.java
index 0350379..d5f0675 100644
--- a/unit/java/azkaban/test/user/PermissionTest.java
+++ b/unit/java/azkaban/test/user/PermissionTest.java
@@ -81,6 +81,20 @@ public class PermissionTest {
assertTrue(permission.equals(permission2));
}
+ @Test
+ public void testFlags() throws Exception {
+ Permission permission = new Permission();
+ permission.addPermission(new Type[]{Type.READ, Type.WRITE});
+
+ int flags = permission.toFlags();
+ Permission permission2 = new Permission(flags);
+
+ assertTrue(permission2.isPermissionSet(Type.READ));
+ assertTrue(permission2.isPermissionSet(Type.WRITE));
+
+ assertTrue(permission.equals(permission2));
+ }
+
/**
* Why? because it's quicker.
* @param message
diff --git a/unit/java/azkaban/test/utils/DirectoryFlowLoaderTest.java b/unit/java/azkaban/test/utils/DirectoryFlowLoaderTest.java
new file mode 100644
index 0000000..4316c5c
--- /dev/null
+++ b/unit/java/azkaban/test/utils/DirectoryFlowLoaderTest.java
@@ -0,0 +1,21 @@
+package azkaban.test.utils;
+
+import java.io.File;
+
+import org.apache.log4j.Logger;
+import org.junit.Test;
+
+import azkaban.utils.DirectoryFlowLoader;
+
+public class DirectoryFlowLoaderTest {
+
+ @Test
+ public void testDirectoryLoad() {
+ Logger logger = Logger.getLogger(this.getClass());
+ DirectoryFlowLoader loader = new DirectoryFlowLoader(logger);
+
+ loader.loadProjectFlow(new File("unit/executions/exectest1"));
+ logger.info(loader.getFlowMap().size());
+ }
+
+}
unit/java/azkaban/test/utils/FileIOUtilsTest.java 118(+118 -0)
diff --git a/unit/java/azkaban/test/utils/FileIOUtilsTest.java b/unit/java/azkaban/test/utils/FileIOUtilsTest.java
new file mode 100644
index 0000000..241162e
--- /dev/null
+++ b/unit/java/azkaban/test/utils/FileIOUtilsTest.java
@@ -0,0 +1,118 @@
+package azkaban.test.utils;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+import junit.framework.Assert;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import azkaban.utils.FileIOUtils;
+import azkaban.utils.Pair;
+
+public class FileIOUtilsTest {
+ File sourceDir = new File("unit/project/testjob");
+ File destDir = new File("unit/executions/unixsymlink");
+
+ @Before
+ public void setUp() throws Exception {
+ if (destDir.exists()) {
+ FileUtils.deleteDirectory(destDir);
+ }
+ destDir.mkdirs();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testSymlinkCopy() throws IOException {
+ FileIOUtils.createDeepSymlink(sourceDir, destDir);
+ }
+
+ @Test
+ public void testSymlinkCopyNonSource() {
+ boolean exception = false;
+ try {
+ FileIOUtils.createDeepSymlink(new File(sourceDir, "idonotexist"), destDir);
+ } catch (IOException e) {
+ System.out.println(e.getMessage());
+ System.out.println("Handled this case nicely.");
+ exception = true;
+ }
+
+ Assert.assertTrue(exception);
+ }
+
+ @Test
+ public void testAsciiUTF() throws IOException {
+ String foreignText = "abcdefghijklmnopqrstuvwxyz";
+ byte[] utf8ByteArray = createUTF8ByteArray(foreignText);
+
+ int length = utf8ByteArray.length;
+ System.out.println("char length:" + foreignText.length() + " utf8BytesLength:" + utf8ByteArray.length + " for:" + foreignText);
+
+ Pair<Integer,Integer> pair = FileIOUtils.getUtf8Range(utf8ByteArray, 1, length - 6);
+ System.out.println("Pair :" + pair.toString());
+
+ String recreatedString = new String(utf8ByteArray, 1, length - 6, "UTF-8");
+ System.out.println("recreatedString:" + recreatedString);
+
+ String correctString = new String(utf8ByteArray, pair.getFirst(), pair.getSecond(), "UTF-8");
+ System.out.println("correctString:" + correctString);
+
+ Assert.assertEquals(pair, new Pair<Integer,Integer>(1, 20));
+ // Two characters stripped from this.
+ Assert.assertEquals(correctString.length(), foreignText.length() - 6);
+
+ }
+
+ @Test
+ public void testForeignUTF() throws IOException {
+ String foreignText = "안녕하세요, 제 이름은 박병호입니다";
+ byte[] utf8ByteArray = createUTF8ByteArray(foreignText);
+
+ int length = utf8ByteArray.length;
+ System.out.println("char length:" + foreignText.length() + " utf8BytesLength:" + utf8ByteArray.length + " for:" + foreignText);
+
+ Pair<Integer,Integer> pair = FileIOUtils.getUtf8Range(utf8ByteArray, 1, length - 6);
+ System.out.println("Pair :" + pair.toString());
+
+ String recreatedString = new String(utf8ByteArray, 1, length - 6, "UTF-8");
+ System.out.println("recreatedString:" + recreatedString);
+
+ String correctString = new String(utf8ByteArray, pair.getFirst(), pair.getSecond(), "UTF-8");
+ System.out.println("correctString:" + correctString);
+
+ Assert.assertEquals(pair, new Pair<Integer,Integer>(3, 40));
+ // Two characters stripped from this.
+ Assert.assertEquals(correctString.length(), foreignText.length() - 3);
+
+
+ // Testing mixed bytes
+ String mixedText = "abc안녕하세요, 제 이름은 박병호입니다";
+ byte[] mixedBytes = createUTF8ByteArray(mixedText);
+ Pair<Integer,Integer> pair2 = FileIOUtils.getUtf8Range(mixedBytes, 1, length - 4);
+ correctString = new String(mixedBytes, pair2.getFirst(), pair2.getSecond(), "UTF-8");
+ System.out.println("correctString:" + correctString);
+ Assert.assertEquals(pair2, new Pair<Integer,Integer>(1, 45));
+ // Two characters stripped from this.
+ Assert.assertEquals(correctString.length(), mixedText.length() - 3);
+
+ }
+
+ private byte[] createUTF8ByteArray(String text) {
+ byte[] textBytes= null;
+ try {
+ textBytes = text.getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ return textBytes;
+ }
+}
\ No newline at end of file
diff --git a/unit/project/testflow/flowTestWithError.zip b/unit/project/testflow/flowTestWithError.zip
new file mode 100644
index 0000000..e84cfc7
Binary files /dev/null and b/unit/project/testflow/flowTestWithError.zip differ
unit/project/testflow/testFlow.zip 0(+0 -0)
diff --git a/unit/project/testflow/testFlow.zip b/unit/project/testflow/testFlow.zip
new file mode 100644
index 0000000..24ac866
Binary files /dev/null and b/unit/project/testflow/testFlow.zip differ
diff --git a/unit/project/testjob/expanded/fail-job.job b/unit/project/testjob/expanded/fail-job.job
new file mode 100644
index 0000000..fdc1050
--- /dev/null
+++ b/unit/project/testjob/expanded/fail-job.job
@@ -0,0 +1,2 @@
+type=java
+job.class=azkaban.jobbies.FailJob
\ No newline at end of file
diff --git a/unit/project/testjob/expanded/push-job.job b/unit/project/testjob/expanded/push-job.job
new file mode 100644
index 0000000..5431788
--- /dev/null
+++ b/unit/project/testjob/expanded/push-job.job
@@ -0,0 +1,5 @@
+type=propertyPusher
+
+prop-dependency=test-job-2
+
+dependencies=fail-job,test-job
\ No newline at end of file
diff --git a/unit/project/testjob/expanded/test-job.job b/unit/project/testjob/expanded/test-job.job
new file mode 100644
index 0000000..a291465
--- /dev/null
+++ b/unit/project/testjob/expanded/test-job.job
@@ -0,0 +1,2 @@
+type=java
+job.class=azkaban.jobbies.TestJob
\ No newline at end of file
diff --git a/unit/project/testjob/expanded/test-job-2.job b/unit/project/testjob/expanded/test-job-2.job
new file mode 100644
index 0000000..fcea87d
--- /dev/null
+++ b/unit/project/testjob/expanded/test-job-2.job
@@ -0,0 +1,4 @@
+type=java
+job.class=azkaban.jobbies.TestJob
+
+pass-on.howdy="hi"
\ No newline at end of file
unit/project/testjob/testjob.zip 0(+0 -0)
diff --git a/unit/project/testjob/testjob.zip b/unit/project/testjob/testjob.zip
new file mode 100644
index 0000000..5b46b6d
Binary files /dev/null and b/unit/project/testjob/testjob.zip differ
unit/project/testjob/testjob-med.zip 0(+0 -0)
diff --git a/unit/project/testjob/testjob-med.zip b/unit/project/testjob/testjob-med.zip
new file mode 100644
index 0000000..5b46b6d
Binary files /dev/null and b/unit/project/testjob/testjob-med.zip differ