Merging in Hrebejk's contribution: Development Environment for Web. Thanks.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/dew/nbactions.xml Wed Jan 23 14:16:13 2013 +0100
1.3 @@ -0,0 +1,56 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +<!--
1.6 +
1.7 + Back 2 Browser Bytecode Translator
1.8 + Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
1.9 +
1.10 + This program is free software: you can redistribute it and/or modify
1.11 + it under the terms of the GNU General Public License as published by
1.12 + the Free Software Foundation, version 2 of the License.
1.13 +
1.14 + This program is distributed in the hope that it will be useful,
1.15 + but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + GNU General Public License for more details.
1.18 +
1.19 + You should have received a copy of the GNU General Public License
1.20 + along with this program. Look for COPYING file in the top folder.
1.21 + If not, see http://opensource.org/licenses/GPL-2.0.
1.22 +
1.23 +-->
1.24 +<actions>
1.25 + <action>
1.26 + <actionName>run</actionName>
1.27 + <goals>
1.28 + <goal>process-classes</goal>
1.29 + <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
1.30 + </goals>
1.31 + <properties>
1.32 + <exec.args>-classpath %classpath org.apidesign.bck2brwsr.dew.Dew</exec.args>
1.33 + <exec.executable>java</exec.executable>
1.34 + </properties>
1.35 + </action>
1.36 + <action>
1.37 + <actionName>debug</actionName>
1.38 + <goals>
1.39 + <goal>process-classes</goal>
1.40 + <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
1.41 + </goals>
1.42 + <properties>
1.43 + <exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath org.apidesign.bck2brwsr.dew.Dew</exec.args>
1.44 + <exec.executable>java</exec.executable>
1.45 + <jpda.listen>true</jpda.listen>
1.46 + </properties>
1.47 + </action>
1.48 + <action>
1.49 + <actionName>profile</actionName>
1.50 + <goals>
1.51 + <goal>process-classes</goal>
1.52 + <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
1.53 + </goals>
1.54 + <properties>
1.55 + <exec.args>${profiler.args} -classpath %classpath org.apidesign.bck2brwsr.dew.Dew</exec.args>
1.56 + <exec.executable>${profiler.java}</exec.executable>
1.57 + </properties>
1.58 + </action>
1.59 + </actions>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/dew/pom.xml Wed Jan 23 14:16:13 2013 +0100
2.3 @@ -0,0 +1,64 @@
2.4 +<?xml version="1.0"?>
2.5 +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
2.6 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2.7 + <modelVersion>4.0.0</modelVersion>
2.8 + <parent>
2.9 + <groupId>org.apidesign</groupId>
2.10 + <artifactId>bck2brwsr</artifactId>
2.11 + <version>0.3-SNAPSHOT</version>
2.12 + </parent>
2.13 + <groupId>org.apidesign.bck2brwsr</groupId>
2.14 + <artifactId>dew</artifactId>
2.15 + <version>0.3-SNAPSHOT</version>
2.16 + <name>Development Environment for Web</name>
2.17 + <url>http://maven.apache.org</url>
2.18 + <build>
2.19 + <plugins>
2.20 + <plugin>
2.21 + <groupId>org.apache.maven.plugins</groupId>
2.22 + <artifactId>maven-compiler-plugin</artifactId>
2.23 + <version>2.3.2</version>
2.24 + <configuration>
2.25 + <source>1.7</source>
2.26 + <target>1.7</target>
2.27 + </configuration>
2.28 + </plugin>
2.29 + </plugins>
2.30 + </build>
2.31 + <properties>
2.32 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2.33 + </properties>
2.34 + <dependencies>
2.35 + <dependency>
2.36 + <groupId>org.glassfish.grizzly</groupId>
2.37 + <artifactId>grizzly-http-server</artifactId>
2.38 + <version>2.2.19</version>
2.39 + </dependency>
2.40 + <dependency>
2.41 + <groupId>${project.groupId}</groupId>
2.42 + <artifactId>vm4brwsr</artifactId>
2.43 + <version>${project.version}</version>
2.44 + </dependency>
2.45 + <dependency>
2.46 + <groupId>org.json</groupId>
2.47 + <artifactId>json</artifactId>
2.48 + <version>20090211</version>
2.49 + </dependency>
2.50 + <dependency>
2.51 + <groupId>org.testng</groupId>
2.52 + <artifactId>testng</artifactId>
2.53 + <scope>test</scope>
2.54 + <exclusions>
2.55 + <exclusion>
2.56 + <artifactId>junit</artifactId>
2.57 + <groupId>junit</groupId>
2.58 + </exclusion>
2.59 + </exclusions>
2.60 + </dependency>
2.61 + <dependency>
2.62 + <groupId>${project.groupId}</groupId>
2.63 + <artifactId>javaquery.api</artifactId>
2.64 + <version>${project.version}</version>
2.65 + </dependency>
2.66 + </dependencies>
2.67 +</project>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/dew/src/main/java/org/apidesign/bck2brwsr/dew/Compile.java Wed Jan 23 14:16:13 2013 +0100
3.3 @@ -0,0 +1,196 @@
3.4 +/**
3.5 + * Back 2 Browser Bytecode Translator
3.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
3.7 + *
3.8 + * This program is free software: you can redistribute it and/or modify
3.9 + * it under the terms of the GNU General Public License as published by
3.10 + * the Free Software Foundation, version 2 of the License.
3.11 + *
3.12 + * This program is distributed in the hope that it will be useful,
3.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.15 + * GNU General Public License for more details.
3.16 + *
3.17 + * You should have received a copy of the GNU General Public License
3.18 + * along with this program. Look for COPYING file in the top folder.
3.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
3.20 + */
3.21 +package org.apidesign.bck2brwsr.dew;
3.22 +
3.23 +import java.io.ByteArrayInputStream;
3.24 +import java.io.ByteArrayOutputStream;
3.25 +import java.io.IOException;
3.26 +import java.io.InputStream;
3.27 +import java.io.OutputStream;
3.28 +import java.net.URI;
3.29 +import java.net.URISyntaxException;
3.30 +import java.util.ArrayList;
3.31 +import java.util.Arrays;
3.32 +import java.util.HashMap;
3.33 +import java.util.List;
3.34 +import java.util.Map;
3.35 +import java.util.regex.Matcher;
3.36 +import java.util.regex.Pattern;
3.37 +import javax.tools.Diagnostic;
3.38 +import javax.tools.DiagnosticListener;
3.39 +import javax.tools.FileObject;
3.40 +import javax.tools.ForwardingJavaFileManager;
3.41 +import javax.tools.JavaFileManager;
3.42 +import javax.tools.JavaFileObject;
3.43 +import javax.tools.JavaFileObject.Kind;
3.44 +import javax.tools.SimpleJavaFileObject;
3.45 +import javax.tools.StandardJavaFileManager;
3.46 +import javax.tools.StandardLocation;
3.47 +import javax.tools.ToolProvider;
3.48 +
3.49 +/**
3.50 + *
3.51 + * @author Jaroslav Tulach <jtulach@netbeans.org>
3.52 + */
3.53 +final class Compile implements DiagnosticListener<JavaFileObject> {
3.54 + private final List<Diagnostic<? extends JavaFileObject>> errors = new ArrayList<>();
3.55 + private final Map<String, byte[]> classes;
3.56 + private final String pkg;
3.57 + private final String cls;
3.58 +
3.59 + private Compile(String html, String code) throws IOException {
3.60 + this.pkg = findPkg(code);
3.61 + this.cls = findCls(code);
3.62 + classes = compile(html, code);
3.63 + }
3.64 +
3.65 + /** Performs compilation of given HTML page and associated Java code
3.66 + */
3.67 + public static Compile create(String html, String code) throws IOException {
3.68 + return new Compile(html, code);
3.69 + }
3.70 +
3.71 + /** Checks for given class among compiled resources */
3.72 + public byte[] get(String res) {
3.73 + return classes.get(res);
3.74 + }
3.75 +
3.76 + /** Obtains errors created during compilation.
3.77 + */
3.78 + public List<Diagnostic<? extends JavaFileObject>> getErrors() {
3.79 + List<Diagnostic<? extends JavaFileObject>> err = new ArrayList<>();
3.80 + for (Diagnostic<? extends JavaFileObject> diagnostic : errors) {
3.81 + if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
3.82 + err.add(diagnostic);
3.83 + }
3.84 + }
3.85 + return err;
3.86 + }
3.87 +
3.88 + private Map<String, byte[]> compile(final String html, final String code) throws IOException {
3.89 + StandardJavaFileManager sjfm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(this, null, null);
3.90 +
3.91 + final Map<String, ByteArrayOutputStream> class2BAOS = new HashMap<>();
3.92 +
3.93 + JavaFileObject file = new SimpleJavaFileObject(URI.create("mem://mem"), Kind.SOURCE) {
3.94 + @Override
3.95 + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
3.96 + return code;
3.97 + }
3.98 + };
3.99 + final JavaFileObject htmlFile = new SimpleJavaFileObject(URI.create("mem://mem2"), Kind.OTHER) {
3.100 + @Override
3.101 + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
3.102 + return html;
3.103 + }
3.104 +
3.105 + @Override
3.106 + public InputStream openInputStream() throws IOException {
3.107 + return new ByteArrayInputStream(html.getBytes());
3.108 + }
3.109 + };
3.110 +
3.111 + final URI scratch;
3.112 + try {
3.113 + scratch = new URI("mem://mem3");
3.114 + } catch (URISyntaxException ex) {
3.115 + throw new IOException(ex);
3.116 + }
3.117 +
3.118 + JavaFileManager jfm = new ForwardingJavaFileManager<JavaFileManager>(sjfm) {
3.119 + @Override
3.120 + public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) throws IOException {
3.121 + if (kind == Kind.CLASS) {
3.122 + final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
3.123 +
3.124 + class2BAOS.put(className.replace('.', '/') + ".class", buffer);
3.125 + return new SimpleJavaFileObject(sibling.toUri(), kind) {
3.126 + @Override
3.127 + public OutputStream openOutputStream() throws IOException {
3.128 + return buffer;
3.129 + }
3.130 + };
3.131 + }
3.132 +
3.133 + if (kind == Kind.SOURCE) {
3.134 + return new SimpleJavaFileObject(scratch/*sibling.toUri()*/, kind) {
3.135 + private final ByteArrayOutputStream data = new ByteArrayOutputStream();
3.136 + @Override
3.137 + public OutputStream openOutputStream() throws IOException {
3.138 + return data;
3.139 + }
3.140 +
3.141 + @Override
3.142 + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
3.143 + data.close();
3.144 + return new String(data.toByteArray());
3.145 + }
3.146 + };
3.147 + }
3.148 +
3.149 + throw new IllegalStateException();
3.150 + }
3.151 +
3.152 + @Override
3.153 + public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException {
3.154 + if (location == StandardLocation.SOURCE_PATH) {
3.155 + if (packageName.equals(pkg)) {
3.156 + return htmlFile;
3.157 + }
3.158 + }
3.159 +
3.160 + return null;
3.161 + }
3.162 +
3.163 + };
3.164 +
3.165 + ToolProvider.getSystemJavaCompiler().getTask(null, jfm, this, /*XXX:*/Arrays.asList("-source", "1.7", "-target", "1.7"), null, Arrays.asList(file)).call();
3.166 +
3.167 + Map<String, byte[]> result = new HashMap<>();
3.168 +
3.169 + for (Map.Entry<String, ByteArrayOutputStream> e : class2BAOS.entrySet()) {
3.170 + result.put(e.getKey(), e.getValue().toByteArray());
3.171 + }
3.172 +
3.173 + return result;
3.174 + }
3.175 +
3.176 +
3.177 + @Override
3.178 + public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
3.179 + errors.add(diagnostic);
3.180 + }
3.181 + private static String findPkg(String java) throws IOException {
3.182 + Pattern p = Pattern.compile("package\\p{javaWhitespace}*([\\p{Alnum}\\.]+)\\p{javaWhitespace}*;", Pattern.MULTILINE);
3.183 + Matcher m = p.matcher(java);
3.184 + if (!m.find()) {
3.185 + throw new IOException("Can't find package declaration in the java file");
3.186 + }
3.187 + String pkg = m.group(1);
3.188 + return pkg;
3.189 + }
3.190 + private static String findCls(String java) throws IOException {
3.191 + Pattern p = Pattern.compile("class\\p{javaWhitespace}*([\\p{Alnum}\\.]+)\\p{javaWhitespace}", Pattern.MULTILINE);
3.192 + Matcher m = p.matcher(java);
3.193 + if (!m.find()) {
3.194 + throw new IOException("Can't find package declaration in the java file");
3.195 + }
3.196 + String cls = m.group(1);
3.197 + return cls;
3.198 + }
3.199 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/dew/src/main/java/org/apidesign/bck2brwsr/dew/Dew.java Wed Jan 23 14:16:13 2013 +0100
4.3 @@ -0,0 +1,138 @@
4.4 +/**
4.5 + * Back 2 Browser Bytecode Translator
4.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
4.7 + *
4.8 + * This program is free software: you can redistribute it and/or modify
4.9 + * it under the terms of the GNU General Public License as published by
4.10 + * the Free Software Foundation, version 2 of the License.
4.11 + *
4.12 + * This program is distributed in the hope that it will be useful,
4.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.15 + * GNU General Public License for more details.
4.16 + *
4.17 + * You should have received a copy of the GNU General Public License
4.18 + * along with this program. Look for COPYING file in the top folder.
4.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
4.20 + */
4.21 +package org.apidesign.bck2brwsr.dew;
4.22 +
4.23 +import java.io.ByteArrayInputStream;
4.24 +import java.io.IOException;
4.25 +import java.io.InputStream;
4.26 +import java.io.InputStreamReader;
4.27 +import java.io.OutputStream;
4.28 +import java.util.List;
4.29 +import java.util.Locale;
4.30 +import javax.tools.Diagnostic;
4.31 +import javax.tools.JavaFileObject;
4.32 +import org.apidesign.vm4brwsr.Bck2Brwsr;
4.33 +import org.glassfish.grizzly.http.Method;
4.34 +import org.glassfish.grizzly.http.server.HttpHandler;
4.35 +import org.glassfish.grizzly.http.server.HttpServer;
4.36 +import org.glassfish.grizzly.http.server.Request;
4.37 +import org.glassfish.grizzly.http.server.Response;
4.38 +import org.glassfish.grizzly.http.util.HttpStatus;
4.39 +import org.json.JSONArray;
4.40 +import org.json.JSONObject;
4.41 +import org.json.JSONTokener;
4.42 +
4.43 +/**
4.44 + *
4.45 + * @author phrebejk
4.46 + */
4.47 +final class Dew extends HttpHandler implements Bck2Brwsr.Resources {
4.48 + private String html = "";
4.49 + private Compile data;
4.50 +
4.51 + public static void main(String... args) throws Exception {
4.52 + DewLauncher l = new DewLauncher(null);
4.53 + l.addClassLoader(DewLauncher.class.getClassLoader());
4.54 + final Dew dew = new Dew();
4.55 + HttpServer s = l.initServer(dew);
4.56 + s.getServerConfiguration().addHttpHandler(dew, "/dew/");
4.57 + l.launchServerAndBrwsr(s, "/dew/");
4.58 + System.in.read();
4.59 + }
4.60 +
4.61 + @Override
4.62 + public void service(Request request, Response response) throws Exception {
4.63 +
4.64 + if ( request.getMethod() == Method.POST ) {
4.65 + InputStream is = request.getInputStream();
4.66 + JSONTokener tok = new JSONTokener(new InputStreamReader(is));
4.67 + JSONObject obj = new JSONObject(tok);
4.68 + String tmpHtml = obj.getString("html");
4.69 + String tmpJava = obj.getString("java");
4.70 +
4.71 + Compile res = Compile.create(tmpHtml, tmpJava);
4.72 + List<Diagnostic<? extends JavaFileObject>> err = res.getErrors();
4.73 + if (err.isEmpty()) {
4.74 + data = res;
4.75 + html = tmpHtml;
4.76 + response.getOutputStream().write("[]".getBytes());
4.77 + response.setStatus(HttpStatus.OK_200);
4.78 + } else {
4.79 +
4.80 + JSONArray errors = new JSONArray();
4.81 +
4.82 + for (Diagnostic<? extends JavaFileObject> d : err) {
4.83 + JSONObject e = new JSONObject();
4.84 + e.put("col", d.getColumnNumber());
4.85 + e.put("line", d.getLineNumber());
4.86 + e.put("kind", d.getKind().toString());
4.87 + e.put("msg", d.getMessage(Locale.ENGLISH));
4.88 + errors.put(e);
4.89 + }
4.90 +
4.91 + errors.write(response.getWriter());
4.92 + response.setStatus(HttpStatus.PRECONDITION_FAILED_412);
4.93 + }
4.94 +
4.95 + return;
4.96 + }
4.97 +
4.98 + String r = request.getHttpHandlerPath();
4.99 + if (r == null || r.equals("/")) {
4.100 + r = "index.html";
4.101 + }
4.102 + if (r.equals("/result.html")) {
4.103 + response.setContentType("text/html");
4.104 + response.getOutputBuffer().write(html);
4.105 + response.setStatus(HttpStatus.OK_200);
4.106 + return;
4.107 + }
4.108 +
4.109 + if (r.startsWith("/")) {
4.110 + r = r.substring(1);
4.111 + }
4.112 +
4.113 + if (r.endsWith(".html") || r.endsWith(".xhtml")) {
4.114 + response.setContentType("text/html");
4.115 + }
4.116 + OutputStream os = response.getOutputStream();
4.117 + try (InputStream is = Dew.class.getResourceAsStream(r) ) {
4.118 + copyStream(is, os, request.getRequestURL().toString() );
4.119 + } catch (IOException ex) {
4.120 + response.setDetailMessage(ex.getLocalizedMessage());
4.121 + response.setError();
4.122 + response.setStatus(404);
4.123 + }
4.124 + }
4.125 +
4.126 + static void copyStream(InputStream is, OutputStream os, String baseURL) throws IOException {
4.127 + for (;;) {
4.128 + int ch = is.read();
4.129 + if (ch == -1) {
4.130 + break;
4.131 + }
4.132 + os.write(ch);
4.133 + }
4.134 + }
4.135 +
4.136 + @Override
4.137 + public InputStream get(String r) throws IOException {
4.138 + byte[] arr = data == null ? null : data.get(r);
4.139 + return arr == null ? null : new ByteArrayInputStream(arr);
4.140 + }
4.141 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/dew/src/main/java/org/apidesign/bck2brwsr/dew/DewLauncher.java Wed Jan 23 14:16:13 2013 +0100
5.3 @@ -0,0 +1,201 @@
5.4 +/**
5.5 + * Back 2 Browser Bytecode Translator
5.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5.7 + *
5.8 + * This program is free software: you can redistribute it and/or modify
5.9 + * it under the terms of the GNU General Public License as published by
5.10 + * the Free Software Foundation, version 2 of the License.
5.11 + *
5.12 + * This program is distributed in the hope that it will be useful,
5.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.15 + * GNU General Public License for more details.
5.16 + *
5.17 + * You should have received a copy of the GNU General Public License
5.18 + * along with this program. Look for COPYING file in the top folder.
5.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
5.20 + */
5.21 +package org.apidesign.bck2brwsr.dew;
5.22 +
5.23 +import java.io.IOException;
5.24 +import java.io.InputStream;
5.25 +import java.io.Writer;
5.26 +import java.net.URI;
5.27 +import java.net.URISyntaxException;
5.28 +import java.net.URL;
5.29 +import java.util.Arrays;
5.30 +import java.util.Enumeration;
5.31 +import java.util.LinkedHashSet;
5.32 +import java.util.Set;
5.33 +import java.util.logging.Level;
5.34 +import java.util.logging.Logger;
5.35 +import org.apidesign.vm4brwsr.Bck2Brwsr;
5.36 +import org.glassfish.grizzly.PortRange;
5.37 +import org.glassfish.grizzly.http.server.HttpHandler;
5.38 +import org.glassfish.grizzly.http.server.HttpServer;
5.39 +import org.glassfish.grizzly.http.server.NetworkListener;
5.40 +import org.glassfish.grizzly.http.server.Request;
5.41 +import org.glassfish.grizzly.http.server.Response;
5.42 +import org.glassfish.grizzly.http.server.ServerConfiguration;
5.43 +
5.44 +/**
5.45 + * Lightweight server to launch dew - the Development Environment for Web.
5.46 + */
5.47 +final class DewLauncher {
5.48 + private static final Logger LOG = Logger.getLogger(DewLauncher.class.getName());
5.49 + private Set<ClassLoader> loaders = new LinkedHashSet<>();
5.50 + private Set<Bck2Brwsr.Resources> xRes = new LinkedHashSet<>();
5.51 + private final Res resources = new Res();
5.52 + private final String cmd;
5.53 +
5.54 + public DewLauncher(String cmd) {
5.55 + this.cmd = cmd;
5.56 + }
5.57 +
5.58 + public void addClassLoader(ClassLoader url) {
5.59 + this.loaders.add(url);
5.60 + }
5.61 +
5.62 + final HttpServer initServer(Bck2Brwsr.Resources... extraResources) {
5.63 + xRes.addAll(Arrays.asList(extraResources));
5.64 +
5.65 + HttpServer s = HttpServer.createSimpleServer(".", new PortRange(8080, 65535));
5.66 +
5.67 + final ServerConfiguration conf = s.getServerConfiguration();
5.68 + conf.addHttpHandler(new VM(resources), "/bck2brwsr.js");
5.69 + conf.addHttpHandler(new VMInit(), "/vm.js");
5.70 + conf.addHttpHandler(new Classes(resources), "/classes/");
5.71 + return s;
5.72 + }
5.73 +
5.74 + final Object[] launchServerAndBrwsr(HttpServer server, final String page) throws IOException, URISyntaxException, InterruptedException {
5.75 + server.start();
5.76 + NetworkListener listener = server.getListeners().iterator().next();
5.77 + int port = listener.getPort();
5.78 +
5.79 + URI uri = new URI("http://localhost:" + port + page);
5.80 + LOG.log(Level.INFO, "Showing {0}", uri);
5.81 + if (cmd == null) {
5.82 + try {
5.83 + LOG.log(Level.INFO, "Trying Desktop.browse on {0} {2} by {1}", new Object[] {
5.84 + System.getProperty("java.vm.name"),
5.85 + System.getProperty("java.vm.vendor"),
5.86 + System.getProperty("java.vm.version"),
5.87 + });
5.88 + java.awt.Desktop.getDesktop().browse(uri);
5.89 + LOG.log(Level.INFO, "Desktop.browse successfully finished");
5.90 + return null;
5.91 + } catch (UnsupportedOperationException ex) {
5.92 + LOG.log(Level.INFO, "Desktop.browse not supported: {0}", ex.getMessage());
5.93 + LOG.log(Level.FINE, null, ex);
5.94 + }
5.95 + }
5.96 + {
5.97 + String cmdName = cmd == null ? "xdg-open" : cmd;
5.98 + String[] cmdArr = {
5.99 + cmdName, uri.toString()
5.100 + };
5.101 + LOG.log(Level.INFO, "Launching {0}", Arrays.toString(cmdArr));
5.102 + final Process process = Runtime.getRuntime().exec(cmdArr);
5.103 + return new Object[] { process, null };
5.104 + }
5.105 + }
5.106 +
5.107 + private class Res implements Bck2Brwsr.Resources {
5.108 + @Override
5.109 + public InputStream get(String resource) throws IOException {
5.110 + for (ClassLoader l : loaders) {
5.111 + URL u = null;
5.112 + Enumeration<URL> en = l.getResources(resource);
5.113 + while (en.hasMoreElements()) {
5.114 + u = en.nextElement();
5.115 + }
5.116 + if (u != null) {
5.117 + return u.openStream();
5.118 + }
5.119 + }
5.120 + for (Bck2Brwsr.Resources r : xRes) {
5.121 + InputStream is = r.get(resource);
5.122 + if (is != null) {
5.123 + return is;
5.124 + }
5.125 + }
5.126 + throw new IOException("Can't find " + resource);
5.127 + }
5.128 + }
5.129 +
5.130 + private static class VM extends HttpHandler {
5.131 + private final Res loader;
5.132 +
5.133 + public VM(Res loader) {
5.134 + this.loader = loader;
5.135 + }
5.136 +
5.137 + @Override
5.138 + public void service(Request request, Response response) throws Exception {
5.139 + response.setCharacterEncoding("UTF-8");
5.140 + response.setContentType("text/javascript");
5.141 + Bck2Brwsr.generate(response.getWriter(), loader);
5.142 + }
5.143 + }
5.144 + private static class VMInit extends HttpHandler {
5.145 + public VMInit() {
5.146 + }
5.147 +
5.148 + @Override
5.149 + public void service(Request request, Response response) throws Exception {
5.150 + response.setCharacterEncoding("UTF-8");
5.151 + response.setContentType("text/javascript");
5.152 + response.getWriter().append(
5.153 + "function ldCls(res) {\n"
5.154 + + " var request = new XMLHttpRequest();\n"
5.155 + + " request.open('GET', '/classes/' + res, false);\n"
5.156 + + " request.send();\n"
5.157 + + " var arr = eval('(' + request.responseText + ')');\n"
5.158 + + " return arr;\n"
5.159 + + "}\n"
5.160 + + "var vm = new bck2brwsr(ldCls);\n");
5.161 + }
5.162 + }
5.163 +
5.164 + private static class Classes extends HttpHandler {
5.165 + private final Res loader;
5.166 +
5.167 + public Classes(Res loader) {
5.168 + this.loader = loader;
5.169 + }
5.170 +
5.171 + @Override
5.172 + public void service(Request request, Response response) throws Exception {
5.173 + String res = request.getHttpHandlerPath();
5.174 + if (res.startsWith("/")) {
5.175 + res = res.substring(1);
5.176 + }
5.177 + try (InputStream is = loader.get(res)) {
5.178 + response.setContentType("text/javascript");
5.179 + Writer w = response.getWriter();
5.180 + w.append("[");
5.181 + for (int i = 0;; i++) {
5.182 + int b = is.read();
5.183 + if (b == -1) {
5.184 + break;
5.185 + }
5.186 + if (i > 0) {
5.187 + w.append(", ");
5.188 + }
5.189 + if (i % 20 == 0) {
5.190 + w.write("\n");
5.191 + }
5.192 + if (b > 127) {
5.193 + b = b - 256;
5.194 + }
5.195 + w.append(Integer.toString(b));
5.196 + }
5.197 + w.append("\n]");
5.198 + } catch (IOException ex) {
5.199 + response.setError();
5.200 + response.setDetailMessage(ex.getMessage());
5.201 + }
5.202 + }
5.203 + }
5.204 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/dew/src/main/resources/org/apidesign/bck2brwsr/dew/css/app.css Wed Jan 23 14:16:13 2013 +0100
6.3 @@ -0,0 +1,54 @@
6.4 +/* app css stylesheet */
6.5 +.code-editor, .mono-font, .CodeMirror {
6.6 + font-family: "Inconsolata","Monaco","Consolas","Andale Mono","Bitstream Vera Sans Mono","Courier New",Courier,monospace;
6.7 + font-size: 13px;
6.8 + line-height: 15px;
6.9 +}
6.10 +
6.11 +.CodeMirror {
6.12 + border: 1px solid #d9edf7;
6.13 + height: 300px;
6.14 +}
6.15 +
6.16 +.CodeMirror-scroll {
6.17 + overflow-y: auto;
6.18 + overflow-x: auto;
6.19 +}
6.20 +
6.21 +.error-hover:hover {
6.22 + text-decoration: underline;
6.23 + cursor: pointer;
6.24 +}
6.25 +
6.26 +.ic-html5 {
6.27 + display: inline-block;
6.28 + height: 20px;
6.29 + width: 20px;
6.30 + vertical-align: text-bottom;
6.31 + background-repeat: no-repeat;
6.32 + background-image: url("../img/html5.png");
6.33 +}
6.34 +
6.35 +.ic-java {
6.36 + display: inline-block;
6.37 + height: 20px;
6.38 + width: 20px;
6.39 + vertical-align: text-bottom;
6.40 + background-repeat: no-repeat;
6.41 + background-image: url("../img/java.png");
6.42 +
6.43 +}
6.44 +
6.45 +.issues {
6.46 + width: 16px;
6.47 +}
6.48 +
6.49 +.issue {
6.50 + height: 16px;
6.51 + width: 16px;
6.52 + vertical-align: middle;
6.53 + background-repeat: no-repeat;
6.54 + background-image: url("../img/error.png");
6.55 + /* color: #822; */
6.56 +}
6.57 +
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/dew/src/main/resources/org/apidesign/bck2brwsr/dew/css/bootstrap-combined.min.css Wed Jan 23 14:16:13 2013 +0100
7.3 @@ -0,0 +1,18 @@
7.4 +/*!
7.5 + * Bootstrap v2.2.2
7.6 + *
7.7 + * Copyright 2012 Twitter, Inc
7.8 + * Licensed under the Apache License v2.0
7.9 + * http://www.apache.org/licenses/LICENSE-2.0
7.10 + *
7.11 + * Designed and built with all the love in the world @twitter by @mdo and @fat.
7.12 + */article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{width:auto\9;height:auto;max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img,.google-maps img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,html input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}label,select,button,input[type="button"],input[type="reset"],input[type="submit"],input[type="radio"],input[type="checkbox"]{cursor:pointer}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}@media print{*{color:#000!important;text-shadow:none!important;background:transparent!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:20px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover{color:#005580;text-decoration:underline}.img-rounded{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.img-polaroid{padding:4px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.1)}.img-circle{-webkit-border-radius:500px;-moz-border-radius:500px;border-radius:500px}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offset1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.127659574468085%;*margin-left:2.074468085106383%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.127659574468085%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.48936170212765%;*width:91.43617021276594%}.row-fluid .span10{width:82.97872340425532%;*width:82.92553191489361%}.row-fluid .span9{width:74.46808510638297%;*width:74.41489361702126%}.row-fluid .span8{width:65.95744680851064%;*width:65.90425531914893%}.row-fluid .span7{width:57.44680851063829%;*width:57.39361702127659%}.row-fluid .span6{width:48.93617021276595%;*width:48.88297872340425%}.row-fluid .span5{width:40.42553191489362%;*width:40.37234042553192%}.row-fluid .span4{width:31.914893617021278%;*width:31.861702127659576%}.row-fluid .span3{width:23.404255319148934%;*width:23.351063829787233%}.row-fluid .span2{width:14.893617021276595%;*width:14.840425531914894%}.row-fluid .span1{width:6.382978723404255%;*width:6.329787234042553%}.row-fluid .offset12{margin-left:104.25531914893617%;*margin-left:104.14893617021275%}.row-fluid .offset12:first-child{margin-left:102.12765957446808%;*margin-left:102.02127659574467%}.row-fluid .offset11{margin-left:95.74468085106382%;*margin-left:95.6382978723404%}.row-fluid .offset11:first-child{margin-left:93.61702127659574%;*margin-left:93.51063829787232%}.row-fluid .offset10{margin-left:87.23404255319149%;*margin-left:87.12765957446807%}.row-fluid .offset10:first-child{margin-left:85.1063829787234%;*margin-left:84.99999999999999%}.row-fluid .offset9{margin-left:78.72340425531914%;*margin-left:78.61702127659572%}.row-fluid .offset9:first-child{margin-left:76.59574468085106%;*margin-left:76.48936170212764%}.row-fluid .offset8{margin-left:70.2127659574468%;*margin-left:70.10638297872339%}.row-fluid .offset8:first-child{margin-left:68.08510638297872%;*margin-left:67.9787234042553%}.row-fluid .offset7{margin-left:61.70212765957446%;*margin-left:61.59574468085106%}.row-fluid .offset7:first-child{margin-left:59.574468085106375%;*margin-left:59.46808510638297%}.row-fluid .offset6{margin-left:53.191489361702125%;*margin-left:53.085106382978715%}.row-fluid .offset6:first-child{margin-left:51.063829787234035%;*margin-left:50.95744680851063%}.row-fluid .offset5{margin-left:44.68085106382979%;*margin-left:44.57446808510638%}.row-fluid .offset5:first-child{margin-left:42.5531914893617%;*margin-left:42.4468085106383%}.row-fluid .offset4{margin-left:36.170212765957444%;*margin-left:36.06382978723405%}.row-fluid .offset4:first-child{margin-left:34.04255319148936%;*margin-left:33.93617021276596%}.row-fluid .offset3{margin-left:27.659574468085104%;*margin-left:27.5531914893617%}.row-fluid .offset3:first-child{margin-left:25.53191489361702%;*margin-left:25.425531914893618%}.row-fluid .offset2{margin-left:19.148936170212764%;*margin-left:19.04255319148936%}.row-fluid .offset2:first-child{margin-left:17.02127659574468%;*margin-left:16.914893617021278%}.row-fluid .offset1{margin-left:10.638297872340425%;*margin-left:10.53191489361702%}.row-fluid .offset1:first-child{margin-left:8.51063829787234%;*margin-left:8.404255319148938%}[class*="span"].hide,.row-fluid [class*="span"].hide{display:none}[class*="span"].pull-right,.row-fluid [class*="span"].pull-right{float:right}.container{margin-right:auto;margin-left:auto;*zoom:1}.container:before,.container:after{display:table;line-height:0;content:""}.container:after{clear:both}.container-fluid{padding-right:20px;padding-left:20px;*zoom:1}.container-fluid:before,.container-fluid:after{display:table;line-height:0;content:""}.container-fluid:after{clear:both}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:21px;font-weight:200;line-height:30px}small{font-size:85%}strong{font-weight:bold}em{font-style:italic}cite{font-style:normal}.muted{color:#999}a.muted:hover{color:#808080}.text-warning{color:#c09853}a.text-warning:hover{color:#a47e3c}.text-error{color:#b94a48}a.text-error:hover{color:#953b39}.text-info{color:#3a87ad}a.text-info:hover{color:#2d6987}.text-success{color:#468847}a.text-success:hover{color:#356635}h1,h2,h3,h4,h5,h6{margin:10px 0;font-family:inherit;font-weight:bold;line-height:20px;color:inherit;text-rendering:optimizelegibility}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;line-height:1;color:#999}h1,h2,h3{line-height:40px}h1{font-size:38.5px}h2{font-size:31.5px}h3{font-size:24.5px}h4{font-size:17.5px}h5{font-size:14px}h6{font-size:11.9px}h1 small{font-size:24.5px}h2 small{font-size:17.5px}h3 small{font-size:14px}h4 small{font-size:14px}.page-header{padding-bottom:9px;margin:20px 0 30px;border-bottom:1px solid #eee}ul,ol{padding:0;margin:0 0 10px 25px}ul ul,ul ol,ol ol,ol ul{margin-bottom:0}li{line-height:20px}ul.unstyled,ol.unstyled{margin-left:0;list-style:none}ul.inline,ol.inline{margin-left:0;list-style:none}ul.inline>li,ol.inline>li{display:inline-block;padding-right:5px;padding-left:5px}dl{margin-bottom:20px}dt,dd{line-height:20px}dt{font-weight:bold}dd{margin-left:10px}.dl-horizontal{*zoom:1}.dl-horizontal:before,.dl-horizontal:after{display:table;line-height:0;content:""}.dl-horizontal:after{clear:both}.dl-horizontal dt{float:left;width:160px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}hr{margin:20px 0;border:0;border-top:1px solid #eee;border-bottom:1px solid #fff}abbr[title],abbr[data-original-title]{cursor:help;border-bottom:1px dotted #999}abbr.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:0 0 0 15px;margin:0 0 20px;border-left:5px solid #eee}blockquote p{margin-bottom:0;font-size:16px;font-weight:300;line-height:25px}blockquote small{display:block;line-height:20px;color:#999}blockquote small:before{content:'\2014 \00A0'}blockquote.pull-right{float:right;padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0}blockquote.pull-right p,blockquote.pull-right small{text-align:right}blockquote.pull-right small:before{content:''}blockquote.pull-right small:after{content:'\00A0 \2014'}q:before,q:after,blockquote:before,blockquote:after{content:""}address{display:block;margin-bottom:20px;font-style:normal;line-height:20px}code,pre{padding:0 3px 2px;font-family:Monaco,Menlo,Consolas,"Courier New",monospace;font-size:12px;color:#333;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}code{padding:2px 4px;color:#d14;white-space:nowrap;background-color:#f7f7f9;border:1px solid #e1e1e8}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:20px;word-break:break-all;word-wrap:break-word;white-space:pre;white-space:pre-wrap;background-color:#f5f5f5;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}pre.prettyprint{margin-bottom:20px}pre code{padding:0;color:inherit;white-space:pre;white-space:pre-wrap;background-color:transparent;border:0}.pre-scrollable{max-height:340px;overflow-y:scroll}form{margin:0 0 20px}fieldset{padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:40px;color:#333;border:0;border-bottom:1px solid #e5e5e5}legend small{font-size:15px;color:#999}label,input,button,select,textarea{font-size:14px;font-weight:normal;line-height:20px}input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}label{display:block;margin-bottom:5px}select,textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{display:inline-block;height:20px;padding:4px 6px;margin-bottom:10px;font-size:14px;line-height:20px;color:#555;vertical-align:middle;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}input,textarea,.uneditable-input{width:206px}textarea{height:auto}textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{background-color:#fff;border:1px solid #ccc;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border linear .2s,box-shadow linear .2s;-moz-transition:border linear .2s,box-shadow linear .2s;-o-transition:border linear .2s,box-shadow linear .2s;transition:border linear .2s,box-shadow linear .2s}textarea:focus,input[type="text"]:focus,input[type="password"]:focus,input[type="datetime"]:focus,input[type="datetime-local"]:focus,input[type="date"]:focus,input[type="month"]:focus,input[type="time"]:focus,input[type="week"]:focus,input[type="number"]:focus,input[type="email"]:focus,input[type="url"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="color"]:focus,.uneditable-input:focus{border-color:rgba(82,168,236,0.8);outline:0;outline:thin dotted \9;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)}input[type="radio"],input[type="checkbox"]{margin:4px 0 0;margin-top:1px \9;*margin-top:0;line-height:normal}input[type="file"],input[type="image"],input[type="submit"],input[type="reset"],input[type="button"],input[type="radio"],input[type="checkbox"]{width:auto}select,input[type="file"]{height:30px;*margin-top:4px;line-height:30px}select{width:220px;background-color:#fff;border:1px solid #ccc}select[multiple],select[size]{height:auto}select:focus,input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.uneditable-input,.uneditable-textarea{color:#999;cursor:not-allowed;background-color:#fcfcfc;border-color:#ccc;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);box-shadow:inset 0 1px 2px rgba(0,0,0,0.025)}.uneditable-input{overflow:hidden;white-space:nowrap}.uneditable-textarea{width:auto;height:auto}input:-moz-placeholder,textarea:-moz-placeholder{color:#999}input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#999}input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#999}.radio,.checkbox{min-height:20px;padding-left:20px}.radio input[type="radio"],.checkbox input[type="checkbox"]{float:left;margin-left:-20px}.controls>.radio:first-child,.controls>.checkbox:first-child{padding-top:5px}.radio.inline,.checkbox.inline{display:inline-block;padding-top:5px;margin-bottom:0;vertical-align:middle}.radio.inline+.radio.inline,.checkbox.inline+.checkbox.inline{margin-left:10px}.input-mini{width:60px}.input-small{width:90px}.input-medium{width:150px}.input-large{width:210px}.input-xlarge{width:270px}.input-xxlarge{width:530px}input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"]{float:none;margin-left:0}.input-append input[class*="span"],.input-append .uneditable-input[class*="span"],.input-prepend input[class*="span"],.input-prepend .uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"],.row-fluid .input-prepend [class*="span"],.row-fluid .input-append [class*="span"]{display:inline-block}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:20px}input.span12,textarea.span12,.uneditable-input.span12{width:926px}input.span11,textarea.span11,.uneditable-input.span11{width:846px}input.span10,textarea.span10,.uneditable-input.span10{width:766px}input.span9,textarea.span9,.uneditable-input.span9{width:686px}input.span8,textarea.span8,.uneditable-input.span8{width:606px}input.span7,textarea.span7,.uneditable-input.span7{width:526px}input.span6,textarea.span6,.uneditable-input.span6{width:446px}input.span5,textarea.span5,.uneditable-input.span5{width:366px}input.span4,textarea.span4,.uneditable-input.span4{width:286px}input.span3,textarea.span3,.uneditable-input.span3{width:206px}input.span2,textarea.span2,.uneditable-input.span2{width:126px}input.span1,textarea.span1,.uneditable-input.span1{width:46px}.controls-row{*zoom:1}.controls-row:before,.controls-row:after{display:table;line-height:0;content:""}.controls-row:after{clear:both}.controls-row [class*="span"],.row-fluid .controls-row [class*="span"]{float:left}.controls-row .checkbox[class*="span"],.controls-row .radio[class*="span"]{padding-top:5px}input[disabled],select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{cursor:not-allowed;background-color:#eee}input[type="radio"][disabled],input[type="checkbox"][disabled],input[type="radio"][readonly],input[type="checkbox"][readonly]{background-color:transparent}.control-group.warning .control-label,.control-group.warning .help-block,.control-group.warning .help-inline{color:#c09853}.control-group.warning .checkbox,.control-group.warning .radio,.control-group.warning input,.control-group.warning select,.control-group.warning textarea{color:#c09853}.control-group.warning input,.control-group.warning select,.control-group.warning textarea{border-color:#c09853;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.warning input:focus,.control-group.warning select:focus,.control-group.warning textarea:focus{border-color:#a47e3c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e}.control-group.warning .input-prepend .add-on,.control-group.warning .input-append .add-on{color:#c09853;background-color:#fcf8e3;border-color:#c09853}.control-group.error .control-label,.control-group.error .help-block,.control-group.error .help-inline{color:#b94a48}.control-group.error .checkbox,.control-group.error .radio,.control-group.error input,.control-group.error select,.control-group.error textarea{color:#b94a48}.control-group.error input,.control-group.error select,.control-group.error textarea{border-color:#b94a48;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.error input:focus,.control-group.error select:focus,.control-group.error textarea:focus{border-color:#953b39;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392}.control-group.error .input-prepend .add-on,.control-group.error .input-append .add-on{color:#b94a48;background-color:#f2dede;border-color:#b94a48}.control-group.success .control-label,.control-group.success .help-block,.control-group.success .help-inline{color:#468847}.control-group.success .checkbox,.control-group.success .radio,.control-group.success input,.control-group.success select,.control-group.success textarea{color:#468847}.control-group.success input,.control-group.success select,.control-group.success textarea{border-color:#468847;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.success input:focus,.control-group.success select:focus,.control-group.success textarea:focus{border-color:#356635;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b}.control-group.success .input-prepend .add-on,.control-group.success .input-append .add-on{color:#468847;background-color:#dff0d8;border-color:#468847}.control-group.info .control-label,.control-group.info .help-block,.control-group.info .help-inline{color:#3a87ad}.control-group.info .checkbox,.control-group.info .radio,.control-group.info input,.control-group.info select,.control-group.info textarea{color:#3a87ad}.control-group.info input,.control-group.info select,.control-group.info textarea{border-color:#3a87ad;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.info input:focus,.control-group.info select:focus,.control-group.info textarea:focus{border-color:#2d6987;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7ab5d3;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7ab5d3;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7ab5d3}.control-group.info .input-prepend .add-on,.control-group.info .input-append .add-on{color:#3a87ad;background-color:#d9edf7;border-color:#3a87ad}input:focus:invalid,textarea:focus:invalid,select:focus:invalid{color:#b94a48;border-color:#ee5f5b}input:focus:invalid:focus,textarea:focus:invalid:focus,select:focus:invalid:focus{border-color:#e9322d;-webkit-box-shadow:0 0 6px #f8b9b7;-moz-box-shadow:0 0 6px #f8b9b7;box-shadow:0 0 6px #f8b9b7}.form-actions{padding:19px 20px 20px;margin-top:20px;margin-bottom:20px;background-color:#f5f5f5;border-top:1px solid #e5e5e5;*zoom:1}.form-actions:before,.form-actions:after{display:table;line-height:0;content:""}.form-actions:after{clear:both}.help-block,.help-inline{color:#595959}.help-block{display:block;margin-bottom:10px}.help-inline{display:inline-block;*display:inline;padding-left:5px;vertical-align:middle;*zoom:1}.input-append,.input-prepend{margin-bottom:5px;font-size:0;white-space:nowrap}.input-append input,.input-prepend input,.input-append select,.input-prepend select,.input-append .uneditable-input,.input-prepend .uneditable-input,.input-append .dropdown-menu,.input-prepend .dropdown-menu{font-size:14px}.input-append input,.input-prepend input,.input-append select,.input-prepend select,.input-append .uneditable-input,.input-prepend .uneditable-input{position:relative;margin-bottom:0;*margin-left:0;vertical-align:top;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-append input:focus,.input-prepend input:focus,.input-append select:focus,.input-prepend select:focus,.input-append .uneditable-input:focus,.input-prepend .uneditable-input:focus{z-index:2}.input-append .add-on,.input-prepend .add-on{display:inline-block;width:auto;height:20px;min-width:16px;padding:4px 5px;font-size:14px;font-weight:normal;line-height:20px;text-align:center;text-shadow:0 1px 0 #fff;background-color:#eee;border:1px solid #ccc}.input-append .add-on,.input-prepend .add-on,.input-append .btn,.input-prepend .btn,.input-append .btn-group>.dropdown-toggle,.input-prepend .btn-group>.dropdown-toggle{vertical-align:top;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-append .active,.input-prepend .active{background-color:#a9dba9;border-color:#46a546}.input-prepend .add-on,.input-prepend .btn{margin-right:-1px}.input-prepend .add-on:first-child,.input-prepend .btn:first-child{-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.input-append input,.input-append select,.input-append .uneditable-input{-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.input-append input+.btn-group .btn:last-child,.input-append select+.btn-group .btn:last-child,.input-append .uneditable-input+.btn-group .btn:last-child{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-append .add-on,.input-append .btn,.input-append .btn-group{margin-left:-1px}.input-append .add-on:last-child,.input-append .btn:last-child,.input-append .btn-group:last-child>.dropdown-toggle{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-prepend.input-append input,.input-prepend.input-append select,.input-prepend.input-append .uneditable-input{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-prepend.input-append input+.btn-group .btn,.input-prepend.input-append select+.btn-group .btn,.input-prepend.input-append .uneditable-input+.btn-group .btn{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-prepend.input-append .add-on:first-child,.input-prepend.input-append .btn:first-child{margin-right:-1px;-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.input-prepend.input-append .add-on:last-child,.input-prepend.input-append .btn:last-child{margin-left:-1px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-prepend.input-append .btn-group:first-child{margin-left:0}input.search-query{padding-right:14px;padding-right:4px \9;padding-left:14px;padding-left:4px \9;margin-bottom:0;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.form-search .input-append .search-query,.form-search .input-prepend .search-query{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.form-search .input-append .search-query{-webkit-border-radius:14px 0 0 14px;-moz-border-radius:14px 0 0 14px;border-radius:14px 0 0 14px}.form-search .input-append .btn{-webkit-border-radius:0 14px 14px 0;-moz-border-radius:0 14px 14px 0;border-radius:0 14px 14px 0}.form-search .input-prepend .search-query{-webkit-border-radius:0 14px 14px 0;-moz-border-radius:0 14px 14px 0;border-radius:0 14px 14px 0}.form-search .input-prepend .btn{-webkit-border-radius:14px 0 0 14px;-moz-border-radius:14px 0 0 14px;border-radius:14px 0 0 14px}.form-search input,.form-inline input,.form-horizontal input,.form-search textarea,.form-inline textarea,.form-horizontal textarea,.form-search select,.form-inline select,.form-horizontal select,.form-search .help-inline,.form-inline .help-inline,.form-horizontal .help-inline,.form-search .uneditable-input,.form-inline .uneditable-input,.form-horizontal .uneditable-input,.form-search .input-prepend,.form-inline .input-prepend,.form-horizontal .input-prepend,.form-search .input-append,.form-inline .input-append,.form-horizontal .input-append{display:inline-block;*display:inline;margin-bottom:0;vertical-align:middle;*zoom:1}.form-search .hide,.form-inline .hide,.form-horizontal .hide{display:none}.form-search label,.form-inline label,.form-search .btn-group,.form-inline .btn-group{display:inline-block}.form-search .input-append,.form-inline .input-append,.form-search .input-prepend,.form-inline .input-prepend{margin-bottom:0}.form-search .radio,.form-search .checkbox,.form-inline .radio,.form-inline .checkbox{padding-left:0;margin-bottom:0;vertical-align:middle}.form-search .radio input[type="radio"],.form-search .checkbox input[type="checkbox"],.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:left;margin-right:3px;margin-left:0}.control-group{margin-bottom:10px}legend+.control-group{margin-top:20px;-webkit-margin-top-collapse:separate}.form-horizontal .control-group{margin-bottom:20px;*zoom:1}.form-horizontal .control-group:before,.form-horizontal .control-group:after{display:table;line-height:0;content:""}.form-horizontal .control-group:after{clear:both}.form-horizontal .control-label{float:left;width:160px;padding-top:5px;text-align:right}.form-horizontal .controls{*display:inline-block;*padding-left:20px;margin-left:180px;*margin-left:0}.form-horizontal .controls:first-child{*padding-left:180px}.form-horizontal .help-block{margin-bottom:0}.form-horizontal input+.help-block,.form-horizontal select+.help-block,.form-horizontal textarea+.help-block,.form-horizontal .uneditable-input+.help-block,.form-horizontal .input-prepend+.help-block,.form-horizontal .input-append+.help-block{margin-top:10px}.form-horizontal .form-actions{padding-left:180px}table{max-width:100%;background-color:transparent;border-collapse:collapse;border-spacing:0}.table{width:100%;margin-bottom:20px}.table th,.table td{padding:8px;line-height:20px;text-align:left;vertical-align:top;border-top:1px solid #ddd}.table th{font-weight:bold}.table thead th{vertical-align:bottom}.table caption+thead tr:first-child th,.table caption+thead tr:first-child td,.table colgroup+thead tr:first-child th,.table colgroup+thead tr:first-child td,.table thead:first-child tr:first-child th,.table thead:first-child tr:first-child td{border-top:0}.table tbody+tbody{border-top:2px solid #ddd}.table .table{background-color:#fff}.table-condensed th,.table-condensed td{padding:4px 5px}.table-bordered{border:1px solid #ddd;border-collapse:separate;*border-collapse:collapse;border-left:0;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.table-bordered th,.table-bordered td{border-left:1px solid #ddd}.table-bordered caption+thead tr:first-child th,.table-bordered caption+tbody tr:first-child th,.table-bordered caption+tbody tr:first-child td,.table-bordered colgroup+thead tr:first-child th,.table-bordered colgroup+tbody tr:first-child th,.table-bordered colgroup+tbody tr:first-child td,.table-bordered thead:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child td{border-top:0}.table-bordered thead:first-child tr:first-child>th:first-child,.table-bordered tbody:first-child tr:first-child>td:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topleft:4px}.table-bordered thead:first-child tr:first-child>th:last-child,.table-bordered tbody:first-child tr:first-child>td:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-radius-topright:4px}.table-bordered thead:last-child tr:last-child>th:first-child,.table-bordered tbody:last-child tr:last-child>td:first-child,.table-bordered tfoot:last-child tr:last-child>td:first-child{-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomleft:4px}.table-bordered thead:last-child tr:last-child>th:last-child,.table-bordered tbody:last-child tr:last-child>td:last-child,.table-bordered tfoot:last-child tr:last-child>td:last-child{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-bottomright:4px}.table-bordered tfoot+tbody:last-child tr:last-child td:first-child{-webkit-border-bottom-left-radius:0;border-bottom-left-radius:0;-moz-border-radius-bottomleft:0}.table-bordered tfoot+tbody:last-child tr:last-child td:last-child{-webkit-border-bottom-right-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomright:0}.table-bordered caption+thead tr:first-child th:first-child,.table-bordered caption+tbody tr:first-child td:first-child,.table-bordered colgroup+thead tr:first-child th:first-child,.table-bordered colgroup+tbody tr:first-child td:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topleft:4px}.table-bordered caption+thead tr:first-child th:last-child,.table-bordered caption+tbody tr:first-child td:last-child,.table-bordered colgroup+thead tr:first-child th:last-child,.table-bordered colgroup+tbody tr:first-child td:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-radius-topright:4px}.table-striped tbody>tr:nth-child(odd)>td,.table-striped tbody>tr:nth-child(odd)>th{background-color:#f9f9f9}.table-hover tbody tr:hover td,.table-hover tbody tr:hover th{background-color:#f5f5f5}table td[class*="span"],table th[class*="span"],.row-fluid table td[class*="span"],.row-fluid table th[class*="span"]{display:table-cell;float:none;margin-left:0}.table td.span1,.table th.span1{float:none;width:44px;margin-left:0}.table td.span2,.table th.span2{float:none;width:124px;margin-left:0}.table td.span3,.table th.span3{float:none;width:204px;margin-left:0}.table td.span4,.table th.span4{float:none;width:284px;margin-left:0}.table td.span5,.table th.span5{float:none;width:364px;margin-left:0}.table td.span6,.table th.span6{float:none;width:444px;margin-left:0}.table td.span7,.table th.span7{float:none;width:524px;margin-left:0}.table td.span8,.table th.span8{float:none;width:604px;margin-left:0}.table td.span9,.table th.span9{float:none;width:684px;margin-left:0}.table td.span10,.table th.span10{float:none;width:764px;margin-left:0}.table td.span11,.table th.span11{float:none;width:844px;margin-left:0}.table td.span12,.table th.span12{float:none;width:924px;margin-left:0}.table tbody tr.success td{background-color:#dff0d8}.table tbody tr.error td{background-color:#f2dede}.table tbody tr.warning td{background-color:#fcf8e3}.table tbody tr.info td{background-color:#d9edf7}.table-hover tbody tr.success:hover td{background-color:#d0e9c6}.table-hover tbody tr.error:hover td{background-color:#ebcccc}.table-hover tbody tr.warning:hover td{background-color:#faf2cc}.table-hover tbody tr.info:hover td{background-color:#c4e3f3}[class^="icon-"],[class*=" icon-"]{display:inline-block;width:14px;height:14px;margin-top:1px;*margin-right:.3em;line-height:14px;vertical-align:text-top;background-image:url("../img/glyphicons-halflings.png");background-position:14px 14px;background-repeat:no-repeat}.icon-white,.nav-pills>.active>a>[class^="icon-"],.nav-pills>.active>a>[class*=" icon-"],.nav-list>.active>a>[class^="icon-"],.nav-list>.active>a>[class*=" icon-"],.navbar-inverse .nav>.active>a>[class^="icon-"],.navbar-inverse .nav>.active>a>[class*=" icon-"],.dropdown-menu>li>a:hover>[class^="icon-"],.dropdown-menu>li>a:hover>[class*=" icon-"],.dropdown-menu>.active>a>[class^="icon-"],.dropdown-menu>.active>a>[class*=" icon-"],.dropdown-submenu:hover>a>[class^="icon-"],.dropdown-submenu:hover>a>[class*=" icon-"]{background-image:url("../img/glyphicons-halflings-white.png")}.icon-glass{background-position:0 0}.icon-music{background-position:-24px 0}.icon-search{background-position:-48px 0}.icon-envelope{background-position:-72px 0}.icon-heart{background-position:-96px 0}.icon-star{background-position:-120px 0}.icon-star-empty{background-position:-144px 0}.icon-user{background-position:-168px 0}.icon-film{background-position:-192px 0}.icon-th-large{background-position:-216px 0}.icon-th{background-position:-240px 0}.icon-th-list{background-position:-264px 0}.icon-ok{background-position:-288px 0}.icon-remove{background-position:-312px 0}.icon-zoom-in{background-position:-336px 0}.icon-zoom-out{background-position:-360px 0}.icon-off{background-position:-384px 0}.icon-signal{background-position:-408px 0}.icon-cog{background-position:-432px 0}.icon-trash{background-position:-456px 0}.icon-home{background-position:0 -24px}.icon-file{background-position:-24px -24px}.icon-time{background-position:-48px -24px}.icon-road{background-position:-72px -24px}.icon-download-alt{background-position:-96px -24px}.icon-download{background-position:-120px -24px}.icon-upload{background-position:-144px -24px}.icon-inbox{background-position:-168px -24px}.icon-play-circle{background-position:-192px -24px}.icon-repeat{background-position:-216px -24px}.icon-refresh{background-position:-240px -24px}.icon-list-alt{background-position:-264px -24px}.icon-lock{background-position:-287px -24px}.icon-flag{background-position:-312px -24px}.icon-headphones{background-position:-336px -24px}.icon-volume-off{background-position:-360px -24px}.icon-volume-down{background-position:-384px -24px}.icon-volume-up{background-position:-408px -24px}.icon-qrcode{background-position:-432px -24px}.icon-barcode{background-position:-456px -24px}.icon-tag{background-position:0 -48px}.icon-tags{background-position:-25px -48px}.icon-book{background-position:-48px -48px}.icon-bookmark{background-position:-72px -48px}.icon-print{background-position:-96px -48px}.icon-camera{background-position:-120px -48px}.icon-font{background-position:-144px -48px}.icon-bold{background-position:-167px -48px}.icon-italic{background-position:-192px -48px}.icon-text-height{background-position:-216px -48px}.icon-text-width{background-position:-240px -48px}.icon-align-left{background-position:-264px -48px}.icon-align-center{background-position:-288px -48px}.icon-align-right{background-position:-312px -48px}.icon-align-justify{background-position:-336px -48px}.icon-list{background-position:-360px -48px}.icon-indent-left{background-position:-384px -48px}.icon-indent-right{background-position:-408px -48px}.icon-facetime-video{background-position:-432px -48px}.icon-picture{background-position:-456px -48px}.icon-pencil{background-position:0 -72px}.icon-map-marker{background-position:-24px -72px}.icon-adjust{background-position:-48px -72px}.icon-tint{background-position:-72px -72px}.icon-edit{background-position:-96px -72px}.icon-share{background-position:-120px -72px}.icon-check{background-position:-144px -72px}.icon-move{background-position:-168px -72px}.icon-step-backward{background-position:-192px -72px}.icon-fast-backward{background-position:-216px -72px}.icon-backward{background-position:-240px -72px}.icon-play{background-position:-264px -72px}.icon-pause{background-position:-288px -72px}.icon-stop{background-position:-312px -72px}.icon-forward{background-position:-336px -72px}.icon-fast-forward{background-position:-360px -72px}.icon-step-forward{background-position:-384px -72px}.icon-eject{background-position:-408px -72px}.icon-chevron-left{background-position:-432px -72px}.icon-chevron-right{background-position:-456px -72px}.icon-plus-sign{background-position:0 -96px}.icon-minus-sign{background-position:-24px -96px}.icon-remove-sign{background-position:-48px -96px}.icon-ok-sign{background-position:-72px -96px}.icon-question-sign{background-position:-96px -96px}.icon-info-sign{background-position:-120px -96px}.icon-screenshot{background-position:-144px -96px}.icon-remove-circle{background-position:-168px -96px}.icon-ok-circle{background-position:-192px -96px}.icon-ban-circle{background-position:-216px -96px}.icon-arrow-left{background-position:-240px -96px}.icon-arrow-right{background-position:-264px -96px}.icon-arrow-up{background-position:-289px -96px}.icon-arrow-down{background-position:-312px -96px}.icon-share-alt{background-position:-336px -96px}.icon-resize-full{background-position:-360px -96px}.icon-resize-small{background-position:-384px -96px}.icon-plus{background-position:-408px -96px}.icon-minus{background-position:-433px -96px}.icon-asterisk{background-position:-456px -96px}.icon-exclamation-sign{background-position:0 -120px}.icon-gift{background-position:-24px -120px}.icon-leaf{background-position:-48px -120px}.icon-fire{background-position:-72px -120px}.icon-eye-open{background-position:-96px -120px}.icon-eye-close{background-position:-120px -120px}.icon-warning-sign{background-position:-144px -120px}.icon-plane{background-position:-168px -120px}.icon-calendar{background-position:-192px -120px}.icon-random{width:16px;background-position:-216px -120px}.icon-comment{background-position:-240px -120px}.icon-magnet{background-position:-264px -120px}.icon-chevron-up{background-position:-288px -120px}.icon-chevron-down{background-position:-313px -119px}.icon-retweet{background-position:-336px -120px}.icon-shopping-cart{background-position:-360px -120px}.icon-folder-close{background-position:-384px -120px}.icon-folder-open{width:16px;background-position:-408px -120px}.icon-resize-vertical{background-position:-432px -119px}.icon-resize-horizontal{background-position:-456px -118px}.icon-hdd{background-position:0 -144px}.icon-bullhorn{background-position:-24px -144px}.icon-bell{background-position:-48px -144px}.icon-certificate{background-position:-72px -144px}.icon-thumbs-up{background-position:-96px -144px}.icon-thumbs-down{background-position:-120px -144px}.icon-hand-right{background-position:-144px -144px}.icon-hand-left{background-position:-168px -144px}.icon-hand-up{background-position:-192px -144px}.icon-hand-down{background-position:-216px -144px}.icon-circle-arrow-right{background-position:-240px -144px}.icon-circle-arrow-left{background-position:-264px -144px}.icon-circle-arrow-up{background-position:-288px -144px}.icon-circle-arrow-down{background-position:-312px -144px}.icon-globe{background-position:-336px -144px}.icon-wrench{background-position:-360px -144px}.icon-tasks{background-position:-384px -144px}.icon-filter{background-position:-408px -144px}.icon-briefcase{background-position:-432px -144px}.icon-fullscreen{background-position:-456px -144px}.dropup,.dropdown{position:relative}.dropdown-toggle{*margin-bottom:-3px}.dropdown-toggle:active,.open .dropdown-toggle{outline:0}.caret{display:inline-block;width:0;height:0;vertical-align:top;border-top:4px solid #000;border-right:4px solid transparent;border-left:4px solid transparent;content:""}.dropdown .caret{margin-top:8px;margin-left:2px}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);*border-right-width:2px;*border-bottom-width:2px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{*width:100%;height:1px;margin:9px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.dropdown-menu li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:20px;color:#333;white-space:nowrap}.dropdown-menu li>a:hover,.dropdown-menu li>a:focus,.dropdown-submenu:hover>a{color:#fff;text-decoration:none;background-color:#0081c2;background-image:-moz-linear-gradient(top,#08c,#0077b3);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#0077b3));background-image:-webkit-linear-gradient(top,#08c,#0077b3);background-image:-o-linear-gradient(top,#08c,#0077b3);background-image:linear-gradient(to bottom,#08c,#0077b3);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0077b3',GradientType=0)}.dropdown-menu .active>a,.dropdown-menu .active>a:hover{color:#fff;text-decoration:none;background-color:#0081c2;background-image:-moz-linear-gradient(top,#08c,#0077b3);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#0077b3));background-image:-webkit-linear-gradient(top,#08c,#0077b3);background-image:-o-linear-gradient(top,#08c,#0077b3);background-image:linear-gradient(to bottom,#08c,#0077b3);background-repeat:repeat-x;outline:0;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0077b3',GradientType=0)}.dropdown-menu .disabled>a,.dropdown-menu .disabled>a:hover{color:#999}.dropdown-menu .disabled>a:hover{text-decoration:none;cursor:default;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.open{*z-index:1000}.open>.dropdown-menu{display:block}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px solid #000;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:1px}.dropdown-submenu{position:relative}.dropdown-submenu>.dropdown-menu{top:0;left:100%;margin-top:-6px;margin-left:-1px;-webkit-border-radius:0 6px 6px 6px;-moz-border-radius:0 6px 6px 6px;border-radius:0 6px 6px 6px}.dropdown-submenu:hover>.dropdown-menu{display:block}.dropup .dropdown-submenu>.dropdown-menu{top:auto;bottom:0;margin-top:0;margin-bottom:-2px;-webkit-border-radius:5px 5px 5px 0;-moz-border-radius:5px 5px 5px 0;border-radius:5px 5px 5px 0}.dropdown-submenu>a:after{display:block;float:right;width:0;height:0;margin-top:5px;margin-right:-10px;border-color:transparent;border-left-color:#ccc;border-style:solid;border-width:5px 0 5px 5px;content:" "}.dropdown-submenu:hover>a:after{border-left-color:#fff}.dropdown-submenu.pull-left{float:none}.dropdown-submenu.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.dropdown .dropdown-menu .nav-header{padding-right:20px;padding-left:20px}.typeahead{z-index:1051;margin-top:2px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-large{padding:24px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.well-small{padding:9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.fade{opacity:0;-webkit-transition:opacity .15s linear;-moz-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{position:relative;height:0;overflow:hidden;-webkit-transition:height .35s ease;-moz-transition:height .35s ease;-o-transition:height .35s ease;transition:height .35s ease}.collapse.in{height:auto}.close{float:right;font-size:20px;font-weight:bold;line-height:20px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.btn{display:inline-block;*display:inline;padding:4px 12px;margin-bottom:0;*margin-left:.3em;font-size:14px;line-height:20px;color:#333;text-align:center;text-shadow:0 1px 1px rgba(255,255,255,0.75);vertical-align:middle;cursor:pointer;background-color:#f5f5f5;*background-color:#e6e6e6;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;border:1px solid #bbb;*border:0;border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);border-bottom-color:#a2a2a2;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffe6e6e6',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);*zoom:1;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn:hover,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class^="icon-"],.btn-large [class*=" icon-"]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class^="icon-"],.btn-small [class*=" icon-"]{margin-top:0}.btn-mini [class^="icon-"],.btn-mini [class*=" icon-"]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-right:0;padding-left:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn{border-color:#c5c5c5;border-color:rgba(0,0,0,0.15) rgba(0,0,0,0.15) rgba(0,0,0,0.25)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#006dcc;*background-color:#04c;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0044cc',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary:hover,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary:active,.btn-primary.active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#faa732;*background-color:#f89406;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450',endColorstr='#fff89406',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning:hover,.btn-warning:active,.btn-warning.active,.btn-warning.disabled,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning:active,.btn-warning.active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#da4f49;*background-color:#bd362f;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeat:repeat-x;border-color:#bd362f #bd362f #802420;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b',endColorstr='#ffbd362f',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-danger:hover,.btn-danger:active,.btn-danger.active,.btn-danger.disabled,.btn-danger[disabled]{color:#fff;background-color:#bd362f;*background-color:#a9302a}.btn-danger:active,.btn-danger.active{background-color:#942a25 \9}.btn-success{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#5bb75b;*background-color:#51a351;background-image:-moz-linear-gradient(top,#62c462,#51a351);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#51a351));background-image:-webkit-linear-gradient(top,#62c462,#51a351);background-image:-o-linear-gradient(top,#62c462,#51a351);background-image:linear-gradient(to bottom,#62c462,#51a351);background-repeat:repeat-x;border-color:#51a351 #51a351 #387038;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462',endColorstr='#ff51a351',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-success:hover,.btn-success:active,.btn-success.active,.btn-success.disabled,.btn-success[disabled]{color:#fff;background-color:#51a351;*background-color:#499249}.btn-success:active,.btn-success.active{background-color:#408140 \9}.btn-info{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#49afcd;*background-color:#2f96b4;background-image:-moz-linear-gradient(top,#5bc0de,#2f96b4);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#2f96b4));background-image:-webkit-linear-gradient(top,#5bc0de,#2f96b4);background-image:-o-linear-gradient(top,#5bc0de,#2f96b4);background-image:linear-gradient(to bottom,#5bc0de,#2f96b4);background-repeat:repeat-x;border-color:#2f96b4 #2f96b4 #1f6377;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de',endColorstr='#ff2f96b4',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-info:hover,.btn-info:active,.btn-info.active,.btn-info.disabled,.btn-info[disabled]{color:#fff;background-color:#2f96b4;*background-color:#2a85a0}.btn-info:active,.btn-info.active{background-color:#24748c \9}.btn-inverse{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#363636;*background-color:#222;background-image:-moz-linear-gradient(top,#444,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#444),to(#222));background-image:-webkit-linear-gradient(top,#444,#222);background-image:-o-linear-gradient(top,#444,#222);background-image:linear-gradient(to bottom,#444,#222);background-repeat:repeat-x;border-color:#222 #222 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff444444',endColorstr='#ff222222',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-inverse:hover,.btn-inverse:active,.btn-inverse.active,.btn-inverse.disabled,.btn-inverse[disabled]{color:#fff;background-color:#222;*background-color:#151515}.btn-inverse:active,.btn-inverse.active{background-color:#080808 \9}button.btn,input[type="submit"].btn{*padding-top:3px;*padding-bottom:3px}button.btn::-moz-focus-inner,input[type="submit"].btn::-moz-focus-inner{padding:0;border:0}button.btn.btn-large,input[type="submit"].btn.btn-large{*padding-top:7px;*padding-bottom:7px}button.btn.btn-small,input[type="submit"].btn.btn-small{*padding-top:3px;*padding-bottom:3px}button.btn.btn-mini,input[type="submit"].btn.btn-mini{*padding-top:1px;*padding-bottom:1px}.btn-link,.btn-link:active,.btn-link[disabled]{background-color:transparent;background-image:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-link{color:#08c;cursor:pointer;border-color:transparent;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-link:hover{color:#005580;text-decoration:underline;background-color:transparent}.btn-link[disabled]:hover{color:#333;text-decoration:none}.btn-group{position:relative;display:inline-block;*display:inline;*margin-left:.3em;font-size:0;white-space:nowrap;vertical-align:middle;*zoom:1}.btn-group:first-child{*margin-left:0}.btn-group+.btn-group{margin-left:5px}.btn-toolbar{margin-top:10px;margin-bottom:10px;font-size:0}.btn-toolbar>.btn+.btn,.btn-toolbar>.btn-group+.btn,.btn-toolbar>.btn+.btn-group{margin-left:5px}.btn-group>.btn{position:relative;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-group>.btn+.btn{margin-left:-1px}.btn-group>.btn,.btn-group>.dropdown-menu,.btn-group>.popover{font-size:14px}.btn-group>.btn-mini{font-size:10.5px}.btn-group>.btn-small{font-size:11.9px}.btn-group>.btn-large{font-size:17.5px}.btn-group>.btn:first-child{margin-left:0;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-bottomleft:4px;-moz-border-radius-topleft:4px}.btn-group>.btn:last-child,.btn-group>.dropdown-toggle{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-bottomright:4px}.btn-group>.btn.large:first-child{margin-left:0;-webkit-border-bottom-left-radius:6px;border-bottom-left-radius:6px;-webkit-border-top-left-radius:6px;border-top-left-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-topleft:6px}.btn-group>.btn.large:last-child,.btn-group>.large.dropdown-toggle{-webkit-border-top-right-radius:6px;border-top-right-radius:6px;-webkit-border-bottom-right-radius:6px;border-bottom-right-radius:6px;-moz-border-radius-topright:6px;-moz-border-radius-bottomright:6px}.btn-group>.btn:hover,.btn-group>.btn:focus,.btn-group>.btn:active,.btn-group>.btn.active{z-index:2}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group>.btn+.dropdown-toggle{*padding-top:5px;padding-right:8px;*padding-bottom:5px;padding-left:8px;-webkit-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn-group>.btn-mini+.dropdown-toggle{*padding-top:2px;padding-right:5px;*padding-bottom:2px;padding-left:5px}.btn-group>.btn-small+.dropdown-toggle{*padding-top:5px;*padding-bottom:4px}.btn-group>.btn-large+.dropdown-toggle{*padding-top:7px;padding-right:12px;*padding-bottom:7px;padding-left:12px}.btn-group.open .dropdown-toggle{background-image:none;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn-group.open .btn.dropdown-toggle{background-color:#e6e6e6}.btn-group.open .btn-primary.dropdown-toggle{background-color:#04c}.btn-group.open .btn-warning.dropdown-toggle{background-color:#f89406}.btn-group.open .btn-danger.dropdown-toggle{background-color:#bd362f}.btn-group.open .btn-success.dropdown-toggle{background-color:#51a351}.btn-group.open .btn-info.dropdown-toggle{background-color:#2f96b4}.btn-group.open .btn-inverse.dropdown-toggle{background-color:#222}.btn .caret{margin-top:8px;margin-left:0}.btn-mini .caret,.btn-small .caret,.btn-large .caret{margin-top:6px}.btn-large .caret{border-top-width:5px;border-right-width:5px;border-left-width:5px}.dropup .btn-large .caret{border-bottom-width:5px}.btn-primary .caret,.btn-warning .caret,.btn-danger .caret,.btn-info .caret,.btn-success .caret,.btn-inverse .caret{border-top-color:#fff;border-bottom-color:#fff}.btn-group-vertical{display:inline-block;*display:inline;*zoom:1}.btn-group-vertical>.btn{display:block;float:none;max-width:100%;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-group-vertical>.btn+.btn{margin-top:-1px;margin-left:0}.btn-group-vertical>.btn:first-child{-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.btn-group-vertical>.btn:last-child{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.btn-group-vertical>.btn-large:first-child{-webkit-border-radius:6px 6px 0 0;-moz-border-radius:6px 6px 0 0;border-radius:6px 6px 0 0}.btn-group-vertical>.btn-large:last-child{-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px}.alert{padding:8px 35px 8px 14px;margin-bottom:20px;text-shadow:0 1px 0 rgba(255,255,255,0.5);background-color:#fcf8e3;border:1px solid #fbeed5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.alert,.alert h4{color:#c09853}.alert h4{margin:0}.alert .close{position:relative;top:-2px;right:-21px;line-height:20px}.alert-success{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.alert-success h4{color:#468847}.alert-danger,.alert-error{color:#b94a48;background-color:#f2dede;border-color:#eed3d7}.alert-danger h4,.alert-error h4{color:#b94a48}.alert-info{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.alert-info h4{color:#3a87ad}.alert-block{padding-top:14px;padding-bottom:14px}.alert-block>p,.alert-block>ul{margin-bottom:0}.alert-block p+p{margin-top:5px}.nav{margin-bottom:20px;margin-left:0;list-style:none}.nav>li>a{display:block}.nav>li>a:hover{text-decoration:none;background-color:#eee}.nav>li>a>img{max-width:none}.nav>.pull-right{float:right}.nav-header{display:block;padding:3px 15px;font-size:11px;font-weight:bold;line-height:20px;color:#999;text-shadow:0 1px 0 rgba(255,255,255,0.5);text-transform:uppercase}.nav li+.nav-header{margin-top:9px}.nav-list{padding-right:15px;padding-left:15px;margin-bottom:0}.nav-list>li>a,.nav-list .nav-header{margin-right:-15px;margin-left:-15px;text-shadow:0 1px 0 rgba(255,255,255,0.5)}.nav-list>li>a{padding:3px 15px}.nav-list>.active>a,.nav-list>.active>a:hover{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.2);background-color:#08c}.nav-list [class^="icon-"],.nav-list [class*=" icon-"]{margin-right:2px}.nav-list .divider{*width:100%;height:1px;margin:9px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.nav-tabs,.nav-pills{*zoom:1}.nav-tabs:before,.nav-pills:before,.nav-tabs:after,.nav-pills:after{display:table;line-height:0;content:""}.nav-tabs:after,.nav-pills:after{clear:both}.nav-tabs>li,.nav-pills>li{float:left}.nav-tabs>li>a,.nav-pills>li>a{padding-right:12px;padding-left:12px;margin-right:2px;line-height:14px}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{margin-bottom:-1px}.nav-tabs>li>a{padding-top:8px;padding-bottom:8px;line-height:20px;border:1px solid transparent;-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>.active>a,.nav-tabs>.active>a:hover{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-pills>li>a{padding-top:8px;padding-bottom:8px;margin-top:2px;margin-bottom:2px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.nav-pills>.active>a,.nav-pills>.active>a:hover{color:#fff;background-color:#08c}.nav-stacked>li{float:none}.nav-stacked>li>a{margin-right:0}.nav-tabs.nav-stacked{border-bottom:0}.nav-tabs.nav-stacked>li>a{border:1px solid #ddd;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.nav-tabs.nav-stacked>li:first-child>a{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-topleft:4px}.nav-tabs.nav-stacked>li:last-child>a{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomright:4px;-moz-border-radius-bottomleft:4px}.nav-tabs.nav-stacked>li>a:hover{z-index:2;border-color:#ddd}.nav-pills.nav-stacked>li>a{margin-bottom:3px}.nav-pills.nav-stacked>li:last-child>a{margin-bottom:1px}.nav-tabs .dropdown-menu{-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px}.nav-pills .dropdown-menu{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.nav .dropdown-toggle .caret{margin-top:6px;border-top-color:#08c;border-bottom-color:#08c}.nav .dropdown-toggle:hover .caret{border-top-color:#005580;border-bottom-color:#005580}.nav-tabs .dropdown-toggle .caret{margin-top:8px}.nav .active .dropdown-toggle .caret{border-top-color:#fff;border-bottom-color:#fff}.nav-tabs .active .dropdown-toggle .caret{border-top-color:#555;border-bottom-color:#555}.nav>.dropdown.active>a:hover{cursor:pointer}.nav-tabs .open .dropdown-toggle,.nav-pills .open .dropdown-toggle,.nav>li.dropdown.open.active>a:hover{color:#fff;background-color:#999;border-color:#999}.nav li.dropdown.open .caret,.nav li.dropdown.open.active .caret,.nav li.dropdown.open a:hover .caret{border-top-color:#fff;border-bottom-color:#fff;opacity:1;filter:alpha(opacity=100)}.tabs-stacked .open>a:hover{border-color:#999}.tabbable{*zoom:1}.tabbable:before,.tabbable:after{display:table;line-height:0;content:""}.tabbable:after{clear:both}.tab-content{overflow:auto}.tabs-below>.nav-tabs,.tabs-right>.nav-tabs,.tabs-left>.nav-tabs{border-bottom:0}.tab-content>.tab-pane,.pill-content>.pill-pane{display:none}.tab-content>.active,.pill-content>.active{display:block}.tabs-below>.nav-tabs{border-top:1px solid #ddd}.tabs-below>.nav-tabs>li{margin-top:-1px;margin-bottom:0}.tabs-below>.nav-tabs>li>a{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.tabs-below>.nav-tabs>li>a:hover{border-top-color:#ddd;border-bottom-color:transparent}.tabs-below>.nav-tabs>.active>a,.tabs-below>.nav-tabs>.active>a:hover{border-color:transparent #ddd #ddd #ddd}.tabs-left>.nav-tabs>li,.tabs-right>.nav-tabs>li{float:none}.tabs-left>.nav-tabs>li>a,.tabs-right>.nav-tabs>li>a{min-width:74px;margin-right:0;margin-bottom:3px}.tabs-left>.nav-tabs{float:left;margin-right:19px;border-right:1px solid #ddd}.tabs-left>.nav-tabs>li>a{margin-right:-1px;-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.tabs-left>.nav-tabs>li>a:hover{border-color:#eee #ddd #eee #eee}.tabs-left>.nav-tabs .active>a,.tabs-left>.nav-tabs .active>a:hover{border-color:#ddd transparent #ddd #ddd;*border-right-color:#fff}.tabs-right>.nav-tabs{float:right;margin-left:19px;border-left:1px solid #ddd}.tabs-right>.nav-tabs>li>a{margin-left:-1px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.tabs-right>.nav-tabs>li>a:hover{border-color:#eee #eee #eee #ddd}.tabs-right>.nav-tabs .active>a,.tabs-right>.nav-tabs .active>a:hover{border-color:#ddd #ddd #ddd transparent;*border-left-color:#fff}.nav>.disabled>a{color:#999}.nav>.disabled>a:hover{text-decoration:none;cursor:default;background-color:transparent}.navbar{*position:relative;*z-index:2;margin-bottom:20px;overflow:visible}.navbar-inner{min-height:40px;padding-right:20px;padding-left:20px;background-color:#fafafa;background-image:-moz-linear-gradient(top,#fff,#f2f2f2);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#f2f2f2));background-image:-webkit-linear-gradient(top,#fff,#f2f2f2);background-image:-o-linear-gradient(top,#fff,#f2f2f2);background-image:linear-gradient(to bottom,#fff,#f2f2f2);background-repeat:repeat-x;border:1px solid #d4d4d4;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#fff2f2f2',GradientType=0);*zoom:1;-webkit-box-shadow:0 1px 4px rgba(0,0,0,0.065);-moz-box-shadow:0 1px 4px rgba(0,0,0,0.065);box-shadow:0 1px 4px rgba(0,0,0,0.065)}.navbar-inner:before,.navbar-inner:after{display:table;line-height:0;content:""}.navbar-inner:after{clear:both}.navbar .container{width:auto}.nav-collapse.collapse{height:auto;overflow:visible}.navbar .brand{display:block;float:left;padding:10px 20px 10px;margin-left:-20px;font-size:20px;font-weight:200;color:#777;text-shadow:0 1px 0 #fff}.navbar .brand:hover{text-decoration:none}.navbar-text{margin-bottom:0;line-height:40px;color:#777}.navbar-link{color:#777}.navbar-link:hover{color:#333}.navbar .divider-vertical{height:40px;margin:0 9px;border-right:1px solid #fff;border-left:1px solid #f2f2f2}.navbar .btn,.navbar .btn-group{margin-top:5px}.navbar .btn-group .btn,.navbar .input-prepend .btn,.navbar .input-append .btn{margin-top:0}.navbar-form{margin-bottom:0;*zoom:1}.navbar-form:before,.navbar-form:after{display:table;line-height:0;content:""}.navbar-form:after{clear:both}.navbar-form input,.navbar-form select,.navbar-form .radio,.navbar-form .checkbox{margin-top:5px}.navbar-form input,.navbar-form select,.navbar-form .btn{display:inline-block;margin-bottom:0}.navbar-form input[type="image"],.navbar-form input[type="checkbox"],.navbar-form input[type="radio"]{margin-top:3px}.navbar-form .input-append,.navbar-form .input-prepend{margin-top:5px;white-space:nowrap}.navbar-form .input-append input,.navbar-form .input-prepend input{margin-top:0}.navbar-search{position:relative;float:left;margin-top:5px;margin-bottom:0}.navbar-search .search-query{padding:4px 14px;margin-bottom:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;font-weight:normal;line-height:1;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.navbar-static-top{position:static;margin-bottom:0}.navbar-static-top .navbar-inner{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;z-index:1030;margin-bottom:0}.navbar-fixed-top .navbar-inner,.navbar-static-top .navbar-inner{border-width:0 0 1px}.navbar-fixed-bottom .navbar-inner{border-width:1px 0 0}.navbar-fixed-top .navbar-inner,.navbar-fixed-bottom .navbar-inner{padding-right:0;padding-left:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.navbar-fixed-top{top:0}.navbar-fixed-top .navbar-inner,.navbar-static-top .navbar-inner{-webkit-box-shadow:0 1px 10px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 10px rgba(0,0,0,0.1);box-shadow:0 1px 10px rgba(0,0,0,0.1)}.navbar-fixed-bottom{bottom:0}.navbar-fixed-bottom .navbar-inner{-webkit-box-shadow:0 -1px 10px rgba(0,0,0,0.1);-moz-box-shadow:0 -1px 10px rgba(0,0,0,0.1);box-shadow:0 -1px 10px rgba(0,0,0,0.1)}.navbar .nav{position:relative;left:0;display:block;float:left;margin:0 10px 0 0}.navbar .nav.pull-right{float:right;margin-right:0}.navbar .nav>li{float:left}.navbar .nav>li>a{float:none;padding:10px 15px 10px;color:#777;text-decoration:none;text-shadow:0 1px 0 #fff}.navbar .nav .dropdown-toggle .caret{margin-top:8px}.navbar .nav>li>a:focus,.navbar .nav>li>a:hover{color:#333;text-decoration:none;background-color:transparent}.navbar .nav>.active>a,.navbar .nav>.active>a:hover,.navbar .nav>.active>a:focus{color:#555;text-decoration:none;background-color:#e5e5e5;-webkit-box-shadow:inset 0 3px 8px rgba(0,0,0,0.125);-moz-box-shadow:inset 0 3px 8px rgba(0,0,0,0.125);box-shadow:inset 0 3px 8px rgba(0,0,0,0.125)}.navbar .btn-navbar{display:none;float:right;padding:7px 10px;margin-right:5px;margin-left:5px;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#ededed;*background-color:#e5e5e5;background-image:-moz-linear-gradient(top,#f2f2f2,#e5e5e5);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f2f2f2),to(#e5e5e5));background-image:-webkit-linear-gradient(top,#f2f2f2,#e5e5e5);background-image:-o-linear-gradient(top,#f2f2f2,#e5e5e5);background-image:linear-gradient(to bottom,#f2f2f2,#e5e5e5);background-repeat:repeat-x;border-color:#e5e5e5 #e5e5e5 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2f2f2',endColorstr='#ffe5e5e5',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075)}.navbar .btn-navbar:hover,.navbar .btn-navbar:active,.navbar .btn-navbar.active,.navbar .btn-navbar.disabled,.navbar .btn-navbar[disabled]{color:#fff;background-color:#e5e5e5;*background-color:#d9d9d9}.navbar .btn-navbar:active,.navbar .btn-navbar.active{background-color:#ccc \9}.navbar .btn-navbar .icon-bar{display:block;width:18px;height:2px;background-color:#f5f5f5;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.25);-moz-box-shadow:0 1px 0 rgba(0,0,0,0.25);box-shadow:0 1px 0 rgba(0,0,0,0.25)}.btn-navbar .icon-bar+.icon-bar{margin-top:3px}.navbar .nav>li>.dropdown-menu:before{position:absolute;top:-7px;left:9px;display:inline-block;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-left:7px solid transparent;border-bottom-color:rgba(0,0,0,0.2);content:''}.navbar .nav>li>.dropdown-menu:after{position:absolute;top:-6px;left:10px;display:inline-block;border-right:6px solid transparent;border-bottom:6px solid #fff;border-left:6px solid transparent;content:''}.navbar-fixed-bottom .nav>li>.dropdown-menu:before{top:auto;bottom:-7px;border-top:7px solid #ccc;border-bottom:0;border-top-color:rgba(0,0,0,0.2)}.navbar-fixed-bottom .nav>li>.dropdown-menu:after{top:auto;bottom:-6px;border-top:6px solid #fff;border-bottom:0}.navbar .nav li.dropdown>a:hover .caret{border-top-color:#555;border-bottom-color:#555}.navbar .nav li.dropdown.open>.dropdown-toggle,.navbar .nav li.dropdown.active>.dropdown-toggle,.navbar .nav li.dropdown.open.active>.dropdown-toggle{color:#555;background-color:#e5e5e5}.navbar .nav li.dropdown>.dropdown-toggle .caret{border-top-color:#777;border-bottom-color:#777}.navbar .nav li.dropdown.open>.dropdown-toggle .caret,.navbar .nav li.dropdown.active>.dropdown-toggle .caret,.navbar .nav li.dropdown.open.active>.dropdown-toggle .caret{border-top-color:#555;border-bottom-color:#555}.navbar .pull-right>li>.dropdown-menu,.navbar .nav>li>.dropdown-menu.pull-right{right:0;left:auto}.navbar .pull-right>li>.dropdown-menu:before,.navbar .nav>li>.dropdown-menu.pull-right:before{right:12px;left:auto}.navbar .pull-right>li>.dropdown-menu:after,.navbar .nav>li>.dropdown-menu.pull-right:after{right:13px;left:auto}.navbar .pull-right>li>.dropdown-menu .dropdown-menu,.navbar .nav>li>.dropdown-menu.pull-right .dropdown-menu{right:100%;left:auto;margin-right:-1px;margin-left:0;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.navbar-inverse .navbar-inner{background-color:#1b1b1b;background-image:-moz-linear-gradient(top,#222,#111);background-image:-webkit-gradient(linear,0 0,0 100%,from(#222),to(#111));background-image:-webkit-linear-gradient(top,#222,#111);background-image:-o-linear-gradient(top,#222,#111);background-image:linear-gradient(to bottom,#222,#111);background-repeat:repeat-x;border-color:#252525;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff222222',endColorstr='#ff111111',GradientType=0)}.navbar-inverse .brand,.navbar-inverse .nav>li>a{color:#999;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.navbar-inverse .brand:hover,.navbar-inverse .nav>li>a:hover{color:#fff}.navbar-inverse .brand{color:#999}.navbar-inverse .navbar-text{color:#999}.navbar-inverse .nav>li>a:focus,.navbar-inverse .nav>li>a:hover{color:#fff;background-color:transparent}.navbar-inverse .nav .active>a,.navbar-inverse .nav .active>a:hover,.navbar-inverse .nav .active>a:focus{color:#fff;background-color:#111}.navbar-inverse .navbar-link{color:#999}.navbar-inverse .navbar-link:hover{color:#fff}.navbar-inverse .divider-vertical{border-right-color:#222;border-left-color:#111}.navbar-inverse .nav li.dropdown.open>.dropdown-toggle,.navbar-inverse .nav li.dropdown.active>.dropdown-toggle,.navbar-inverse .nav li.dropdown.open.active>.dropdown-toggle{color:#fff;background-color:#111}.navbar-inverse .nav li.dropdown>a:hover .caret{border-top-color:#fff;border-bottom-color:#fff}.navbar-inverse .nav li.dropdown>.dropdown-toggle .caret{border-top-color:#999;border-bottom-color:#999}.navbar-inverse .nav li.dropdown.open>.dropdown-toggle .caret,.navbar-inverse .nav li.dropdown.active>.dropdown-toggle .caret,.navbar-inverse .nav li.dropdown.open.active>.dropdown-toggle .caret{border-top-color:#fff;border-bottom-color:#fff}.navbar-inverse .navbar-search .search-query{color:#fff;background-color:#515151;border-color:#111;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-webkit-transition:none;-moz-transition:none;-o-transition:none;transition:none}.navbar-inverse .navbar-search .search-query:-moz-placeholder{color:#ccc}.navbar-inverse .navbar-search .search-query:-ms-input-placeholder{color:#ccc}.navbar-inverse .navbar-search .search-query::-webkit-input-placeholder{color:#ccc}.navbar-inverse .navbar-search .search-query:focus,.navbar-inverse .navbar-search .search-query.focused{padding:5px 15px;color:#333;text-shadow:0 1px 0 #fff;background-color:#fff;border:0;outline:0;-webkit-box-shadow:0 0 3px rgba(0,0,0,0.15);-moz-box-shadow:0 0 3px rgba(0,0,0,0.15);box-shadow:0 0 3px rgba(0,0,0,0.15)}.navbar-inverse .btn-navbar{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#0e0e0e;*background-color:#040404;background-image:-moz-linear-gradient(top,#151515,#040404);background-image:-webkit-gradient(linear,0 0,0 100%,from(#151515),to(#040404));background-image:-webkit-linear-gradient(top,#151515,#040404);background-image:-o-linear-gradient(top,#151515,#040404);background-image:linear-gradient(to bottom,#151515,#040404);background-repeat:repeat-x;border-color:#040404 #040404 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff151515',endColorstr='#ff040404',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.navbar-inverse .btn-navbar:hover,.navbar-inverse .btn-navbar:active,.navbar-inverse .btn-navbar.active,.navbar-inverse .btn-navbar.disabled,.navbar-inverse .btn-navbar[disabled]{color:#fff;background-color:#040404;*background-color:#000}.navbar-inverse .btn-navbar:active,.navbar-inverse .btn-navbar.active{background-color:#000 \9}.breadcrumb{padding:8px 15px;margin:0 0 20px;list-style:none;background-color:#f5f5f5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.breadcrumb>li{display:inline-block;*display:inline;text-shadow:0 1px 0 #fff;*zoom:1}.breadcrumb>li>.divider{padding:0 5px;color:#ccc}.breadcrumb>.active{color:#999}.pagination{margin:20px 0}.pagination ul{display:inline-block;*display:inline;margin-bottom:0;margin-left:0;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*zoom:1;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,0.05);box-shadow:0 1px 2px rgba(0,0,0,0.05)}.pagination ul>li{display:inline}.pagination ul>li>a,.pagination ul>li>span{float:left;padding:4px 12px;line-height:20px;text-decoration:none;background-color:#fff;border:1px solid #ddd;border-left-width:0}.pagination ul>li>a:hover,.pagination ul>.active>a,.pagination ul>.active>span{background-color:#f5f5f5}.pagination ul>.active>a,.pagination ul>.active>span{color:#999;cursor:default}.pagination ul>.disabled>span,.pagination ul>.disabled>a,.pagination ul>.disabled>a:hover{color:#999;cursor:default;background-color:transparent}.pagination ul>li:first-child>a,.pagination ul>li:first-child>span{border-left-width:1px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-bottomleft:4px;-moz-border-radius-topleft:4px}.pagination ul>li:last-child>a,.pagination ul>li:last-child>span{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-bottomright:4px}.pagination-centered{text-align:center}.pagination-right{text-align:right}.pagination-large ul>li>a,.pagination-large ul>li>span{padding:11px 19px;font-size:17.5px}.pagination-large ul>li:first-child>a,.pagination-large ul>li:first-child>span{-webkit-border-bottom-left-radius:6px;border-bottom-left-radius:6px;-webkit-border-top-left-radius:6px;border-top-left-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-topleft:6px}.pagination-large ul>li:last-child>a,.pagination-large ul>li:last-child>span{-webkit-border-top-right-radius:6px;border-top-right-radius:6px;-webkit-border-bottom-right-radius:6px;border-bottom-right-radius:6px;-moz-border-radius-topright:6px;-moz-border-radius-bottomright:6px}.pagination-mini ul>li:first-child>a,.pagination-small ul>li:first-child>a,.pagination-mini ul>li:first-child>span,.pagination-small ul>li:first-child>span{-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;-webkit-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-bottomleft:3px;-moz-border-radius-topleft:3px}.pagination-mini ul>li:last-child>a,.pagination-small ul>li:last-child>a,.pagination-mini ul>li:last-child>span,.pagination-small ul>li:last-child>span{-webkit-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px;-moz-border-radius-topright:3px;-moz-border-radius-bottomright:3px}.pagination-small ul>li>a,.pagination-small ul>li>span{padding:2px 10px;font-size:11.9px}.pagination-mini ul>li>a,.pagination-mini ul>li>span{padding:0 6px;font-size:10.5px}.pager{margin:20px 0;text-align:center;list-style:none;*zoom:1}.pager:before,.pager:after{display:table;line-height:0;content:""}.pager:after{clear:both}.pager li{display:inline}.pager li>a,.pager li>span{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.pager li>a:hover{text-decoration:none;background-color:#f5f5f5}.pager .next>a,.pager .next>span{float:right}.pager .previous>a,.pager .previous>span{float:left}.pager .disabled>a,.pager .disabled>a:hover,.pager .disabled>span{color:#999;cursor:default;background-color:#fff}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0}.modal-backdrop,.modal-backdrop.fade.in{opacity:.8;filter:alpha(opacity=80)}.modal{position:fixed;top:10%;left:50%;z-index:1050;width:560px;margin-left:-280px;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.3);*border:1px solid #999;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;outline:0;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.modal.fade{top:-25%;-webkit-transition:opacity .3s linear,top .3s ease-out;-moz-transition:opacity .3s linear,top .3s ease-out;-o-transition:opacity .3s linear,top .3s ease-out;transition:opacity .3s linear,top .3s ease-out}.modal.fade.in{top:10%}.modal-header{padding:9px 15px;border-bottom:1px solid #eee}.modal-header .close{margin-top:2px}.modal-header h3{margin:0;line-height:30px}.modal-body{position:relative;max-height:400px;padding:15px;overflow-y:auto}.modal-form{margin-bottom:0}.modal-footer{padding:14px 15px 15px;margin-bottom:0;text-align:right;background-color:#f5f5f5;border-top:1px solid #ddd;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;*zoom:1;-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.modal-footer:before,.modal-footer:after{display:table;line-height:0;content:""}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}.tooltip{position:absolute;z-index:1030;display:block;padding:5px;font-size:11px;opacity:0;filter:alpha(opacity=0);visibility:visible}.tooltip.in{opacity:.8;filter:alpha(opacity=80)}.tooltip.top{margin-top:-3px}.tooltip.right{margin-left:3px}.tooltip.bottom{margin-top:3px}.tooltip.left{margin-left:-3px}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-right-color:#000;border-width:5px 5px 5px 0}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-left-color:#000;border-width:5px 0 5px 5px}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-bottom-color:#000;border-width:0 5px 5px}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;width:236px;padding:1px;text-align:left;white-space:normal;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.popover.top{margin-top:-10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-left:-10px}.popover-title{padding:8px 14px;margin:0;font-size:14px;font-weight:normal;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.popover-content{padding:9px 14px}.popover .arrow,.popover .arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover .arrow{border-width:11px}.popover .arrow:after{border-width:10px;content:""}.popover.top .arrow{bottom:-11px;left:50%;margin-left:-11px;border-top-color:#999;border-top-color:rgba(0,0,0,0.25);border-bottom-width:0}.popover.top .arrow:after{bottom:1px;margin-left:-10px;border-top-color:#fff;border-bottom-width:0}.popover.right .arrow{top:50%;left:-11px;margin-top:-11px;border-right-color:#999;border-right-color:rgba(0,0,0,0.25);border-left-width:0}.popover.right .arrow:after{bottom:-10px;left:1px;border-right-color:#fff;border-left-width:0}.popover.bottom .arrow{top:-11px;left:50%;margin-left:-11px;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,0.25);border-top-width:0}.popover.bottom .arrow:after{top:1px;margin-left:-10px;border-bottom-color:#fff;border-top-width:0}.popover.left .arrow{top:50%;right:-11px;margin-top:-11px;border-left-color:#999;border-left-color:rgba(0,0,0,0.25);border-right-width:0}.popover.left .arrow:after{right:1px;bottom:-10px;border-left-color:#fff;border-right-width:0}.thumbnails{margin-left:-20px;list-style:none;*zoom:1}.thumbnails:before,.thumbnails:after{display:table;line-height:0;content:""}.thumbnails:after{clear:both}.row-fluid .thumbnails{margin-left:0}.thumbnails>li{float:left;margin-bottom:20px;margin-left:20px}.thumbnail{display:block;padding:4px;line-height:20px;border:1px solid #ddd;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.055);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.055);box-shadow:0 1px 3px rgba(0,0,0,0.055);-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out}a.thumbnail:hover{border-color:#08c;-webkit-box-shadow:0 1px 4px rgba(0,105,214,0.25);-moz-box-shadow:0 1px 4px rgba(0,105,214,0.25);box-shadow:0 1px 4px rgba(0,105,214,0.25)}.thumbnail>img{display:block;max-width:100%;margin-right:auto;margin-left:auto}.thumbnail .caption{padding:9px;color:#555}.media,.media-body{overflow:hidden;*overflow:visible;zoom:1}.media,.media .media{margin-top:15px}.media:first-child{margin-top:0}.media-object{display:block}.media-heading{margin:0 0 5px}.media .pull-left{margin-right:10px}.media .pull-right{margin-left:10px}.media-list{margin-left:0;list-style:none}.label,.badge{display:inline-block;padding:2px 4px;font-size:11.844px;font-weight:bold;line-height:14px;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);white-space:nowrap;vertical-align:baseline;background-color:#999}.label{-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.badge{padding-right:9px;padding-left:9px;-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px}.label:empty,.badge:empty{display:none}a.label:hover,a.badge:hover{color:#fff;text-decoration:none;cursor:pointer}.label-important,.badge-important{background-color:#b94a48}.label-important[href],.badge-important[href]{background-color:#953b39}.label-warning,.badge-warning{background-color:#f89406}.label-warning[href],.badge-warning[href]{background-color:#c67605}.label-success,.badge-success{background-color:#468847}.label-success[href],.badge-success[href]{background-color:#356635}.label-info,.badge-info{background-color:#3a87ad}.label-info[href],.badge-info[href]{background-color:#2d6987}.label-inverse,.badge-inverse{background-color:#333}.label-inverse[href],.badge-inverse[href]{background-color:#1a1a1a}.btn .label,.btn .badge{position:relative;top:-1px}.btn-mini .label,.btn-mini .badge{top:0}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-moz-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-ms-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-o-keyframes progress-bar-stripes{from{background-position:0 0}to{background-position:40px 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f7f7f7;background-image:-moz-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f5f5f5),to(#f9f9f9));background-image:-webkit-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-o-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:linear-gradient(to bottom,#f5f5f5,#f9f9f9);background-repeat:repeat-x;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5',endColorstr='#fff9f9f9',GradientType=0);-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress .bar{float:left;width:0;height:100%;font-size:12px;color:#fff;text-align:center;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#0e90d2;background-image:-moz-linear-gradient(top,#149bdf,#0480be);background-image:-webkit-gradient(linear,0 0,0 100%,from(#149bdf),to(#0480be));background-image:-webkit-linear-gradient(top,#149bdf,#0480be);background-image:-o-linear-gradient(top,#149bdf,#0480be);background-image:linear-gradient(to bottom,#149bdf,#0480be);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff149bdf',endColorstr='#ff0480be',GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-moz-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:width .6s ease;-moz-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease}.progress .bar+.bar{-webkit-box-shadow:inset 1px 0 0 rgba(0,0,0,0.15),inset 0 -1px 0 rgba(0,0,0,0.15);-moz-box-shadow:inset 1px 0 0 rgba(0,0,0,0.15),inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 1px 0 0 rgba(0,0,0,0.15),inset 0 -1px 0 rgba(0,0,0,0.15)}.progress-striped .bar{background-color:#149bdf;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);-webkit-background-size:40px 40px;-moz-background-size:40px 40px;-o-background-size:40px 40px;background-size:40px 40px}.progress.active .bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-moz-animation:progress-bar-stripes 2s linear infinite;-ms-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-danger .bar,.progress .bar-danger{background-color:#dd514c;background-image:-moz-linear-gradient(top,#ee5f5b,#c43c35);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#c43c35));background-image:-webkit-linear-gradient(top,#ee5f5b,#c43c35);background-image:-o-linear-gradient(top,#ee5f5b,#c43c35);background-image:linear-gradient(to bottom,#ee5f5b,#c43c35);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b',endColorstr='#ffc43c35',GradientType=0)}.progress-danger.progress-striped .bar,.progress-striped .bar-danger{background-color:#ee5f5b;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-success .bar,.progress .bar-success{background-color:#5eb95e;background-image:-moz-linear-gradient(top,#62c462,#57a957);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#57a957));background-image:-webkit-linear-gradient(top,#62c462,#57a957);background-image:-o-linear-gradient(top,#62c462,#57a957);background-image:linear-gradient(to bottom,#62c462,#57a957);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462',endColorstr='#ff57a957',GradientType=0)}.progress-success.progress-striped .bar,.progress-striped .bar-success{background-color:#62c462;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-info .bar,.progress .bar-info{background-color:#4bb1cf;background-image:-moz-linear-gradient(top,#5bc0de,#339bb9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#339bb9));background-image:-webkit-linear-gradient(top,#5bc0de,#339bb9);background-image:-o-linear-gradient(top,#5bc0de,#339bb9);background-image:linear-gradient(to bottom,#5bc0de,#339bb9);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de',endColorstr='#ff339bb9',GradientType=0)}.progress-info.progress-striped .bar,.progress-striped .bar-info{background-color:#5bc0de;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-warning .bar,.progress .bar-warning{background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450',endColorstr='#fff89406',GradientType=0)}.progress-warning.progress-striped .bar,.progress-striped .bar-warning{background-color:#fbb450;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.accordion{margin-bottom:20px}.accordion-group{margin-bottom:2px;border:1px solid #e5e5e5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.accordion-heading{border-bottom:0}.accordion-heading .accordion-toggle{display:block;padding:8px 15px}.accordion-toggle{cursor:pointer}.accordion-inner{padding:9px 15px;border-top:1px solid #e5e5e5}.carousel{position:relative;margin-bottom:20px;line-height:1}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner>.item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;-moz-transition:.6s ease-in-out left;-o-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel-inner>.item>img{display:block;line-height:1}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{left:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{left:100%}.carousel-inner>.prev{left:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{left:0}.carousel-inner>.active.left{left:-100%}.carousel-inner>.active.right{left:100%}.carousel-control{position:absolute;top:40%;left:15px;width:40px;height:40px;margin-top:-20px;font-size:60px;font-weight:100;line-height:30px;color:#fff;text-align:center;background:#222;border:3px solid #fff;-webkit-border-radius:23px;-moz-border-radius:23px;border-radius:23px;opacity:.5;filter:alpha(opacity=50)}.carousel-control.right{right:15px;left:auto}.carousel-control:hover{color:#fff;text-decoration:none;opacity:.9;filter:alpha(opacity=90)}.carousel-caption{position:absolute;right:0;bottom:0;left:0;padding:15px;background:#333;background:rgba(0,0,0,0.75)}.carousel-caption h4,.carousel-caption p{line-height:20px;color:#fff}.carousel-caption h4{margin:0 0 5px}.carousel-caption p{margin-bottom:0}.hero-unit{padding:60px;margin-bottom:30px;font-size:18px;font-weight:200;line-height:30px;color:inherit;background-color:#eee;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.hero-unit h1{margin-bottom:0;font-size:60px;line-height:1;letter-spacing:-1px;color:inherit}.hero-unit li{line-height:30px}.pull-right{float:right}.pull-left{float:left}.hide{display:none}.show{display:block}.invisible{visibility:hidden}.affix{position:fixed}
7.13 +/*!
7.14 + * Bootstrap Responsive v2.2.2
7.15 + *
7.16 + * Copyright 2012 Twitter, Inc
7.17 + * Licensed under the Apache License v2.0
7.18 + * http://www.apache.org/licenses/LICENSE-2.0
7.19 + *
7.20 + * Designed and built with all the love in the world @twitter by @mdo and @fat.
7.21 + */@-ms-viewport{width:device-width}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.hidden{display:none;visibility:hidden}.visible-phone{display:none!important}.visible-tablet{display:none!important}.hidden-desktop{display:none!important}.visible-desktop{display:inherit!important}@media(min-width:768px) and (max-width:979px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-tablet{display:inherit!important}.hidden-tablet{display:none!important}}@media(max-width:767px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-phone{display:inherit!important}.hidden-phone{display:none!important}}@media(min-width:1200px){.row{margin-left:-30px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:30px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1170px}.span12{width:1170px}.span11{width:1070px}.span10{width:970px}.span9{width:870px}.span8{width:770px}.span7{width:670px}.span6{width:570px}.span5{width:470px}.span4{width:370px}.span3{width:270px}.span2{width:170px}.span1{width:70px}.offset12{margin-left:1230px}.offset11{margin-left:1130px}.offset10{margin-left:1030px}.offset9{margin-left:930px}.offset8{margin-left:830px}.offset7{margin-left:730px}.offset6{margin-left:630px}.offset5{margin-left:530px}.offset4{margin-left:430px}.offset3{margin-left:330px}.offset2{margin-left:230px}.offset1{margin-left:130px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.564102564102564%;*margin-left:2.5109110747408616%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.564102564102564%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.45299145299145%;*width:91.39979996362975%}.row-fluid .span10{width:82.90598290598291%;*width:82.8527914166212%}.row-fluid .span9{width:74.35897435897436%;*width:74.30578286961266%}.row-fluid .span8{width:65.81196581196582%;*width:65.75877432260411%}.row-fluid .span7{width:57.26495726495726%;*width:57.21176577559556%}.row-fluid .span6{width:48.717948717948715%;*width:48.664757228587014%}.row-fluid .span5{width:40.17094017094017%;*width:40.11774868157847%}.row-fluid .span4{width:31.623931623931625%;*width:31.570740134569924%}.row-fluid .span3{width:23.076923076923077%;*width:23.023731587561375%}.row-fluid .span2{width:14.52991452991453%;*width:14.476723040552828%}.row-fluid .span1{width:5.982905982905983%;*width:5.929714493544281%}.row-fluid .offset12{margin-left:105.12820512820512%;*margin-left:105.02182214948171%}.row-fluid .offset12:first-child{margin-left:102.56410256410257%;*margin-left:102.45771958537915%}.row-fluid .offset11{margin-left:96.58119658119658%;*margin-left:96.47481360247316%}.row-fluid .offset11:first-child{margin-left:94.01709401709402%;*margin-left:93.91071103837061%}.row-fluid .offset10{margin-left:88.03418803418803%;*margin-left:87.92780505546462%}.row-fluid .offset10:first-child{margin-left:85.47008547008548%;*margin-left:85.36370249136206%}.row-fluid .offset9{margin-left:79.48717948717949%;*margin-left:79.38079650845607%}.row-fluid .offset9:first-child{margin-left:76.92307692307693%;*margin-left:76.81669394435352%}.row-fluid .offset8{margin-left:70.94017094017094%;*margin-left:70.83378796144753%}.row-fluid .offset8:first-child{margin-left:68.37606837606839%;*margin-left:68.26968539734497%}.row-fluid .offset7{margin-left:62.393162393162385%;*margin-left:62.28677941443899%}.row-fluid .offset7:first-child{margin-left:59.82905982905982%;*margin-left:59.72267685033642%}.row-fluid .offset6{margin-left:53.84615384615384%;*margin-left:53.739770867430444%}.row-fluid .offset6:first-child{margin-left:51.28205128205128%;*margin-left:51.175668303327875%}.row-fluid .offset5{margin-left:45.299145299145295%;*margin-left:45.1927623204219%}.row-fluid .offset5:first-child{margin-left:42.73504273504273%;*margin-left:42.62865975631933%}.row-fluid .offset4{margin-left:36.75213675213675%;*margin-left:36.645753773413354%}.row-fluid .offset4:first-child{margin-left:34.18803418803419%;*margin-left:34.081651209310785%}.row-fluid .offset3{margin-left:28.205128205128204%;*margin-left:28.0987452264048%}.row-fluid .offset3:first-child{margin-left:25.641025641025642%;*margin-left:25.53464266230224%}.row-fluid .offset2{margin-left:19.65811965811966%;*margin-left:19.551736679396257%}.row-fluid .offset2:first-child{margin-left:17.094017094017094%;*margin-left:16.98763411529369%}.row-fluid .offset1{margin-left:11.11111111111111%;*margin-left:11.004728132387708%}.row-fluid .offset1:first-child{margin-left:8.547008547008547%;*margin-left:8.440625568285142%}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:30px}input.span12,textarea.span12,.uneditable-input.span12{width:1156px}input.span11,textarea.span11,.uneditable-input.span11{width:1056px}input.span10,textarea.span10,.uneditable-input.span10{width:956px}input.span9,textarea.span9,.uneditable-input.span9{width:856px}input.span8,textarea.span8,.uneditable-input.span8{width:756px}input.span7,textarea.span7,.uneditable-input.span7{width:656px}input.span6,textarea.span6,.uneditable-input.span6{width:556px}input.span5,textarea.span5,.uneditable-input.span5{width:456px}input.span4,textarea.span4,.uneditable-input.span4{width:356px}input.span3,textarea.span3,.uneditable-input.span3{width:256px}input.span2,textarea.span2,.uneditable-input.span2{width:156px}input.span1,textarea.span1,.uneditable-input.span1{width:56px}.thumbnails{margin-left:-30px}.thumbnails>li{margin-left:30px}.row-fluid .thumbnails{margin-left:0}}@media(min-width:768px) and (max-width:979px){.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:724px}.span12{width:724px}.span11{width:662px}.span10{width:600px}.span9{width:538px}.span8{width:476px}.span7{width:414px}.span6{width:352px}.span5{width:290px}.span4{width:228px}.span3{width:166px}.span2{width:104px}.span1{width:42px}.offset12{margin-left:764px}.offset11{margin-left:702px}.offset10{margin-left:640px}.offset9{margin-left:578px}.offset8{margin-left:516px}.offset7{margin-left:454px}.offset6{margin-left:392px}.offset5{margin-left:330px}.offset4{margin-left:268px}.offset3{margin-left:206px}.offset2{margin-left:144px}.offset1{margin-left:82px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.7624309392265194%;*margin-left:2.709239449864817%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.7624309392265194%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.43646408839778%;*width:91.38327259903608%}.row-fluid .span10{width:82.87292817679558%;*width:82.81973668743387%}.row-fluid .span9{width:74.30939226519337%;*width:74.25620077583166%}.row-fluid .span8{width:65.74585635359117%;*width:65.69266486422946%}.row-fluid .span7{width:57.18232044198895%;*width:57.12912895262725%}.row-fluid .span6{width:48.61878453038674%;*width:48.56559304102504%}.row-fluid .span5{width:40.05524861878453%;*width:40.00205712942283%}.row-fluid .span4{width:31.491712707182323%;*width:31.43852121782062%}.row-fluid .span3{width:22.92817679558011%;*width:22.87498530621841%}.row-fluid .span2{width:14.3646408839779%;*width:14.311449394616199%}.row-fluid .span1{width:5.801104972375691%;*width:5.747913483013988%}.row-fluid .offset12{margin-left:105.52486187845304%;*margin-left:105.41847889972962%}.row-fluid .offset12:first-child{margin-left:102.76243093922652%;*margin-left:102.6560479605031%}.row-fluid .offset11{margin-left:96.96132596685082%;*margin-left:96.8549429881274%}.row-fluid .offset11:first-child{margin-left:94.1988950276243%;*margin-left:94.09251204890089%}.row-fluid .offset10{margin-left:88.39779005524862%;*margin-left:88.2914070765252%}.row-fluid .offset10:first-child{margin-left:85.6353591160221%;*margin-left:85.52897613729868%}.row-fluid .offset9{margin-left:79.8342541436464%;*margin-left:79.72787116492299%}.row-fluid .offset9:first-child{margin-left:77.07182320441989%;*margin-left:76.96544022569647%}.row-fluid .offset8{margin-left:71.2707182320442%;*margin-left:71.16433525332079%}.row-fluid .offset8:first-child{margin-left:68.50828729281768%;*margin-left:68.40190431409427%}.row-fluid .offset7{margin-left:62.70718232044199%;*margin-left:62.600799341718584%}.row-fluid .offset7:first-child{margin-left:59.94475138121547%;*margin-left:59.838368402492065%}.row-fluid .offset6{margin-left:54.14364640883978%;*margin-left:54.037263430116376%}.row-fluid .offset6:first-child{margin-left:51.38121546961326%;*margin-left:51.27483249088986%}.row-fluid .offset5{margin-left:45.58011049723757%;*margin-left:45.47372751851417%}.row-fluid .offset5:first-child{margin-left:42.81767955801105%;*margin-left:42.71129657928765%}.row-fluid .offset4{margin-left:37.01657458563536%;*margin-left:36.91019160691196%}.row-fluid .offset4:first-child{margin-left:34.25414364640884%;*margin-left:34.14776066768544%}.row-fluid .offset3{margin-left:28.45303867403315%;*margin-left:28.346655695309746%}.row-fluid .offset3:first-child{margin-left:25.69060773480663%;*margin-left:25.584224756083227%}.row-fluid .offset2{margin-left:19.88950276243094%;*margin-left:19.783119783707537%}.row-fluid .offset2:first-child{margin-left:17.12707182320442%;*margin-left:17.02068884448102%}.row-fluid .offset1{margin-left:11.32596685082873%;*margin-left:11.219583872105325%}.row-fluid .offset1:first-child{margin-left:8.56353591160221%;*margin-left:8.457152932878806%}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:20px}input.span12,textarea.span12,.uneditable-input.span12{width:710px}input.span11,textarea.span11,.uneditable-input.span11{width:648px}input.span10,textarea.span10,.uneditable-input.span10{width:586px}input.span9,textarea.span9,.uneditable-input.span9{width:524px}input.span8,textarea.span8,.uneditable-input.span8{width:462px}input.span7,textarea.span7,.uneditable-input.span7{width:400px}input.span6,textarea.span6,.uneditable-input.span6{width:338px}input.span5,textarea.span5,.uneditable-input.span5{width:276px}input.span4,textarea.span4,.uneditable-input.span4{width:214px}input.span3,textarea.span3,.uneditable-input.span3{width:152px}input.span2,textarea.span2,.uneditable-input.span2{width:90px}input.span1,textarea.span1,.uneditable-input.span1{width:28px}}@media(max-width:767px){body{padding-right:20px;padding-left:20px}.navbar-fixed-top,.navbar-fixed-bottom,.navbar-static-top{margin-right:-20px;margin-left:-20px}.container-fluid{padding:0}.dl-horizontal dt{float:none;width:auto;clear:none;text-align:left}.dl-horizontal dd{margin-left:0}.container{width:auto}.row-fluid{width:100%}.row,.thumbnails{margin-left:0}.thumbnails>li{float:none;margin-left:0}[class*="span"],.uneditable-input[class*="span"],.row-fluid [class*="span"]{display:block;float:none;width:100%;margin-left:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.span12,.row-fluid .span12{width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="offset"]:first-child{margin-left:0}.input-large,.input-xlarge,.input-xxlarge,input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.input-prepend input,.input-append input,.input-prepend input[class*="span"],.input-append input[class*="span"]{display:inline-block;width:auto}.controls-row [class*="span"]+[class*="span"]{margin-left:0}.modal{position:fixed;top:20px;right:20px;left:20px;width:auto;margin:0}.modal.fade{top:-100px}.modal.fade.in{top:20px}}@media(max-width:480px){.nav-collapse{-webkit-transform:translate3d(0,0,0)}.page-header h1 small{display:block;line-height:20px}input[type="checkbox"],input[type="radio"]{border:1px solid #ccc}.form-horizontal .control-label{float:none;width:auto;padding-top:0;text-align:left}.form-horizontal .controls{margin-left:0}.form-horizontal .control-list{padding-top:0}.form-horizontal .form-actions{padding-right:10px;padding-left:10px}.media .pull-left,.media .pull-right{display:block;float:none;margin-bottom:10px}.media-object{margin-right:0;margin-left:0}.modal{top:10px;right:10px;left:10px}.modal-header .close{padding:10px;margin:-10px}.carousel-caption{position:static}}@media(max-width:979px){body{padding-top:0}.navbar-fixed-top,.navbar-fixed-bottom{position:static}.navbar-fixed-top{margin-bottom:20px}.navbar-fixed-bottom{margin-top:20px}.navbar-fixed-top .navbar-inner,.navbar-fixed-bottom .navbar-inner{padding:5px}.navbar .container{width:auto;padding:0}.navbar .brand{padding-right:10px;padding-left:10px;margin:0 0 0 -5px}.nav-collapse{clear:both}.nav-collapse .nav{float:none;margin:0 0 10px}.nav-collapse .nav>li{float:none}.nav-collapse .nav>li>a{margin-bottom:2px}.nav-collapse .nav>.divider-vertical{display:none}.nav-collapse .nav .nav-header{color:#777;text-shadow:none}.nav-collapse .nav>li>a,.nav-collapse .dropdown-menu a{padding:9px 15px;font-weight:bold;color:#777;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.nav-collapse .btn{padding:4px 10px 4px;font-weight:normal;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.nav-collapse .dropdown-menu li+li a{margin-bottom:2px}.nav-collapse .nav>li>a:hover,.nav-collapse .dropdown-menu a:hover{background-color:#f2f2f2}.navbar-inverse .nav-collapse .nav>li>a,.navbar-inverse .nav-collapse .dropdown-menu a{color:#999}.navbar-inverse .nav-collapse .nav>li>a:hover,.navbar-inverse .nav-collapse .dropdown-menu a:hover{background-color:#111}.nav-collapse.in .btn-group{padding:0;margin-top:5px}.nav-collapse .dropdown-menu{position:static;top:auto;left:auto;display:none;float:none;max-width:none;padding:0;margin:0 15px;background-color:transparent;border:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.nav-collapse .open>.dropdown-menu{display:block}.nav-collapse .dropdown-menu:before,.nav-collapse .dropdown-menu:after{display:none}.nav-collapse .dropdown-menu .divider{display:none}.nav-collapse .nav>li>.dropdown-menu:before,.nav-collapse .nav>li>.dropdown-menu:after{display:none}.nav-collapse .navbar-form,.nav-collapse .navbar-search{float:none;padding:10px 15px;margin:10px 0;border-top:1px solid #f2f2f2;border-bottom:1px solid #f2f2f2;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1)}.navbar-inverse .nav-collapse .navbar-form,.navbar-inverse .nav-collapse .navbar-search{border-top-color:#111;border-bottom-color:#111}.navbar .nav-collapse .nav.pull-right{float:none;margin-left:0}.nav-collapse,.nav-collapse.collapse{height:0;overflow:hidden}.navbar .btn-navbar{display:block}.navbar-static .navbar-inner{padding-right:10px;padding-left:10px}}@media(min-width:980px){.nav-collapse.collapse{height:auto!important;overflow:visible!important}}
8.1 Binary file dew/src/main/resources/org/apidesign/bck2brwsr/dew/img/error.png has changed
9.1 Binary file dew/src/main/resources/org/apidesign/bck2brwsr/dew/img/glyphicons-halflings-white.png has changed
10.1 Binary file dew/src/main/resources/org/apidesign/bck2brwsr/dew/img/glyphicons-halflings.png has changed
11.1 Binary file dew/src/main/resources/org/apidesign/bck2brwsr/dew/img/html5.png has changed
12.1 Binary file dew/src/main/resources/org/apidesign/bck2brwsr/dew/img/java.png has changed
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/dew/src/main/resources/org/apidesign/bck2brwsr/dew/index.html Wed Jan 23 14:16:13 2013 +0100
13.3 @@ -0,0 +1,98 @@
13.4 +<!--
13.5 +To change this template, choose Tools | Templates
13.6 +and open the template in the editor.
13.7 +-->
13.8 +<!DOCTYPE html>
13.9 +<html lang="en" ng-app="bck2brwsr" ng-controller="DevCtrl">
13.10 + <head>
13.11 + <title>Back2Browser - DEW</title>
13.12 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
13.13 + <meta name="viewport" content="width=device-width, initial-scale=1.0">
13.14 + <link rel="stylesheet" href="css/bootstrap-combined.min.css"/>
13.15 + <link rel="stylesheet" href="js/codemirror/codemirror.css">
13.16 + <link rel="stylesheet" href="js/codemirror/theme/elegant.css"/>
13.17 + <link rel="stylesheet" href="css/app.css"/>
13.18 + </head>
13.19 + <body>
13.20 +
13.21 + <div class="navbar navbar-fixed-top" style="width: 100%">
13.22 + <div class="navbar-inner" style="padding-left: 12px; padding-right: 12px;">
13.23 + <!-- a class="brand" style="font-size: 100%"><span class="text-info"><b>Java and HTML5</b></span><small>- Together at Last!</small></a-->
13.24 + <form class="navbar-form pull-right">
13.25 + <!-- select class="span2"></select -->
13.26 + <button ng-click="post()" class="btn btn-warning">Rebuild</button>
13.27 + </form>
13.28 + <!-- ul class="nav">
13.29 + <li><select class="btn-small" type="text"></select></li>
13.30 + </ul -->
13.31 + <!-- form class="form form-horizontal pull-right">
13.32 + <button class="btn btn-warning btn-small pull-right top" ng-click="post()">Rebuild</button>
13.33 + </form -->
13.34 + <!-- ul class="nav pull-right">
13.35 +
13.36 + </ul-->
13.37 + </div>
13.38 + </div>
13.39 +
13.40 + <div class="container-fluid">
13.41 +
13.42 + <div style="height: 4em;"> </div>
13.43 +
13.44 + <div class="row-fluid">
13.45 + <div class="span6" style="margin-bottom: 10px;">
13.46 + <table class="table table-condensed" style="margin-bottom: 2px">
13.47 + <tr><td><i class="ic-html5"></i> HTML5</td></tr>
13.48 + </table>
13.49 + <div>
13.50 + <textarea ui-codemirror='{ lineNumbers : true, mode : "xml", theme : "elegant", matchBrackets : true, lineWrapping : true }' ng-model="html"></textarea>
13.51 + <div class="alert alert-error" ng-show="doc.modelError">
13.52 + <small>{{doc.modelError.toString()}}</small>
13.53 + </div>
13.54 + </div>
13.55 + </div>
13.56 +
13.57 + <div class="span6">
13.58 + <table class="table table-condensed" style="margin-bottom: 2px">
13.59 + <tr><td><i class="ic-java"></i> Java</td></tr>
13.60 + </table>
13.61 + <div>
13.62 + <textarea id="editorJava" ui-codemirror='{ lineNumbers : true, mode : "text/x-java", theme : "elegant", matchBrackets : true, lineWrapping : true, gutters: ["CodeMirror-linenumbers", "issues"] }' ng-model="java"></textarea>
13.63 + <div class="alert alert-error" ng-show="doc.modelError">
13.64 + <small>{{doc.modelError.toString()}}</small>
13.65 + </div>
13.66 + </div>
13.67 + </div>
13.68 +
13.69 + </div>
13.70 +
13.71 + <table class="table table-condensed">
13.72 + <tr ng-click="gotoError(e.line, e.col)" ng-repeat="e in errors" ng-class="errorClass(e.kind)">
13.73 + <td style="text-align: right">{{e.line}}</td>
13.74 + <td>:</td>
13.75 + <td style="text-align: left">{{e.col}}</td>
13.76 + <td width="100%" class="text-error error-hover">{{e.msg}} <i class="icon-play"/></td>
13.77 + </tr>
13.78 + </table>
13.79 +
13.80 +
13.81 + <div> </div>
13.82 +
13.83 + <ul class="nav nav-tabs">
13.84 + <li ng-class="'active'"><a href="#">Result</a></li>
13.85 + </ul>
13.86 +
13.87 +
13.88 + <!-- button class="btn" ng-click="reload()">Reload</button -->
13.89 + <iframe id="result" frameborder="0" scrolling="yes" width="100%" style="height: 1000px; overflow: auto; border: 1px solid #DFDFDF;" src="result.html">
13.90 + <p>Your browser does not support iframes.</p>
13.91 + </iframe>
13.92 +
13.93 + </div>
13.94 +
13.95 + <script src="js/angular/angular.min.js"></script>
13.96 + <script src="js/codemirror/codemirror.js"></script>
13.97 + <script src="js/codemirror/mode/xml.js"></script>
13.98 + <script src="js/codemirror/mode/clike.js"></script>
13.99 + <script src="js/app.js"></script>
13.100 + </body>
13.101 +</html>
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/dew/src/main/resources/org/apidesign/bck2brwsr/dew/js/angular/angular.min.js Wed Jan 23 14:16:13 2013 +0100
14.3 @@ -0,0 +1,159 @@
14.4 +/*
14.5 + AngularJS v1.0.3
14.6 + (c) 2010-2012 Google, Inc. http://angularjs.org
14.7 + License: MIT
14.8 +*/
14.9 +(function(U,ca,p){'use strict';function m(b,a,c){var d;if(b)if(N(b))for(d in b)d!="prototype"&&d!="length"&&d!="name"&&b.hasOwnProperty(d)&&a.call(c,b[d],d);else if(b.forEach&&b.forEach!==m)b.forEach(a,c);else if(L(b)&&wa(b.length))for(d=0;d<b.length;d++)a.call(c,b[d],d);else for(d in b)b.hasOwnProperty(d)&&a.call(c,b[d],d);return b}function lb(b){var a=[],c;for(c in b)b.hasOwnProperty(c)&&a.push(c);return a.sort()}function ec(b,a,c){for(var d=lb(b),e=0;e<d.length;e++)a.call(c,b[d[e]],d[e]);return d}
14.10 +function mb(b){return function(a,c){b(c,a)}}function xa(){for(var b=Z.length,a;b;){b--;a=Z[b].charCodeAt(0);if(a==57)return Z[b]="A",Z.join("");if(a==90)Z[b]="0";else return Z[b]=String.fromCharCode(a+1),Z.join("")}Z.unshift("0");return Z.join("")}function x(b){m(arguments,function(a){a!==b&&m(a,function(a,d){b[d]=a})});return b}function G(b){return parseInt(b,10)}function ya(b,a){return x(new (x(function(){},{prototype:b})),a)}function D(){}function ma(b){return b}function I(b){return function(){return b}}
14.11 +function t(b){return typeof b=="undefined"}function v(b){return typeof b!="undefined"}function L(b){return b!=null&&typeof b=="object"}function F(b){return typeof b=="string"}function wa(b){return typeof b=="number"}function na(b){return Sa.apply(b)=="[object Date]"}function J(b){return Sa.apply(b)=="[object Array]"}function N(b){return typeof b=="function"}function oa(b){return b&&b.document&&b.location&&b.alert&&b.setInterval}function R(b){return F(b)?b.replace(/^\s*/,"").replace(/\s*$/,""):b}function fc(b){return b&&
14.12 +(b.nodeName||b.bind&&b.find)}function Ta(b,a,c){var d=[];m(b,function(b,g,i){d.push(a.call(c,b,g,i))});return d}function gc(b,a){var c=0,d;if(J(b)||F(b))return b.length;else if(L(b))for(d in b)(!a||b.hasOwnProperty(d))&&c++;return c}function za(b,a){if(b.indexOf)return b.indexOf(a);for(var c=0;c<b.length;c++)if(a===b[c])return c;return-1}function Ua(b,a){var c=za(b,a);c>=0&&b.splice(c,1);return a}function V(b,a){if(oa(b)||b&&b.$evalAsync&&b.$watch)throw B("Can't copy Window or Scope");if(a){if(b===
14.13 +a)throw B("Can't copy equivalent objects or arrays");if(J(b)){for(;a.length;)a.pop();for(var c=0;c<b.length;c++)a.push(V(b[c]))}else for(c in m(a,function(b,c){delete a[c]}),b)a[c]=V(b[c])}else(a=b)&&(J(b)?a=V(b,[]):na(b)?a=new Date(b.getTime()):L(b)&&(a=V(b,{})));return a}function hc(b,a){var a=a||{},c;for(c in b)b.hasOwnProperty(c)&&c.substr(0,2)!=="$$"&&(a[c]=b[c]);return a}function ha(b,a){if(b===a)return!0;if(b===null||a===null)return!1;if(b!==b&&a!==a)return!0;var c=typeof b,d;if(c==typeof a&&
14.14 +c=="object")if(J(b)){if((c=b.length)==a.length){for(d=0;d<c;d++)if(!ha(b[d],a[d]))return!1;return!0}}else if(na(b))return na(a)&&b.getTime()==a.getTime();else{if(b&&b.$evalAsync&&b.$watch||a&&a.$evalAsync&&a.$watch||oa(b)||oa(a))return!1;c={};for(d in b){if(d.charAt(0)!=="$"&&!N(b[d])&&!ha(b[d],a[d]))return!1;c[d]=!0}for(d in a)if(!c[d]&&d.charAt(0)!=="$"&&!N(a[d]))return!1;return!0}return!1}function Va(b,a){var c=arguments.length>2?ia.call(arguments,2):[];return N(a)&&!(a instanceof RegExp)?c.length?
14.15 +function(){return arguments.length?a.apply(b,c.concat(ia.call(arguments,0))):a.apply(b,c)}:function(){return arguments.length?a.apply(b,arguments):a.call(b)}:a}function ic(b,a){var c=a;/^\$+/.test(b)?c=p:oa(a)?c="$WINDOW":a&&ca===a?c="$DOCUMENT":a&&a.$evalAsync&&a.$watch&&(c="$SCOPE");return c}function da(b,a){return JSON.stringify(b,ic,a?" ":null)}function nb(b){return F(b)?JSON.parse(b):b}function Wa(b){b&&b.length!==0?(b=E(""+b),b=!(b=="f"||b=="0"||b=="false"||b=="no"||b=="n"||b=="[]")):b=!1;
14.16 +return b}function pa(b){b=u(b).clone();try{b.html("")}catch(a){}return u("<div>").append(b).html().match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/,function(a,b){return"<"+E(b)})}function Xa(b){var a={},c,d;m((b||"").split("&"),function(b){b&&(c=b.split("="),d=decodeURIComponent(c[0]),a[d]=v(c[1])?decodeURIComponent(c[1]):!0)});return a}function ob(b){var a=[];m(b,function(b,d){a.push(Ya(d,!0)+(b===!0?"":"="+Ya(b,!0)))});return a.length?a.join("&"):""}function Za(b){return Ya(b,!0).replace(/%26/gi,"&").replace(/%3D/gi,
14.17 +"=").replace(/%2B/gi,"+")}function Ya(b,a){return encodeURIComponent(b).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(a?null:/%20/g,"+")}function jc(b,a){function c(a){a&&d.push(a)}var d=[b],e,g,i=["ng:app","ng-app","x-ng-app","data-ng-app"],f=/\sng[:\-]app(:\s*([\w\d_]+);?)?\s/;m(i,function(a){i[a]=!0;c(ca.getElementById(a));a=a.replace(":","\\:");b.querySelectorAll&&(m(b.querySelectorAll("."+a),c),m(b.querySelectorAll("."+a+"\\:"),c),m(b.querySelectorAll("["+
14.18 +a+"]"),c))});m(d,function(a){if(!e){var b=f.exec(" "+a.className+" ");b?(e=a,g=(b[2]||"").replace(/\s+/g,",")):m(a.attributes,function(b){if(!e&&i[b.name])e=a,g=b.value})}});e&&a(e,g?[g]:[])}function pb(b,a){b=u(b);a=a||[];a.unshift(["$provide",function(a){a.value("$rootElement",b)}]);a.unshift("ng");var c=qb(a);c.invoke(["$rootScope","$rootElement","$compile","$injector",function(a,b,c,i){a.$apply(function(){b.data("$injector",i);c(b)(a)})}]);return c}function $a(b,a){a=a||"_";return b.replace(kc,
14.19 +function(b,d){return(d?a:"")+b.toLowerCase()})}function qa(b,a,c){if(!b)throw new B("Argument '"+(a||"?")+"' is "+(c||"required"));return b}function ra(b,a,c){c&&J(b)&&(b=b[b.length-1]);qa(N(b),a,"not a function, got "+(b&&typeof b=="object"?b.constructor.name||"Object":typeof b));return b}function lc(b){function a(a,b,e){return a[b]||(a[b]=e())}return a(a(b,"angular",Object),"module",function(){var b={};return function(d,e,g){e&&b.hasOwnProperty(d)&&(b[d]=null);return a(b,d,function(){function a(c,
14.20 +d,e){return function(){b[e||"push"]([c,d,arguments]);return j}}if(!e)throw B("No module: "+d);var b=[],c=[],k=a("$injector","invoke"),j={_invokeQueue:b,_runBlocks:c,requires:e,name:d,provider:a("$provide","provider"),factory:a("$provide","factory"),service:a("$provide","service"),value:a("$provide","value"),constant:a("$provide","constant","unshift"),filter:a("$filterProvider","register"),controller:a("$controllerProvider","register"),directive:a("$compileProvider","directive"),config:k,run:function(a){c.push(a);
14.21 +return this}};g&&k(g);return j})}})}function rb(b){return b.replace(mc,function(a,b,d,e){return e?d.toUpperCase():d}).replace(nc,"Moz$1")}function ab(b,a){function c(){var e;for(var b=[this],c=a,i,f,h,k,j,l;b.length;){i=b.shift();f=0;for(h=i.length;f<h;f++){k=u(i[f]);c?k.triggerHandler("$destroy"):c=!c;j=0;for(e=(l=k.children()).length,k=e;j<k;j++)b.push(ja(l[j]))}}return d.apply(this,arguments)}var d=ja.fn[b],d=d.$original||d;c.$original=d;ja.fn[b]=c}function Q(b){if(b instanceof Q)return b;if(!(this instanceof
14.22 +Q)){if(F(b)&&b.charAt(0)!="<")throw B("selectors not implemented");return new Q(b)}if(F(b)){var a=ca.createElement("div");a.innerHTML="<div> </div>"+b;a.removeChild(a.firstChild);bb(this,a.childNodes);this.remove()}else bb(this,b)}function cb(b){return b.cloneNode(!0)}function sa(b){sb(b);for(var a=0,b=b.childNodes||[];a<b.length;a++)sa(b[a])}function tb(b,a,c){var d=$(b,"events");$(b,"handle")&&(t(a)?m(d,function(a,c){db(b,c,a);delete d[c]}):t(c)?(db(b,a,d[a]),delete d[a]):Ua(d[a],c))}function sb(b){var a=
14.23 +b[Aa],c=Ba[a];c&&(c.handle&&(c.events.$destroy&&c.handle({},"$destroy"),tb(b)),delete Ba[a],b[Aa]=p)}function $(b,a,c){var d=b[Aa],d=Ba[d||-1];if(v(c))d||(b[Aa]=d=++oc,d=Ba[d]={}),d[a]=c;else return d&&d[a]}function ub(b,a,c){var d=$(b,"data"),e=v(c),g=!e&&v(a),i=g&&!L(a);!d&&!i&&$(b,"data",d={});if(e)d[a]=c;else if(g)if(i)return d&&d[a];else x(d,a);else return d}function Ca(b,a){return(" "+b.className+" ").replace(/[\n\t]/g," ").indexOf(" "+a+" ")>-1}function vb(b,a){a&&m(a.split(" "),function(a){b.className=
14.24 +R((" "+b.className+" ").replace(/[\n\t]/g," ").replace(" "+R(a)+" "," "))})}function wb(b,a){a&&m(a.split(" "),function(a){if(!Ca(b,a))b.className=R(b.className+" "+R(a))})}function bb(b,a){if(a)for(var a=!a.nodeName&&v(a.length)&&!oa(a)?a:[a],c=0;c<a.length;c++)b.push(a[c])}function xb(b,a){return Da(b,"$"+(a||"ngController")+"Controller")}function Da(b,a,c){b=u(b);for(b[0].nodeType==9&&(b=b.find("html"));b.length;){if(c=b.data(a))return c;b=b.parent()}}function yb(b,a){var c=Ea[a.toLowerCase()];
14.25 +return c&&zb[b.nodeName]&&c}function pc(b,a){var c=function(c,e){if(!c.preventDefault)c.preventDefault=function(){c.returnValue=!1};if(!c.stopPropagation)c.stopPropagation=function(){c.cancelBubble=!0};if(!c.target)c.target=c.srcElement||ca;if(t(c.defaultPrevented)){var g=c.preventDefault;c.preventDefault=function(){c.defaultPrevented=!0;g.call(c)};c.defaultPrevented=!1}c.isDefaultPrevented=function(){return c.defaultPrevented};m(a[e||c.type],function(a){a.call(b,c)});aa<=8?(c.preventDefault=null,
14.26 +c.stopPropagation=null,c.isDefaultPrevented=null):(delete c.preventDefault,delete c.stopPropagation,delete c.isDefaultPrevented)};c.elem=b;return c}function ga(b){var a=typeof b,c;if(a=="object"&&b!==null)if(typeof(c=b.$$hashKey)=="function")c=b.$$hashKey();else{if(c===p)c=b.$$hashKey=xa()}else c=b;return a+":"+c}function Fa(b){m(b,this.put,this)}function eb(){}function Ab(b){var a,c;if(typeof b=="function"){if(!(a=b.$inject))a=[],c=b.toString().replace(qc,""),c=c.match(rc),m(c[1].split(sc),function(b){b.replace(tc,
14.27 +function(b,c,d){a.push(d)})}),b.$inject=a}else J(b)?(c=b.length-1,ra(b[c],"fn"),a=b.slice(0,c)):ra(b,"fn",!0);return a}function qb(b){function a(a){return function(b,c){if(L(b))m(b,mb(a));else return a(b,c)}}function c(a,b){N(b)&&(b=l.instantiate(b));if(!b.$get)throw B("Provider "+a+" must define $get factory method.");return j[a+f]=b}function d(a,b){return c(a,{$get:b})}function e(a){var b=[];m(a,function(a){if(!k.get(a))if(k.put(a,!0),F(a)){var c=ta(a);b=b.concat(e(c.requires)).concat(c._runBlocks);
14.28 +try{for(var d=c._invokeQueue,c=0,f=d.length;c<f;c++){var h=d[c],g=h[0]=="$injector"?l:l.get(h[0]);g[h[1]].apply(g,h[2])}}catch(n){throw n.message&&(n.message+=" from "+a),n;}}else if(N(a))try{b.push(l.invoke(a))}catch(i){throw i.message&&(i.message+=" from "+a),i;}else if(J(a))try{b.push(l.invoke(a))}catch(j){throw j.message&&(j.message+=" from "+String(a[a.length-1])),j;}else ra(a,"module")});return b}function g(a,b){function c(d){if(typeof d!=="string")throw B("Service name expected");if(a.hasOwnProperty(d)){if(a[d]===
14.29 +i)throw B("Circular dependency: "+h.join(" <- "));return a[d]}else try{return h.unshift(d),a[d]=i,a[d]=b(d)}finally{h.shift()}}function d(a,b,e){var f=[],k=Ab(a),g,n,i;n=0;for(g=k.length;n<g;n++)i=k[n],f.push(e&&e.hasOwnProperty(i)?e[i]:c(i,h));a.$inject||(a=a[g]);switch(b?-1:f.length){case 0:return a();case 1:return a(f[0]);case 2:return a(f[0],f[1]);case 3:return a(f[0],f[1],f[2]);case 4:return a(f[0],f[1],f[2],f[3]);case 5:return a(f[0],f[1],f[2],f[3],f[4]);case 6:return a(f[0],f[1],f[2],f[3],
14.30 +f[4],f[5]);case 7:return a(f[0],f[1],f[2],f[3],f[4],f[5],f[6]);case 8:return a(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7]);case 9:return a(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8]);case 10:return a(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],f[9]);default:return a.apply(b,f)}}return{invoke:d,instantiate:function(a,b){var c=function(){},e;c.prototype=(J(a)?a[a.length-1]:a).prototype;c=new c;e=d(a,c,b);return L(e)?e:c},get:c,annotate:Ab}}var i={},f="Provider",h=[],k=new Fa,j={$provide:{provider:a(c),
14.31 +factory:a(d),service:a(function(a,b){return d(a,["$injector",function(a){return a.instantiate(b)}])}),value:a(function(a,b){return d(a,I(b))}),constant:a(function(a,b){j[a]=b;o[a]=b}),decorator:function(a,b){var c=l.get(a+f),d=c.$get;c.$get=function(){var a=r.invoke(d,c);return r.invoke(b,null,{$delegate:a})}}}},l=g(j,function(){throw B("Unknown provider: "+h.join(" <- "));}),o={},r=o.$injector=g(o,function(a){a=l.get(a+f);return r.invoke(a.$get,a)});m(e(b),function(a){r.invoke(a||D)});return r}function uc(){var b=
14.32 +!0;this.disableAutoScrolling=function(){b=!1};this.$get=["$window","$location","$rootScope",function(a,c,d){function e(a){var b=null;m(a,function(a){!b&&E(a.nodeName)==="a"&&(b=a)});return b}function g(){var b=c.hash(),d;b?(d=i.getElementById(b))?d.scrollIntoView():(d=e(i.getElementsByName(b)))?d.scrollIntoView():b==="top"&&a.scrollTo(0,0):a.scrollTo(0,0)}var i=a.document;b&&d.$watch(function(){return c.hash()},function(){d.$evalAsync(g)});return g}]}function vc(b,a,c,d){function e(a){try{a.apply(null,
14.33 +ia.call(arguments,1))}finally{if(n--,n===0)for(;w.length;)try{w.pop()()}catch(b){c.error(b)}}}function g(a,b){(function ea(){m(q,function(a){a()});s=b(ea,a)})()}function i(){O!=f.url()&&(O=f.url(),m(A,function(a){a(f.url())}))}var f=this,h=a[0],k=b.location,j=b.history,l=b.setTimeout,o=b.clearTimeout,r={};f.isMock=!1;var n=0,w=[];f.$$completeOutstandingRequest=e;f.$$incOutstandingRequestCount=function(){n++};f.notifyWhenNoOutstandingRequests=function(a){m(q,function(a){a()});n===0?a():w.push(a)};
14.34 +var q=[],s;f.addPollFn=function(a){t(s)&&g(100,l);q.push(a);return a};var O=k.href,C=a.find("base");f.url=function(a,b){if(a){if(O!=a)return O=a,d.history?b?j.replaceState(null,"",a):(j.pushState(null,"",a),C.attr("href",C.attr("href"))):b?k.replace(a):k.href=a,f}else return k.href.replace(/%27/g,"'")};var A=[],K=!1;f.onUrlChange=function(a){K||(d.history&&u(b).bind("popstate",i),d.hashchange?u(b).bind("hashchange",i):f.addPollFn(i),K=!0);A.push(a);return a};f.baseHref=function(){var a=C.attr("href");
14.35 +return a?a.replace(/^https?\:\/\/[^\/]*/,""):a};var W={},y="",M=f.baseHref();f.cookies=function(a,b){var d,e,f,k;if(a)if(b===p)h.cookie=escape(a)+"=;path="+M+";expires=Thu, 01 Jan 1970 00:00:00 GMT";else{if(F(b))d=(h.cookie=escape(a)+"="+escape(b)+";path="+M).length+1,d>4096&&c.warn("Cookie '"+a+"' possibly not set or overflowed because it was too large ("+d+" > 4096 bytes)!"),W.length>20&&c.warn("Cookie '"+a+"' possibly not set or overflowed because too many cookies were already set ("+W.length+
14.36 +" > 20 )")}else{if(h.cookie!==y){y=h.cookie;d=y.split("; ");W={};for(f=0;f<d.length;f++)e=d[f],k=e.indexOf("="),k>0&&(W[unescape(e.substring(0,k))]=unescape(e.substring(k+1)))}return W}};f.defer=function(a,b){var c;n++;c=l(function(){delete r[c];e(a)},b||0);r[c]=!0;return c};f.defer.cancel=function(a){return r[a]?(delete r[a],o(a),e(D),!0):!1}}function wc(){this.$get=["$window","$log","$sniffer","$document",function(b,a,c,d){return new vc(b,d,a,c)}]}function xc(){this.$get=function(){function b(b,
14.37 +d){function e(a){if(a!=l){if(o){if(o==a)o=a.n}else o=a;g(a.n,a.p);g(a,l);l=a;l.n=null}}function g(a,b){if(a!=b){if(a)a.p=b;if(b)b.n=a}}if(b in a)throw B("cacheId "+b+" taken");var i=0,f=x({},d,{id:b}),h={},k=d&&d.capacity||Number.MAX_VALUE,j={},l=null,o=null;return a[b]={put:function(a,b){var c=j[a]||(j[a]={key:a});e(c);t(b)||(a in h||i++,h[a]=b,i>k&&this.remove(o.key))},get:function(a){var b=j[a];if(b)return e(b),h[a]},remove:function(a){var b=j[a];if(b){if(b==l)l=b.p;if(b==o)o=b.n;g(b.n,b.p);delete j[a];
14.38 +delete h[a];i--}},removeAll:function(){h={};i=0;j={};l=o=null},destroy:function(){j=f=h=null;delete a[b]},info:function(){return x({},f,{size:i})}}}var a={};b.info=function(){var b={};m(a,function(a,e){b[e]=a.info()});return b};b.get=function(b){return a[b]};return b}}function yc(){this.$get=["$cacheFactory",function(b){return b("templates")}]}function Bb(b){var a={},c="Directive",d=/^\s*directive\:\s*([\d\w\-_]+)\s+(.*)$/,e=/(([\d\w\-_]+)(?:\:([^;]+))?;?)/,g="Template must have exactly one root element. was: ";
14.39 +this.directive=function f(d,e){F(d)?(qa(e,"directive"),a.hasOwnProperty(d)||(a[d]=[],b.factory(d+c,["$injector","$exceptionHandler",function(b,c){var e=[];m(a[d],function(a){try{var f=b.invoke(a);if(N(f))f={compile:I(f)};else if(!f.compile&&f.link)f.compile=I(f.link);f.priority=f.priority||0;f.name=f.name||d;f.require=f.require||f.controller&&f.name;f.restrict=f.restrict||"A";e.push(f)}catch(k){c(k)}});return e}])),a[d].push(e)):m(d,mb(f));return this};this.$get=["$injector","$interpolate","$exceptionHandler",
14.40 +"$http","$templateCache","$parse","$controller","$rootScope",function(b,h,k,j,l,o,r,n){function w(a,b,c){a instanceof u||(a=u(a));m(a,function(b,c){b.nodeType==3&&(a[c]=u(b).wrap("<span></span>").parent()[0])});var d=s(a,b,a,c);return function(b,c){qa(b,"scope");var e=c?ua.clone.call(a):a;e.data("$scope",b);q(e,"ng-scope");c&&c(e,b);d&&d(b,e,e);return e}}function q(a,b){try{a.addClass(b)}catch(c){}}function s(a,b,c,d){function e(a,c,d,k){for(var g,h,j,n,o,l=0,r=0,q=f.length;l<q;r++)j=c[r],g=f[l++],
14.41 +h=f[l++],g?(g.scope?(n=a.$new(L(g.scope)),u(j).data("$scope",n)):n=a,(o=g.transclude)||!k&&b?g(h,n,j,d,function(b){return function(c){var d=a.$new();return b(d,c).bind("$destroy",Va(d,d.$destroy))}}(o||b)):g(h,n,j,p,k)):h&&h(a,j.childNodes,p,k)}for(var f=[],k,g,h,j=0;j<a.length;j++)g=new ea,k=O(a[j],[],g,d),g=(k=k.length?C(k,a[j],g,b,c):null)&&k.terminal||!a[j].childNodes.length?null:s(a[j].childNodes,k?k.transclude:b),f.push(k),f.push(g),h=h||k||g;return h?e:null}function O(a,b,c,f){var k=c.$attr,
14.42 +g;switch(a.nodeType){case 1:A(b,fa(Cb(a).toLowerCase()),"E",f);var h,j,n;g=a.attributes;for(var o=0,l=g&&g.length;o<l;o++)if(h=g[o],h.specified)j=h.name,n=fa(j.toLowerCase()),k[n]=j,c[n]=h=R(aa&&j=="href"?decodeURIComponent(a.getAttribute(j,2)):h.value),yb(a,n)&&(c[n]=!0),X(a,b,h,n),A(b,n,"A",f);a=a.className;if(F(a)&&a!=="")for(;g=e.exec(a);)n=fa(g[2]),A(b,n,"C",f)&&(c[n]=R(g[3])),a=a.substr(g.index+g[0].length);break;case 3:H(b,a.nodeValue);break;case 8:try{if(g=d.exec(a.nodeValue))n=fa(g[1]),A(b,
14.43 +n,"M",f)&&(c[n]=R(g[2]))}catch(r){}}b.sort(y);return b}function C(a,b,c,d,e){function f(a,b){if(a)a.require=z.require,l.push(a);if(b)b.require=z.require,ba.push(b)}function h(a,b){var c,d="data",e=!1;if(F(a)){for(;(c=a.charAt(0))=="^"||c=="?";)a=a.substr(1),c=="^"&&(d="inheritedData"),e=e||c=="?";c=b[d]("$"+a+"Controller");if(!c&&!e)throw B("No controller: "+a);}else J(a)&&(c=[],m(a,function(a){c.push(h(a,b))}));return c}function j(a,d,e,f,g){var n,q,w,K,s;n=b===e?c:hc(c,new ea(u(e),c.$attr));q=n.$$element;
14.44 +if(C){var zc=/^\s*([@=&])\s*(\w*)\s*$/,O=d.$parent||d;m(C.scope,function(a,b){var c=a.match(zc)||[],e=c[2]||b,f,g,k;switch(c[1]){case "@":n.$observe(e,function(a){d[b]=a});n.$$observers[e].$$scope=O;break;case "=":g=o(n[e]);k=g.assign||function(){f=d[b]=g(O);throw B(Db+n[e]+" (directive: "+C.name+")");};f=d[b]=g(O);d.$watch(function(){var a=g(O);a!==d[b]&&(a!==f?f=d[b]=a:k(O,a=f=d[b]));return a});break;case "&":g=o(n[e]);d[b]=function(a){return g(O,a)};break;default:throw B("Invalid isolate scope definition for directive "+
14.45 +C.name+": "+a);}})}t&&m(t,function(a){var b={$scope:d,$element:q,$attrs:n,$transclude:g};s=a.controller;s=="@"&&(s=n[a.name]);q.data("$"+a.name+"Controller",r(s,b))});f=0;for(w=l.length;f<w;f++)try{K=l[f],K(d,q,n,K.require&&h(K.require,q))}catch(y){k(y,pa(q))}a&&a(d,e.childNodes,p,g);f=0;for(w=ba.length;f<w;f++)try{K=ba[f],K(d,q,n,K.require&&h(K.require,q))}catch(Ha){k(Ha,pa(q))}}for(var n=-Number.MAX_VALUE,l=[],ba=[],s=null,C=null,A=null,y=c.$$element=u(b),z,H,X,D,v=d,t,x,Y,E=0,G=a.length;E<G;E++){z=
14.46 +a[E];X=p;if(n>z.priority)break;if(Y=z.scope)M("isolated scope",C,z,y),L(Y)&&(q(y,"ng-isolate-scope"),C=z),q(y,"ng-scope"),s=s||z;H=z.name;if(Y=z.controller)t=t||{},M("'"+H+"' controller",t[H],z,y),t[H]=z;if(Y=z.transclude)M("transclusion",D,z,y),D=z,n=z.priority,Y=="element"?(X=u(b),y=c.$$element=u("<\!-- "+H+": "+c[H]+" --\>"),b=y[0],Ga(e,u(X[0]),b),v=w(X,d,n)):(X=u(cb(b)).contents(),y.html(""),v=w(X,d));if(Y=z.template)if(M("template",A,z,y),A=z,Y=Ha(Y),z.replace){X=u("<div>"+R(Y)+"</div>").contents();
14.47 +b=X[0];if(X.length!=1||b.nodeType!==1)throw new B(g+Y);Ga(e,y,b);H={$attr:{}};a=a.concat(O(b,a.splice(E+1,a.length-(E+1)),H));K(c,H);G=a.length}else y.html(Y);if(z.templateUrl)M("template",A,z,y),A=z,j=W(a.splice(E,a.length-E),j,y,c,e,z.replace,v),G=a.length;else if(z.compile)try{x=z.compile(y,c,v),N(x)?f(null,x):x&&f(x.pre,x.post)}catch(I){k(I,pa(y))}if(z.terminal)j.terminal=!0,n=Math.max(n,z.priority)}j.scope=s&&s.scope;j.transclude=D&&v;return j}function A(d,e,g,h){var j=!1;if(a.hasOwnProperty(e))for(var n,
14.48 +e=b.get(e+c),o=0,l=e.length;o<l;o++)try{if(n=e[o],(h===p||h>n.priority)&&n.restrict.indexOf(g)!=-1)d.push(n),j=!0}catch(r){k(r)}return j}function K(a,b){var c=b.$attr,d=a.$attr,e=a.$$element;m(a,function(d,e){e.charAt(0)!="$"&&(b[e]&&(d+=(e==="style"?";":" ")+b[e]),a.$set(e,d,!0,c[e]))});m(b,function(b,f){f=="class"?(q(e,b),a["class"]=(a["class"]?a["class"]+" ":"")+b):f=="style"?e.attr("style",e.attr("style")+";"+b):f.charAt(0)!="$"&&!a.hasOwnProperty(f)&&(a[f]=b,d[f]=c[f])})}function W(a,b,c,d,e,
14.49 +f,k){var h=[],n,o,r=c[0],q=a.shift(),w=x({},q,{controller:null,templateUrl:null,transclude:null,scope:null});c.html("");j.get(q.templateUrl,{cache:l}).success(function(j){var l,q,j=Ha(j);if(f){q=u("<div>"+R(j)+"</div>").contents();l=q[0];if(q.length!=1||l.nodeType!==1)throw new B(g+j);j={$attr:{}};Ga(e,c,l);O(l,a,j);K(d,j)}else l=r,c.html(j);a.unshift(w);n=C(a,c,d,k);for(o=s(c.contents(),k);h.length;){var ba=h.pop(),j=h.pop();q=h.pop();var y=h.pop(),m=l;q!==r&&(m=cb(l),Ga(j,u(q),m));n(function(){b(o,
14.50 +y,m,e,ba)},y,m,e,ba)}h=null}).error(function(a,b,c,d){throw B("Failed to load template: "+d.url);});return function(a,c,d,e,f){h?(h.push(c),h.push(d),h.push(e),h.push(f)):n(function(){b(o,c,d,e,f)},c,d,e,f)}}function y(a,b){return b.priority-a.priority}function M(a,b,c,d){if(b)throw B("Multiple directives ["+b.name+", "+c.name+"] asking for "+a+" on: "+pa(d));}function H(a,b){var c=h(b,!0);c&&a.push({priority:0,compile:I(function(a,b){var d=b.parent(),e=d.data("$binding")||[];e.push(c);q(d.data("$binding",
14.51 +e),"ng-binding");a.$watch(c,function(a){b[0].nodeValue=a})})})}function X(a,b,c,d){var e=h(c,!0);e&&b.push({priority:100,compile:I(function(a,b,c){b=c.$$observers||(c.$$observers={});d==="class"&&(e=h(c[d],!0));c[d]=p;(b[d]||(b[d]=[])).$$inter=!0;(c.$$observers&&c.$$observers[d].$$scope||a).$watch(e,function(a){c.$set(d,a)})})})}function Ga(a,b,c){var d=b[0],e=d.parentNode,f,g;if(a){f=0;for(g=a.length;f<g;f++)if(a[f]==d){a[f]=c;break}}e&&e.replaceChild(c,d);c[u.expando]=d[u.expando];b[0]=c}var ea=
14.52 +function(a,b){this.$$element=a;this.$attr=b||{}};ea.prototype={$normalize:fa,$set:function(a,b,c,d){var e=yb(this.$$element[0],a),f=this.$$observers;e&&(this.$$element.prop(a,b),d=e);this[a]=b;d?this.$attr[a]=d:(d=this.$attr[a])||(this.$attr[a]=d=$a(a,"-"));c!==!1&&(b===null||b===p?this.$$element.removeAttr(d):this.$$element.attr(d,b));f&&m(f[a],function(a){try{a(b)}catch(c){k(c)}})},$observe:function(a,b){var c=this,d=c.$$observers||(c.$$observers={}),e=d[a]||(d[a]=[]);e.push(b);n.$evalAsync(function(){e.$$inter||
14.53 +b(c[a])});return b}};var D=h.startSymbol(),ba=h.endSymbol(),Ha=D=="{{"||ba=="}}"?ma:function(a){return a.replace(/\{\{/g,D).replace(/}}/g,ba)};return w}]}function fa(b){return rb(b.replace(Ac,""))}function Bc(){var b={};this.register=function(a,c){L(a)?x(b,a):b[a]=c};this.$get=["$injector","$window",function(a,c){return function(d,e){if(F(d)){var g=d,d=b.hasOwnProperty(g)?b[g]:fb(e.$scope,g,!0)||fb(c,g,!0);ra(d,g,!0)}return a.instantiate(d,e)}}]}function Cc(){this.$get=["$window",function(b){return u(b.document)}]}
14.54 +function Dc(){this.$get=["$log",function(b){return function(a,c){b.error.apply(b,arguments)}}]}function Ec(){var b="{{",a="}}";this.startSymbol=function(a){return a?(b=a,this):b};this.endSymbol=function(b){return b?(a=b,this):a};this.$get=["$parse",function(c){function d(d,f){for(var h,k,j=0,l=[],o=d.length,r=!1,n=[];j<o;)(h=d.indexOf(b,j))!=-1&&(k=d.indexOf(a,h+e))!=-1?(j!=h&&l.push(d.substring(j,h)),l.push(j=c(r=d.substring(h+e,k))),j.exp=r,j=k+g,r=!0):(j!=o&&l.push(d.substring(j)),j=o);if(!(o=
14.55 +l.length))l.push(""),o=1;if(!f||r)return n.length=o,j=function(a){for(var b=0,c=o,d;b<c;b++){if(typeof(d=l[b])=="function")d=d(a),d==null||d==p?d="":typeof d!="string"&&(d=da(d));n[b]=d}return n.join("")},j.exp=d,j.parts=l,j}var e=b.length,g=a.length;d.startSymbol=function(){return b};d.endSymbol=function(){return a};return d}]}function Eb(b){for(var b=b.split("/"),a=b.length;a--;)b[a]=Za(b[a]);return b.join("/")}function va(b,a){var c=Fb.exec(b),c={protocol:c[1],host:c[3],port:G(c[5])||Gb[c[1]]||
14.56 +null,path:c[6]||"/",search:c[8],hash:c[10]};if(a)a.$$protocol=c.protocol,a.$$host=c.host,a.$$port=c.port;return c}function ka(b,a,c){return b+"://"+a+(c==Gb[b]?"":":"+c)}function Fc(b,a,c){var d=va(b);return decodeURIComponent(d.path)!=a||t(d.hash)||d.hash.indexOf(c)!==0?b:ka(d.protocol,d.host,d.port)+a.substr(0,a.lastIndexOf("/"))+d.hash.substr(c.length)}function Gc(b,a,c){var d=va(b);if(decodeURIComponent(d.path)==a)return b;else{var e=d.search&&"?"+d.search||"",g=d.hash&&"#"+d.hash||"",i=a.substr(0,
14.57 +a.lastIndexOf("/")),f=d.path.substr(i.length);if(d.path.indexOf(i)!==0)throw B('Invalid url "'+b+'", missing path prefix "'+i+'" !');return ka(d.protocol,d.host,d.port)+a+"#"+c+f+e+g}}function gb(b,a,c){a=a||"";this.$$parse=function(b){var c=va(b,this);if(c.path.indexOf(a)!==0)throw B('Invalid url "'+b+'", missing path prefix "'+a+'" !');this.$$path=decodeURIComponent(c.path.substr(a.length));this.$$search=Xa(c.search);this.$$hash=c.hash&&decodeURIComponent(c.hash)||"";this.$$compose()};this.$$compose=
14.58 +function(){var b=ob(this.$$search),c=this.$$hash?"#"+Za(this.$$hash):"";this.$$url=Eb(this.$$path)+(b?"?"+b:"")+c;this.$$absUrl=ka(this.$$protocol,this.$$host,this.$$port)+a+this.$$url};this.$$rewriteAppUrl=function(a){if(a.indexOf(c)==0)return a};this.$$parse(b)}function Ia(b,a,c){var d;this.$$parse=function(b){var c=va(b,this);if(c.hash&&c.hash.indexOf(a)!==0)throw B('Invalid url "'+b+'", missing hash prefix "'+a+'" !');d=c.path+(c.search?"?"+c.search:"");c=Hc.exec((c.hash||"").substr(a.length));
14.59 +this.$$path=c[1]?(c[1].charAt(0)=="/"?"":"/")+decodeURIComponent(c[1]):"";this.$$search=Xa(c[3]);this.$$hash=c[5]&&decodeURIComponent(c[5])||"";this.$$compose()};this.$$compose=function(){var b=ob(this.$$search),c=this.$$hash?"#"+Za(this.$$hash):"";this.$$url=Eb(this.$$path)+(b?"?"+b:"")+c;this.$$absUrl=ka(this.$$protocol,this.$$host,this.$$port)+d+(this.$$url?"#"+a+this.$$url:"")};this.$$rewriteAppUrl=function(a){if(a.indexOf(c)==0)return a};this.$$parse(b)}function Hb(b,a,c,d){Ia.apply(this,arguments);
14.60 +this.$$rewriteAppUrl=function(b){if(b.indexOf(c)==0)return c+d+"#"+a+b.substr(c.length)}}function Ja(b){return function(){return this[b]}}function Ib(b,a){return function(c){if(t(c))return this[b];this[b]=a(c);this.$$compose();return this}}function Ic(){var b="",a=!1;this.hashPrefix=function(a){return v(a)?(b=a,this):b};this.html5Mode=function(b){return v(b)?(a=b,this):a};this.$get=["$rootScope","$browser","$sniffer","$rootElement",function(c,d,e,g){function i(a){c.$broadcast("$locationChangeSuccess",
14.61 +f.absUrl(),a)}var f,h,k,j=d.url(),l=va(j);a?(h=d.baseHref()||"/",k=h.substr(0,h.lastIndexOf("/")),l=ka(l.protocol,l.host,l.port)+k+"/",f=e.history?new gb(Fc(j,h,b),k,l):new Hb(Gc(j,h,b),b,l,h.substr(k.length+1))):(l=ka(l.protocol,l.host,l.port)+(l.path||"")+(l.search?"?"+l.search:"")+"#"+b+"/",f=new Ia(j,b,l));g.bind("click",function(a){if(!a.ctrlKey&&!(a.metaKey||a.which==2)){for(var b=u(a.target);E(b[0].nodeName)!=="a";)if(b[0]===g[0]||!(b=b.parent())[0])return;var d=b.prop("href"),e=f.$$rewriteAppUrl(d);
14.62 +d&&!b.attr("target")&&e&&(f.$$parse(e),c.$apply(),a.preventDefault(),U.angular["ff-684208-preventDefault"]=!0)}});f.absUrl()!=j&&d.url(f.absUrl(),!0);d.onUrlChange(function(a){f.absUrl()!=a&&(c.$evalAsync(function(){var b=f.absUrl();f.$$parse(a);i(b)}),c.$$phase||c.$digest())});var o=0;c.$watch(function(){var a=d.url(),b=f.$$replace;if(!o||a!=f.absUrl())o++,c.$evalAsync(function(){c.$broadcast("$locationChangeStart",f.absUrl(),a).defaultPrevented?f.$$parse(a):(d.url(f.absUrl(),b),i(a))});f.$$replace=
14.63 +!1;return o});return f}]}function Jc(){this.$get=["$window",function(b){function a(a){a instanceof B&&(a.stack?a=a.message&&a.stack.indexOf(a.message)===-1?"Error: "+a.message+"\n"+a.stack:a.stack:a.sourceURL&&(a=a.message+"\n"+a.sourceURL+":"+a.line));return a}function c(c){var e=b.console||{},g=e[c]||e.log||D;return g.apply?function(){var b=[];m(arguments,function(c){b.push(a(c))});return g.apply(e,b)}:function(a,b){g(a,b)}}return{log:c("log"),warn:c("warn"),info:c("info"),error:c("error")}}]}function Kc(b,
14.64 +a){function c(a){return a.indexOf(q)!=-1}function d(){return n+1<b.length?b.charAt(n+1):!1}function e(a){return"0"<=a&&a<="9"}function g(a){return a==" "||a=="\r"||a=="\t"||a=="\n"||a=="\u000b"||a=="\u00a0"}function i(a){return"a"<=a&&a<="z"||"A"<=a&&a<="Z"||"_"==a||a=="$"}function f(a){return a=="-"||a=="+"||e(a)}function h(a,c,d){d=d||n;throw B("Lexer Error: "+a+" at column"+(v(c)?"s "+c+"-"+n+" ["+b.substring(c,d)+"]":" "+d)+" in expression ["+b+"].");}function k(){for(var a="",c=n;n<b.length;){var k=
14.65 +E(b.charAt(n));if(k=="."||e(k))a+=k;else{var g=d();if(k=="e"&&f(g))a+=k;else if(f(k)&&g&&e(g)&&a.charAt(a.length-1)=="e")a+=k;else if(f(k)&&(!g||!e(g))&&a.charAt(a.length-1)=="e")h("Invalid exponent");else break}n++}a*=1;o.push({index:c,text:a,json:!0,fn:function(){return a}})}function j(){for(var c="",d=n,f,k,h;n<b.length;){var j=b.charAt(n);if(j=="."||i(j)||e(j))j=="."&&(f=n),c+=j;else break;n++}if(f)for(k=n;k<b.length;){j=b.charAt(k);if(j=="("){h=c.substr(f-d+1);c=c.substr(0,f-d);n=k;break}if(g(j))k++;
14.66 +else break}d={index:d,text:c};if(Ka.hasOwnProperty(c))d.fn=d.json=Ka[c];else{var l=Jb(c,a);d.fn=x(function(a,b){return l(a,b)},{assign:function(a,b){return Kb(a,c,b)}})}o.push(d);h&&(o.push({index:f,text:".",json:!1}),o.push({index:f+1,text:h,json:!1}))}function l(a){var c=n;n++;for(var d="",e=a,f=!1;n<b.length;){var k=b.charAt(n);e+=k;if(f)k=="u"?(k=b.substring(n+1,n+5),k.match(/[\da-f]{4}/i)||h("Invalid unicode escape [\\u"+k+"]"),n+=4,d+=String.fromCharCode(parseInt(k,16))):(f=Lc[k],d+=f?f:k),
14.67 +f=!1;else if(k=="\\")f=!0;else if(k==a){n++;o.push({index:c,text:e,string:d,json:!0,fn:function(){return d}});return}else d+=k;n++}h("Unterminated quote",c)}for(var o=[],r,n=0,w=[],q,s=":";n<b.length;){q=b.charAt(n);if(c("\"'"))l(q);else if(e(q)||c(".")&&e(d()))k();else if(i(q)){if(j(),"{,".indexOf(s)!=-1&&w[0]=="{"&&(r=o[o.length-1]))r.json=r.text.indexOf(".")==-1}else if(c("(){}[].,;:"))o.push({index:n,text:q,json:":[,".indexOf(s)!=-1&&c("{[")||c("}]:,")}),c("{[")&&w.unshift(q),c("}]")&&w.shift(),
14.68 +n++;else if(g(q)){n++;continue}else{var m=q+d(),C=Ka[q],A=Ka[m];A?(o.push({index:n,text:m,fn:A}),n+=2):C?(o.push({index:n,text:q,fn:C,json:"[,:".indexOf(s)!=-1&&c("+-")}),n+=1):h("Unexpected next character ",n,n+1)}s=q}return o}function Mc(b,a,c,d){function e(a,c){throw B("Syntax Error: Token '"+c.text+"' "+a+" at column "+(c.index+1)+" of the expression ["+b+"] starting at ["+b.substring(c.index)+"].");}function g(){if(M.length===0)throw B("Unexpected end of expression: "+b);return M[0]}function i(a,
14.69 +b,c,d){if(M.length>0){var e=M[0],f=e.text;if(f==a||f==b||f==c||f==d||!a&&!b&&!c&&!d)return e}return!1}function f(b,c,d,f){return(b=i(b,c,d,f))?(a&&!b.json&&e("is not valid json",b),M.shift(),b):!1}function h(a){f(a)||e("is unexpected, expecting ["+a+"]",i())}function k(a,b){return function(c,d){return a(c,d,b)}}function j(a,b,c){return function(d,e){return b(d,e,a,c)}}function l(){for(var a=[];;)if(M.length>0&&!i("}",")",";","]")&&a.push(v()),!f(";"))return a.length==1?a[0]:function(b,c){for(var d,
14.70 +e=0;e<a.length;e++){var f=a[e];f&&(d=f(b,c))}return d}}function o(){for(var a=f(),b=c(a.text),d=[];;)if(a=f(":"))d.push(H());else{var e=function(a,c,e){for(var e=[e],f=0;f<d.length;f++)e.push(d[f](a,c));return b.apply(a,e)};return function(){return e}}}function r(){for(var a=n(),b;;)if(b=f("||"))a=j(a,b.fn,n());else return a}function n(){var a=w(),b;if(b=f("&&"))a=j(a,b.fn,n());return a}function w(){var a=q(),b;if(b=f("==","!="))a=j(a,b.fn,w());return a}function q(){var a;a=s();for(var b;b=f("+",
14.71 +"-");)a=j(a,b.fn,s());if(b=f("<",">","<=",">="))a=j(a,b.fn,q());return a}function s(){for(var a=m(),b;b=f("*","/","%");)a=j(a,b.fn,m());return a}function m(){var a;return f("+")?C():(a=f("-"))?j(W,a.fn,m()):(a=f("!"))?k(a.fn,m()):C()}function C(){var a;if(f("("))a=v(),h(")");else if(f("["))a=A();else if(f("{"))a=K();else{var b=f();(a=b.fn)||e("not a primary expression",b)}for(var c;b=f("(","[",".");)b.text==="("?(a=u(a,c),c=null):b.text==="["?(c=a,a=ea(a)):b.text==="."?(c=a,a=t(a)):e("IMPOSSIBLE");
14.72 +return a}function A(){var a=[];if(g().text!="]"){do a.push(H());while(f(","))}h("]");return function(b,c){for(var d=[],e=0;e<a.length;e++)d.push(a[e](b,c));return d}}function K(){var a=[];if(g().text!="}"){do{var b=f(),b=b.string||b.text;h(":");var c=H();a.push({key:b,value:c})}while(f(","))}h("}");return function(b,c){for(var d={},e=0;e<a.length;e++){var f=a[e],k=f.value(b,c);d[f.key]=k}return d}}var W=I(0),y,M=Kc(b,d),H=function(){var a=r(),c,d;return(d=f("="))?(a.assign||e("implies assignment but ["+
14.73 +b.substring(0,d.index)+"] can not be assigned to",d),c=r(),function(b,d){return a.assign(b,c(b,d),d)}):a},u=function(a,b){var c=[];if(g().text!=")"){do c.push(H());while(f(","))}h(")");return function(d,e){for(var f=[],k=b?b(d,e):d,h=0;h<c.length;h++)f.push(c[h](d,e));h=a(d,e)||D;return h.apply?h.apply(k,f):h(f[0],f[1],f[2],f[3],f[4])}},t=function(a){var b=f().text,c=Jb(b,d);return x(function(b,d){return c(a(b,d),d)},{assign:function(c,d,e){return Kb(a(c,e),b,d)}})},ea=function(a){var b=H();h("]");
14.74 +return x(function(c,d){var e=a(c,d),f=b(c,d),k;if(!e)return p;if((e=e[f])&&e.then){k=e;if(!("$$v"in e))k.$$v=p,k.then(function(a){k.$$v=a});e=e.$$v}return e},{assign:function(c,d,e){return a(c,e)[b(c,e)]=d}})},v=function(){for(var a=H(),b;;)if(b=f("|"))a=j(a,b.fn,o());else return a};a?(H=r,u=t=ea=v=function(){e("is not valid json",{text:b,index:0})},y=C()):y=l();M.length!==0&&e("is an unexpected token",M[0]);return y}function Kb(b,a,c){for(var a=a.split("."),d=0;a.length>1;d++){var e=a.shift(),g=
14.75 +b[e];g||(g={},b[e]=g);b=g}return b[a.shift()]=c}function fb(b,a,c){if(!a)return b;for(var a=a.split("."),d,e=b,g=a.length,i=0;i<g;i++)d=a[i],b&&(b=(e=b)[d]);return!c&&N(b)?Va(e,b):b}function Lb(b,a,c,d,e){return function(g,i){var f=i&&i.hasOwnProperty(b)?i:g,h;if(f===null||f===p)return f;if((f=f[b])&&f.then){if(!("$$v"in f))h=f,h.$$v=p,h.then(function(a){h.$$v=a});f=f.$$v}if(!a||f===null||f===p)return f;if((f=f[a])&&f.then){if(!("$$v"in f))h=f,h.$$v=p,h.then(function(a){h.$$v=a});f=f.$$v}if(!c||f===
14.76 +null||f===p)return f;if((f=f[c])&&f.then){if(!("$$v"in f))h=f,h.$$v=p,h.then(function(a){h.$$v=a});f=f.$$v}if(!d||f===null||f===p)return f;if((f=f[d])&&f.then){if(!("$$v"in f))h=f,h.$$v=p,h.then(function(a){h.$$v=a});f=f.$$v}if(!e||f===null||f===p)return f;if((f=f[e])&&f.then){if(!("$$v"in f))h=f,h.$$v=p,h.then(function(a){h.$$v=a});f=f.$$v}return f}}function Jb(b,a){if(hb.hasOwnProperty(b))return hb[b];var c=b.split("."),d=c.length,e;if(a)e=d<6?Lb(c[0],c[1],c[2],c[3],c[4]):function(a,b){var e=0,
14.77 +k;do k=Lb(c[e++],c[e++],c[e++],c[e++],c[e++])(a,b),b=p,a=k;while(e<d);return k};else{var g="var l, fn, p;\n";m(c,function(a,b){g+="if(s === null || s === undefined) return s;\nl=s;\ns="+(b?"s":'((k&&k.hasOwnProperty("'+a+'"))?k:s)')+'["'+a+'"];\nif (s && s.then) {\n if (!("$$v" in s)) {\n p=s;\n p.$$v = undefined;\n p.then(function(v) {p.$$v=v;});\n}\n s=s.$$v\n}\n'});g+="return s;";e=Function("s","k",g);e.toString=function(){return g}}return hb[b]=e}function Nc(){var b={};this.$get=["$filter","$sniffer",
14.78 +function(a,c){return function(d){switch(typeof d){case "string":return b.hasOwnProperty(d)?b[d]:b[d]=Mc(d,!1,a,c.csp);case "function":return d;default:return D}}}]}function Oc(){this.$get=["$rootScope","$exceptionHandler",function(b,a){return Pc(function(a){b.$evalAsync(a)},a)}]}function Pc(b,a){function c(a){return a}function d(a){return i(a)}var e=function(){var f=[],h,k;return k={resolve:function(a){if(f){var c=f;f=p;h=g(a);c.length&&b(function(){for(var a,b=0,d=c.length;b<d;b++)a=c[b],h.then(a[0],
14.79 +a[1])})}},reject:function(a){k.resolve(i(a))},promise:{then:function(b,k){var g=e(),i=function(d){try{g.resolve((b||c)(d))}catch(e){a(e),g.reject(e)}},n=function(b){try{g.resolve((k||d)(b))}catch(c){a(c),g.reject(c)}};f?f.push([i,n]):h.then(i,n);return g.promise}}}},g=function(a){return a&&a.then?a:{then:function(c){var d=e();b(function(){d.resolve(c(a))});return d.promise}}},i=function(a){return{then:function(c,k){var g=e();b(function(){g.resolve((k||d)(a))});return g.promise}}};return{defer:e,reject:i,
14.80 +when:function(f,h,k){var j=e(),l,o=function(b){try{return(h||c)(b)}catch(d){return a(d),i(d)}},r=function(b){try{return(k||d)(b)}catch(c){return a(c),i(c)}};b(function(){g(f).then(function(a){l||(l=!0,j.resolve(g(a).then(o,r)))},function(a){l||(l=!0,j.resolve(r(a)))})});return j.promise},all:function(a){var b=e(),c=a.length,d=[];c?m(a,function(a,e){g(a).then(function(a){e in d||(d[e]=a,--c||b.resolve(d))},function(a){e in d||b.reject(a)})}):b.resolve(d);return b.promise}}}function Qc(){var b={};this.when=
14.81 +function(a,c){b[a]=x({reloadOnSearch:!0},c);if(a){var d=a[a.length-1]=="/"?a.substr(0,a.length-1):a+"/";b[d]={redirectTo:a}}return this};this.otherwise=function(a){this.when(null,a);return this};this.$get=["$rootScope","$location","$routeParams","$q","$injector","$http","$templateCache",function(a,c,d,e,g,i,f){function h(){var b=k(),h=r.current;if(b&&h&&b.$route===h.$route&&ha(b.pathParams,h.pathParams)&&!b.reloadOnSearch&&!o)h.params=b.params,V(h.params,d),a.$broadcast("$routeUpdate",h);else if(b||
14.82 +h)o=!1,a.$broadcast("$routeChangeStart",b,h),(r.current=b)&&b.redirectTo&&(F(b.redirectTo)?c.path(j(b.redirectTo,b.params)).search(b.params).replace():c.url(b.redirectTo(b.pathParams,c.path(),c.search())).replace()),e.when(b).then(function(){if(b){var a=[],c=[],d;m(b.resolve||{},function(b,d){a.push(d);c.push(F(b)?g.get(b):g.invoke(b))});if(!v(d=b.template))if(v(d=b.templateUrl))d=i.get(d,{cache:f}).then(function(a){return a.data});v(d)&&(a.push("$template"),c.push(d));return e.all(c).then(function(b){var c=
14.83 +{};m(b,function(b,d){c[a[d]]=b});return c})}}).then(function(c){if(b==r.current){if(b)b.locals=c,V(b.params,d);a.$broadcast("$routeChangeSuccess",b,h)}},function(c){b==r.current&&a.$broadcast("$routeChangeError",b,h,c)})}function k(){var a,d;m(b,function(b,e){if(!d&&(a=l(c.path(),e)))d=ya(b,{params:x({},c.search(),a),pathParams:a}),d.$route=b});return d||b[null]&&ya(b[null],{params:{},pathParams:{}})}function j(a,b){var c=[];m((a||"").split(":"),function(a,d){if(d==0)c.push(a);else{var e=a.match(/(\w+)(.*)/),
14.84 +f=e[1];c.push(b[f]);c.push(e[2]||"");delete b[f]}});return c.join("")}var l=function(a,b){var c="^"+b.replace(/([\.\\\(\)\^\$])/g,"\\$1")+"$",d=[],e={};m(b.split(/\W/),function(a){if(a){var b=RegExp(":"+a+"([\\W])");c.match(b)&&(c=c.replace(b,"([^\\/]*)$1"),d.push(a))}});var f=a.match(RegExp(c));f&&m(d,function(a,b){e[a]=f[b+1]});return f?e:null},o=!1,r={routes:b,reload:function(){o=!0;a.$evalAsync(h)}};a.$on("$locationChangeSuccess",h);return r}]}function Rc(){this.$get=I({})}function Sc(){var b=
14.85 +10;this.digestTtl=function(a){arguments.length&&(b=a);return b};this.$get=["$injector","$exceptionHandler","$parse",function(a,c,d){function e(){this.$id=xa();this.$$phase=this.$parent=this.$$watchers=this.$$nextSibling=this.$$prevSibling=this.$$childHead=this.$$childTail=null;this["this"]=this.$root=this;this.$$asyncQueue=[];this.$$listeners={}}function g(a){if(h.$$phase)throw B(h.$$phase+" already in progress");h.$$phase=a}function i(a,b){var c=d(a);ra(c,b);return c}function f(){}e.prototype={$new:function(a){if(N(a))throw B("API-CHANGE: Use $controller to instantiate controllers.");
14.86 +a?(a=new e,a.$root=this.$root):(a=function(){},a.prototype=this,a=new a,a.$id=xa());a["this"]=a;a.$$listeners={};a.$parent=this;a.$$asyncQueue=[];a.$$watchers=a.$$nextSibling=a.$$childHead=a.$$childTail=null;a.$$prevSibling=this.$$childTail;this.$$childHead?this.$$childTail=this.$$childTail.$$nextSibling=a:this.$$childHead=this.$$childTail=a;return a},$watch:function(a,b,c){var d=i(a,"watch"),e=this.$$watchers,g={fn:b,last:f,get:d,exp:a,eq:!!c};if(!N(b)){var h=i(b||D,"listener");g.fn=function(a,b,
14.87 +c){h(c)}}if(!e)e=this.$$watchers=[];e.unshift(g);return function(){Ua(e,g)}},$digest:function(){var a,d,e,i,r,n,m,q=b,s,p=[],C,A;g("$digest");do{m=!1;s=this;do{for(r=s.$$asyncQueue;r.length;)try{s.$eval(r.shift())}catch(K){c(K)}if(i=s.$$watchers)for(n=i.length;n--;)try{if(a=i[n],(d=a.get(s))!==(e=a.last)&&!(a.eq?ha(d,e):typeof d=="number"&&typeof e=="number"&&isNaN(d)&&isNaN(e)))m=!0,a.last=a.eq?V(d):d,a.fn(d,e===f?d:e,s),q<5&&(C=4-q,p[C]||(p[C]=[]),A=N(a.exp)?"fn: "+(a.exp.name||a.exp.toString()):
14.88 +a.exp,A+="; newVal: "+da(d)+"; oldVal: "+da(e),p[C].push(A))}catch(W){c(W)}if(!(i=s.$$childHead||s!==this&&s.$$nextSibling))for(;s!==this&&!(i=s.$$nextSibling);)s=s.$parent}while(s=i);if(m&&!q--)throw h.$$phase=null,B(b+" $digest() iterations reached. Aborting!\nWatchers fired in the last 5 iterations: "+da(p));}while(m||r.length);h.$$phase=null},$destroy:function(){if(h!=this){var a=this.$parent;this.$broadcast("$destroy");if(a.$$childHead==this)a.$$childHead=this.$$nextSibling;if(a.$$childTail==
14.89 +this)a.$$childTail=this.$$prevSibling;if(this.$$prevSibling)this.$$prevSibling.$$nextSibling=this.$$nextSibling;if(this.$$nextSibling)this.$$nextSibling.$$prevSibling=this.$$prevSibling;this.$parent=this.$$nextSibling=this.$$prevSibling=this.$$childHead=this.$$childTail=null}},$eval:function(a,b){return d(a)(this,b)},$evalAsync:function(a){this.$$asyncQueue.push(a)},$apply:function(a){try{return g("$apply"),this.$eval(a)}catch(b){c(b)}finally{h.$$phase=null;try{h.$digest()}catch(d){throw c(d),d;}}},
14.90 +$on:function(a,b){var c=this.$$listeners[a];c||(this.$$listeners[a]=c=[]);c.push(b);return function(){c[za(c,b)]=null}},$emit:function(a,b){var d=[],e,f=this,g=!1,h={name:a,targetScope:f,stopPropagation:function(){g=!0},preventDefault:function(){h.defaultPrevented=!0},defaultPrevented:!1},i=[h].concat(ia.call(arguments,1)),m,p;do{e=f.$$listeners[a]||d;h.currentScope=f;m=0;for(p=e.length;m<p;m++)if(e[m])try{if(e[m].apply(null,i),g)return h}catch(C){c(C)}else e.splice(m,1),m--,p--;f=f.$parent}while(f);
14.91 +return h},$broadcast:function(a,b){var d=this,e=this,f={name:a,targetScope:this,preventDefault:function(){f.defaultPrevented=!0},defaultPrevented:!1},g=[f].concat(ia.call(arguments,1)),h,i;do{d=e;f.currentScope=d;e=d.$$listeners[a]||[];h=0;for(i=e.length;h<i;h++)if(e[h])try{e[h].apply(null,g)}catch(m){c(m)}else e.splice(h,1),h--,i--;if(!(e=d.$$childHead||d!==this&&d.$$nextSibling))for(;d!==this&&!(e=d.$$nextSibling);)d=d.$parent}while(d=e);return f}};var h=new e;return h}]}function Tc(){this.$get=
14.92 +["$window",function(b){var a={},c=G((/android (\d+)/.exec(E(b.navigator.userAgent))||[])[1]);return{history:!(!b.history||!b.history.pushState||c<4),hashchange:"onhashchange"in b&&(!b.document.documentMode||b.document.documentMode>7),hasEvent:function(c){if(c=="input"&&aa==9)return!1;if(t(a[c])){var e=b.document.createElement("div");a[c]="on"+c in e}return a[c]},csp:!1}}]}function Uc(){this.$get=I(U)}function Mb(b){var a={},c,d,e;if(!b)return a;m(b.split("\n"),function(b){e=b.indexOf(":");c=E(R(b.substr(0,
14.93 +e)));d=R(b.substr(e+1));c&&(a[c]?a[c]+=", "+d:a[c]=d)});return a}function Nb(b){var a=L(b)?b:p;return function(c){a||(a=Mb(b));return c?a[E(c)]||null:a}}function Ob(b,a,c){if(N(c))return c(b,a);m(c,function(c){b=c(b,a)});return b}function Vc(){var b=/^\s*(\[|\{[^\{])/,a=/[\}\]]\s*$/,c=/^\)\]\}',?\n/,d=this.defaults={transformResponse:[function(d){F(d)&&(d=d.replace(c,""),b.test(d)&&a.test(d)&&(d=nb(d,!0)));return d}],transformRequest:[function(a){return L(a)&&Sa.apply(a)!=="[object File]"?da(a):a}],
14.94 +headers:{common:{Accept:"application/json, text/plain, */*","X-Requested-With":"XMLHttpRequest"},post:{"Content-Type":"application/json;charset=utf-8"},put:{"Content-Type":"application/json;charset=utf-8"}}},e=this.responseInterceptors=[];this.$get=["$httpBackend","$browser","$cacheFactory","$rootScope","$q","$injector",function(a,b,c,h,k,j){function l(a){function c(a){var b=x({},a,{data:Ob(a.data,a.headers,f)});return 200<=a.status&&a.status<300?b:k.reject(b)}a.method=la(a.method);var e=a.transformRequest||
14.95 +d.transformRequest,f=a.transformResponse||d.transformResponse,h=d.headers,h=x({"X-XSRF-TOKEN":b.cookies()["XSRF-TOKEN"]},h.common,h[E(a.method)],a.headers),e=Ob(a.data,Nb(h),e),g;t(a.data)&&delete h["Content-Type"];g=o(a,e,h);g=g.then(c,c);m(w,function(a){g=a(g)});g.success=function(b){g.then(function(c){b(c.data,c.status,c.headers,a)});return g};g.error=function(b){g.then(null,function(c){b(c.data,c.status,c.headers,a)});return g};return g}function o(b,c,d){function e(a,b,c){m&&(200<=a&&a<300?m.put(w,
14.96 +[a,b,Mb(c)]):m.remove(w));f(b,a,c);h.$apply()}function f(a,c,d){c=Math.max(c,0);(200<=c&&c<300?j.resolve:j.reject)({data:a,status:c,headers:Nb(d),config:b})}function i(){var a=za(l.pendingRequests,b);a!==-1&&l.pendingRequests.splice(a,1)}var j=k.defer(),o=j.promise,m,p,w=r(b.url,b.params);l.pendingRequests.push(b);o.then(i,i);b.cache&&b.method=="GET"&&(m=L(b.cache)?b.cache:n);if(m)if(p=m.get(w))if(p.then)return p.then(i,i),p;else J(p)?f(p[1],p[0],V(p[2])):f(p,200,{});else m.put(w,o);p||a(b.method,
14.97 +w,c,e,d,b.timeout,b.withCredentials);return o}function r(a,b){if(!b)return a;var c=[];ec(b,function(a,b){a==null||a==p||(L(a)&&(a=da(a)),c.push(encodeURIComponent(b)+"="+encodeURIComponent(a)))});return a+(a.indexOf("?")==-1?"?":"&")+c.join("&")}var n=c("$http"),w=[];m(e,function(a){w.push(F(a)?j.get(a):j.invoke(a))});l.pendingRequests=[];(function(a){m(arguments,function(a){l[a]=function(b,c){return l(x(c||{},{method:a,url:b}))}})})("get","delete","head","jsonp");(function(a){m(arguments,function(a){l[a]=
14.98 +function(b,c,d){return l(x(d||{},{method:a,url:b,data:c}))}})})("post","put");l.defaults=d;return l}]}function Wc(){this.$get=["$browser","$window","$document",function(b,a,c){return Xc(b,Yc,b.defer,a.angular.callbacks,c[0],a.location.protocol.replace(":",""))}]}function Xc(b,a,c,d,e,g){function i(a,b){var c=e.createElement("script"),d=function(){e.body.removeChild(c);b&&b()};c.type="text/javascript";c.src=a;aa?c.onreadystatechange=function(){/loaded|complete/.test(c.readyState)&&d()}:c.onload=c.onerror=
14.99 +d;e.body.appendChild(c)}return function(e,h,k,j,l,o,r){function n(a,c,d,e){c=(h.match(Fb)||["",g])[1]=="file"?d?200:404:c;a(c==1223?204:c,d,e);b.$$completeOutstandingRequest(D)}b.$$incOutstandingRequestCount();h=h||b.url();if(E(e)=="jsonp"){var p="_"+(d.counter++).toString(36);d[p]=function(a){d[p].data=a};i(h.replace("JSON_CALLBACK","angular.callbacks."+p),function(){d[p].data?n(j,200,d[p].data):n(j,-2);delete d[p]})}else{var q=new a;q.open(e,h,!0);m(l,function(a,b){a&&q.setRequestHeader(b,a)});
14.100 +var s;q.onreadystatechange=function(){q.readyState==4&&n(j,s||q.status,q.responseText,q.getAllResponseHeaders())};if(r)q.withCredentials=!0;q.send(k||"");o>0&&c(function(){s=-1;q.abort()},o)}}}function Zc(){this.$get=function(){return{id:"en-us",NUMBER_FORMATS:{DECIMAL_SEP:".",GROUP_SEP:",",PATTERNS:[{minInt:1,minFrac:0,maxFrac:3,posPre:"",posSuf:"",negPre:"-",negSuf:"",gSize:3,lgSize:3},{minInt:1,minFrac:2,maxFrac:2,posPre:"\u00a4",posSuf:"",negPre:"(\u00a4",negSuf:")",gSize:3,lgSize:3}],CURRENCY_SYM:"$"},
14.101 +DATETIME_FORMATS:{MONTH:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),SHORTMONTH:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),DAY:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),SHORTDAY:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(","),AMPMS:["AM","PM"],medium:"MMM d, y h:mm:ss a","short":"M/d/yy h:mm a",fullDate:"EEEE, MMMM d, y",longDate:"MMMM d, y",mediumDate:"MMM d, y",shortDate:"M/d/yy",mediumTime:"h:mm:ss a",
14.102 +shortTime:"h:mm a"},pluralCat:function(b){return b===1?"one":"other"}}}}function $c(){this.$get=["$rootScope","$browser","$q","$exceptionHandler",function(b,a,c,d){function e(e,f,h){var k=c.defer(),j=k.promise,l=v(h)&&!h,f=a.defer(function(){try{k.resolve(e())}catch(a){k.reject(a),d(a)}l||b.$apply()},f),h=function(){delete g[j.$$timeoutId]};j.$$timeoutId=f;g[f]=k;j.then(h,h);return j}var g={};e.cancel=function(b){return b&&b.$$timeoutId in g?(g[b.$$timeoutId].reject("canceled"),a.defer.cancel(b.$$timeoutId)):
14.103 +!1};return e}]}function Pb(b){function a(a,e){return b.factory(a+c,e)}var c="Filter";this.register=a;this.$get=["$injector",function(a){return function(b){return a.get(b+c)}}];a("currency",Qb);a("date",Rb);a("filter",ad);a("json",bd);a("limitTo",cd);a("lowercase",dd);a("number",Sb);a("orderBy",Tb);a("uppercase",ed)}function ad(){return function(b,a){if(!(b instanceof Array))return b;var c=[];c.check=function(a){for(var b=0;b<c.length;b++)if(!c[b](a))return!1;return!0};var d=function(a,b){if(b.charAt(0)===
14.104 +"!")return!d(a,b.substr(1));switch(typeof a){case "boolean":case "number":case "string":return(""+a).toLowerCase().indexOf(b)>-1;case "object":for(var c in a)if(c.charAt(0)!=="$"&&d(a[c],b))return!0;return!1;case "array":for(c=0;c<a.length;c++)if(d(a[c],b))return!0;return!1;default:return!1}};switch(typeof a){case "boolean":case "number":case "string":a={$:a};case "object":for(var e in a)e=="$"?function(){var b=(""+a[e]).toLowerCase();b&&c.push(function(a){return d(a,b)})}():function(){var b=e,f=
14.105 +(""+a[e]).toLowerCase();f&&c.push(function(a){return d(fb(a,b),f)})}();break;case "function":c.push(a);break;default:return b}for(var g=[],i=0;i<b.length;i++){var f=b[i];c.check(f)&&g.push(f)}return g}}function Qb(b){var a=b.NUMBER_FORMATS;return function(b,d){if(t(d))d=a.CURRENCY_SYM;return Ub(b,a.PATTERNS[1],a.GROUP_SEP,a.DECIMAL_SEP,2).replace(/\u00A4/g,d)}}function Sb(b){var a=b.NUMBER_FORMATS;return function(b,d){return Ub(b,a.PATTERNS[0],a.GROUP_SEP,a.DECIMAL_SEP,d)}}function Ub(b,a,c,d,e){if(isNaN(b)||
14.106 +!isFinite(b))return"";var g=b<0,b=Math.abs(b),i=b+"",f="",h=[],k=!1;if(i.indexOf("e")!==-1){var j=i.match(/([\d\.]+)e(-?)(\d+)/);j&&j[2]=="-"&&j[3]>e+1?i="0":(f=i,k=!0)}if(!k){i=(i.split(Vb)[1]||"").length;t(e)&&(e=Math.min(Math.max(a.minFrac,i),a.maxFrac));var i=Math.pow(10,e),b=Math.round(b*i)/i,b=(""+b).split(Vb),i=b[0],b=b[1]||"",k=0,j=a.lgSize,l=a.gSize;if(i.length>=j+l)for(var k=i.length-j,o=0;o<k;o++)(k-o)%l===0&&o!==0&&(f+=c),f+=i.charAt(o);for(o=k;o<i.length;o++)(i.length-o)%j===0&&o!==0&&
14.107 +(f+=c),f+=i.charAt(o);for(;b.length<e;)b+="0";e&&(f+=d+b.substr(0,e))}h.push(g?a.negPre:a.posPre);h.push(f);h.push(g?a.negSuf:a.posSuf);return h.join("")}function ib(b,a,c){var d="";b<0&&(d="-",b=-b);for(b=""+b;b.length<a;)b="0"+b;c&&(b=b.substr(b.length-a));return d+b}function P(b,a,c,d){return function(e){e=e["get"+b]();if(c>0||e>-c)e+=c;e===0&&c==-12&&(e=12);return ib(e,a,d)}}function La(b,a){return function(c,d){var e=c["get"+b](),g=la(a?"SHORT"+b:b);return d[g][e]}}function Rb(b){function a(a){var b;
14.108 +if(b=a.match(c)){var a=new Date(0),g=0,i=0;b[9]&&(g=G(b[9]+b[10]),i=G(b[9]+b[11]));a.setUTCFullYear(G(b[1]),G(b[2])-1,G(b[3]));a.setUTCHours(G(b[4]||0)-g,G(b[5]||0)-i,G(b[6]||0),G(b[7]||0))}return a}var c=/^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;return function(c,e){var g="",i=[],f,h,e=e||"mediumDate",e=b.DATETIME_FORMATS[e]||e;F(c)&&(c=fd.test(c)?G(c):a(c));wa(c)&&(c=new Date(c));if(!na(c))return c;for(;e;)(h=gd.exec(e))?(i=i.concat(ia.call(h,
14.109 +1)),e=i.pop()):(i.push(e),e=null);m(i,function(a){f=hd[a];g+=f?f(c,b.DATETIME_FORMATS):a.replace(/(^'|'$)/g,"").replace(/''/g,"'")});return g}}function bd(){return function(b){return da(b,!0)}}function cd(){return function(b,a){if(!(b instanceof Array))return b;var a=G(a),c=[],d,e;if(!b||!(b instanceof Array))return c;a>b.length?a=b.length:a<-b.length&&(a=-b.length);a>0?(d=0,e=a):(d=b.length+a,e=b.length);for(;d<e;d++)c.push(b[d]);return c}}function Tb(b){return function(a,c,d){function e(a,b){return Wa(b)?
14.110 +function(b,c){return a(c,b)}:a}if(!(a instanceof Array))return a;if(!c)return a;for(var c=J(c)?c:[c],c=Ta(c,function(a){var c=!1,d=a||ma;if(F(a)){if(a.charAt(0)=="+"||a.charAt(0)=="-")c=a.charAt(0)=="-",a=a.substring(1);d=b(a)}return e(function(a,b){var c;c=d(a);var e=d(b),f=typeof c,g=typeof e;f==g?(f=="string"&&(c=c.toLowerCase()),f=="string"&&(e=e.toLowerCase()),c=c===e?0:c<e?-1:1):c=f<g?-1:1;return c},c)}),g=[],i=0;i<a.length;i++)g.push(a[i]);return g.sort(e(function(a,b){for(var d=0;d<c.length;d++){var e=
14.111 +c[d](a,b);if(e!==0)return e}return 0},d))}}function S(b){N(b)&&(b={link:b});b.restrict=b.restrict||"AC";return I(b)}function Wb(b,a){function c(a,c){c=c?"-"+$a(c,"-"):"";b.removeClass((a?Ma:Na)+c).addClass((a?Na:Ma)+c)}var d=this,e=b.parent().controller("form")||Oa,g=0,i=d.$error={};d.$name=a.name;d.$dirty=!1;d.$pristine=!0;d.$valid=!0;d.$invalid=!1;e.$addControl(d);b.addClass(Pa);c(!0);d.$addControl=function(a){a.$name&&!d.hasOwnProperty(a.$name)&&(d[a.$name]=a)};d.$removeControl=function(a){a.$name&&
14.112 +d[a.$name]===a&&delete d[a.$name];m(i,function(b,c){d.$setValidity(c,!0,a)})};d.$setValidity=function(a,b,k){var j=i[a];if(b){if(j&&(Ua(j,k),!j.length)){g--;if(!g)c(b),d.$valid=!0,d.$invalid=!1;i[a]=!1;c(!0,a);e.$setValidity(a,!0,d)}}else{g||c(b);if(j){if(za(j,k)!=-1)return}else i[a]=j=[],g++,c(!1,a),e.$setValidity(a,!1,d);j.push(k);d.$valid=!1;d.$invalid=!0}};d.$setDirty=function(){b.removeClass(Pa).addClass(Xb);d.$dirty=!0;d.$pristine=!1;e.$setDirty()}}function T(b){return t(b)||b===""||b===null||
14.113 +b!==b}function Qa(b,a,c,d,e,g){var i=function(){var c=R(a.val());d.$viewValue!==c&&b.$apply(function(){d.$setViewValue(c)})};if(e.hasEvent("input"))a.bind("input",i);else{var f;a.bind("keydown",function(a){a=a.keyCode;a===91||15<a&&a<19||37<=a&&a<=40||f||(f=g.defer(function(){i();f=null}))});a.bind("change",i)}d.$render=function(){a.val(T(d.$viewValue)?"":d.$viewValue)};var h=c.ngPattern,k=function(a,b){return T(b)||a.test(b)?(d.$setValidity("pattern",!0),b):(d.$setValidity("pattern",!1),p)};h&&(h.match(/^\/(.*)\/$/)?
14.114 +(h=RegExp(h.substr(1,h.length-2)),e=function(a){return k(h,a)}):e=function(a){var c=b.$eval(h);if(!c||!c.test)throw new B("Expected "+h+" to be a RegExp but was "+c);return k(c,a)},d.$formatters.push(e),d.$parsers.push(e));if(c.ngMinlength){var j=G(c.ngMinlength),e=function(a){return!T(a)&&a.length<j?(d.$setValidity("minlength",!1),p):(d.$setValidity("minlength",!0),a)};d.$parsers.push(e);d.$formatters.push(e)}if(c.ngMaxlength){var l=G(c.ngMaxlength),c=function(a){return!T(a)&&a.length>l?(d.$setValidity("maxlength",
14.115 +!1),p):(d.$setValidity("maxlength",!0),a)};d.$parsers.push(c);d.$formatters.push(c)}}function jb(b,a){b="ngClass"+b;return S(function(c,d,e){function g(b,d){if(a===!0||c.$index%2===a)d&&b!==d&&i(d),f(b)}function i(a){L(a)&&!J(a)&&(a=Ta(a,function(a,b){if(a)return b}));d.removeClass(J(a)?a.join(" "):a)}function f(a){L(a)&&!J(a)&&(a=Ta(a,function(a,b){if(a)return b}));a&&d.addClass(J(a)?a.join(" "):a)}c.$watch(e[b],g,!0);e.$observe("class",function(){var a=c.$eval(e[b]);g(a,a)});b!=="ngClass"&&c.$watch("$index",
14.116 +function(d,g){var j=d%2;j!==g%2&&(j==a?f(c.$eval(e[b])):i(c.$eval(e[b])))})})}var E=function(b){return F(b)?b.toLowerCase():b},la=function(b){return F(b)?b.toUpperCase():b},B=U.Error,aa=G((/msie (\d+)/.exec(E(navigator.userAgent))||[])[1]),u,ja,ia=[].slice,Ra=[].push,Sa=Object.prototype.toString,Yb=U.angular||(U.angular={}),ta,Cb,Z=["0","0","0"];D.$inject=[];ma.$inject=[];Cb=aa<9?function(b){b=b.nodeName?b:b[0];return b.scopeName&&b.scopeName!="HTML"?la(b.scopeName+":"+b.nodeName):b.nodeName}:function(b){return b.nodeName?
14.117 +b.nodeName:b[0].nodeName};var kc=/[A-Z]/g,id={full:"1.0.3",major:1,minor:0,dot:3,codeName:"bouncy-thunder"},Ba=Q.cache={},Aa=Q.expando="ng-"+(new Date).getTime(),oc=1,Zb=U.document.addEventListener?function(b,a,c){b.addEventListener(a,c,!1)}:function(b,a,c){b.attachEvent("on"+a,c)},db=U.document.removeEventListener?function(b,a,c){b.removeEventListener(a,c,!1)}:function(b,a,c){b.detachEvent("on"+a,c)},mc=/([\:\-\_]+(.))/g,nc=/^moz([A-Z])/,ua=Q.prototype={ready:function(b){function a(){c||(c=!0,b())}
14.118 +var c=!1;this.bind("DOMContentLoaded",a);Q(U).bind("load",a)},toString:function(){var b=[];m(this,function(a){b.push(""+a)});return"["+b.join(", ")+"]"},eq:function(b){return b>=0?u(this[b]):u(this[this.length+b])},length:0,push:Ra,sort:[].sort,splice:[].splice},Ea={};m("multiple,selected,checked,disabled,readOnly,required".split(","),function(b){Ea[E(b)]=b});var zb={};m("input,select,option,textarea,button,form".split(","),function(b){zb[la(b)]=!0});m({data:ub,inheritedData:Da,scope:function(b){return Da(b,
14.119 +"$scope")},controller:xb,injector:function(b){return Da(b,"$injector")},removeAttr:function(b,a){b.removeAttribute(a)},hasClass:Ca,css:function(b,a,c){a=rb(a);if(v(c))b.style[a]=c;else{var d;aa<=8&&(d=b.currentStyle&&b.currentStyle[a],d===""&&(d="auto"));d=d||b.style[a];aa<=8&&(d=d===""?p:d);return d}},attr:function(b,a,c){var d=E(a);if(Ea[d])if(v(c))c?(b[a]=!0,b.setAttribute(a,d)):(b[a]=!1,b.removeAttribute(d));else return b[a]||(b.attributes.getNamedItem(a)||D).specified?d:p;else if(v(c))b.setAttribute(a,
14.120 +c);else if(b.getAttribute)return b=b.getAttribute(a,2),b===null?p:b},prop:function(b,a,c){if(v(c))b[a]=c;else return b[a]},text:x(aa<9?function(b,a){if(b.nodeType==1){if(t(a))return b.innerText;b.innerText=a}else{if(t(a))return b.nodeValue;b.nodeValue=a}}:function(b,a){if(t(a))return b.textContent;b.textContent=a},{$dv:""}),val:function(b,a){if(t(a))return b.value;b.value=a},html:function(b,a){if(t(a))return b.innerHTML;for(var c=0,d=b.childNodes;c<d.length;c++)sa(d[c]);b.innerHTML=a}},function(b,
14.121 +a){Q.prototype[a]=function(a,d){var e,g;if((b.length==2&&b!==Ca&&b!==xb?a:d)===p)if(L(a)){for(e=0;e<this.length;e++)if(b===ub)b(this[e],a);else for(g in a)b(this[e],g,a[g]);return this}else{if(this.length)return b(this[0],a,d)}else{for(e=0;e<this.length;e++)b(this[e],a,d);return this}return b.$dv}});m({removeData:sb,dealoc:sa,bind:function a(c,d,e){var g=$(c,"events"),i=$(c,"handle");g||$(c,"events",g={});i||$(c,"handle",i=pc(c,g));m(d.split(" "),function(d){var h=g[d];if(!h){if(d=="mouseenter"||
14.122 +d=="mouseleave"){var k=0;g.mouseenter=[];g.mouseleave=[];a(c,"mouseover",function(a){k++;k==1&&i(a,"mouseenter")});a(c,"mouseout",function(a){k--;k==0&&i(a,"mouseleave")})}else Zb(c,d,i),g[d]=[];h=g[d]}h.push(e)})},unbind:tb,replaceWith:function(a,c){var d,e=a.parentNode;sa(a);m(new Q(c),function(c){d?e.insertBefore(c,d.nextSibling):e.replaceChild(c,a);d=c})},children:function(a){var c=[];m(a.childNodes,function(a){a.nodeName!="#text"&&c.push(a)});return c},contents:function(a){return a.childNodes},
14.123 +append:function(a,c){m(new Q(c),function(c){a.nodeType===1&&a.appendChild(c)})},prepend:function(a,c){if(a.nodeType===1){var d=a.firstChild;m(new Q(c),function(c){d?a.insertBefore(c,d):(a.appendChild(c),d=c)})}},wrap:function(a,c){var c=u(c)[0],d=a.parentNode;d&&d.replaceChild(c,a);c.appendChild(a)},remove:function(a){sa(a);var c=a.parentNode;c&&c.removeChild(a)},after:function(a,c){var d=a,e=a.parentNode;m(new Q(c),function(a){e.insertBefore(a,d.nextSibling);d=a})},addClass:wb,removeClass:vb,toggleClass:function(a,
14.124 +c,d){t(d)&&(d=!Ca(a,c));(d?wb:vb)(a,c)},parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},next:function(a){return a.nextSibling},find:function(a,c){return a.getElementsByTagName(c)},clone:cb,triggerHandler:function(a,c){var d=($(a,"events")||{})[c];m(d,function(c){c.call(a,null)})}},function(a,c){Q.prototype[c]=function(c,e){for(var g,i=0;i<this.length;i++)g==p?(g=a(this[i],c,e),g!==p&&(g=u(g))):bb(g,a(this[i],c,e));return g==p?this:g}});Fa.prototype={put:function(a,c){this[ga(a)]=
14.125 +c},get:function(a){return this[ga(a)]},remove:function(a){var c=this[a=ga(a)];delete this[a];return c}};eb.prototype={push:function(a,c){var d=this[a=ga(a)];d?d.push(c):this[a]=[c]},shift:function(a){var c=this[a=ga(a)];if(c)return c.length==1?(delete this[a],c[0]):c.shift()},peek:function(a){if(a=this[ga(a)])return a[0]}};var rc=/^function\s*[^\(]*\(\s*([^\)]*)\)/m,sc=/,/,tc=/^\s*(_?)(\S+?)\1\s*$/,qc=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg,Db="Non-assignable model expression: ";Bb.$inject=["$provide"];
14.126 +var Ac=/^(x[\:\-_]|data[\:\-_])/i,Fb=/^([^:]+):\/\/(\w+:{0,1}\w*@)?([\w\.-]*)(:([0-9]+))?(\/[^\?#]*)?(\?([^#]*))?(#(.*))?$/,$b=/^([^\?#]*)?(\?([^#]*))?(#(.*))?$/,Hc=$b,Gb={http:80,https:443,ftp:21};gb.prototype={$$replace:!1,absUrl:Ja("$$absUrl"),url:function(a,c){if(t(a))return this.$$url;var d=$b.exec(a);d[1]&&this.path(decodeURIComponent(d[1]));if(d[2]||d[1])this.search(d[3]||"");this.hash(d[5]||"",c);return this},protocol:Ja("$$protocol"),host:Ja("$$host"),port:Ja("$$port"),path:Ib("$$path",function(a){return a.charAt(0)==
14.127 +"/"?a:"/"+a}),search:function(a,c){if(t(a))return this.$$search;v(c)?c===null?delete this.$$search[a]:this.$$search[a]=c:this.$$search=F(a)?Xa(a):a;this.$$compose();return this},hash:Ib("$$hash",ma),replace:function(){this.$$replace=!0;return this}};Ia.prototype=ya(gb.prototype);Hb.prototype=ya(Ia.prototype);var Ka={"null":function(){return null},"true":function(){return!0},"false":function(){return!1},undefined:D,"+":function(a,c,d,e){d=d(a,c);e=e(a,c);return v(d)?v(e)?d+e:d:v(e)?e:p},"-":function(a,
14.128 +c,d,e){d=d(a,c);e=e(a,c);return(v(d)?d:0)-(v(e)?e:0)},"*":function(a,c,d,e){return d(a,c)*e(a,c)},"/":function(a,c,d,e){return d(a,c)/e(a,c)},"%":function(a,c,d,e){return d(a,c)%e(a,c)},"^":function(a,c,d,e){return d(a,c)^e(a,c)},"=":D,"==":function(a,c,d,e){return d(a,c)==e(a,c)},"!=":function(a,c,d,e){return d(a,c)!=e(a,c)},"<":function(a,c,d,e){return d(a,c)<e(a,c)},">":function(a,c,d,e){return d(a,c)>e(a,c)},"<=":function(a,c,d,e){return d(a,c)<=e(a,c)},">=":function(a,c,d,e){return d(a,c)>=e(a,
14.129 +c)},"&&":function(a,c,d,e){return d(a,c)&&e(a,c)},"||":function(a,c,d,e){return d(a,c)||e(a,c)},"&":function(a,c,d,e){return d(a,c)&e(a,c)},"|":function(a,c,d,e){return e(a,c)(a,c,d(a,c))},"!":function(a,c,d){return!d(a,c)}},Lc={n:"\n",f:"\u000c",r:"\r",t:"\t",v:"\u000b","'":"'",'"':'"'},hb={},Yc=U.XMLHttpRequest||function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(a){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(c){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(d){}throw new B("This browser does not support XMLHttpRequest.");
14.130 +};Pb.$inject=["$provide"];Qb.$inject=["$locale"];Sb.$inject=["$locale"];var Vb=".",hd={yyyy:P("FullYear",4),yy:P("FullYear",2,0,!0),y:P("FullYear",1),MMMM:La("Month"),MMM:La("Month",!0),MM:P("Month",2,1),M:P("Month",1,1),dd:P("Date",2),d:P("Date",1),HH:P("Hours",2),H:P("Hours",1),hh:P("Hours",2,-12),h:P("Hours",1,-12),mm:P("Minutes",2),m:P("Minutes",1),ss:P("Seconds",2),s:P("Seconds",1),EEEE:La("Day"),EEE:La("Day",!0),a:function(a,c){return a.getHours()<12?c.AMPMS[0]:c.AMPMS[1]},Z:function(a){a=a.getTimezoneOffset();
14.131 +return ib(a/60,2)+ib(Math.abs(a%60),2)}},gd=/((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,fd=/^\d+$/;Rb.$inject=["$locale"];var dd=I(E),ed=I(la);Tb.$inject=["$parse"];var jd=I({restrict:"E",compile:function(a,c){c.href||c.$set("href","");return function(a,c){c.bind("click",function(a){if(!c.attr("href"))return a.preventDefault(),!1})}}}),kb={};m(Ea,function(a,c){var d=fa("ng-"+c);kb[d]=function(){return{priority:100,compile:function(){return function(a,g,i){a.$watch(i[d],
14.132 +function(a){i.$set(c,!!a)})}}}}});m(["src","href"],function(a){var c=fa("ng-"+a);kb[c]=function(){return{priority:99,link:function(d,e,g){g.$observe(c,function(c){c&&(g.$set(a,c),aa&&e.prop(a,c))})}}}});var Oa={$addControl:D,$removeControl:D,$setValidity:D,$setDirty:D};Wb.$inject=["$element","$attrs","$scope"];var Ra=function(a){return["$timeout",function(c){var d={name:"form",restrict:"E",controller:Wb,compile:function(){return{pre:function(a,d,i,f){if(!i.action){var h=function(a){a.preventDefault?
14.133 +a.preventDefault():a.returnValue=!1};Zb(d[0],"submit",h);d.bind("$destroy",function(){c(function(){db(d[0],"submit",h)},0,!1)})}var k=d.parent().controller("form"),j=i.name||i.ngForm;j&&(a[j]=f);k&&d.bind("$destroy",function(){k.$removeControl(f);j&&(a[j]=p);x(f,Oa)})}}}};return a?x(V(d),{restrict:"EAC"}):d}]},kd=Ra(),ld=Ra(!0),md=/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/,nd=/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/,od=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/,
14.134 +ac={text:Qa,number:function(a,c,d,e,g,i){Qa(a,c,d,e,g,i);e.$parsers.push(function(a){var c=T(a);return c||od.test(a)?(e.$setValidity("number",!0),a===""?null:c?a:parseFloat(a)):(e.$setValidity("number",!1),p)});e.$formatters.push(function(a){return T(a)?"":""+a});if(d.min){var f=parseFloat(d.min),a=function(a){return!T(a)&&a<f?(e.$setValidity("min",!1),p):(e.$setValidity("min",!0),a)};e.$parsers.push(a);e.$formatters.push(a)}if(d.max){var h=parseFloat(d.max),d=function(a){return!T(a)&&a>h?(e.$setValidity("max",
14.135 +!1),p):(e.$setValidity("max",!0),a)};e.$parsers.push(d);e.$formatters.push(d)}e.$formatters.push(function(a){return T(a)||wa(a)?(e.$setValidity("number",!0),a):(e.$setValidity("number",!1),p)})},url:function(a,c,d,e,g,i){Qa(a,c,d,e,g,i);a=function(a){return T(a)||md.test(a)?(e.$setValidity("url",!0),a):(e.$setValidity("url",!1),p)};e.$formatters.push(a);e.$parsers.push(a)},email:function(a,c,d,e,g,i){Qa(a,c,d,e,g,i);a=function(a){return T(a)||nd.test(a)?(e.$setValidity("email",!0),a):(e.$setValidity("email",
14.136 +!1),p)};e.$formatters.push(a);e.$parsers.push(a)},radio:function(a,c,d,e){t(d.name)&&c.attr("name",xa());c.bind("click",function(){c[0].checked&&a.$apply(function(){e.$setViewValue(d.value)})});e.$render=function(){c[0].checked=d.value==e.$viewValue};d.$observe("value",e.$render)},checkbox:function(a,c,d,e){var g=d.ngTrueValue,i=d.ngFalseValue;F(g)||(g=!0);F(i)||(i=!1);c.bind("click",function(){a.$apply(function(){e.$setViewValue(c[0].checked)})});e.$render=function(){c[0].checked=e.$viewValue};e.$formatters.push(function(a){return a===
14.137 +g});e.$parsers.push(function(a){return a?g:i})},hidden:D,button:D,submit:D,reset:D},bc=["$browser","$sniffer",function(a,c){return{restrict:"E",require:"?ngModel",link:function(d,e,g,i){i&&(ac[E(g.type)]||ac.text)(d,e,g,i,c,a)}}}],Na="ng-valid",Ma="ng-invalid",Pa="ng-pristine",Xb="ng-dirty",pd=["$scope","$exceptionHandler","$attrs","$element","$parse",function(a,c,d,e,g){function i(a,c){c=c?"-"+$a(c,"-"):"";e.removeClass((a?Ma:Na)+c).addClass((a?Na:Ma)+c)}this.$modelValue=this.$viewValue=Number.NaN;
14.138 +this.$parsers=[];this.$formatters=[];this.$viewChangeListeners=[];this.$pristine=!0;this.$dirty=!1;this.$valid=!0;this.$invalid=!1;this.$name=d.name;var f=g(d.ngModel),h=f.assign;if(!h)throw B(Db+d.ngModel+" ("+pa(e)+")");this.$render=D;var k=e.inheritedData("$formController")||Oa,j=0,l=this.$error={};e.addClass(Pa);i(!0);this.$setValidity=function(a,c){if(l[a]!==!c){if(c){if(l[a]&&j--,!j)i(!0),this.$valid=!0,this.$invalid=!1}else i(!1),this.$invalid=!0,this.$valid=!1,j++;l[a]=!c;i(c,a);k.$setValidity(a,
14.139 +c,this)}};this.$setViewValue=function(d){this.$viewValue=d;if(this.$pristine)this.$dirty=!0,this.$pristine=!1,e.removeClass(Pa).addClass(Xb),k.$setDirty();m(this.$parsers,function(a){d=a(d)});if(this.$modelValue!==d)this.$modelValue=d,h(a,d),m(this.$viewChangeListeners,function(a){try{a()}catch(d){c(d)}})};var o=this;a.$watch(function(){var c=f(a);if(o.$modelValue!==c){var d=o.$formatters,e=d.length;for(o.$modelValue=c;e--;)c=d[e](c);if(o.$viewValue!==c)o.$viewValue=c,o.$render()}})}],qd=function(){return{require:["ngModel",
14.140 +"^?form"],controller:pd,link:function(a,c,d,e){var g=e[0],i=e[1]||Oa;i.$addControl(g);c.bind("$destroy",function(){i.$removeControl(g)})}}},rd=I({require:"ngModel",link:function(a,c,d,e){e.$viewChangeListeners.push(function(){a.$eval(d.ngChange)})}}),cc=function(){return{require:"?ngModel",link:function(a,c,d,e){if(e){d.required=!0;var g=function(a){if(d.required&&(T(a)||a===!1))e.$setValidity("required",!1);else return e.$setValidity("required",!0),a};e.$formatters.push(g);e.$parsers.unshift(g);
14.141 +d.$observe("required",function(){g(e.$viewValue)})}}}},sd=function(){return{require:"ngModel",link:function(a,c,d,e){var g=(a=/\/(.*)\//.exec(d.ngList))&&RegExp(a[1])||d.ngList||",";e.$parsers.push(function(a){var c=[];a&&m(a.split(g),function(a){a&&c.push(R(a))});return c});e.$formatters.push(function(a){return J(a)?a.join(", "):p})}}},td=/^(true|false|\d+)$/,ud=function(){return{priority:100,compile:function(a,c){return td.test(c.ngValue)?function(a,c,g){g.$set("value",a.$eval(g.ngValue))}:function(a,
14.142 +c,g){a.$watch(g.ngValue,function(a){g.$set("value",a,!1)})}}}},vd=S(function(a,c,d){c.addClass("ng-binding").data("$binding",d.ngBind);a.$watch(d.ngBind,function(a){c.text(a==p?"":a)})}),wd=["$interpolate",function(a){return function(c,d,e){c=a(d.attr(e.$attr.ngBindTemplate));d.addClass("ng-binding").data("$binding",c);e.$observe("ngBindTemplate",function(a){d.text(a)})}}],xd=[function(){return function(a,c,d){c.addClass("ng-binding").data("$binding",d.ngBindHtmlUnsafe);a.$watch(d.ngBindHtmlUnsafe,
14.143 +function(a){c.html(a||"")})}}],yd=jb("",!0),zd=jb("Odd",0),Ad=jb("Even",1),Bd=S({compile:function(a,c){c.$set("ngCloak",p);a.removeClass("ng-cloak")}}),Cd=[function(){return{scope:!0,controller:"@"}}],Dd=["$sniffer",function(a){return{priority:1E3,compile:function(){a.csp=!0}}}],dc={};m("click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave".split(" "),function(a){var c=fa("ng-"+a);dc[c]=["$parse",function(d){return function(e,g,i){var f=d(i[c]);g.bind(E(a),function(a){e.$apply(function(){f(e,
14.144 +{$event:a})})})}}]});var Ed=S(function(a,c,d){c.bind("submit",function(){a.$apply(d.ngSubmit)})}),Fd=["$http","$templateCache","$anchorScroll","$compile",function(a,c,d,e){return{restrict:"ECA",terminal:!0,compile:function(g,i){var f=i.ngInclude||i.src,h=i.onload||"",k=i.autoscroll;return function(g,i){var o=0,m,n=function(){m&&(m.$destroy(),m=null);i.html("")};g.$watch(f,function(f){var p=++o;f?a.get(f,{cache:c}).success(function(a){p===o&&(m&&m.$destroy(),m=g.$new(),i.html(a),e(i.contents())(m),
14.145 +v(k)&&(!k||g.$eval(k))&&d(),m.$emit("$includeContentLoaded"),g.$eval(h))}).error(function(){p===o&&n()}):n()})}}}}],Gd=S({compile:function(){return{pre:function(a,c,d){a.$eval(d.ngInit)}}}}),Hd=S({terminal:!0,priority:1E3}),Id=["$locale","$interpolate",function(a,c){var d=/{}/g;return{restrict:"EA",link:function(e,g,i){var f=i.count,h=g.attr(i.$attr.when),k=i.offset||0,j=e.$eval(h),l={},o=c.startSymbol(),r=c.endSymbol();m(j,function(a,e){l[e]=c(a.replace(d,o+f+"-"+k+r))});e.$watch(function(){var c=
14.146 +parseFloat(e.$eval(f));return isNaN(c)?"":(j[c]||(c=a.pluralCat(c-k)),l[c](e,g,!0))},function(a){g.text(a)})}}}],Jd=S({transclude:"element",priority:1E3,terminal:!0,compile:function(a,c,d){return function(a,c,i){var f=i.ngRepeat,i=f.match(/^\s*(.+)\s+in\s+(.*)\s*$/),h,k,j;if(!i)throw B("Expected ngRepeat in form of '_item_ in _collection_' but got '"+f+"'.");f=i[1];h=i[2];i=f.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);if(!i)throw B("'item' in 'item in collection' should be identifier or (key, value) but got '"+
14.147 +f+"'.");k=i[3]||i[1];j=i[2];var l=new eb;a.$watch(function(a){var e,f,i=a.$eval(h),m=gc(i,!0),p,u=new eb,C,A,v,t,y=c;if(J(i))v=i||[];else{v=[];for(C in i)i.hasOwnProperty(C)&&C.charAt(0)!="$"&&v.push(C);v.sort()}e=0;for(f=v.length;e<f;e++){C=i===v?e:v[e];A=i[C];if(t=l.shift(A)){p=t.scope;u.push(A,t);if(e!==t.index)t.index=e,y.after(t.element);y=t.element}else p=a.$new();p[k]=A;j&&(p[j]=C);p.$index=e;p.$first=e===0;p.$last=e===m-1;p.$middle=!(p.$first||p.$last);t||d(p,function(a){y.after(a);t={scope:p,
14.148 +element:y=a,index:e};u.push(A,t)})}for(C in l)if(l.hasOwnProperty(C))for(v=l[C];v.length;)A=v.pop(),A.element.remove(),A.scope.$destroy();l=u})}}}),Kd=S(function(a,c,d){a.$watch(d.ngShow,function(a){c.css("display",Wa(a)?"":"none")})}),Ld=S(function(a,c,d){a.$watch(d.ngHide,function(a){c.css("display",Wa(a)?"none":"")})}),Md=S(function(a,c,d){a.$watch(d.ngStyle,function(a,d){d&&a!==d&&m(d,function(a,d){c.css(d,"")});a&&c.css(a)},!0)}),Nd=I({restrict:"EA",compile:function(a,c){var d=c.ngSwitch||c.on,
14.149 +e={};a.data("ng-switch",e);return function(a,i){var f,h,k;a.$watch(d,function(d){h&&(k.$destroy(),h.remove(),h=k=null);if(f=e["!"+d]||e["?"])a.$eval(c.change),k=a.$new(),f(k,function(a){h=a;i.append(a)})})}}}),Od=S({transclude:"element",priority:500,compile:function(a,c,d){a=a.inheritedData("ng-switch");qa(a);a["!"+c.ngSwitchWhen]=d}}),Pd=S({transclude:"element",priority:500,compile:function(a,c,d){a=a.inheritedData("ng-switch");qa(a);a["?"]=d}}),Qd=S({controller:["$transclude","$element",function(a,
14.150 +c){a(function(a){c.append(a)})}]}),Rd=["$http","$templateCache","$route","$anchorScroll","$compile","$controller",function(a,c,d,e,g,i){return{restrict:"ECA",terminal:!0,link:function(a,c,k){function j(){var j=d.current&&d.current.locals,k=j&&j.$template;if(k){c.html(k);l&&(l.$destroy(),l=null);var k=g(c.contents()),p=d.current;l=p.scope=a.$new();if(p.controller)j.$scope=l,j=i(p.controller,j),c.contents().data("$ngControllerController",j);k(l);l.$emit("$viewContentLoaded");l.$eval(m);e()}else c.html(""),
14.151 +l&&(l.$destroy(),l=null)}var l,m=k.onload||"";a.$on("$routeChangeSuccess",j);j()}}}],Sd=["$templateCache",function(a){return{restrict:"E",terminal:!0,compile:function(c,d){d.type=="text/ng-template"&&a.put(d.id,c[0].text)}}}],Td=I({terminal:!0}),Ud=["$compile","$parse",function(a,c){var d=/^\s*(.*?)(?:\s+as\s+(.*?))?(?:\s+group\s+by\s+(.*))?\s+for\s+(?:([\$\w][\$\w\d]*)|(?:\(\s*([\$\w][\$\w\d]*)\s*,\s*([\$\w][\$\w\d]*)\s*\)))\s+in\s+(.*)$/,e={$setViewValue:D};return{restrict:"E",require:["select",
14.152 +"?ngModel"],controller:["$element","$scope","$attrs",function(a,c,d){var h=this,k={},j=e,l;h.databound=d.ngModel;h.init=function(a,c,d){j=a;l=d};h.addOption=function(c){k[c]=!0;j.$viewValue==c&&(a.val(c),l.parent()&&l.remove())};h.removeOption=function(a){this.hasOption(a)&&(delete k[a],j.$viewValue==a&&this.renderUnknownOption(a))};h.renderUnknownOption=function(c){c="? "+ga(c)+" ?";l.val(c);a.prepend(l);a.val(c);l.prop("selected",!0)};h.hasOption=function(a){return k.hasOwnProperty(a)};c.$on("$destroy",
14.153 +function(){h.renderUnknownOption=D})}],link:function(e,i,f,h){function k(a,c,d,e){d.$render=function(){var a=d.$viewValue;e.hasOption(a)?(A.parent()&&A.remove(),c.val(a),a===""&&s.prop("selected",!0)):t(a)&&s?c.val(""):e.renderUnknownOption(a)};c.bind("change",function(){a.$apply(function(){A.parent()&&A.remove();d.$setViewValue(c.val())})})}function j(a,c,d){var e;d.$render=function(){var a=new Fa(d.$viewValue);m(c.children(),function(c){c.selected=v(a.get(c.value))})};a.$watch(function(){ha(e,d.$viewValue)||
14.154 +(e=V(d.$viewValue),d.$render())});c.bind("change",function(){a.$apply(function(){var a=[];m(c.children(),function(c){c.selected&&a.push(c.value)});d.$setViewValue(a)})})}function l(e,f,g){function h(){var a={"":[]},c=[""],d,i,s,t,u;s=g.$modelValue;t=r(e)||[];var y=l?lb(t):t,A,w,x;w={};u=!1;var z,B;if(n)u=new Fa(s);else if(s===null||q)a[""].push({selected:s===null,id:"",label:""}),u=!0;for(x=0;A=y.length,x<A;x++){w[k]=t[l?w[l]=y[x]:x];d=m(e,w)||"";if(!(i=a[d]))i=a[d]=[],c.push(d);n?d=u.remove(o(e,
14.155 +w))!=p:(d=s===o(e,w),u=u||d);z=j(e,w);z=z===p?"":z;i.push({id:l?y[x]:x,label:z,selected:d})}!n&&!u&&a[""].unshift({id:"?",label:"",selected:!0});w=0;for(y=c.length;w<y;w++){d=c[w];i=a[d];if(v.length<=w)s={element:C.clone().attr("label",d),label:i.label},t=[s],v.push(t),f.append(s.element);else if(t=v[w],s=t[0],s.label!=d)s.element.attr("label",s.label=d);z=null;x=0;for(A=i.length;x<A;x++)if(d=i[x],u=t[x+1]){z=u.element;if(u.label!==d.label)z.text(u.label=d.label);if(u.id!==d.id)z.val(u.id=d.id);if(u.element.selected!==
14.156 +d.selected)z.prop("selected",u.selected=d.selected)}else d.id===""&&q?B=q:(B=D.clone()).val(d.id).attr("selected",d.selected).text(d.label),t.push({element:B,label:d.label,id:d.id,selected:d.selected}),z?z.after(B):s.element.append(B),z=B;for(x++;t.length>x;)t.pop().element.remove()}for(;v.length>w;)v.pop()[0].element.remove()}var i;if(!(i=w.match(d)))throw B("Expected ngOptions in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got '"+w+"'.");var j=c(i[2]||i[1]),k=i[4]||
14.157 +i[6],l=i[5],m=c(i[3]||""),o=c(i[2]?i[1]:k),r=c(i[7]),v=[[{element:f,label:""}]];q&&(a(q)(e),q.removeClass("ng-scope"),q.remove());f.html("");f.bind("change",function(){e.$apply(function(){var a,c=r(e)||[],d={},h,i,j,m,q,s;if(n){i=[];m=0;for(s=v.length;m<s;m++){a=v[m];j=1;for(q=a.length;j<q;j++)if((h=a[j].element)[0].selected)h=h.val(),l&&(d[l]=h),d[k]=c[h],i.push(o(e,d))}}else h=f.val(),h=="?"?i=p:h==""?i=null:(d[k]=c[h],l&&(d[l]=h),i=o(e,d));g.$setViewValue(i)})});g.$render=h;e.$watch(h)}if(h[1]){for(var o=
14.158 +h[0],r=h[1],n=f.multiple,w=f.ngOptions,q=!1,s,D=u(ca.createElement("option")),C=u(ca.createElement("optgroup")),A=D.clone(),h=0,x=i.children(),E=x.length;h<E;h++)if(x[h].value==""){s=q=x.eq(h);break}o.init(r,q,A);if(n&&(f.required||f.ngRequired)){var y=function(a){r.$setValidity("required",!f.required||a&&a.length);return a};r.$parsers.push(y);r.$formatters.unshift(y);f.$observe("required",function(){y(r.$viewValue)})}w?l(e,i,r):n?j(e,i,r):k(e,i,r,o)}}}}],Vd=["$interpolate",function(a){var c={addOption:D,
14.159 +removeOption:D};return{restrict:"E",priority:100,compile:function(d,e){if(t(e.value)){var g=a(d.text(),!0);g||e.$set("value",d.text())}return function(a,d,e){var k=d.parent(),j=k.data("$selectController")||k.parent().data("$selectController");j&&j.databound?d.prop("selected",!1):j=c;g?a.$watch(g,function(a,c){e.$set("value",a);a!==c&&j.removeOption(c);j.addOption(a)}):j.addOption(e.value);d.bind("$destroy",function(){j.removeOption(e.value)})}}}}],Wd=I({restrict:"E",terminal:!0});(ja=U.jQuery)?(u=
14.160 +ja,x(ja.fn,{scope:ua.scope,controller:ua.controller,injector:ua.injector,inheritedData:ua.inheritedData}),ab("remove",!0),ab("empty"),ab("html")):u=Q;Yb.element=u;(function(a){x(a,{bootstrap:pb,copy:V,extend:x,equals:ha,element:u,forEach:m,injector:qb,noop:D,bind:Va,toJson:da,fromJson:nb,identity:ma,isUndefined:t,isDefined:v,isString:F,isFunction:N,isObject:L,isNumber:wa,isElement:fc,isArray:J,version:id,isDate:na,lowercase:E,uppercase:la,callbacks:{counter:0}});ta=lc(U);try{ta("ngLocale")}catch(c){ta("ngLocale",
14.161 +[]).provider("$locale",Zc)}ta("ng",["ngLocale"],["$provide",function(a){a.provider("$compile",Bb).directive({a:jd,input:bc,textarea:bc,form:kd,script:Sd,select:Ud,style:Wd,option:Vd,ngBind:vd,ngBindHtmlUnsafe:xd,ngBindTemplate:wd,ngClass:yd,ngClassEven:Ad,ngClassOdd:zd,ngCsp:Dd,ngCloak:Bd,ngController:Cd,ngForm:ld,ngHide:Ld,ngInclude:Fd,ngInit:Gd,ngNonBindable:Hd,ngPluralize:Id,ngRepeat:Jd,ngShow:Kd,ngSubmit:Ed,ngStyle:Md,ngSwitch:Nd,ngSwitchWhen:Od,ngSwitchDefault:Pd,ngOptions:Td,ngView:Rd,ngTransclude:Qd,
14.162 +ngModel:qd,ngList:sd,ngChange:rd,required:cc,ngRequired:cc,ngValue:ud}).directive(kb).directive(dc);a.provider({$anchorScroll:uc,$browser:wc,$cacheFactory:xc,$controller:Bc,$document:Cc,$exceptionHandler:Dc,$filter:Pb,$interpolate:Ec,$http:Vc,$httpBackend:Wc,$location:Ic,$log:Jc,$parse:Nc,$route:Qc,$routeParams:Rc,$rootScope:Sc,$q:Oc,$sniffer:Tc,$templateCache:yc,$timeout:$c,$window:Uc})}])})(Yb);u(ca).ready(function(){jc(ca,pb)})})(window,document);angular.element(document).find("head").append('<style type="text/css">@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak{display:none;}ng\\:form{display:block;}</style>');
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/dew/src/main/resources/org/apidesign/bck2brwsr/dew/js/app.js Wed Jan 23 14:16:13 2013 +0100
15.3 @@ -0,0 +1,224 @@
15.4 +// 'use strict';
15.5 +
15.6 +// Declare app level module which depends on filters, and services
15.7 +angular.module('bck2brwsr', []).
15.8 + directive('uiCodemirror', ['$timeout', function($timeout) {
15.9 + 'use strict';
15.10 +
15.11 + var events = ["cursorActivity", "viewportChange", "gutterClick", "focus", "blur", "scroll", "update"];
15.12 + return {
15.13 + restrict: 'A',
15.14 + require: 'ngModel',
15.15 + link: function(scope, elm, attrs, ngModel) {
15.16 + var options, opts, onChange, deferCodeMirror, codeMirror, timeoutId, val;
15.17 +
15.18 + if (elm[0].type !== 'textarea') {
15.19 + throw new Error('uiCodemirror3 can only be applied to a textarea element');
15.20 + }
15.21 +
15.22 + options = /* uiConfig.codemirror || */ {};
15.23 + opts = angular.extend({}, options, scope.$eval(attrs.uiCodemirror));
15.24 +
15.25 + onChange = function(instance, changeObj) {
15.26 + val = instance.getValue();
15.27 + $timeout.cancel(timeoutId);
15.28 + timeoutId = $timeout(function() {
15.29 + ngModel.$setViewValue(val);
15.30 + }, 500);
15.31 + };
15.32 +
15.33 + deferCodeMirror = function() {
15.34 + codeMirror = CodeMirror.fromTextArea(elm[0], opts);
15.35 + elm[0].codeMirror = codeMirror;
15.36 + // codeMirror.on("change", onChange(opts.onChange));
15.37 + codeMirror.on("change", onChange);
15.38 +
15.39 + for (var i = 0, n = events.length, aEvent; i < n; ++i) {
15.40 + aEvent = opts["on" + events[i].charAt(0).toUpperCase() + events[i].slice(1)];
15.41 + if (aEvent === void 0)
15.42 + continue;
15.43 + if (typeof aEvent !== "function")
15.44 + continue;
15.45 +
15.46 + var bound = _.bind( aEvent, scope );
15.47 +
15.48 + codeMirror.on(events[i], bound);
15.49 + }
15.50 +
15.51 + // CodeMirror expects a string, so make sure it gets one.
15.52 + // This does not change the model.
15.53 + ngModel.$formatters.push(function(value) {
15.54 + if (angular.isUndefined(value) || value === null) {
15.55 + return '';
15.56 + }
15.57 + else if (angular.isObject(value) || angular.isArray(value)) {
15.58 + throw new Error('ui-codemirror cannot use an object or an array as a model');
15.59 + }
15.60 + return value;
15.61 + });
15.62 +
15.63 + // Override the ngModelController $render method, which is what gets called when the model is updated.
15.64 + // This takes care of the synchronizing the codeMirror element with the underlying model, in the case that it is changed by something else.
15.65 + ngModel.$render = function() {
15.66 + codeMirror.setValue(ngModel.$viewValue);
15.67 + };
15.68 +
15.69 + };
15.70 +
15.71 + $timeout(deferCodeMirror);
15.72 +
15.73 + }
15.74 + };
15.75 +}]);
15.76 +
15.77 +function DevCtrl( $scope, $http ) {
15.78 + var templateHtml =
15.79 +"<html><body>\n" +
15.80 +" <input data-bind=\"value: value, valueUpdate: 'afterkeydown'\" \n" +
15.81 +" value=\"0\" type=\"number\">\n" +
15.82 +" </input>\n" +
15.83 +" * <span data-bind=\"text: value\">0</span> \n" +
15.84 +" = <span data-bind=\"text: powerValue\">0</span>\n" +
15.85 +" <br/>\n" +
15.86 +" <button id='dupl'>Duplicate!</button>\n" +
15.87 +" <button id=\"clear\">Clear!</button>" +
15.88 +" <hr/>\n" +
15.89 +"\n" +
15.90 +"\n" +
15.91 +"\n" +
15.92 +"\n" +
15.93 +"\n" +
15.94 +"\n" +
15.95 +"\n" +
15.96 +"\n" +
15.97 +"\n" +
15.98 +"\n" +
15.99 +"\n" +
15.100 +"\n" +
15.101 +"\n" +
15.102 +"\n" +
15.103 +"\n" +
15.104 +"\n" +
15.105 +"\n" +
15.106 +"\n" +
15.107 +"\n" +
15.108 +"\n" +
15.109 +" <script src=\"/bck2brwsr.js\"></script>\n" +
15.110 +" <script type=\"text/javascript\">\n" +
15.111 +" function ldCls(res) {\n" +
15.112 +" var request = new XMLHttpRequest();\n" +
15.113 +" request.open('GET', '/classes/' + res, false);\n" +
15.114 +" request.send();\n" +
15.115 +" var arr = eval('(' + request.responseText + ')');\n" +
15.116 +" return arr;\n" +
15.117 +" }\n" +
15.118 +" var vm = new bck2brwsr(ldCls);\n" +
15.119 +" vm.loadClass('bck2brwsr.demo.YourFirstHTML5PageInRealLanguage');\n" +
15.120 +" </script>\n" +
15.121 +"</body></html>";
15.122 + var templateJava =
15.123 +"package bck2brwsr.demo;\n" +
15.124 +"import org.apidesign.bck2brwsr.htmlpage.api.*;\n" +
15.125 +"import static org.apidesign.bck2brwsr.htmlpage.api.OnEvent.*;\n" +
15.126 +"\n" +
15.127 +"@Page(xhtml=\"index.html\", className=\"Index\", properties={\n" +
15.128 +" @Property(name=\"value\", type=int.class)\n" +
15.129 +"})\n" +
15.130 +"class YourFirstHTML5PageInRealLanguage {\n" +
15.131 +" static { new Index().applyBindings(); }\n" +
15.132 +" @On(event=CLICK, id=\"dupl\") static void duplicateValue(Index m) {\n" +
15.133 +" m.setValue(m.getValue() * 2);\n" +
15.134 +" }\n" +
15.135 +" @On(event=CLICK, id=\"clear\") static void zeroTheValue(Index m) {\n" +
15.136 +" m.setValue(0);;\n" +
15.137 +" }\n" +
15.138 +" @ComputedProperty static int powerValue(int value) {\n" +
15.139 +" return value * value;\n" +
15.140 +" }\n" +
15.141 +"}";
15.142 +
15.143 +
15.144 + $scope.makeMarker = function( editor, line ) {
15.145 + var marker = document.createElement("div");
15.146 + marker.innerHTML = " ";
15.147 + marker.className = "issue";
15.148 +
15.149 + var info = editor.lineInfo(line);
15.150 + editor.setGutterMarker(line, "issues", info.markers ? null : marker);
15.151 +
15.152 + return marker;
15.153 + };
15.154 +
15.155 +
15.156 + // Returns a function, that, as long as it continues to be invoked, will not
15.157 + // be triggered. The function will be called after it stops being called for
15.158 + // N milliseconds. If `immediate` is passed, trigger the function on the
15.159 + // leading edge, instead of the trailing.
15.160 + $scope.debounce = function(func, wait, immediate) {
15.161 + var timeout, result;
15.162 + return function() {
15.163 + var context = this, args = arguments;
15.164 + var later = function() {
15.165 + timeout = null;
15.166 + if (!immediate) result = func.apply(context, args);
15.167 + };
15.168 + var callNow = immediate && !timeout;
15.169 + clearTimeout(timeout);
15.170 + timeout = setTimeout(later, wait);
15.171 + if (callNow) result = func.apply(context, args);
15.172 + return result;
15.173 + };
15.174 + };
15.175 +
15.176 + $scope.reload = function() {
15.177 + $scope.errors = null;
15.178 + var frame = document.getElementById("result");
15.179 + frame.src = "result.html";
15.180 + frame.contentDocument.location.reload(true);
15.181 + frame.contentWindow.location.reload();
15.182 + document.getElementById("editorJava").codeMirror.clearGutter("issues");
15.183 + };
15.184 +
15.185 + $scope.fail = function( data ) {
15.186 + $scope.errors = eval( data );
15.187 + var editor = document.getElementById("editorJava").codeMirror;
15.188 + editor.clearGutter( "issues" );
15.189 +
15.190 + for( var i = 0; i < $scope.errors.length; i ++ ) {
15.191 + $scope.makeMarker( editor, $scope.errors[i].line - 1 );
15.192 + }
15.193 +
15.194 + };
15.195 +
15.196 + $scope.post = function() {
15.197 + return $http({url: ".",
15.198 + method: "POST",
15.199 + //headers: this.headers,
15.200 + data: { html : $scope.html, java : $scope.java}
15.201 + }).success( $scope.reload ).error( $scope.fail );
15.202 + };
15.203 +
15.204 + $scope.errorClass = function( kind ) {
15.205 + switch( kind ) {
15.206 + case "ERROR" :
15.207 + return "error";
15.208 + default :
15.209 + return "warning";
15.210 + }
15.211 + };
15.212 +
15.213 + $scope.gotoError = function( line, col ) {
15.214 + var editor = document.getElementById("editorJava").codeMirror;
15.215 + editor.setCursor({ line: line - 1, ch : col - 1 });
15.216 + editor.focus();
15.217 + };
15.218 +
15.219 + $scope.tab = "html";
15.220 + $scope.html= templateHtml;
15.221 + $scope.java = templateJava;
15.222 +
15.223 + $scope.$watch( "html", $scope.debounce( $scope.post, 2000 ) );
15.224 + $scope.$watch( "java", $scope.debounce( $scope.post, 2000 ) );
15.225 + $scope.post();
15.226 +
15.227 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/dew/src/main/resources/org/apidesign/bck2brwsr/dew/js/codemirror/codemirror.css Wed Jan 23 14:16:13 2013 +0100
16.3 @@ -0,0 +1,239 @@
16.4 +/* BASICS */
16.5 +
16.6 +.CodeMirror {
16.7 + /* Set height, width, borders, and global font properties here */
16.8 + font-family: monospace;
16.9 + height: 300px;
16.10 +}
16.11 +.CodeMirror-scroll {
16.12 + /* Set scrolling behaviour here */
16.13 + overflow: auto;
16.14 +}
16.15 +
16.16 +/* PADDING */
16.17 +
16.18 +.CodeMirror-lines {
16.19 + padding: 4px 0; /* Vertical padding around content */
16.20 +}
16.21 +.CodeMirror pre {
16.22 + padding: 0 4px; /* Horizontal padding of content */
16.23 +}
16.24 +
16.25 +.CodeMirror-scrollbar-filler {
16.26 + background-color: white; /* The little square between H and V scrollbars */
16.27 +}
16.28 +
16.29 +/* GUTTER */
16.30 +
16.31 +.CodeMirror-gutters {
16.32 + border-right: 1px solid #ddd;
16.33 + background-color: #f7f7f7;
16.34 +}
16.35 +.CodeMirror-linenumbers {}
16.36 +.CodeMirror-linenumber {
16.37 + padding: 0 3px 0 5px;
16.38 + min-width: 20px;
16.39 + text-align: right;
16.40 + color: #999;
16.41 +}
16.42 +
16.43 +/* CURSOR */
16.44 +
16.45 +.CodeMirror pre.CodeMirror-cursor {
16.46 + border-left: 1px solid black;
16.47 +}
16.48 +/* Shown when moving in bi-directional text */
16.49 +.CodeMirror pre.CodeMirror-secondarycursor {
16.50 + border-left: 1px solid silver;
16.51 +}
16.52 +.cm-keymap-fat-cursor pre.CodeMirror-cursor {
16.53 + width: auto;
16.54 + border: 0;
16.55 + background: transparent;
16.56 + background: rgba(0, 200, 0, .4);
16.57 + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800);
16.58 +}
16.59 +/* Kludge to turn off filter in ie9+, which also accepts rgba */
16.60 +.cm-keymap-fat-cursor pre.CodeMirror-cursor:not(#nonsense_id) {
16.61 + filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
16.62 +}
16.63 +/* Can style cursor different in overwrite (non-insert) mode */
16.64 +.CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {}
16.65 +
16.66 +/* DEFAULT THEME */
16.67 +
16.68 +.cm-s-default .cm-keyword {color: #708;}
16.69 +.cm-s-default .cm-atom {color: #219;}
16.70 +.cm-s-default .cm-number {color: #164;}
16.71 +.cm-s-default .cm-def {color: #00f;}
16.72 +.cm-s-default .cm-variable {color: black;}
16.73 +.cm-s-default .cm-variable-2 {color: #05a;}
16.74 +.cm-s-default .cm-variable-3 {color: #085;}
16.75 +.cm-s-default .cm-property {color: black;}
16.76 +.cm-s-default .cm-operator {color: black;}
16.77 +.cm-s-default .cm-comment {color: #a50;}
16.78 +.cm-s-default .cm-string {color: #a11;}
16.79 +.cm-s-default .cm-string-2 {color: #f50;}
16.80 +.cm-s-default .cm-meta {color: #555;}
16.81 +.cm-s-default .cm-error {color: #f00;}
16.82 +.cm-s-default .cm-qualifier {color: #555;}
16.83 +.cm-s-default .cm-builtin {color: #30a;}
16.84 +.cm-s-default .cm-bracket {color: #997;}
16.85 +.cm-s-default .cm-tag {color: #170;}
16.86 +.cm-s-default .cm-attribute {color: #00c;}
16.87 +.cm-s-default .cm-header {color: blue;}
16.88 +.cm-s-default .cm-quote {color: #090;}
16.89 +.cm-s-default .cm-hr {color: #999;}
16.90 +.cm-s-default .cm-link {color: #00c;}
16.91 +
16.92 +.cm-negative {color: #d44;}
16.93 +.cm-positive {color: #292;}
16.94 +.cm-header, .cm-strong {font-weight: bold;}
16.95 +.cm-em {font-style: italic;}
16.96 +.cm-emstrong {font-style: italic; font-weight: bold;}
16.97 +.cm-link {text-decoration: underline;}
16.98 +
16.99 +.cm-invalidchar {color: #f00;}
16.100 +
16.101 +div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
16.102 +div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
16.103 +
16.104 +/* STOP */
16.105 +
16.106 +/* The rest of this file contains styles related to the mechanics of
16.107 + the editor. You probably shouldn't touch them. */
16.108 +
16.109 +.CodeMirror {
16.110 + line-height: 1;
16.111 + position: relative;
16.112 + overflow: hidden;
16.113 +}
16.114 +
16.115 +.CodeMirror-scroll {
16.116 + /* 30px is the magic margin used to hide the element's real scrollbars */
16.117 + /* See overflow: hidden in .CodeMirror, and the paddings in .CodeMirror-sizer */
16.118 + margin-bottom: -30px; margin-right: -30px;
16.119 + padding-bottom: 30px; padding-right: 30px;
16.120 + height: 100%;
16.121 + outline: none; /* Prevent dragging from highlighting the element */
16.122 + position: relative;
16.123 +}
16.124 +.CodeMirror-sizer {
16.125 + position: relative;
16.126 +}
16.127 +
16.128 +/* The fake, visible scrollbars. Used to force redraw during scrolling
16.129 + before actuall scrolling happens, thus preventing shaking and
16.130 + flickering artifacts. */
16.131 +.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler {
16.132 + position: absolute;
16.133 + z-index: 6;
16.134 + display: none;
16.135 +}
16.136 +.CodeMirror-vscrollbar {
16.137 + right: 0; top: 0;
16.138 + overflow-x: hidden;
16.139 + overflow-y: scroll;
16.140 +}
16.141 +.CodeMirror-hscrollbar {
16.142 + bottom: 0; left: 0;
16.143 + overflow-y: hidden;
16.144 + overflow-x: scroll;
16.145 +}
16.146 +.CodeMirror-scrollbar-filler {
16.147 + right: 0; bottom: 0;
16.148 + z-index: 6;
16.149 +}
16.150 +
16.151 +.CodeMirror-gutters {
16.152 + position: absolute; left: 0; top: 0;
16.153 + height: 100%;
16.154 + z-index: 3;
16.155 +}
16.156 +.CodeMirror-gutter {
16.157 + height: 100%;
16.158 + display: inline-block;
16.159 + /* Hack to make IE7 behave */
16.160 + *zoom:1;
16.161 + *display:inline;
16.162 +}
16.163 +.CodeMirror-gutter-elt {
16.164 + position: absolute;
16.165 + cursor: default;
16.166 + z-index: 4;
16.167 +}
16.168 +
16.169 +.CodeMirror-lines {
16.170 + cursor: text;
16.171 +}
16.172 +.CodeMirror pre {
16.173 + /* Reset some styles that the rest of the page might have set */
16.174 + -moz-border-radius: 0; -webkit-border-radius: 0; -o-border-radius: 0; border-radius: 0;
16.175 + border-width: 0;
16.176 + background: transparent;
16.177 + font-family: inherit;
16.178 + font-size: inherit;
16.179 + margin: 0;
16.180 + white-space: pre;
16.181 + word-wrap: normal;
16.182 + line-height: inherit;
16.183 + color: inherit;
16.184 + z-index: 2;
16.185 + position: relative;
16.186 + overflow: visible;
16.187 +}
16.188 +.CodeMirror-wrap pre {
16.189 + word-wrap: break-word;
16.190 + white-space: pre-wrap;
16.191 + word-break: normal;
16.192 +}
16.193 +.CodeMirror-linebackground {
16.194 + position: absolute;
16.195 + left: 0; right: 0; top: 0; bottom: 0;
16.196 + z-index: 0;
16.197 +}
16.198 +
16.199 +.CodeMirror-linewidget {
16.200 + position: relative;
16.201 + z-index: 2;
16.202 +}
16.203 +
16.204 +.CodeMirror-wrap .CodeMirror-scroll {
16.205 + overflow-x: hidden;
16.206 +}
16.207 +
16.208 +.CodeMirror-measure {
16.209 + position: absolute;
16.210 + width: 100%; height: 0px;
16.211 + overflow: hidden;
16.212 + visibility: hidden;
16.213 +}
16.214 +.CodeMirror-measure pre { position: static; }
16.215 +
16.216 +.CodeMirror pre.CodeMirror-cursor {
16.217 + position: absolute;
16.218 + visibility: hidden;
16.219 + border-right: none;
16.220 + width: 0;
16.221 +}
16.222 +.CodeMirror-focused pre.CodeMirror-cursor {
16.223 + visibility: visible;
16.224 +}
16.225 +
16.226 +.CodeMirror-selected { background: #d9d9d9; }
16.227 +.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
16.228 +
16.229 +.CodeMirror-searching {
16.230 + background: #ffa;
16.231 + background: rgba(255, 255, 0, .4);
16.232 +}
16.233 +
16.234 +/* IE7 hack to prevent it from returning funny offsetTops on the spans */
16.235 +.CodeMirror span { *vertical-align: text-bottom; }
16.236 +
16.237 +@media print {
16.238 + /* Hide the cursor when printing */
16.239 + .CodeMirror pre.CodeMirror-cursor {
16.240 + visibility: hidden;
16.241 + }
16.242 +}
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2 +++ b/dew/src/main/resources/org/apidesign/bck2brwsr/dew/js/codemirror/codemirror.js Wed Jan 23 14:16:13 2013 +0100
17.3 @@ -0,0 +1,4553 @@
17.4 +// CodeMirror version 3.0
17.5 +//
17.6 +// CodeMirror is the only global var we claim
17.7 +window.CodeMirror = (function() {
17.8 + "use strict";
17.9 +
17.10 + // BROWSER SNIFFING
17.11 +
17.12 + // Crude, but necessary to handle a number of hard-to-feature-detect
17.13 + // bugs and behavior differences.
17.14 + var gecko = /gecko\/\d/i.test(navigator.userAgent);
17.15 + var ie = /MSIE \d/.test(navigator.userAgent);
17.16 + var ie_lt8 = /MSIE [1-7]\b/.test(navigator.userAgent);
17.17 + var ie_lt9 = /MSIE [1-8]\b/.test(navigator.userAgent);
17.18 + var webkit = /WebKit\//.test(navigator.userAgent);
17.19 + var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
17.20 + var chrome = /Chrome\//.test(navigator.userAgent);
17.21 + var opera = /Opera\//.test(navigator.userAgent);
17.22 + var safari = /Apple Computer/.test(navigator.vendor);
17.23 + var khtml = /KHTML\//.test(navigator.userAgent);
17.24 + var mac_geLion = /Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent);
17.25 + var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);
17.26 + var phantom = /PhantomJS/.test(navigator.userAgent);
17.27 +
17.28 + var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
17.29 + // This is woefully incomplete. Suggestions for alternative methods welcome.
17.30 + var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent);
17.31 + var mac = ios || /Mac/.test(navigator.platform);
17.32 +
17.33 + // Optimize some code when these features are not used
17.34 + var sawReadOnlySpans = false, sawCollapsedSpans = false;
17.35 +
17.36 + // CONSTRUCTOR
17.37 +
17.38 + function CodeMirror(place, options) {
17.39 + if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
17.40 +
17.41 + this.options = options = options || {};
17.42 + // Determine effective options based on given values and defaults.
17.43 + for (var opt in defaults) if (!options.hasOwnProperty(opt) && defaults.hasOwnProperty(opt))
17.44 + options[opt] = defaults[opt];
17.45 + setGuttersForLineNumbers(options);
17.46 +
17.47 + var display = this.display = makeDisplay(place);
17.48 + display.wrapper.CodeMirror = this;
17.49 + updateGutters(this);
17.50 + if (options.autofocus && !mobile) focusInput(this);
17.51 +
17.52 + this.view = makeView(new BranchChunk([new LeafChunk([makeLine("", null, textHeight(display))])]));
17.53 + this.nextOpId = 0;
17.54 + loadMode(this);
17.55 + themeChanged(this);
17.56 + if (options.lineWrapping)
17.57 + this.display.wrapper.className += " CodeMirror-wrap";
17.58 +
17.59 + // Initialize the content.
17.60 + this.setValue(options.value || "");
17.61 + // Override magic textarea content restore that IE sometimes does
17.62 + // on our hidden textarea on reload
17.63 + if (ie) setTimeout(bind(resetInput, this, true), 20);
17.64 + this.view.history = makeHistory();
17.65 +
17.66 + registerEventHandlers(this);
17.67 + // IE throws unspecified error in certain cases, when
17.68 + // trying to access activeElement before onload
17.69 + var hasFocus; try { hasFocus = (document.activeElement == display.input); } catch(e) { }
17.70 + if (hasFocus || (options.autofocus && !mobile)) setTimeout(bind(onFocus, this), 20);
17.71 + else onBlur(this);
17.72 +
17.73 + operation(this, function() {
17.74 + for (var opt in optionHandlers)
17.75 + if (optionHandlers.propertyIsEnumerable(opt))
17.76 + optionHandlers[opt](this, options[opt], Init);
17.77 + for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
17.78 + })();
17.79 + }
17.80 +
17.81 + // DISPLAY CONSTRUCTOR
17.82 +
17.83 + function makeDisplay(place) {
17.84 + var d = {};
17.85 + var input = d.input = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none;");
17.86 + input.setAttribute("wrap", "off"); input.setAttribute("autocorrect", "off"); input.setAttribute("autocapitalize", "off");
17.87 + // Wraps and hides input textarea
17.88 + d.inputDiv = elt("div", [input], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
17.89 + // The actual fake scrollbars.
17.90 + d.scrollbarH = elt("div", [elt("div", null, null, "height: 1px")], "CodeMirror-hscrollbar");
17.91 + d.scrollbarV = elt("div", [elt("div", null, null, "width: 1px")], "CodeMirror-vscrollbar");
17.92 + d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
17.93 + // DIVs containing the selection and the actual code
17.94 + d.lineDiv = elt("div");
17.95 + d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
17.96 + // Blinky cursor, and element used to ensure cursor fits at the end of a line
17.97 + d.cursor = elt("pre", "\u00a0", "CodeMirror-cursor");
17.98 + // Secondary cursor, shown when on a 'jump' in bi-directional text
17.99 + d.otherCursor = elt("pre", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor");
17.100 + // Used to measure text size
17.101 + d.measure = elt("div", null, "CodeMirror-measure");
17.102 + // Wraps everything that needs to exist inside the vertically-padded coordinate system
17.103 + d.lineSpace = elt("div", [d.measure, d.selectionDiv, d.lineDiv, d.cursor, d.otherCursor],
17.104 + null, "position: relative; outline: none");
17.105 + // Moved around its parent to cover visible view
17.106 + d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
17.107 + // Set to the height of the text, causes scrolling
17.108 + d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
17.109 + // D is needed because behavior of elts with overflow: auto and padding is inconsistent across browsers
17.110 + d.heightForcer = elt("div", "\u00a0", null, "position: absolute; height: " + scrollerCutOff + "px");
17.111 + // Will contain the gutters, if any
17.112 + d.gutters = elt("div", null, "CodeMirror-gutters");
17.113 + d.lineGutter = null;
17.114 + // Helper element to properly size the gutter backgrounds
17.115 + var scrollerInner = elt("div", [d.sizer, d.heightForcer, d.gutters], null, "position: relative; min-height: 100%");
17.116 + // Provides scrolling
17.117 + d.scroller = elt("div", [scrollerInner], "CodeMirror-scroll");
17.118 + d.scroller.setAttribute("tabIndex", "-1");
17.119 + // The element in which the editor lives.
17.120 + d.wrapper = elt("div", [d.inputDiv, d.scrollbarH, d.scrollbarV,
17.121 + d.scrollbarFiller, d.scroller], "CodeMirror");
17.122 + // Work around IE7 z-index bug
17.123 + if (ie_lt8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
17.124 + if (place.appendChild) place.appendChild(d.wrapper); else place(d.wrapper);
17.125 +
17.126 + // Needed to hide big blue blinking cursor on Mobile Safari
17.127 + if (ios) input.style.width = "0px";
17.128 + if (!webkit) d.scroller.draggable = true;
17.129 + // Needed to handle Tab key in KHTML
17.130 + if (khtml) { d.inputDiv.style.height = "1px"; d.inputDiv.style.position = "absolute"; }
17.131 + // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
17.132 + else if (ie_lt8) d.scrollbarH.style.minWidth = d.scrollbarV.style.minWidth = "18px";
17.133 +
17.134 + // Current visible range (may be bigger than the view window).
17.135 + d.viewOffset = d.showingFrom = d.showingTo = d.lastSizeC = 0;
17.136 +
17.137 + // Used to only resize the line number gutter when necessary (when
17.138 + // the amount of lines crosses a boundary that makes its width change)
17.139 + d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
17.140 + // See readInput and resetInput
17.141 + d.prevInput = "";
17.142 + // Set to true when a non-horizontal-scrolling widget is added. As
17.143 + // an optimization, widget aligning is skipped when d is false.
17.144 + d.alignWidgets = false;
17.145 + // Flag that indicates whether we currently expect input to appear
17.146 + // (after some event like 'keypress' or 'input') and are polling
17.147 + // intensively.
17.148 + d.pollingFast = false;
17.149 + // Self-resetting timeout for the poller
17.150 + d.poll = new Delayed();
17.151 + // True when a drag from the editor is active
17.152 + d.draggingText = false;
17.153 +
17.154 + d.cachedCharWidth = d.cachedTextHeight = null;
17.155 + d.measureLineCache = [];
17.156 + d.measureLineCachePos = 0;
17.157 +
17.158 + // Tracks when resetInput has punted to just putting a short
17.159 + // string instead of the (large) selection.
17.160 + d.inaccurateSelection = false;
17.161 +
17.162 + // Used to adjust overwrite behaviour when a paste has been
17.163 + // detected
17.164 + d.pasteIncoming = false;
17.165 +
17.166 + return d;
17.167 + }
17.168 +
17.169 + // VIEW CONSTRUCTOR
17.170 +
17.171 + function makeView(doc) {
17.172 + var selPos = {line: 0, ch: 0};
17.173 + return {
17.174 + doc: doc,
17.175 + // frontier is the point up to which the content has been parsed,
17.176 + frontier: 0, highlight: new Delayed(),
17.177 + sel: {from: selPos, to: selPos, head: selPos, anchor: selPos, shift: false, extend: false},
17.178 + scrollTop: 0, scrollLeft: 0,
17.179 + overwrite: false, focused: false,
17.180 + // Tracks the maximum line length so that
17.181 + // the horizontal scrollbar can be kept
17.182 + // static when scrolling.
17.183 + maxLine: getLine(doc, 0),
17.184 + maxLineLength: 0,
17.185 + maxLineChanged: false,
17.186 + suppressEdits: false,
17.187 + goalColumn: null,
17.188 + cantEdit: false,
17.189 + keyMaps: []
17.190 + };
17.191 + }
17.192 +
17.193 + // STATE UPDATES
17.194 +
17.195 + // Used to get the editor into a consistent state again when options change.
17.196 +
17.197 + function loadMode(cm) {
17.198 + var doc = cm.view.doc;
17.199 + cm.view.mode = CodeMirror.getMode(cm.options, cm.options.mode);
17.200 + doc.iter(0, doc.size, function(line) { line.stateAfter = null; });
17.201 + cm.view.frontier = 0;
17.202 + startWorker(cm, 100);
17.203 + }
17.204 +
17.205 + function wrappingChanged(cm) {
17.206 + var doc = cm.view.doc, th = textHeight(cm.display);
17.207 + if (cm.options.lineWrapping) {
17.208 + cm.display.wrapper.className += " CodeMirror-wrap";
17.209 + var perLine = cm.display.scroller.clientWidth / charWidth(cm.display) - 3;
17.210 + doc.iter(0, doc.size, function(line) {
17.211 + if (line.height == 0) return;
17.212 + var guess = Math.ceil(line.text.length / perLine) || 1;
17.213 + if (guess != 1) updateLineHeight(line, guess * th);
17.214 + });
17.215 + cm.display.sizer.style.minWidth = "";
17.216 + } else {
17.217 + cm.display.wrapper.className = cm.display.wrapper.className.replace(" CodeMirror-wrap", "");
17.218 + computeMaxLength(cm.view);
17.219 + doc.iter(0, doc.size, function(line) {
17.220 + if (line.height != 0) updateLineHeight(line, th);
17.221 + });
17.222 + }
17.223 + regChange(cm, 0, doc.size);
17.224 + clearCaches(cm);
17.225 + setTimeout(function(){updateScrollbars(cm.display, cm.view.doc.height);}, 100);
17.226 + }
17.227 +
17.228 + function keyMapChanged(cm) {
17.229 + var style = keyMap[cm.options.keyMap].style;
17.230 + cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-keymap-\S+/g, "") +
17.231 + (style ? " cm-keymap-" + style : "");
17.232 + }
17.233 +
17.234 + function themeChanged(cm) {
17.235 + cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
17.236 + cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
17.237 + clearCaches(cm);
17.238 + }
17.239 +
17.240 + function guttersChanged(cm) {
17.241 + updateGutters(cm);
17.242 + updateDisplay(cm, true);
17.243 + }
17.244 +
17.245 + function updateGutters(cm) {
17.246 + var gutters = cm.display.gutters, specs = cm.options.gutters;
17.247 + removeChildren(gutters);
17.248 + for (var i = 0; i < specs.length; ++i) {
17.249 + var gutterClass = specs[i];
17.250 + var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
17.251 + if (gutterClass == "CodeMirror-linenumbers") {
17.252 + cm.display.lineGutter = gElt;
17.253 + gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
17.254 + }
17.255 + }
17.256 + gutters.style.display = i ? "" : "none";
17.257 + }
17.258 +
17.259 + function lineLength(doc, line) {
17.260 + if (line.height == 0) return 0;
17.261 + var len = line.text.length, merged, cur = line;
17.262 + while (merged = collapsedSpanAtStart(cur)) {
17.263 + var found = merged.find();
17.264 + cur = getLine(doc, found.from.line);
17.265 + len += found.from.ch - found.to.ch;
17.266 + }
17.267 + cur = line;
17.268 + while (merged = collapsedSpanAtEnd(cur)) {
17.269 + var found = merged.find();
17.270 + len -= cur.text.length - found.from.ch;
17.271 + cur = getLine(doc, found.to.line);
17.272 + len += cur.text.length - found.to.ch;
17.273 + }
17.274 + return len;
17.275 + }
17.276 +
17.277 + function computeMaxLength(view) {
17.278 + view.maxLine = getLine(view.doc, 0);
17.279 + view.maxLineLength = lineLength(view.doc, view.maxLine);
17.280 + view.maxLineChanged = true;
17.281 + view.doc.iter(1, view.doc.size, function(line) {
17.282 + var len = lineLength(view.doc, line);
17.283 + if (len > view.maxLineLength) {
17.284 + view.maxLineLength = len;
17.285 + view.maxLine = line;
17.286 + }
17.287 + });
17.288 + }
17.289 +
17.290 + // Make sure the gutters options contains the element
17.291 + // "CodeMirror-linenumbers" when the lineNumbers option is true.
17.292 + function setGuttersForLineNumbers(options) {
17.293 + var found = false;
17.294 + for (var i = 0; i < options.gutters.length; ++i) {
17.295 + if (options.gutters[i] == "CodeMirror-linenumbers") {
17.296 + if (options.lineNumbers) found = true;
17.297 + else options.gutters.splice(i--, 1);
17.298 + }
17.299 + }
17.300 + if (!found && options.lineNumbers)
17.301 + options.gutters.push("CodeMirror-linenumbers");
17.302 + }
17.303 +
17.304 + // SCROLLBARS
17.305 +
17.306 + // Re-synchronize the fake scrollbars with the actual size of the
17.307 + // content. Optionally force a scrollTop.
17.308 + function updateScrollbars(d /* display */, docHeight) {
17.309 + var totalHeight = docHeight + 2 * paddingTop(d);
17.310 + d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
17.311 + var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight);
17.312 + var needsH = d.scroller.scrollWidth > d.scroller.clientWidth;
17.313 + var needsV = scrollHeight > d.scroller.clientHeight;
17.314 + if (needsV) {
17.315 + d.scrollbarV.style.display = "block";
17.316 + d.scrollbarV.style.bottom = needsH ? scrollbarWidth(d.measure) + "px" : "0";
17.317 + d.scrollbarV.firstChild.style.height =
17.318 + (scrollHeight - d.scroller.clientHeight + d.scrollbarV.clientHeight) + "px";
17.319 + } else d.scrollbarV.style.display = "";
17.320 + if (needsH) {
17.321 + d.scrollbarH.style.display = "block";
17.322 + d.scrollbarH.style.right = needsV ? scrollbarWidth(d.measure) + "px" : "0";
17.323 + d.scrollbarH.firstChild.style.width =
17.324 + (d.scroller.scrollWidth - d.scroller.clientWidth + d.scrollbarH.clientWidth) + "px";
17.325 + } else d.scrollbarH.style.display = "";
17.326 + if (needsH && needsV) {
17.327 + d.scrollbarFiller.style.display = "block";
17.328 + d.scrollbarFiller.style.height = d.scrollbarFiller.style.width = scrollbarWidth(d.measure) + "px";
17.329 + } else d.scrollbarFiller.style.display = "";
17.330 +
17.331 + if (mac_geLion && scrollbarWidth(d.measure) === 0)
17.332 + d.scrollbarV.style.minWidth = d.scrollbarH.style.minHeight = mac_geMountainLion ? "18px" : "12px";
17.333 + }
17.334 +
17.335 + function visibleLines(display, doc, viewPort) {
17.336 + var top = display.scroller.scrollTop, height = display.wrapper.clientHeight;
17.337 + if (typeof viewPort == "number") top = viewPort;
17.338 + else if (viewPort) {top = viewPort.top; height = viewPort.bottom - viewPort.top;}
17.339 + top = Math.floor(top - paddingTop(display));
17.340 + var bottom = Math.ceil(top + height);
17.341 + return {from: lineAtHeight(doc, top), to: lineAtHeight(doc, bottom)};
17.342 + }
17.343 +
17.344 + // LINE NUMBERS
17.345 +
17.346 + function alignHorizontally(cm) {
17.347 + var display = cm.display;
17.348 + if (!display.alignWidgets && !display.gutters.firstChild) return;
17.349 + var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.view.scrollLeft;
17.350 + var gutterW = display.gutters.offsetWidth, l = comp + "px";
17.351 + for (var n = display.lineDiv.firstChild; n; n = n.nextSibling) if (n.alignable) {
17.352 + for (var i = 0, a = n.alignable; i < a.length; ++i) a[i].style.left = l;
17.353 + }
17.354 + display.gutters.style.left = (comp + gutterW) + "px";
17.355 + }
17.356 +
17.357 + function maybeUpdateLineNumberWidth(cm) {
17.358 + if (!cm.options.lineNumbers) return false;
17.359 + var doc = cm.view.doc, last = lineNumberFor(cm.options, doc.size - 1), display = cm.display;
17.360 + if (last.length != display.lineNumChars) {
17.361 + var test = display.measure.appendChild(elt("div", [elt("div", last)],
17.362 + "CodeMirror-linenumber CodeMirror-gutter-elt"));
17.363 + var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
17.364 + display.lineGutter.style.width = "";
17.365 + display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding);
17.366 + display.lineNumWidth = display.lineNumInnerWidth + padding;
17.367 + display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
17.368 + display.lineGutter.style.width = display.lineNumWidth + "px";
17.369 + return true;
17.370 + }
17.371 + return false;
17.372 + }
17.373 +
17.374 + function lineNumberFor(options, i) {
17.375 + return String(options.lineNumberFormatter(i + options.firstLineNumber));
17.376 + }
17.377 + function compensateForHScroll(display) {
17.378 + return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
17.379 + }
17.380 +
17.381 + // DISPLAY DRAWING
17.382 +
17.383 + function updateDisplay(cm, changes, viewPort) {
17.384 + var oldFrom = cm.display.showingFrom, oldTo = cm.display.showingTo;
17.385 + var updated = updateDisplayInner(cm, changes, viewPort);
17.386 + if (updated) {
17.387 + signalLater(cm, cm, "update", cm);
17.388 + if (cm.display.showingFrom != oldFrom || cm.display.showingTo != oldTo)
17.389 + signalLater(cm, cm, "viewportChange", cm, cm.display.showingFrom, cm.display.showingTo);
17.390 + }
17.391 + updateSelection(cm);
17.392 + updateScrollbars(cm.display, cm.view.doc.height);
17.393 +
17.394 + return updated;
17.395 + }
17.396 +
17.397 + // Uses a set of changes plus the current scroll position to
17.398 + // determine which DOM updates have to be made, and makes the
17.399 + // updates.
17.400 + function updateDisplayInner(cm, changes, viewPort) {
17.401 + var display = cm.display, doc = cm.view.doc;
17.402 + if (!display.wrapper.clientWidth) {
17.403 + display.showingFrom = display.showingTo = display.viewOffset = 0;
17.404 + return;
17.405 + }
17.406 +
17.407 + // Compute the new visible window
17.408 + // If scrollTop is specified, use that to determine which lines
17.409 + // to render instead of the current scrollbar position.
17.410 + var visible = visibleLines(display, doc, viewPort);
17.411 + // Bail out if the visible area is already rendered and nothing changed.
17.412 + if (changes !== true && changes.length == 0 &&
17.413 + visible.from > display.showingFrom && visible.to < display.showingTo)
17.414 + return;
17.415 +
17.416 + if (changes && maybeUpdateLineNumberWidth(cm))
17.417 + changes = true;
17.418 + display.sizer.style.marginLeft = display.scrollbarH.style.left = display.gutters.offsetWidth + "px";
17.419 +
17.420 + // When merged lines are present, the line that needs to be
17.421 + // redrawn might not be the one that was changed.
17.422 + if (changes !== true && sawCollapsedSpans)
17.423 + for (var i = 0; i < changes.length; ++i) {
17.424 + var ch = changes[i], merged;
17.425 + while (merged = collapsedSpanAtStart(getLine(doc, ch.from))) {
17.426 + var from = merged.find().from.line;
17.427 + if (ch.diff) ch.diff -= ch.from - from;
17.428 + ch.from = from;
17.429 + }
17.430 + }
17.431 +
17.432 + // Used to determine which lines need their line numbers updated
17.433 + var positionsChangedFrom = changes === true ? 0 : Infinity;
17.434 + if (cm.options.lineNumbers && changes && changes !== true)
17.435 + for (var i = 0; i < changes.length; ++i)
17.436 + if (changes[i].diff) { positionsChangedFrom = changes[i].from; break; }
17.437 +
17.438 + var from = Math.max(visible.from - cm.options.viewportMargin, 0);
17.439 + var to = Math.min(doc.size, visible.to + cm.options.viewportMargin);
17.440 + if (display.showingFrom < from && from - display.showingFrom < 20) from = display.showingFrom;
17.441 + if (display.showingTo > to && display.showingTo - to < 20) to = Math.min(doc.size, display.showingTo);
17.442 + if (sawCollapsedSpans) {
17.443 + from = lineNo(visualLine(doc, getLine(doc, from)));
17.444 + while (to < doc.size && lineIsHidden(getLine(doc, to))) ++to;
17.445 + }
17.446 +
17.447 + // Create a range of theoretically intact lines, and punch holes
17.448 + // in that using the change info.
17.449 + var intact = changes === true ? [] :
17.450 + computeIntact([{from: display.showingFrom, to: display.showingTo}], changes);
17.451 + // Clip off the parts that won't be visible
17.452 + var intactLines = 0;
17.453 + for (var i = 0; i < intact.length; ++i) {
17.454 + var range = intact[i];
17.455 + if (range.from < from) range.from = from;
17.456 + if (range.to > to) range.to = to;
17.457 + if (range.from >= range.to) intact.splice(i--, 1);
17.458 + else intactLines += range.to - range.from;
17.459 + }
17.460 + if (intactLines == to - from && from == display.showingFrom && to == display.showingTo)
17.461 + return;
17.462 + intact.sort(function(a, b) {return a.from - b.from;});
17.463 +
17.464 + if (intactLines < (to - from) * .7) display.lineDiv.style.display = "none";
17.465 + patchDisplay(cm, from, to, intact, positionsChangedFrom);
17.466 + display.lineDiv.style.display = "";
17.467 +
17.468 + var different = from != display.showingFrom || to != display.showingTo ||
17.469 + display.lastSizeC != display.wrapper.clientHeight;
17.470 + // This is just a bogus formula that detects when the editor is
17.471 + // resized or the font size changes.
17.472 + if (different) display.lastSizeC = display.wrapper.clientHeight;
17.473 + display.showingFrom = from; display.showingTo = to;
17.474 + startWorker(cm, 100);
17.475 +
17.476 + var prevBottom = display.lineDiv.offsetTop;
17.477 + for (var node = display.lineDiv.firstChild, height; node; node = node.nextSibling) if (node.lineObj) {
17.478 + if (ie_lt8) {
17.479 + var bot = node.offsetTop + node.offsetHeight;
17.480 + height = bot - prevBottom;
17.481 + prevBottom = bot;
17.482 + } else {
17.483 + var box = node.getBoundingClientRect();
17.484 + height = box.bottom - box.top;
17.485 + }
17.486 + var diff = node.lineObj.height - height;
17.487 + if (height < 2) height = textHeight(display);
17.488 + if (diff > .001 || diff < -.001)
17.489 + updateLineHeight(node.lineObj, height);
17.490 + }
17.491 + display.viewOffset = heightAtLine(cm, getLine(doc, from));
17.492 + // Position the mover div to align with the current virtual scroll position
17.493 + display.mover.style.top = display.viewOffset + "px";
17.494 + return true;
17.495 + }
17.496 +
17.497 + function computeIntact(intact, changes) {
17.498 + for (var i = 0, l = changes.length || 0; i < l; ++i) {
17.499 + var change = changes[i], intact2 = [], diff = change.diff || 0;
17.500 + for (var j = 0, l2 = intact.length; j < l2; ++j) {
17.501 + var range = intact[j];
17.502 + if (change.to <= range.from && change.diff) {
17.503 + intact2.push({from: range.from + diff, to: range.to + diff});
17.504 + } else if (change.to <= range.from || change.from >= range.to) {
17.505 + intact2.push(range);
17.506 + } else {
17.507 + if (change.from > range.from)
17.508 + intact2.push({from: range.from, to: change.from});
17.509 + if (change.to < range.to)
17.510 + intact2.push({from: change.to + diff, to: range.to + diff});
17.511 + }
17.512 + }
17.513 + intact = intact2;
17.514 + }
17.515 + return intact;
17.516 + }
17.517 +
17.518 + function getDimensions(cm) {
17.519 + var d = cm.display, left = {}, width = {};
17.520 + for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
17.521 + left[cm.options.gutters[i]] = n.offsetLeft;
17.522 + width[cm.options.gutters[i]] = n.offsetWidth;
17.523 + }
17.524 + return {fixedPos: compensateForHScroll(d),
17.525 + gutterTotalWidth: d.gutters.offsetWidth,
17.526 + gutterLeft: left,
17.527 + gutterWidth: width,
17.528 + wrapperWidth: d.wrapper.clientWidth};
17.529 + }
17.530 +
17.531 + function patchDisplay(cm, from, to, intact, updateNumbersFrom) {
17.532 + var dims = getDimensions(cm);
17.533 + var display = cm.display, lineNumbers = cm.options.lineNumbers;
17.534 + // IE does bad things to nodes when .innerHTML = "" is used on a parent
17.535 + // we still need widgets and markers intact to add back to the new content later
17.536 + if (!intact.length && !ie && (!webkit || !cm.display.currentWheelTarget))
17.537 + removeChildren(display.lineDiv);
17.538 + var container = display.lineDiv, cur = container.firstChild;
17.539 +
17.540 + function rm(node) {
17.541 + var next = node.nextSibling;
17.542 + if (webkit && mac && cm.display.currentWheelTarget == node) {
17.543 + node.style.display = "none";
17.544 + node.lineObj = null;
17.545 + } else {
17.546 + container.removeChild(node);
17.547 + }
17.548 + return next;
17.549 + }
17.550 +
17.551 + var nextIntact = intact.shift(), lineNo = from;
17.552 + cm.view.doc.iter(from, to, function(line) {
17.553 + if (nextIntact && nextIntact.to == lineNo) nextIntact = intact.shift();
17.554 + if (lineIsHidden(line)) {
17.555 + if (line.height != 0) updateLineHeight(line, 0);
17.556 + } else if (nextIntact && nextIntact.from <= lineNo && nextIntact.to > lineNo) {
17.557 + // This line is intact. Skip to the actual node. Update its
17.558 + // line number if needed.
17.559 + while (cur.lineObj != line) cur = rm(cur);
17.560 + if (lineNumbers && updateNumbersFrom <= lineNo && cur.lineNumber)
17.561 + setTextContent(cur.lineNumber, lineNumberFor(cm.options, lineNo));
17.562 + cur = cur.nextSibling;
17.563 + } else {
17.564 + // This line needs to be generated.
17.565 + var lineNode = buildLineElement(cm, line, lineNo, dims);
17.566 + container.insertBefore(lineNode, cur);
17.567 + lineNode.lineObj = line;
17.568 + }
17.569 + ++lineNo;
17.570 + });
17.571 + while (cur) cur = rm(cur);
17.572 + }
17.573 +
17.574 + function buildLineElement(cm, line, lineNo, dims) {
17.575 + var lineElement = lineContent(cm, line);
17.576 + var markers = line.gutterMarkers, display = cm.display;
17.577 +
17.578 + if (!cm.options.lineNumbers && !markers && !line.bgClass && !line.wrapClass &&
17.579 + (!line.widgets || !line.widgets.length)) return lineElement;
17.580 +
17.581 + // Lines with gutter elements or a background class need
17.582 + // to be wrapped again, and have the extra elements added
17.583 + // to the wrapper div
17.584 +
17.585 + var wrap = elt("div", null, line.wrapClass, "position: relative");
17.586 + if (cm.options.lineNumbers || markers) {
17.587 + var gutterWrap = wrap.appendChild(elt("div", null, null, "position: absolute; left: " +
17.588 + dims.fixedPos + "px"));
17.589 + wrap.alignable = [gutterWrap];
17.590 + if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
17.591 + wrap.lineNumber = gutterWrap.appendChild(
17.592 + elt("div", lineNumberFor(cm.options, lineNo),
17.593 + "CodeMirror-linenumber CodeMirror-gutter-elt",
17.594 + "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
17.595 + + display.lineNumInnerWidth + "px"));
17.596 + if (markers)
17.597 + for (var k = 0; k < cm.options.gutters.length; ++k) {
17.598 + var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
17.599 + if (found)
17.600 + gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
17.601 + dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
17.602 + }
17.603 + }
17.604 + // Kludge to make sure the styled element lies behind the selection (by z-index)
17.605 + if (line.bgClass)
17.606 + wrap.appendChild(elt("div", "\u00a0", line.bgClass + " CodeMirror-linebackground"));
17.607 + wrap.appendChild(lineElement);
17.608 + if (line.widgets)
17.609 + for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
17.610 + var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
17.611 + node.widget = widget;
17.612 + if (widget.noHScroll) {
17.613 + (wrap.alignable || (wrap.alignable = [])).push(node);
17.614 + var width = dims.wrapperWidth;
17.615 + node.style.left = dims.fixedPos + "px";
17.616 + if (!widget.coverGutter) {
17.617 + width -= dims.gutterTotalWidth;
17.618 + node.style.paddingLeft = dims.gutterTotalWidth + "px";
17.619 + }
17.620 + node.style.width = width + "px";
17.621 + }
17.622 + if (widget.coverGutter) {
17.623 + node.style.zIndex = 5;
17.624 + node.style.position = "relative";
17.625 + if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
17.626 + }
17.627 + if (widget.above)
17.628 + wrap.insertBefore(node, cm.options.lineNumbers && line.height != 0 ? gutterWrap : lineElement);
17.629 + else
17.630 + wrap.appendChild(node);
17.631 + }
17.632 +
17.633 + if (ie_lt8) wrap.style.zIndex = 2;
17.634 + return wrap;
17.635 + }
17.636 +
17.637 + // SELECTION / CURSOR
17.638 +
17.639 + function updateSelection(cm) {
17.640 + var display = cm.display;
17.641 + var collapsed = posEq(cm.view.sel.from, cm.view.sel.to);
17.642 + if (collapsed || cm.options.showCursorWhenSelecting)
17.643 + updateSelectionCursor(cm);
17.644 + else
17.645 + display.cursor.style.display = display.otherCursor.style.display = "none";
17.646 + if (!collapsed)
17.647 + updateSelectionRange(cm);
17.648 + else
17.649 + display.selectionDiv.style.display = "none";
17.650 +
17.651 + // Move the hidden textarea near the cursor to prevent scrolling artifacts
17.652 + var headPos = cursorCoords(cm, cm.view.sel.head, "div");
17.653 + var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
17.654 + display.inputDiv.style.top = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
17.655 + headPos.top + lineOff.top - wrapOff.top)) + "px";
17.656 + display.inputDiv.style.left = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
17.657 + headPos.left + lineOff.left - wrapOff.left)) + "px";
17.658 + }
17.659 +
17.660 + // No selection, plain cursor
17.661 + function updateSelectionCursor(cm) {
17.662 + var display = cm.display, pos = cursorCoords(cm, cm.view.sel.head, "div");
17.663 + display.cursor.style.left = pos.left + "px";
17.664 + display.cursor.style.top = pos.top + "px";
17.665 + display.cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
17.666 + display.cursor.style.display = "";
17.667 +
17.668 + if (pos.other) {
17.669 + display.otherCursor.style.display = "";
17.670 + display.otherCursor.style.left = pos.other.left + "px";
17.671 + display.otherCursor.style.top = pos.other.top + "px";
17.672 + display.otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
17.673 + } else { display.otherCursor.style.display = "none"; }
17.674 + }
17.675 +
17.676 + // Highlight selection
17.677 + function updateSelectionRange(cm) {
17.678 + var display = cm.display, doc = cm.view.doc, sel = cm.view.sel;
17.679 + var fragment = document.createDocumentFragment();
17.680 + var clientWidth = display.lineSpace.offsetWidth, pl = paddingLeft(cm.display);
17.681 +
17.682 + function add(left, top, width, bottom) {
17.683 + if (top < 0) top = 0;
17.684 + fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
17.685 + "px; top: " + top + "px; width: " + (width == null ? clientWidth - left : width) +
17.686 + "px; height: " + (bottom - top) + "px"));
17.687 + }
17.688 +
17.689 + function drawForLine(line, fromArg, toArg, retTop) {
17.690 + var lineObj = getLine(doc, line);
17.691 + var lineLen = lineObj.text.length, rVal = retTop ? Infinity : -Infinity;
17.692 + function coords(ch) {
17.693 + return charCoords(cm, {line: line, ch: ch}, "div", lineObj);
17.694 + }
17.695 +
17.696 + iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
17.697 + var leftPos = coords(dir == "rtl" ? to - 1 : from);
17.698 + var rightPos = coords(dir == "rtl" ? from : to - 1);
17.699 + var left = leftPos.left, right = rightPos.right;
17.700 + if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
17.701 + add(left, leftPos.top, null, leftPos.bottom);
17.702 + left = pl;
17.703 + if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
17.704 + }
17.705 + if (toArg == null && to == lineLen) right = clientWidth;
17.706 + if (fromArg == null && from == 0) left = pl;
17.707 + rVal = retTop ? Math.min(rightPos.top, rVal) : Math.max(rightPos.bottom, rVal);
17.708 + if (left < pl + 1) left = pl;
17.709 + add(left, rightPos.top, right - left, rightPos.bottom);
17.710 + });
17.711 + return rVal;
17.712 + }
17.713 +
17.714 + if (sel.from.line == sel.to.line) {
17.715 + drawForLine(sel.from.line, sel.from.ch, sel.to.ch);
17.716 + } else {
17.717 + var fromObj = getLine(doc, sel.from.line);
17.718 + var cur = fromObj, merged, path = [sel.from.line, sel.from.ch], singleLine;
17.719 + while (merged = collapsedSpanAtEnd(cur)) {
17.720 + var found = merged.find();
17.721 + path.push(found.from.ch, found.to.line, found.to.ch);
17.722 + if (found.to.line == sel.to.line) {
17.723 + path.push(sel.to.ch);
17.724 + singleLine = true;
17.725 + break;
17.726 + }
17.727 + cur = getLine(doc, found.to.line);
17.728 + }
17.729 +
17.730 + // This is a single, merged line
17.731 + if (singleLine) {
17.732 + for (var i = 0; i < path.length; i += 3)
17.733 + drawForLine(path[i], path[i+1], path[i+2]);
17.734 + } else {
17.735 + var middleTop, middleBot, toObj = getLine(doc, sel.to.line);
17.736 + if (sel.from.ch)
17.737 + // Draw the first line of selection.
17.738 + middleTop = drawForLine(sel.from.line, sel.from.ch, null, false);
17.739 + else
17.740 + // Simply include it in the middle block.
17.741 + middleTop = heightAtLine(cm, fromObj) - display.viewOffset;
17.742 +
17.743 + if (!sel.to.ch)
17.744 + middleBot = heightAtLine(cm, toObj) - display.viewOffset;
17.745 + else
17.746 + middleBot = drawForLine(sel.to.line, collapsedSpanAtStart(toObj) ? null : 0, sel.to.ch, true);
17.747 +
17.748 + if (middleTop < middleBot) add(pl, middleTop, null, middleBot);
17.749 + }
17.750 + }
17.751 +
17.752 + removeChildrenAndAdd(display.selectionDiv, fragment);
17.753 + display.selectionDiv.style.display = "";
17.754 + }
17.755 +
17.756 + // Cursor-blinking
17.757 + function restartBlink(cm) {
17.758 + var display = cm.display;
17.759 + clearInterval(display.blinker);
17.760 + var on = true;
17.761 + display.cursor.style.visibility = display.otherCursor.style.visibility = "";
17.762 + display.blinker = setInterval(function() {
17.763 + if (!display.cursor.offsetHeight) return;
17.764 + display.cursor.style.visibility = display.otherCursor.style.visibility = (on = !on) ? "" : "hidden";
17.765 + }, cm.options.cursorBlinkRate);
17.766 + }
17.767 +
17.768 + // HIGHLIGHT WORKER
17.769 +
17.770 + function startWorker(cm, time) {
17.771 + if (cm.view.frontier < cm.display.showingTo)
17.772 + cm.view.highlight.set(time, bind(highlightWorker, cm));
17.773 + }
17.774 +
17.775 + function highlightWorker(cm) {
17.776 + var view = cm.view, doc = view.doc;
17.777 + if (view.frontier >= cm.display.showingTo) return;
17.778 + var end = +new Date + cm.options.workTime;
17.779 + var state = copyState(view.mode, getStateBefore(cm, view.frontier));
17.780 + var changed = [], prevChange;
17.781 + doc.iter(view.frontier, Math.min(doc.size, cm.display.showingTo + 500), function(line) {
17.782 + if (view.frontier >= cm.display.showingFrom) { // Visible
17.783 + if (highlightLine(cm, line, state) && view.frontier >= cm.display.showingFrom) {
17.784 + if (prevChange && prevChange.end == view.frontier) prevChange.end++;
17.785 + else changed.push(prevChange = {start: view.frontier, end: view.frontier + 1});
17.786 + }
17.787 + line.stateAfter = copyState(view.mode, state);
17.788 + } else {
17.789 + processLine(cm, line, state);
17.790 + line.stateAfter = view.frontier % 5 == 0 ? copyState(view.mode, state) : null;
17.791 + }
17.792 + ++view.frontier;
17.793 + if (+new Date > end) {
17.794 + startWorker(cm, cm.options.workDelay);
17.795 + return true;
17.796 + }
17.797 + });
17.798 + if (changed.length)
17.799 + operation(cm, function() {
17.800 + for (var i = 0; i < changed.length; ++i)
17.801 + regChange(this, changed[i].start, changed[i].end);
17.802 + })();
17.803 + }
17.804 +
17.805 + // Finds the line to start with when starting a parse. Tries to
17.806 + // find a line with a stateAfter, so that it can start with a
17.807 + // valid state. If that fails, it returns the line with the
17.808 + // smallest indentation, which tends to need the least context to
17.809 + // parse correctly.
17.810 + function findStartLine(cm, n) {
17.811 + var minindent, minline, doc = cm.view.doc;
17.812 + for (var search = n, lim = n - 100; search > lim; --search) {
17.813 + if (search == 0) return 0;
17.814 + var line = getLine(doc, search-1);
17.815 + if (line.stateAfter) return search;
17.816 + var indented = countColumn(line.text, null, cm.options.tabSize);
17.817 + if (minline == null || minindent > indented) {
17.818 + minline = search - 1;
17.819 + minindent = indented;
17.820 + }
17.821 + }
17.822 + return minline;
17.823 + }
17.824 +
17.825 + function getStateBefore(cm, n) {
17.826 + var view = cm.view;
17.827 + var pos = findStartLine(cm, n), state = pos && getLine(view.doc, pos-1).stateAfter;
17.828 + if (!state) state = startState(view.mode);
17.829 + else state = copyState(view.mode, state);
17.830 + view.doc.iter(pos, n, function(line) {
17.831 + processLine(cm, line, state);
17.832 + var save = pos == n - 1 || pos % 5 == 0 || pos >= view.showingFrom && pos < view.showingTo;
17.833 + line.stateAfter = save ? copyState(view.mode, state) : null;
17.834 + ++pos;
17.835 + });
17.836 + return state;
17.837 + }
17.838 +
17.839 + // POSITION MEASUREMENT
17.840 +
17.841 + function paddingTop(display) {return display.lineSpace.offsetTop;}
17.842 + function paddingLeft(display) {
17.843 + var e = removeChildrenAndAdd(display.measure, elt("pre")).appendChild(elt("span", "x"));
17.844 + return e.offsetLeft;
17.845 + }
17.846 +
17.847 + function measureChar(cm, line, ch, data) {
17.848 + var data = data || measureLine(cm, line), dir = -1;
17.849 + for (var pos = ch;; pos += dir) {
17.850 + var r = data[pos];
17.851 + if (r) break;
17.852 + if (dir < 0 && pos == 0) dir = 1;
17.853 + }
17.854 + return {left: pos < ch ? r.right : r.left,
17.855 + right: pos > ch ? r.left : r.right,
17.856 + top: r.top, bottom: r.bottom};
17.857 + }
17.858 +
17.859 + function measureLine(cm, line) {
17.860 + // First look in the cache
17.861 + var display = cm.display, cache = cm.display.measureLineCache;
17.862 + for (var i = 0; i < cache.length; ++i) {
17.863 + var memo = cache[i];
17.864 + if (memo.text == line.text && memo.markedSpans == line.markedSpans &&
17.865 + display.scroller.clientWidth == memo.width)
17.866 + return memo.measure;
17.867 + }
17.868 +
17.869 + var measure = measureLineInner(cm, line);
17.870 + // Store result in the cache
17.871 + var memo = {text: line.text, width: display.scroller.clientWidth,
17.872 + markedSpans: line.markedSpans, measure: measure};
17.873 + if (cache.length == 16) cache[++display.measureLineCachePos % 16] = memo;
17.874 + else cache.push(memo);
17.875 + return measure;
17.876 + }
17.877 +
17.878 + function measureLineInner(cm, line) {
17.879 + var display = cm.display, measure = emptyArray(line.text.length);
17.880 + var pre = lineContent(cm, line, measure);
17.881 +
17.882 + // IE does not cache element positions of inline elements between
17.883 + // calls to getBoundingClientRect. This makes the loop below,
17.884 + // which gathers the positions of all the characters on the line,
17.885 + // do an amount of layout work quadratic to the number of
17.886 + // characters. When line wrapping is off, we try to improve things
17.887 + // by first subdividing the line into a bunch of inline blocks, so
17.888 + // that IE can reuse most of the layout information from caches
17.889 + // for those blocks. This does interfere with line wrapping, so it
17.890 + // doesn't work when wrapping is on, but in that case the
17.891 + // situation is slightly better, since IE does cache line-wrapping
17.892 + // information and only recomputes per-line.
17.893 + if (ie && !ie_lt8 && !cm.options.lineWrapping && pre.childNodes.length > 100) {
17.894 + var fragment = document.createDocumentFragment();
17.895 + var chunk = 10, n = pre.childNodes.length;
17.896 + for (var i = 0, chunks = Math.ceil(n / chunk); i < chunks; ++i) {
17.897 + var wrap = elt("div", null, null, "display: inline-block");
17.898 + for (var j = 0; j < chunk && n; ++j) {
17.899 + wrap.appendChild(pre.firstChild);
17.900 + --n;
17.901 + }
17.902 + fragment.appendChild(wrap);
17.903 + }
17.904 + pre.appendChild(fragment);
17.905 + }
17.906 +
17.907 + removeChildrenAndAdd(display.measure, pre);
17.908 +
17.909 + var outer = display.lineDiv.getBoundingClientRect();
17.910 + var vranges = [], data = emptyArray(line.text.length), maxBot = pre.offsetHeight;
17.911 + for (var i = 0, cur; i < measure.length; ++i) if (cur = measure[i]) {
17.912 + var size = cur.getBoundingClientRect();
17.913 + var top = Math.max(0, size.top - outer.top), bot = Math.min(size.bottom - outer.top, maxBot);
17.914 + for (var j = 0; j < vranges.length; j += 2) {
17.915 + var rtop = vranges[j], rbot = vranges[j+1];
17.916 + if (rtop > bot || rbot < top) continue;
17.917 + if (rtop <= top && rbot >= bot ||
17.918 + top <= rtop && bot >= rbot ||
17.919 + Math.min(bot, rbot) - Math.max(top, rtop) >= (bot - top) >> 1) {
17.920 + vranges[j] = Math.min(top, rtop);
17.921 + vranges[j+1] = Math.max(bot, rbot);
17.922 + break;
17.923 + }
17.924 + }
17.925 + if (j == vranges.length) vranges.push(top, bot);
17.926 + data[i] = {left: size.left - outer.left, right: size.right - outer.left, top: j};
17.927 + }
17.928 + for (var i = 0, cur; i < data.length; ++i) if (cur = data[i]) {
17.929 + var vr = cur.top;
17.930 + cur.top = vranges[vr]; cur.bottom = vranges[vr+1];
17.931 + }
17.932 + return data;
17.933 + }
17.934 +
17.935 + function clearCaches(cm) {
17.936 + cm.display.measureLineCache.length = cm.display.measureLineCachePos = 0;
17.937 + cm.display.cachedCharWidth = cm.display.cachedTextHeight = null;
17.938 + cm.view.maxLineChanged = true;
17.939 + }
17.940 +
17.941 + // Context is one of "line", "div" (display.lineDiv), "local"/null (editor), or "page"
17.942 + function intoCoordSystem(cm, lineObj, rect, context) {
17.943 + if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
17.944 + var size = lineObj.widgets[i].node.offsetHeight;
17.945 + rect.top += size; rect.bottom += size;
17.946 + }
17.947 + if (context == "line") return rect;
17.948 + if (!context) context = "local";
17.949 + var yOff = heightAtLine(cm, lineObj);
17.950 + if (context != "local") yOff -= cm.display.viewOffset;
17.951 + if (context == "page") {
17.952 + var lOff = cm.display.lineSpace.getBoundingClientRect();
17.953 + yOff += lOff.top + (window.pageYOffset || (document.documentElement || document.body).scrollTop);
17.954 + var xOff = lOff.left + (window.pageXOffset || (document.documentElement || document.body).scrollLeft);
17.955 + rect.left += xOff; rect.right += xOff;
17.956 + }
17.957 + rect.top += yOff; rect.bottom += yOff;
17.958 + return rect;
17.959 + }
17.960 +
17.961 + function charCoords(cm, pos, context, lineObj) {
17.962 + if (!lineObj) lineObj = getLine(cm.view.doc, pos.line);
17.963 + return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch), context);
17.964 + }
17.965 +
17.966 + function cursorCoords(cm, pos, context, lineObj, measurement) {
17.967 + lineObj = lineObj || getLine(cm.view.doc, pos.line);
17.968 + if (!measurement) measurement = measureLine(cm, lineObj);
17.969 + function get(ch, right) {
17.970 + var m = measureChar(cm, lineObj, ch, measurement);
17.971 + if (right) m.left = m.right; else m.right = m.left;
17.972 + return intoCoordSystem(cm, lineObj, m, context);
17.973 + }
17.974 + var order = getOrder(lineObj), ch = pos.ch;
17.975 + if (!order) return get(ch);
17.976 + var main, other, linedir = order[0].level;
17.977 + for (var i = 0; i < order.length; ++i) {
17.978 + var part = order[i], rtl = part.level % 2, nb, here;
17.979 + if (part.from < ch && part.to > ch) return get(ch, rtl);
17.980 + var left = rtl ? part.to : part.from, right = rtl ? part.from : part.to;
17.981 + if (left == ch) {
17.982 + // Opera and IE return bogus offsets and widths for edges
17.983 + // where the direction flips, but only for the side with the
17.984 + // lower level. So we try to use the side with the higher
17.985 + // level.
17.986 + if (i && part.level < (nb = order[i-1]).level) here = get(nb.level % 2 ? nb.from : nb.to - 1, true);
17.987 + else here = get(rtl && part.from != part.to ? ch - 1 : ch);
17.988 + if (rtl == linedir) main = here; else other = here;
17.989 + } else if (right == ch) {
17.990 + var nb = i < order.length - 1 && order[i+1];
17.991 + if (!rtl && nb && nb.from == nb.to) continue;
17.992 + if (nb && part.level < nb.level) here = get(nb.level % 2 ? nb.to - 1 : nb.from);
17.993 + else here = get(rtl ? ch : ch - 1, true);
17.994 + if (rtl == linedir) main = here; else other = here;
17.995 + }
17.996 + }
17.997 + if (linedir && !ch) other = get(order[0].to - 1);
17.998 + if (!main) return other;
17.999 + if (other) main.other = other;
17.1000 + return main;
17.1001 + }
17.1002 +
17.1003 + // Coords must be lineSpace-local
17.1004 + function coordsChar(cm, x, y) {
17.1005 + var doc = cm.view.doc;
17.1006 + y += cm.display.viewOffset;
17.1007 + if (y < 0) return {line: 0, ch: 0, outside: true};
17.1008 + var lineNo = lineAtHeight(doc, y);
17.1009 + if (lineNo >= doc.size) return {line: doc.size - 1, ch: getLine(doc, doc.size - 1).text.length};
17.1010 + if (x < 0) x = 0;
17.1011 +
17.1012 + for (;;) {
17.1013 + var lineObj = getLine(doc, lineNo);
17.1014 + var found = coordsCharInner(cm, lineObj, lineNo, x, y);
17.1015 + var merged = collapsedSpanAtEnd(lineObj);
17.1016 + if (merged && found.ch == lineRight(lineObj))
17.1017 + lineNo = merged.find().to.line;
17.1018 + else
17.1019 + return found;
17.1020 + }
17.1021 + }
17.1022 +
17.1023 + function coordsCharInner(cm, lineObj, lineNo, x, y) {
17.1024 + var innerOff = y - heightAtLine(cm, lineObj);
17.1025 + var wrongLine = false, cWidth = cm.display.wrapper.clientWidth;
17.1026 + var measurement = measureLine(cm, lineObj);
17.1027 +
17.1028 + function getX(ch) {
17.1029 + var sp = cursorCoords(cm, {line: lineNo, ch: ch}, "line",
17.1030 + lineObj, measurement);
17.1031 + wrongLine = true;
17.1032 + if (innerOff > sp.bottom) return Math.max(0, sp.left - cWidth);
17.1033 + else if (innerOff < sp.top) return sp.left + cWidth;
17.1034 + else wrongLine = false;
17.1035 + return sp.left;
17.1036 + }
17.1037 +
17.1038 + var bidi = getOrder(lineObj), dist = lineObj.text.length;
17.1039 + var from = lineLeft(lineObj), to = lineRight(lineObj);
17.1040 + var fromX = paddingLeft(cm.display), toX = getX(to);
17.1041 +
17.1042 + if (x > toX) return {line: lineNo, ch: to, outside: wrongLine};
17.1043 + // Do a binary search between these bounds.
17.1044 + for (;;) {
17.1045 + if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
17.1046 + var after = x - fromX < toX - x, ch = after ? from : to;
17.1047 + while (isExtendingChar.test(lineObj.text.charAt(ch))) ++ch;
17.1048 + return {line: lineNo, ch: ch, after: after, outside: wrongLine};
17.1049 + }
17.1050 + var step = Math.ceil(dist / 2), middle = from + step;
17.1051 + if (bidi) {
17.1052 + middle = from;
17.1053 + for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1);
17.1054 + }
17.1055 + var middleX = getX(middle);
17.1056 + if (middleX > x) {to = middle; toX = middleX; if (wrongLine) toX += 1000; dist -= step;}
17.1057 + else {from = middle; fromX = middleX; dist = step;}
17.1058 + }
17.1059 + }
17.1060 +
17.1061 + var measureText;
17.1062 + function textHeight(display) {
17.1063 + if (display.cachedTextHeight != null) return display.cachedTextHeight;
17.1064 + if (measureText == null) {
17.1065 + measureText = elt("pre");
17.1066 + // Measure a bunch of lines, for browsers that compute
17.1067 + // fractional heights.
17.1068 + for (var i = 0; i < 49; ++i) {
17.1069 + measureText.appendChild(document.createTextNode("x"));
17.1070 + measureText.appendChild(elt("br"));
17.1071 + }
17.1072 + measureText.appendChild(document.createTextNode("x"));
17.1073 + }
17.1074 + removeChildrenAndAdd(display.measure, measureText);
17.1075 + var height = measureText.offsetHeight / 50;
17.1076 + if (height > 3) display.cachedTextHeight = height;
17.1077 + removeChildren(display.measure);
17.1078 + return height || 1;
17.1079 + }
17.1080 +
17.1081 + function charWidth(display) {
17.1082 + if (display.cachedCharWidth != null) return display.cachedCharWidth;
17.1083 + var anchor = elt("span", "x");
17.1084 + var pre = elt("pre", [anchor]);
17.1085 + removeChildrenAndAdd(display.measure, pre);
17.1086 + var width = anchor.offsetWidth;
17.1087 + if (width > 2) display.cachedCharWidth = width;
17.1088 + return width || 10;
17.1089 + }
17.1090 +
17.1091 + // OPERATIONS
17.1092 +
17.1093 + // Operations are used to wrap changes in such a way that each
17.1094 + // change won't have to update the cursor and display (which would
17.1095 + // be awkward, slow, and error-prone), but instead updates are
17.1096 + // batched and then all combined and executed at once.
17.1097 +
17.1098 + function startOperation(cm) {
17.1099 + if (cm.curOp) ++cm.curOp.depth;
17.1100 + else cm.curOp = {
17.1101 + // Nested operations delay update until the outermost one
17.1102 + // finishes.
17.1103 + depth: 1,
17.1104 + // An array of ranges of lines that have to be updated. See
17.1105 + // updateDisplay.
17.1106 + changes: [],
17.1107 + delayedCallbacks: [],
17.1108 + updateInput: null,
17.1109 + userSelChange: null,
17.1110 + textChanged: null,
17.1111 + selectionChanged: false,
17.1112 + updateMaxLine: false,
17.1113 + id: ++cm.nextOpId
17.1114 + };
17.1115 + }
17.1116 +
17.1117 + function endOperation(cm) {
17.1118 + var op = cm.curOp;
17.1119 + if (--op.depth) return;
17.1120 + cm.curOp = null;
17.1121 + var view = cm.view, display = cm.display;
17.1122 + if (op.updateMaxLine) computeMaxLength(view);
17.1123 + if (view.maxLineChanged && !cm.options.lineWrapping) {
17.1124 + var width = measureChar(cm, view.maxLine, view.maxLine.text.length).right;
17.1125 + display.sizer.style.minWidth = (width + 3 + scrollerCutOff) + "px";
17.1126 + view.maxLineChanged = false;
17.1127 + }
17.1128 + var newScrollPos, updated;
17.1129 + if (op.selectionChanged) {
17.1130 + var coords = cursorCoords(cm, view.sel.head);
17.1131 + newScrollPos = calculateScrollPos(cm, coords.left, coords.top, coords.left, coords.bottom);
17.1132 + }
17.1133 + if (op.changes.length || newScrollPos && newScrollPos.scrollTop != null)
17.1134 + updated = updateDisplay(cm, op.changes, newScrollPos && newScrollPos.scrollTop);
17.1135 + if (!updated && op.selectionChanged) updateSelection(cm);
17.1136 + if (newScrollPos) scrollCursorIntoView(cm);
17.1137 + if (op.selectionChanged) restartBlink(cm);
17.1138 +
17.1139 + if (view.focused && op.updateInput)
17.1140 + resetInput(cm, op.userSelChange);
17.1141 +
17.1142 + if (op.textChanged)
17.1143 + signal(cm, "change", cm, op.textChanged);
17.1144 + if (op.selectionChanged) signal(cm, "cursorActivity", cm);
17.1145 + for (var i = 0; i < op.delayedCallbacks.length; ++i) op.delayedCallbacks[i](cm);
17.1146 + }
17.1147 +
17.1148 + // Wraps a function in an operation. Returns the wrapped function.
17.1149 + function operation(cm1, f) {
17.1150 + return function() {
17.1151 + var cm = cm1 || this;
17.1152 + startOperation(cm);
17.1153 + try {var result = f.apply(cm, arguments);}
17.1154 + finally {endOperation(cm);}
17.1155 + return result;
17.1156 + };
17.1157 + }
17.1158 +
17.1159 + function regChange(cm, from, to, lendiff) {
17.1160 + cm.curOp.changes.push({from: from, to: to, diff: lendiff});
17.1161 + }
17.1162 +
17.1163 + // INPUT HANDLING
17.1164 +
17.1165 + function slowPoll(cm) {
17.1166 + if (cm.view.pollingFast) return;
17.1167 + cm.display.poll.set(cm.options.pollInterval, function() {
17.1168 + readInput(cm);
17.1169 + if (cm.view.focused) slowPoll(cm);
17.1170 + });
17.1171 + }
17.1172 +
17.1173 + function fastPoll(cm) {
17.1174 + var missed = false;
17.1175 + cm.display.pollingFast = true;
17.1176 + function p() {
17.1177 + var changed = readInput(cm);
17.1178 + if (!changed && !missed) {missed = true; cm.display.poll.set(60, p);}
17.1179 + else {cm.display.pollingFast = false; slowPoll(cm);}
17.1180 + }
17.1181 + cm.display.poll.set(20, p);
17.1182 + }
17.1183 +
17.1184 + // prevInput is a hack to work with IME. If we reset the textarea
17.1185 + // on every change, that breaks IME. So we look for changes
17.1186 + // compared to the previous content instead. (Modern browsers have
17.1187 + // events that indicate IME taking place, but these are not widely
17.1188 + // supported or compatible enough yet to rely on.)
17.1189 + function readInput(cm) {
17.1190 + var input = cm.display.input, prevInput = cm.display.prevInput, view = cm.view, sel = view.sel;
17.1191 + if (!view.focused || hasSelection(input) || isReadOnly(cm)) return false;
17.1192 + var text = input.value;
17.1193 + if (text == prevInput && posEq(sel.from, sel.to)) return false;
17.1194 + startOperation(cm);
17.1195 + view.sel.shift = false;
17.1196 + var same = 0, l = Math.min(prevInput.length, text.length);
17.1197 + while (same < l && prevInput[same] == text[same]) ++same;
17.1198 + var from = sel.from, to = sel.to;
17.1199 + if (same < prevInput.length)
17.1200 + from = {line: from.line, ch: from.ch - (prevInput.length - same)};
17.1201 + else if (view.overwrite && posEq(from, to) && !cm.display.pasteIncoming)
17.1202 + to = {line: to.line, ch: Math.min(getLine(cm.view.doc, to.line).text.length, to.ch + (text.length - same))};
17.1203 + var updateInput = cm.curOp.updateInput;
17.1204 + updateDoc(cm, from, to, splitLines(text.slice(same)), "end",
17.1205 + cm.display.pasteIncoming ? "paste" : "input", {from: from, to: to});
17.1206 + cm.curOp.updateInput = updateInput;
17.1207 + if (text.length > 1000) input.value = cm.display.prevInput = "";
17.1208 + else cm.display.prevInput = text;
17.1209 + endOperation(cm);
17.1210 + cm.display.pasteIncoming = false;
17.1211 + return true;
17.1212 + }
17.1213 +
17.1214 + function resetInput(cm, user) {
17.1215 + var view = cm.view, minimal, selected;
17.1216 + if (!posEq(view.sel.from, view.sel.to)) {
17.1217 + cm.display.prevInput = "";
17.1218 + minimal = hasCopyEvent &&
17.1219 + (view.sel.to.line - view.sel.from.line > 100 || (selected = cm.getSelection()).length > 1000);
17.1220 + if (minimal) cm.display.input.value = "-";
17.1221 + else cm.display.input.value = selected || cm.getSelection();
17.1222 + if (view.focused) selectInput(cm.display.input);
17.1223 + } else if (user) cm.display.prevInput = cm.display.input.value = "";
17.1224 + cm.display.inaccurateSelection = minimal;
17.1225 + }
17.1226 +
17.1227 + function focusInput(cm) {
17.1228 + if (cm.options.readOnly != "nocursor" && (ie || document.activeElement != cm.display.input))
17.1229 + cm.display.input.focus();
17.1230 + }
17.1231 +
17.1232 + function isReadOnly(cm) {
17.1233 + return cm.options.readOnly || cm.view.cantEdit;
17.1234 + }
17.1235 +
17.1236 + // EVENT HANDLERS
17.1237 +
17.1238 + function registerEventHandlers(cm) {
17.1239 + var d = cm.display;
17.1240 + on(d.scroller, "mousedown", operation(cm, onMouseDown));
17.1241 + on(d.scroller, "dblclick", operation(cm, e_preventDefault));
17.1242 + on(d.lineSpace, "selectstart", function(e) {
17.1243 + if (!mouseEventInWidget(d, e)) e_preventDefault(e);
17.1244 + });
17.1245 + // Gecko browsers fire contextmenu *after* opening the menu, at
17.1246 + // which point we can't mess with it anymore. Context menu is
17.1247 + // handled in onMouseDown for Gecko.
17.1248 + if (!gecko) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
17.1249 +
17.1250 + on(d.scroller, "scroll", function() {
17.1251 + setScrollTop(cm, d.scroller.scrollTop);
17.1252 + setScrollLeft(cm, d.scroller.scrollLeft, true);
17.1253 + signal(cm, "scroll", cm);
17.1254 + });
17.1255 + on(d.scrollbarV, "scroll", function() {
17.1256 + setScrollTop(cm, d.scrollbarV.scrollTop);
17.1257 + });
17.1258 + on(d.scrollbarH, "scroll", function() {
17.1259 + setScrollLeft(cm, d.scrollbarH.scrollLeft);
17.1260 + });
17.1261 +
17.1262 + on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
17.1263 + on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
17.1264 +
17.1265 + function reFocus() { if (cm.view.focused) setTimeout(bind(focusInput, cm), 0); }
17.1266 + on(d.scrollbarH, "mousedown", reFocus);
17.1267 + on(d.scrollbarV, "mousedown", reFocus);
17.1268 + // Prevent wrapper from ever scrolling
17.1269 + on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
17.1270 + on(window, "resize", function resizeHandler() {
17.1271 + // Might be a text scaling operation, clear size caches.
17.1272 + d.cachedCharWidth = d.cachedTextHeight = null;
17.1273 + clearCaches(cm);
17.1274 + if (d.wrapper.parentNode) updateDisplay(cm, true);
17.1275 + else off(window, "resize", resizeHandler);
17.1276 + });
17.1277 +
17.1278 + on(d.input, "keyup", operation(cm, function(e) {
17.1279 + if (cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return;
17.1280 + if (e_prop(e, "keyCode") == 16) cm.view.sel.shift = false;
17.1281 + }));
17.1282 + on(d.input, "input", bind(fastPoll, cm));
17.1283 + on(d.input, "keydown", operation(cm, onKeyDown));
17.1284 + on(d.input, "keypress", operation(cm, onKeyPress));
17.1285 + on(d.input, "focus", bind(onFocus, cm));
17.1286 + on(d.input, "blur", bind(onBlur, cm));
17.1287 +
17.1288 + function drag_(e) {
17.1289 + if (cm.options.onDragEvent && cm.options.onDragEvent(cm, addStop(e))) return;
17.1290 + e_stop(e);
17.1291 + }
17.1292 + if (cm.options.dragDrop) {
17.1293 + on(d.scroller, "dragstart", function(e){onDragStart(cm, e);});
17.1294 + on(d.scroller, "dragenter", drag_);
17.1295 + on(d.scroller, "dragover", drag_);
17.1296 + on(d.scroller, "drop", operation(cm, onDrop));
17.1297 + }
17.1298 + on(d.scroller, "paste", function(){focusInput(cm); fastPoll(cm);});
17.1299 + on(d.input, "paste", function() {
17.1300 + d.pasteIncoming = true;
17.1301 + fastPoll(cm);
17.1302 + });
17.1303 +
17.1304 + function prepareCopy() {
17.1305 + if (d.inaccurateSelection) {
17.1306 + d.prevInput = "";
17.1307 + d.inaccurateSelection = false;
17.1308 + d.input.value = cm.getSelection();
17.1309 + selectInput(d.input);
17.1310 + }
17.1311 + }
17.1312 + on(d.input, "cut", prepareCopy);
17.1313 + on(d.input, "copy", prepareCopy);
17.1314 +
17.1315 + // Needed to handle Tab key in KHTML
17.1316 + if (khtml) on(d.sizer, "mouseup", function() {
17.1317 + if (document.activeElement == d.input) d.input.blur();
17.1318 + focusInput(cm);
17.1319 + });
17.1320 + }
17.1321 +
17.1322 + function mouseEventInWidget(display, e) {
17.1323 + for (var n = e_target(e); n != display.wrapper; n = n.parentNode)
17.1324 + if (/\bCodeMirror-(?:line)?widget\b/.test(n.className) ||
17.1325 + n.parentNode == display.sizer && n != display.mover) return true;
17.1326 + }
17.1327 +
17.1328 + function posFromMouse(cm, e, liberal) {
17.1329 + var display = cm.display;
17.1330 + if (!liberal) {
17.1331 + var target = e_target(e);
17.1332 + if (target == display.scrollbarH || target == display.scrollbarH.firstChild ||
17.1333 + target == display.scrollbarV || target == display.scrollbarV.firstChild ||
17.1334 + target == display.scrollbarFiller) return null;
17.1335 + }
17.1336 + var x, y, space = display.lineSpace.getBoundingClientRect();
17.1337 + // Fails unpredictably on IE[67] when mouse is dragged around quickly.
17.1338 + try { x = e.clientX; y = e.clientY; } catch (e) { return null; }
17.1339 + return coordsChar(cm, x - space.left, y - space.top);
17.1340 + }
17.1341 +
17.1342 + var lastClick, lastDoubleClick;
17.1343 + function onMouseDown(e) {
17.1344 + var cm = this, display = cm.display, view = cm.view, sel = view.sel, doc = view.doc;
17.1345 + sel.shift = e_prop(e, "shiftKey");
17.1346 +
17.1347 + if (mouseEventInWidget(display, e)) {
17.1348 + if (!webkit) {
17.1349 + display.scroller.draggable = false;
17.1350 + setTimeout(function(){display.scroller.draggable = true;}, 100);
17.1351 + }
17.1352 + return;
17.1353 + }
17.1354 + if (clickInGutter(cm, e)) return;
17.1355 + var start = posFromMouse(cm, e);
17.1356 +
17.1357 + switch (e_button(e)) {
17.1358 + case 3:
17.1359 + if (gecko) onContextMenu.call(cm, cm, e);
17.1360 + return;
17.1361 + case 2:
17.1362 + if (start) extendSelection(cm, start);
17.1363 + setTimeout(bind(focusInput, cm), 20);
17.1364 + e_preventDefault(e);
17.1365 + return;
17.1366 + }
17.1367 + // For button 1, if it was clicked inside the editor
17.1368 + // (posFromMouse returning non-null), we have to adjust the
17.1369 + // selection.
17.1370 + if (!start) {if (e_target(e) == display.scroller) e_preventDefault(e); return;}
17.1371 +
17.1372 + if (!view.focused) onFocus(cm);
17.1373 +
17.1374 + var now = +new Date, type = "single";
17.1375 + if (lastDoubleClick && lastDoubleClick.time > now - 400 && posEq(lastDoubleClick.pos, start)) {
17.1376 + type = "triple";
17.1377 + e_preventDefault(e);
17.1378 + setTimeout(bind(focusInput, cm), 20);
17.1379 + selectLine(cm, start.line);
17.1380 + } else if (lastClick && lastClick.time > now - 400 && posEq(lastClick.pos, start)) {
17.1381 + type = "double";
17.1382 + lastDoubleClick = {time: now, pos: start};
17.1383 + e_preventDefault(e);
17.1384 + var word = findWordAt(getLine(doc, start.line).text, start);
17.1385 + extendSelection(cm, word.from, word.to);
17.1386 + } else { lastClick = {time: now, pos: start}; }
17.1387 +
17.1388 + var last = start;
17.1389 + if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) && !posEq(sel.from, sel.to) &&
17.1390 + !posLess(start, sel.from) && !posLess(sel.to, start) && type == "single") {
17.1391 + var dragEnd = operation(cm, function(e2) {
17.1392 + if (webkit) display.scroller.draggable = false;
17.1393 + view.draggingText = false;
17.1394 + off(document, "mouseup", dragEnd);
17.1395 + off(display.scroller, "drop", dragEnd);
17.1396 + if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
17.1397 + e_preventDefault(e2);
17.1398 + extendSelection(cm, start);
17.1399 + focusInput(cm);
17.1400 + }
17.1401 + });
17.1402 + // Let the drag handler handle this.
17.1403 + if (webkit) display.scroller.draggable = true;
17.1404 + view.draggingText = dragEnd;
17.1405 + // IE's approach to draggable
17.1406 + if (display.scroller.dragDrop) display.scroller.dragDrop();
17.1407 + on(document, "mouseup", dragEnd);
17.1408 + on(display.scroller, "drop", dragEnd);
17.1409 + return;
17.1410 + }
17.1411 + e_preventDefault(e);
17.1412 + if (type == "single") extendSelection(cm, clipPos(doc, start));
17.1413 +
17.1414 + var startstart = sel.from, startend = sel.to;
17.1415 +
17.1416 + function doSelect(cur) {
17.1417 + if (type == "single") {
17.1418 + extendSelection(cm, clipPos(doc, start), cur);
17.1419 + return;
17.1420 + }
17.1421 +
17.1422 + startstart = clipPos(doc, startstart);
17.1423 + startend = clipPos(doc, startend);
17.1424 + if (type == "double") {
17.1425 + var word = findWordAt(getLine(doc, cur.line).text, cur);
17.1426 + if (posLess(cur, startstart)) extendSelection(cm, word.from, startend);
17.1427 + else extendSelection(cm, startstart, word.to);
17.1428 + } else if (type == "triple") {
17.1429 + if (posLess(cur, startstart)) extendSelection(cm, startend, clipPos(doc, {line: cur.line, ch: 0}));
17.1430 + else extendSelection(cm, startstart, clipPos(doc, {line: cur.line + 1, ch: 0}));
17.1431 + }
17.1432 + }
17.1433 +
17.1434 + var editorSize = display.wrapper.getBoundingClientRect();
17.1435 + // Used to ensure timeout re-tries don't fire when another extend
17.1436 + // happened in the meantime (clearTimeout isn't reliable -- at
17.1437 + // least on Chrome, the timeouts still happen even when cleared,
17.1438 + // if the clear happens after their scheduled firing time).
17.1439 + var counter = 0;
17.1440 +
17.1441 + function extend(e) {
17.1442 + var curCount = ++counter;
17.1443 + var cur = posFromMouse(cm, e, true);
17.1444 + if (!cur) return;
17.1445 + if (!posEq(cur, last)) {
17.1446 + if (!view.focused) onFocus(cm);
17.1447 + last = cur;
17.1448 + doSelect(cur);
17.1449 + var visible = visibleLines(display, doc);
17.1450 + if (cur.line >= visible.to || cur.line < visible.from)
17.1451 + setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);
17.1452 + } else {
17.1453 + var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
17.1454 + if (outside) setTimeout(operation(cm, function() {
17.1455 + if (counter != curCount) return;
17.1456 + display.scroller.scrollTop += outside;
17.1457 + extend(e);
17.1458 + }), 50);
17.1459 + }
17.1460 + }
17.1461 +
17.1462 + function done(e) {
17.1463 + counter = Infinity;
17.1464 + var cur = posFromMouse(cm, e);
17.1465 + if (cur) doSelect(cur);
17.1466 + e_preventDefault(e);
17.1467 + focusInput(cm);
17.1468 + off(document, "mousemove", move);
17.1469 + off(document, "mouseup", up);
17.1470 + }
17.1471 +
17.1472 + var move = operation(cm, function(e) {
17.1473 + if (!ie && !e_button(e)) done(e);
17.1474 + else extend(e);
17.1475 + });
17.1476 + var up = operation(cm, done);
17.1477 + on(document, "mousemove", move);
17.1478 + on(document, "mouseup", up);
17.1479 + }
17.1480 +
17.1481 + function onDrop(e) {
17.1482 + var cm = this;
17.1483 + if (cm.options.onDragEvent && cm.options.onDragEvent(cm, addStop(e))) return;
17.1484 + e_preventDefault(e);
17.1485 + var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
17.1486 + if (!pos || isReadOnly(cm)) return;
17.1487 + if (files && files.length && window.FileReader && window.File) {
17.1488 + var n = files.length, text = Array(n), read = 0;
17.1489 + var loadFile = function(file, i) {
17.1490 + var reader = new FileReader;
17.1491 + reader.onload = function() {
17.1492 + text[i] = reader.result;
17.1493 + if (++read == n) {
17.1494 + pos = clipPos(cm.view.doc, pos);
17.1495 + operation(cm, function() {
17.1496 + var end = replaceRange(cm, text.join(""), pos, pos, "paste");
17.1497 + setSelection(cm, pos, end);
17.1498 + })();
17.1499 + }
17.1500 + };
17.1501 + reader.readAsText(file);
17.1502 + };
17.1503 + for (var i = 0; i < n; ++i) loadFile(files[i], i);
17.1504 + } else {
17.1505 + // Don't do a replace if the drop happened inside of the selected text.
17.1506 + if (cm.view.draggingText && !(posLess(pos, cm.view.sel.from) || posLess(cm.view.sel.to, pos))) {
17.1507 + cm.view.draggingText(e);
17.1508 + if (ie) setTimeout(bind(focusInput, cm), 50);
17.1509 + return;
17.1510 + }
17.1511 + try {
17.1512 + var text = e.dataTransfer.getData("Text");
17.1513 + if (text) {
17.1514 + var curFrom = cm.view.sel.from, curTo = cm.view.sel.to;
17.1515 + setSelection(cm, pos, pos);
17.1516 + if (cm.view.draggingText) replaceRange(cm, "", curFrom, curTo, "paste");
17.1517 + cm.replaceSelection(text, null, "paste");
17.1518 + focusInput(cm);
17.1519 + onFocus(cm);
17.1520 + }
17.1521 + }
17.1522 + catch(e){}
17.1523 + }
17.1524 + }
17.1525 +
17.1526 + function clickInGutter(cm, e) {
17.1527 + var display = cm.display;
17.1528 + try { var mX = e.clientX, mY = e.clientY; }
17.1529 + catch(e) { return false; }
17.1530 +
17.1531 + if (mX >= Math.floor(display.gutters.getBoundingClientRect().right)) return false;
17.1532 + e_preventDefault(e);
17.1533 + if (!hasHandler(cm, "gutterClick")) return true;
17.1534 +
17.1535 + var lineBox = display.lineDiv.getBoundingClientRect();
17.1536 + if (mY > lineBox.bottom) return true;
17.1537 + mY -= lineBox.top - display.viewOffset;
17.1538 +
17.1539 + for (var i = 0; i < cm.options.gutters.length; ++i) {
17.1540 + var g = display.gutters.childNodes[i];
17.1541 + if (g && g.getBoundingClientRect().right >= mX) {
17.1542 + var line = lineAtHeight(cm.view.doc, mY);
17.1543 + var gutter = cm.options.gutters[i];
17.1544 + signalLater(cm, cm, "gutterClick", cm, line, gutter, e);
17.1545 + break;
17.1546 + }
17.1547 + }
17.1548 + return true;
17.1549 + }
17.1550 +
17.1551 + function onDragStart(cm, e) {
17.1552 + var txt = cm.getSelection();
17.1553 + e.dataTransfer.setData("Text", txt);
17.1554 +
17.1555 + // Use dummy image instead of default browsers image.
17.1556 + // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
17.1557 + if (e.dataTransfer.setDragImage && !safari)
17.1558 + e.dataTransfer.setDragImage(elt('img'), 0, 0);
17.1559 + }
17.1560 +
17.1561 + function setScrollTop(cm, val) {
17.1562 + if (Math.abs(cm.view.scrollTop - val) < 2) return;
17.1563 + cm.view.scrollTop = val;
17.1564 + if (!gecko) updateDisplay(cm, [], val);
17.1565 + if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
17.1566 + if (cm.display.scrollbarV.scrollTop != val) cm.display.scrollbarV.scrollTop = val;
17.1567 + if (gecko) updateDisplay(cm, []);
17.1568 + }
17.1569 + function setScrollLeft(cm, val, isScroller) {
17.1570 + if (isScroller ? val == cm.view.scrollLeft : Math.abs(cm.view.scrollLeft - val) < 2) return;
17.1571 + cm.view.scrollLeft = val;
17.1572 + alignHorizontally(cm);
17.1573 + if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
17.1574 + if (cm.display.scrollbarH.scrollLeft != val) cm.display.scrollbarH.scrollLeft = val;
17.1575 + }
17.1576 +
17.1577 + // Since the delta values reported on mouse wheel events are
17.1578 + // unstandardized between browsers and even browser versions, and
17.1579 + // generally horribly unpredictable, this code starts by measuring
17.1580 + // the scroll effect that the first few mouse wheel events have,
17.1581 + // and, from that, detects the way it can convert deltas to pixel
17.1582 + // offsets afterwards.
17.1583 + //
17.1584 + // The reason we want to know the amount a wheel event will scroll
17.1585 + // is that it gives us a chance to update the display before the
17.1586 + // actual scrolling happens, reducing flickering.
17.1587 +
17.1588 + var wheelSamples = 0, wheelDX, wheelDY, wheelStartX, wheelStartY, wheelPixelsPerUnit = null;
17.1589 + // Fill in a browser-detected starting value on browsers where we
17.1590 + // know one. These don't have to be accurate -- the result of them
17.1591 + // being wrong would just be a slight flicker on the first wheel
17.1592 + // scroll (if it is large enough).
17.1593 + if (ie) wheelPixelsPerUnit = -.53;
17.1594 + else if (gecko) wheelPixelsPerUnit = 15;
17.1595 + else if (chrome) wheelPixelsPerUnit = -.7;
17.1596 + else if (safari) wheelPixelsPerUnit = -1/3;
17.1597 +
17.1598 + function onScrollWheel(cm, e) {
17.1599 + var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
17.1600 + if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
17.1601 + if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
17.1602 + else if (dy == null) dy = e.wheelDelta;
17.1603 +
17.1604 + // Webkit browsers on OS X abort momentum scrolls when the target
17.1605 + // of the scroll event is removed from the scrollable element.
17.1606 + // This hack (see related code in patchDisplay) makes sure the
17.1607 + // element is kept around.
17.1608 + if (dy && mac && webkit) {
17.1609 + for (var cur = e.target; cur != scroll; cur = cur.parentNode) {
17.1610 + if (cur.lineObj) {
17.1611 + cm.display.currentWheelTarget = cur;
17.1612 + break;
17.1613 + }
17.1614 + }
17.1615 + }
17.1616 +
17.1617 + var scroll = cm.display.scroller;
17.1618 + // On some browsers, horizontal scrolling will cause redraws to
17.1619 + // happen before the gutter has been realigned, causing it to
17.1620 + // wriggle around in a most unseemly way. When we have an
17.1621 + // estimated pixels/delta value, we just handle horizontal
17.1622 + // scrolling entirely here. It'll be slightly off from native, but
17.1623 + // better than glitching out.
17.1624 + if (dx && !gecko && !opera && wheelPixelsPerUnit != null) {
17.1625 + if (dy)
17.1626 + setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
17.1627 + setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
17.1628 + e_preventDefault(e);
17.1629 + wheelStartX = null; // Abort measurement, if in progress
17.1630 + return;
17.1631 + }
17.1632 +
17.1633 + if (dy && wheelPixelsPerUnit != null) {
17.1634 + var pixels = dy * wheelPixelsPerUnit;
17.1635 + var top = cm.view.scrollTop, bot = top + cm.display.wrapper.clientHeight;
17.1636 + if (pixels < 0) top = Math.max(0, top + pixels - 50);
17.1637 + else bot = Math.min(cm.view.doc.height, bot + pixels + 50);
17.1638 + updateDisplay(cm, [], {top: top, bottom: bot});
17.1639 + }
17.1640 +
17.1641 + if (wheelSamples < 20) {
17.1642 + if (wheelStartX == null) {
17.1643 + wheelStartX = scroll.scrollLeft; wheelStartY = scroll.scrollTop;
17.1644 + wheelDX = dx; wheelDY = dy;
17.1645 + setTimeout(function() {
17.1646 + if (wheelStartX == null) return;
17.1647 + var movedX = scroll.scrollLeft - wheelStartX;
17.1648 + var movedY = scroll.scrollTop - wheelStartY;
17.1649 + var sample = (movedY && wheelDY && movedY / wheelDY) ||
17.1650 + (movedX && wheelDX && movedX / wheelDX);
17.1651 + wheelStartX = wheelStartY = null;
17.1652 + if (!sample) return;
17.1653 + wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
17.1654 + ++wheelSamples;
17.1655 + }, 200);
17.1656 + } else {
17.1657 + wheelDX += dx; wheelDY += dy;
17.1658 + }
17.1659 + }
17.1660 + }
17.1661 +
17.1662 + function doHandleBinding(cm, bound, dropShift) {
17.1663 + if (typeof bound == "string") {
17.1664 + bound = commands[bound];
17.1665 + if (!bound) return false;
17.1666 + }
17.1667 + // Ensure previous input has been read, so that the handler sees a
17.1668 + // consistent view of the document
17.1669 + if (cm.display.pollingFast && readInput(cm)) cm.display.pollingFast = false;
17.1670 + var view = cm.view, prevShift = view.sel.shift;
17.1671 + try {
17.1672 + if (isReadOnly(cm)) view.suppressEdits = true;
17.1673 + if (dropShift) view.sel.shift = false;
17.1674 + bound(cm);
17.1675 + } catch(e) {
17.1676 + if (e != Pass) throw e;
17.1677 + return false;
17.1678 + } finally {
17.1679 + view.sel.shift = prevShift;
17.1680 + view.suppressEdits = false;
17.1681 + }
17.1682 + return true;
17.1683 + }
17.1684 +
17.1685 + function allKeyMaps(cm) {
17.1686 + var maps = cm.view.keyMaps.slice(0);
17.1687 + maps.push(cm.options.keyMap);
17.1688 + if (cm.options.extraKeys) maps.unshift(cm.options.extraKeys);
17.1689 + return maps;
17.1690 + }
17.1691 +
17.1692 + var maybeTransition;
17.1693 + function handleKeyBinding(cm, e) {
17.1694 + // Handle auto keymap transitions
17.1695 + var startMap = getKeyMap(cm.options.keyMap), next = startMap.auto;
17.1696 + clearTimeout(maybeTransition);
17.1697 + if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {
17.1698 + if (getKeyMap(cm.options.keyMap) == startMap)
17.1699 + cm.options.keyMap = (next.call ? next.call(null, cm) : next);
17.1700 + }, 50);
17.1701 +
17.1702 + var name = keyNames[e_prop(e, "keyCode")], handled = false;
17.1703 + var flipCtrlCmd = mac && (opera || qtwebkit);
17.1704 + if (name == null || e.altGraphKey) return false;
17.1705 + if (e_prop(e, "altKey")) name = "Alt-" + name;
17.1706 + if (e_prop(e, flipCtrlCmd ? "metaKey" : "ctrlKey")) name = "Ctrl-" + name;
17.1707 + if (e_prop(e, flipCtrlCmd ? "ctrlKey" : "metaKey")) name = "Cmd-" + name;
17.1708 +
17.1709 + var stopped = false;
17.1710 + function stop() { stopped = true; }
17.1711 + var keymaps = allKeyMaps(cm);
17.1712 +
17.1713 + if (e_prop(e, "shiftKey")) {
17.1714 + handled = lookupKey("Shift-" + name, keymaps,
17.1715 + function(b) {return doHandleBinding(cm, b, true);}, stop)
17.1716 + || lookupKey(name, keymaps, function(b) {
17.1717 + if (typeof b == "string" && /^go[A-Z]/.test(b)) return doHandleBinding(cm, b);
17.1718 + }, stop);
17.1719 + } else {
17.1720 + handled = lookupKey(name, keymaps,
17.1721 + function(b) { return doHandleBinding(cm, b); }, stop);
17.1722 + }
17.1723 + if (stopped) handled = false;
17.1724 + if (handled) {
17.1725 + e_preventDefault(e);
17.1726 + restartBlink(cm);
17.1727 + if (ie_lt9) { e.oldKeyCode = e.keyCode; e.keyCode = 0; }
17.1728 + }
17.1729 + return handled;
17.1730 + }
17.1731 +
17.1732 + function handleCharBinding(cm, e, ch) {
17.1733 + var handled = lookupKey("'" + ch + "'", allKeyMaps(cm),
17.1734 + function(b) { return doHandleBinding(cm, b, true); });
17.1735 + if (handled) {
17.1736 + e_preventDefault(e);
17.1737 + restartBlink(cm);
17.1738 + }
17.1739 + return handled;
17.1740 + }
17.1741 +
17.1742 + var lastStoppedKey = null;
17.1743 + function onKeyDown(e) {
17.1744 + var cm = this;
17.1745 + if (!cm.view.focused) onFocus(cm);
17.1746 + if (ie && e.keyCode == 27) { e.returnValue = false; }
17.1747 + if (cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return;
17.1748 + var code = e_prop(e, "keyCode");
17.1749 + // IE does strange things with escape.
17.1750 + cm.view.sel.shift = code == 16 || e_prop(e, "shiftKey");
17.1751 + // First give onKeyEvent option a chance to handle this.
17.1752 + var handled = handleKeyBinding(cm, e);
17.1753 + if (opera) {
17.1754 + lastStoppedKey = handled ? code : null;
17.1755 + // Opera has no cut event... we try to at least catch the key combo
17.1756 + if (!handled && code == 88 && !hasCopyEvent && e_prop(e, mac ? "metaKey" : "ctrlKey"))
17.1757 + cm.replaceSelection("");
17.1758 + }
17.1759 + }
17.1760 +
17.1761 + function onKeyPress(e) {
17.1762 + var cm = this;
17.1763 + if (cm.options.onKeyEvent && cm.options.onKeyEvent(cm, addStop(e))) return;
17.1764 + var keyCode = e_prop(e, "keyCode"), charCode = e_prop(e, "charCode");
17.1765 + if (opera && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
17.1766 + if (((opera && (!e.which || e.which < 10)) || khtml) && handleKeyBinding(cm, e)) return;
17.1767 + var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
17.1768 + if (this.options.electricChars && this.view.mode.electricChars &&
17.1769 + this.options.smartIndent && !isReadOnly(this) &&
17.1770 + this.view.mode.electricChars.indexOf(ch) > -1)
17.1771 + setTimeout(operation(cm, function() {indentLine(cm, cm.view.sel.to.line, "smart");}), 75);
17.1772 + if (handleCharBinding(cm, e, ch)) return;
17.1773 + fastPoll(cm);
17.1774 + }
17.1775 +
17.1776 + function onFocus(cm) {
17.1777 + if (cm.options.readOnly == "nocursor") return;
17.1778 + if (!cm.view.focused) {
17.1779 + signal(cm, "focus", cm);
17.1780 + cm.view.focused = true;
17.1781 + if (cm.display.scroller.className.search(/\bCodeMirror-focused\b/) == -1)
17.1782 + cm.display.scroller.className += " CodeMirror-focused";
17.1783 + resetInput(cm, true);
17.1784 + }
17.1785 + slowPoll(cm);
17.1786 + restartBlink(cm);
17.1787 + }
17.1788 + function onBlur(cm) {
17.1789 + if (cm.view.focused) {
17.1790 + signal(cm, "blur", cm);
17.1791 + cm.view.focused = false;
17.1792 + cm.display.scroller.className = cm.display.scroller.className.replace(" CodeMirror-focused", "");
17.1793 + }
17.1794 + clearInterval(cm.display.blinker);
17.1795 + setTimeout(function() {if (!cm.view.focused) cm.view.sel.shift = false;}, 150);
17.1796 + }
17.1797 +
17.1798 + var detectingSelectAll;
17.1799 + function onContextMenu(cm, e) {
17.1800 + var display = cm.display, sel = cm.view.sel;
17.1801 + var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
17.1802 + if (!pos || opera) return; // Opera is difficult.
17.1803 + if (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to))
17.1804 + operation(cm, setSelection)(cm, pos, pos);
17.1805 +
17.1806 + var oldCSS = display.input.style.cssText;
17.1807 + display.inputDiv.style.position = "absolute";
17.1808 + display.input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
17.1809 + "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: white; outline: none;" +
17.1810 + "border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
17.1811 + focusInput(cm);
17.1812 + resetInput(cm, true);
17.1813 + // Adds "Select all" to context menu in FF
17.1814 + if (posEq(sel.from, sel.to)) display.input.value = display.prevInput = " ";
17.1815 +
17.1816 + function rehide() {
17.1817 + display.inputDiv.style.position = "relative";
17.1818 + display.input.style.cssText = oldCSS;
17.1819 + if (ie_lt9) display.scrollbarV.scrollTop = display.scroller.scrollTop = scrollPos;
17.1820 + slowPoll(cm);
17.1821 +
17.1822 + // Try to detect the user choosing select-all
17.1823 + if (display.input.selectionStart != null) {
17.1824 + clearTimeout(detectingSelectAll);
17.1825 + var extval = display.input.value = " " + (posEq(sel.from, sel.to) ? "" : display.input.value), i = 0;
17.1826 + display.prevInput = " ";
17.1827 + display.input.selectionStart = 1; display.input.selectionEnd = extval.length;
17.1828 + detectingSelectAll = setTimeout(function poll(){
17.1829 + if (display.prevInput == " " && display.input.selectionStart == 0)
17.1830 + operation(cm, commands.selectAll)(cm);
17.1831 + else if (i++ < 10) detectingSelectAll = setTimeout(poll, 500);
17.1832 + else resetInput(cm);
17.1833 + }, 200);
17.1834 + }
17.1835 + }
17.1836 +
17.1837 + if (gecko) {
17.1838 + e_stop(e);
17.1839 + on(window, "mouseup", function mouseup() {
17.1840 + off(window, "mouseup", mouseup);
17.1841 + setTimeout(rehide, 20);
17.1842 + });
17.1843 + } else {
17.1844 + setTimeout(rehide, 50);
17.1845 + }
17.1846 + }
17.1847 +
17.1848 + // UPDATING
17.1849 +
17.1850 + // Replace the range from from to to by the strings in newText.
17.1851 + // Afterwards, set the selection to selFrom, selTo.
17.1852 + function updateDoc(cm, from, to, newText, selUpdate, origin) {
17.1853 + // Possibly split or suppress the update based on the presence
17.1854 + // of read-only spans in its range.
17.1855 + var split = sawReadOnlySpans &&
17.1856 + removeReadOnlyRanges(cm.view.doc, from, to);
17.1857 + if (split) {
17.1858 + for (var i = split.length - 1; i >= 1; --i)
17.1859 + updateDocInner(cm, split[i].from, split[i].to, [""], origin);
17.1860 + if (split.length)
17.1861 + return updateDocInner(cm, split[0].from, split[0].to, newText, selUpdate, origin);
17.1862 + } else {
17.1863 + return updateDocInner(cm, from, to, newText, selUpdate, origin);
17.1864 + }
17.1865 + }
17.1866 +
17.1867 + function updateDocInner(cm, from, to, newText, selUpdate, origin) {
17.1868 + if (cm.view.suppressEdits) return;
17.1869 +
17.1870 + var view = cm.view, doc = view.doc, old = [];
17.1871 + doc.iter(from.line, to.line + 1, function(line) {
17.1872 + old.push(newHL(line.text, line.markedSpans));
17.1873 + });
17.1874 + var startSelFrom = view.sel.from, startSelTo = view.sel.to;
17.1875 + var lines = updateMarkedSpans(hlSpans(old[0]), hlSpans(lst(old)), from.ch, to.ch, newText);
17.1876 + var retval = updateDocNoUndo(cm, from, to, lines, selUpdate, origin);
17.1877 + if (view.history) addChange(cm, from.line, newText.length, old, origin,
17.1878 + startSelFrom, startSelTo, view.sel.from, view.sel.to);
17.1879 + return retval;
17.1880 + }
17.1881 +
17.1882 + function unredoHelper(cm, type) {
17.1883 + var doc = cm.view.doc, hist = cm.view.history;
17.1884 + var set = (type == "undo" ? hist.done : hist.undone).pop();
17.1885 + if (!set) return;
17.1886 + var anti = {events: [], fromBefore: set.fromAfter, toBefore: set.toAfter,
17.1887 + fromAfter: set.fromBefore, toAfter: set.toBefore};
17.1888 + for (var i = set.events.length - 1; i >= 0; i -= 1) {
17.1889 + hist.dirtyCounter += type == "undo" ? -1 : 1;
17.1890 + var change = set.events[i];
17.1891 + var replaced = [], end = change.start + change.added;
17.1892 + doc.iter(change.start, end, function(line) { replaced.push(newHL(line.text, line.markedSpans)); });
17.1893 + anti.events.push({start: change.start, added: change.old.length, old: replaced});
17.1894 + var selPos = i ? null : {from: set.fromBefore, to: set.toBefore};
17.1895 + updateDocNoUndo(cm, {line: change.start, ch: 0}, {line: end - 1, ch: getLine(doc, end-1).text.length},
17.1896 + change.old, selPos, type);
17.1897 + }
17.1898 + (type == "undo" ? hist.undone : hist.done).push(anti);
17.1899 + }
17.1900 +
17.1901 + function updateDocNoUndo(cm, from, to, lines, selUpdate, origin) {
17.1902 + var view = cm.view, doc = view.doc, display = cm.display;
17.1903 + if (view.suppressEdits) return;
17.1904 +
17.1905 + var nlines = to.line - from.line, firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
17.1906 + var recomputeMaxLength = false, checkWidthStart = from.line;
17.1907 + if (!cm.options.lineWrapping) {
17.1908 + checkWidthStart = lineNo(visualLine(doc, firstLine));
17.1909 + doc.iter(checkWidthStart, to.line + 1, function(line) {
17.1910 + if (lineLength(doc, line) == view.maxLineLength) {
17.1911 + recomputeMaxLength = true;
17.1912 + return true;
17.1913 + }
17.1914 + });
17.1915 + }
17.1916 +
17.1917 + var lastHL = lst(lines), th = textHeight(display);
17.1918 +
17.1919 + // First adjust the line structure
17.1920 + if (from.ch == 0 && to.ch == 0 && hlText(lastHL) == "") {
17.1921 + // This is a whole-line replace. Treated specially to make
17.1922 + // sure line objects move the way they are supposed to.
17.1923 + var added = [];
17.1924 + for (var i = 0, e = lines.length - 1; i < e; ++i)
17.1925 + added.push(makeLine(hlText(lines[i]), hlSpans(lines[i]), th));
17.1926 + updateLine(cm, lastLine, lastLine.text, hlSpans(lastHL));
17.1927 + if (nlines) doc.remove(from.line, nlines, cm);
17.1928 + if (added.length) doc.insert(from.line, added);
17.1929 + } else if (firstLine == lastLine) {
17.1930 + if (lines.length == 1) {
17.1931 + updateLine(cm, firstLine, firstLine.text.slice(0, from.ch) + hlText(lines[0]) +
17.1932 + firstLine.text.slice(to.ch), hlSpans(lines[0]));
17.1933 + } else {
17.1934 + for (var added = [], i = 1, e = lines.length - 1; i < e; ++i)
17.1935 + added.push(makeLine(hlText(lines[i]), hlSpans(lines[i]), th));
17.1936 + added.push(makeLine(hlText(lastHL) + firstLine.text.slice(to.ch), hlSpans(lastHL), th));
17.1937 + updateLine(cm, firstLine, firstLine.text.slice(0, from.ch) + hlText(lines[0]), hlSpans(lines[0]));
17.1938 + doc.insert(from.line + 1, added);
17.1939 + }
17.1940 + } else if (lines.length == 1) {
17.1941 + updateLine(cm, firstLine, firstLine.text.slice(0, from.ch) + hlText(lines[0]) +
17.1942 + lastLine.text.slice(to.ch), hlSpans(lines[0]));
17.1943 + doc.remove(from.line + 1, nlines, cm);
17.1944 + } else {
17.1945 + var added = [];
17.1946 + updateLine(cm, firstLine, firstLine.text.slice(0, from.ch) + hlText(lines[0]), hlSpans(lines[0]));
17.1947 + updateLine(cm, lastLine, hlText(lastHL) + lastLine.text.slice(to.ch), hlSpans(lastHL));
17.1948 + for (var i = 1, e = lines.length - 1; i < e; ++i)
17.1949 + added.push(makeLine(hlText(lines[i]), hlSpans(lines[i]), th));
17.1950 + if (nlines > 1) doc.remove(from.line + 1, nlines - 1, cm);
17.1951 + doc.insert(from.line + 1, added);
17.1952 + }
17.1953 +
17.1954 + if (cm.options.lineWrapping) {
17.1955 + var perLine = Math.max(5, display.scroller.clientWidth / charWidth(display) - 3);
17.1956 + doc.iter(from.line, from.line + lines.length, function(line) {
17.1957 + if (line.height == 0) return;
17.1958 + var guess = (Math.ceil(line.text.length / perLine) || 1) * th;
17.1959 + if (guess != line.height) updateLineHeight(line, guess);
17.1960 + });
17.1961 + } else {
17.1962 + doc.iter(checkWidthStart, from.line + lines.length, function(line) {
17.1963 + var len = lineLength(doc, line);
17.1964 + if (len > view.maxLineLength) {
17.1965 + view.maxLine = line;
17.1966 + view.maxLineLength = len;
17.1967 + view.maxLineChanged = true;
17.1968 + recomputeMaxLength = false;
17.1969 + }
17.1970 + });
17.1971 + if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
17.1972 + }
17.1973 +
17.1974 + // Adjust frontier, schedule worker
17.1975 + view.frontier = Math.min(view.frontier, from.line);
17.1976 + startWorker(cm, 400);
17.1977 +
17.1978 + var lendiff = lines.length - nlines - 1;
17.1979 + // Remember that these lines changed, for updating the display
17.1980 + regChange(cm, from.line, to.line + 1, lendiff);
17.1981 + if (hasHandler(cm, "change")) {
17.1982 + // Normalize lines to contain only strings, since that's what
17.1983 + // the change event handler expects
17.1984 + for (var i = 0; i < lines.length; ++i)
17.1985 + if (typeof lines[i] != "string") lines[i] = lines[i].text;
17.1986 + var changeObj = {from: from, to: to, text: lines, origin: origin};
17.1987 + if (cm.curOp.textChanged) {
17.1988 + for (var cur = cm.curOp.textChanged; cur.next; cur = cur.next) {}
17.1989 + cur.next = changeObj;
17.1990 + } else cm.curOp.textChanged = changeObj;
17.1991 + }
17.1992 +
17.1993 + // Update the selection
17.1994 + var newSelFrom, newSelTo, end = {line: from.line + lines.length - 1,
17.1995 + ch: hlText(lastHL).length + (lines.length == 1 ? from.ch : 0)};
17.1996 + if (selUpdate && typeof selUpdate != "string") {
17.1997 + if (selUpdate.from) { newSelFrom = selUpdate.from; newSelTo = selUpdate.to; }
17.1998 + else newSelFrom = newSelTo = selUpdate;
17.1999 + } else if (selUpdate == "end") {
17.2000 + newSelFrom = newSelTo = end;
17.2001 + } else if (selUpdate == "start") {
17.2002 + newSelFrom = newSelTo = from;
17.2003 + } else if (selUpdate == "around") {
17.2004 + newSelFrom = from; newSelTo = end;
17.2005 + } else {
17.2006 + var adjustPos = function(pos) {
17.2007 + if (posLess(pos, from)) return pos;
17.2008 + if (!posLess(to, pos)) return end;
17.2009 + var line = pos.line + lendiff;
17.2010 + var ch = pos.ch;
17.2011 + if (pos.line == to.line)
17.2012 + ch += hlText(lastHL).length - (to.ch - (to.line == from.line ? from.ch : 0));
17.2013 + return {line: line, ch: ch};
17.2014 + };
17.2015 + newSelFrom = adjustPos(view.sel.from);
17.2016 + newSelTo = adjustPos(view.sel.to);
17.2017 + }
17.2018 + setSelection(cm, newSelFrom, newSelTo, null, true);
17.2019 + return end;
17.2020 + }
17.2021 +
17.2022 + function replaceRange(cm, code, from, to, origin) {
17.2023 + if (!to) to = from;
17.2024 + if (posLess(to, from)) { var tmp = to; to = from; from = tmp; }
17.2025 + return updateDoc(cm, from, to, splitLines(code), null, origin);
17.2026 + }
17.2027 +
17.2028 + // SELECTION
17.2029 +
17.2030 + function posEq(a, b) {return a.line == b.line && a.ch == b.ch;}
17.2031 + function posLess(a, b) {return a.line < b.line || (a.line == b.line && a.ch < b.ch);}
17.2032 + function copyPos(x) {return {line: x.line, ch: x.ch};}
17.2033 +
17.2034 + function clipLine(doc, n) {return Math.max(0, Math.min(n, doc.size-1));}
17.2035 + function clipPos(doc, pos) {
17.2036 + if (pos.line < 0) return {line: 0, ch: 0};
17.2037 + if (pos.line >= doc.size) return {line: doc.size-1, ch: getLine(doc, doc.size-1).text.length};
17.2038 + var ch = pos.ch, linelen = getLine(doc, pos.line).text.length;
17.2039 + if (ch == null || ch > linelen) return {line: pos.line, ch: linelen};
17.2040 + else if (ch < 0) return {line: pos.line, ch: 0};
17.2041 + else return pos;
17.2042 + }
17.2043 + function isLine(doc, l) {return l >= 0 && l < doc.size;}
17.2044 +
17.2045 + // If shift is held, this will move the selection anchor. Otherwise,
17.2046 + // it'll set the whole selection.
17.2047 + function extendSelection(cm, pos, other, bias) {
17.2048 + var sel = cm.view.sel;
17.2049 + if (sel.shift || sel.extend) {
17.2050 + var anchor = sel.anchor;
17.2051 + if (other) {
17.2052 + var posBefore = posLess(pos, anchor);
17.2053 + if (posBefore != posLess(other, anchor)) {
17.2054 + anchor = pos;
17.2055 + pos = other;
17.2056 + } else if (posBefore != posLess(pos, other)) {
17.2057 + pos = other;
17.2058 + }
17.2059 + }
17.2060 + setSelection(cm, anchor, pos, bias);
17.2061 + } else {
17.2062 + setSelection(cm, pos, other || pos, bias);
17.2063 + }
17.2064 + cm.curOp.userSelChange = true;
17.2065 + }
17.2066 +
17.2067 + // Update the selection. Last two args are only used by
17.2068 + // updateDoc, since they have to be expressed in the line
17.2069 + // numbers before the update.
17.2070 + function setSelection(cm, anchor, head, bias, checkAtomic) {
17.2071 + cm.view.goalColumn = null;
17.2072 + var sel = cm.view.sel;
17.2073 + // Skip over atomic spans.
17.2074 + if (checkAtomic || !posEq(anchor, sel.anchor))
17.2075 + anchor = skipAtomic(cm, anchor, bias, checkAtomic != "push");
17.2076 + if (checkAtomic || !posEq(head, sel.head))
17.2077 + head = skipAtomic(cm, head, bias, checkAtomic != "push");
17.2078 +
17.2079 + if (posEq(sel.anchor, anchor) && posEq(sel.head, head)) return;
17.2080 +
17.2081 + sel.anchor = anchor; sel.head = head;
17.2082 + var inv = posLess(head, anchor);
17.2083 + sel.from = inv ? head : anchor;
17.2084 + sel.to = inv ? anchor : head;
17.2085 +
17.2086 + cm.curOp.updateInput = true;
17.2087 + cm.curOp.selectionChanged = true;
17.2088 + }
17.2089 +
17.2090 + function reCheckSelection(cm) {
17.2091 + setSelection(cm, cm.view.sel.from, cm.view.sel.to, null, "push");
17.2092 + }
17.2093 +
17.2094 + function skipAtomic(cm, pos, bias, mayClear) {
17.2095 + var doc = cm.view.doc, flipped = false, curPos = pos;
17.2096 + var dir = bias || 1;
17.2097 + cm.view.cantEdit = false;
17.2098 + search: for (;;) {
17.2099 + var line = getLine(doc, curPos.line), toClear;
17.2100 + if (line.markedSpans) {
17.2101 + for (var i = 0; i < line.markedSpans.length; ++i) {
17.2102 + var sp = line.markedSpans[i], m = sp.marker;
17.2103 + if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) &&
17.2104 + (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) {
17.2105 + if (mayClear && m.clearOnEnter) {
17.2106 + (toClear || (toClear = [])).push(m);
17.2107 + continue;
17.2108 + } else if (!m.atomic) continue;
17.2109 + var newPos = m.find()[dir < 0 ? "from" : "to"];
17.2110 + if (posEq(newPos, curPos)) {
17.2111 + newPos.ch += dir;
17.2112 + if (newPos.ch < 0) {
17.2113 + if (newPos.line) newPos = clipPos(doc, {line: newPos.line - 1});
17.2114 + else newPos = null;
17.2115 + } else if (newPos.ch > line.text.length) {
17.2116 + if (newPos.line < doc.size - 1) newPos = {line: newPos.line + 1, ch: 0};
17.2117 + else newPos = null;
17.2118 + }
17.2119 + if (!newPos) {
17.2120 + if (flipped) {
17.2121 + // Driven in a corner -- no valid cursor position found at all
17.2122 + // -- try again *with* clearing, if we didn't already
17.2123 + if (!mayClear) return skipAtomic(cm, pos, bias, true);
17.2124 + // Otherwise, turn off editing until further notice, and return the start of the doc
17.2125 + cm.view.cantEdit = true;
17.2126 + return {line: 0, ch: 0};
17.2127 + }
17.2128 + flipped = true; newPos = pos; dir = -dir;
17.2129 + }
17.2130 + }
17.2131 + curPos = newPos;
17.2132 + continue search;
17.2133 + }
17.2134 + }
17.2135 + if (toClear) for (var i = 0; i < toClear.length; ++i) toClear[i].clear();
17.2136 + }
17.2137 + return curPos;
17.2138 + }
17.2139 + }
17.2140 +
17.2141 + // SCROLLING
17.2142 +
17.2143 + function scrollCursorIntoView(cm) {
17.2144 + var view = cm.view;
17.2145 + var coords = scrollPosIntoView(cm, view.sel.head);
17.2146 + if (!view.focused) return;
17.2147 + var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
17.2148 + if (coords.top + box.top < 0) doScroll = true;
17.2149 + else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
17.2150 + if (doScroll != null && !phantom) {
17.2151 + var hidden = display.cursor.style.display == "none";
17.2152 + if (hidden) {
17.2153 + display.cursor.style.display = "";
17.2154 + display.cursor.style.left = coords.left + "px";
17.2155 + display.cursor.style.top = (coords.top - display.viewOffset) + "px";
17.2156 + }
17.2157 + display.cursor.scrollIntoView(doScroll);
17.2158 + if (hidden) display.cursor.style.display = "none";
17.2159 + }
17.2160 + }
17.2161 +
17.2162 + function scrollPosIntoView(cm, pos) {
17.2163 + for (;;) {
17.2164 + var changed = false, coords = cursorCoords(cm, pos);
17.2165 + var scrollPos = calculateScrollPos(cm, coords.left, coords.top, coords.left, coords.bottom);
17.2166 + var startTop = cm.view.scrollTop, startLeft = cm.view.scrollLeft;
17.2167 + if (scrollPos.scrollTop != null) {
17.2168 + setScrollTop(cm, scrollPos.scrollTop);
17.2169 + if (Math.abs(cm.view.scrollTop - startTop) > 1) changed = true;
17.2170 + }
17.2171 + if (scrollPos.scrollLeft != null) {
17.2172 + setScrollLeft(cm, scrollPos.scrollLeft);
17.2173 + if (Math.abs(cm.view.scrollLeft - startLeft) > 1) changed = true;
17.2174 + }
17.2175 + if (!changed) return coords;
17.2176 + }
17.2177 + }
17.2178 +
17.2179 + function scrollIntoView(cm, x1, y1, x2, y2) {
17.2180 + var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);
17.2181 + if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);
17.2182 + if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);
17.2183 + }
17.2184 +
17.2185 + function calculateScrollPos(cm, x1, y1, x2, y2) {
17.2186 + var display = cm.display, pt = paddingTop(display);
17.2187 + y1 += pt; y2 += pt;
17.2188 + var screen = display.scroller.clientHeight - scrollerCutOff, screentop = display.scroller.scrollTop, result = {};
17.2189 + var docBottom = cm.view.doc.height + 2 * pt;
17.2190 + var atTop = y1 < pt + 10, atBottom = y2 + pt > docBottom - 10;
17.2191 + if (y1 < screentop) result.scrollTop = atTop ? 0 : Math.max(0, y1);
17.2192 + else if (y2 > screentop + screen) result.scrollTop = (atBottom ? docBottom : y2) - screen;
17.2193 +
17.2194 + var screenw = display.scroller.clientWidth - scrollerCutOff, screenleft = display.scroller.scrollLeft;
17.2195 + x1 += display.gutters.offsetWidth; x2 += display.gutters.offsetWidth;
17.2196 + var gutterw = display.gutters.offsetWidth;
17.2197 + var atLeft = x1 < gutterw + 10;
17.2198 + if (x1 < screenleft + gutterw || atLeft) {
17.2199 + if (atLeft) x1 = 0;
17.2200 + result.scrollLeft = Math.max(0, x1 - 10 - gutterw);
17.2201 + } else if (x2 > screenw + screenleft - 3) {
17.2202 + result.scrollLeft = x2 + 10 - screenw;
17.2203 + }
17.2204 + return result;
17.2205 + }
17.2206 +
17.2207 + // API UTILITIES
17.2208 +
17.2209 + function indentLine(cm, n, how, aggressive) {
17.2210 + var doc = cm.view.doc;
17.2211 + if (!how) how = "add";
17.2212 + if (how == "smart") {
17.2213 + if (!cm.view.mode.indent) how = "prev";
17.2214 + else var state = getStateBefore(cm, n);
17.2215 + }
17.2216 +
17.2217 + var tabSize = cm.options.tabSize;
17.2218 + var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
17.2219 + var curSpaceString = line.text.match(/^\s*/)[0], indentation;
17.2220 + if (how == "smart") {
17.2221 + indentation = cm.view.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
17.2222 + if (indentation == Pass) {
17.2223 + if (!aggressive) return;
17.2224 + how = "prev";
17.2225 + }
17.2226 + }
17.2227 + if (how == "prev") {
17.2228 + if (n) indentation = countColumn(getLine(doc, n-1).text, null, tabSize);
17.2229 + else indentation = 0;
17.2230 + }
17.2231 + else if (how == "add") indentation = curSpace + cm.options.indentUnit;
17.2232 + else if (how == "subtract") indentation = curSpace - cm.options.indentUnit;
17.2233 + indentation = Math.max(0, indentation);
17.2234 +
17.2235 + var indentString = "", pos = 0;
17.2236 + if (cm.options.indentWithTabs)
17.2237 + for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
17.2238 + if (pos < indentation) indentString += spaceStr(indentation - pos);
17.2239 +
17.2240 + if (indentString != curSpaceString)
17.2241 + replaceRange(cm, indentString, {line: n, ch: 0}, {line: n, ch: curSpaceString.length}, "input");
17.2242 + line.stateAfter = null;
17.2243 + }
17.2244 +
17.2245 + function changeLine(cm, handle, op) {
17.2246 + var no = handle, line = handle, doc = cm.view.doc;
17.2247 + if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle));
17.2248 + else no = lineNo(handle);
17.2249 + if (no == null) return null;
17.2250 + if (op(line, no)) regChange(cm, no, no + 1);
17.2251 + else return null;
17.2252 + return line;
17.2253 + }
17.2254 +
17.2255 + function findPosH(cm, dir, unit, visually) {
17.2256 + var doc = cm.view.doc, end = cm.view.sel.head, line = end.line, ch = end.ch;
17.2257 + var lineObj = getLine(doc, line);
17.2258 + function findNextLine() {
17.2259 + var l = line + dir;
17.2260 + if (l < 0 || l == doc.size) return false;
17.2261 + line = l;
17.2262 + return lineObj = getLine(doc, l);
17.2263 + }
17.2264 + function moveOnce(boundToLine) {
17.2265 + var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true);
17.2266 + if (next == null) {
17.2267 + if (!boundToLine && findNextLine()) {
17.2268 + if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
17.2269 + else ch = dir < 0 ? lineObj.text.length : 0;
17.2270 + } else return false;
17.2271 + } else ch = next;
17.2272 + return true;
17.2273 + }
17.2274 + if (unit == "char") moveOnce();
17.2275 + else if (unit == "column") moveOnce(true);
17.2276 + else if (unit == "word") {
17.2277 + var sawWord = false;
17.2278 + for (;;) {
17.2279 + if (dir < 0) if (!moveOnce()) break;
17.2280 + if (isWordChar(lineObj.text.charAt(ch))) sawWord = true;
17.2281 + else if (sawWord) {if (dir < 0) {dir = 1; moveOnce();} break;}
17.2282 + if (dir > 0) if (!moveOnce()) break;
17.2283 + }
17.2284 + }
17.2285 + return skipAtomic(cm, {line: line, ch: ch}, dir, true);
17.2286 + }
17.2287 +
17.2288 + function findWordAt(line, pos) {
17.2289 + var start = pos.ch, end = pos.ch;
17.2290 + if (line) {
17.2291 + if (pos.after === false || end == line.length) --start; else ++end;
17.2292 + var startChar = line.charAt(start);
17.2293 + var check = isWordChar(startChar) ? isWordChar :
17.2294 + /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} :
17.2295 + function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
17.2296 + while (start > 0 && check(line.charAt(start - 1))) --start;
17.2297 + while (end < line.length && check(line.charAt(end))) ++end;
17.2298 + }
17.2299 + return {from: {line: pos.line, ch: start}, to: {line: pos.line, ch: end}};
17.2300 + }
17.2301 +
17.2302 + function selectLine(cm, line) {
17.2303 + extendSelection(cm, {line: line, ch: 0}, clipPos(cm.view.doc, {line: line + 1, ch: 0}));
17.2304 + }
17.2305 +
17.2306 + // PROTOTYPE
17.2307 +
17.2308 + // The publicly visible API. Note that operation(null, f) means
17.2309 + // 'wrap f in an operation, performed on its `this` parameter'
17.2310 +
17.2311 + CodeMirror.prototype = {
17.2312 + getValue: function(lineSep) {
17.2313 + var text = [], doc = this.view.doc;
17.2314 + doc.iter(0, doc.size, function(line) { text.push(line.text); });
17.2315 + return text.join(lineSep || "\n");
17.2316 + },
17.2317 +
17.2318 + setValue: operation(null, function(code) {
17.2319 + var doc = this.view.doc, top = {line: 0, ch: 0}, lastLen = getLine(doc, doc.size-1).text.length;
17.2320 + updateDocInner(this, top, {line: doc.size - 1, ch: lastLen}, splitLines(code), top, top, "setValue");
17.2321 + }),
17.2322 +
17.2323 + getSelection: function(lineSep) { return this.getRange(this.view.sel.from, this.view.sel.to, lineSep); },
17.2324 +
17.2325 + replaceSelection: operation(null, function(code, collapse, origin) {
17.2326 + var sel = this.view.sel;
17.2327 + updateDoc(this, sel.from, sel.to, splitLines(code), collapse || "around", origin);
17.2328 + }),
17.2329 +
17.2330 + focus: function(){window.focus(); focusInput(this); onFocus(this); fastPoll(this);},
17.2331 +
17.2332 + setOption: function(option, value) {
17.2333 + var options = this.options, old = options[option];
17.2334 + if (options[option] == value && option != "mode") return;
17.2335 + options[option] = value;
17.2336 + if (optionHandlers.hasOwnProperty(option))
17.2337 + operation(this, optionHandlers[option])(this, value, old);
17.2338 + },
17.2339 +
17.2340 + getOption: function(option) {return this.options[option];},
17.2341 +
17.2342 + getMode: function() {return this.view.mode;},
17.2343 +
17.2344 + addKeyMap: function(map) {
17.2345 + this.view.keyMaps.push(map);
17.2346 + },
17.2347 +
17.2348 + removeKeyMap: function(map) {
17.2349 + var maps = this.view.keyMaps;
17.2350 + for (var i = 0; i < maps.length; ++i)
17.2351 + if ((typeof map == "string" ? maps[i].name : maps[i]) == map) {
17.2352 + maps.splice(i, 1);
17.2353 + return true;
17.2354 + }
17.2355 + },
17.2356 +
17.2357 + undo: operation(null, function() {unredoHelper(this, "undo");}),
17.2358 + redo: operation(null, function() {unredoHelper(this, "redo");}),
17.2359 +
17.2360 + indentLine: operation(null, function(n, dir, aggressive) {
17.2361 + if (typeof dir != "string") {
17.2362 + if (dir == null) dir = this.options.smartIndent ? "smart" : "prev";
17.2363 + else dir = dir ? "add" : "subtract";
17.2364 + }
17.2365 + if (isLine(this.view.doc, n)) indentLine(this, n, dir, aggressive);
17.2366 + }),
17.2367 +
17.2368 + indentSelection: operation(null, function(how) {
17.2369 + var sel = this.view.sel;
17.2370 + if (posEq(sel.from, sel.to)) return indentLine(this, sel.from.line, how);
17.2371 + var e = sel.to.line - (sel.to.ch ? 0 : 1);
17.2372 + for (var i = sel.from.line; i <= e; ++i) indentLine(this, i, how);
17.2373 + }),
17.2374 +
17.2375 + historySize: function() {
17.2376 + var hist = this.view.history;
17.2377 + return {undo: hist.done.length, redo: hist.undone.length};
17.2378 + },
17.2379 +
17.2380 + clearHistory: function() {this.view.history = makeHistory();},
17.2381 +
17.2382 + markClean: function() {
17.2383 + this.view.history.dirtyCounter = 0;
17.2384 + this.view.history.lastOp = this.view.history.lastOrigin = null;
17.2385 + },
17.2386 +
17.2387 + isClean: function () {return this.view.history.dirtyCounter == 0;},
17.2388 +
17.2389 + getHistory: function() {
17.2390 + var hist = this.view.history;
17.2391 + function cp(arr) {
17.2392 + for (var i = 0, nw = [], nwelt; i < arr.length; ++i) {
17.2393 + var set = arr[i];
17.2394 + nw.push({events: nwelt = [], fromBefore: set.fromBefore, toBefore: set.toBefore,
17.2395 + fromAfter: set.fromAfter, toAfter: set.toAfter});
17.2396 + for (var j = 0, elt = set.events; j < elt.length; ++j) {
17.2397 + var old = [], cur = elt[j];
17.2398 + nwelt.push({start: cur.start, added: cur.added, old: old});
17.2399 + for (var k = 0; k < cur.old.length; ++k) old.push(hlText(cur.old[k]));
17.2400 + }
17.2401 + }
17.2402 + return nw;
17.2403 + }
17.2404 + return {done: cp(hist.done), undone: cp(hist.undone)};
17.2405 + },
17.2406 +
17.2407 + setHistory: function(histData) {
17.2408 + var hist = this.view.history = makeHistory();
17.2409 + hist.done = histData.done;
17.2410 + hist.undone = histData.undone;
17.2411 + },
17.2412 +
17.2413 + // Fetch the parser token for a given character. Useful for hacks
17.2414 + // that want to inspect the mode state (say, for completion).
17.2415 + getTokenAt: function(pos) {
17.2416 + var doc = this.view.doc;
17.2417 + pos = clipPos(doc, pos);
17.2418 + var state = getStateBefore(this, pos.line), mode = this.view.mode;
17.2419 + var line = getLine(doc, pos.line);
17.2420 + var stream = new StringStream(line.text, this.options.tabSize);
17.2421 + while (stream.pos < pos.ch && !stream.eol()) {
17.2422 + stream.start = stream.pos;
17.2423 + var style = mode.token(stream, state);
17.2424 + }
17.2425 + return {start: stream.start,
17.2426 + end: stream.pos,
17.2427 + string: stream.current(),
17.2428 + className: style || null, // Deprecated, use 'type' instead
17.2429 + type: style || null,
17.2430 + state: state};
17.2431 + },
17.2432 +
17.2433 + getStateAfter: function(line) {
17.2434 + var doc = this.view.doc;
17.2435 + line = clipLine(doc, line == null ? doc.size - 1: line);
17.2436 + return getStateBefore(this, line + 1);
17.2437 + },
17.2438 +
17.2439 + cursorCoords: function(start, mode) {
17.2440 + var pos, sel = this.view.sel;
17.2441 + if (start == null) pos = sel.head;
17.2442 + else if (typeof start == "object") pos = clipPos(this.view.doc, start);
17.2443 + else pos = start ? sel.from : sel.to;
17.2444 + return cursorCoords(this, pos, mode || "page");
17.2445 + },
17.2446 +
17.2447 + charCoords: function(pos, mode) {
17.2448 + return charCoords(this, clipPos(this.view.doc, pos), mode || "page");
17.2449 + },
17.2450 +
17.2451 + coordsChar: function(coords) {
17.2452 + var off = this.display.lineSpace.getBoundingClientRect();
17.2453 + return coordsChar(this, coords.left - off.left, coords.top - off.top);
17.2454 + },
17.2455 +
17.2456 + defaultTextHeight: function() { return textHeight(this.display); },
17.2457 +
17.2458 + markText: operation(null, function(from, to, options) {
17.2459 + return markText(this, clipPos(this.view.doc, from), clipPos(this.view.doc, to),
17.2460 + options, "range");
17.2461 + }),
17.2462 +
17.2463 + setBookmark: operation(null, function(pos, widget) {
17.2464 + pos = clipPos(this.view.doc, pos);
17.2465 + return markText(this, pos, pos, widget ? {replacedWith: widget} : {}, "bookmark");
17.2466 + }),
17.2467 +
17.2468 + findMarksAt: function(pos) {
17.2469 + var doc = this.view.doc;
17.2470 + pos = clipPos(doc, pos);
17.2471 + var markers = [], spans = getLine(doc, pos.line).markedSpans;
17.2472 + if (spans) for (var i = 0; i < spans.length; ++i) {
17.2473 + var span = spans[i];
17.2474 + if ((span.from == null || span.from <= pos.ch) &&
17.2475 + (span.to == null || span.to >= pos.ch))
17.2476 + markers.push(span.marker);
17.2477 + }
17.2478 + return markers;
17.2479 + },
17.2480 +
17.2481 + setGutterMarker: operation(null, function(line, gutterID, value) {
17.2482 + return changeLine(this, line, function(line) {
17.2483 + var markers = line.gutterMarkers || (line.gutterMarkers = {});
17.2484 + markers[gutterID] = value;
17.2485 + if (!value && isEmpty(markers)) line.gutterMarkers = null;
17.2486 + return true;
17.2487 + });
17.2488 + }),
17.2489 +
17.2490 + clearGutter: operation(null, function(gutterID) {
17.2491 + var i = 0, cm = this, doc = cm.view.doc;
17.2492 + doc.iter(0, doc.size, function(line) {
17.2493 + if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
17.2494 + line.gutterMarkers[gutterID] = null;
17.2495 + regChange(cm, i, i + 1);
17.2496 + if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null;
17.2497 + }
17.2498 + ++i;
17.2499 + });
17.2500 + }),
17.2501 +
17.2502 + addLineClass: operation(null, function(handle, where, cls) {
17.2503 + return changeLine(this, handle, function(line) {
17.2504 + var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass";
17.2505 + if (!line[prop]) line[prop] = cls;
17.2506 + else if (new RegExp("\\b" + cls + "\\b").test(line[prop])) return false;
17.2507 + else line[prop] += " " + cls;
17.2508 + return true;
17.2509 + });
17.2510 + }),
17.2511 +
17.2512 + removeLineClass: operation(null, function(handle, where, cls) {
17.2513 + return changeLine(this, handle, function(line) {
17.2514 + var prop = where == "text" ? "textClass" : where == "background" ? "bgClass" : "wrapClass";
17.2515 + var cur = line[prop];
17.2516 + if (!cur) return false;
17.2517 + else if (cls == null) line[prop] = null;
17.2518 + else {
17.2519 + var upd = cur.replace(new RegExp("^" + cls + "\\b\\s*|\\s*\\b" + cls + "\\b"), "");
17.2520 + if (upd == cur) return false;
17.2521 + line[prop] = upd || null;
17.2522 + }
17.2523 + return true;
17.2524 + });
17.2525 + }),
17.2526 +
17.2527 + addLineWidget: operation(null, function(handle, node, options) {
17.2528 + var widget = options || {};
17.2529 + widget.node = node;
17.2530 + if (widget.noHScroll) this.display.alignWidgets = true;
17.2531 + changeLine(this, handle, function(line) {
17.2532 + (line.widgets || (line.widgets = [])).push(widget);
17.2533 + widget.line = line;
17.2534 + return true;
17.2535 + });
17.2536 + return widget;
17.2537 + }),
17.2538 +
17.2539 + removeLineWidget: operation(null, function(widget) {
17.2540 + var ws = widget.line.widgets, no = lineNo(widget.line);
17.2541 + if (no == null) return;
17.2542 + for (var i = 0; i < ws.length; ++i) if (ws[i] == widget) ws.splice(i--, 1);
17.2543 + regChange(this, no, no + 1);
17.2544 + }),
17.2545 +
17.2546 + lineInfo: function(line) {
17.2547 + if (typeof line == "number") {
17.2548 + if (!isLine(this.view.doc, line)) return null;
17.2549 + var n = line;
17.2550 + line = getLine(this.view.doc, line);
17.2551 + if (!line) return null;
17.2552 + } else {
17.2553 + var n = lineNo(line);
17.2554 + if (n == null) return null;
17.2555 + }
17.2556 + return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
17.2557 + textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
17.2558 + widgets: line.widgets};
17.2559 + },
17.2560 +
17.2561 + getViewport: function() { return {from: this.display.showingFrom, to: this.display.showingTo};},
17.2562 +
17.2563 + addWidget: function(pos, node, scroll, vert, horiz) {
17.2564 + var display = this.display;
17.2565 + pos = cursorCoords(this, clipPos(this.view.doc, pos));
17.2566 + var top = pos.top, left = pos.left;
17.2567 + node.style.position = "absolute";
17.2568 + display.sizer.appendChild(node);
17.2569 + if (vert == "over") top = pos.top;
17.2570 + else if (vert == "near") {
17.2571 + var vspace = Math.max(display.wrapper.clientHeight, this.view.doc.height),
17.2572 + hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
17.2573 + if (pos.bottom + node.offsetHeight > vspace && pos.top > node.offsetHeight)
17.2574 + top = pos.top - node.offsetHeight;
17.2575 + if (left + node.offsetWidth > hspace)
17.2576 + left = hspace - node.offsetWidth;
17.2577 + }
17.2578 + node.style.top = (top + paddingTop(display)) + "px";
17.2579 + node.style.left = node.style.right = "";
17.2580 + if (horiz == "right") {
17.2581 + left = display.sizer.clientWidth - node.offsetWidth;
17.2582 + node.style.right = "0px";
17.2583 + } else {
17.2584 + if (horiz == "left") left = 0;
17.2585 + else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2;
17.2586 + node.style.left = left + "px";
17.2587 + }
17.2588 + if (scroll)
17.2589 + scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight);
17.2590 + },
17.2591 +
17.2592 + lineCount: function() {return this.view.doc.size;},
17.2593 +
17.2594 + clipPos: function(pos) {return clipPos(this.view.doc, pos);},
17.2595 +
17.2596 + getCursor: function(start) {
17.2597 + var sel = this.view.sel, pos;
17.2598 + if (start == null || start == "head") pos = sel.head;
17.2599 + else if (start == "anchor") pos = sel.anchor;
17.2600 + else if (start == "end" || start === false) pos = sel.to;
17.2601 + else pos = sel.from;
17.2602 + return copyPos(pos);
17.2603 + },
17.2604 +
17.2605 + somethingSelected: function() {return !posEq(this.view.sel.from, this.view.sel.to);},
17.2606 +
17.2607 + setCursor: operation(null, function(line, ch, extend) {
17.2608 + var pos = clipPos(this.view.doc, typeof line == "number" ? {line: line, ch: ch || 0} : line);
17.2609 + if (extend) extendSelection(this, pos);
17.2610 + else setSelection(this, pos, pos);
17.2611 + }),
17.2612 +
17.2613 + setSelection: operation(null, function(anchor, head) {
17.2614 + var doc = this.view.doc;
17.2615 + setSelection(this, clipPos(doc, anchor), clipPos(doc, head || anchor));
17.2616 + }),
17.2617 +
17.2618 + extendSelection: operation(null, function(from, to) {
17.2619 + var doc = this.view.doc;
17.2620 + extendSelection(this, clipPos(doc, from), to && clipPos(doc, to));
17.2621 + }),
17.2622 +
17.2623 + setExtending: function(val) {this.view.sel.extend = val;},
17.2624 +
17.2625 + getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
17.2626 +
17.2627 + getLineHandle: function(line) {
17.2628 + var doc = this.view.doc;
17.2629 + if (isLine(doc, line)) return getLine(doc, line);
17.2630 + },
17.2631 +
17.2632 + getLineNumber: function(line) {return lineNo(line);},
17.2633 +
17.2634 + setLine: operation(null, function(line, text) {
17.2635 + if (isLine(this.view.doc, line))
17.2636 + replaceRange(this, text, {line: line, ch: 0}, {line: line, ch: getLine(this.view.doc, line).text.length});
17.2637 + }),
17.2638 +
17.2639 + removeLine: operation(null, function(line) {
17.2640 + if (isLine(this.view.doc, line))
17.2641 + replaceRange(this, "", {line: line, ch: 0}, clipPos(this.view.doc, {line: line+1, ch: 0}));
17.2642 + }),
17.2643 +
17.2644 + replaceRange: operation(null, function(code, from, to) {
17.2645 + var doc = this.view.doc;
17.2646 + from = clipPos(doc, from);
17.2647 + to = to ? clipPos(doc, to) : from;
17.2648 + return replaceRange(this, code, from, to);
17.2649 + }),
17.2650 +
17.2651 + getRange: function(from, to, lineSep) {
17.2652 + var doc = this.view.doc;
17.2653 + from = clipPos(doc, from); to = clipPos(doc, to);
17.2654 + var l1 = from.line, l2 = to.line;
17.2655 + if (l1 == l2) return getLine(doc, l1).text.slice(from.ch, to.ch);
17.2656 + var code = [getLine(doc, l1).text.slice(from.ch)];
17.2657 + doc.iter(l1 + 1, l2, function(line) { code.push(line.text); });
17.2658 + code.push(getLine(doc, l2).text.slice(0, to.ch));
17.2659 + return code.join(lineSep || "\n");
17.2660 + },
17.2661 +
17.2662 + triggerOnKeyDown: operation(null, onKeyDown),
17.2663 +
17.2664 + execCommand: function(cmd) {return commands[cmd](this);},
17.2665 +
17.2666 + // Stuff used by commands, probably not much use to outside code.
17.2667 + moveH: operation(null, function(dir, unit) {
17.2668 + var sel = this.view.sel, pos = dir < 0 ? sel.from : sel.to;
17.2669 + if (sel.shift || sel.extend || posEq(sel.from, sel.to)) pos = findPosH(this, dir, unit, true);
17.2670 + extendSelection(this, pos, pos, dir);
17.2671 + }),
17.2672 +
17.2673 + deleteH: operation(null, function(dir, unit) {
17.2674 + var sel = this.view.sel;
17.2675 + if (!posEq(sel.from, sel.to)) replaceRange(this, "", sel.from, sel.to, "delete");
17.2676 + else replaceRange(this, "", sel.from, findPosH(this, dir, unit, false), "delete");
17.2677 + this.curOp.userSelChange = true;
17.2678 + }),
17.2679 +
17.2680 + moveV: operation(null, function(dir, unit) {
17.2681 + var view = this.view, doc = view.doc, display = this.display;
17.2682 + var cur = view.sel.head, pos = cursorCoords(this, cur, "div");
17.2683 + var x = pos.left, y;
17.2684 + if (view.goalColumn != null) x = view.goalColumn;
17.2685 + if (unit == "page") {
17.2686 + var pageSize = Math.min(display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
17.2687 + y = pos.top + dir * pageSize;
17.2688 + } else if (unit == "line") {
17.2689 + y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
17.2690 + }
17.2691 + do {
17.2692 + var target = coordsChar(this, x, y);
17.2693 + y += dir * 5;
17.2694 + } while (target.outside && (dir < 0 ? y > 0 : y < doc.height));
17.2695 +
17.2696 + if (unit == "page") display.scrollbarV.scrollTop += charCoords(this, target, "div").top - pos.top;
17.2697 + extendSelection(this, target, target, dir);
17.2698 + view.goalColumn = x;
17.2699 + }),
17.2700 +
17.2701 + toggleOverwrite: function() {
17.2702 + if (this.view.overwrite = !this.view.overwrite)
17.2703 + this.display.cursor.className += " CodeMirror-overwrite";
17.2704 + else
17.2705 + this.display.cursor.className = this.display.cursor.className.replace(" CodeMirror-overwrite", "");
17.2706 + },
17.2707 +
17.2708 + posFromIndex: function(off) {
17.2709 + var lineNo = 0, ch, doc = this.view.doc;
17.2710 + doc.iter(0, doc.size, function(line) {
17.2711 + var sz = line.text.length + 1;
17.2712 + if (sz > off) { ch = off; return true; }
17.2713 + off -= sz;
17.2714 + ++lineNo;
17.2715 + });
17.2716 + return clipPos(doc, {line: lineNo, ch: ch});
17.2717 + },
17.2718 + indexFromPos: function (coords) {
17.2719 + if (coords.line < 0 || coords.ch < 0) return 0;
17.2720 + var index = coords.ch;
17.2721 + this.view.doc.iter(0, coords.line, function (line) {
17.2722 + index += line.text.length + 1;
17.2723 + });
17.2724 + return index;
17.2725 + },
17.2726 +
17.2727 + scrollTo: function(x, y) {
17.2728 + if (x != null) this.display.scrollbarH.scrollLeft = this.display.scroller.scrollLeft = x;
17.2729 + if (y != null) this.display.scrollbarV.scrollTop = this.display.scroller.scrollTop = y;
17.2730 + updateDisplay(this, []);
17.2731 + },
17.2732 + getScrollInfo: function() {
17.2733 + var scroller = this.display.scroller, co = scrollerCutOff;
17.2734 + return {left: scroller.scrollLeft, top: scroller.scrollTop,
17.2735 + height: scroller.scrollHeight - co, width: scroller.scrollWidth - co,
17.2736 + clientHeight: scroller.clientHeight - co, clientWidth: scroller.clientWidth - co};
17.2737 + },
17.2738 +
17.2739 + scrollIntoView: function(pos) {
17.2740 + if (typeof pos == "number") pos = {line: pos, ch: 0};
17.2741 + pos = pos ? clipPos(this.view.doc, pos) : this.view.sel.head;
17.2742 + scrollPosIntoView(this, pos);
17.2743 + },
17.2744 +
17.2745 + setSize: function(width, height) {
17.2746 + function interpret(val) {
17.2747 + return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
17.2748 + }
17.2749 + if (width != null) this.display.wrapper.style.width = interpret(width);
17.2750 + if (height != null) this.display.wrapper.style.height = interpret(height);
17.2751 + this.refresh();
17.2752 + },
17.2753 +
17.2754 + on: function(type, f) {on(this, type, f);},
17.2755 + off: function(type, f) {off(this, type, f);},
17.2756 +
17.2757 + operation: function(f){return operation(this, f)();},
17.2758 +
17.2759 + refresh: function() {
17.2760 + clearCaches(this);
17.2761 + if (this.display.scroller.scrollHeight > this.view.scrollTop)
17.2762 + this.display.scrollbarV.scrollTop = this.display.scroller.scrollTop = this.view.scrollTop;
17.2763 + updateDisplay(this, true);
17.2764 + },
17.2765 +
17.2766 + getInputField: function(){return this.display.input;},
17.2767 + getWrapperElement: function(){return this.display.wrapper;},
17.2768 + getScrollerElement: function(){return this.display.scroller;},
17.2769 + getGutterElement: function(){return this.display.gutters;}
17.2770 + };
17.2771 +
17.2772 + // OPTION DEFAULTS
17.2773 +
17.2774 + var optionHandlers = CodeMirror.optionHandlers = {};
17.2775 +
17.2776 + // The default configuration options.
17.2777 + var defaults = CodeMirror.defaults = {};
17.2778 +
17.2779 + function option(name, deflt, handle, notOnInit) {
17.2780 + CodeMirror.defaults[name] = deflt;
17.2781 + if (handle) optionHandlers[name] =
17.2782 + notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle;
17.2783 + }
17.2784 +
17.2785 + var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}};
17.2786 +
17.2787 + // These two are, on init, called from the constructor because they
17.2788 + // have to be initialized before the editor can start at all.
17.2789 + option("value", "", function(cm, val) {cm.setValue(val);}, true);
17.2790 + option("mode", null, loadMode, true);
17.2791 +
17.2792 + option("indentUnit", 2, loadMode, true);
17.2793 + option("indentWithTabs", false);
17.2794 + option("smartIndent", true);
17.2795 + option("tabSize", 4, function(cm) {
17.2796 + loadMode(cm);
17.2797 + clearCaches(cm);
17.2798 + updateDisplay(cm, true);
17.2799 + }, true);
17.2800 + option("electricChars", true);
17.2801 +
17.2802 + option("theme", "default", function(cm) {
17.2803 + themeChanged(cm);
17.2804 + guttersChanged(cm);
17.2805 + }, true);
17.2806 + option("keyMap", "default", keyMapChanged);
17.2807 + option("extraKeys", null);
17.2808 +
17.2809 + option("onKeyEvent", null);
17.2810 + option("onDragEvent", null);
17.2811 +
17.2812 + option("lineWrapping", false, wrappingChanged, true);
17.2813 + option("gutters", [], function(cm) {
17.2814 + setGuttersForLineNumbers(cm.options);
17.2815 + guttersChanged(cm);
17.2816 + }, true);
17.2817 + option("lineNumbers", false, function(cm) {
17.2818 + setGuttersForLineNumbers(cm.options);
17.2819 + guttersChanged(cm);
17.2820 + }, true);
17.2821 + option("firstLineNumber", 1, guttersChanged, true);
17.2822 + option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true);
17.2823 + option("showCursorWhenSelecting", false, updateSelection, true);
17.2824 +
17.2825 + option("readOnly", false, function(cm, val) {
17.2826 + if (val == "nocursor") {onBlur(cm); cm.display.input.blur();}
17.2827 + else if (!val) resetInput(cm, true);
17.2828 + });
17.2829 + option("dragDrop", true);
17.2830 +
17.2831 + option("cursorBlinkRate", 530);
17.2832 + option("cursorHeight", 1);
17.2833 + option("workTime", 100);
17.2834 + option("workDelay", 100);
17.2835 + option("flattenSpans", true);
17.2836 + option("pollInterval", 100);
17.2837 + option("undoDepth", 40);
17.2838 + option("viewportMargin", 10, function(cm){cm.refresh();}, true);
17.2839 +
17.2840 + option("tabindex", null, function(cm, val) {
17.2841 + cm.display.input.tabIndex = val || "";
17.2842 + });
17.2843 + option("autofocus", null);
17.2844 +
17.2845 + // MODE DEFINITION AND QUERYING
17.2846 +
17.2847 + // Known modes, by name and by MIME
17.2848 + var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
17.2849 +
17.2850 + CodeMirror.defineMode = function(name, mode) {
17.2851 + if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
17.2852 + if (arguments.length > 2) {
17.2853 + mode.dependencies = [];
17.2854 + for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]);
17.2855 + }
17.2856 + modes[name] = mode;
17.2857 + };
17.2858 +
17.2859 + CodeMirror.defineMIME = function(mime, spec) {
17.2860 + mimeModes[mime] = spec;
17.2861 + };
17.2862 +
17.2863 + CodeMirror.resolveMode = function(spec) {
17.2864 + if (typeof spec == "string" && mimeModes.hasOwnProperty(spec))
17.2865 + spec = mimeModes[spec];
17.2866 + else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec))
17.2867 + return CodeMirror.resolveMode("application/xml");
17.2868 + if (typeof spec == "string") return {name: spec};
17.2869 + else return spec || {name: "null"};
17.2870 + };
17.2871 +
17.2872 + CodeMirror.getMode = function(options, spec) {
17.2873 + var spec = CodeMirror.resolveMode(spec);
17.2874 + var mfactory = modes[spec.name];
17.2875 + if (!mfactory) return CodeMirror.getMode(options, "text/plain");
17.2876 + var modeObj = mfactory(options, spec);
17.2877 + if (modeExtensions.hasOwnProperty(spec.name)) {
17.2878 + var exts = modeExtensions[spec.name];
17.2879 + for (var prop in exts) {
17.2880 + if (!exts.hasOwnProperty(prop)) continue;
17.2881 + if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
17.2882 + modeObj[prop] = exts[prop];
17.2883 + }
17.2884 + }
17.2885 + modeObj.name = spec.name;
17.2886 + return modeObj;
17.2887 + };
17.2888 +
17.2889 + CodeMirror.defineMode("null", function() {
17.2890 + return {token: function(stream) {stream.skipToEnd();}};
17.2891 + });
17.2892 + CodeMirror.defineMIME("text/plain", "null");
17.2893 +
17.2894 + var modeExtensions = CodeMirror.modeExtensions = {};
17.2895 + CodeMirror.extendMode = function(mode, properties) {
17.2896 + var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
17.2897 + for (var prop in properties) if (properties.hasOwnProperty(prop))
17.2898 + exts[prop] = properties[prop];
17.2899 + };
17.2900 +
17.2901 + // EXTENSIONS
17.2902 +
17.2903 + CodeMirror.defineExtension = function(name, func) {
17.2904 + CodeMirror.prototype[name] = func;
17.2905 + };
17.2906 +
17.2907 + CodeMirror.defineOption = option;
17.2908 +
17.2909 + var initHooks = [];
17.2910 + CodeMirror.defineInitHook = function(f) {initHooks.push(f);};
17.2911 +
17.2912 + // MODE STATE HANDLING
17.2913 +
17.2914 + // Utility functions for working with state. Exported because modes
17.2915 + // sometimes need to do this.
17.2916 + function copyState(mode, state) {
17.2917 + if (state === true) return state;
17.2918 + if (mode.copyState) return mode.copyState(state);
17.2919 + var nstate = {};
17.2920 + for (var n in state) {
17.2921 + var val = state[n];
17.2922 + if (val instanceof Array) val = val.concat([]);
17.2923 + nstate[n] = val;
17.2924 + }
17.2925 + return nstate;
17.2926 + }
17.2927 + CodeMirror.copyState = copyState;
17.2928 +
17.2929 + function startState(mode, a1, a2) {
17.2930 + return mode.startState ? mode.startState(a1, a2) : true;
17.2931 + }
17.2932 + CodeMirror.startState = startState;
17.2933 +
17.2934 + CodeMirror.innerMode = function(mode, state) {
17.2935 + while (mode.innerMode) {
17.2936 + var info = mode.innerMode(state);
17.2937 + state = info.state;
17.2938 + mode = info.mode;
17.2939 + }
17.2940 + return info || {mode: mode, state: state};
17.2941 + };
17.2942 +
17.2943 + // STANDARD COMMANDS
17.2944 +
17.2945 + var commands = CodeMirror.commands = {
17.2946 + selectAll: function(cm) {cm.setSelection({line: 0, ch: 0}, {line: cm.lineCount() - 1});},
17.2947 + killLine: function(cm) {
17.2948 + var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to);
17.2949 + if (!sel && cm.getLine(from.line).length == from.ch)
17.2950 + cm.replaceRange("", from, {line: from.line + 1, ch: 0}, "delete");
17.2951 + else cm.replaceRange("", from, sel ? to : {line: from.line}, "delete");
17.2952 + },
17.2953 + deleteLine: function(cm) {
17.2954 + var l = cm.getCursor().line;
17.2955 + cm.replaceRange("", {line: l, ch: 0}, {line: l}, "delete");
17.2956 + },
17.2957 + undo: function(cm) {cm.undo();},
17.2958 + redo: function(cm) {cm.redo();},
17.2959 + goDocStart: function(cm) {cm.extendSelection({line: 0, ch: 0});},
17.2960 + goDocEnd: function(cm) {cm.extendSelection({line: cm.lineCount() - 1});},
17.2961 + goLineStart: function(cm) {
17.2962 + cm.extendSelection(lineStart(cm, cm.getCursor().line));
17.2963 + },
17.2964 + goLineStartSmart: function(cm) {
17.2965 + var cur = cm.getCursor(), start = lineStart(cm, cur.line);
17.2966 + var line = cm.getLineHandle(start.line);
17.2967 + var order = getOrder(line);
17.2968 + if (!order || order[0].level == 0) {
17.2969 + var firstNonWS = Math.max(0, line.text.search(/\S/));
17.2970 + var inWS = cur.line == start.line && cur.ch <= firstNonWS && cur.ch;
17.2971 + cm.extendSelection({line: start.line, ch: inWS ? 0 : firstNonWS});
17.2972 + } else cm.extendSelection(start);
17.2973 + },
17.2974 + goLineEnd: function(cm) {
17.2975 + cm.extendSelection(lineEnd(cm, cm.getCursor().line));
17.2976 + },
17.2977 + goLineUp: function(cm) {cm.moveV(-1, "line");},
17.2978 + goLineDown: function(cm) {cm.moveV(1, "line");},
17.2979 + goPageUp: function(cm) {cm.moveV(-1, "page");},
17.2980 + goPageDown: function(cm) {cm.moveV(1, "page");},
17.2981 + goCharLeft: function(cm) {cm.moveH(-1, "char");},
17.2982 + goCharRight: function(cm) {cm.moveH(1, "char");},
17.2983 + goColumnLeft: function(cm) {cm.moveH(-1, "column");},
17.2984 + goColumnRight: function(cm) {cm.moveH(1, "column");},
17.2985 + goWordLeft: function(cm) {cm.moveH(-1, "word");},
17.2986 + goWordRight: function(cm) {cm.moveH(1, "word");},
17.2987 + delCharBefore: function(cm) {cm.deleteH(-1, "char");},
17.2988 + delCharAfter: function(cm) {cm.deleteH(1, "char");},
17.2989 + delWordBefore: function(cm) {cm.deleteH(-1, "word");},
17.2990 + delWordAfter: function(cm) {cm.deleteH(1, "word");},
17.2991 + indentAuto: function(cm) {cm.indentSelection("smart");},
17.2992 + indentMore: function(cm) {cm.indentSelection("add");},
17.2993 + indentLess: function(cm) {cm.indentSelection("subtract");},
17.2994 + insertTab: function(cm) {cm.replaceSelection("\t", "end", "input");},
17.2995 + defaultTab: function(cm) {
17.2996 + if (cm.somethingSelected()) cm.indentSelection("add");
17.2997 + else cm.replaceSelection("\t", "end", "input");
17.2998 + },
17.2999 + transposeChars: function(cm) {
17.3000 + var cur = cm.getCursor(), line = cm.getLine(cur.line);
17.3001 + if (cur.ch > 0 && cur.ch < line.length - 1)
17.3002 + cm.replaceRange(line.charAt(cur.ch) + line.charAt(cur.ch - 1),
17.3003 + {line: cur.line, ch: cur.ch - 1}, {line: cur.line, ch: cur.ch + 1});
17.3004 + },
17.3005 + newlineAndIndent: function(cm) {
17.3006 + operation(cm, function() {
17.3007 + cm.replaceSelection("\n", "end", "input");
17.3008 + cm.indentLine(cm.getCursor().line, null, true);
17.3009 + })();
17.3010 + },
17.3011 + toggleOverwrite: function(cm) {cm.toggleOverwrite();}
17.3012 + };
17.3013 +
17.3014 + // STANDARD KEYMAPS
17.3015 +
17.3016 + var keyMap = CodeMirror.keyMap = {};
17.3017 + keyMap.basic = {
17.3018 + "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
17.3019 + "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
17.3020 + "Delete": "delCharAfter", "Backspace": "delCharBefore", "Tab": "defaultTab", "Shift-Tab": "indentAuto",
17.3021 + "Enter": "newlineAndIndent", "Insert": "toggleOverwrite"
17.3022 + };
17.3023 + // Note that the save and find-related commands aren't defined by
17.3024 + // default. Unknown commands are simply ignored.
17.3025 + keyMap.pcDefault = {
17.3026 + "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
17.3027 + "Ctrl-Home": "goDocStart", "Alt-Up": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Down": "goDocEnd",
17.3028 + "Ctrl-Left": "goWordLeft", "Ctrl-Right": "goWordRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
17.3029 + "Ctrl-Backspace": "delWordBefore", "Ctrl-Delete": "delWordAfter", "Ctrl-S": "save", "Ctrl-F": "find",
17.3030 + "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
17.3031 + "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
17.3032 + fallthrough: "basic"
17.3033 + };
17.3034 + keyMap.macDefault = {
17.3035 + "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
17.3036 + "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goWordLeft",
17.3037 + "Alt-Right": "goWordRight", "Cmd-Left": "goLineStart", "Cmd-Right": "goLineEnd", "Alt-Backspace": "delWordBefore",
17.3038 + "Ctrl-Alt-Backspace": "delWordAfter", "Alt-Delete": "delWordAfter", "Cmd-S": "save", "Cmd-F": "find",
17.3039 + "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
17.3040 + "Cmd-[": "indentLess", "Cmd-]": "indentMore",
17.3041 + fallthrough: ["basic", "emacsy"]
17.3042 + };
17.3043 + keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
17.3044 + keyMap.emacsy = {
17.3045 + "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
17.3046 + "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
17.3047 + "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
17.3048 + "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
17.3049 + };
17.3050 +
17.3051 + // KEYMAP DISPATCH
17.3052 +
17.3053 + function getKeyMap(val) {
17.3054 + if (typeof val == "string") return keyMap[val];
17.3055 + else return val;
17.3056 + }
17.3057 +
17.3058 + function lookupKey(name, maps, handle, stop) {
17.3059 + function lookup(map) {
17.3060 + map = getKeyMap(map);
17.3061 + var found = map[name];
17.3062 + if (found === false) {
17.3063 + if (stop) stop();
17.3064 + return true;
17.3065 + }
17.3066 + if (found != null && handle(found)) return true;
17.3067 + if (map.nofallthrough) {
17.3068 + if (stop) stop();
17.3069 + return true;
17.3070 + }
17.3071 + var fallthrough = map.fallthrough;
17.3072 + if (fallthrough == null) return false;
17.3073 + if (Object.prototype.toString.call(fallthrough) != "[object Array]")
17.3074 + return lookup(fallthrough);
17.3075 + for (var i = 0, e = fallthrough.length; i < e; ++i) {
17.3076 + if (lookup(fallthrough[i])) return true;
17.3077 + }
17.3078 + return false;
17.3079 + }
17.3080 +
17.3081 + for (var i = 0; i < maps.length; ++i)
17.3082 + if (lookup(maps[i])) return true;
17.3083 + }
17.3084 + function isModifierKey(event) {
17.3085 + var name = keyNames[e_prop(event, "keyCode")];
17.3086 + return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
17.3087 + }
17.3088 + CodeMirror.isModifierKey = isModifierKey;
17.3089 +
17.3090 + // FROMTEXTAREA
17.3091 +
17.3092 + CodeMirror.fromTextArea = function(textarea, options) {
17.3093 + if (!options) options = {};
17.3094 + options.value = textarea.value;
17.3095 + if (!options.tabindex && textarea.tabindex)
17.3096 + options.tabindex = textarea.tabindex;
17.3097 + // Set autofocus to true if this textarea is focused, or if it has
17.3098 + // autofocus and no other element is focused.
17.3099 + if (options.autofocus == null) {
17.3100 + var hasFocus = document.body;
17.3101 + // doc.activeElement occasionally throws on IE
17.3102 + try { hasFocus = document.activeElement; } catch(e) {}
17.3103 + options.autofocus = hasFocus == textarea ||
17.3104 + textarea.getAttribute("autofocus") != null && hasFocus == document.body;
17.3105 + }
17.3106 +
17.3107 + function save() {textarea.value = cm.getValue();}
17.3108 + if (textarea.form) {
17.3109 + // Deplorable hack to make the submit method do the right thing.
17.3110 + on(textarea.form, "submit", save);
17.3111 + var form = textarea.form, realSubmit = form.submit;
17.3112 + try {
17.3113 + form.submit = function wrappedSubmit() {
17.3114 + save();
17.3115 + form.submit = realSubmit;
17.3116 + form.submit();
17.3117 + form.submit = wrappedSubmit;
17.3118 + };
17.3119 + } catch(e) {}
17.3120 + }
17.3121 +
17.3122 + textarea.style.display = "none";
17.3123 + var cm = CodeMirror(function(node) {
17.3124 + textarea.parentNode.insertBefore(node, textarea.nextSibling);
17.3125 + }, options);
17.3126 + cm.save = save;
17.3127 + cm.getTextArea = function() { return textarea; };
17.3128 + cm.toTextArea = function() {
17.3129 + save();
17.3130 + textarea.parentNode.removeChild(cm.getWrapperElement());
17.3131 + textarea.style.display = "";
17.3132 + if (textarea.form) {
17.3133 + off(textarea.form, "submit", save);
17.3134 + if (typeof textarea.form.submit == "function")
17.3135 + textarea.form.submit = realSubmit;
17.3136 + }
17.3137 + };
17.3138 + return cm;
17.3139 + };
17.3140 +
17.3141 + // STRING STREAM
17.3142 +
17.3143 + // Fed to the mode parsers, provides helper functions to make
17.3144 + // parsers more succinct.
17.3145 +
17.3146 + // The character stream used by a mode's parser.
17.3147 + function StringStream(string, tabSize) {
17.3148 + this.pos = this.start = 0;
17.3149 + this.string = string;
17.3150 + this.tabSize = tabSize || 8;
17.3151 + }
17.3152 +
17.3153 + StringStream.prototype = {
17.3154 + eol: function() {return this.pos >= this.string.length;},
17.3155 + sol: function() {return this.pos == 0;},
17.3156 + peek: function() {return this.string.charAt(this.pos) || undefined;},
17.3157 + next: function() {
17.3158 + if (this.pos < this.string.length)
17.3159 + return this.string.charAt(this.pos++);
17.3160 + },
17.3161 + eat: function(match) {
17.3162 + var ch = this.string.charAt(this.pos);
17.3163 + if (typeof match == "string") var ok = ch == match;
17.3164 + else var ok = ch && (match.test ? match.test(ch) : match(ch));
17.3165 + if (ok) {++this.pos; return ch;}
17.3166 + },
17.3167 + eatWhile: function(match) {
17.3168 + var start = this.pos;
17.3169 + while (this.eat(match)){}
17.3170 + return this.pos > start;
17.3171 + },
17.3172 + eatSpace: function() {
17.3173 + var start = this.pos;
17.3174 + while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
17.3175 + return this.pos > start;
17.3176 + },
17.3177 + skipToEnd: function() {this.pos = this.string.length;},
17.3178 + skipTo: function(ch) {
17.3179 + var found = this.string.indexOf(ch, this.pos);
17.3180 + if (found > -1) {this.pos = found; return true;}
17.3181 + },
17.3182 + backUp: function(n) {this.pos -= n;},
17.3183 + column: function() {return countColumn(this.string, this.start, this.tabSize);},
17.3184 + indentation: function() {return countColumn(this.string, null, this.tabSize);},
17.3185 + match: function(pattern, consume, caseInsensitive) {
17.3186 + if (typeof pattern == "string") {
17.3187 + var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
17.3188 + if (cased(this.string).indexOf(cased(pattern), this.pos) == this.pos) {
17.3189 + if (consume !== false) this.pos += pattern.length;
17.3190 + return true;
17.3191 + }
17.3192 + } else {
17.3193 + var match = this.string.slice(this.pos).match(pattern);
17.3194 + if (match && match.index > 0) return null;
17.3195 + if (match && consume !== false) this.pos += match[0].length;
17.3196 + return match;
17.3197 + }
17.3198 + },
17.3199 + current: function(){return this.string.slice(this.start, this.pos);}
17.3200 + };
17.3201 + CodeMirror.StringStream = StringStream;
17.3202 +
17.3203 + // TEXTMARKERS
17.3204 +
17.3205 + function TextMarker(cm, type) {
17.3206 + this.lines = [];
17.3207 + this.type = type;
17.3208 + this.cm = cm;
17.3209 + }
17.3210 +
17.3211 + TextMarker.prototype.clear = function() {
17.3212 + if (this.explicitlyCleared) return;
17.3213 + startOperation(this.cm);
17.3214 + var min = null, max = null;
17.3215 + for (var i = 0; i < this.lines.length; ++i) {
17.3216 + var line = this.lines[i];
17.3217 + var span = getMarkedSpanFor(line.markedSpans, this);
17.3218 + if (span.to != null) max = lineNo(line);
17.3219 + line.markedSpans = removeMarkedSpan(line.markedSpans, span);
17.3220 + if (span.from != null)
17.3221 + min = lineNo(line);
17.3222 + else if (this.collapsed && !lineIsHidden(line))
17.3223 + updateLineHeight(line, textHeight(this.cm.display));
17.3224 + }
17.3225 + if (min != null) regChange(this.cm, min, max + 1);
17.3226 + this.lines.length = 0;
17.3227 + this.explicitlyCleared = true;
17.3228 + if (this.collapsed && this.cm.view.cantEdit) {
17.3229 + this.cm.view.cantEdit = false;
17.3230 + reCheckSelection(this.cm);
17.3231 + }
17.3232 + endOperation(this.cm);
17.3233 + signalLater(this.cm, this, "clear");
17.3234 + };
17.3235 +
17.3236 + TextMarker.prototype.find = function() {
17.3237 + var from, to;
17.3238 + for (var i = 0; i < this.lines.length; ++i) {
17.3239 + var line = this.lines[i];
17.3240 + var span = getMarkedSpanFor(line.markedSpans, this);
17.3241 + if (span.from != null || span.to != null) {
17.3242 + var found = lineNo(line);
17.3243 + if (span.from != null) from = {line: found, ch: span.from};
17.3244 + if (span.to != null) to = {line: found, ch: span.to};
17.3245 + }
17.3246 + }
17.3247 + if (this.type == "bookmark") return from;
17.3248 + return from && {from: from, to: to};
17.3249 + };
17.3250 +
17.3251 + function markText(cm, from, to, options, type) {
17.3252 + var doc = cm.view.doc;
17.3253 + var marker = new TextMarker(cm, type);
17.3254 + if (type == "range" && !posLess(from, to)) return marker;
17.3255 + if (options) for (var opt in options) if (options.hasOwnProperty(opt))
17.3256 + marker[opt] = options[opt];
17.3257 + if (marker.replacedWith) {
17.3258 + marker.collapsed = true;
17.3259 + marker.replacedWith = elt("span", [marker.replacedWith], "CodeMirror-widget");
17.3260 + }
17.3261 + if (marker.collapsed) sawCollapsedSpans = true;
17.3262 +
17.3263 + var curLine = from.line, size = 0, collapsedAtStart, collapsedAtEnd;
17.3264 + doc.iter(curLine, to.line + 1, function(line) {
17.3265 + var span = {from: null, to: null, marker: marker};
17.3266 + size += line.text.length;
17.3267 + if (curLine == from.line) {span.from = from.ch; size -= from.ch;}
17.3268 + if (curLine == to.line) {span.to = to.ch; size -= line.text.length - to.ch;}
17.3269 + if (marker.collapsed) {
17.3270 + if (curLine == to.line) collapsedAtEnd = collapsedSpanAt(line, to.ch);
17.3271 + if (curLine == from.line) collapsedAtStart = collapsedSpanAt(line, from.ch);
17.3272 + else updateLineHeight(line, 0);
17.3273 + }
17.3274 + addMarkedSpan(line, span);
17.3275 + if (marker.collapsed && curLine == from.line && lineIsHidden(line))
17.3276 + updateLineHeight(line, 0);
17.3277 + ++curLine;
17.3278 + });
17.3279 +
17.3280 + if (marker.readOnly) {
17.3281 + sawReadOnlySpans = true;
17.3282 + if (cm.view.history.done.length || cm.view.history.undone.length)
17.3283 + cm.clearHistory();
17.3284 + }
17.3285 + if (marker.collapsed) {
17.3286 + if (collapsedAtStart != collapsedAtEnd)
17.3287 + throw new Error("Inserting collapsed marker overlapping an existing one");
17.3288 + marker.size = size;
17.3289 + marker.atomic = true;
17.3290 + }
17.3291 + if (marker.className || marker.startStyle || marker.endStyle || marker.collapsed)
17.3292 + regChange(cm, from.line, to.line + 1);
17.3293 + if (marker.atomic) reCheckSelection(cm);
17.3294 + return marker;
17.3295 + }
17.3296 +
17.3297 + // TEXTMARKER SPANS
17.3298 +
17.3299 + function getMarkedSpanFor(spans, marker) {
17.3300 + if (spans) for (var i = 0; i < spans.length; ++i) {
17.3301 + var span = spans[i];
17.3302 + if (span.marker == marker) return span;
17.3303 + }
17.3304 + }
17.3305 + function removeMarkedSpan(spans, span) {
17.3306 + for (var r, i = 0; i < spans.length; ++i)
17.3307 + if (spans[i] != span) (r || (r = [])).push(spans[i]);
17.3308 + return r;
17.3309 + }
17.3310 + function addMarkedSpan(line, span) {
17.3311 + line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
17.3312 + span.marker.lines.push(line);
17.3313 + }
17.3314 +
17.3315 + function markedSpansBefore(old, startCh) {
17.3316 + if (old) for (var i = 0, nw; i < old.length; ++i) {
17.3317 + var span = old[i], marker = span.marker;
17.3318 + var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
17.3319 + if (startsBefore || marker.type == "bookmark" && span.from == startCh) {
17.3320 + var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
17.3321 + (nw || (nw = [])).push({from: span.from,
17.3322 + to: endsAfter ? null : span.to,
17.3323 + marker: marker});
17.3324 + }
17.3325 + }
17.3326 + return nw;
17.3327 + }
17.3328 +
17.3329 + function markedSpansAfter(old, startCh, endCh) {
17.3330 + if (old) for (var i = 0, nw; i < old.length; ++i) {
17.3331 + var span = old[i], marker = span.marker;
17.3332 + var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
17.3333 + if (endsAfter || marker.type == "bookmark" && span.from == endCh && span.from != startCh) {
17.3334 + var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
17.3335 + (nw || (nw = [])).push({from: startsBefore ? null : span.from - endCh,
17.3336 + to: span.to == null ? null : span.to - endCh,
17.3337 + marker: marker});
17.3338 + }
17.3339 + }
17.3340 + return nw;
17.3341 + }
17.3342 +
17.3343 + function updateMarkedSpans(oldFirst, oldLast, startCh, endCh, newText) {
17.3344 + if (!oldFirst && !oldLast) return newText;
17.3345 + // Get the spans that 'stick out' on both sides
17.3346 + var first = markedSpansBefore(oldFirst, startCh);
17.3347 + var last = markedSpansAfter(oldLast, startCh, endCh);
17.3348 +
17.3349 + // Next, merge those two ends
17.3350 + var sameLine = newText.length == 1, offset = lst(newText).length + (sameLine ? startCh : 0);
17.3351 + if (first) {
17.3352 + // Fix up .to properties of first
17.3353 + for (var i = 0; i < first.length; ++i) {
17.3354 + var span = first[i];
17.3355 + if (span.to == null) {
17.3356 + var found = getMarkedSpanFor(last, span.marker);
17.3357 + if (!found) span.to = startCh;
17.3358 + else if (sameLine) span.to = found.to == null ? null : found.to + offset;
17.3359 + }
17.3360 + }
17.3361 + }
17.3362 + if (last) {
17.3363 + // Fix up .from in last (or move them into first in case of sameLine)
17.3364 + for (var i = 0; i < last.length; ++i) {
17.3365 + var span = last[i];
17.3366 + if (span.to != null) span.to += offset;
17.3367 + if (span.from == null) {
17.3368 + var found = getMarkedSpanFor(first, span.marker);
17.3369 + if (!found) {
17.3370 + span.from = offset;
17.3371 + if (sameLine) (first || (first = [])).push(span);
17.3372 + }
17.3373 + } else {
17.3374 + span.from += offset;
17.3375 + if (sameLine) (first || (first = [])).push(span);
17.3376 + }
17.3377 + }
17.3378 + }
17.3379 +
17.3380 + var newMarkers = [newHL(newText[0], first)];
17.3381 + if (!sameLine) {
17.3382 + // Fill gap with whole-line-spans
17.3383 + var gap = newText.length - 2, gapMarkers;
17.3384 + if (gap > 0 && first)
17.3385 + for (var i = 0; i < first.length; ++i)
17.3386 + if (first[i].to == null)
17.3387 + (gapMarkers || (gapMarkers = [])).push({from: null, to: null, marker: first[i].marker});
17.3388 + for (var i = 0; i < gap; ++i)
17.3389 + newMarkers.push(newHL(newText[i+1], gapMarkers));
17.3390 + newMarkers.push(newHL(lst(newText), last));
17.3391 + }
17.3392 + return newMarkers;
17.3393 + }
17.3394 +
17.3395 + function removeReadOnlyRanges(doc, from, to) {
17.3396 + var markers = null;
17.3397 + doc.iter(from.line, to.line + 1, function(line) {
17.3398 + if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
17.3399 + var mark = line.markedSpans[i].marker;
17.3400 + if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
17.3401 + (markers || (markers = [])).push(mark);
17.3402 + }
17.3403 + });
17.3404 + if (!markers) return null;
17.3405 + var parts = [{from: from, to: to}];
17.3406 + for (var i = 0; i < markers.length; ++i) {
17.3407 + var m = markers[i].find();
17.3408 + for (var j = 0; j < parts.length; ++j) {
17.3409 + var p = parts[j];
17.3410 + if (!posLess(m.from, p.to) || posLess(m.to, p.from)) continue;
17.3411 + var newParts = [j, 1];
17.3412 + if (posLess(p.from, m.from)) newParts.push({from: p.from, to: m.from});
17.3413 + if (posLess(m.to, p.to)) newParts.push({from: m.to, to: p.to});
17.3414 + parts.splice.apply(parts, newParts);
17.3415 + j += newParts.length - 1;
17.3416 + }
17.3417 + }
17.3418 + return parts;
17.3419 + }
17.3420 +
17.3421 + function collapsedSpanAt(line, ch) {
17.3422 + var sps = sawCollapsedSpans && line.markedSpans, found;
17.3423 + if (sps) for (var sp, i = 0; i < sps.length; ++i) {
17.3424 + sp = sps[i];
17.3425 + if (!sp.marker.collapsed) continue;
17.3426 + if ((sp.from == null || sp.from < ch) &&
17.3427 + (sp.to == null || sp.to > ch) &&
17.3428 + (!found || found.width < sp.marker.width))
17.3429 + found = sp.marker;
17.3430 + }
17.3431 + return found;
17.3432 + }
17.3433 + function collapsedSpanAtStart(line) { return collapsedSpanAt(line, -1); }
17.3434 + function collapsedSpanAtEnd(line) { return collapsedSpanAt(line, line.text.length + 1); }
17.3435 +
17.3436 + function visualLine(doc, line) {
17.3437 + var merged;
17.3438 + while (merged = collapsedSpanAtStart(line))
17.3439 + line = getLine(doc, merged.find().from.line);
17.3440 + return line;
17.3441 + }
17.3442 +
17.3443 + function lineIsHidden(line) {
17.3444 + var sps = sawCollapsedSpans && line.markedSpans;
17.3445 + if (sps) for (var sp, i = 0; i < sps.length; ++i) {
17.3446 + sp = sps[i];
17.3447 + if (!sp.marker.collapsed) continue;
17.3448 + if (sp.from == null) return true;
17.3449 + if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(line, sp))
17.3450 + return true;
17.3451 + }
17.3452 + }
17.3453 + window.lineIsHidden = lineIsHidden;
17.3454 + function lineIsHiddenInner(line, span) {
17.3455 + if (span.to == null || span.marker.inclusiveRight && span.to == line.text.length)
17.3456 + return true;
17.3457 + for (var sp, i = 0; i < line.markedSpans.length; ++i) {
17.3458 + sp = line.markedSpans[i];
17.3459 + if (sp.marker.collapsed && sp.from == span.to &&
17.3460 + (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
17.3461 + lineIsHiddenInner(line, sp)) return true;
17.3462 + }
17.3463 + }
17.3464 +
17.3465 + // hl stands for history-line, a data structure that can be either a
17.3466 + // string (line without markers) or a {text, markedSpans} object.
17.3467 + function hlText(val) { return typeof val == "string" ? val : val.text; }
17.3468 + function hlSpans(val) {
17.3469 + if (typeof val == "string") return null;
17.3470 + var spans = val.markedSpans, out = null;
17.3471 + for (var i = 0; i < spans.length; ++i) {
17.3472 + if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); }
17.3473 + else if (out) out.push(spans[i]);
17.3474 + }
17.3475 + return !out ? spans : out.length ? out : null;
17.3476 + }
17.3477 + function newHL(text, spans) { return spans ? {text: text, markedSpans: spans} : text; }
17.3478 +
17.3479 + function detachMarkedSpans(line) {
17.3480 + var spans = line.markedSpans;
17.3481 + if (!spans) return;
17.3482 + for (var i = 0; i < spans.length; ++i) {
17.3483 + var lines = spans[i].marker.lines;
17.3484 + var ix = indexOf(lines, line);
17.3485 + lines.splice(ix, 1);
17.3486 + }
17.3487 + line.markedSpans = null;
17.3488 + }
17.3489 +
17.3490 + function attachMarkedSpans(line, spans) {
17.3491 + if (!spans) return;
17.3492 + for (var i = 0; i < spans.length; ++i)
17.3493 + spans[i].marker.lines.push(line);
17.3494 + line.markedSpans = spans;
17.3495 + }
17.3496 +
17.3497 + // LINE DATA STRUCTURE
17.3498 +
17.3499 + // Line objects. These hold state related to a line, including
17.3500 + // highlighting info (the styles array).
17.3501 + function makeLine(text, markedSpans, height) {
17.3502 + var line = {text: text, height: height};
17.3503 + attachMarkedSpans(line, markedSpans);
17.3504 + if (lineIsHidden(line)) line.height = 0;
17.3505 + return line;
17.3506 + }
17.3507 +
17.3508 + function updateLine(cm, line, text, markedSpans) {
17.3509 + line.text = text;
17.3510 + line.stateAfter = line.styles = null;
17.3511 + if (line.order != null) line.order = null;
17.3512 + detachMarkedSpans(line);
17.3513 + attachMarkedSpans(line, markedSpans);
17.3514 + if (lineIsHidden(line)) line.height = 0;
17.3515 + else if (!line.height) line.height = textHeight(cm.display);
17.3516 + signalLater(cm, line, "change");
17.3517 + }
17.3518 +
17.3519 + function cleanUpLine(line) {
17.3520 + line.parent = null;
17.3521 + detachMarkedSpans(line);
17.3522 + }
17.3523 +
17.3524 + // Run the given mode's parser over a line, update the styles
17.3525 + // array, which contains alternating fragments of text and CSS
17.3526 + // classes.
17.3527 + function highlightLine(cm, line, state) {
17.3528 + var mode = cm.view.mode, flattenSpans = cm.options.flattenSpans;
17.3529 + var changed = !line.styles, pos = 0, curText = "", curStyle = null;
17.3530 + var stream = new StringStream(line.text, cm.options.tabSize), st = line.styles || (line.styles = []);
17.3531 + if (line.text == "" && mode.blankLine) mode.blankLine(state);
17.3532 + while (!stream.eol()) {
17.3533 + var style = mode.token(stream, state), substr = stream.current();
17.3534 + stream.start = stream.pos;
17.3535 + if (!flattenSpans || curStyle != style) {
17.3536 + if (curText) {
17.3537 + changed = changed || pos >= st.length || curText != st[pos] || curStyle != st[pos+1];
17.3538 + st[pos++] = curText; st[pos++] = curStyle;
17.3539 + }
17.3540 + curText = substr; curStyle = style;
17.3541 + } else curText = curText + substr;
17.3542 + // Give up when line is ridiculously long
17.3543 + if (stream.pos > 5000) break;
17.3544 + }
17.3545 + if (curText) {
17.3546 + changed = changed || pos >= st.length || curText != st[pos] || curStyle != st[pos+1];
17.3547 + st[pos++] = curText; st[pos++] = curStyle;
17.3548 + }
17.3549 + if (stream.pos > 5000) { st[pos++] = line.text.slice(stream.pos); st[pos++] = null; }
17.3550 + if (pos != st.length) { st.length = pos; changed = true; }
17.3551 + return changed;
17.3552 + }
17.3553 +
17.3554 + // Lightweight form of highlight -- proceed over this line and
17.3555 + // update state, but don't save a style array.
17.3556 + function processLine(cm, line, state) {
17.3557 + var mode = cm.view.mode;
17.3558 + var stream = new StringStream(line.text, cm.options.tabSize);
17.3559 + if (line.text == "" && mode.blankLine) mode.blankLine(state);
17.3560 + while (!stream.eol() && stream.pos <= 5000) {
17.3561 + mode.token(stream, state);
17.3562 + stream.start = stream.pos;
17.3563 + }
17.3564 + }
17.3565 +
17.3566 + var styleToClassCache = {};
17.3567 + function styleToClass(style) {
17.3568 + if (!style) return null;
17.3569 + return styleToClassCache[style] ||
17.3570 + (styleToClassCache[style] = "cm-" + style.replace(/ +/g, " cm-"));
17.3571 + }
17.3572 +
17.3573 + function lineContent(cm, realLine, measure) {
17.3574 + var merged, line = realLine, lineBefore, sawBefore, simple = true;
17.3575 + while (merged = collapsedSpanAtStart(line)) {
17.3576 + simple = false;
17.3577 + line = getLine(cm.view.doc, merged.find().from.line);
17.3578 + if (!lineBefore) lineBefore = line;
17.3579 + }
17.3580 +
17.3581 + var builder = {pre: elt("pre"), col: 0, pos: 0, display: !measure,
17.3582 + measure: null, addedOne: false, cm: cm};
17.3583 + if (line.textClass) builder.pre.className = line.textClass;
17.3584 +
17.3585 + do {
17.3586 + if (!line.styles)
17.3587 + highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line)));
17.3588 + builder.measure = line == realLine && measure;
17.3589 + builder.pos = 0;
17.3590 + builder.addToken = builder.measure ? buildTokenMeasure : buildToken;
17.3591 + if (measure && sawBefore && line != realLine && !builder.addedOne) {
17.3592 + measure[0] = builder.pre.appendChild(zeroWidthElement(cm.display.measure));
17.3593 + builder.addedOne = true;
17.3594 + }
17.3595 + var next = insertLineContent(line, builder);
17.3596 + sawBefore = line == lineBefore;
17.3597 + if (next) {
17.3598 + line = getLine(cm.view.doc, next.to.line);
17.3599 + simple = false;
17.3600 + }
17.3601 + } while (next);
17.3602 +
17.3603 + if (measure && !builder.addedOne)
17.3604 + measure[0] = builder.pre.appendChild(simple ? elt("span", "\u00a0") : zeroWidthElement(cm.display.measure));
17.3605 + if (!builder.pre.firstChild && !lineIsHidden(realLine))
17.3606 + builder.pre.appendChild(document.createTextNode("\u00a0"));
17.3607 +
17.3608 + return builder.pre;
17.3609 + }
17.3610 +
17.3611 + var tokenSpecialChars = /[\t\u0000-\u0019\u200b\u2028\u2029\uFEFF]/g;
17.3612 + function buildToken(builder, text, style, startStyle, endStyle) {
17.3613 + if (!text) return;
17.3614 + if (!tokenSpecialChars.test(text)) {
17.3615 + builder.col += text.length;
17.3616 + var content = document.createTextNode(text);
17.3617 + } else {
17.3618 + var content = document.createDocumentFragment(), pos = 0;
17.3619 + while (true) {
17.3620 + tokenSpecialChars.lastIndex = pos;
17.3621 + var m = tokenSpecialChars.exec(text);
17.3622 + var skipped = m ? m.index - pos : text.length - pos;
17.3623 + if (skipped) {
17.3624 + content.appendChild(document.createTextNode(text.slice(pos, pos + skipped)));
17.3625 + builder.col += skipped;
17.3626 + }
17.3627 + if (!m) break;
17.3628 + pos += skipped + 1;
17.3629 + if (m[0] == "\t") {
17.3630 + var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
17.3631 + content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
17.3632 + builder.col += tabWidth;
17.3633 + } else {
17.3634 + var token = elt("span", "\u2022", "cm-invalidchar");
17.3635 + token.title = "\\u" + m[0].charCodeAt(0).toString(16);
17.3636 + content.appendChild(token);
17.3637 + builder.col += 1;
17.3638 + }
17.3639 + }
17.3640 + }
17.3641 + if (style || startStyle || endStyle || builder.measure) {
17.3642 + var fullStyle = style || "";
17.3643 + if (startStyle) fullStyle += startStyle;
17.3644 + if (endStyle) fullStyle += endStyle;
17.3645 + return builder.pre.appendChild(elt("span", [content], fullStyle));
17.3646 + }
17.3647 + builder.pre.appendChild(content);
17.3648 + }
17.3649 +
17.3650 + function buildTokenMeasure(builder, text, style, startStyle, endStyle) {
17.3651 + for (var i = 0; i < text.length; ++i) {
17.3652 + if (i && i < text.length - 1 &&
17.3653 + builder.cm.options.lineWrapping &&
17.3654 + spanAffectsWrapping.test(text.slice(i - 1, i + 1)))
17.3655 + builder.pre.appendChild(elt("wbr"));
17.3656 + builder.measure[builder.pos++] =
17.3657 + buildToken(builder, text.charAt(i), style,
17.3658 + i == 0 && startStyle, i == text.length - 1 && endStyle);
17.3659 + }
17.3660 + if (text.length) builder.addedOne = true;
17.3661 + }
17.3662 +
17.3663 + function buildCollapsedSpan(builder, size, widget) {
17.3664 + if (widget) {
17.3665 + if (!builder.display) widget = widget.cloneNode(true);
17.3666 + builder.pre.appendChild(widget);
17.3667 + if (builder.measure && size) {
17.3668 + builder.measure[builder.pos] = widget;
17.3669 + builder.addedOne = true;
17.3670 + }
17.3671 + }
17.3672 + builder.pos += size;
17.3673 + }
17.3674 +
17.3675 + // Outputs a number of spans to make up a line, taking highlighting
17.3676 + // and marked text into account.
17.3677 + function insertLineContent(line, builder) {
17.3678 + var st = line.styles, spans = line.markedSpans;
17.3679 + if (!spans) {
17.3680 + for (var i = 0; i < st.length; i+=2)
17.3681 + builder.addToken(builder, st[i], styleToClass(st[i+1]));
17.3682 + return;
17.3683 + }
17.3684 +
17.3685 + var allText = line.text, len = allText.length;
17.3686 + var pos = 0, i = 0, text = "", style;
17.3687 + var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, collapsed;
17.3688 + for (;;) {
17.3689 + if (nextChange == pos) { // Update current marker set
17.3690 + spanStyle = spanEndStyle = spanStartStyle = "";
17.3691 + collapsed = null; nextChange = Infinity;
17.3692 + var foundBookmark = null;
17.3693 + for (var j = 0; j < spans.length; ++j) {
17.3694 + var sp = spans[j], m = sp.marker;
17.3695 + if (sp.from <= pos && (sp.to == null || sp.to > pos)) {
17.3696 + if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; }
17.3697 + if (m.className) spanStyle += " " + m.className;
17.3698 + if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
17.3699 + if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle;
17.3700 + if (m.collapsed && (!collapsed || collapsed.marker.width < m.width))
17.3701 + collapsed = sp;
17.3702 + } else if (sp.from > pos && nextChange > sp.from) {
17.3703 + nextChange = sp.from;
17.3704 + }
17.3705 + if (m.type == "bookmark" && sp.from == pos && m.replacedWith)
17.3706 + foundBookmark = m.replacedWith;
17.3707 + }
17.3708 + if (collapsed && (collapsed.from || 0) == pos) {
17.3709 + buildCollapsedSpan(builder, (collapsed.to == null ? len : collapsed.to) - pos,
17.3710 + collapsed.from != null && collapsed.marker.replacedWith);
17.3711 + if (collapsed.to == null) return collapsed.marker.find();
17.3712 + }
17.3713 + if (foundBookmark && !collapsed) buildCollapsedSpan(builder, 0, foundBookmark);
17.3714 + }
17.3715 + if (pos >= len) break;
17.3716 +
17.3717 + var upto = Math.min(len, nextChange);
17.3718 + while (true) {
17.3719 + if (text) {
17.3720 + var end = pos + text.length;
17.3721 + if (!collapsed) {
17.3722 + var tokenText = end > upto ? text.slice(0, upto - pos) : text;
17.3723 + builder.addToken(builder, tokenText, style + spanStyle,
17.3724 + spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "");
17.3725 + }
17.3726 + if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
17.3727 + pos = end;
17.3728 + spanStartStyle = "";
17.3729 + }
17.3730 + text = st[i++]; style = styleToClass(st[i++]);
17.3731 + }
17.3732 + }
17.3733 + }
17.3734 +
17.3735 + // DOCUMENT DATA STRUCTURE
17.3736 +
17.3737 + function LeafChunk(lines) {
17.3738 + this.lines = lines;
17.3739 + this.parent = null;
17.3740 + for (var i = 0, e = lines.length, height = 0; i < e; ++i) {
17.3741 + lines[i].parent = this;
17.3742 + height += lines[i].height;
17.3743 + }
17.3744 + this.height = height;
17.3745 + }
17.3746 +
17.3747 + LeafChunk.prototype = {
17.3748 + chunkSize: function() { return this.lines.length; },
17.3749 + remove: function(at, n, cm) {
17.3750 + for (var i = at, e = at + n; i < e; ++i) {
17.3751 + var line = this.lines[i];
17.3752 + this.height -= line.height;
17.3753 + cleanUpLine(line);
17.3754 + signalLater(cm, line, "delete");
17.3755 + }
17.3756 + this.lines.splice(at, n);
17.3757 + },
17.3758 + collapse: function(lines) {
17.3759 + lines.splice.apply(lines, [lines.length, 0].concat(this.lines));
17.3760 + },
17.3761 + insertHeight: function(at, lines, height) {
17.3762 + this.height += height;
17.3763 + this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
17.3764 + for (var i = 0, e = lines.length; i < e; ++i) lines[i].parent = this;
17.3765 + },
17.3766 + iterN: function(at, n, op) {
17.3767 + for (var e = at + n; at < e; ++at)
17.3768 + if (op(this.lines[at])) return true;
17.3769 + }
17.3770 + };
17.3771 +
17.3772 + function BranchChunk(children) {
17.3773 + this.children = children;
17.3774 + var size = 0, height = 0;
17.3775 + for (var i = 0, e = children.length; i < e; ++i) {
17.3776 + var ch = children[i];
17.3777 + size += ch.chunkSize(); height += ch.height;
17.3778 + ch.parent = this;
17.3779 + }
17.3780 + this.size = size;
17.3781 + this.height = height;
17.3782 + this.parent = null;
17.3783 + }
17.3784 +
17.3785 + BranchChunk.prototype = {
17.3786 + chunkSize: function() { return this.size; },
17.3787 + remove: function(at, n, callbacks) {
17.3788 + this.size -= n;
17.3789 + for (var i = 0; i < this.children.length; ++i) {
17.3790 + var child = this.children[i], sz = child.chunkSize();
17.3791 + if (at < sz) {
17.3792 + var rm = Math.min(n, sz - at), oldHeight = child.height;
17.3793 + child.remove(at, rm, callbacks);
17.3794 + this.height -= oldHeight - child.height;
17.3795 + if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
17.3796 + if ((n -= rm) == 0) break;
17.3797 + at = 0;
17.3798 + } else at -= sz;
17.3799 + }
17.3800 + if (this.size - n < 25) {
17.3801 + var lines = [];
17.3802 + this.collapse(lines);
17.3803 + this.children = [new LeafChunk(lines)];
17.3804 + this.children[0].parent = this;
17.3805 + }
17.3806 + },
17.3807 + collapse: function(lines) {
17.3808 + for (var i = 0, e = this.children.length; i < e; ++i) this.children[i].collapse(lines);
17.3809 + },
17.3810 + insert: function(at, lines) {
17.3811 + var height = 0;
17.3812 + for (var i = 0, e = lines.length; i < e; ++i) height += lines[i].height;
17.3813 + this.insertHeight(at, lines, height);
17.3814 + },
17.3815 + insertHeight: function(at, lines, height) {
17.3816 + this.size += lines.length;
17.3817 + this.height += height;
17.3818 + for (var i = 0, e = this.children.length; i < e; ++i) {
17.3819 + var child = this.children[i], sz = child.chunkSize();
17.3820 + if (at <= sz) {
17.3821 + child.insertHeight(at, lines, height);
17.3822 + if (child.lines && child.lines.length > 50) {
17.3823 + while (child.lines.length > 50) {
17.3824 + var spilled = child.lines.splice(child.lines.length - 25, 25);
17.3825 + var newleaf = new LeafChunk(spilled);
17.3826 + child.height -= newleaf.height;
17.3827 + this.children.splice(i + 1, 0, newleaf);
17.3828 + newleaf.parent = this;
17.3829 + }
17.3830 + this.maybeSpill();
17.3831 + }
17.3832 + break;
17.3833 + }
17.3834 + at -= sz;
17.3835 + }
17.3836 + },
17.3837 + maybeSpill: function() {
17.3838 + if (this.children.length <= 10) return;
17.3839 + var me = this;
17.3840 + do {
17.3841 + var spilled = me.children.splice(me.children.length - 5, 5);
17.3842 + var sibling = new BranchChunk(spilled);
17.3843 + if (!me.parent) { // Become the parent node
17.3844 + var copy = new BranchChunk(me.children);
17.3845 + copy.parent = me;
17.3846 + me.children = [copy, sibling];
17.3847 + me = copy;
17.3848 + } else {
17.3849 + me.size -= sibling.size;
17.3850 + me.height -= sibling.height;
17.3851 + var myIndex = indexOf(me.parent.children, me);
17.3852 + me.parent.children.splice(myIndex + 1, 0, sibling);
17.3853 + }
17.3854 + sibling.parent = me.parent;
17.3855 + } while (me.children.length > 10);
17.3856 + me.parent.maybeSpill();
17.3857 + },
17.3858 + iter: function(from, to, op) { this.iterN(from, to - from, op); },
17.3859 + iterN: function(at, n, op) {
17.3860 + for (var i = 0, e = this.children.length; i < e; ++i) {
17.3861 + var child = this.children[i], sz = child.chunkSize();
17.3862 + if (at < sz) {
17.3863 + var used = Math.min(n, sz - at);
17.3864 + if (child.iterN(at, used, op)) return true;
17.3865 + if ((n -= used) == 0) break;
17.3866 + at = 0;
17.3867 + } else at -= sz;
17.3868 + }
17.3869 + }
17.3870 + };
17.3871 +
17.3872 + // LINE UTILITIES
17.3873 +
17.3874 + function getLine(chunk, n) {
17.3875 + while (!chunk.lines) {
17.3876 + for (var i = 0;; ++i) {
17.3877 + var child = chunk.children[i], sz = child.chunkSize();
17.3878 + if (n < sz) { chunk = child; break; }
17.3879 + n -= sz;
17.3880 + }
17.3881 + }
17.3882 + return chunk.lines[n];
17.3883 + }
17.3884 +
17.3885 + function updateLineHeight(line, height) {
17.3886 + var diff = height - line.height;
17.3887 + for (var n = line; n; n = n.parent) n.height += diff;
17.3888 + }
17.3889 +
17.3890 + function lineNo(line) {
17.3891 + if (line.parent == null) return null;
17.3892 + var cur = line.parent, no = indexOf(cur.lines, line);
17.3893 + for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
17.3894 + for (var i = 0;; ++i) {
17.3895 + if (chunk.children[i] == cur) break;
17.3896 + no += chunk.children[i].chunkSize();
17.3897 + }
17.3898 + }
17.3899 + return no;
17.3900 + }
17.3901 +
17.3902 + function lineAtHeight(chunk, h) {
17.3903 + var n = 0;
17.3904 + outer: do {
17.3905 + for (var i = 0, e = chunk.children.length; i < e; ++i) {
17.3906 + var child = chunk.children[i], ch = child.height;
17.3907 + if (h < ch) { chunk = child; continue outer; }
17.3908 + h -= ch;
17.3909 + n += child.chunkSize();
17.3910 + }
17.3911 + return n;
17.3912 + } while (!chunk.lines);
17.3913 + for (var i = 0, e = chunk.lines.length; i < e; ++i) {
17.3914 + var line = chunk.lines[i], lh = line.height;
17.3915 + if (h < lh) break;
17.3916 + h -= lh;
17.3917 + }
17.3918 + return n + i;
17.3919 + }
17.3920 +
17.3921 + function heightAtLine(cm, lineObj) {
17.3922 + lineObj = visualLine(cm.view.doc, lineObj);
17.3923 +
17.3924 + var h = 0, chunk = lineObj.parent;
17.3925 + for (var i = 0; i < chunk.lines.length; ++i) {
17.3926 + var line = chunk.lines[i];
17.3927 + if (line == lineObj) break;
17.3928 + else h += line.height;
17.3929 + }
17.3930 + for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
17.3931 + for (var i = 0; i < p.children.length; ++i) {
17.3932 + var cur = p.children[i];
17.3933 + if (cur == chunk) break;
17.3934 + else h += cur.height;
17.3935 + }
17.3936 + }
17.3937 + return h;
17.3938 + }
17.3939 +
17.3940 + function getOrder(line) {
17.3941 + var order = line.order;
17.3942 + if (order == null) order = line.order = bidiOrdering(line.text);
17.3943 + return order;
17.3944 + }
17.3945 +
17.3946 + // HISTORY
17.3947 +
17.3948 + function makeHistory() {
17.3949 + return {
17.3950 + // Arrays of history events. Doing something adds an event to
17.3951 + // done and clears undo. Undoing moves events from done to
17.3952 + // undone, redoing moves them in the other direction.
17.3953 + done: [], undone: [],
17.3954 + // Used to track when changes can be merged into a single undo
17.3955 + // event
17.3956 + lastTime: 0, lastOp: null, lastOrigin: null,
17.3957 + // Used by the isClean() method
17.3958 + dirtyCounter: 0
17.3959 + };
17.3960 + }
17.3961 +
17.3962 + function addChange(cm, start, added, old, origin, fromBefore, toBefore, fromAfter, toAfter) {
17.3963 + var history = cm.view.history;
17.3964 + history.undone.length = 0;
17.3965 + var time = +new Date, cur = lst(history.done);
17.3966 +
17.3967 + if (cur &&
17.3968 + (history.lastOp == cm.curOp.id ||
17.3969 + history.lastOrigin == origin && (origin == "input" || origin == "delete") &&
17.3970 + history.lastTime > time - 600)) {
17.3971 + // Merge this change into the last event
17.3972 + var last = lst(cur.events);
17.3973 + if (last.start > start + old.length || last.start + last.added < start) {
17.3974 + // Doesn't intersect with last sub-event, add new sub-event
17.3975 + cur.events.push({start: start, added: added, old: old});
17.3976 + } else {
17.3977 + // Patch up the last sub-event
17.3978 + var startBefore = Math.max(0, last.start - start),
17.3979 + endAfter = Math.max(0, (start + old.length) - (last.start + last.added));
17.3980 + for (var i = startBefore; i > 0; --i) last.old.unshift(old[i - 1]);
17.3981 + for (var i = endAfter; i > 0; --i) last.old.push(old[old.length - i]);
17.3982 + if (startBefore) last.start = start;
17.3983 + last.added += added - (old.length - startBefore - endAfter);
17.3984 + }
17.3985 + cur.fromAfter = fromAfter; cur.toAfter = toAfter;
17.3986 + } else {
17.3987 + // Can not be merged, start a new event.
17.3988 + cur = {events: [{start: start, added: added, old: old}],
17.3989 + fromBefore: fromBefore, toBefore: toBefore, fromAfter: fromAfter, toAfter: toAfter};
17.3990 + history.done.push(cur);
17.3991 + while (history.done.length > cm.options.undoDepth)
17.3992 + history.done.shift();
17.3993 + if (history.dirtyCounter < 0)
17.3994 + // The user has made a change after undoing past the last clean state.
17.3995 + // We can never get back to a clean state now until markClean() is called.
17.3996 + history.dirtyCounter = NaN;
17.3997 + else
17.3998 + history.dirtyCounter++;
17.3999 + }
17.4000 + history.lastTime = time;
17.4001 + history.lastOp = cm.curOp.id;
17.4002 + history.lastOrigin = origin;
17.4003 + }
17.4004 +
17.4005 + // EVENT OPERATORS
17.4006 +
17.4007 + function stopMethod() {e_stop(this);}
17.4008 + // Ensure an event has a stop method.
17.4009 + function addStop(event) {
17.4010 + if (!event.stop) event.stop = stopMethod;
17.4011 + return event;
17.4012 + }
17.4013 +
17.4014 + function e_preventDefault(e) {
17.4015 + if (e.preventDefault) e.preventDefault();
17.4016 + else e.returnValue = false;
17.4017 + }
17.4018 + function e_stopPropagation(e) {
17.4019 + if (e.stopPropagation) e.stopPropagation();
17.4020 + else e.cancelBubble = true;
17.4021 + }
17.4022 + function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);}
17.4023 + CodeMirror.e_stop = e_stop;
17.4024 + CodeMirror.e_preventDefault = e_preventDefault;
17.4025 + CodeMirror.e_stopPropagation = e_stopPropagation;
17.4026 +
17.4027 + function e_target(e) {return e.target || e.srcElement;}
17.4028 + function e_button(e) {
17.4029 + var b = e.which;
17.4030 + if (b == null) {
17.4031 + if (e.button & 1) b = 1;
17.4032 + else if (e.button & 2) b = 3;
17.4033 + else if (e.button & 4) b = 2;
17.4034 + }
17.4035 + if (mac && e.ctrlKey && b == 1) b = 3;
17.4036 + return b;
17.4037 + }
17.4038 +
17.4039 + // Allow 3rd-party code to override event properties by adding an override
17.4040 + // object to an event object.
17.4041 + function e_prop(e, prop) {
17.4042 + var overridden = e.override && e.override.hasOwnProperty(prop);
17.4043 + return overridden ? e.override[prop] : e[prop];
17.4044 + }
17.4045 +
17.4046 + // EVENT HANDLING
17.4047 +
17.4048 + function on(emitter, type, f) {
17.4049 + if (emitter.addEventListener)
17.4050 + emitter.addEventListener(type, f, false);
17.4051 + else if (emitter.attachEvent)
17.4052 + emitter.attachEvent("on" + type, f);
17.4053 + else {
17.4054 + var map = emitter._handlers || (emitter._handlers = {});
17.4055 + var arr = map[type] || (map[type] = []);
17.4056 + arr.push(f);
17.4057 + }
17.4058 + }
17.4059 +
17.4060 + function off(emitter, type, f) {
17.4061 + if (emitter.removeEventListener)
17.4062 + emitter.removeEventListener(type, f, false);
17.4063 + else if (emitter.detachEvent)
17.4064 + emitter.detachEvent("on" + type, f);
17.4065 + else {
17.4066 + var arr = emitter._handlers && emitter._handlers[type];
17.4067 + if (!arr) return;
17.4068 + for (var i = 0; i < arr.length; ++i)
17.4069 + if (arr[i] == f) { arr.splice(i, 1); break; }
17.4070 + }
17.4071 + }
17.4072 +
17.4073 + function signal(emitter, type /*, values...*/) {
17.4074 + var arr = emitter._handlers && emitter._handlers[type];
17.4075 + if (!arr) return;
17.4076 + var args = Array.prototype.slice.call(arguments, 2);
17.4077 + for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args);
17.4078 + }
17.4079 +
17.4080 + function signalLater(cm, emitter, type /*, values...*/) {
17.4081 + var arr = emitter._handlers && emitter._handlers[type];
17.4082 + if (!arr) return;
17.4083 + var args = Array.prototype.slice.call(arguments, 3), flist = cm.curOp && cm.curOp.delayedCallbacks;
17.4084 + function bnd(f) {return function(){f.apply(null, args);};};
17.4085 + for (var i = 0; i < arr.length; ++i)
17.4086 + if (flist) flist.push(bnd(arr[i]));
17.4087 + else arr[i].apply(null, args);
17.4088 + }
17.4089 +
17.4090 + function hasHandler(emitter, type) {
17.4091 + var arr = emitter._handlers && emitter._handlers[type];
17.4092 + return arr && arr.length > 0;
17.4093 + }
17.4094 +
17.4095 + CodeMirror.on = on; CodeMirror.off = off; CodeMirror.signal = signal;
17.4096 +
17.4097 + // MISC UTILITIES
17.4098 +
17.4099 + // Number of pixels added to scroller and sizer to hide scrollbar
17.4100 + var scrollerCutOff = 30;
17.4101 +
17.4102 + // Returned or thrown by various protocols to signal 'I'm not
17.4103 + // handling this'.
17.4104 + var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
17.4105 +
17.4106 + function Delayed() {this.id = null;}
17.4107 + Delayed.prototype = {set: function(ms, f) {clearTimeout(this.id); this.id = setTimeout(f, ms);}};
17.4108 +
17.4109 + // Counts the column offset in a string, taking tabs into account.
17.4110 + // Used mostly to find indentation.
17.4111 + function countColumn(string, end, tabSize) {
17.4112 + if (end == null) {
17.4113 + end = string.search(/[^\s\u00a0]/);
17.4114 + if (end == -1) end = string.length;
17.4115 + }
17.4116 + for (var i = 0, n = 0; i < end; ++i) {
17.4117 + if (string.charAt(i) == "\t") n += tabSize - (n % tabSize);
17.4118 + else ++n;
17.4119 + }
17.4120 + return n;
17.4121 + }
17.4122 + CodeMirror.countColumn = countColumn;
17.4123 +
17.4124 + var spaceStrs = [""];
17.4125 + function spaceStr(n) {
17.4126 + while (spaceStrs.length <= n)
17.4127 + spaceStrs.push(lst(spaceStrs) + " ");
17.4128 + return spaceStrs[n];
17.4129 + }
17.4130 +
17.4131 + function lst(arr) { return arr[arr.length-1]; }
17.4132 +
17.4133 + function selectInput(node) {
17.4134 + if (ios) { // Mobile Safari apparently has a bug where select() is broken.
17.4135 + node.selectionStart = 0;
17.4136 + node.selectionEnd = node.value.length;
17.4137 + } else node.select();
17.4138 + }
17.4139 +
17.4140 + function indexOf(collection, elt) {
17.4141 + if (collection.indexOf) return collection.indexOf(elt);
17.4142 + for (var i = 0, e = collection.length; i < e; ++i)
17.4143 + if (collection[i] == elt) return i;
17.4144 + return -1;
17.4145 + }
17.4146 +
17.4147 + function emptyArray(size) {
17.4148 + for (var a = [], i = 0; i < size; ++i) a.push(undefined);
17.4149 + return a;
17.4150 + }
17.4151 +
17.4152 + function bind(f) {
17.4153 + var args = Array.prototype.slice.call(arguments, 1);
17.4154 + return function(){return f.apply(null, args);};
17.4155 + }
17.4156 +
17.4157 + var nonASCIISingleCaseWordChar = /[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc]/;
17.4158 + function isWordChar(ch) {
17.4159 + return /\w/.test(ch) || ch > "\x80" &&
17.4160 + (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
17.4161 + }
17.4162 +
17.4163 + function isEmpty(obj) {
17.4164 + var c = 0;
17.4165 + for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) ++c;
17.4166 + return !c;
17.4167 + }
17.4168 +
17.4169 + var isExtendingChar = /[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\uA670-\uA672\uA674-\uA67D\uA69F]/;
17.4170 +
17.4171 + // DOM UTILITIES
17.4172 +
17.4173 + function elt(tag, content, className, style) {
17.4174 + var e = document.createElement(tag);
17.4175 + if (className) e.className = className;
17.4176 + if (style) e.style.cssText = style;
17.4177 + if (typeof content == "string") setTextContent(e, content);
17.4178 + else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
17.4179 + return e;
17.4180 + }
17.4181 +
17.4182 + function removeChildren(e) {
17.4183 + e.innerHTML = "";
17.4184 + return e;
17.4185 + }
17.4186 +
17.4187 + function removeChildrenAndAdd(parent, e) {
17.4188 + return removeChildren(parent).appendChild(e);
17.4189 + }
17.4190 +
17.4191 + function setTextContent(e, str) {
17.4192 + if (ie_lt9) {
17.4193 + e.innerHTML = "";
17.4194 + e.appendChild(document.createTextNode(str));
17.4195 + } else e.textContent = str;
17.4196 + }
17.4197 +
17.4198 + // FEATURE DETECTION
17.4199 +
17.4200 + // Detect drag-and-drop
17.4201 + var dragAndDrop = function() {
17.4202 + // There is *some* kind of drag-and-drop support in IE6-8, but I
17.4203 + // couldn't get it to work yet.
17.4204 + if (ie_lt9) return false;
17.4205 + var div = elt('div');
17.4206 + return "draggable" in div || "dragDrop" in div;
17.4207 + }();
17.4208 +
17.4209 + // For a reason I have yet to figure out, some browsers disallow
17.4210 + // word wrapping between certain characters *only* if a new inline
17.4211 + // element is started between them. This makes it hard to reliably
17.4212 + // measure the position of things, since that requires inserting an
17.4213 + // extra span. This terribly fragile set of regexps matches the
17.4214 + // character combinations that suffer from this phenomenon on the
17.4215 + // various browsers.
17.4216 + var spanAffectsWrapping = /^$/; // Won't match any two-character string
17.4217 + if (gecko) spanAffectsWrapping = /$'/;
17.4218 + else if (safari) spanAffectsWrapping = /\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/;
17.4219 + else if (chrome) spanAffectsWrapping = /\-[^ \-\.?]|\?[^ \-\.?\]\}:;!'\"\),\/]|[\.!\"#&%\)*+,:;=>\]|\}~][\(\{\[<]|\$'/;
17.4220 +
17.4221 + var knownScrollbarWidth;
17.4222 + function scrollbarWidth(measure) {
17.4223 + if (knownScrollbarWidth != null) return knownScrollbarWidth;
17.4224 + var test = elt("div", null, null, "width: 50px; height: 50px; overflow-x: scroll");
17.4225 + removeChildrenAndAdd(measure, test);
17.4226 + if (test.offsetWidth)
17.4227 + knownScrollbarWidth = test.offsetHeight - test.clientHeight;
17.4228 + return knownScrollbarWidth || 0;
17.4229 + }
17.4230 +
17.4231 + var zwspSupported;
17.4232 + function zeroWidthElement(measure) {
17.4233 + if (zwspSupported == null) {
17.4234 + var test = elt("span", "\u200b");
17.4235 + removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
17.4236 + if (measure.firstChild.offsetHeight != 0)
17.4237 + zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !ie_lt8;
17.4238 + }
17.4239 + if (zwspSupported) return elt("span", "\u200b");
17.4240 + else return elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
17.4241 + }
17.4242 +
17.4243 + // See if "".split is the broken IE version, if so, provide an
17.4244 + // alternative way to split lines.
17.4245 + var splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
17.4246 + var pos = 0, result = [], l = string.length;
17.4247 + while (pos <= l) {
17.4248 + var nl = string.indexOf("\n", pos);
17.4249 + if (nl == -1) nl = string.length;
17.4250 + var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
17.4251 + var rt = line.indexOf("\r");
17.4252 + if (rt != -1) {
17.4253 + result.push(line.slice(0, rt));
17.4254 + pos += rt + 1;
17.4255 + } else {
17.4256 + result.push(line);
17.4257 + pos = nl + 1;
17.4258 + }
17.4259 + }
17.4260 + return result;
17.4261 + } : function(string){return string.split(/\r\n?|\n/);};
17.4262 + CodeMirror.splitLines = splitLines;
17.4263 +
17.4264 + var hasSelection = window.getSelection ? function(te) {
17.4265 + try { return te.selectionStart != te.selectionEnd; }
17.4266 + catch(e) { return false; }
17.4267 + } : function(te) {
17.4268 + try {var range = te.ownerDocument.selection.createRange();}
17.4269 + catch(e) {}
17.4270 + if (!range || range.parentElement() != te) return false;
17.4271 + return range.compareEndPoints("StartToEnd", range) != 0;
17.4272 + };
17.4273 +
17.4274 + var hasCopyEvent = (function() {
17.4275 + var e = elt("div");
17.4276 + if ("oncopy" in e) return true;
17.4277 + e.setAttribute("oncopy", "return;");
17.4278 + return typeof e.oncopy == 'function';
17.4279 + })();
17.4280 +
17.4281 + // KEY NAMING
17.4282 +
17.4283 + var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
17.4284 + 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
17.4285 + 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
17.4286 + 46: "Delete", 59: ";", 91: "Mod", 92: "Mod", 93: "Mod", 109: "-", 107: "=", 127: "Delete",
17.4287 + 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
17.4288 + 221: "]", 222: "'", 63276: "PageUp", 63277: "PageDown", 63275: "End", 63273: "Home",
17.4289 + 63234: "Left", 63232: "Up", 63235: "Right", 63233: "Down", 63302: "Insert", 63272: "Delete"};
17.4290 + CodeMirror.keyNames = keyNames;
17.4291 + (function() {
17.4292 + // Number keys
17.4293 + for (var i = 0; i < 10; i++) keyNames[i + 48] = String(i);
17.4294 + // Alphabetic keys
17.4295 + for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i);
17.4296 + // Function keys
17.4297 + for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
17.4298 + })();
17.4299 +
17.4300 + // BIDI HELPERS
17.4301 +
17.4302 + function iterateBidiSections(order, from, to, f) {
17.4303 + if (!order) return f(from, to, "ltr");
17.4304 + for (var i = 0; i < order.length; ++i) {
17.4305 + var part = order[i];
17.4306 + if (part.from < to && part.to > from)
17.4307 + f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr");
17.4308 + }
17.4309 + }
17.4310 +
17.4311 + function bidiLeft(part) { return part.level % 2 ? part.to : part.from; }
17.4312 + function bidiRight(part) { return part.level % 2 ? part.from : part.to; }
17.4313 +
17.4314 + function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; }
17.4315 + function lineRight(line) {
17.4316 + var order = getOrder(line);
17.4317 + if (!order) return line.text.length;
17.4318 + return bidiRight(lst(order));
17.4319 + }
17.4320 +
17.4321 + function lineStart(cm, lineN) {
17.4322 + var line = getLine(cm.view.doc, lineN);
17.4323 + var visual = visualLine(cm.view.doc, line);
17.4324 + if (visual != line) lineN = lineNo(visual);
17.4325 + var order = getOrder(visual);
17.4326 + var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual);
17.4327 + return {line: lineN, ch: ch};
17.4328 + }
17.4329 + function lineEnd(cm, lineNo) {
17.4330 + var merged, line;
17.4331 + while (merged = collapsedSpanAtEnd(line = getLine(cm.view.doc, lineNo)))
17.4332 + lineNo = merged.find().to.line;
17.4333 + var order = getOrder(line);
17.4334 + var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line);
17.4335 + return {line: lineNo, ch: ch};
17.4336 + }
17.4337 +
17.4338 + // This is somewhat involved. It is needed in order to move
17.4339 + // 'visually' through bi-directional text -- i.e., pressing left
17.4340 + // should make the cursor go left, even when in RTL text. The
17.4341 + // tricky part is the 'jumps', where RTL and LTR text touch each
17.4342 + // other. This often requires the cursor offset to move more than
17.4343 + // one unit, in order to visually move one unit.
17.4344 + function moveVisually(line, start, dir, byUnit) {
17.4345 + var bidi = getOrder(line);
17.4346 + if (!bidi) return moveLogically(line, start, dir, byUnit);
17.4347 + var moveOneUnit = byUnit ? function(pos, dir) {
17.4348 + do pos += dir;
17.4349 + while (pos > 0 && isExtendingChar.test(line.text.charAt(pos)));
17.4350 + return pos;
17.4351 + } : function(pos, dir) { return pos + dir; };
17.4352 + var linedir = bidi[0].level;
17.4353 + for (var i = 0; i < bidi.length; ++i) {
17.4354 + var part = bidi[i], sticky = part.level % 2 == linedir;
17.4355 + if ((part.from < start && part.to > start) ||
17.4356 + (sticky && (part.from == start || part.to == start))) break;
17.4357 + }
17.4358 + var target = moveOneUnit(start, part.level % 2 ? -dir : dir);
17.4359 +
17.4360 + while (target != null) {
17.4361 + if (part.level % 2 == linedir) {
17.4362 + if (target < part.from || target > part.to) {
17.4363 + part = bidi[i += dir];
17.4364 + target = part && (dir > 0 == part.level % 2 ? moveOneUnit(part.to, -1) : moveOneUnit(part.from, 1));
17.4365 + } else break;
17.4366 + } else {
17.4367 + if (target == bidiLeft(part)) {
17.4368 + part = bidi[--i];
17.4369 + target = part && bidiRight(part);
17.4370 + } else if (target == bidiRight(part)) {
17.4371 + part = bidi[++i];
17.4372 + target = part && bidiLeft(part);
17.4373 + } else break;
17.4374 + }
17.4375 + }
17.4376 +
17.4377 + return target < 0 || target > line.text.length ? null : target;
17.4378 + }
17.4379 +
17.4380 + function moveLogically(line, start, dir, byUnit) {
17.4381 + var target = start + dir;
17.4382 + if (byUnit) while (target > 0 && isExtendingChar.test(line.text.charAt(target))) target += dir;
17.4383 + return target < 0 || target > line.text.length ? null : target;
17.4384 + }
17.4385 +
17.4386 + // Bidirectional ordering algorithm
17.4387 + // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
17.4388 + // that this (partially) implements.
17.4389 +
17.4390 + // One-char codes used for character types:
17.4391 + // L (L): Left-to-Right
17.4392 + // R (R): Right-to-Left
17.4393 + // r (AL): Right-to-Left Arabic
17.4394 + // 1 (EN): European Number
17.4395 + // + (ES): European Number Separator
17.4396 + // % (ET): European Number Terminator
17.4397 + // n (AN): Arabic Number
17.4398 + // , (CS): Common Number Separator
17.4399 + // m (NSM): Non-Spacing Mark
17.4400 + // b (BN): Boundary Neutral
17.4401 + // s (B): Paragraph Separator
17.4402 + // t (S): Segment Separator
17.4403 + // w (WS): Whitespace
17.4404 + // N (ON): Other Neutrals
17.4405 +
17.4406 + // Returns null if characters are ordered as they appear
17.4407 + // (left-to-right), or an array of sections ({from, to, level}
17.4408 + // objects) in the order in which they occur visually.
17.4409 + var bidiOrdering = (function() {
17.4410 + // Character types for codepoints 0 to 0xff
17.4411 + var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL";
17.4412 + // Character types for codepoints 0x600 to 0x6ff
17.4413 + var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr";
17.4414 + function charType(code) {
17.4415 + if (code <= 0xff) return lowTypes.charAt(code);
17.4416 + else if (0x590 <= code && code <= 0x5f4) return "R";
17.4417 + else if (0x600 <= code && code <= 0x6ff) return arabicTypes.charAt(code - 0x600);
17.4418 + else if (0x700 <= code && code <= 0x8ac) return "r";
17.4419 + else return "L";
17.4420 + }
17.4421 +
17.4422 + var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
17.4423 + var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
17.4424 +
17.4425 + return function charOrdering(str) {
17.4426 + if (!bidiRE.test(str)) return false;
17.4427 + var len = str.length, types = [], startType = null;
17.4428 + for (var i = 0, type; i < len; ++i) {
17.4429 + types.push(type = charType(str.charCodeAt(i)));
17.4430 + if (startType == null) {
17.4431 + if (type == "L") startType = "L";
17.4432 + else if (type == "R" || type == "r") startType = "R";
17.4433 + }
17.4434 + }
17.4435 + if (startType == null) startType = "L";
17.4436 +
17.4437 + // W1. Examine each non-spacing mark (NSM) in the level run, and
17.4438 + // change the type of the NSM to the type of the previous
17.4439 + // character. If the NSM is at the start of the level run, it will
17.4440 + // get the type of sor.
17.4441 + for (var i = 0, prev = startType; i < len; ++i) {
17.4442 + var type = types[i];
17.4443 + if (type == "m") types[i] = prev;
17.4444 + else prev = type;
17.4445 + }
17.4446 +
17.4447 + // W2. Search backwards from each instance of a European number
17.4448 + // until the first strong type (R, L, AL, or sor) is found. If an
17.4449 + // AL is found, change the type of the European number to Arabic
17.4450 + // number.
17.4451 + // W3. Change all ALs to R.
17.4452 + for (var i = 0, cur = startType; i < len; ++i) {
17.4453 + var type = types[i];
17.4454 + if (type == "1" && cur == "r") types[i] = "n";
17.4455 + else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; }
17.4456 + }
17.4457 +
17.4458 + // W4. A single European separator between two European numbers
17.4459 + // changes to a European number. A single common separator between
17.4460 + // two numbers of the same type changes to that type.
17.4461 + for (var i = 1, prev = types[0]; i < len - 1; ++i) {
17.4462 + var type = types[i];
17.4463 + if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1";
17.4464 + else if (type == "," && prev == types[i+1] &&
17.4465 + (prev == "1" || prev == "n")) types[i] = prev;
17.4466 + prev = type;
17.4467 + }
17.4468 +
17.4469 + // W5. A sequence of European terminators adjacent to European
17.4470 + // numbers changes to all European numbers.
17.4471 + // W6. Otherwise, separators and terminators change to Other
17.4472 + // Neutral.
17.4473 + for (var i = 0; i < len; ++i) {
17.4474 + var type = types[i];
17.4475 + if (type == ",") types[i] = "N";
17.4476 + else if (type == "%") {
17.4477 + for (var end = i + 1; end < len && types[end] == "%"; ++end) {}
17.4478 + var replace = (i && types[i-1] == "!") || (end < len - 1 && types[end] == "1") ? "1" : "N";
17.4479 + for (var j = i; j < end; ++j) types[j] = replace;
17.4480 + i = end - 1;
17.4481 + }
17.4482 + }
17.4483 +
17.4484 + // W7. Search backwards from each instance of a European number
17.4485 + // until the first strong type (R, L, or sor) is found. If an L is
17.4486 + // found, then change the type of the European number to L.
17.4487 + for (var i = 0, cur = startType; i < len; ++i) {
17.4488 + var type = types[i];
17.4489 + if (cur == "L" && type == "1") types[i] = "L";
17.4490 + else if (isStrong.test(type)) cur = type;
17.4491 + }
17.4492 +
17.4493 + // N1. A sequence of neutrals takes the direction of the
17.4494 + // surrounding strong text if the text on both sides has the same
17.4495 + // direction. European and Arabic numbers act as if they were R in
17.4496 + // terms of their influence on neutrals. Start-of-level-run (sor)
17.4497 + // and end-of-level-run (eor) are used at level run boundaries.
17.4498 + // N2. Any remaining neutrals take the embedding direction.
17.4499 + for (var i = 0; i < len; ++i) {
17.4500 + if (isNeutral.test(types[i])) {
17.4501 + for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {}
17.4502 + var before = (i ? types[i-1] : startType) == "L";
17.4503 + var after = (end < len - 1 ? types[end] : startType) == "L";
17.4504 + var replace = before || after ? "L" : "R";
17.4505 + for (var j = i; j < end; ++j) types[j] = replace;
17.4506 + i = end - 1;
17.4507 + }
17.4508 + }
17.4509 +
17.4510 + // Here we depart from the documented algorithm, in order to avoid
17.4511 + // building up an actual levels array. Since there are only three
17.4512 + // levels (0, 1, 2) in an implementation that doesn't take
17.4513 + // explicit embedding into account, we can build up the order on
17.4514 + // the fly, without following the level-based algorithm.
17.4515 + var order = [], m;
17.4516 + for (var i = 0; i < len;) {
17.4517 + if (countsAsLeft.test(types[i])) {
17.4518 + var start = i;
17.4519 + for (++i; i < len && countsAsLeft.test(types[i]); ++i) {}
17.4520 + order.push({from: start, to: i, level: 0});
17.4521 + } else {
17.4522 + var pos = i, at = order.length;
17.4523 + for (++i; i < len && types[i] != "L"; ++i) {}
17.4524 + for (var j = pos; j < i;) {
17.4525 + if (countsAsNum.test(types[j])) {
17.4526 + if (pos < j) order.splice(at, 0, {from: pos, to: j, level: 1});
17.4527 + var nstart = j;
17.4528 + for (++j; j < i && countsAsNum.test(types[j]); ++j) {}
17.4529 + order.splice(at, 0, {from: nstart, to: j, level: 2});
17.4530 + pos = j;
17.4531 + } else ++j;
17.4532 + }
17.4533 + if (pos < i) order.splice(at, 0, {from: pos, to: i, level: 1});
17.4534 + }
17.4535 + }
17.4536 + if (order[0].level == 1 && (m = str.match(/^\s+/))) {
17.4537 + order[0].from = m[0].length;
17.4538 + order.unshift({from: 0, to: m[0].length, level: 0});
17.4539 + }
17.4540 + if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
17.4541 + lst(order).to -= m[0].length;
17.4542 + order.push({from: len - m[0].length, to: len, level: 0});
17.4543 + }
17.4544 + if (order[0].level != lst(order).level)
17.4545 + order.push({from: len, to: len, level: order[0].level});
17.4546 +
17.4547 + return order;
17.4548 + };
17.4549 + })();
17.4550 +
17.4551 + // THE END
17.4552 +
17.4553 + CodeMirror.version = "3.0";
17.4554 +
17.4555 + return CodeMirror;
17.4556 +})();
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2 +++ b/dew/src/main/resources/org/apidesign/bck2brwsr/dew/js/codemirror/mode/clike.js Wed Jan 23 14:16:13 2013 +0100
18.3 @@ -0,0 +1,300 @@
18.4 +CodeMirror.defineMode("clike", function(config, parserConfig) {
18.5 + var indentUnit = config.indentUnit,
18.6 + statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
18.7 + keywords = parserConfig.keywords || {},
18.8 + builtin = parserConfig.builtin || {},
18.9 + blockKeywords = parserConfig.blockKeywords || {},
18.10 + atoms = parserConfig.atoms || {},
18.11 + hooks = parserConfig.hooks || {},
18.12 + multiLineStrings = parserConfig.multiLineStrings;
18.13 + var isOperatorChar = /[+\-*&%=<>!?|\/]/;
18.14 +
18.15 + var curPunc;
18.16 +
18.17 + function tokenBase(stream, state) {
18.18 + var ch = stream.next();
18.19 + if (hooks[ch]) {
18.20 + var result = hooks[ch](stream, state);
18.21 + if (result !== false) return result;
18.22 + }
18.23 + if (ch == '"' || ch == "'") {
18.24 + state.tokenize = tokenString(ch);
18.25 + return state.tokenize(stream, state);
18.26 + }
18.27 + if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
18.28 + curPunc = ch;
18.29 + return null;
18.30 + }
18.31 + if (/\d/.test(ch)) {
18.32 + stream.eatWhile(/[\w\.]/);
18.33 + return "number";
18.34 + }
18.35 + if (ch == "/") {
18.36 + if (stream.eat("*")) {
18.37 + state.tokenize = tokenComment;
18.38 + return tokenComment(stream, state);
18.39 + }
18.40 + if (stream.eat("/")) {
18.41 + stream.skipToEnd();
18.42 + return "comment";
18.43 + }
18.44 + }
18.45 + if (isOperatorChar.test(ch)) {
18.46 + stream.eatWhile(isOperatorChar);
18.47 + return "operator";
18.48 + }
18.49 + stream.eatWhile(/[\w\$_]/);
18.50 + var cur = stream.current();
18.51 + if (keywords.propertyIsEnumerable(cur)) {
18.52 + if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
18.53 + return "keyword";
18.54 + }
18.55 + if (builtin.propertyIsEnumerable(cur)) {
18.56 + if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
18.57 + return "builtin";
18.58 + }
18.59 + if (atoms.propertyIsEnumerable(cur)) return "atom";
18.60 + return "variable";
18.61 + }
18.62 +
18.63 + function tokenString(quote) {
18.64 + return function(stream, state) {
18.65 + var escaped = false, next, end = false;
18.66 + while ((next = stream.next()) != null) {
18.67 + if (next == quote && !escaped) {end = true; break;}
18.68 + escaped = !escaped && next == "\\";
18.69 + }
18.70 + if (end || !(escaped || multiLineStrings))
18.71 + state.tokenize = null;
18.72 + return "string";
18.73 + };
18.74 + }
18.75 +
18.76 + function tokenComment(stream, state) {
18.77 + var maybeEnd = false, ch;
18.78 + while (ch = stream.next()) {
18.79 + if (ch == "/" && maybeEnd) {
18.80 + state.tokenize = null;
18.81 + break;
18.82 + }
18.83 + maybeEnd = (ch == "*");
18.84 + }
18.85 + return "comment";
18.86 + }
18.87 +
18.88 + function Context(indented, column, type, align, prev) {
18.89 + this.indented = indented;
18.90 + this.column = column;
18.91 + this.type = type;
18.92 + this.align = align;
18.93 + this.prev = prev;
18.94 + }
18.95 + function pushContext(state, col, type) {
18.96 + var indent = state.indented;
18.97 + if (state.context && state.context.type == "statement")
18.98 + indent = state.context.indented;
18.99 + return state.context = new Context(indent, col, type, null, state.context);
18.100 + }
18.101 + function popContext(state) {
18.102 + var t = state.context.type;
18.103 + if (t == ")" || t == "]" || t == "}")
18.104 + state.indented = state.context.indented;
18.105 + return state.context = state.context.prev;
18.106 + }
18.107 +
18.108 + // Interface
18.109 +
18.110 + return {
18.111 + startState: function(basecolumn) {
18.112 + return {
18.113 + tokenize: null,
18.114 + context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
18.115 + indented: 0,
18.116 + startOfLine: true
18.117 + };
18.118 + },
18.119 +
18.120 + token: function(stream, state) {
18.121 + var ctx = state.context;
18.122 + if (stream.sol()) {
18.123 + if (ctx.align == null) ctx.align = false;
18.124 + state.indented = stream.indentation();
18.125 + state.startOfLine = true;
18.126 + }
18.127 + if (stream.eatSpace()) return null;
18.128 + curPunc = null;
18.129 + var style = (state.tokenize || tokenBase)(stream, state);
18.130 + if (style == "comment" || style == "meta") return style;
18.131 + if (ctx.align == null) ctx.align = true;
18.132 +
18.133 + if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
18.134 + else if (curPunc == "{") pushContext(state, stream.column(), "}");
18.135 + else if (curPunc == "[") pushContext(state, stream.column(), "]");
18.136 + else if (curPunc == "(") pushContext(state, stream.column(), ")");
18.137 + else if (curPunc == "}") {
18.138 + while (ctx.type == "statement") ctx = popContext(state);
18.139 + if (ctx.type == "}") ctx = popContext(state);
18.140 + while (ctx.type == "statement") ctx = popContext(state);
18.141 + }
18.142 + else if (curPunc == ctx.type) popContext(state);
18.143 + else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
18.144 + pushContext(state, stream.column(), "statement");
18.145 + state.startOfLine = false;
18.146 + return style;
18.147 + },
18.148 +
18.149 + indent: function(state, textAfter) {
18.150 + if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
18.151 + var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
18.152 + if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
18.153 + var closing = firstChar == ctx.type;
18.154 + if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
18.155 + else if (ctx.align) return ctx.column + (closing ? 0 : 1);
18.156 + else return ctx.indented + (closing ? 0 : indentUnit);
18.157 + },
18.158 +
18.159 + electricChars: "{}"
18.160 + };
18.161 +});
18.162 +
18.163 +(function() {
18.164 + function words(str) {
18.165 + var obj = {}, words = str.split(" ");
18.166 + for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
18.167 + return obj;
18.168 + }
18.169 + var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
18.170 + "double static else struct entry switch extern typedef float union for unsigned " +
18.171 + "goto while enum void const signed volatile";
18.172 +
18.173 + function cppHook(stream, state) {
18.174 + if (!state.startOfLine) return false;
18.175 + for (;;) {
18.176 + if (stream.skipTo("\\")) {
18.177 + stream.next();
18.178 + if (stream.eol()) {
18.179 + state.tokenize = cppHook;
18.180 + break;
18.181 + }
18.182 + } else {
18.183 + stream.skipToEnd();
18.184 + state.tokenize = null;
18.185 + break;
18.186 + }
18.187 + }
18.188 + return "meta";
18.189 + }
18.190 +
18.191 + // C#-style strings where "" escapes a quote.
18.192 + function tokenAtString(stream, state) {
18.193 + var next;
18.194 + while ((next = stream.next()) != null) {
18.195 + if (next == '"' && !stream.eat('"')) {
18.196 + state.tokenize = null;
18.197 + break;
18.198 + }
18.199 + }
18.200 + return "string";
18.201 + }
18.202 +
18.203 + function mimes(ms, mode) {
18.204 + for (var i = 0; i < ms.length; ++i) CodeMirror.defineMIME(ms[i], mode);
18.205 + }
18.206 +
18.207 + mimes(["text/x-csrc", "text/x-c", "text/x-chdr"], {
18.208 + name: "clike",
18.209 + keywords: words(cKeywords),
18.210 + blockKeywords: words("case do else for if switch while struct"),
18.211 + atoms: words("null"),
18.212 + hooks: {"#": cppHook}
18.213 + });
18.214 + mimes(["text/x-c++src", "text/x-c++hdr"], {
18.215 + name: "clike",
18.216 + keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
18.217 + "static_cast typeid catch operator template typename class friend private " +
18.218 + "this using const_cast inline public throw virtual delete mutable protected " +
18.219 + "wchar_t"),
18.220 + blockKeywords: words("catch class do else finally for if struct switch try while"),
18.221 + atoms: words("true false null"),
18.222 + hooks: {"#": cppHook}
18.223 + });
18.224 + CodeMirror.defineMIME("text/x-java", {
18.225 + name: "clike",
18.226 + keywords: words("abstract assert boolean break byte case catch char class const continue default " +
18.227 + "do double else enum extends final finally float for goto if implements import " +
18.228 + "instanceof int interface long native new package private protected public " +
18.229 + "return short static strictfp super switch synchronized this throw throws transient " +
18.230 + "try void volatile while"),
18.231 + blockKeywords: words("catch class do else finally for if switch try while"),
18.232 + atoms: words("true false null"),
18.233 + hooks: {
18.234 + "@": function(stream) {
18.235 + stream.eatWhile(/[\w\$_]/);
18.236 + return "meta";
18.237 + }
18.238 + }
18.239 + });
18.240 + CodeMirror.defineMIME("text/x-csharp", {
18.241 + name: "clike",
18.242 + keywords: words("abstract as base break case catch checked class const continue" +
18.243 + " default delegate do else enum event explicit extern finally fixed for" +
18.244 + " foreach goto if implicit in interface internal is lock namespace new" +
18.245 + " operator out override params private protected public readonly ref return sealed" +
18.246 + " sizeof stackalloc static struct switch this throw try typeof unchecked" +
18.247 + " unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
18.248 + " global group into join let orderby partial remove select set value var yield"),
18.249 + blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
18.250 + builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" +
18.251 + " Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32" +
18.252 + " UInt64 bool byte char decimal double short int long object" +
18.253 + " sbyte float string ushort uint ulong"),
18.254 + atoms: words("true false null"),
18.255 + hooks: {
18.256 + "@": function(stream, state) {
18.257 + if (stream.eat('"')) {
18.258 + state.tokenize = tokenAtString;
18.259 + return tokenAtString(stream, state);
18.260 + }
18.261 + stream.eatWhile(/[\w\$_]/);
18.262 + return "meta";
18.263 + }
18.264 + }
18.265 + });
18.266 + CodeMirror.defineMIME("text/x-scala", {
18.267 + name: "clike",
18.268 + keywords: words(
18.269 +
18.270 + /* scala */
18.271 + "abstract case catch class def do else extends false final finally for forSome if " +
18.272 + "implicit import lazy match new null object override package private protected return " +
18.273 + "sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
18.274 + "<% >: # @ " +
18.275 +
18.276 + /* package scala */
18.277 + "assert assume require print println printf readLine readBoolean readByte readShort " +
18.278 + "readChar readInt readLong readFloat readDouble " +
18.279 +
18.280 + "AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
18.281 + "Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
18.282 + "Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
18.283 + "Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
18.284 + "StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
18.285 +
18.286 + /* package java.lang */
18.287 + "Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
18.288 + "Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
18.289 + "Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
18.290 + "StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
18.291 +
18.292 +
18.293 + ),
18.294 + blockKeywords: words("catch class do else finally for forSome if match switch try while"),
18.295 + atoms: words("true false null"),
18.296 + hooks: {
18.297 + "@": function(stream) {
18.298 + stream.eatWhile(/[\w\$_]/);
18.299 + return "meta";
18.300 + }
18.301 + }
18.302 + });
18.303 +}());
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2 +++ b/dew/src/main/resources/org/apidesign/bck2brwsr/dew/js/codemirror/mode/xml.js Wed Jan 23 14:16:13 2013 +0100
19.3 @@ -0,0 +1,324 @@
19.4 +CodeMirror.defineMode("xml", function(config, parserConfig) {
19.5 + var indentUnit = config.indentUnit;
19.6 + var Kludges = parserConfig.htmlMode ? {
19.7 + autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
19.8 + 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
19.9 + 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
19.10 + 'track': true, 'wbr': true},
19.11 + implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
19.12 + 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
19.13 + 'th': true, 'tr': true},
19.14 + contextGrabbers: {
19.15 + 'dd': {'dd': true, 'dt': true},
19.16 + 'dt': {'dd': true, 'dt': true},
19.17 + 'li': {'li': true},
19.18 + 'option': {'option': true, 'optgroup': true},
19.19 + 'optgroup': {'optgroup': true},
19.20 + 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
19.21 + 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
19.22 + 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
19.23 + 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
19.24 + 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
19.25 + 'rp': {'rp': true, 'rt': true},
19.26 + 'rt': {'rp': true, 'rt': true},
19.27 + 'tbody': {'tbody': true, 'tfoot': true},
19.28 + 'td': {'td': true, 'th': true},
19.29 + 'tfoot': {'tbody': true},
19.30 + 'th': {'td': true, 'th': true},
19.31 + 'thead': {'tbody': true, 'tfoot': true},
19.32 + 'tr': {'tr': true}
19.33 + },
19.34 + doNotIndent: {"pre": true},
19.35 + allowUnquoted: true,
19.36 + allowMissing: true
19.37 + } : {
19.38 + autoSelfClosers: {},
19.39 + implicitlyClosed: {},
19.40 + contextGrabbers: {},
19.41 + doNotIndent: {},
19.42 + allowUnquoted: false,
19.43 + allowMissing: false
19.44 + };
19.45 + var alignCDATA = parserConfig.alignCDATA;
19.46 +
19.47 + // Return variables for tokenizers
19.48 + var tagName, type;
19.49 +
19.50 + function inText(stream, state) {
19.51 + function chain(parser) {
19.52 + state.tokenize = parser;
19.53 + return parser(stream, state);
19.54 + }
19.55 +
19.56 + var ch = stream.next();
19.57 + if (ch == "<") {
19.58 + if (stream.eat("!")) {
19.59 + if (stream.eat("[")) {
19.60 + if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
19.61 + else return null;
19.62 + }
19.63 + else if (stream.match("--")) return chain(inBlock("comment", "-->"));
19.64 + else if (stream.match("DOCTYPE", true, true)) {
19.65 + stream.eatWhile(/[\w\._\-]/);
19.66 + return chain(doctype(1));
19.67 + }
19.68 + else return null;
19.69 + }
19.70 + else if (stream.eat("?")) {
19.71 + stream.eatWhile(/[\w\._\-]/);
19.72 + state.tokenize = inBlock("meta", "?>");
19.73 + return "meta";
19.74 + }
19.75 + else {
19.76 + var isClose = stream.eat("/");
19.77 + tagName = "";
19.78 + var c;
19.79 + while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
19.80 + if (!tagName) return "error";
19.81 + type = isClose ? "closeTag" : "openTag";
19.82 + state.tokenize = inTag;
19.83 + return "tag";
19.84 + }
19.85 + }
19.86 + else if (ch == "&") {
19.87 + var ok;
19.88 + if (stream.eat("#")) {
19.89 + if (stream.eat("x")) {
19.90 + ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
19.91 + } else {
19.92 + ok = stream.eatWhile(/[\d]/) && stream.eat(";");
19.93 + }
19.94 + } else {
19.95 + ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
19.96 + }
19.97 + return ok ? "atom" : "error";
19.98 + }
19.99 + else {
19.100 + stream.eatWhile(/[^&<]/);
19.101 + return null;
19.102 + }
19.103 + }
19.104 +
19.105 + function inTag(stream, state) {
19.106 + var ch = stream.next();
19.107 + if (ch == ">" || (ch == "/" && stream.eat(">"))) {
19.108 + state.tokenize = inText;
19.109 + type = ch == ">" ? "endTag" : "selfcloseTag";
19.110 + return "tag";
19.111 + }
19.112 + else if (ch == "=") {
19.113 + type = "equals";
19.114 + return null;
19.115 + }
19.116 + else if (/[\'\"]/.test(ch)) {
19.117 + state.tokenize = inAttribute(ch);
19.118 + return state.tokenize(stream, state);
19.119 + }
19.120 + else {
19.121 + stream.eatWhile(/[^\s\u00a0=<>\"\']/);
19.122 + return "word";
19.123 + }
19.124 + }
19.125 +
19.126 + function inAttribute(quote) {
19.127 + return function(stream, state) {
19.128 + while (!stream.eol()) {
19.129 + if (stream.next() == quote) {
19.130 + state.tokenize = inTag;
19.131 + break;
19.132 + }
19.133 + }
19.134 + return "string";
19.135 + };
19.136 + }
19.137 +
19.138 + function inBlock(style, terminator) {
19.139 + return function(stream, state) {
19.140 + while (!stream.eol()) {
19.141 + if (stream.match(terminator)) {
19.142 + state.tokenize = inText;
19.143 + break;
19.144 + }
19.145 + stream.next();
19.146 + }
19.147 + return style;
19.148 + };
19.149 + }
19.150 + function doctype(depth) {
19.151 + return function(stream, state) {
19.152 + var ch;
19.153 + while ((ch = stream.next()) != null) {
19.154 + if (ch == "<") {
19.155 + state.tokenize = doctype(depth + 1);
19.156 + return state.tokenize(stream, state);
19.157 + } else if (ch == ">") {
19.158 + if (depth == 1) {
19.159 + state.tokenize = inText;
19.160 + break;
19.161 + } else {
19.162 + state.tokenize = doctype(depth - 1);
19.163 + return state.tokenize(stream, state);
19.164 + }
19.165 + }
19.166 + }
19.167 + return "meta";
19.168 + };
19.169 + }
19.170 +
19.171 + var curState, setStyle;
19.172 + function pass() {
19.173 + for (var i = arguments.length - 1; i >= 0; i--) curState.cc.push(arguments[i]);
19.174 + }
19.175 + function cont() {
19.176 + pass.apply(null, arguments);
19.177 + return true;
19.178 + }
19.179 +
19.180 + function pushContext(tagName, startOfLine) {
19.181 + var noIndent = Kludges.doNotIndent.hasOwnProperty(tagName) || (curState.context && curState.context.noIndent);
19.182 + curState.context = {
19.183 + prev: curState.context,
19.184 + tagName: tagName,
19.185 + indent: curState.indented,
19.186 + startOfLine: startOfLine,
19.187 + noIndent: noIndent
19.188 + };
19.189 + }
19.190 + function popContext() {
19.191 + if (curState.context) curState.context = curState.context.prev;
19.192 + }
19.193 +
19.194 + function element(type) {
19.195 + if (type == "openTag") {
19.196 + curState.tagName = tagName;
19.197 + return cont(attributes, endtag(curState.startOfLine));
19.198 + } else if (type == "closeTag") {
19.199 + var err = false;
19.200 + if (curState.context) {
19.201 + if (curState.context.tagName != tagName) {
19.202 + if (Kludges.implicitlyClosed.hasOwnProperty(curState.context.tagName.toLowerCase())) {
19.203 + popContext();
19.204 + }
19.205 + err = !curState.context || curState.context.tagName != tagName;
19.206 + }
19.207 + } else {
19.208 + err = true;
19.209 + }
19.210 + if (err) setStyle = "error";
19.211 + return cont(endclosetag(err));
19.212 + }
19.213 + return cont();
19.214 + }
19.215 + function endtag(startOfLine) {
19.216 + return function(type) {
19.217 + var tagName = curState.tagName;
19.218 + curState.tagName = null;
19.219 + if (type == "selfcloseTag" ||
19.220 + (type == "endTag" && Kludges.autoSelfClosers.hasOwnProperty(tagName.toLowerCase()))) {
19.221 + maybePopContext(tagName.toLowerCase());
19.222 + return cont();
19.223 + }
19.224 + if (type == "endTag") {
19.225 + maybePopContext(tagName.toLowerCase());
19.226 + pushContext(tagName, startOfLine);
19.227 + return cont();
19.228 + }
19.229 + return cont();
19.230 + };
19.231 + }
19.232 + function endclosetag(err) {
19.233 + return function(type) {
19.234 + if (err) setStyle = "error";
19.235 + if (type == "endTag") { popContext(); return cont(); }
19.236 + setStyle = "error";
19.237 + return cont(arguments.callee);
19.238 + };
19.239 + }
19.240 + function maybePopContext(nextTagName) {
19.241 + var parentTagName;
19.242 + while (true) {
19.243 + if (!curState.context) {
19.244 + return;
19.245 + }
19.246 + parentTagName = curState.context.tagName.toLowerCase();
19.247 + if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
19.248 + !Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
19.249 + return;
19.250 + }
19.251 + popContext();
19.252 + }
19.253 + }
19.254 +
19.255 + function attributes(type) {
19.256 + if (type == "word") {setStyle = "attribute"; return cont(attribute, attributes);}
19.257 + if (type == "endTag" || type == "selfcloseTag") return pass();
19.258 + setStyle = "error";
19.259 + return cont(attributes);
19.260 + }
19.261 + function attribute(type) {
19.262 + if (type == "equals") return cont(attvalue, attributes);
19.263 + if (!Kludges.allowMissing) setStyle = "error";
19.264 + else if (type == "word") setStyle = "attribute";
19.265 + return (type == "endTag" || type == "selfcloseTag") ? pass() : cont();
19.266 + }
19.267 + function attvalue(type) {
19.268 + if (type == "string") return cont(attvaluemaybe);
19.269 + if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return cont();}
19.270 + setStyle = "error";
19.271 + return (type == "endTag" || type == "selfCloseTag") ? pass() : cont();
19.272 + }
19.273 + function attvaluemaybe(type) {
19.274 + if (type == "string") return cont(attvaluemaybe);
19.275 + else return pass();
19.276 + }
19.277 +
19.278 + return {
19.279 + startState: function() {
19.280 + return {tokenize: inText, cc: [], indented: 0, startOfLine: true, tagName: null, context: null};
19.281 + },
19.282 +
19.283 + token: function(stream, state) {
19.284 + if (stream.sol()) {
19.285 + state.startOfLine = true;
19.286 + state.indented = stream.indentation();
19.287 + }
19.288 + if (stream.eatSpace()) return null;
19.289 +
19.290 + setStyle = type = tagName = null;
19.291 + var style = state.tokenize(stream, state);
19.292 + state.type = type;
19.293 + if ((style || type) && style != "comment") {
19.294 + curState = state;
19.295 + while (true) {
19.296 + var comb = state.cc.pop() || element;
19.297 + if (comb(type || style)) break;
19.298 + }
19.299 + }
19.300 + state.startOfLine = false;
19.301 + return setStyle || style;
19.302 + },
19.303 +
19.304 + indent: function(state, textAfter, fullLine) {
19.305 + var context = state.context;
19.306 + if ((state.tokenize != inTag && state.tokenize != inText) ||
19.307 + context && context.noIndent)
19.308 + return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
19.309 + if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
19.310 + if (context && /^<\//.test(textAfter))
19.311 + context = context.prev;
19.312 + while (context && !context.startOfLine)
19.313 + context = context.prev;
19.314 + if (context) return context.indent + indentUnit;
19.315 + else return 0;
19.316 + },
19.317 +
19.318 + electricChars: "/",
19.319 +
19.320 + configuration: parserConfig.htmlMode ? "html" : "xml"
19.321 + };
19.322 +});
19.323 +
19.324 +CodeMirror.defineMIME("text/xml", "xml");
19.325 +CodeMirror.defineMIME("application/xml", "xml");
19.326 +if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
19.327 + CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/dew/src/main/resources/org/apidesign/bck2brwsr/dew/js/codemirror/theme/elegant.css Wed Jan 23 14:16:13 2013 +0100
20.3 @@ -0,0 +1,10 @@
20.4 +.cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom {color: #762;}
20.5 +.cm-s-elegant span.cm-comment {color: #262; font-style: italic; line-height: 1em;}
20.6 +.cm-s-elegant span.cm-meta {color: #555; font-style: italic; line-height: 1em;}
20.7 +.cm-s-elegant span.cm-variable {color: black;}
20.8 +.cm-s-elegant span.cm-variable-2 {color: #b11;}
20.9 +.cm-s-elegant span.cm-qualifier {color: #555;}
20.10 +.cm-s-elegant span.cm-keyword {color: #730;}
20.11 +.cm-s-elegant span.cm-builtin {color: #30a;}
20.12 +.cm-s-elegant span.cm-error {background-color: #fdd;}
20.13 +.cm-s-elegant span.cm-link {color: #762;}
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2 +++ b/dew/src/main/resources/org/apidesign/bck2brwsr/launcher/harness.xhtml Wed Jan 23 14:16:13 2013 +0100
21.3 @@ -0,0 +1,41 @@
21.4 +<?xml version="1.0" encoding="UTF-8"?>
21.5 +<!--
21.6 +
21.7 + Back 2 Browser Bytecode Translator
21.8 + Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
21.9 +
21.10 + This program is free software: you can redistribute it and/or modify
21.11 + it under the terms of the GNU General Public License as published by
21.12 + the Free Software Foundation, version 2 of the License.
21.13 +
21.14 + This program is distributed in the hope that it will be useful,
21.15 + but WITHOUT ANY WARRANTY; without even the implied warranty of
21.16 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21.17 + GNU General Public License for more details.
21.18 +
21.19 + You should have received a copy of the GNU General Public License
21.20 + along with this program. Look for COPYING file in the top folder.
21.21 + If not, see http://opensource.org/licenses/GPL-2.0.
21.22 +
21.23 +-->
21.24 +<!DOCTYPE html>
21.25 +<html xmlns="http://www.w3.org/1999/xhtml">
21.26 + <head>
21.27 + <title>Bck2Brwsr Harness</title>
21.28 + </head>
21.29 + <body>
21.30 + <script src="/bck2brwsr.js"></script>
21.31 + <script src="/vm.js"></script>
21.32 +
21.33 + <h1>Bck2Brwsr Execution Harness</h1>
21.34 +
21.35 + <textarea id="bck2brwsr.result" rows="25" style="width: 100%;" disabled="">
21.36 + </textarea>
21.37 +
21.38 + <div id="bck2brwsr.fragment"/>
21.39 +
21.40 + <script type="text/javascript">
21.41 + vm.loadClass('org.apidesign.bck2brwsr.launcher.Console').harness__VLjava_lang_String_2('$U/../data');
21.42 + </script>
21.43 + </body>
21.44 +</html>
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2 +++ b/dew/src/test/java/org/apidesign/bck2brwsr/dew/CompileTest.java Wed Jan 23 14:16:13 2013 +0100
22.3 @@ -0,0 +1,45 @@
22.4 +/**
22.5 + * Back 2 Browser Bytecode Translator
22.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
22.7 + *
22.8 + * This program is free software: you can redistribute it and/or modify
22.9 + * it under the terms of the GNU General Public License as published by
22.10 + * the Free Software Foundation, version 2 of the License.
22.11 + *
22.12 + * This program is distributed in the hope that it will be useful,
22.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
22.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22.15 + * GNU General Public License for more details.
22.16 + *
22.17 + * You should have received a copy of the GNU General Public License
22.18 + * along with this program. Look for COPYING file in the top folder.
22.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
22.20 + */
22.21 +package org.apidesign.bck2brwsr.dew;
22.22 +
22.23 +import java.io.IOException;
22.24 +import static org.testng.Assert.*;
22.25 +import org.testng.annotations.Test;
22.26 +
22.27 +/**
22.28 + *
22.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
22.30 + */
22.31 +public class CompileTest {
22.32 + @Test public void testCompile() throws IOException {
22.33 + String html = "<html><body>"
22.34 + + " <button id='btn'>Hello!</button>"
22.35 + + "</body></html>";
22.36 + String java = "package x.y.z;"
22.37 + + "import org.apidesign.bck2brwsr.htmlpage.api.*;"
22.38 + + "import static org.apidesign.bck2brwsr.htmlpage.api.OnEvent.*;"
22.39 + + "@Page(xhtml=\"index.html\", className=\"Index\")"
22.40 + + "class X { "
22.41 + + " @On(event=CLICK, id=\"btn\") static void clcs() {}"
22.42 + + "}";
22.43 + Compile result = Compile.create(html, java);
22.44 +
22.45 + assertNotNull(result.get("x/y/z/X.class"), "Class X is compiled: " + result);
22.46 + assertNotNull(result.get("x/y/z/Index.class"), "Class Index is compiled: " + result);
22.47 + }
22.48 +}
23.1 --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Wed Jan 23 12:04:49 2013 +0100
23.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Wed Jan 23 14:16:13 2013 +0100
23.3 @@ -70,6 +70,9 @@
23.4 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
23.5 for (Element e : roundEnv.getElementsAnnotatedWith(Page.class)) {
23.6 Page p = e.getAnnotation(Page.class);
23.7 + if (p == null) {
23.8 + continue;
23.9 + }
23.10 PackageElement pe = (PackageElement)e.getEnclosingElement();
23.11 String pkg = pe.getQualifiedName().toString();
23.12
24.1 --- a/pom.xml Wed Jan 23 12:04:49 2013 +0100
24.2 +++ b/pom.xml Wed Jan 23 14:16:13 2013 +0100
24.3 @@ -10,6 +10,7 @@
24.4 <module>vm</module>
24.5 <module>emul</module>
24.6 <module>core</module>
24.7 + <module>dew</module>
24.8 <module>mojo</module>
24.9 <module>javaquery</module>
24.10 <module>javap</module>
24.11 @@ -74,6 +75,7 @@
24.12 <exclude>*</exclude>
24.13 <exclude>.*/**</exclude>
24.14 <exclude>mojo/src/main/resources/archetype-resources/**</exclude>
24.15 + <exclude>dew/src/main/resources/org/apidesign/bck2brwsr/dew/**</exclude>
24.16 <exclude>vmtest/src/test/resources/**</exclude>
24.17 <exclude>javaquery/api/src/main/resources/org/apidesign/bck2brwsr/htmlpage/knockout*.js</exclude>
24.18 </excludes>